1
0

mode_caigouAction.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. class mode_caigouClassAction extends inputAction{
  3. protected function savebefore($table, $arr, $id, $addbo){
  4. $data = $this->getsubtabledata(0);
  5. if(count($data)==0)return '至少要有一行记录';
  6. $this->sssaid = '0';
  7. foreach($data as $k=>$rs){
  8. $this->sssaid.=','.$rs['aid'].'';
  9. if(isset($rs['aid']))foreach($data as $k1=>$rs1){
  10. if($k!=$k1){
  11. if($rs['aid']==$rs1['aid'])
  12. return '行'.($k1+1).'的物品已在行'.($k+1).'上填写,不要重复填写';
  13. }
  14. }
  15. }
  16. $rows['type'] = '1';//一定要是1,不能去掉
  17. return array(
  18. 'rows'=>$rows
  19. );
  20. }
  21. protected function saveafter($table, $arr, $id, $addbo){
  22. $uarr['status'] = 0;
  23. $uarr['type'] = 0;
  24. m('goodss')->update($uarr,"`mid`='$id'");
  25. m('goodss')->update("`count`=abs(`count`)","`mid`='$id'");
  26. m('goods')->setstock($this->sssaid);
  27. }
  28. public function getgoodsdata()
  29. {
  30. return m('goods')->getgoodsdata(2);
  31. }
  32. public function getcustgong()
  33. {
  34. $arows = m('customer')->getall('`status`=1 and `isgys`=1','id,name');
  35. $rows = array();
  36. foreach($arows as $k=>$rs)$rows[]=array(
  37. 'name' => $rs['name'],
  38. 'value' => $rs['id']
  39. );
  40. return $rows;
  41. }
  42. public function getgoodsAjax()
  43. {
  44. $aid = (int)$this->post('aid');
  45. $rs = m('goods')->getone($aid,'unit,price');
  46. $this->returnjson($rs);
  47. }
  48. }
粤ICP备19079148号