custxiaoModel.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. class flow_custxiaoClassModel extends flowModel
  3. {
  4. public $minwidth = 600;//子表最小宽
  5. public function initModel()
  6. {
  7. $this->goodsobj = m('goods');
  8. $this->custractobj = m('custract');
  9. $this->crmobj = m('crm');
  10. }
  11. public function flowxiangfields(&$fields)
  12. {
  13. $fields['base_name'] = '销售人';
  14. $fields['base_deptname'] = '销售人部门';
  15. $fields['base_sericnum'] = '销售单号';
  16. return $fields;
  17. }
  18. public function flowsearchfields()
  19. {
  20. $arr[] = array('name'=>'销售人...','fields'=>'uid');
  21. return $arr;
  22. }
  23. protected function flowsubmit($na, $sm)
  24. {
  25. $num = $this->sericnum;
  26. $this->update(array('num'=>$num),$this->id);
  27. m('custfina')->update("`htnum`='$num'", "`htid`='-".$this->id."'");
  28. }
  29. //子表数据替换处理
  30. protected function flowsubdata($rows, $lx=0){
  31. $db = m('goods');
  32. foreach($rows as $k=>$rs){
  33. $one = $db->getone($rs['aid']);
  34. if($one){
  35. $name = $one['name'];
  36. if(!isempt($one['xinghao']))$name.='('.$one['xinghao'].')';
  37. if($lx==1)$rows[$k]['aid'] = $name; //1展示时
  38. $rows[$k]['temp_aid'] = $name;
  39. }
  40. }
  41. return $rows;
  42. }
  43. //作废或删除时
  44. protected function flowzuofeibill($sm)
  45. {
  46. $this->custractobj->update('`xiaoid`=0', "`xiaoid`='".$this->id."'");//合同取消关联销售单
  47. $this->update('`custractid`=0', $this->id);//取消关联合同
  48. //删除关联收付款单
  49. $this->deletebilljoin('custfina',"`htid`='-".$this->id."'", $sm);
  50. //删除出库详情的
  51. m('goodss')->delete("`mid`='$this->id'");
  52. }
  53. //$lx,0默认,1详情展示,2列表显示
  54. public function flowrsreplace($rs, $lx=0)
  55. {
  56. $rs['states']= $rs['state'];
  57. $rs['state'] = $this->goodsobj->crkstate($rs['state'],1);
  58. //读取物品
  59. if($lx==2){
  60. $rs['wupinlist'] = $this->goodsobj->getgoodninfo($rs['id'], 1);
  61. }
  62. $custractid = (int)$rs['custractid'];
  63. //读取收款状态
  64. $dsmoney = '';
  65. if($custractid>0){
  66. //从合同那读取
  67. $htrs = $this->custractobj->getone('`id`='.$custractid.' and `status`<>5');
  68. if($htrs){
  69. $custractid = $htrs['num'];//读取合同编号
  70. if($lx==1)$custractid = '<a href="'.$this->getxiangurl('custract',$rs['custractid'],'auto').'">'.$custractid.'</a>';
  71. $nrss = $this->crmobj->ractmoney($htrs);
  72. $ispay = $nrss[0];
  73. $moneys = $nrss[1];
  74. if($ispay==1){
  75. $dsmoney = '<font color=green>已全部收款</font>';
  76. }else{
  77. $dsmoney = '待收<font color=#ff6600>'.$moneys.'</font>';
  78. }
  79. }else{
  80. $custractid = 0;//不存在
  81. $this->update('`custractid`='.$custractid.'', $rs['id']);
  82. }
  83. }
  84. if($custractid===0){
  85. $custractid = '<font color=#aaaaaa>无关联</a>';
  86. $dsmoney = $this->crmobj->xiaozhuantai($rs);
  87. }
  88. $rs['custractid'] = $custractid;
  89. $rs['shoukuzt'] = $dsmoney;
  90. return $rs;
  91. }
  92. }
粤ICP备19079148号