| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- class flow_custxiaoClassModel extends flowModel
- {
- public $minwidth = 600;//子表最小宽
- public $goodsobj,$custractobj,$crmobj;
-
- public function initModel()
- {
- $this->goodsobj = m('goods');
- $this->custractobj = m('custract');
- $this->crmobj = m('crm');
- }
-
- public function flowxiangfields(&$fields)
- {
- $fields['base_name'] = '销售人';
- $fields['base_deptname'] = '销售人部门';
- $fields['base_sericnum'] = '销售单号';
- return $fields;
- }
-
- public function flowsearchfields()
- {
- $arr[] = array('name'=>'销售人...','fields'=>'uid');
- return $arr;
- }
-
- protected function flowsubmit($na, $sm)
- {
- $num = $this->sericnum;
- $this->update(array('num'=>$num),$this->id);
- m('custfina')->update("`htnum`='$num'", "`htid`='-".$this->id."'");
- }
-
- //子表数据替换处理
- protected function flowsubdata($rows, $lx=0){
- $db = m('goods');
- foreach($rows as $k=>$rs){
- $one = $db->getone($rs['aid']);
- if($one){
- $name = $one['name'];
- if(!isempt($one['xinghao']))$name.='('.$one['xinghao'].')';
- if($lx==1)$rows[$k]['aid'] = $name; //1展示时
- $rows[$k]['temp_aid'] = $name;
- }
- }
- return $rows;
- }
-
- //作废或删除时
- protected function flowzuofeibill($sm)
- {
- $this->custractobj->update('`xiaoid`=0', "`xiaoid`='".$this->id."'");//合同取消关联销售单
-
- $this->update('`custractid`=0', $this->id);//取消关联合同
-
- //删除关联收付款单
- $this->deletebilljoin('custfina',"`htid`='-".$this->id."'", $sm);
-
- //删除出库详情的
- m('goodss')->delete("`mid`='$this->id'");
- }
-
- //$lx,0默认,1详情展示,2列表显示
- public function flowrsreplace($rs, $lx=0)
- {
- $rs['states']= $rs['state'];
- $rs['state'] = $this->goodsobj->crkstate($rs['state'],1);
- //读取物品
- if($lx==2){
- $rs['wupinlist'] = $this->goodsobj->getgoodninfo($rs['id'], 1);
- }
-
- $custractid = (int)$rs['custractid'];
-
- //读取收款状态
- $dsmoney = '';
- if($custractid>0){
-
- //从合同那读取
- $htrs = $this->custractobj->getone('`id`='.$custractid.' and `status`<>5');
- if($htrs){
- $custractid = $htrs['num'];//读取合同编号
- if($lx==1)$custractid = '<a href="'.$this->getxiangurl('custract',$rs['custractid'],'auto').'">'.$custractid.'</a>';
-
- $nrss = $this->crmobj->ractmoney($htrs);
- $ispay = $nrss[0];
- $moneys = $nrss[1];
-
- if($ispay==1){
- $dsmoney = '<font color=green>已全部收款</font>';
- }else{
- $dsmoney = '待收<font color=#ff6600>'.$moneys.'</font>';
- }
-
- }else{
- $custractid = 0;//不存在
- $this->update('`custractid`='.$custractid.'', $rs['id']);
- }
- }
-
-
- if($custractid===0){
- $custractid = '<font color=#aaaaaa>无关联</a>';
- $dsmoney = $this->crmobj->xiaozhuantai($rs);
- }
- $rs['custractid'] = $custractid;
- $rs['shoukuzt'] = $dsmoney;
-
-
- return $rs;
- }
- }
|