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