Zzququeu9.php 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516
  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. $this->load->_model("Model_logic_u9action","logic_u9action");
  13. $this->load->_model("Model_whlabel_bh_transfer","whlabel_bh_transfer");
  14. $this->load->_model('Model_systemtransfer','systemtransfer');
  15. }
  16. public function _remap($arg,$arg_array)
  17. {
  18. if($arg == 'dc')//调出单
  19. {
  20. $this->_dc($arg_array);
  21. }
  22. elseif($arg == 'cg')//采购
  23. {
  24. $this->_cg($arg_array);
  25. }
  26. elseif($arg == 'xs')//销售单
  27. {
  28. $this->_xs($arg_array);
  29. }
  30. elseif($arg == 'bzch')//标准出货
  31. {
  32. $this->_bzch($arg_array);
  33. }
  34. elseif($arg == 'bzsh')//标准收货
  35. {
  36. $this->_bzsh($arg_array);
  37. }
  38. elseif($arg == 'dr')//调入单
  39. {
  40. $this->_dr($arg_array);
  41. }
  42. elseif($arg == 'xs_two')//调入单
  43. {
  44. $this->_xs_two($arg_array);
  45. }
  46. elseif($arg == 'dczt')//在途的调出单
  47. {
  48. $this->_dczt($arg_array);
  49. }
  50. elseif($arg == 'add'){
  51. $this->_add();
  52. }
  53. elseif($arg == 'excel'){
  54. $this->_excel();
  55. }
  56. elseif($arg == 'mcindex')
  57. {
  58. $this->_mcindex();
  59. }
  60. elseif($arg == 'scdel')//删除
  61. {
  62. $this->_del($arg_array);
  63. }
  64. elseif($arg == 'waixiao')//编辑
  65. {
  66. $this->_waixiao($arg_array);
  67. }
  68. elseif($arg == 'wxcprk')//外销成品入库
  69. {
  70. $this->_wxcprk($arg_array);
  71. }
  72. elseif($arg == 'wxcprksh'){
  73. $this->_wxcprksh($arg_array);
  74. }
  75. elseif($arg == 'wxxs'){
  76. $this->_wxxs($arg_array);
  77. }elseif($arg == 'gcbh_index'){
  78. $this->_gcbh_index();
  79. }elseif($arg == 'gcbhexcel'){
  80. $this->_gcbhexcel();
  81. }elseif($arg == 'bhcprk'){
  82. $this->_bhcprk($arg_array);
  83. }elseif($arg == 'cpkbh_index'){
  84. $this->_cpkbh_index();
  85. }
  86. elseif($arg == 'checkProduct'){
  87. $this->_checkProduct();
  88. }
  89. else
  90. {
  91. $this->_index();
  92. }
  93. }
  94. public function _index(){
  95. $post = $this->input->post(NULL, TRUE);
  96. if(isset($post['page']))
  97. {
  98. $page = $this->input->post('page',true);
  99. $perpage = $this->input->post('perpage',true);
  100. $timetk = $this->input->post('timetk',true);//订单开始时间
  101. $timetj = $this->input->post('timetj',true);//订单结束时间
  102. $timetk = strtotime($timetk);
  103. $timetj = strtotime($timetj);
  104. $status = $this->input->post('status',true);
  105. $order_no = $this->input->post('order_no',true);
  106. $where='type = 10 ';
  107. if($order_no){
  108. $where .= " and order_no = '".$order_no."' ";
  109. }
  110. if($status){
  111. if($status == 1){
  112. $where .= " and dc_status = 0 ";
  113. }elseif($status == 2){
  114. $where .= " and dc_status = -1 ";
  115. }elseif($status == 3){
  116. $where .= " and dc_status = -2 ";
  117. }elseif($status == 4){
  118. $where .= " and dc_status = -3 ";
  119. }elseif($status == 5){
  120. $where .= " and dc_status < 3 ";
  121. }
  122. }
  123. if($timetk && $timetj){
  124. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  125. }
  126. if(empty($page))
  127. {
  128. $start = 0;
  129. $perpage = 10;
  130. }
  131. else
  132. {
  133. $start = ($page - 1)*$perpage;
  134. }
  135. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  136. $type_list = $this->zzquque_u9->getType();
  137. $list = [];
  138. foreach($info_list as $k=>$v){
  139. $dc_no = "";
  140. if($v['dc_status'] == 0){
  141. $dc_no = "<span data-action='dc' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";
  142. }elseif($v['dc_status'] == -1){
  143. $tmp_str = "异常信息";
  144. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  145. if(isset($error[0])){
  146. if($error[0]['apply_api']=='lpck'){
  147. $ret_data = json_decode($error[0]['ret_data'],true);
  148. $apply_data = json_decode($error[0]['apply_data'],true);
  149. if(isset($ret_data["ResMsg"])){
  150. if(empty($apply_data['0'])){
  151. $tmp_str = $ret_data["ResMsg"];
  152. }else{
  153. $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  154. }
  155. }else{
  156. $tmp_str = "料品同步失败";
  157. }
  158. }else{
  159. $ret_data = json_decode($error[0]['ret_data'],true);
  160. if(isset($ret_data[0]["ResMsg"])){
  161. $tmp_str = $ret_data[0]["ResMsg"];
  162. }elseif(isset($ret_data['msg'])){
  163. $tmp_str = $ret_data['msg'];
  164. }else{
  165. $tmp_str = "料品同步失败";
  166. }
  167. }
  168. }
  169. $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>';
  170. }
  171. if(!empty($v['dc_no'])){
  172. $dc_no = $v['dc_no']."<br/>".$dc_no;
  173. }
  174. $cg_no = "";
  175. if($v['cg_status'] == 0){
  176. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建采购单</span>";
  177. }elseif($v['cg_status'] == 1){
  178. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交采购单</span>";
  179. }elseif($v['cg_status'] == -1){
  180. $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>';
  181. }elseif($v['cg_status'] == 2){
  182. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核采购单</span>";
  183. }elseif($v['cg_status'] == -2){
  184. $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>';
  185. }elseif($v['cg_status'] == -3){
  186. $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>';
  187. }
  188. if(!empty($v['cg_no'])){
  189. $cg_no = $v['cg_no']."<br/>".$cg_no;
  190. }
  191. $xs_no = "";
  192. if($v['xs_status'] == 0){
  193. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";
  194. }elseif($v['xs_status'] == 1){
  195. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";
  196. }elseif($v['xs_status'] == -1){
  197. $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>';
  198. }elseif($v['xs_status'] == 2){
  199. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";
  200. }elseif($v['xs_status'] == -2){
  201. $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>';
  202. }elseif($v['xs_status'] == -3){
  203. $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>';
  204. }
  205. if(!empty($v['xs_no'])){
  206. $xs_no = $v['xs_no']."<br/>".$xs_no;
  207. }
  208. $xs_two_no ='';
  209. if($v['xs_two_status'] == 0){
  210. $xs_two_no .= "<span data-action='xs_two' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";
  211. }elseif($v['xs_two_status'] == 1){
  212. $xs_two_no .= "<span data-action='xs_two' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交销售单</span>";
  213. }elseif($v['xs_two_status'] == -1){
  214. $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>';
  215. }elseif($v['xs_two_status'] == 2){
  216. $xs_two_no .= "<span data-action='xs_two' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核销售单</span>";
  217. }elseif($v['xs_two_status'] == -2){
  218. $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>';
  219. }elseif($v['xs_two_status'] == -3){
  220. $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>';
  221. }
  222. if(!empty($v['xs_two_no'])){
  223. $xs_two_no = $v['xs_two_no']."<br/>".$xs_two_no;
  224. }
  225. $bzch_no ="";
  226. if($v['bzch_status'] == 0){
  227. $bzch_no .= "<span data-action='bzch' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建出货单</span>";
  228. }elseif($v['bzch_status'] == 1){
  229. $bzch_no .= "<span data-action='bzch' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交出货单</span>";
  230. }elseif($v['bzch_status'] == -1){
  231. $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>';
  232. }elseif($v['bzch_status'] == 2){
  233. $bzch_no .= "<span data-action='bzch' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核出货单</span>";
  234. }elseif($v['bzch_status'] == -2){
  235. $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>';
  236. }elseif($v['bzch_status'] == -3){
  237. $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>';
  238. }
  239. //$bzsh_no =empty($v['bzsh_no'])?"":$v['bzsh_no'];
  240. if(!empty($v['bzch_no'])){
  241. $bzch_no = $v['bzch_no']."<br/>".$bzch_no;
  242. }
  243. $dr_no = "";
  244. if($v['dr_status'] == 0){
  245. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调入单</span>";
  246. }elseif($v['dr_status'] == 1){
  247. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' onclick='doAction(this)'>提交调入单</span>";
  248. }elseif($v['dr_status'] == -1){
  249. $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>';
  250. }elseif($v['dr_status'] == 2){
  251. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' onclick='doAction(this)'>审核调入单</span>";
  252. }elseif($v['dr_status'] == -2){
  253. $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>';
  254. }elseif($v['dr_status'] == -3){
  255. $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>';
  256. }
  257. if(!empty($v['dr_no'])){
  258. $dr_no = $v['dr_no']."<br/>".$dr_no;
  259. }
  260. $list[] = [
  261. 'id'=>$v['id'],
  262. 'order_no'=>$v['order_no'],
  263. 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",
  264. 'dc_no'=> $dc_no,
  265. 'cg_no'=>$cg_no,
  266. 'xs_no'=>$xs_no,
  267. 'dr_no'=>$dr_no,
  268. 'xs_two_no'=>$xs_two_no,
  269. 'bzch_no'=>$bzch_no,
  270. //'bzsh_no'=>$bzsh_no,
  271. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  272. 'update_time'=>date("Y-m-d H:i:s",$v['update_time']),
  273. 'operate'=>($v['dc_status'] == 3)?"": "<span data-action='dr' data-id='".$v['id']."' onclick='doDel(this)' style='background-color:red'>删除</span>"
  274. ];
  275. }
  276. $total = $this->zzquque_u9->find_count($where);
  277. $pagenum = ceil($total/$perpage);
  278. $over = $total-($start+$perpage);
  279. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  280. echo json_encode($rows);exit;
  281. }
  282. $this->_Template('zzququeu9',$this->data);
  283. }
  284. public function _dc($arg_array){
  285. $process= $arg_array[0];
  286. $id = $arg_array[1];
  287. $info = $this->zzquque_u9->read($id);
  288. if($process == 1){
  289. if(!in_array($info['dc_status'],[0,-1])){
  290. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  291. exit;
  292. }
  293. $r = $this->logic_u9xgsd->createDc($info);
  294. if($r['code'] == 1){
  295. echo json_encode(array('msg'=>'创建调出单成功','success'=>true));
  296. exit;
  297. }else{
  298. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  299. exit;
  300. }
  301. }else if($process == 2){
  302. if(!in_array($info['dc_status'],[1,-2])){
  303. echo json_encode(array('msg'=>'当前状态不符合提交调出单的条件','success'=>false));
  304. exit;
  305. }
  306. $r = $this->logic_u9xgsd->subDc($info);
  307. if($r['code'] == 1){
  308. echo json_encode(array('msg'=>'提交调出单成功','success'=>true));
  309. exit;
  310. }else{
  311. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  312. exit;
  313. }
  314. }else if($process == 3){
  315. if(!in_array($info['dc_status'],[2,-3])){
  316. echo json_encode(array('msg'=>'当前状态不符合审核调出单的条件','success'=>false));
  317. exit;
  318. }
  319. $r = $this->logic_u9xgsd->shDc($info);
  320. if($r['code'] == 1){
  321. echo json_encode(array('msg'=>'审核调出单成功','success'=>true));
  322. exit;
  323. }else{
  324. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  325. exit;
  326. }
  327. }else{
  328. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  329. exit;
  330. }
  331. }
  332. public function _cg($arg_array){
  333. $process= $arg_array[0];
  334. $id = $arg_array[1];
  335. $info = $this->zzquque_u9->read($id);
  336. if($info['dc_status'] != 3){
  337. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  338. exit;
  339. }
  340. if($process == 1){
  341. if(!in_array($info['cg_status'],[0,-1])){
  342. echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));
  343. exit;
  344. }
  345. $r = $this->logic_u9xgsd->createCg($info);
  346. if($r['code'] == 1){
  347. echo json_encode(array('msg'=>'创建采购单成功','success'=>true));
  348. exit;
  349. }else{
  350. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  351. exit;
  352. }
  353. }else if($process == 2){
  354. if(!in_array($info['cg_status'],[1,-2])){
  355. echo json_encode(array('msg'=>'当前状态不符合提交采购单的条件','success'=>false));
  356. exit;
  357. }
  358. $r = $this->logic_u9xgsd->subCg($info);
  359. if($r['code'] == 1){
  360. echo json_encode(array('msg'=>'提交采购单成功','success'=>true));
  361. exit;
  362. }else{
  363. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  364. exit;
  365. }
  366. }else if($process == 3){
  367. if(!in_array($info['cg_status'],[2,-3])){
  368. echo json_encode(array('msg'=>'当前状态不符合审核采购单的条件','success'=>false));
  369. exit;
  370. }
  371. $r = $this->logic_u9xgsd->shCg($info);
  372. if($r['code'] == 1){
  373. echo json_encode(array('msg'=>'审核采购单成功','success'=>true));
  374. exit;
  375. }else{
  376. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  377. exit;
  378. }
  379. }else{
  380. echo json_encode(array('msg'=>'当前状态不符合创建采购单的条件','success'=>false));
  381. exit;
  382. }
  383. }
  384. public function _xs($arg_array){
  385. $process= $arg_array[0];
  386. $id = $arg_array[1];
  387. $info = $this->zzquque_u9->read($id);
  388. if($info['dc_status'] != 3){
  389. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  390. exit;
  391. }
  392. if($process == 1){
  393. if(!in_array($info['xs_status'],[0,-1])){
  394. echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));
  395. exit;
  396. }
  397. $r = $this->logic_u9xgsd->createXs($info);
  398. if($r['code'] == 1){
  399. echo json_encode(array('msg'=>'创建销售单成功','success'=>true));
  400. exit;
  401. }else{
  402. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  403. exit;
  404. }
  405. }else if($process == 2){
  406. if(!in_array($info['xs_status'],[1,-2])){
  407. echo json_encode(array('msg'=>'当前状态不符合提交销售单的条件','success'=>false));
  408. exit;
  409. }
  410. $r = $this->logic_u9xgsd->subXs($info);
  411. if($r['code'] == 1){
  412. echo json_encode(array('msg'=>'提交销售单成功','success'=>true));
  413. exit;
  414. }else{
  415. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  416. exit;
  417. }
  418. }else if($process == 3){
  419. if(!in_array($info['xs_status'],[2,-3])){
  420. echo json_encode(array('msg'=>'当前状态不符合审核销售单的条件','success'=>false));
  421. exit;
  422. }
  423. $r = $this->logic_u9xgsd->shXs($info);
  424. if($r['code'] == 1){
  425. echo json_encode(array('msg'=>'审核销售单成功','success'=>true));
  426. exit;
  427. }else{
  428. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  429. exit;
  430. }
  431. }else{
  432. echo json_encode(array('msg'=>'当前状态不符合创建销售单的条件','success'=>false));
  433. exit;
  434. }
  435. }
  436. public function _dr($arg_array){
  437. $process= $arg_array[0];
  438. $id = $arg_array[1];
  439. $info = $this->zzquque_u9->read($id);
  440. if($info['dc_status'] != 3){
  441. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  442. exit;
  443. }
  444. if($process == 1){
  445. if(!in_array($info['dr_status'],[0,-1])){
  446. echo json_encode(array('msg'=>'当前状态不符合查询调入单的条件','success'=>false));
  447. exit;
  448. }
  449. $r = $this->logic_u9xgsd->createDr($info);
  450. if($r['code'] == 1){
  451. echo json_encode(array('msg'=>'查询调入单成功','success'=>true));
  452. exit;
  453. }else{
  454. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  455. exit;
  456. }
  457. }else if($process == 2){
  458. if(!in_array($info['dr_status'],[1,-2])){
  459. echo json_encode(array('msg'=>'当前状态不符合提交调入单的条件','success'=>false));
  460. exit;
  461. }
  462. $r = $this->logic_u9xgsd->subDr($info);
  463. if($r['code'] == 1){
  464. echo json_encode(array('msg'=>'提交调入单成功','success'=>true));
  465. exit;
  466. }else{
  467. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  468. exit;
  469. }
  470. }else if($process == 3){
  471. if(!in_array($info['dr_status'],[2,-3])){
  472. echo json_encode(array('msg'=>'当前状态不符合审核调入单的条件','success'=>false));
  473. exit;
  474. }
  475. $r = $this->logic_u9xgsd->shDr($info);
  476. if($r['code'] == 1){
  477. echo json_encode(array('msg'=>'审核调入单成功','success'=>true));
  478. exit;
  479. }else{
  480. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  481. exit;
  482. }
  483. }else{
  484. echo json_encode(array('msg'=>'当前状态不符合创建调入单的条件','success'=>false));
  485. exit;
  486. }
  487. }
  488. public function _xs_two($arg_array){
  489. $process= $arg_array[0];
  490. $id = $arg_array[1];
  491. $info = $this->zzquque_u9->read($id);
  492. if($info['dc_status'] != 3){
  493. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  494. exit;
  495. }
  496. if($process == 1){
  497. if(!in_array($info['xs_two_status'],[0,-1])){
  498. echo json_encode(array('msg'=>'当前状态不符合查询香港销售单的条件','success'=>false));
  499. exit;
  500. }
  501. $r = $this->logic_u9xgsd->createXsTwo($info);
  502. if($r['code'] == 1){
  503. echo json_encode(array('msg'=>'创建香港销售单成功','success'=>true));
  504. exit;
  505. }else{
  506. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  507. exit;
  508. }
  509. }else if($process == 2){
  510. if(!in_array($info['xs_two_status'],[1,-2])){
  511. echo json_encode(array('msg'=>'当前状态不符合提交香港销售单的条件','success'=>false));
  512. exit;
  513. }
  514. $r = $this->logic_u9xgsd->subXsTwo($info);
  515. if($r['code'] == 1){
  516. echo json_encode(array('msg'=>'提交香港销售单成功','success'=>true));
  517. exit;
  518. }else{
  519. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  520. exit;
  521. }
  522. }else if($process == 3){
  523. if(!in_array($info['xs_two_status'],[2,-3])){
  524. echo json_encode(array('msg'=>'当前状态不符合审核香港销售单的条件','success'=>false));
  525. exit;
  526. }
  527. $r = $this->logic_u9xgsd->shXsTwo($info);
  528. if($r['code'] == 1){
  529. echo json_encode(array('msg'=>'审核香港销售单成功','success'=>true));
  530. exit;
  531. }else{
  532. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  533. exit;
  534. }
  535. }else{
  536. echo json_encode(array('msg'=>'当前状态不符合创建香港销售单的条件','success'=>false));
  537. exit;
  538. }
  539. }
  540. public function _bzch($arg_array){
  541. $process= $arg_array[0];
  542. $id = $arg_array[1];
  543. $info = $this->zzquque_u9->read($id);
  544. if($info['dc_status'] != 3){
  545. echo json_encode(array('msg'=>'调出单未审核不能执行后续操作','success'=>false));
  546. exit;
  547. }
  548. if($info['xs_two_status'] != 3){
  549. echo json_encode(array('msg'=>'香港销售单未审核不能执行后续操作','success'=>false));
  550. exit;
  551. }
  552. if($process == 1){
  553. if(!in_array($info['bzsh_status'],[0,-1])){
  554. echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));
  555. exit;
  556. }
  557. $r = $this->logic_u9xgsd->createCh($info);
  558. if($r['code'] == 1){
  559. echo json_encode(array('msg'=>'创建标准收货单成功','success'=>true));
  560. exit;
  561. }else{
  562. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  563. exit;
  564. }
  565. }else if($process == 2){
  566. $r = $this->logic_u9xgsd->subAndShCh($info);
  567. if($r['code'] == 1){
  568. echo json_encode(array('msg'=>'审核标准收货单成功','success'=>true));
  569. exit;
  570. }else{
  571. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  572. exit;
  573. }
  574. }else{
  575. echo json_encode(array('msg'=>'当前状态不符合创建标准收货单的条件','success'=>false));
  576. exit;
  577. }
  578. }
  579. public function _bzsh($arg_array){
  580. }
  581. public function _add(){
  582. $order_no = $this->input->post('order_no',true);
  583. if(empty($order_no)){
  584. echo json_encode(['msg'=>'请输入要添加的订单编码!','success'=>false]);exit;
  585. }
  586. $info = $this->logic_order->getInfo("number = '" .$order_no."'");
  587. if(empty($info)){
  588. echo json_encode(['msg'=>'订单不存在!请仔细核对单号','success'=>false]);exit;
  589. }
  590. $num = $this->zzquque_u9->find_all("order_no = '".$info['number']."'");
  591. if(empty($num)){
  592. $this->zzquque_u9->insert([
  593. 'platform'=>$info['lv_platform'],
  594. 'warehouse'=>$info['type'],
  595. 'type'=>10,
  596. 'order_no'=>$info['number'],
  597. 'create_time'=>time(),
  598. 'update_time'=>time(),
  599. ]);
  600. echo json_encode(['msg'=>'添加成功','success'=>true]);exit;
  601. }else{
  602. echo json_encode(['msg'=>'订单不允许重复添加','success'=>false]);exit;
  603. }
  604. }
  605. public function _excel(){
  606. $params = $this->input->get();
  607. $where = " type = 10 ";
  608. if(!empty($params['order_no'])){
  609. $where .= " and order_no = '".$params['order_no']."' ";
  610. }
  611. if(!empty($params['timetk'])){
  612. $where .= " and create_time > ".strtotime($params['timetk'])." ";
  613. }
  614. if(!empty($params['timetj'])){
  615. $where .= "and create_time < ".strtotime($params['timetj'])." ";
  616. }
  617. if(!empty($params['status'])){
  618. $status = $params['status'];
  619. if($status == 1){
  620. $where .= " and dc_status = 0 ";
  621. }elseif($status == 2){
  622. $where .= " and dc_status = -1 ";
  623. }elseif($status == 3){
  624. $where .= " and dc_status = -2 ";
  625. }elseif($status == 4){
  626. $where .= " and dc_status = -3 ";
  627. }elseif($status == 5){
  628. $where .= " and dc_status < 3 ";
  629. }
  630. }
  631. $info_list = $this->zzquque_u9->find_all($where,'*','id desc');
  632. $type_list = $this->zzquque_u9->getType();
  633. $list = [];
  634. foreach($info_list as $k=>$v){
  635. $dc_no = $v['dc_no'];
  636. $error_str = "";
  637. $error_json ="";
  638. if($v['dc_status'] == -1){
  639. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  640. $error_json = $error[0]['ret_data'];
  641. if($error[0]['apply_api']=='lpck'){
  642. $ret_data = json_decode($error[0]['ret_data'],true);
  643. $apply_data = json_decode($error[0]['apply_data'],true);
  644. if(isset($ret_data["ResMsg"])){
  645. if(empty($apply_data['0'])){
  646. $error_str = $ret_data["ResMsg"];
  647. }else{
  648. $error_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  649. }
  650. }else{
  651. $error_str = "料品同步失败";
  652. }
  653. }else{
  654. $ret_data = json_decode($error[0]['ret_data'],true);
  655. if(isset($ret_data[0]["ResMsg"])){
  656. $error_str = $ret_data[0]["ResMsg"];
  657. }elseif(isset($ret_data['msg'])){
  658. $error_str = $ret_data['msg'];
  659. }else{
  660. $error_str = "料品同步失败";
  661. }
  662. }
  663. }
  664. $list[] = [
  665. 'id'=>$v['id'],
  666. 'order_no'=>$v['order_no'],
  667. 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",
  668. 'dc_no'=> $dc_no,
  669. 'error'=>$error_str,
  670. 'error_json'=>$error_json,
  671. //'bzsh_no'=>$bzsh_no,
  672. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  673. ];
  674. }
  675. $filename = date("Y-m-d")."u9小单导出.xls";
  676. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  677. <head>
  678. <!--[if gte mso 9]><xml>
  679. <x:ExcelWorkbook>
  680. <x:ExcelWorksheets>
  681. <x:ExcelWorksheet>
  682. <x:Name>EXCEL</x:Name>
  683. <x:WorksheetOptions>
  684. <x:Print>
  685. <x:ValidPrinterInfo />
  686. </x:Print>
  687. </x:WorksheetOptions>
  688. </x:ExcelWorksheet>
  689. </x:ExcelWorksheets>
  690. </x:ExcelWorkbook>
  691. </xml>
  692. <![endif]-->
  693. </head><body>";
  694. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  695. $str .= "<tr><td>id</td><td>订单号</td><td>类型</td><td>调出单号</td><td>创建时间</td><td>错误信息</td><td>错误json</td></tr>";
  696. foreach ($list as $key=>$value)
  697. {
  698. $str .= "<tr>";
  699. $str .= "<td>". $value['id']. "</td>";
  700. $str .= "<td>". $value['order_no']. "</td>";
  701. $str .= "<td>". $value['type']. "</td>";
  702. $str .= "<td>". $value['dc_no']. "</td>";
  703. $str .= "<td>". $value['create_time']. "</td>";
  704. $str .= "<td>". $value['error']. "</td>";
  705. $str .= "<td>". $value['error_json']. "</td>";
  706. $str .= "</tr>";
  707. }
  708. $str .= "</table></body></html>";
  709. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  710. header( "Content-type: application/octet-stream" );
  711. header( "Content-Disposition: attachment; filename=".$filename );
  712. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  713. header( "Pragma: no-cache" );
  714. header( "Expires: 0" );
  715. exit($str);
  716. }
  717. public function _mcindex(){
  718. $post = $this->input->post(NULL, TRUE);
  719. if(isset($post['page']))
  720. {
  721. $page = $this->input->post('page',true);
  722. $perpage = $this->input->post('perpage',true);
  723. $timetk = $this->input->post('timetk',true);//订单开始时间
  724. $timetj = $this->input->post('timetj',true);//订单结束时间
  725. $timetk = strtotime($timetk);
  726. $timetj = strtotime($timetj);
  727. $order_no = $this->input->post('order_no',true);
  728. $type = $this->input->post('type',true);
  729. if($type == 1){
  730. $where=' ( type = 1)';
  731. }elseif($type == 2){
  732. $where=' ( type = 2)';
  733. }else{
  734. $where=' ( type = 1 or type = 2)';
  735. }
  736. if($order_no){
  737. $where .= " and order_no = '".$order_no."' ";
  738. }
  739. if($timetk && $timetj){
  740. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  741. }
  742. if(empty($page))
  743. {
  744. $start = 0;
  745. $perpage = 1;
  746. }
  747. else
  748. {
  749. $start = ($page - 1)*$perpage;
  750. }
  751. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  752. $type_list = $this->zzquque_u9->getType();
  753. $list = [];
  754. foreach($info_list as $k=>$v){
  755. $dc_no = "";
  756. if($v['dc_status'] == 0){
  757. if($v['type'] == 1){
  758. $dc_no = "<span data-action='dczt' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建调出单</span>";
  759. }
  760. }elseif($v['dc_status'] == -1){
  761. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 1 and two_type = 1 ","*",'id desc',0,1);
  762. if($error[0]['apply_api']=='lpck'){
  763. $ret_data = json_decode($error[0]['ret_data'],true);
  764. $apply_data = json_decode($error[0]['apply_data'],true);
  765. if(isset($ret_data["ResMsg"])){
  766. if(empty($apply_data['0'])){
  767. $tmp_str = $ret_data["ResMsg"];
  768. }else{
  769. $tmp_str = $ret_data["ResMsg"]."【". $apply_data[0]['EntityCode']."】";
  770. }
  771. }else{
  772. $tmp_str = "料品同步失败";
  773. }
  774. }else{
  775. $tmp_str= "";
  776. $ret_data = json_decode($error[0]['ret_data'],true);
  777. if(isset($ret_data[0]["ResMsg"])){
  778. $tmp_str = $ret_data[0]["ResMsg"];
  779. }elseif(isset($ret_data['msg'])){
  780. $tmp_str = $ret_data['msg'];
  781. }elseif(isset($ret_data['Data'])){
  782. foreach($ret_data['Data'] as $iit){
  783. if(!$iit['IsSucess']){
  784. $tmp_str .= $iit['ErrorMsg']."<br>";
  785. }
  786. }
  787. }else{
  788. $tmp_str = "料品同步失败";
  789. }
  790. }
  791. $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>';
  792. }
  793. if(!empty($v['dc_no'])){
  794. if($v['type'] == 1){
  795. $dc_no = $v['dc_no']."【销售组织】"."<br/>".$dc_no;
  796. }else{
  797. $dc_no = $v['dc_no']."【香港组织】"."<br/>".$dc_no;
  798. }
  799. }
  800. $cg_no = "";
  801. if($v['type'] == 1){
  802. if($v['cg_status'] == 1){
  803. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."'>采购单提交异常</span>";
  804. }elseif($v['cg_status'] == -1){
  805. $cg_no .= "<span data-action='cg' data-process='1' data-id='".$v['id']."' >创建采购单失败</span>";
  806. }elseif($v['cg_status'] == 2){
  807. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单未审核</span>";
  808. }elseif($v['cg_status'] == -2){
  809. $cg_no .= "<span data-action='cg' data-process='2' data-id='".$v['id']."' >采购单提交失败</span>";
  810. }elseif($v['cg_status'] == -3){
  811. $cg_no .= "<span data-action='cg' data-process='3' data-id='".$v['id']."' >采购单审核失败</span>";
  812. }
  813. if(!empty($v['cg_no'])){
  814. $cg_no = $v['cg_no']."【香港组织】<br/>".$cg_no;
  815. }
  816. }
  817. $xs_no = "";
  818. if($v['type'] == 1){
  819. if($v['xs_status'] == 1){
  820. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单未提交</span>";
  821. }elseif($v['xs_status'] == -1){
  822. $xs_no .= "<span data-action='xs' data-process='1' data-id='".$v['id']."' >销售单创建失败</span>";
  823. }elseif($v['xs_status'] == 2){
  824. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单未审核</span>";
  825. }elseif($v['xs_status'] == -2){
  826. $xs_no .= "<span data-action='xs' data-process='2' data-id='".$v['id']."' >销售单提交失败</span>";
  827. }elseif($v['xs_status'] == -3){
  828. $xs_no .= "<span data-action='xs' data-process='3' data-id='".$v['id']."' >销售单审核失败</span>";
  829. }
  830. if(!empty($v['xs_no'])){
  831. $xs_no = $v['xs_no']."【销售组织】<br/>".$xs_no;
  832. }
  833. }
  834. $dr_no = "";
  835. if($v['dr_status'] == 1){
  836. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单未提交</span>";
  837. }elseif($v['dr_status'] == -1){
  838. $dr_no .= "<span data-action='dr' data-process='1' data-id='".$v['id']."' >创建调入单失败</span>";
  839. }elseif($v['dr_status'] == 2){
  840. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单未审核</span>";
  841. }elseif($v['dr_status'] == -2){
  842. $dr_no .= "<span data-action='dr' data-process='2' data-id='".$v['id']."' >调入单提交失败</span>";
  843. }elseif($v['dr_status'] == -3){
  844. $dr_no .= "<span data-action='dr' data-process='3' data-id='".$v['id']."' >调入单审核失败</span>";
  845. }
  846. if(!empty($v['dr_no'])){
  847. $dr_no = $v['dr_no']."【香港组织】<br/>".$dr_no;
  848. }
  849. $type = "";
  850. if(isset($type_list[$v['type']])){
  851. if($v['type'] == 2){
  852. $type = "<i style='color:#70B'>".$type_list[$v['type']]."</i>";
  853. }else{
  854. $type = "<i>".$type_list[$v['type']]."</i>";
  855. }
  856. }else{
  857. $type = "<b style='color:red'>异常</b>";
  858. }
  859. $list[] = [
  860. 'id'=>$v['id'],
  861. 'order_no'=>$v['order_no'],
  862. 'type'=>$type,
  863. 'dc_no'=> $dc_no,
  864. 'cg_no'=>$cg_no,
  865. 'xs_no'=>$xs_no,
  866. 'dr_no'=>$dr_no,
  867. // 'xs_two_no'=>"",
  868. // 'bzch_no'=>"",
  869. //'bzsh_no'=>$bzsh_no,
  870. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  871. 'update_time'=>date("Y-m-d H:i:s",$v['update_time']),
  872. 'operate'=>"<span onclick='checkProduct(this)' style='background-color:#FF8C00' data-id='".$v['id']."' >物料核对</span>"
  873. ];
  874. }
  875. $total = $this->zzquque_u9->find_count($where);
  876. $pagenum = ceil($total/$perpage);
  877. $over = $total-($start+$perpage);
  878. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  879. echo json_encode($rows);exit;
  880. }
  881. $this->_Template('zzququeu9zt',$this->data);
  882. }
  883. public function _dczt($arg_array){
  884. $process= $arg_array[0];
  885. $id = $arg_array[1];
  886. $info = $this->zzquque_u9->read($id);
  887. if($process == 1){
  888. if(!in_array($info['dc_status'],[0,-1])){
  889. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  890. exit;
  891. }
  892. $r = $this->logic_u9ztsd->createdDc($info);
  893. if($r['code'] == 1){
  894. echo json_encode(array('msg'=>'创建调出单成功','success'=>true));
  895. exit;
  896. }else{
  897. echo json_encode(array('msg'=>$r['msg'],'success'=>false));
  898. exit;
  899. }
  900. }else{
  901. echo json_encode(array('msg'=>'当前状态不符合创建调出单的条件','success'=>false));
  902. exit;
  903. }
  904. }
  905. private function _del($arg_array){
  906. $id = $arg_array[0];
  907. $user = $this->user->get_api($_SESSION['api']);
  908. if(!in_array($user['userid'],['ceshi','admin'])){
  909. echo json_encode(array('msg'=>'权限不足,禁止删除!','success'=>false));
  910. }
  911. $info = $this->zzquque_u9->read($id);
  912. //目前只删除小单的 在途的单子 不管对错都不处理留痕
  913. if(($info['dc_status'] < 3) && ($info['type'] == 10)){
  914. $this->zzquque_u9->remove($id);
  915. echo json_encode(array('msg'=>'删除成功','success'=>true));
  916. }else{
  917. echo json_encode(array('msg'=>'不满足删除条件','success'=>true));
  918. }
  919. }
  920. public function _waixiao(){
  921. $post = $this->input->post(NULL, TRUE);
  922. if(isset($post['page']))
  923. {
  924. $page = $this->input->post('page',true);
  925. $perpage = $this->input->post('perpage',true);
  926. $timetk = $this->input->post('timetk',true);//订单开始时间
  927. $timetj = $this->input->post('timetj',true);//订单结束时间
  928. $timetk = strtotime($timetk);
  929. $timetj = strtotime($timetj);
  930. $order_no = $this->input->post('order_no',true);
  931. $type = $this->input->post('type',true);
  932. $where = " ( type = 20) ";
  933. if($order_no){
  934. $where .= " and order_no like '%".$order_no."%' ";
  935. }
  936. if($timetk && $timetj){
  937. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  938. }
  939. if(empty($page))
  940. {
  941. $start = 0;
  942. $perpage = 1;
  943. }
  944. else
  945. {
  946. $start = ($page - 1)*$perpage;
  947. }
  948. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  949. $type_list = $this->zzquque_u9->getType();
  950. $list = [];
  951. $lb_list= [];
  952. foreach($info_list as $k=>$v){
  953. $bzsh_no = $v['bzsh_no'];
  954. if($v['bzsh_status'] == 0){
  955. $bzsh_no = "<span data-action='wxcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";
  956. }elseif($v['bzsh_status'] == -1){
  957. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 20 and two_type = 1 ","*",'id desc',0,1);
  958. $tmp_str= "";
  959. if(isset($error[0]['ret_data'])){
  960. $ret_data = json_decode($error[0]['ret_data'],true);
  961. if(isset($ret_data[0]["ResMsg"])){
  962. $tmp_str = $ret_data[0]["ResMsg"];
  963. }elseif(isset($ret_data['msg'])){
  964. $tmp_str = $ret_data['msg'];
  965. }elseif(isset($ret_data['Data'])){
  966. foreach($ret_data['Data'] as $iit){
  967. if(!$iit['m_isSucess']){
  968. $tmp_str .= $iit['m_errorMsg']."<br>";
  969. }
  970. }
  971. }else{
  972. $tmp_str = "系统执行失败,请重试";
  973. }
  974. }else{
  975. $tmp_str = "";
  976. }
  977. $bzsh_no = "<span data-action='wxcprk' 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>';
  978. }elseif($v['bzsh_status'] == 1){
  979. $bzsh_no = $v['bzsh_no']."<br/><span data-action='wxcprksh' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";
  980. }
  981. $xs_no = " ";
  982. if($v['xs_status'] == -1){
  983. $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";
  984. }elseif($v['xs_status'] == 0){
  985. $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";
  986. }
  987. if(!empty($v['xs_no'])){
  988. $xs_no = $v['xs_no']."<br/>".$xs_no;
  989. }
  990. $bzch_no = empty($v['bzch_no'])?"":$v['bzch_no'];
  991. $lb_list[] = $v['child_order_no'];
  992. $list[] = [
  993. 'id'=>$v['id'],
  994. 'order_no'=>$v['order_no'],
  995. 'type'=>"工厂外销单",
  996. 'child_order_no'=>$v['child_order_no'],
  997. 'bzsh_no'=> $bzsh_no,
  998. 'xs_no'=>$xs_no,
  999. 'bzch_no'=>$bzch_no,
  1000. // 'xs_two_no'=>"",
  1001. // 'bzch_no'=>"",
  1002. //'bzsh_no'=>$bzsh_no,
  1003. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  1004. 'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
  1005. ];
  1006. }
  1007. $lb_list = array_unique($lb_list);
  1008. $lb_arr = [];
  1009. if(!empty($lb_list)){
  1010. $lb_arr = $this->systemtransfer->find_all("id in (".implode(',',$lb_list).") ","id,jm,title,pm");
  1011. $lb_arr = array_column($lb_arr,null,'id');
  1012. }
  1013. foreach($list as $k=>$v){
  1014. $list[$k]['child_order_no'] = isset($lb_arr[$v['child_order_no']])?$lb_arr[$v['child_order_no']]['pm']:'';
  1015. }
  1016. $total = $this->zzquque_u9->find_count($where);
  1017. $pagenum = ceil($total/$perpage);
  1018. $over = $total-($start+$perpage);
  1019. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1020. echo json_encode($rows);exit;
  1021. }
  1022. $this->_Template('zzququeu9wx',$this->data);
  1023. }
  1024. public function _wxcprk($arg_array){
  1025. $id = $arg_array[0];
  1026. $info = $this->zzquque_u9->read($id);
  1027. if(empty($info)){
  1028. echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));
  1029. exit;
  1030. }
  1031. if($info['bzsh_status'] != 0){
  1032. echo json_encode(array('msg'=>"当前状态不符合创建成品入库单的条件",'success'=>false));
  1033. exit;
  1034. }
  1035. $res = $this->logic_u9action->doRkd($info);
  1036. if($res['code'] == 1){
  1037. echo json_encode(array('msg'=>'创建成品入库单成功','success'=>true));
  1038. exit;
  1039. }else{
  1040. echo json_encode(array('msg'=>$res['msg'],'success'=>false));
  1041. exit;
  1042. }
  1043. }
  1044. public function _wxcprksh($arg_array){
  1045. $id = $arg_array[0];
  1046. $info = $this->zzquque_u9->read($id);
  1047. if(empty($info)){
  1048. echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));
  1049. exit;
  1050. }
  1051. if($info['bzsh_status'] != 0){
  1052. echo json_encode(array('msg'=>"当前状态不符合审核成品入库单的条件",'success'=>false));
  1053. exit;
  1054. }
  1055. $res = $this->logic_u9action->checkRkd($info);
  1056. if($res['code'] == 1){
  1057. echo json_encode(array('msg'=>'审核成品入库单成功','success'=>true));
  1058. exit;
  1059. }else{
  1060. echo json_encode(array('msg'=>$res['msg'],'success'=>false));
  1061. exit;
  1062. }
  1063. }
  1064. public function _wxxs($arg_array){
  1065. $id = $arg_array[0];
  1066. $info = $this->zzquque_u9->read($id);
  1067. if(empty($info)){
  1068. echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));
  1069. exit;
  1070. }
  1071. if($info['xs_status'] != 0){
  1072. echo json_encode(array('msg'=>"当前状态不符合创建销售单的条件",'success'=>false));
  1073. exit;
  1074. }
  1075. $res = $this->logic_u9action->createXsd($info);
  1076. if($res['code'] == 1){
  1077. echo json_encode(array('msg'=>'创建销售单成功','success'=>true));
  1078. exit;
  1079. }else{
  1080. echo json_encode(array('msg'=>$res['msg'],'success'=>false));
  1081. exit;
  1082. }
  1083. }
  1084. public function _gcbh_index(){
  1085. $post = $this->input->post(NULL, TRUE);
  1086. if(isset($post['page']))
  1087. {
  1088. $page = $this->input->post('page',true);
  1089. $perpage = $this->input->post('perpage',true);
  1090. $timetk = $this->input->post('timetk',true);//订单开始时间
  1091. $timetj = $this->input->post('timetj',true);//订单结束时间
  1092. $timetk = strtotime($timetk);
  1093. $timetj = strtotime($timetj);
  1094. $order_no = $this->input->post('order_no',true);
  1095. $type = $this->input->post('type',true);
  1096. $where = " ( type = 21) ";
  1097. if($order_no){
  1098. $where .= " and order_no like '%".$order_no."%' ";
  1099. }
  1100. if($timetk && $timetj){
  1101. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  1102. }
  1103. if(empty($page))
  1104. {
  1105. $start = 0;
  1106. $perpage = 1;
  1107. }
  1108. else
  1109. {
  1110. $start = ($page - 1)*$perpage;
  1111. }
  1112. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  1113. // $type_list = $this->zzquque_u9->getType();
  1114. $list = [];
  1115. foreach($info_list as $k=>$v){
  1116. $bzsh_no = empty($v['bzsh_no'])?"":$v['bzsh_no'];
  1117. if($v['bzsh_status'] == 0){
  1118. $bzsh_no = "<span data-action='bhcprk' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";
  1119. }elseif($v['bzsh_status'] == -1){
  1120. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 20 and two_type = 1 ","*",'id desc',0,1);
  1121. $tmp_str= "";
  1122. if(isset($error[0]['ret_data'])){
  1123. $ret_data = json_decode($error[0]['ret_data'],true);
  1124. if(isset($ret_data[0]["ResMsg"])){
  1125. $tmp_str = $ret_data[0]["ResMsg"];
  1126. }elseif(isset($ret_data['msg'])){
  1127. $tmp_str = $ret_data['msg'];
  1128. }elseif(isset($ret_data['Data'])){
  1129. foreach($ret_data['Data'] as $iit){
  1130. if(!$iit['m_isSucess']){
  1131. $tmp_str .= $iit['m_errorMsg']."<br>";
  1132. }
  1133. }
  1134. }else{
  1135. $tmp_str = "系统执行失败,请重试";
  1136. }
  1137. }else{
  1138. $tmp_str = "";
  1139. }
  1140. $bzsh_no = "<span data-action='bhcprk' 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>';
  1141. }elseif($v['bzsh_status'] == 1){
  1142. //$bzsh_no = $v['bzsh_no']."<br/><span data-action='wxcprksh' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建成品入库单</span>";
  1143. $bzsh_no = $v['bzsh_no'];
  1144. }
  1145. $dc_no = empty($v['dc_no'])?" ":$v['dc_no'];
  1146. // if($v['xs_status'] == -1){
  1147. // $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";
  1148. // }elseif($v['xs_status'] == 0){
  1149. // $xs_no .= "<span data-action='wxxs' data-process='1' onclick='doAction(this)' data-id='".$v['id']."' >创建销售单</span>";
  1150. // }
  1151. // if(!empty($v['xs_no'])){
  1152. // $xs_no = $v['xs_no']."<br/>".$xs_no;
  1153. // }
  1154. // $bzch_no = empty($v['bzch_no'])?"":$v['bzch_no'];
  1155. $list[] = [
  1156. 'id'=>$v['id'],
  1157. 'order_no'=>$v['order_no'],
  1158. 'type'=>"工厂备货单",
  1159. 'bzsh_no'=> $bzsh_no,
  1160. 'dc_no'=>$dc_no,
  1161. //'bzch_no'=>$bzch_no,
  1162. // 'xs_two_no'=>"",
  1163. // 'bzch_no'=>"",
  1164. //'bzsh_no'=>$bzsh_no,
  1165. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  1166. 'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
  1167. ];
  1168. }
  1169. $total = $this->zzquque_u9->find_count($where);
  1170. $pagenum = ceil($total/$perpage);
  1171. $over = $total-($start+$perpage);
  1172. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1173. echo json_encode($rows);exit;
  1174. }
  1175. $this->_Template('zzququeu9gcbh',$this->data);
  1176. }
  1177. public function _bhcprk($arg_array){
  1178. $id = $arg_array[0];
  1179. $info = $this->zzquque_u9->read($id);
  1180. if(empty($info)){
  1181. echo json_encode(array('msg'=>"数据异常,请联系技术",'success'=>false));
  1182. exit;
  1183. }
  1184. if($info['bzsh_status'] != 0){
  1185. echo json_encode(array('msg'=>"当前状态不符合创建成品入库单的条件",'success'=>false));
  1186. exit;
  1187. }
  1188. $res = $this->logic_u9bh->dpCprk($info);
  1189. if($res['code'] == 1){
  1190. echo json_encode(array('msg'=>'创建成品入库单成功','success'=>true));
  1191. exit;
  1192. }else{
  1193. echo json_encode(array('msg'=>$res['msg'],'success'=>false));
  1194. exit;
  1195. }
  1196. }
  1197. public function _gcbhexcel(){
  1198. $params = $this->input->get();
  1199. $where = " type = 21 ";
  1200. if(!empty($params['order_no'])){
  1201. $where .= " and order_no = '".$params['order_no']."' ";
  1202. }
  1203. if(!empty($params['timetk'])){
  1204. $where .= " and create_time > ".strtotime($params['timetk'])." ";
  1205. }
  1206. if(!empty($params['timetj'])){
  1207. $where .= "and create_time < ".strtotime($params['timetj'])." ";
  1208. }
  1209. $info_list = $this->zzquque_u9->find_all($where,'*','id desc');
  1210. $type_list = $this->zzquque_u9->getType();
  1211. $list = [];
  1212. foreach($info_list as $k=>$v){
  1213. $error_str = "";
  1214. $error_json ="";
  1215. if($v['bzsh_status'] == -1){
  1216. $error = $this->zzququeu9_logs->find_all("oid = ".$v['id']." and one_type = 20 and two_type = 1 ","*",'id desc',0,1);
  1217. $error_json = $error[0]['ret_data'];
  1218. if($error[0]['apply_api']=='scrk_cj'){
  1219. $ret_data = json_decode($error[0]['ret_data'],true);
  1220. if(isset($ret_data["Data"])){
  1221. if(isset($ret_data['Data']['0'])){
  1222. $error_str = $ret_data['Data']['0']["m_errorMsg"];
  1223. }else{
  1224. $error_str = "数据异常请联系技术";
  1225. }
  1226. }else{
  1227. $error_str = "数据异常请联系技术";
  1228. }
  1229. }else{
  1230. $ret_data = json_decode($error[0]['ret_data'],true);
  1231. if(isset($ret_data[0]["ResMsg"])){
  1232. $error_str = $ret_data[0]["ResMsg"];
  1233. }elseif(isset($ret_data['msg'])){
  1234. $error_str = $ret_data['msg'];
  1235. }else{
  1236. $error_str = "数据异常请联系技术";
  1237. }
  1238. }
  1239. }
  1240. $transfer_info = $this->whlabel_bh_transfer->read($v['child_order_no']);
  1241. $pm = empty($transfer_info['pm'])?"异常":$transfer_info['pm'];
  1242. $list[] = [
  1243. 'id'=>$v['id'],
  1244. 'order_no'=>$v['order_no'],
  1245. 'pm'=>$pm,
  1246. 'type'=>isset($type_list[$v['type']])?$type_list[$v['type']]:"异常",
  1247. 'bzsh_no'=>empty($v['bzsh_no'])?"":$v['bzsh_no'],
  1248. 'dc_no'=>empty($v['dc_no'])?"":$v['dc_no'],
  1249. 'error_str'=>$error_str,
  1250. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  1251. ];
  1252. }
  1253. $filename = date("Y-m-d")."u9小单导出.xls";
  1254. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1255. <head>
  1256. <!--[if gte mso 9]><xml>
  1257. <x:ExcelWorkbook>
  1258. <x:ExcelWorksheets>
  1259. <x:ExcelWorksheet>
  1260. <x:Name>EXCEL</x:Name>
  1261. <x:WorksheetOptions>
  1262. <x:Print>
  1263. <x:ValidPrinterInfo />
  1264. </x:Print>
  1265. </x:WorksheetOptions>
  1266. </x:ExcelWorksheet>
  1267. </x:ExcelWorksheets>
  1268. </x:ExcelWorkbook>
  1269. </xml>
  1270. <![endif]-->
  1271. </head><body>";
  1272. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  1273. $str .= "<tr><td>id</td><td>订单号</td><td>品名</td><td>类型</td><td>成品入库单</td><td>调出单</td><td>错误信息</td><td>时间</td></tr>";
  1274. foreach ($list as $key=>$value)
  1275. {
  1276. $str .= "<tr>";
  1277. $str .= "<td>". $value['id']. "</td>";
  1278. $str .= "<td>". $value['order_no']. "</td>";
  1279. $str .= "<td>". $value['pm']. "</td>";
  1280. $str .= "<td>". $value['type']. "</td>";
  1281. $str .= "<td>". $value['bzsh_no']. "</td>";
  1282. $str .= "<td>". $value['dc_no']. "</td>";
  1283. $str .= "<td>". $value['error_str']. "</td>";
  1284. $str .= "<td>". $value['create_time']. "</td>";
  1285. $str .= "</tr>";
  1286. }
  1287. $str .= "</table></body></html>";
  1288. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1289. header( "Content-type: application/octet-stream" );
  1290. header( "Content-Disposition: attachment; filename=".$filename );
  1291. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1292. header( "Pragma: no-cache" );
  1293. header( "Expires: 0" );
  1294. exit($str);
  1295. }
  1296. public function _cpkbh_index(){
  1297. $post = $this->input->post(NULL, TRUE);
  1298. if(isset($post['page']))
  1299. {
  1300. $page = $this->input->post('page',true);
  1301. $perpage = $this->input->post('perpage',true);
  1302. $timetk = $this->input->post('timetk',true);//订单开始时间
  1303. $timetj = $this->input->post('timetj',true);//订单结束时间
  1304. $timetk = strtotime($timetk);
  1305. $timetj = strtotime($timetj);
  1306. $order_no = $this->input->post('order_no',true);
  1307. $type = $this->input->post('type',true);
  1308. $where = " ( type = 22) ";
  1309. if($order_no){
  1310. $where .= " and order_no like '%".$order_no."%' ";
  1311. }
  1312. if($timetk && $timetj){
  1313. $where .= " and create_time > ".$timetk." and create_time < ".$timetj." ";
  1314. }
  1315. if(empty($page))
  1316. {
  1317. $start = 0;
  1318. $perpage = 1;
  1319. }
  1320. else
  1321. {
  1322. $start = ($page - 1)*$perpage;
  1323. }
  1324. $info_list = $this->zzquque_u9->find_all($where,'*','id desc',$start,$perpage);
  1325. $list = [];
  1326. foreach($info_list as $k=>$v){
  1327. $xs_no = "";
  1328. if($v['xs_status'] == 0){
  1329. $xs_no = "<span data-action='xs' data-process='1' data-id='".$v['id']."' onclick='doAction(this)'>创建销售单</span>";
  1330. }
  1331. if(!empty($v['xs_no'])){
  1332. $xs_no = $v['xs_no'];
  1333. }
  1334. $bzch_no = empty($v['bzch_no'])?"":$v['bzch_no'];
  1335. $list[] = [
  1336. 'id'=>$v['id'],
  1337. 'order_no'=>$v['order_no'],
  1338. 'type'=>"成品备货单",
  1339. 'xs_no'=>$xs_no,
  1340. 'bzch_no'=>$bzch_no,
  1341. 'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
  1342. 'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
  1343. ];
  1344. }
  1345. $total = $this->zzquque_u9->find_count($where);
  1346. $pagenum = ceil($total/$perpage);
  1347. $over = $total-($start+$perpage);
  1348. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1349. echo json_encode($rows);exit;
  1350. }
  1351. $this->_Template('zzququeu9cpkbh',$this->data);
  1352. }
  1353. protected function _checkProduct(){
  1354. $post = $this->input->post(NULL, TRUE);
  1355. if(empty($post)){
  1356. echo json_encode(array('msg'=>'参数错误','success'=>false,'data'=>[]));
  1357. exit;
  1358. }
  1359. $info = $this->zzquque_u9->read($post['id']);
  1360. if(empty($info)){
  1361. echo json_encode(array('msg'=>'数据异常','success'=>false,'data'=>[]));
  1362. exit;
  1363. }
  1364. $res = $this->logic_u9ztsd->checkProduct($info);
  1365. if($res['code'] == 1){
  1366. $final_all = [];
  1367. foreach($res['data'] as $k=>$v){
  1368. $final_all[] = [
  1369. "U9料号"=>$v['jm'],
  1370. "中文品名"=>$v['zh'],
  1371. "调出条数"=>$v['dcsl'],
  1372. '是否在u9创建'=>($v['is_register'] == 1)?"是":"否",
  1373. ];
  1374. }
  1375. echo json_encode(array('msg'=>"核验完毕,是否导出excel?",'success'=>true,'data'=>$final_all));
  1376. exit;
  1377. }else{
  1378. echo json_encode(array('msg'=>$res['msg'],'success'=>false,'data'=>[]));
  1379. exit;
  1380. }
  1381. }
  1382. }