Zzququeu9.php 66 KB

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