Zzququeu9.php 65 KB

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