Zzququeu9.php 42 KB

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