Zzququeu9.php 41 KB

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