finpiaoModel.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. //发票管理
  3. class flow_finpiaoClassModel extends flowModel
  4. {
  5. public $defaultorder = 'opendt,desc';
  6. public function flowrsreplace($rs, $lx=0)
  7. {
  8. return $rs;
  9. }
  10. protected function flowbillwhere($uid, $lx)
  11. {
  12. $month = $this->rock->post('month');
  13. $where = '';
  14. if($month!=''){
  15. $where.=" and `opendt` like '$month%'";
  16. }
  17. return array(
  18. 'where' => $where
  19. );
  20. }
  21. //导入数据的测试显示
  22. public function flowdaorutestdata()
  23. {
  24. $barr[] = array(
  25. 'type' => '收到的发票',
  26. 'ptype' => '增值税普通发票',
  27. 'kainame' => '张三',
  28. 'money' => '50',
  29. 'custname' => '销售单位',
  30. 'maicustname' => '购买单位',
  31. 'daima' => '',
  32. 'haoma' => '',
  33. 'opendt' => '2017-01-17',
  34. 'explain' => '说明',
  35. );
  36. $barr[] = array(
  37. 'type' => '开出去的发票',
  38. 'ptype' => '增值税普通发票',
  39. 'kainame' => '张三',
  40. 'money' => '500',
  41. 'custname' => '销售单位',
  42. 'maicustname' => '购买单位',
  43. 'daima' => '',
  44. 'haoma' => '',
  45. 'opendt' => '2017-01-17',
  46. 'explain' => '说明客户买了啥给他开了发票',
  47. );
  48. return $barr;
  49. }
  50. //导入之前处理,必须添加客户
  51. public function flowdaorubefore($rows)
  52. {
  53. $inarr = array();
  54. $crmdb = m('crm');
  55. foreach($rows as $k=>$rs){
  56. $arr = $rs;
  57. $custname = $rs['custname'];
  58. $custrs = $crmdb->getcustomer($custname);
  59. if(!$custrs)return '行'.($k+1).'销售方名称【'.$custname.'】不存在,请先建客户档案';
  60. $arr['custid'] = $custrs['id'];
  61. $maicustname = $rs['maicustname'];
  62. $custrs1 = $crmdb->getcustomer($maicustname);
  63. if(!$custrs1)return '行'.($k+1).'购买方名称【'.$maicustname.'】不存在,请先建客户档案';
  64. $arr['maicustid'] = $custrs1['id'];
  65. $type = 1; //收到的发票
  66. if(contain($rs['type'],'开出去'))$type=0;//开出去发票
  67. $arr['type'] = $type;
  68. $arr['status'] = 1;
  69. $inarr[] = $arr;
  70. }
  71. return $inarr;
  72. }
  73. }
粤ICP备19079148号