Zzququeu9.php 42 KB

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