mode_tuihuoAction.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * 此文件是流程模块【tuihuo.退货单】对应控制器接口文件。
  4. */
  5. class mode_tuihuoClassAction extends inputAction{
  6. protected function savebefore($table, $arr, $id, $addbo){
  7. $data = $this->getsubtabledata(0);
  8. if(count($data)==0)return '至少要有一行记录';
  9. $this->sssaid = '0';
  10. foreach($data as $k=>$rs){
  11. $this->sssaid.=','.$rs['aid'].'';
  12. if(isset($rs['aid']))foreach($data as $k1=>$rs1){
  13. if($k!=$k1){
  14. if($rs['aid']==$rs1['aid'])
  15. return '行'.($k1+1).'的物品已在行'.($k+1).'上填写,不要重复填写';
  16. }
  17. }
  18. }
  19. $rows['type'] = '5';//一定要是5,不能去掉
  20. return array(
  21. 'rows'=>$rows
  22. );
  23. }
  24. protected function saveafter($table, $arr, $id, $addbo){
  25. m('goods')->setstock($this->sssaid);
  26. }
  27. public function getgoodsdata()
  28. {
  29. return m('goods')->getgoodsdata(2);
  30. }
  31. //读取我的客户
  32. public function getmycust()
  33. {
  34. $rows = m('crm')->getmycust($this->adminid, $this->rock->arrvalue($this->rs, 'custid'));
  35. return $rows;
  36. }
  37. //读取我的销售单
  38. public function getxiaoshou()
  39. {
  40. $arr[] = array('value'=>'0','name'=>'不关联');
  41. //读取我合同
  42. $custractid = 0;
  43. $mid = (int)$this->get('mid','0');
  44. if($mid>0){
  45. $custractid = (int)$this->flow->getmou('custractid', $mid);
  46. }
  47. //已申请过的
  48. $where = ' and `id` not in(select `custractid` from `[Q]goodm` where `type`=5 and `status`<>5)';
  49. if($custractid>0)$where=' and `id`='.$custractid.'';
  50. $rows = m('goodm')->getall('`uid`='.$this->adminid.' and `type`=2 and `status`=1'.$where.'');
  51. foreach($rows as $k=>$rs){
  52. $arr[] = array(
  53. 'value' => $rs['id'],
  54. 'name' => ''.$rs['num'].'.'.$rs['custname'].''
  55. );
  56. }
  57. return $arr;
  58. }
  59. public function tuileixing()
  60. {
  61. $this->option->addoption('退货类型','tuileixing',62, '普通退货,无理由退货');
  62. $data = $this->option->getmnum('tuileixing');
  63. $arr = array();
  64. foreach($data as $k=>$rs){
  65. $arr[] = array(
  66. 'name' => $rs['name'],
  67. 'value' => $rs['name'],
  68. );
  69. }
  70. return $arr;
  71. }
  72. public function ractchangeAjax()
  73. {
  74. $htid = (int)$this->get('ractid');
  75. $cars = m('goodm')->getone($htid, 'id,custid,custname,money,discount');
  76. $cars['zbarr'] = $this->db->getall("select a.`aid`,b.name as temp_aid,a.`count`,a.`unit`,a.`price` from `[Q]goodn` a left join `[Q]goods` b on a.`aid`=b.`id` where a.`mid`='$htid'");
  77. $this->returnjson($cars);
  78. }
  79. }
粤ICP备19079148号