Zzququeu9.php 62 KB

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