Zzququeu9.php 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. class Zzququeu9 extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_zzquque_u9','zzquque_u9');
  8. $this->load->_model("Model_logic_order","logic_order");
  9. $this->load->_model("Model_logic_u9xgsd","logic_u9xgsd");
  10. $this->load->_model("Model_logic_u9ztsd","logic_u9ztsd");
  11. $this->load->_model('Model_zzququeu9_logs','zzququeu9_logs');
  12. }
  13. public function _remap($arg,$arg_array)
  14. {
  15. if($arg == 'dc')//调出单
  16. {
  17. $this->_dc($arg_array);
  18. }
  19. elseif($arg == 'cg')//采购
  20. {
  21. $this->_cg($arg_array);
  22. }
  23. elseif($arg == 'xs')//销售单
  24. {
  25. $this->_xs($arg_array);
  26. }
  27. elseif($arg == 'bzch')//标准出货
  28. {
  29. $this->_bzch($arg_array);
  30. }
  31. elseif($arg == 'bzsh')//标准收货
  32. {
  33. $this->_bzsh($arg_array);
  34. }
  35. elseif($arg == 'dr')//调入单
  36. {
  37. $this->_dr($arg_array);
  38. }
  39. elseif($arg == 'xs_two')//调入单
  40. {
  41. $this->_xs_two($arg_array);
  42. }
  43. elseif($arg == 'dczt')//在途的调出单
  44. {
  45. $this->_dczt($arg_array);
  46. }
  47. elseif($arg == 'add'){
  48. $this->_add();
  49. }
  50. elseif($arg == 'excel'){
  51. $this->_excel();
  52. }
  53. elseif($arg == 'mcindex')
  54. {
  55. $this->_mcindex();
  56. }
  57. elseif($arg == 'scdel')//删除
  58. {
  59. $this->_del($arg_array);
  60. }
  61. else
  62. {
  63. $this->_index();
  64. }
  65. }
  66. public function _index(){
  67. $post = $this->input->post(NULL, TRUE);
  68. if(isset($post['page']))
  69. {
  70. $page = $this->input->post('page',true);
  71. $perpage = $this->input->post('perpage',true);
  72. $timetk = $this->input->post('timetk',true);//订单开始时间
  73. $timetj = $this->input->post('timetj',true);//订单结束时间
  74. $timetk = strtotime($timetk);
  75. $timetj = strtotime($timetj);
  76. $status = $this->input->post('status',true);
  77. $order_no = $this->input->post('order_no',true);
  78. $where='type = 10 ';
  79. if($order_no){
  80. $where .= " and order_no = '".$order_no."' ";
  81. }
  82. if($status){
  83. if($status == 1){
  84. $where .= " and dc_status = 0 ";
  85. }elseif($status == 2){
  86. $where .= " and dc_status = -1 ";
  87. }elseif($status == 3){
  88. $where .= " and dc_status = -2 ";
  89. }elseif($status == 4){
  90. $where .= " and dc_status = -3 ";
  91. }elseif($status == 5){
  92. $where .= " and dc_status < 3 ";
  93. }
  94. }
  95. if($timetk && $timetj){
  96. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  97. }
  98. if(empty($page))
  99. {
  100. $start = 0;
  101. $perpage = 10;
  102. }
  103. else
  104. {
  105. $start = ($page - 1)*$perpage;
  106. }
  107. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  108. $type_list = $this->zzquque_u9->getType();
  109. $list = [];
  110. foreach($info_list as $k=>$v){
  111. $dc_no = "";
  112. if($v['dc_status'] == 0){
  113. $dc_no = "<span data-action='dc' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";
  114. }elseif($v['dc_status'] == -1){
  115. $tmp_str = "异常信息";
  116. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  117. if(isset($error[0])){
  118. if($error[0]['apply_api']=='lpck'){
  119. $ret_data = json_decode($error[0]['ret_data'],true);
  120. $apply_data = json_decode($error[0]['apply_data'],true);
  121. if(isset($ret_data["ResMsg"])){
  122. if(empty($apply_data['0'])){
  123. $tmp_str = $ret_data["ResMsg"];
  124. }else{
  125. $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  126. }
  127. }else{
  128. $tmp_str = "料品同步失败";
  129. }
  130. }else{
  131. $ret_data = json_decode($error[0]['ret_data'],true);
  132. if(isset($ret_data[0]["ResMsg"])){
  133. $tmp_str = $ret_data[0]["ResMsg"];
  134. }elseif(isset($ret_data['msg'])){
  135. $tmp_str = $ret_data['msg'];
  136. }else{
  137. $tmp_str = "料品同步失败";
  138. }
  139. }
  140. }
  141. $dc_no = "<span data-action='dc' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';
  142. }
  143. if(!empty($v['dc_no'])){
  144. $dc_no = $v['dc_no']."<br/>".$dc_no;
  145. }
  146. $cg_no = "";
  147. if($v['cg_status'] == 0){
  148. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建采购单</span>";
  149. }elseif($v['cg_status'] == 1){
  150. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交采购单</span>";
  151. }elseif($v['cg_status'] == -1){
  152. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建采购单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="采购单创建失败"></i><p>';
  153. }elseif($v['cg_status'] == 2){
  154. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核采购单</span>";
  155. }elseif($v['cg_status'] == -2){
  156. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交采购单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="采购单提交失败"></i><p>';
  157. }elseif($v['cg_status'] == -3){
  158. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核采购单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="采购单审核失败"></i><p>';
  159. }
  160. if(!empty($v['cg_no'])){
  161. $cg_no = $v['cg_no']."<br/>".$cg_no;
  162. }
  163. $xs_no = "";
  164. if($v['xs_status'] == 0){
  165. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";
  166. }elseif($v['xs_status'] == 1){
  167. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";
  168. }elseif($v['xs_status'] == -1){
  169. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="销售单创建失败"></i><p>';
  170. }elseif($v['xs_status'] == 2){
  171. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";
  172. }elseif($v['xs_status'] == -2){
  173. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="销售单提交失败"></i><p>';
  174. }elseif($v['xs_status'] == -3){
  175. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="销售单审核失败"></i><p>';
  176. }
  177. if(!empty($v['xs_no'])){
  178. $xs_no = $v['xs_no']."<br/>".$xs_no;
  179. }
  180. $xs_two_no ='';
  181. if($v['xs_two_status'] == 0){
  182. $xs_two_no .= "<span data-action='xs_two' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";
  183. }elseif($v['xs_two_status'] == 1){
  184. $xs_two_no .= "<span data-action='xs_two' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";
  185. }elseif($v['xs_two_status'] == -1){
  186. $xs_two_no .= "<span data-action='xs_two' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  187. }elseif($v['xs_two_status'] == 2){
  188. $xs_two_no .= "<span data-action='xs_two' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";
  189. }elseif($v['xs_two_status'] == -2){
  190. $xs_two_no .= "<span data-action='xs_two' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  191. }elseif($v['xs_two_status'] == -3){
  192. $xs_two_no .= "<span data-action='xs_two' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  193. }
  194. if(!empty($v['xs_two_no'])){
  195. $xs_two_no = $v['xs_two_no']."<br/>".$xs_two_no;
  196. }
  197. $bzch_no ="";
  198. if($v['bzch_status'] == 0){
  199. $bzch_no .= "<span data-action='bzch' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建出货单</span>";
  200. }elseif($v['bzch_status'] == 1){
  201. $bzch_no .= "<span data-action='bzch' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交出货单</span>";
  202. }elseif($v['bzch_status'] == -1){
  203. $bzch_no .= "<span data-action='bzch' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建出货单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  204. }elseif($v['bzch_status'] == 2){
  205. $bzch_no .= "<span data-action='bzch' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核出货单</span>";
  206. }elseif($v['bzch_status'] == -2){
  207. $bzch_no .= "<span data-action='bzch' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交出货单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  208. }elseif($v['bzch_status'] == -3){
  209. $bzch_no .= "<span data-action='bzch' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核出货单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  210. }
  211. //$bzsh_no =empty($v['bzsh_no'])?"":$v['bzsh_no'];
  212. if(!empty($v['bzch_no'])){
  213. $bzch_no = $v['bzch_no']."<br/>".$bzch_no;
  214. }
  215. $dr_no = "";
  216. if($v['dr_status'] == 0){
  217. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调入单</span>";
  218. }elseif($v['dr_status'] == 1){
  219. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交调入单</span>";
  220. }elseif($v['dr_status'] == -1){
  221. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调入单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  222. }elseif($v['dr_status'] == 2){
  223. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核调入单</span>";
  224. }elseif($v['dr_status'] == -2){
  225. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交调入单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  226. }elseif($v['dr_status'] == -3){
  227. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核调入单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="123"></i><p>';
  228. }
  229. if(!empty($v['dr_no'])){
  230. $dr_no = $v['dr_no']."<br/>".$dr_no;
  231. }
  232. $list[] = [
  233. 'id'=>$v['id'],
  234. 'order_no'=>$v['order_no'],
  235. 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",
  236. 'dc_no'=> $dc_no,
  237. 'cg_no'=>$cg_no,
  238. 'xs_no'=>$xs_no,
  239. 'dr_no'=>$dr_no,
  240. 'xs_two_no'=>$xs_two_no,
  241. 'bzch_no'=>$bzch_no,
  242. //'bzsh_no'=>$bzsh_no,
  243. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  244. 'update_time'=>date("Y-m-d H:i:s",$v['update_time']),
  245. 'operate'=>($v['dc_status'] == 3)?"": "<span data-action='dr' data-id='".$v['id']."' onclick='doDel(this)' style='background-color:red'>删除</span>"
  246. ];
  247. }
  248. $total = $this->zzquque_u9->find_count($where);
  249. $pagenum = ceil($total/$perpage);
  250. $over = $total-($start+$perpage);
  251. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  252. echo json_encode($rows);exit;
  253. }
  254. $this->_Template('zzququeu9',$this->data);
  255. }
  256. public function _dc($arg_array){
  257. $process= $arg_array[0];
  258. $id = $arg_array[1];
  259. $info = $this->zzquque_u9->read($id);
  260. if($process == 1){
  261. if(!in_array($info['dc_status'],[0,-1])){
  262. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  263. exit;
  264. }
  265. $r = $this->logic_u9xgsd->createDc($info);
  266. if($r['code'] == 1){
  267. echo json_encode(array('msg'=>'创建调出单成功','success'=>true));
  268. exit;
  269. }else{
  270. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  271. exit;
  272. }
  273. }else if($process == 2){
  274. if(!in_array($info['dc_status'],[1,-2])){
  275. echo json_encode(array('msg'=>'当前状态不符合提交调出单的条件','success'=>false));
  276. exit;
  277. }
  278. $r = $this->logic_u9xgsd->subDc($info);
  279. if($r['code'] == 1){
  280. echo json_encode(array('msg'=>'提交调出单成功','success'=>true));
  281. exit;
  282. }else{
  283. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  284. exit;
  285. }
  286. }else if($process == 3){
  287. if(!in_array($info['dc_status'],[2,-3])){
  288. echo json_encode(array('msg'=>'当前状态不符合审核调出单的条件','success'=>false));
  289. exit;
  290. }
  291. $r = $this->logic_u9xgsd->shDc($info);
  292. if($r['code'] == 1){
  293. echo json_encode(array('msg'=>'审核调出单成功','success'=>true));
  294. exit;
  295. }else{
  296. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  297. exit;
  298. }
  299. }else{
  300. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  301. exit;
  302. }
  303. }
  304. public function _cg($arg_array){
  305. $process= $arg_array[0];
  306. $id = $arg_array[1];
  307. $info = $this->zzquque_u9->read($id);
  308. if($info['dc_status'] != 3){
  309. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  310. exit;
  311. }
  312. if($process == 1){
  313. if(!in_array($info['cg_status'],[0,-1])){
  314. echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));
  315. exit;
  316. }
  317. $r = $this->logic_u9xgsd->createCg($info);
  318. if($r['code'] == 1){
  319. echo json_encode(array('msg'=>'创建采购单成功','success'=>true));
  320. exit;
  321. }else{
  322. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  323. exit;
  324. }
  325. }else if($process == 2){
  326. if(!in_array($info['cg_status'],[1,-2])){
  327. echo json_encode(array('msg'=>'当前状态不符合提交采购单的条件','success'=>false));
  328. exit;
  329. }
  330. $r = $this->logic_u9xgsd->subCg($info);
  331. if($r['code'] == 1){
  332. echo json_encode(array('msg'=>'提交采购单成功','success'=>true));
  333. exit;
  334. }else{
  335. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  336. exit;
  337. }
  338. }else if($process == 3){
  339. if(!in_array($info['cg_status'],[2,-3])){
  340. echo json_encode(array('msg'=>'当前状态不符合审核采购单的条件','success'=>false));
  341. exit;
  342. }
  343. $r = $this->logic_u9xgsd->shCg($info);
  344. if($r['code'] == 1){
  345. echo json_encode(array('msg'=>'审核采购单成功','success'=>true));
  346. exit;
  347. }else{
  348. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  349. exit;
  350. }
  351. }else{
  352. echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));
  353. exit;
  354. }
  355. }
  356. public function _xs($arg_array){
  357. $process= $arg_array[0];
  358. $id = $arg_array[1];
  359. $info = $this->zzquque_u9->read($id);
  360. if($info['dc_status'] != 3){
  361. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  362. exit;
  363. }
  364. if($process == 1){
  365. if(!in_array($info['xs_status'],[0,-1])){
  366. echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));
  367. exit;
  368. }
  369. $r = $this->logic_u9xgsd->createXs($info);
  370. if($r['code'] == 1){
  371. echo json_encode(array('msg'=>'创建销售单成功','success'=>true));
  372. exit;
  373. }else{
  374. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  375. exit;
  376. }
  377. }else if($process == 2){
  378. if(!in_array($info['xs_status'],[1,-2])){
  379. echo json_encode(array('msg'=>'当前状态不符合提交销售单的条件','success'=>false));
  380. exit;
  381. }
  382. $r = $this->logic_u9xgsd->subXs($info);
  383. if($r['code'] == 1){
  384. echo json_encode(array('msg'=>'提交销售单成功','success'=>true));
  385. exit;
  386. }else{
  387. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  388. exit;
  389. }
  390. }else if($process == 3){
  391. if(!in_array($info['xs_status'],[2,-3])){
  392. echo json_encode(array('msg'=>'当前状态不符合审核销售单的条件','success'=>false));
  393. exit;
  394. }
  395. $r = $this->logic_u9xgsd->shXs($info);
  396. if($r['code'] == 1){
  397. echo json_encode(array('msg'=>'审核销售单成功','success'=>true));
  398. exit;
  399. }else{
  400. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  401. exit;
  402. }
  403. }else{
  404. echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));
  405. exit;
  406. }
  407. }
  408. public function _dr($arg_array){
  409. $process= $arg_array[0];
  410. $id = $arg_array[1];
  411. $info = $this->zzquque_u9->read($id);
  412. if($info['dc_status'] != 3){
  413. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  414. exit;
  415. }
  416. if($process == 1){
  417. if(!in_array($info['dr_status'],[0,-1])){
  418. echo json_encode(array('msg'=>'当前状态不符合查询调入单的条件','success'=>false));
  419. exit;
  420. }
  421. $r = $this->logic_u9xgsd->createDr($info);
  422. if($r['code'] == 1){
  423. echo json_encode(array('msg'=>'查询调入单成功','success'=>true));
  424. exit;
  425. }else{
  426. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  427. exit;
  428. }
  429. }else if($process == 2){
  430. if(!in_array($info['dr_status'],[1,-2])){
  431. echo json_encode(array('msg'=>'当前状态不符合提交调入单的条件','success'=>false));
  432. exit;
  433. }
  434. $r = $this->logic_u9xgsd->subDr($info);
  435. if($r['code'] == 1){
  436. echo json_encode(array('msg'=>'提交调入单成功','success'=>true));
  437. exit;
  438. }else{
  439. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  440. exit;
  441. }
  442. }else if($process == 3){
  443. if(!in_array($info['dr_status'],[2,-3])){
  444. echo json_encode(array('msg'=>'当前状态不符合审核调入单的条件','success'=>false));
  445. exit;
  446. }
  447. $r = $this->logic_u9xgsd->shDr($info);
  448. if($r['code'] == 1){
  449. echo json_encode(array('msg'=>'审核调入单成功','success'=>true));
  450. exit;
  451. }else{
  452. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  453. exit;
  454. }
  455. }else{
  456. echo json_encode(array('msg'=>'当前状态不符合创建调入单的条件','success'=>false));
  457. exit;
  458. }
  459. }
  460. public function _xs_two($arg_array){
  461. $process= $arg_array[0];
  462. $id = $arg_array[1];
  463. $info = $this->zzquque_u9->read($id);
  464. if($info['dc_status'] != 3){
  465. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  466. exit;
  467. }
  468. if($process == 1){
  469. if(!in_array($info['xs_two_status'],[0,-1])){
  470. echo json_encode(array('msg'=>'当前状态不符合查询香港销售单的条件','success'=>false));
  471. exit;
  472. }
  473. $r = $this->logic_u9xgsd->createXsTwo($info);
  474. if($r['code'] == 1){
  475. echo json_encode(array('msg'=>'创建香港销售单成功','success'=>true));
  476. exit;
  477. }else{
  478. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  479. exit;
  480. }
  481. }else if($process == 2){
  482. if(!in_array($info['xs_two_status'],[1,-2])){
  483. echo json_encode(array('msg'=>'当前状态不符合提交香港销售单的条件','success'=>false));
  484. exit;
  485. }
  486. $r = $this->logic_u9xgsd->subXsTwo($info);
  487. if($r['code'] == 1){
  488. echo json_encode(array('msg'=>'提交香港销售单成功','success'=>true));
  489. exit;
  490. }else{
  491. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  492. exit;
  493. }
  494. }else if($process == 3){
  495. if(!in_array($info['xs_two_status'],[2,-3])){
  496. echo json_encode(array('msg'=>'当前状态不符合审核香港销售单的条件','success'=>false));
  497. exit;
  498. }
  499. $r = $this->logic_u9xgsd->shXsTwo($info);
  500. if($r['code'] == 1){
  501. echo json_encode(array('msg'=>'审核香港销售单成功','success'=>true));
  502. exit;
  503. }else{
  504. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  505. exit;
  506. }
  507. }else{
  508. echo json_encode(array('msg'=>'当前状态不符合创建香港销售单的条件','success'=>false));
  509. exit;
  510. }
  511. }
  512. public function _bzch($arg_array){
  513. $process= $arg_array[0];
  514. $id = $arg_array[1];
  515. $info = $this->zzquque_u9->read($id);
  516. if($info['dc_status'] != 3){
  517. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  518. exit;
  519. }
  520. if($info['xs_two_status'] != 3){
  521. echo json_encode(array('msg'=>'香港销售单未审核不能执行后续操作','success'=>false));
  522. exit;
  523. }
  524. if($process == 1){
  525. if(!in_array($info['bzsh_status'],[0,-1])){
  526. echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));
  527. exit;
  528. }
  529. $r = $this->logic_u9xgsd->createCh($info);
  530. if($r['code'] == 1){
  531. echo json_encode(array('msg'=>'创建标准收货单成功','success'=>true));
  532. exit;
  533. }else{
  534. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  535. exit;
  536. }
  537. }else if($process == 2){
  538. $r = $this->logic_u9xgsd->subAndShCh($info);
  539. if($r['code'] == 1){
  540. echo json_encode(array('msg'=>'审核标准收货单成功','success'=>true));
  541. exit;
  542. }else{
  543. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  544. exit;
  545. }
  546. }else{
  547. echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));
  548. exit;
  549. }
  550. }
  551. public function _bzsh($arg_array){
  552. }
  553. public function _add(){
  554. $order_no = $this->input->post('order_no',true);
  555. if(empty($order_no)){
  556. echo json_encode(['msg'=>'请输入要添加的订单编码!','success'=>false]);exit;
  557. }
  558. $info = $this->logic_order->getInfo("number = '" .$order_no."'");
  559. if(empty($info)){
  560. echo json_encode(['msg'=>'订单不存在!请仔细核对单号','success'=>false]);exit;
  561. }
  562. $num = $this->zzquque_u9->find_all("order_no = '".$info['number']."'");
  563. if(empty($num)){
  564. $this->zzquque_u9->insert([
  565. 'platform'=>$info['lv_platform'],
  566. 'warehouse'=>$info['type'],
  567. 'type'=>10,
  568. 'order_no'=>$info['number'],
  569. 'create_time'=>time(),
  570. 'update_time'=>time(),
  571. ]);
  572. echo json_encode(['msg'=>'添加成功','success'=>true]);exit;
  573. }else{
  574. echo json_encode(['msg'=>'订单不允许重复添加','success'=>false]);exit;
  575. }
  576. }
  577. public function _excel(){
  578. $params = $this->input->get();
  579. $where = " type = 10 ";
  580. if(!empty($params['order_no'])){
  581. $where .= " and order_no = '".$params['order_no']."' ";
  582. }
  583. if(!empty($params['timetk'])){
  584. $where .= " and create_time > ".strtotime($params['timetk'])." ";
  585. }
  586. if(!empty($params['timetj'])){
  587. $where .= "and create_time < ".strtotime($params['timetj'])." ";
  588. }
  589. if(!empty($params['status'])){
  590. $status = $params['status'];
  591. if($status == 1){
  592. $where .= " and dc_status = 0 ";
  593. }elseif($status == 2){
  594. $where .= " and dc_status = -1 ";
  595. }elseif($status == 3){
  596. $where .= " and dc_status = -2 ";
  597. }elseif($status == 4){
  598. $where .= " and dc_status = -3 ";
  599. }elseif($status == 5){
  600. $where .= " and dc_status < 3 ";
  601. }
  602. }
  603. $info_list = $this->zzquque_u9->find_all($where,'*','id desc');
  604. $type_list = $this->zzquque_u9->getType();
  605. $list = [];
  606. foreach($info_list as $k=>$v){
  607. $dc_no = $v['dc_no'];
  608. $error_str = "";
  609. $error_json ="";
  610. if($v['dc_status'] == -1){
  611. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  612. $error_json = $error[0]['ret_data'];
  613. if($error[0]['apply_api']=='lpck'){
  614. $ret_data = json_decode($error[0]['ret_data'],true);
  615. $apply_data = json_decode($error[0]['apply_data'],true);
  616. if(isset($ret_data["ResMsg"])){
  617. if(empty($apply_data['0'])){
  618. $error_str = $ret_data["ResMsg"];
  619. }else{
  620. $error_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  621. }
  622. }else{
  623. $error_str = "料品同步失败";
  624. }
  625. }else{
  626. $ret_data = json_decode($error[0]['ret_data'],true);
  627. if(isset($ret_data[0]["ResMsg"])){
  628. $error_str = $ret_data[0]["ResMsg"];
  629. }elseif(isset($ret_data['msg'])){
  630. $error_str = $ret_data['msg'];
  631. }else{
  632. $error_str = "料品同步失败";
  633. }
  634. }
  635. }
  636. $list[] = [
  637. 'id'=>$v['id'],
  638. 'order_no'=>$v['order_no'],
  639. 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",
  640. 'dc_no'=> $dc_no,
  641. 'error'=>$error_str,
  642. 'error_json'=>$error_json,
  643. //'bzsh_no'=>$bzsh_no,
  644. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  645. ];
  646. }
  647. $filename = date("Y-m-d")."u9小单导出.xls";
  648. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  649. <head>
  650. <!--[if gte mso 9]><xml>
  651. <x:ExcelWorkbook>
  652. <x:ExcelWorksheets>
  653. <x:ExcelWorksheet>
  654. <x:Name>EXCEL</x:Name>
  655. <x:WorksheetOptions>
  656. <x:Print>
  657. <x:ValidPrinterInfo />
  658. </x:Print>
  659. </x:WorksheetOptions>
  660. </x:ExcelWorksheet>
  661. </x:ExcelWorksheets>
  662. </x:ExcelWorkbook>
  663. </xml>
  664. <![endif]-->
  665. </head><body>";
  666. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  667. $str .= "<tr><td>id</td><td>订单号</td><td>类型</td><td>调出单号</td><td>创建时间</td><td>错误信息</td><td>错误json</td></tr>";
  668. foreach ($list as $key=>$value)
  669. {
  670. $str .= "<tr>";
  671. $str .= "<td>". $value['id']. "</td>";
  672. $str .= "<td>". $value['order_no']. "</td>";
  673. $str .= "<td>". $value['type']. "</td>";
  674. $str .= "<td>". $value['dc_no']. "</td>";
  675. $str .= "<td>". $value['create_time']. "</td>";
  676. $str .= "<td>". $value['error']. "</td>";
  677. $str .= "<td>". $value['error_json']. "</td>";
  678. $str .= "</tr>";
  679. }
  680. $str .= "</table></body></html>";
  681. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  682. header( "Content-type: application/octet-stream" );
  683. header( "Content-Disposition: attachment; filename=".$filename );
  684. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  685. header( "Pragma: no-cache" );
  686. header( "Expires: 0" );
  687. exit($str);
  688. }
  689. public function _mcindex(){
  690. $post = $this->input->post(NULL, TRUE);
  691. if(isset($post['page']))
  692. {
  693. $page = $this->input->post('page',true);
  694. $perpage = $this->input->post('perpage',true);
  695. $timetk = $this->input->post('timetk',true);//订单开始时间
  696. $timetj = $this->input->post('timetj',true);//订单结束时间
  697. $timetk = strtotime($timetk);
  698. $timetj = strtotime($timetj);
  699. $order_no = $this->input->post('order_no',true);
  700. $type = $this->input->post('type',true);
  701. if($type == 1){
  702. $where=' ( type = 1)';
  703. }elseif($type == 2){
  704. $where=' ( type = 2)';
  705. }else{
  706. $where=' ( type = 1 or type = 2)';
  707. }
  708. if($order_no){
  709. $where .= " and order_no = '".$order_no."' ";
  710. }
  711. if($timetk && $timetj){
  712. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  713. }
  714. if(empty($page))
  715. {
  716. $start = 0;
  717. $perpage = 1;
  718. }
  719. else
  720. {
  721. $start = ($page - 1)*$perpage;
  722. }
  723. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  724. $type_list = $this->zzquque_u9->getType();
  725. $list = [];
  726. foreach($info_list as $k=>$v){
  727. $dc_no = "";
  728. if($v['dc_status'] == 0){
  729. if($v['type'] == 1){
  730. $dc_no = "<span data-action='dczt' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";
  731. }
  732. }elseif($v['dc_status'] == -1){
  733. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  734. if($error[0]['apply_api']=='lpck'){
  735. $ret_data = json_decode($error[0]['ret_data'],true);
  736. $apply_data = json_decode($error[0]['apply_data'],true);
  737. if(isset($ret_data["ResMsg"])){
  738. if(empty($apply_data['0'])){
  739. $tmp_str = $ret_data["ResMsg"];
  740. }else{
  741. $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  742. }
  743. }else{
  744. $tmp_str = "料品同步失败";
  745. }
  746. }else{
  747. $tmp_str= "";
  748. $ret_data = json_decode($error[0]['ret_data'],true);
  749. if(isset($ret_data[0]["ResMsg"])){
  750. $tmp_str = $ret_data[0]["ResMsg"];
  751. }elseif(isset($ret_data['msg'])){
  752. $tmp_str = $ret_data['msg'];
  753. }elseif(isset($ret_data['Data'])){
  754. foreach($ret_data['Data'] as $iit){
  755. if(!$iit['IsSucess']){
  756. $tmp_str .= $iit['ErrorMsg']."<br>";
  757. }
  758. }
  759. }else{
  760. $tmp_str = "料品同步失败";
  761. }
  762. }
  763. $dc_no = "<span data-action='dczt' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>".'<p style="color:blue"><i class="method fa fa-exclamation-circle" data-t="'.$tmp_str.'"></i><p>';
  764. }
  765. if(!empty($v['dc_no'])){
  766. if($v['type'] == 1){
  767. $dc_no = $v['dc_no']."【销售组织】"."<br/>".$dc_no;
  768. }else{
  769. $dc_no = $v['dc_no']."【香港组织】"."<br/>".$dc_no;
  770. }
  771. }
  772. $cg_no = "";
  773. if($v['type'] == 1){
  774. if($v['cg_status'] == 1){
  775. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."'>采购单提交异常</span>";
  776. }elseif($v['cg_status'] == -1){
  777. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' >创建采购单失败</span>";
  778. }elseif($v['cg_status'] == 2){
  779. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单未审核</span>";
  780. }elseif($v['cg_status'] == -2){
  781. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' >采购单提交失败</span>";
  782. }elseif($v['cg_status'] == -3){
  783. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单审核失败</span>";
  784. }
  785. if(!empty($v['cg_no'])){
  786. $cg_no = $v['cg_no']."【香港组织】<br/>".$cg_no;
  787. }
  788. }
  789. $xs_no = "";
  790. if($v['type'] == 1){
  791. if($v['xs_status'] == 1){
  792. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单未提交</span>";
  793. }elseif($v['xs_status'] == -1){
  794. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' >销售单创建失败</span>";
  795. }elseif($v['xs_status'] == 2){
  796. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单未审核</span>";
  797. }elseif($v['xs_status'] == -2){
  798. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单提交失败</span>";
  799. }elseif($v['xs_status'] == -3){
  800. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单审核失败</span>";
  801. }
  802. if(!empty($v['xs_no'])){
  803. $xs_no = $v['xs_no']."【销售组织】<br/>".$xs_no;
  804. }
  805. }
  806. $dr_no = "";
  807. if($v['dr_status'] == 1){
  808. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单未提交</span>";
  809. }elseif($v['dr_status'] == -1){
  810. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' >创建调入单失败</span>";
  811. }elseif($v['dr_status'] == 2){
  812. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单未审核</span>";
  813. }elseif($v['dr_status'] == -2){
  814. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单提交失败</span>";
  815. }elseif($v['dr_status'] == -3){
  816. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单审核失败</span>";
  817. }
  818. if(!empty($v['dr_no'])){
  819. $dr_no = $v['dr_no']."【香港组织】<br/>".$dr_no;
  820. }
  821. $type = "";
  822. if(isset($type_list[$v['type']])){
  823. if($v['type'] == 2){
  824. $type = "<i style='color:#70B'>".$type_list[$v['type']]."</i>";
  825. }else{
  826. $type = "<i>".$type_list[$v['type']]."</i>";
  827. }
  828. }else{
  829. $type = "<b style='color:red'>异常</b>";
  830. }
  831. $list[] = [
  832. 'id'=>$v['id'],
  833. 'order_no'=>$v['order_no'],
  834. 'type'=>$type,
  835. 'dc_no'=> $dc_no,
  836. 'cg_no'=>$cg_no,
  837. 'xs_no'=>$xs_no,
  838. 'dr_no'=>$dr_no,
  839. // 'xs_two_no'=>"",
  840. // 'bzch_no'=>"",
  841. //'bzsh_no'=>$bzsh_no,
  842. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  843. 'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
  844. ];
  845. }
  846. $total = $this->zzquque_u9->find_count($where);
  847. $pagenum = ceil($total/$perpage);
  848. $over = $total-($start+$perpage);
  849. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  850. echo json_encode($rows);exit;
  851. }
  852. $this->_Template('zzququeu9zt',$this->data);
  853. }
  854. public function _dczt($arg_array){
  855. $process= $arg_array[0];
  856. $id = $arg_array[1];
  857. $info = $this->zzquque_u9->read($id);
  858. if($process == 1){
  859. if(!in_array($info['dc_status'],[0,-1])){
  860. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  861. exit;
  862. }
  863. $r = $this->logic_u9ztsd->createdDc($info);
  864. if($r['code'] == 1){
  865. echo json_encode(array('msg'=>'创建调出单成功','success'=>true));
  866. exit;
  867. }else{
  868. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  869. exit;
  870. }
  871. }else{
  872. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  873. exit;
  874. }
  875. }
  876. private function _del($arg_array){
  877. $id = $arg_array[0];
  878. $user = $this->user->get_api($_SESSION['api']);
  879. if(!in_array($user['userid'],['ceshi','admin'])){
  880. echo json_encode(array('msg'=>'权限不足,禁止删除!','success'=>false));
  881. }
  882. $info = $this->zzquque_u9->read($id);
  883. //目前只删除小单的 在途的单子 不管对错都不处理留痕
  884. if(($info['dc_status'] < 3) && ($info['type'] == 10)){
  885. $this->zzquque_u9->remove($id);
  886. echo json_encode(array('msg'=>'删除成功','success'=>true));
  887. }else{
  888. echo json_encode(array('msg'=>'不满足删除条件','success'=>true));
  889. }
  890. }
  891. }