custfinbModel.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. //客户付款单
  3. class flow_custfinbClassModel extends flowModel
  4. {
  5. public $statearrs,$statearrf;
  6. public $delbool = 0;
  7. public function initModel(){
  8. $this->statearrs = c('array')->strtoarray('未收款|red,已收款|green');
  9. $this->statearrf = c('array')->strtoarray('未付款|red,已付款|green');
  10. }
  11. public function flowrsreplace($rs)
  12. {
  13. if($rs['id']==0)return $rs;
  14. $starrr = array('收','付');
  15. $rs['paystatus'] = $rs['ispay'];
  16. $ispay = '<font color=red>未'.$starrr[$rs['type']].'款</font>';
  17. if($rs['ispay']==1)$ispay = '<font color=green>已'.$starrr[$rs['type']].'款</font>';
  18. $rs['ispay'] = $ispay;
  19. $rs['type'] = ''.$starrr[$rs['type']].'款单';
  20. $htid = $rs['htid'];
  21. $url = '';
  22. if($htid>0)$url = $this->getxiangurl('custract', $htid, 'auto');
  23. if($htid<0)$url = $this->getxiangurl('custxiao', 0-$htid, 'auto');
  24. if(arrvalue($rs,'xgid') && arrvalue($rs,'xgnum'))$url = $this->getxiangurl($rs['xgnum'], $rs['xgid'], 'auto');
  25. if($url && !isempt($rs['htnum']))
  26. $rs['htnum'] = '<a href="javascript:;" onclick="js.open(\''.$url.'\')">'.$rs['htnum'].'</a>';
  27. if($rs['custid']>0){
  28. //$url = $this->getxiangurl('customer', $rs['custid'], 'auto');
  29. //$rs['custname'] = '<a href="javascript:;" onclick="js.open(\''.$url.'\')">'.$rs['custname'].'</a>';
  30. }
  31. $jzid = arrvalue($rs,'jzid');
  32. if($jzid>0){
  33. $url = $this->getxiangurl('finjizhi', $jzid, 'auto');
  34. $rs['jzid'] = '<a href="javascript:;" onclick="js.open(\''.$url.'\')">已生成</a>';
  35. }else if($jzid=='-1'){
  36. $rs['jzid'] = '<font color=#aaaaaa>不需要</font>';
  37. }else{
  38. $rs['jzid'] = '';
  39. }
  40. return $rs;
  41. }
  42. //操作菜单操作
  43. protected function flowoptmenu($ors, $arr)
  44. {
  45. //标识已付款处理
  46. if($ors['num']=='pay'){
  47. $ispay = 0;
  48. $paydt = arrvalue($arr,'fields_paydt', $this->rock->now);
  49. if(!isempt($paydt))$ispay = 1;
  50. $this->update("`ispay`='$ispay',`paydt`='$paydt'", $this->id);
  51. m('crm')->ractmoney($this->rs['htid']);
  52. }
  53. //复制一单
  54. if($ors['num']=='noupfuzhe'){
  55. $jine = $this->rock->number(trim($arr['sm']));
  56. $uarr = $this->getone($this->id);
  57. $money= $uarr['money'];
  58. unset($uarr['id']);
  59. $uarr['createname'] = $this->adminname;
  60. $uarr['createid'] = $this->adminid;
  61. $uarr['money'] = $jine;
  62. $this->insert($uarr);
  63. $this->update('`money`=`money`-'.$jine.'', $this->id);
  64. }
  65. }
  66. //操作菜单操作之前
  67. protected function flowoptmenubefore($ors, $arr)
  68. {
  69. if($ors['num']=='noupfuzhe'){
  70. $sm = trim($arr['sm']);
  71. if(!$sm || !is_numeric($sm))return '输入“'.$sm.'”的不是金额';
  72. $sm = $this->rock->number($sm);
  73. if(floatval($sm)<=0)return '输入金额必须大于0';
  74. if(floatval($sm) >= floatval($this->rs['money']))return '输入的金额不能超过'.$this->rs['money'].'';
  75. }
  76. }
  77. protected function flowbillwhere($uid, $lx)
  78. {
  79. $month = $this->rock->post('month');
  80. $where = '';
  81. if($month!=''){
  82. $where.=" and `dt` like '$month%'";
  83. }
  84. return array(
  85. 'where' => $where,
  86. 'order' => '`optdt` desc'
  87. );
  88. }
  89. protected function flowdeletebill($sm)
  90. {
  91. $this->delbool++;
  92. $xgid = arrvalue($this->rs,'xgid');
  93. $xgnum = arrvalue($this->rs,'xgnum');
  94. $sid = $this->id;
  95. if($xgnum && $xgid && $this->delbool==1){
  96. $sflow = m('flow:'.$xgnum.'')->initbase($xgnum);
  97. $drows = $this->getall("`xgnum`='$xgnum' and `xgid`='$xgid'");//相关联一起删
  98. foreach($drows as $k=>$rs1){
  99. $mid = $rs1['id'];
  100. $this->loaddata($mid, false);
  101. $this->deletebill($sm, false);
  102. }
  103. $sflow->update('`payid`=0', $xgid);
  104. }
  105. $this->id = $sid;
  106. }
  107. protected function flowgetoptmenu($opt,$bo=false)
  108. {
  109. if($opt=='noupcreatejz' && $bo){
  110. return m('mode')->iscun('finjizhi');
  111. }
  112. }
  113. public function flowlistscript()
  114. {
  115. include_once('webmain/flow/page/rock_page_custfina_script.php');
  116. return '';
  117. }
  118. }
粤ICP备19079148号