custxiaoModel.php 2.9 KB

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