Zzququeu9.php 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  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_zzququeu9_logs','zzququeu9_logs');
  11. }
  12. public function _remap($arg,$arg_array)
  13. {
  14. if($arg == 'dc')//调出单
  15. {
  16. $this->_dc($arg_array);
  17. }
  18. elseif($arg == 'cg')//采购
  19. {
  20. $this->_cg($arg_array);
  21. }
  22. elseif($arg == 'xs')//销售单
  23. {
  24. $this->_xs($arg_array);
  25. }
  26. elseif($arg == 'bzch')//标准出货
  27. {
  28. $this->_bzch($arg_array);
  29. }
  30. elseif($arg == 'bzsh')//标准收货
  31. {
  32. $this->_bzsh($arg_array);
  33. }
  34. elseif($arg == 'dr')//调入单
  35. {
  36. $this->_dr($arg_array);
  37. }
  38. elseif($arg == 'xs_two')//调入单
  39. {
  40. $this->_xs_two($arg_array);
  41. }
  42. elseif($arg == 'add'){
  43. $this->_add();
  44. }
  45. elseif($arg == 'excel'){
  46. $this->_excel();
  47. }
  48. elseif($arg == 'mcindex')
  49. {
  50. $this->_mcindex();
  51. }
  52. else
  53. {
  54. $this->_index();
  55. }
  56. }
  57. public function _index(){
  58. $post = $this->input->post(NULL, TRUE);
  59. if(isset($post['page']))
  60. {
  61. $page = $this->input->post('page',true);
  62. $perpage = $this->input->post('perpage',true);
  63. $timetk = $this->input->post('timetk',true);//订单开始时间
  64. $timetj = $this->input->post('timetj',true);//订单结束时间
  65. $timetk = strtotime($timetk);
  66. $timetj = strtotime($timetj);
  67. $status = $this->input->post('status',true);
  68. $order_no = $this->input->post('order_no',true);
  69. $where='type = 10 ';
  70. if($order_no){
  71. $where .= " and order_no = '".$order_no."' ";
  72. }
  73. if($timetk && $timetj){
  74. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  75. }
  76. if($status){
  77. if($status = 1){
  78. $where .= " and dc_status < 0 ";
  79. }elseif($status = 2){
  80. $where .= " and cg_status < 0 ";
  81. }elseif($status = 3){
  82. $where .= " and xs_status < 0 ";
  83. }elseif($status = 4){
  84. $where .= " and dr_status < 0 ";
  85. }elseif($status = 5){
  86. $where .= " and xs_two_status < 0 ";
  87. }elseif($status = 6){
  88. $where .= " and bzsh_status <0 ";
  89. }
  90. }
  91. if(empty($page))
  92. {
  93. $start = 0;
  94. $perpage = 1;
  95. }
  96. else
  97. {
  98. $start = ($page - 1)*$perpage;
  99. }
  100. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  101. $type_list = $this->zzquque_u9->getType();
  102. $list = [];
  103. foreach($info_list as $k=>$v){
  104. $dc_no = "";
  105. if($v['dc_status'] == 0){
  106. $dc_no = "<span data-action='dc' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";
  107. }elseif($v['dc_status'] == -1){
  108. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  109. if($error[0]['apply_api']=='lpck'){
  110. $ret_data = json_decode($error[0]['ret_data'],true);
  111. $apply_data = json_decode($error[0]['apply_data'],true);
  112. if(isset($ret_data["ResMsg"])){
  113. if(empty($apply_data['0'])){
  114. $tmp_str = $ret_data["ResMsg"];
  115. }else{
  116. $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  117. }
  118. }else{
  119. $tmp_str = "料品同步失败";
  120. }
  121. }else{
  122. $ret_data = json_decode($error[0]['ret_data'],true);
  123. if(isset($ret_data[0]["ResMsg"])){
  124. $tmp_str = $ret_data[0]["ResMsg"];
  125. }elseif(isset($ret_data['msg'])){
  126. $tmp_str = $ret_data['msg'];
  127. }else{
  128. $tmp_str = "料品同步失败";
  129. }
  130. }
  131. $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>';
  132. }
  133. if(!empty($v['dc_no'])){
  134. $dc_no = $v['dc_no']."<br/>".$dc_no;
  135. }
  136. $cg_no = "";
  137. if($v['cg_status'] == 0){
  138. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建采购单</span>";
  139. }elseif($v['cg_status'] == 1){
  140. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交采购单</span>";
  141. }elseif($v['cg_status'] == -1){
  142. $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>';
  143. }elseif($v['cg_status'] == 2){
  144. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核采购单</span>";
  145. }elseif($v['cg_status'] == -2){
  146. $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>';
  147. }elseif($v['cg_status'] == -3){
  148. $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>';
  149. }
  150. if(!empty($v['cg_no'])){
  151. $cg_no = $v['cg_no']."<br/>".$cg_no;
  152. }
  153. $xs_no = "";
  154. if($v['xs_status'] == 0){
  155. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";
  156. }elseif($v['xs_status'] == 1){
  157. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";
  158. }elseif($v['xs_status'] == -1){
  159. $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>';
  160. }elseif($v['xs_status'] == 2){
  161. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";
  162. }elseif($v['xs_status'] == -2){
  163. $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>';
  164. }elseif($v['xs_status'] == -3){
  165. $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>';
  166. }
  167. if(!empty($v['xs_no'])){
  168. $xs_no = $v['xs_no']."<br/>".$xs_no;
  169. }
  170. $xs_two_no ='';
  171. if($v['xs_two_status'] == 0){
  172. $xs_two_no .= "<span data-action='xs_two' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";
  173. }elseif($v['xs_two_status'] == 1){
  174. $xs_two_no .= "<span data-action='xs_two' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";
  175. }elseif($v['xs_two_status'] == -1){
  176. $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>';
  177. }elseif($v['xs_two_status'] == 2){
  178. $xs_two_no .= "<span data-action='xs_two' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";
  179. }elseif($v['xs_two_status'] == -2){
  180. $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>';
  181. }elseif($v['xs_two_status'] == -3){
  182. $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>';
  183. }
  184. if(!empty($v['xs_two_no'])){
  185. $xs_two_no = $v['xs_two_no']."<br/>".$xs_two_no;
  186. }
  187. $bzch_no ="";
  188. if($v['bzch_status'] == 0){
  189. $bzch_no .= "<span data-action='bzch' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建出货单</span>";
  190. }elseif($v['bzch_status'] == 1){
  191. $bzch_no .= "<span data-action='bzch' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交出货单</span>";
  192. }elseif($v['bzch_status'] == -1){
  193. $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>';
  194. }elseif($v['bzch_status'] == 2){
  195. $bzch_no .= "<span data-action='bzch' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核出货单</span>";
  196. }elseif($v['bzch_status'] == -2){
  197. $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>';
  198. }elseif($v['bzch_status'] == -3){
  199. $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>';
  200. }
  201. //$bzsh_no =empty($v['bzsh_no'])?"":$v['bzsh_no'];
  202. if(!empty($v['bzch_no'])){
  203. $bzch_no = $v['bzch_no']."<br/>".$bzch_no;
  204. }
  205. $dr_no = "";
  206. if($v['dr_status'] == 0){
  207. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调入单</span>";
  208. }elseif($v['dr_status'] == 1){
  209. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交调入单</span>";
  210. }elseif($v['dr_status'] == -1){
  211. $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>';
  212. }elseif($v['dr_status'] == 2){
  213. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核调入单</span>";
  214. }elseif($v['dr_status'] == -2){
  215. $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>';
  216. }elseif($v['dr_status'] == -3){
  217. $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>';
  218. }
  219. if(!empty($v['dr_no'])){
  220. $dr_no = $v['dr_no']."<br/>".$dr_no;
  221. }
  222. $list[] = [
  223. 'id'=>$v['id'],
  224. 'order_no'=>$v['order_no'],
  225. 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",
  226. 'dc_no'=> $dc_no,
  227. 'cg_no'=>$cg_no,
  228. 'xs_no'=>$xs_no,
  229. 'dr_no'=>$dr_no,
  230. 'xs_two_no'=>$xs_two_no,
  231. 'bzch_no'=>$bzch_no,
  232. //'bzsh_no'=>$bzsh_no,
  233. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  234. 'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
  235. ];
  236. }
  237. $total = $this->zzquque_u9->find_count($where);
  238. $pagenum = ceil($total/$perpage);
  239. $over = $total-($start+$perpage);
  240. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  241. echo json_encode($rows);exit;
  242. }
  243. $this->_Template('zzququeu9',$this->data);
  244. }
  245. public function _dc($arg_array){
  246. $process= $arg_array[0];
  247. $id = $arg_array[1];
  248. $info = $this->zzquque_u9->read($id);
  249. if($process == 1){
  250. if(!in_array($info['dc_status'],[0,-1])){
  251. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  252. exit;
  253. }
  254. $r = $this->logic_u9xgsd->createDc($info);
  255. if($r['code'] == 1){
  256. echo json_encode(array('msg'=>'创建调出单成功','success'=>true));
  257. exit;
  258. }else{
  259. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  260. exit;
  261. }
  262. }else if($process == 2){
  263. if(!in_array($info['dc_status'],[1,-2])){
  264. echo json_encode(array('msg'=>'当前状态不符合提交调出单的条件','success'=>false));
  265. exit;
  266. }
  267. $r = $this->logic_u9xgsd->subDc($info);
  268. if($r['code'] == 1){
  269. echo json_encode(array('msg'=>'提交调出单成功','success'=>true));
  270. exit;
  271. }else{
  272. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  273. exit;
  274. }
  275. }else if($process == 3){
  276. if(!in_array($info['dc_status'],[2,-3])){
  277. echo json_encode(array('msg'=>'当前状态不符合审核调出单的条件','success'=>false));
  278. exit;
  279. }
  280. $r = $this->logic_u9xgsd->shDc($info);
  281. if($r['code'] == 1){
  282. echo json_encode(array('msg'=>'审核调出单成功','success'=>true));
  283. exit;
  284. }else{
  285. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  286. exit;
  287. }
  288. }else{
  289. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  290. exit;
  291. }
  292. }
  293. public function _cg($arg_array){
  294. $process= $arg_array[0];
  295. $id = $arg_array[1];
  296. $info = $this->zzquque_u9->read($id);
  297. if($info['dc_status'] != 3){
  298. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  299. exit;
  300. }
  301. if($process == 1){
  302. if(!in_array($info['cg_status'],[0,-1])){
  303. echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));
  304. exit;
  305. }
  306. $r = $this->logic_u9xgsd->createCg($info);
  307. if($r['code'] == 1){
  308. echo json_encode(array('msg'=>'创建采购单成功','success'=>true));
  309. exit;
  310. }else{
  311. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  312. exit;
  313. }
  314. }else if($process == 2){
  315. if(!in_array($info['cg_status'],[1,-2])){
  316. echo json_encode(array('msg'=>'当前状态不符合提交采购单的条件','success'=>false));
  317. exit;
  318. }
  319. $r = $this->logic_u9xgsd->subCg($info);
  320. if($r['code'] == 1){
  321. echo json_encode(array('msg'=>'提交采购单成功','success'=>true));
  322. exit;
  323. }else{
  324. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  325. exit;
  326. }
  327. }else if($process == 3){
  328. if(!in_array($info['cg_status'],[2,-3])){
  329. echo json_encode(array('msg'=>'当前状态不符合审核采购单的条件','success'=>false));
  330. exit;
  331. }
  332. $r = $this->logic_u9xgsd->shCg($info);
  333. if($r['code'] == 1){
  334. echo json_encode(array('msg'=>'审核采购单成功','success'=>true));
  335. exit;
  336. }else{
  337. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  338. exit;
  339. }
  340. }else{
  341. echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));
  342. exit;
  343. }
  344. }
  345. public function _xs($arg_array){
  346. $process= $arg_array[0];
  347. $id = $arg_array[1];
  348. $info = $this->zzquque_u9->read($id);
  349. if($info['dc_status'] != 3){
  350. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  351. exit;
  352. }
  353. if($process == 1){
  354. if(!in_array($info['xs_status'],[0,-1])){
  355. echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));
  356. exit;
  357. }
  358. $r = $this->logic_u9xgsd->createXs($info);
  359. if($r['code'] == 1){
  360. echo json_encode(array('msg'=>'创建销售单成功','success'=>true));
  361. exit;
  362. }else{
  363. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  364. exit;
  365. }
  366. }else if($process == 2){
  367. if(!in_array($info['xs_status'],[1,-2])){
  368. echo json_encode(array('msg'=>'当前状态不符合提交销售单的条件','success'=>false));
  369. exit;
  370. }
  371. $r = $this->logic_u9xgsd->subXs($info);
  372. if($r['code'] == 1){
  373. echo json_encode(array('msg'=>'提交销售单成功','success'=>true));
  374. exit;
  375. }else{
  376. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  377. exit;
  378. }
  379. }else if($process == 3){
  380. if(!in_array($info['xs_status'],[2,-3])){
  381. echo json_encode(array('msg'=>'当前状态不符合审核销售单的条件','success'=>false));
  382. exit;
  383. }
  384. $r = $this->logic_u9xgsd->shXs($info);
  385. if($r['code'] == 1){
  386. echo json_encode(array('msg'=>'审核销售单成功','success'=>true));
  387. exit;
  388. }else{
  389. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  390. exit;
  391. }
  392. }else{
  393. echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));
  394. exit;
  395. }
  396. }
  397. public function _dr($arg_array){
  398. $process= $arg_array[0];
  399. $id = $arg_array[1];
  400. $info = $this->zzquque_u9->read($id);
  401. if($info['dc_status'] != 3){
  402. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  403. exit;
  404. }
  405. if($process == 1){
  406. if(!in_array($info['dr_status'],[0,-1])){
  407. echo json_encode(array('msg'=>'当前状态不符合查询调入单的条件','success'=>false));
  408. exit;
  409. }
  410. $r = $this->logic_u9xgsd->createDr($info);
  411. if($r['code'] == 1){
  412. echo json_encode(array('msg'=>'查询调入单成功','success'=>true));
  413. exit;
  414. }else{
  415. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  416. exit;
  417. }
  418. }else if($process == 2){
  419. if(!in_array($info['dr_status'],[1,-2])){
  420. echo json_encode(array('msg'=>'当前状态不符合提交调入单的条件','success'=>false));
  421. exit;
  422. }
  423. $r = $this->logic_u9xgsd->subDr($info);
  424. if($r['code'] == 1){
  425. echo json_encode(array('msg'=>'提交调入单成功','success'=>true));
  426. exit;
  427. }else{
  428. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  429. exit;
  430. }
  431. }else if($process == 3){
  432. if(!in_array($info['dr_status'],[2,-3])){
  433. echo json_encode(array('msg'=>'当前状态不符合审核调入单的条件','success'=>false));
  434. exit;
  435. }
  436. $r = $this->logic_u9xgsd->shDr($info);
  437. if($r['code'] == 1){
  438. echo json_encode(array('msg'=>'审核调入单成功','success'=>true));
  439. exit;
  440. }else{
  441. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  442. exit;
  443. }
  444. }else{
  445. echo json_encode(array('msg'=>'当前状态不符合创建调入单的条件','success'=>false));
  446. exit;
  447. }
  448. }
  449. public function _xs_two($arg_array){
  450. $process= $arg_array[0];
  451. $id = $arg_array[1];
  452. $info = $this->zzquque_u9->read($id);
  453. if($info['dc_status'] != 3){
  454. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  455. exit;
  456. }
  457. if($process == 1){
  458. if(!in_array($info['xs_two_status'],[0,-1])){
  459. echo json_encode(array('msg'=>'当前状态不符合查询香港销售单的条件','success'=>false));
  460. exit;
  461. }
  462. $r = $this->logic_u9xgsd->createXsTwo($info);
  463. if($r['code'] == 1){
  464. echo json_encode(array('msg'=>'创建香港销售单成功','success'=>true));
  465. exit;
  466. }else{
  467. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  468. exit;
  469. }
  470. }else if($process == 2){
  471. if(!in_array($info['xs_two_status'],[1,-2])){
  472. echo json_encode(array('msg'=>'当前状态不符合提交香港销售单的条件','success'=>false));
  473. exit;
  474. }
  475. $r = $this->logic_u9xgsd->subXsTwo($info);
  476. if($r['code'] == 1){
  477. echo json_encode(array('msg'=>'提交香港销售单成功','success'=>true));
  478. exit;
  479. }else{
  480. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  481. exit;
  482. }
  483. }else if($process == 3){
  484. if(!in_array($info['xs_two_status'],[2,-3])){
  485. echo json_encode(array('msg'=>'当前状态不符合审核香港销售单的条件','success'=>false));
  486. exit;
  487. }
  488. $r = $this->logic_u9xgsd->shXsTwo($info);
  489. if($r['code'] == 1){
  490. echo json_encode(array('msg'=>'审核香港销售单成功','success'=>true));
  491. exit;
  492. }else{
  493. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  494. exit;
  495. }
  496. }else{
  497. echo json_encode(array('msg'=>'当前状态不符合创建香港销售单的条件','success'=>false));
  498. exit;
  499. }
  500. }
  501. public function _bzch($arg_array){
  502. $process= $arg_array[0];
  503. $id = $arg_array[1];
  504. $info = $this->zzquque_u9->read($id);
  505. if($info['dc_status'] != 3){
  506. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  507. exit;
  508. }
  509. if($info['xs_two_status'] != 3){
  510. echo json_encode(array('msg'=>'香港销售单未审核不能执行后续操作','success'=>false));
  511. exit;
  512. }
  513. if($process == 1){
  514. if(!in_array($info['bzsh_status'],[0,-1])){
  515. echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));
  516. exit;
  517. }
  518. $r = $this->logic_u9xgsd->createCh($info);
  519. if($r['code'] == 1){
  520. echo json_encode(array('msg'=>'创建标准收货单成功','success'=>true));
  521. exit;
  522. }else{
  523. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  524. exit;
  525. }
  526. }else if($process == 2){
  527. $r = $this->logic_u9xgsd->subAndShCh($info);
  528. if($r['code'] == 1){
  529. echo json_encode(array('msg'=>'审核标准收货单成功','success'=>true));
  530. exit;
  531. }else{
  532. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  533. exit;
  534. }
  535. }else{
  536. echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));
  537. exit;
  538. }
  539. }
  540. public function _bzsh($arg_array){
  541. }
  542. public function _add(){
  543. $order_no = $this->input->post('order_no',true);
  544. if(empty($order_no)){
  545. echo json_encode(['msg'=>'请输入要添加的订单编码!','success'=>false]);exit;
  546. }
  547. $info = $this->logic_order->getInfo("number = '" .$order_no."'");
  548. if(empty($info)){
  549. echo json_encode(['msg'=>'订单不存在!请仔细核对单号','success'=>false]);exit;
  550. }
  551. $num = $this->zzquque_u9->find_all("order_no = '".$info['number']."'");
  552. if(empty($num)){
  553. $this->zzquque_u9->insert([
  554. 'platform'=>$info['lv_platform'],
  555. 'warehouse'=>$info['type'],
  556. 'type'=>10,
  557. 'order_no'=>$info['number'],
  558. 'create_time'=>time(),
  559. 'update_time'=>time(),
  560. ]);
  561. echo json_encode(['msg'=>'添加成功','success'=>true]);exit;
  562. }else{
  563. echo json_encode(['msg'=>'订单不允许重复添加','success'=>false]);exit;
  564. }
  565. }
  566. public function _excel(){
  567. $params = $this->input->get();
  568. $where = "1 = 1";
  569. if(!empty($params['order_no'])){
  570. $where .= " order_no = '".$params['order_no']."' ";
  571. }
  572. if(!empty($params['timetk'])){
  573. $where .= " create_time > ".strtotime($params['timetk'])." ";
  574. }
  575. if(!empty($params['timetj'])){
  576. $where .= " create_time < ".strtotime($params['timetj'])." ";
  577. }
  578. if(!empty($params['status'])){
  579. $where .= " status = ".$params['status'];
  580. }
  581. var_dump($where);
  582. }
  583. public function _mcindex(){
  584. $post = $this->input->post(NULL, TRUE);
  585. if(isset($post['page']))
  586. {
  587. $page = $this->input->post('page',true);
  588. $perpage = $this->input->post('perpage',true);
  589. $timetk = $this->input->post('timetk',true);//订单开始时间
  590. $timetj = $this->input->post('timetj',true);//订单结束时间
  591. $timetk = strtotime($timetk);
  592. $timetj = strtotime($timetj);
  593. $order_no = $this->input->post('order_no',true);
  594. $where=' ( type = 1 or type = 2)';
  595. if($order_no){
  596. $where .= " and order_no = '".$order_no."' ";
  597. }
  598. if($timetk && $timetj){
  599. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  600. }
  601. if(empty($page))
  602. {
  603. $start = 0;
  604. $perpage = 1;
  605. }
  606. else
  607. {
  608. $start = ($page - 1)*$perpage;
  609. }
  610. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  611. $type_list = $this->zzquque_u9->getType();
  612. $list = [];
  613. foreach($info_list as $k=>$v){
  614. $dc_no = "";
  615. if($v['dc_status'] == 0){
  616. $dc_no = "<span data-action='dc' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";
  617. }elseif($v['dc_status'] == -1){
  618. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  619. if($error[0]['apply_api']=='lpck'){
  620. $ret_data = json_decode($error[0]['ret_data'],true);
  621. $apply_data = json_decode($error[0]['apply_data'],true);
  622. if(isset($ret_data["ResMsg"])){
  623. if(empty($apply_data['0'])){
  624. $tmp_str = $ret_data["ResMsg"];
  625. }else{
  626. $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  627. }
  628. }else{
  629. $tmp_str = "料品同步失败";
  630. }
  631. }else{
  632. $ret_data = json_decode($error[0]['ret_data'],true);
  633. if(isset($ret_data[0]["ResMsg"])){
  634. $tmp_str = $ret_data[0]["ResMsg"];
  635. }elseif(isset($ret_data['msg'])){
  636. $tmp_str = $ret_data['msg'];
  637. }else{
  638. $tmp_str = "料品同步失败";
  639. }
  640. }
  641. $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>';
  642. }
  643. if(!empty($v['dc_no'])){
  644. if($v['type'] == 1){
  645. $dc_no = $v['dc_no']."【销售组织】"."<br/>".$dc_no;
  646. }else{
  647. $dc_no = $v['dc_no']."【香港组织】"."<br/>".$dc_no;
  648. }
  649. }
  650. $cg_no = "";
  651. if($v['type'] == 1){
  652. if($v['cg_status'] == 1){
  653. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."'>采购单提交异常</span>";
  654. }elseif($v['cg_status'] == -1){
  655. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' >创建采购单失败</span>";
  656. }elseif($v['cg_status'] == 2){
  657. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单未审核</span>";
  658. }elseif($v['cg_status'] == -2){
  659. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' >采购单提交失败</span>";
  660. }elseif($v['cg_status'] == -3){
  661. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单审核失败</span>";
  662. }
  663. if(!empty($v['cg_no'])){
  664. $cg_no = $v['cg_no']."【香港组织】<br/>".$cg_no;
  665. }
  666. }
  667. $xs_no = "";
  668. if($v['type'] == 1){
  669. if($v['xs_status'] == 1){
  670. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单未提交</span>";
  671. }elseif($v['xs_status'] == -1){
  672. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' >销售单创建失败</span>";
  673. }elseif($v['xs_status'] == 2){
  674. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单未审核</span>";
  675. }elseif($v['xs_status'] == -2){
  676. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单提交失败</span>";
  677. }elseif($v['xs_status'] == -3){
  678. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单审核失败</span>";
  679. }
  680. if(!empty($v['xs_no'])){
  681. $xs_no = $v['xs_no']."【销售组织】<br/>".$xs_no;
  682. }
  683. }
  684. $dr_no = "";
  685. if($v['dr_status'] == 1){
  686. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单未提交</span>";
  687. }elseif($v['dr_status'] == -1){
  688. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' >创建调入单失败</span>";
  689. }elseif($v['dr_status'] == 2){
  690. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单未审核</span>";
  691. }elseif($v['dr_status'] == -2){
  692. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单提交失败</span>";
  693. }elseif($v['dr_status'] == -3){
  694. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单审核失败</span>";
  695. }
  696. if(!empty($v['dr_no'])){
  697. $dr_no = $v['dr_no']."【香港组织】<br/>".$dr_no;
  698. }
  699. $list[] = [
  700. 'id'=>$v['id'],
  701. 'order_no'=>$v['order_no'],
  702. 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",
  703. 'dc_no'=> $dc_no,
  704. 'cg_no'=>$cg_no,
  705. 'xs_no'=>$xs_no,
  706. 'dr_no'=>$dr_no,
  707. // 'xs_two_no'=>"",
  708. // 'bzch_no'=>"",
  709. //'bzsh_no'=>$bzsh_no,
  710. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  711. 'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
  712. ];
  713. }
  714. $total = $this->zzquque_u9->find_count($where);
  715. $pagenum = ceil($total/$perpage);
  716. $over = $total-($start+$perpage);
  717. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  718. echo json_encode($rows);exit;
  719. }
  720. $this->_Template('zzququeu9zt',$this->data);
  721. }
  722. }