Whlabel_bh.php 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whlabel_bh extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel_bh','whlabel_bh');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_specialstock','specialstock');
  27. $this->load->_model('Model_whlabellabel','whlabellabel');
  28. $this->load->_model('Model_whlabelwz','whlabelwz');
  29. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  30. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  31. $this->load->_model('Model_orderurl','orderurl');
  32. $this->load->_model('Model_brand','brand');
  33. $this->load->_model('Model_classid','classid');
  34. $this->load->_model('Model_apiyy','apiyy');
  35. $this->load->_model('Model_whlabel_bh_list','whlabel_bh_list');
  36. $this->load->_model('Model_whlabel','whlabel');
  37. $this->load->_model('Model_whlabel_bh_transfer','whlabel_bh_transfer');
  38. $this->load->_model('Model_transfer','transfer');
  39. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  40. $this->load->_model("Model_logic_ding","logic_ding");
  41. $this->load->_model("Model_apiyyv1","apiyyv1");
  42. $this->load->_model('Model_settingtest','settingtest');
  43. $this->load->_model("Model_whlabel_bh_transfer_cr","whlabel_bh_transfer_cr");
  44. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg,$arg_array)
  48. {
  49. if($arg == 'add')
  50. {
  51. $this->_add();
  52. }
  53. else if($arg == 'edit')
  54. {
  55. $this->_edit($arg_array);
  56. }
  57. else if($arg == 'del')//删除
  58. {
  59. $this->_del();
  60. }
  61. else if($arg == 'deltransfer')//删除
  62. {
  63. $this->_deltransfer();
  64. }
  65. else if($arg == 'cz')//删除
  66. {
  67. $this->_cz();
  68. }
  69. else if($arg == 'db')//删除
  70. {
  71. $this->_db();
  72. }
  73. else if($arg == 'kc')//删除
  74. {
  75. $this->_kc();
  76. }
  77. else if($arg == 'excel')//删除
  78. {
  79. $this->_excel();
  80. }
  81. else if($arg == 'xxpl')//删除
  82. {
  83. $this->_xxpl();
  84. }
  85. else if($arg == 'bbprint')//删除
  86. {
  87. $this->_bbprint();
  88. }
  89. else if($arg == 'operate')
  90. {
  91. $this->_operate();
  92. }
  93. else if($arg == 'out')
  94. {
  95. $this->_out();
  96. }
  97. else if($arg == 'bdbb')
  98. {
  99. $this->_bdbb();
  100. }
  101. else if($arg == 'rk')
  102. {
  103. $this->_rk();
  104. }
  105. else if($arg == 'ck')
  106. {
  107. $this->_ck();
  108. }
  109. else if($arg == 'ck')
  110. {
  111. $this->_ck();
  112. }
  113. else if($arg == 'transfer_log'){
  114. $this->_transfer_log();
  115. }
  116. else if($arg == 'transfer_detail'){
  117. $this->_transfer_detail($arg_array);
  118. }
  119. else
  120. {
  121. $this->_index();
  122. }
  123. }
  124. //管理
  125. public function _index()
  126. {
  127. $post = $this->input->post(NULL, TRUE);
  128. if(isset($post['page']))
  129. {
  130. $page = $this->input->post('page',true);
  131. $perpage = $this->input->post('perpage',true);
  132. $orderinfo = $this->input->post('orderinfo',true);
  133. $jm = $this->input->post('jm',true);
  134. $title = $this->input->post('title',true);
  135. $pm = $this->input->post('pm',true);
  136. $category = $this->input->post('category',true);
  137. $size = $this->input->post('size',true);
  138. $grade = $this->input->post('grade',true);
  139. $color = $this->input->post('color',true);
  140. $lowe = $this->input->post('lowe',true);
  141. $type = $this->input->post('type',true);
  142. $shipremarks = $this->input->post('shipremarks',true);
  143. $type = $this->input->post('type',true);
  144. $state = $this->input->post('state',true);
  145. $timetk = $this->input->post('timetk',true);
  146. $timetj = $this->input->post('timetj',true);
  147. $timetk = strtotime($timetk);
  148. $timetj = strtotime($timetj);
  149. $where = "1=1 ";
  150. if($timetk && $timetj)
  151. {
  152. $where .= " and time > '$timetk' and time < '$timetj'";
  153. }
  154. if($orderinfo)
  155. {
  156. $where .= " and orderinfo like '%$orderinfo%'";
  157. }
  158. if($type != '')
  159. {
  160. $where .= " and type = '$type'";
  161. }
  162. if($jm)
  163. {
  164. $where .= " and jm like '%$jm%'";
  165. }
  166. if($title)
  167. {
  168. $where .= " and title like '%$title%'";
  169. }
  170. if($pm)
  171. {
  172. $where .= " and pm like '%$pm%'";
  173. }
  174. if($category)
  175. {
  176. $where .= " and shipremarks like '%-$category-%'";
  177. }
  178. if($size)
  179. {
  180. $where .= " and shipremarks like '%-$size-%'";
  181. }
  182. if($grade)
  183. {
  184. $where .= " and shipremarks like '%-$grade-%'";
  185. }
  186. if($color)
  187. {
  188. $where .= " and shipremarks like '%-$color-%'";
  189. }
  190. if($lowe)
  191. {
  192. $where .= " and shipremarks like '%-$lowe-%'";
  193. }
  194. if($type)
  195. {
  196. $where .= " and type = '$type'";
  197. }
  198. if($state)
  199. {
  200. $where .= " and state = '$state'";
  201. }
  202. if($shipremarks)
  203. {
  204. $where .= " and shipremarks like '%$shipremarks%'";
  205. }
  206. //数据排序
  207. $order_str = "time desc";
  208. if(empty($page))
  209. {
  210. $start = 0;
  211. $perpage = 1;
  212. }
  213. else
  214. {
  215. $start = ($page - 1)*$perpage;
  216. }
  217. $warehouse = $this->warehouse->find_all();
  218. $ck = array();
  219. foreach ($warehouse as $v)
  220. {
  221. $ck[$v['id']] = $v['title'];
  222. }
  223. //取得信息列表
  224. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,time,cscg',$order_str,$start,$perpage);
  225. foreach ($info_list as $key=>$value)
  226. {
  227. $d = $this->whlabel_bh->read($value['id']);
  228. $info_list[$key]['title'] = "<font data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>".$d['jm'].'</font><br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  229. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$d['number']."'");
  230. $printnum = array_sum(array_column($printnum,'ts'));
  231. $info_list[$key]['printnum'] = $printnum;
  232. $info_list[$key]['num'] = $value['bhnum']-$printnum;
  233. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  234. $info_list[$key]['cscg'] = "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";
  235. }
  236. $total = $this->whlabel_bh->find_count($where);
  237. $pagenum = ceil($total/$perpage);
  238. $over = $total-($start+$perpage);
  239. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  240. echo json_encode($rows);exit;
  241. /**
  242. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,kcnum,num,rknum,dbnum,state,time,scapi,dbapi',$order_str,$start,$perpage);
  243. foreach ($info_list as $key=>$value)
  244. {
  245. $d = $this->whlabel_bh->read($value['id']);
  246. if($d['print'] == 0)
  247. {
  248. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #2ca8a1;'>未打印</span></p>";
  249. }
  250. else
  251. {
  252. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #999;'>已打印</span></p>";
  253. }
  254. if($value['state'] == 0)
  255. {
  256. $info_list[$key]['state'] = "<p>待生产/外购</p><p><span data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>传输料号</span></p>";//开 始
  257. }
  258. else if($value['state'] == 1)
  259. {
  260. $info_list[$key]['state'] = "<p>生产/外购中</p><p><span data-id='".$value['id']."' data-cz='1' class='whlabel_bh_ks'>完成入库</span></p>".$print;
  261. }
  262. else if($value['state'] == 2)
  263. {
  264. $info_list[$key]['state'] = "<p>已完成</p><p>已全部入库</p>";
  265. }
  266. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  267. $info_list[$key]['title'] = $d['jm'].'<br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  268. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  269. $zc = '';
  270. foreach ($zd as $v)
  271. {
  272. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  273. }
  274. $info_list[$key]['scapi'] = $zc;
  275. $info_list[$key]['dbapi'] = "<span data-id='".$value['id']."' class='whlabel_bh_db'>调拨出库</span>";
  276. $info_list[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  277. }
  278. **/
  279. }
  280. if(isset($_SESSION['api']))
  281. {
  282. $user = $this->user->get_api($_SESSION['api']);
  283. }
  284. else
  285. {
  286. header('Location: /');exit;
  287. }
  288. $w = $this->shop->find_all("yyid != ''");
  289. $this->data['yyck'] = $w;
  290. if($user['userid'] == 'ch')
  291. {
  292. $user['vip'] = 1;
  293. }
  294. $this->data['vip'] = $user['vip'];
  295. $this->_Template('whlabel_bh',$this->data);
  296. }
  297. //入库操作
  298. public function _add()
  299. {
  300. $tc = $this->typeclass->find_all();
  301. $typeclass = array();
  302. foreach ($tc as $v)
  303. {
  304. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  305. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  306. }
  307. $post = $this->input->post(NULL, TRUE);
  308. if(isset($post['num']))
  309. {
  310. $list = array();
  311. $sku = $this->input->post('sku',true);
  312. $category = $this->input->post('category',true);
  313. $list['category'] = $category;
  314. $list['hairtype'] = $this->input->post('hairtype',true);
  315. $list['grade'] = $this->input->post('grade',true);
  316. $size = $this->input->post('size',true);
  317. $xzsku = $this->input->post('xzsku',true);
  318. $list['size'] = rtrim($size,',');
  319. $list['hairnumber'] = $this->input->post('hairnumber',true);
  320. $list['extension'] = $this->input->post('extension',true);
  321. if($category == 1297)
  322. {
  323. $list['sywignumber'] = $this->input->post('sywignumber',true);
  324. }
  325. if($category == 1702)
  326. {
  327. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  328. $list['syother'] = $this->input->post('syother',true);
  329. }
  330. if($category == 133)
  331. {
  332. $list['fittype'] = $this->input->post('fittype',true);
  333. $list['acother'] = $this->input->post('acother',true);
  334. }
  335. $list['color'] = $this->input->post('color',true);
  336. $list['lowe'] = $this->input->post('lowe',true);
  337. if($category == 127)
  338. {
  339. $list['type'] = $this->input->post('type',true);
  340. $list['headroad'] = $this->input->post('headroad',true);
  341. $list['density'] = $this->input->post('density',true);
  342. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  343. {
  344. $list['lacesize'] = $this->input->post('lacesize',true);
  345. }
  346. $list['lacecolor'] = $this->input->post('lacecolor',true);
  347. $list['lacetypes'] = $this->input->post('lacetypes',true);
  348. }
  349. if($category == 128)
  350. {
  351. $list['lacetype'] = $this->input->post('lacetype',true);
  352. $list['haircap'] = $this->input->post('haircap',true);
  353. $list['density'] = $this->input->post('density',true);
  354. $list['lacecolor'] = $this->input->post('lacecolor',true);
  355. $list['lacetypes'] = $this->input->post('lacetypes',true);
  356. $list['wigother'] = $this->input->post('wigother',true);
  357. $list['wigother1'] = $this->input->post('wigother1',true);
  358. $list['wigother2'] = $this->input->post('wigother2',true);
  359. }
  360. if($category == 129)
  361. {
  362. $list['wide'] = $this->input->post('wide',true);
  363. }
  364. if($category == 131)
  365. {
  366. $list['gifttype'] = $this->input->post('gifttype',true);
  367. $list['giftother'] = $this->input->post('giftother',true);
  368. }
  369. if($category == 134)
  370. {
  371. $list['pieceweight'] = $this->input->post('pieceweight',true);
  372. }
  373. if($category == 1297)
  374. {
  375. $list['synthetictype'] = $this->input->post('synthetictype',true);
  376. $list['sywigother'] = $this->input->post('sywigother',true);
  377. }
  378. if($category == 130 || $category == 133 || $category == 1702)
  379. {
  380. $list['items'] = $this->input->post('items',true);
  381. $list['weight'] = $this->input->post('weight',true);
  382. }
  383. if($category == 1702)
  384. {
  385. $list['syhairther'] = $this->input->post('syhairther',true);
  386. }
  387. $classid = $this->classid->sku();
  388. $pm = $classid;
  389. $jm = $classid;
  390. $sku = $sku;
  391. $title = '';$features = '';$cs = array();
  392. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  393. foreach($list as $k=>$v)
  394. {
  395. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  396. {
  397. if($typeclass[$v]['bm'] != '')
  398. {
  399. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  400. }
  401. }
  402. if($v != 0)
  403. {
  404. if($k != 'size')
  405. {
  406. $title .= $typeclass[$v]['title']." ";
  407. }
  408. $features .=$v.'-';
  409. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  410. if(isset($pm[$typeclass[$v]['classid']]))
  411. {
  412. if($typeclass[$v]['title'] == '9A')
  413. {
  414. $pm[$typeclass[$v]['classid']] = '9A';
  415. }
  416. else if($typeclass[$v]['title'] == '10A')
  417. {
  418. $pm[$typeclass[$v]['classid']] = '10A';
  419. }
  420. else
  421. {
  422. $clzh = $typeclass[$v]['zh'];
  423. if(stripos($typeclass[$v]['zh'],'|') !== false)
  424. {
  425. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  426. $clzh = $clzh[0];
  427. }
  428. $pm[$typeclass[$v]['classid']] = $clzh;
  429. }
  430. }
  431. if(isset($jm[$typeclass[$v]['classid']]))
  432. {
  433. if($typeclass[$v]['jm'])
  434. {
  435. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  436. }
  437. }
  438. }
  439. }
  440. $jm = array_filter($jm);//去除空值
  441. $jm = implode("-",$jm);
  442. $sku = array_filter($sku);//去除空值
  443. $sku = implode("-",$sku);
  444. $pm = array_filter($pm);//去除空值
  445. $pm = implode(" ",$pm);
  446. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  447. if($list['size'])
  448. {
  449. $typeclass = $this->typeclass->read($list['size']);
  450. $title .= $typeclass['title'];
  451. }
  452. $title = trim($title,' ');
  453. $post['num'] = $this->input->post('num',true);
  454. $ztime = $this->input->post('ztime',true);
  455. $post['ztime'] = strtotime($ztime);
  456. $post['bm'] = '03'.implode("",$bmpx);
  457. $post['jm'] = $jm;
  458. $post['sku'] = $sku;
  459. $post['pm'] = $pm;
  460. $post['title'] = $title;
  461. $post['features'] = '-'.$features;
  462. $post['number'] = date('YmdHis',time()).rand(100,999);
  463. if(!$post['num'])
  464. {
  465. $post['number'] = date("YmdHis").rand(100,999);
  466. }
  467. $time = time();
  468. $post['time'] = $time;//操作时间
  469. $post['printnum'] = $time;
  470. $post['type'] = 0;
  471. //传输料号开始
  472. $lc = 0;
  473. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  474. if(isset($lh['Data'][0]))
  475. {
  476. if($lh['Data'][0]['m_isSucess'] != 1)
  477. {
  478. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  479. {
  480. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$post['bm'],'jm'=>$post['jm'],'success'=>false));exit;
  481. }
  482. }
  483. }
  484. else
  485. {
  486. echo json_encode(array('msg'=>'料号错误','cs'=>$lh,'success'=>false));exit;
  487. }
  488. if($this->whlabel_bh->insert($post))
  489. {
  490. echo json_encode(array('msg'=>'添加成功','cs'=>$cs,'success'=>true));exit;
  491. }
  492. else
  493. {
  494. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  495. }
  496. }
  497. $w = $this->shop->find_all("yyid != ''");
  498. $this->data['yyck'] = $w;
  499. $purchase = $this->purchase->find_all("yyid != ''");
  500. $this->data['purchase'] = $purchase;
  501. $this->data['data'] = (isset($_GET['data']))?$_GET['data']:'';
  502. $this->_Template('whlabel_bh_add',$this->data);
  503. }
  504. public function get_cjlp($data)//创建料品
  505. {
  506. $list["0"]["Code"] = $data['jm'];//料号,SKU
  507. $list["0"]["Code1"] = '';
  508. $list["0"]["Name"] = $data['zh'];//产品名称
  509. $list["0"]["MainItemCategory"]["Code"] = $data['bm'];
  510. $list["0"]["Org"]["Code"] = 001;
  511. $list["0"]["OtherID"] = 1;
  512. $list["0"]["PurchaseInfo"]["BudgetControlType"] = -1;
  513. $list["0"]["PurchaseInfo"]["PriceSource"] = 2;
  514. $list["0"]["PurchaseInfo"]["InquireRule"] = -1;
  515. $list["0"]["PurchaseInfo"]["InquireFixedPeriod"] = 0;
  516. $list["0"]["PurchaseInfo"]["StatisticPeriod"] = -1;
  517. $list["0"]["PurchaseInfo"]["IsPUTradePathModify"] = true;
  518. $list["0"]["PurchaseInfo"]["IsPURtnTradePathModify"] = true;
  519. $list["0"]["InventoryUOM"]["Code"] = '条';
  520. $list["0"]["InventorySecondUOM"]["Code"] = '';
  521. $list["0"]["IsDualUOM"] = false;
  522. $list["0"]["InventoryInfo"]["InventoryPlanningMethod"] = 4;
  523. $list["0"]["InventoryInfo"]["InventoryPlanTime"] = -1;
  524. $list["0"]["InventoryInfo"]["TurnOverRate"] = 1;
  525. $list["0"]["InventoryInfo"]["ReserveMode"] = -1;
  526. $list["0"]["InventoryInfo"]["SupplyMethod"] = -1;
  527. $list["0"]["DescFlexField"]["PrivateDescSeg1"] = 01;
  528. $list["0"]["DescFlexField"]["PubDescSeg5"] = 01;
  529. $list["0"]["Description"] = $data['title'];
  530. $list["0"]["ItemForm"] = 2001;
  531. $list["0"]["ItemFormAttribute"] = 10;
  532. $list["0"]["IsInventoryEnable"] = true;
  533. $list["0"]["IsPurchaseEnable"] = true;
  534. $list["0"]["IsSalesEnable"] = true;
  535. $list["0"]["IsBuildEnable"] = true;
  536. $list["0"]["IsOutsideOperationEnable"] = true;
  537. $list["0"]["IsMRPEnable"] = true;
  538. $list["0"]["IsBOMEnable"] = true;
  539. $list["0"]["IsCostCalByGrade"] = false;
  540. $list["0"]["IsCostCalByPotency"] = false;
  541. $list["0"]["IsGradeControl"] = false;
  542. $list["0"]["StandardGrade"] = -1;
  543. $list["0"]["StartGrade"] = -1;
  544. $list["0"]["EndGrade"] = -1;
  545. $list["0"]["IsPotencyControl"] = false;
  546. $list["0"]["StandardPotency"] = -1;
  547. $list["0"]["StartPotency"] = -1;
  548. $list["0"]["EndPotency"] = -1;
  549. $asd = $list;
  550. $list = json_encode($list);
  551. $token = $this->setting->get_yytoken_130();
  552. $url = 'http://172.31.105.167/U9C/webapi/ItemMaster/Create';
  553. $header[] = "Content-Type: application/json";
  554. $header[] = "Token: ".$token;
  555. $ch = curl_init();
  556. curl_setopt($ch, CURLOPT_URL, $url);
  557. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  558. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  559. curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
  560. curl_setopt($ch, CURLOPT_POST, 1);
  561. curl_setopt($ch, CURLOPT_POSTFIELDS, $list);
  562. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  563. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  564. $res = curl_exec($ch);
  565. $res = json_decode($res,true);
  566. return $asd;
  567. }
  568. //修改产品
  569. public function _edit($arg_array)
  570. {
  571. $tc = $this->typeclass->find_all();
  572. $typeclass = array();
  573. foreach ($tc as $v)
  574. {
  575. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  576. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  577. }
  578. $post = $this->input->post(NULL, TRUE);
  579. if(isset($post['id']))
  580. {
  581. $id = $this->input->post('id',true);
  582. $list = array();
  583. $sku = $this->input->post('sku',true);
  584. $category = $this->input->post('category',true);
  585. $list['category'] = $category;
  586. $list['hairtype'] = $this->input->post('hairtype',true);
  587. $list['grade'] = $this->input->post('grade',true);
  588. $size = $this->input->post('size',true);
  589. $xzsku = $this->input->post('xzsku',true);
  590. $list['size'] = rtrim($size,',');
  591. $list['hairnumber'] = $this->input->post('hairnumber',true);
  592. $list['extension'] = $this->input->post('extension',true);
  593. if($category == 1297)
  594. {
  595. $list['sywignumber'] = $this->input->post('sywignumber',true);
  596. }
  597. if($category == 1702)
  598. {
  599. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  600. $list['syother'] = $this->input->post('syother',true);
  601. }
  602. if($category == 133)
  603. {
  604. $list['fittype'] = $this->input->post('fittype',true);
  605. $list['acother'] = $this->input->post('acother',true);
  606. }
  607. $list['color'] = $this->input->post('color',true);
  608. $list['lowe'] = $this->input->post('lowe',true);
  609. if($category == 127)
  610. {
  611. $list['type'] = $this->input->post('type',true);
  612. $list['headroad'] = $this->input->post('headroad',true);
  613. $list['density'] = $this->input->post('density',true);
  614. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  615. {
  616. $list['lacesize'] = $this->input->post('lacesize',true);
  617. }
  618. $list['lacecolor'] = $this->input->post('lacecolor',true);
  619. $list['lacetypes'] = $this->input->post('lacetypes',true);
  620. }
  621. if($category == 128)
  622. {
  623. $list['lacetype'] = $this->input->post('lacetype',true);
  624. $list['haircap'] = $this->input->post('haircap',true);
  625. $list['density'] = $this->input->post('density',true);
  626. $list['lacecolor'] = $this->input->post('lacecolor',true);
  627. $list['lacetypes'] = $this->input->post('lacetypes',true);
  628. $list['wigother'] = $this->input->post('wigother',true);
  629. $list['wigother1'] = $this->input->post('wigother1',true);
  630. $list['wigother2'] = $this->input->post('wigother2',true);
  631. }
  632. if($category == 129)
  633. {
  634. $list['wide'] = $this->input->post('wide',true);
  635. }
  636. if($category == 131)
  637. {
  638. $list['gifttype'] = $this->input->post('gifttype',true);
  639. $list['giftother'] = $this->input->post('giftother',true);
  640. }
  641. if($category == 134)
  642. {
  643. $list['pieceweight'] = $this->input->post('pieceweight',true);
  644. }
  645. if($category == 1297)
  646. {
  647. $list['synthetictype'] = $this->input->post('synthetictype',true);
  648. $list['sywigother'] = $this->input->post('sywigother',true);
  649. }
  650. if($category == 130 || $category == 133 || $category == 1702)
  651. {
  652. $list['items'] = $this->input->post('items',true);
  653. $list['weight'] = $this->input->post('weight',true);
  654. }
  655. if($category == 1702)
  656. {
  657. $list['syhairther'] = $this->input->post('syhairther',true);
  658. }
  659. $classid = $this->classid->sku();
  660. $pm = $classid;
  661. $jm = $classid;
  662. $sku = $sku;
  663. $title = '';$features = '';$cs = array();
  664. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  665. foreach($list as $k=>$v)
  666. {
  667. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  668. {
  669. if($typeclass[$v]['bm'] != '')
  670. {
  671. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  672. }
  673. }
  674. if($v != 0)
  675. {
  676. if($k != 'size')
  677. {
  678. $title .= $typeclass[$v]['title']." ";
  679. }
  680. $features .=$v.'-';
  681. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  682. if(isset($pm[$typeclass[$v]['classid']]))
  683. {
  684. if($typeclass[$v]['title'] == '9A')
  685. {
  686. $pm[$typeclass[$v]['classid']] = '9A';
  687. }
  688. else if($typeclass[$v]['title'] == '10A')
  689. {
  690. $pm[$typeclass[$v]['classid']] = '10A';
  691. }
  692. else
  693. {
  694. $clzh = $typeclass[$v]['zh'];
  695. if(stripos($typeclass[$v]['zh'],'|') !== false)
  696. {
  697. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  698. $clzh = $clzh[0];
  699. }
  700. $pm[$typeclass[$v]['classid']] = $clzh;
  701. }
  702. }
  703. if(isset($jm[$typeclass[$v]['classid']]))
  704. {
  705. if($typeclass[$v]['jm'])
  706. {
  707. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  708. }
  709. }
  710. }
  711. }
  712. $jm = array_filter($jm);//去除空值
  713. $jm = implode("-",$jm);
  714. $sku = array_filter($sku);//去除空值
  715. $sku = implode("-",$sku);
  716. $pm = array_filter($pm);//去除空值
  717. $pm = implode(" ",$pm);
  718. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  719. if($list['size'])
  720. {
  721. $typeclass = $this->typeclass->read($list['size']);
  722. $title .= $typeclass['title'];
  723. }
  724. $title = trim($title,' ');
  725. $post['num'] = $this->input->post('num',true);
  726. $ztime = $this->input->post('ztime',true);
  727. $post['ztime'] = strtotime($ztime);
  728. $post['bm'] = '03'.implode("",$bmpx);
  729. $post['jm'] = $jm;
  730. $post['sku'] = $sku;
  731. $post['pm'] = $pm;
  732. $post['title'] = $title;
  733. $post['features'] = '-'.$features;
  734. $ztime = $this->input->post('ztime',true);
  735. if($ztime)
  736. {
  737. $post['ztime'] = strtotime($ztime);
  738. }
  739. if($this->whlabel_bh->save($post,$id))
  740. {
  741. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  742. }
  743. else
  744. {
  745. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  746. }
  747. }
  748. $w = $this->shop->find_all("yyid != ''");
  749. $this->data['yyck'] = $w;
  750. $whlabel_bh = $this->whlabel_bh->read($arg_array[0]);
  751. $this->data['whlabel_bh'] = $whlabel_bh ;
  752. $purchase = $this->purchase->find_all("yyid != ''");
  753. $this->data['purchase'] = $purchase;
  754. $this->_Template('whlabel_bh_edit',$this->data);
  755. }
  756. public function _cz()
  757. {
  758. $post = $this->input->post(NULL, TRUE);
  759. if(isset($post['id']))
  760. {
  761. $id = $this->input->post('id',true);
  762. $cz = $this->input->post('cz',true);
  763. $num = $this->input->post('num',true);
  764. $cz = $cz+1;
  765. $w = $this->whlabel_bh->read($id);
  766. if(!$w)
  767. {
  768. echo json_encode(array('msg'=>'操作的信息不存在!','success'=>false));exit;
  769. }
  770. //传输料号开始
  771. $lc = 0;
  772. $lh = $this->apiyy->get_cjlp(array('jm'=>$w['jm'],'title'=>$w['title'],'zh'=>$w['pm'],'bm'=>$w['bm']));
  773. if(isset($lh['Data'][0]))
  774. {
  775. if($lh['Data'][0]['m_isSucess'] != 1)
  776. {
  777. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  778. {
  779. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$w['bm'],'jm'=>$w['jm'],'success'=>false));exit;
  780. }
  781. }
  782. }
  783. else
  784. {
  785. echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit;
  786. }
  787. echo json_encode(array('msg'=>'操作成功!'.$lh['Data'][0]['m_isSucess'],'id'=>$id,'typetext'=>'传输料号','text'=>'','num'=>0,'cs'=>$lh,'bm'=>$w['bm'],'success'=>true));
  788. /** 投产
  789. if($w['scapi'] != 99)
  790. {
  791. if($w['state'] == $cz)
  792. {
  793. echo json_encode(array('msg'=>'请刷新页面后再进行操作!','success'=>false));exit;
  794. }
  795. if($w['type'] == '0')
  796. {
  797. $type = '生产';
  798. $bhlx = 0;
  799. }
  800. else
  801. {
  802. $type = '外购';
  803. $bhlx = 1;
  804. }
  805. $yy = $this->apiyy->_peihuo($w,$w['kh'],$w['orderinfo'],$w['num'],2000);
  806. if($yy['c'] == 0)
  807. {
  808. if($this->whlabel_bh->save(array('state'=>$cz,'scapi'=>99,'scid'=>$yy['scid'],'sctime'=>time()),$id))
  809. {
  810. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已操作','text'=>$type.'中','success'=>true));
  811. }
  812. else
  813. {
  814. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  815. }
  816. }
  817. else
  818. {
  819. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  820. }
  821. }
  822. else if($w['dbapi'] != 99 && $w['type'] == '0')
  823. {
  824. $cz = 1;
  825. if(!is_numeric($num))
  826. {
  827. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  828. }
  829. if($num > $w['num']-$w['rknum'])
  830. {
  831. echo json_encode(array('msg'=>'完成数量大于生产总数量!','success'=>false));exit;
  832. }
  833. if($w['rknum']+$num == $w['num'])
  834. {
  835. $dbapi = 99;
  836. $cz = 2;
  837. }
  838. else
  839. {
  840. $dbapi = 0;
  841. }
  842. $w['ts'] = $num;
  843. $rk = $this->apiyy->_newrk($w);
  844. if($rk['c'] == 0)
  845. {
  846. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>$dbapi,'scid'=>$rk['scid']),$id))
  847. {
  848. if($dbapi == 99)
  849. {
  850. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  851. }
  852. else
  853. {
  854. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  855. }
  856. }
  857. else
  858. {
  859. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  860. }
  861. }
  862. else
  863. {
  864. $this->whlabel_bh->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$id);
  865. echo json_encode(array('msg'=>$rk['error'],'success'=>false));exit;
  866. }
  867. }
  868. else if($w['dbapi'] != 99 && $w['type'] == '1')
  869. {
  870. $cz = 1;
  871. if(!is_numeric($num))
  872. {
  873. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  874. }
  875. if($num > $w['num']-$w['rknum'])
  876. {
  877. echo json_encode(array('msg'=>'完成数量大于外购总数量!','success'=>false));exit;
  878. }
  879. if($w['rknum']+$num == $w['num'])
  880. {
  881. $dbapi = 99;
  882. $cz = 2;
  883. }
  884. else
  885. {
  886. $dbapi = 0;
  887. }
  888. $scid = explode('~',$w['scid']);
  889. $rkdata = array('od'=>$scid[1],'ts'=>$num,'title'=>$w['title']);
  890. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>99),$id))
  891. {
  892. if($dbapi == 99)
  893. {
  894. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  895. }
  896. else
  897. {
  898. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  899. }
  900. }
  901. else
  902. {
  903. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  904. }
  905. }
  906. **/
  907. }
  908. }
  909. public function _db()
  910. {
  911. $post = $this->input->post(NULL, TRUE);
  912. if(isset($post['id']))
  913. {
  914. $id = $this->input->post('id',true);
  915. $num = $this->input->post('num',true);
  916. $warehouse = $this->input->post('warehouse',true);
  917. $w = $this->warehouse->read($warehouse);
  918. $data = $this->whlabel_bh->read($id);
  919. if(!$data)
  920. {
  921. echo json_encode(array('msg'=>'此备货信息已被删除','success'=>false));exit;
  922. }
  923. $d = $this->whlabel_bh_list->find_all("uid = '".$id."'");
  924. $ydbnum = sprintf("%01.2f",array_sum(array_column($d,'num')));
  925. if($num > $data['rknum']-$ydbnum)
  926. {
  927. echo json_encode(array('msg'=>'调拨数量不允许大于(备货入库数量-已调拨数量)','success'=>false));exit;
  928. }
  929. $data['dccbm'] = 13001;//默认从许昌仓调出
  930. $data['ts'] = $num;
  931. $data['drcbm'] = $w['yybm'];
  932. $dc = $this->apiyy->get_cpdc($data);
  933. if(isset($dc['Data'][0]))
  934. {
  935. if($dc['Data'][0]['IsSucess'] != 1)
  936. {
  937. echo json_encode(array('msg'=>$dc['Data'][0]['ErrorMsg'].'-1','success'=>false));exit;
  938. }
  939. else
  940. {
  941. $sh = $this->apiyy->get_order_sh($data,'SO/Submit','SO/Approve',130);
  942. if(isset($sh['Data'][0]))
  943. {
  944. $code = $sh['Data'][0]['Code'];
  945. echo json_encode(array('msg'=>$sh['Data'][0]['ErrorMsg'].'-2','success'=>false));
  946. }
  947. else
  948. {
  949. $code = '';
  950. echo json_encode(array('msg'=>'调出成功!','success'=>true));
  951. }
  952. $p['uid'] = $id;
  953. $p['bm'] = $data['bm'];
  954. $p['sku'] = $data['jm'];
  955. $p['shipremarks'] = $data['shipremarks'];
  956. $p['title'] = $data['title'];
  957. $p['zh'] = $data['pm'];
  958. $p['fpdata'] = $data['features'];
  959. $p['num'] = $num;
  960. $p['warehouse'] = 13;//默认从许昌仓调出
  961. $p['rwarehouse'] = $warehouse;
  962. $p['time'] = time();//操作时间
  963. $p['code'] = $code;
  964. $this->whlabel_bh_list->insert($p);
  965. }
  966. }
  967. else
  968. {
  969. echo json_encode(array('msg'=>json_encode($dc),'success'=>false));exit;
  970. }
  971. }
  972. }
  973. public function _del()
  974. {
  975. $post = $this->input->post(NULL, TRUE);
  976. if(isset($post['s']))
  977. {
  978. $id_arr = $this->input->post('s');
  979. $id_arr = explode(',',trim($id_arr,','));
  980. if(!$id_arr)
  981. {
  982. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  983. }
  984. //循环删除记录
  985. foreach ($id_arr as $v)
  986. {
  987. $w = $this->whlabel_bh->read($v);
  988. if($w['state'] > 0)
  989. {
  990. // echo json_encode(array('msg'=>'有已投产产品,无法删除!','success'=>true));exit;
  991. }
  992. }
  993. foreach ($id_arr as $v)
  994. {
  995. $this->whlabel_bh->remove($v);
  996. }
  997. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  998. }
  999. }
  1000. public function _deltransfer()
  1001. {
  1002. $post = $this->input->post(NULL, TRUE);
  1003. if(isset($post['s']))
  1004. {
  1005. $id_arr = $this->input->post('s');
  1006. $id_arr = explode(',',trim($id_arr,','));
  1007. if(!$id_arr)
  1008. {
  1009. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1010. }
  1011. if(count($id_arr) > 1)
  1012. {
  1013. echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit;
  1014. }
  1015. foreach ($id_arr as $v)
  1016. {
  1017. $this->whlabel_bh_transfer->remove($v);
  1018. }
  1019. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1020. }
  1021. }
  1022. public function _kc()
  1023. {
  1024. $post = $this->input->post(NULL, TRUE);
  1025. if(isset($post['category']))
  1026. {
  1027. $list = array();
  1028. $sku = $this->input->post('sku',true);
  1029. $features = $this->input->post('features',true);
  1030. $category = $this->input->post('category',true);
  1031. $list['category'] = $category;
  1032. $list['hairtype'] = $this->input->post('hairtype',true);
  1033. $list['grade'] = $this->input->post('grade',true);
  1034. $size = $this->input->post('size',true);
  1035. $xzsku = $this->input->post('xzsku',true);
  1036. $list['size'] = rtrim($size,',');
  1037. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1038. $list['extension'] = $this->input->post('extension',true);
  1039. if($category == 1297)
  1040. {
  1041. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1042. }
  1043. if($category == 1702)
  1044. {
  1045. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1046. $list['syother'] = $this->input->post('syother',true);
  1047. }
  1048. if($category == 133)
  1049. {
  1050. $list['fittype'] = $this->input->post('fittype',true);
  1051. $list['acother'] = $this->input->post('acother',true);
  1052. }
  1053. $list['color'] = $this->input->post('color',true);
  1054. $list['lowe'] = $this->input->post('lowe',true);
  1055. if($category == 127)
  1056. {
  1057. $list['type'] = $this->input->post('type',true);
  1058. $list['headroad'] = $this->input->post('headroad',true);
  1059. $list['density'] = $this->input->post('density',true);
  1060. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1061. {
  1062. $list['lacesize'] = $this->input->post('lacesize',true);
  1063. }
  1064. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1065. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1066. }
  1067. if($category == 128)
  1068. {
  1069. $list['lacetype'] = $this->input->post('lacetype',true);
  1070. $list['haircap'] = $this->input->post('haircap',true);
  1071. $list['density'] = $this->input->post('density',true);
  1072. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1073. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1074. $list['wigother'] = $this->input->post('wigother',true);
  1075. $list['wigother1'] = $this->input->post('wigother1',true);
  1076. $list['wigother2'] = $this->input->post('wigother2',true);
  1077. }
  1078. if($category == 129)
  1079. {
  1080. $list['wide'] = $this->input->post('wide',true);
  1081. }
  1082. if($category == 131)
  1083. {
  1084. $list['gifttype'] = $this->input->post('gifttype',true);
  1085. $list['giftother'] = $this->input->post('giftother',true);
  1086. }
  1087. if($category == 134)
  1088. {
  1089. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1090. }
  1091. if($category == 1297)
  1092. {
  1093. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1094. $list['sywigother'] = $this->input->post('sywigother',true);
  1095. }
  1096. if($category == 130 || $category == 133 || $category == 1702)
  1097. {
  1098. $list['items'] = $this->input->post('items',true);
  1099. $list['weight'] = $this->input->post('weight',true);
  1100. }
  1101. if($category == 1702)
  1102. {
  1103. $list['syhairther'] = $this->input->post('syhairther',true);
  1104. }
  1105. $shipremarks = '';
  1106. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1107. foreach($list as $k=>$v)
  1108. {
  1109. if($v != 0)
  1110. {
  1111. $shipremarks .=$v.'-';
  1112. }
  1113. }
  1114. $shipremarks = '-'.$shipremarks;
  1115. if($features)
  1116. {
  1117. $shipremarks = $features;
  1118. }
  1119. $w = $this->whlabel->find_count("features = '$shipremarks' and state = '0' and zd = '' and warehouse = '13'");//默认许昌仓
  1120. if($w > 0)
  1121. {
  1122. echo json_encode(array('msg'=>$w,'success'=>true));exit;
  1123. }
  1124. else
  1125. {
  1126. echo json_encode(array('msg'=>'没有可用库存','cs'=>$shipremarks,'success'=>false));
  1127. }
  1128. }
  1129. }
  1130. public function _excel()
  1131. {
  1132. $classid = $this->classid->sku();
  1133. $pm = $classid;
  1134. $typeclass = array();
  1135. $tc = $this->typeclass->find_all();
  1136. foreach ($tc as $v)
  1137. {
  1138. $typeclass[$v['id']] = $v;
  1139. }
  1140. $prc = array();
  1141. $purchase = $this->purchase->find_all();
  1142. foreach($purchase as $k=>$v)
  1143. {
  1144. $prc[$v['id']] = $v['title'];
  1145. }
  1146. if(isset($_GET['excel']))
  1147. {
  1148. $number = $this->input->post('number',true);
  1149. $sku = $this->input->post('sku',true);
  1150. $title = $this->input->post('title',true);
  1151. $pm = $this->input->post('pm',true);
  1152. $category = $this->input->post('category',true);
  1153. $size = $this->input->post('size',true);
  1154. $grade = $this->input->post('grade',true);
  1155. $color = $this->input->post('color',true);
  1156. $lowe = $this->input->post('lowe',true);
  1157. $state = $this->input->post('state',true);
  1158. $shipremarks = $this->input->post('shipremarks',true);
  1159. $type = $this->input->post('type',true);
  1160. $sid = $this->input->get('sid',true);
  1161. $ktime = $this->input->get('ktime',true);
  1162. $jtime = $this->input->get('jtime',true);
  1163. $ktime = strtotime($ktime);
  1164. $jtime = strtotime($jtime);
  1165. $where = "1=1";$gj = "";$ck = "";
  1166. if($number)
  1167. {
  1168. $where .= " and number like '%$number%'";
  1169. }
  1170. if($type != '')
  1171. {
  1172. $where .= " and type = '$type'";
  1173. }
  1174. if($sku)
  1175. {
  1176. $where .= " and sku like '%$sku%'";
  1177. }
  1178. if($title)
  1179. {
  1180. $where .= " and title like '%$title%'";
  1181. }
  1182. if($pm)
  1183. {
  1184. $where .= " and pm like '%$pm%'";
  1185. }
  1186. if($category)
  1187. {
  1188. $where .= " and shipremarks like '%-$category-%'";
  1189. }
  1190. if($size)
  1191. {
  1192. $where .= " and shipremarks like '%-$size-%'";
  1193. }
  1194. if($grade)
  1195. {
  1196. $where .= " and shipremarks like '%-$grade-%'";
  1197. }
  1198. if($color)
  1199. {
  1200. $where .= " and shipremarks like '%-$color-%'";
  1201. }
  1202. if($lowe)
  1203. {
  1204. $where .= " and shipremarks like '%-$lowe-%'";
  1205. }
  1206. if($state)
  1207. {
  1208. $where .= " and state = '$state'";
  1209. }
  1210. if($shipremarks)
  1211. {
  1212. $where .= " and shipremarks like '%$shipremarks%'";
  1213. }
  1214. $sidwhere = '';
  1215. if($sid)
  1216. {
  1217. $sd = "";
  1218. $s = explode(',',trim($sid,','));
  1219. foreach ($s as $value)
  1220. {
  1221. $sd .= " id = ".$value." or";
  1222. }
  1223. $sidwhere = " and (".rtrim($sd,'or').")";
  1224. }
  1225. //数据排序
  1226. $order_str = "time desc";
  1227. if(empty($page))
  1228. {
  1229. $start = 0;
  1230. $perpage = 1;
  1231. }
  1232. else
  1233. {
  1234. $start = ($page - 1)*$perpage;
  1235. }
  1236. //取得信息列表
  1237. /**
  1238. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  1239. $rows = array();$list = array();
  1240. foreach ($info_list as $key=>$value)
  1241. {
  1242. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1243. }
  1244. **/
  1245. $warehouse = $this->warehouse->find_all();
  1246. $ck = array();
  1247. foreach ($warehouse as $v)
  1248. {
  1249. $ck[$v['id']] = $v['title'];
  1250. }
  1251. $list = array();
  1252. $rows = $this->whlabel_bh->find_all($where.$sidwhere,'state,orderinfo,number,jm,title,pm,shipremarks,bhnum,kcnum,num,rknum,dbnum,id,sctime,time');
  1253. foreach ($rows as $key=>$value)
  1254. {
  1255. if($value['state'] == 0)
  1256. {
  1257. $rows[$key]['state'] = "待生产/外购";
  1258. }
  1259. else if($value['state'] == 1)
  1260. {
  1261. $rows[$key]['state'] = "生产/外购中";
  1262. }
  1263. else if($value['state'] == 2)
  1264. {
  1265. $rows[$key]['state'] = "已完成";
  1266. }
  1267. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  1268. $zc = '';
  1269. foreach ($zd as $v)
  1270. {
  1271. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  1272. }
  1273. $rows[$key]['id'] = $zc;
  1274. $rows[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  1275. $rows[$key]['sctime'] = ($value['sctime']>0)?date('Y-m-d',$value['sctime']):'未记录';
  1276. $rows[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  1277. }
  1278. $title = '备货详情';
  1279. $titlename = "<table border=1>
  1280. <tr align='center'>
  1281. <td>状态</td>
  1282. <td>标题</td>
  1283. <td>流水码</td>
  1284. <td>简码</td>
  1285. <td>英文</td>
  1286. <td>中文</td>
  1287. <td>备注</td>
  1288. <td>备货数量</td>
  1289. <td>库存数量</td>
  1290. <td>生产/外购数量</td>
  1291. <td>入库数量</td>
  1292. <td>调拨数量</td>
  1293. <td>调拨详情</td>>
  1294. <td>生产时间</td>>
  1295. <td>操作时间</td>>
  1296. </tr>
  1297. </table>";
  1298. $filename = $title.".xls";
  1299. $tail = "";
  1300. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1301. }
  1302. }
  1303. public function _xxpl()
  1304. {
  1305. /* 订单加入键值-j */
  1306. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1307. $config['upload_path'] = '.'.$dir ;
  1308. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1309. $config['allowed_types'] = 'xls|xlsx|csv';
  1310. $config['max_size'] = 10240;
  1311. $this->load->library('upload', $config);
  1312. $this->upload->initialize($config);
  1313. if ($this->upload->do_upload('userfile'))
  1314. {
  1315. $full_path = $dir.$this->upload->data('file_name');
  1316. $fileName = '.' . $full_path;
  1317. if (!file_exists($fileName))
  1318. {
  1319. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1320. }
  1321. else
  1322. {
  1323. require_once "./data/excel/PHPExcel/IOFactory.php";
  1324. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1325. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1326. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1327. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1328. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1329. ++$column;//如果列数大于26行
  1330. $list = array();
  1331. for ($i = 2; $i <= $row; $i++) // 行数循环
  1332. {
  1333. $data = array();
  1334. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1335. {
  1336. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1337. }
  1338. $list[] = $data;
  1339. }
  1340. }
  1341. $tc = $this->typeclass->find_all();
  1342. $typeclass = array();
  1343. foreach ($tc as $v)
  1344. {
  1345. $typeclass[$v['jm']] = array('id'=>$v['id'],'zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  1346. }
  1347. $i = 0;$j = 0;$ed = array();
  1348. $classid = $this->classid->sku();
  1349. $typeclassid = [];
  1350. foreach($tc as $v){
  1351. $typeclassid[$v['id']] = array('id'=>$v['id'],'zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  1352. }
  1353. $i = 0;$j = 0;$ed = [];
  1354. $ck = [
  1355. "成品仓"=>'99001',
  1356. "美国仓"=>'02031',
  1357. "AP"=>'0103001',
  1358. "WK"=>'0103002',
  1359. "QV"=>'0103003',
  1360. "AS"=>'0103004',
  1361. "H"=>"0103005",
  1362. "AP英"=>"0103006",
  1363. "YMS"=>"0103007",
  1364. "AP新"=>"0103008",
  1365. "WK新"=>"0103009",
  1366. "H新"=>"0103010",
  1367. "Bilisar"=>"0103011",
  1368. "Estilar"=>"0103012",
  1369. "QM"=>"0103013",
  1370. "Afola"=>"0103014",
  1371. "拼多多-Finsa"=>"0106002",
  1372. "拼多多-艾彩"=>"0105001",
  1373. "拼多多-Estilar"=>"0106001",
  1374. "拼多多-QM"=>"0106003",
  1375. ];
  1376. foreach($list as $k=>$v){
  1377. $res = $this->logic_u9tools->getGoodInfoByErpSku($v[0],$v[1],$typeclass,$typeclassid,$classid);
  1378. if($res['code']==1){
  1379. //传输料号开始
  1380. $post = $res['data'];
  1381. $post['orderinfo'] = $v[2];
  1382. $post['num'] = $v[5];
  1383. $post['state'] = ($v[3] == '生产')?0:1;
  1384. $post['purchase'] = "";//供货商
  1385. $post['shipremarks'] = empty($v[6])?" ":$v[6];//
  1386. $post['rknum'] = 0;
  1387. $post['scapi'] = 0;
  1388. $post['dbapi'] = 0;
  1389. $post['bhnum'] = $v[5];
  1390. if(isset($ck[$v[4]])){
  1391. $post['kh'] = $ck[$v[4]];
  1392. }else{
  1393. $j++;
  1394. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1395. continue;
  1396. }
  1397. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  1398. $this->logic_ding->sendToDing("备货批量导入出现的错误信息".json_encode($lh,JSON_UNESCAPED_UNICODE));
  1399. if(isset($lh['Data'][0]))
  1400. {
  1401. if($lh['Data'][0]['m_isSucess'] != 1)
  1402. {
  1403. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1404. {
  1405. $j++;
  1406. $ed[] = array($lh['Data'][0]['m_errorMsg'],$post['jm'],$post['bm']);
  1407. }
  1408. }
  1409. }
  1410. else
  1411. {
  1412. $j++;
  1413. $ed[] = array('料号错误',$post['jm'],$post['bm']);
  1414. }
  1415. if($this->whlabel_bh->insert($post))
  1416. {
  1417. $i++;
  1418. }
  1419. else
  1420. {
  1421. $j++;
  1422. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1423. }
  1424. }else{
  1425. $j++;
  1426. $ed[] = array($res['msg'],$v[1],"");
  1427. }
  1428. }
  1429. if($j > 0)
  1430. {
  1431. $time = date('Ymd',time());
  1432. $title = '错误信息-'.$time;
  1433. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  1434. $tail = "\n";
  1435. $filename = $title.".xls";
  1436. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  1437. $dir = '/data/excel/'.$time.'/';
  1438. $file_name = 'error_'.$time.rand(1000,9999);
  1439. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  1440. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  1441. fwrite($myfile,$ecl);
  1442. fclose($myfile);
  1443. $error = $dir.$file_name.'.xls';
  1444. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  1445. }
  1446. else
  1447. {
  1448. echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>1,'success'=>true));exit;
  1449. }
  1450. }
  1451. else
  1452. {
  1453. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  1454. }
  1455. }
  1456. public function _cslh($jm,$title,$pm,$bm)
  1457. {
  1458. $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$title,'zh'=>$pm,'bm'=>$bm));
  1459. if(isset($lh['Data'][0]))
  1460. {
  1461. if($lh['Data'][0]['m_isSucess'] != 1)
  1462. {
  1463. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1464. {
  1465. return array('msg'=>$lh['Data'][0]['m_errorMsg'],'x'=>1);exit;
  1466. }
  1467. }
  1468. }
  1469. else
  1470. {
  1471. return array('msg'=>'料号错误','x'=>1);exit;
  1472. }
  1473. return array('x'=>2);exit;
  1474. }
  1475. public function _bbprint()
  1476. {
  1477. $time = time();
  1478. $post = $this->input->post(NULL);
  1479. if(isset($post['d']))
  1480. {
  1481. $order = 0;$time = time();
  1482. $d = $this->input->post('d',true);
  1483. $n = $this->input->post('n',true);//打印数量
  1484. $data = $this->whlabel_bh->read($d);
  1485. if(!$data)
  1486. {
  1487. echo json_encode(array('msg'=>'未找到此备货信息,请刷新页面重试','success'=>false));exit;
  1488. }
  1489. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$data['number']."'");
  1490. $printnum = array_sum(array_column($printnum,'ts'));
  1491. if(($data['bhnum'] + 1)-$printnum-$n < 0)
  1492. {
  1493. echo json_encode(array('msg'=>'打印数量不可超出备货数量!','success'=>false));exit;
  1494. }
  1495. $post['number'] = $data['number'];
  1496. $post['orderinfo'] = $data['orderinfo'];
  1497. $post['type'] = 0;//0生产 1外购
  1498. $post['features'] = $data['features'];
  1499. $post['jm'] = $data['jm'];
  1500. $post['bm'] = $data['bm'];
  1501. $post['pm'] = $data['pm'];
  1502. $post['sku'] = $data['sku'];
  1503. $post['features'] = $data['features'];
  1504. $post['number'] = $data['number'];
  1505. $post['title'] = $data['title'];
  1506. $post['printtime'] = $time;
  1507. $post['ts'] = 1;
  1508. // $post['rk'] = "";//默认订单中心 打印后直接入库
  1509. // $post['rktime'] = "";
  1510. // $post['ctime15'] = $time;
  1511. $post['time'] = $time;
  1512. $post['gtime'] = date('Yms',$time);
  1513. $post['wbid'] = $data['id'];
  1514. $rows = array();
  1515. $label = date("ymdHis").rand(1000,9999);
  1516. $post['label'] = $label;
  1517. // if($this->whlabel_bh_transfer->insert($post))
  1518. // {
  1519. // echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1520. // }
  1521. // else
  1522. // {
  1523. // $this->db->trans_rollback();
  1524. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1525. // }
  1526. if(stripos($post['features'],'-126-') !== false)
  1527. {
  1528. $drck = '12003';//进入发条库
  1529. }
  1530. else if(stripos($post['features'],'-127-') !== false)
  1531. {
  1532. $drck = '12004';//进入发块库
  1533. }
  1534. else
  1535. {
  1536. $drck = '12006';//其它进入完成库
  1537. }
  1538. //创建u9的生产单
  1539. $token = $this->settingtest->get_yytoken_120();
  1540. $params = [
  1541. 'org_code'=>"120",
  1542. 'djhlx'=>'2000',
  1543. 'scbm_code'=>"12008",
  1544. "time"=>time(),
  1545. 'owner_org_code'=>"120",
  1546. 'title'=>$post['orderinfo'],
  1547. 'shipremarks'=>$data['shipremarks'],
  1548. 'list'=>[
  1549. [
  1550. 'drck'=>$drck,
  1551. 'jm'=>$post['jm'],
  1552. 'sl'=>$n,
  1553. 'drck'=>$drck,
  1554. ]
  1555. ]
  1556. ];
  1557. $res = $this->apiyyv1->scdCreate($params,$token);
  1558. $this->logic_ding->sendToDing("【".$post['orderinfo']."-".$data['id']."】生产备货同步u9||".json_encode($res,JSON_UNESCAPED_UNICODE));
  1559. if(!isset($res[0]['Data'])){
  1560. echo json_encode(array('msg'=>'u9同步返回异常,请重试!','success'=>false));exit;
  1561. }
  1562. if(!$res[0]['Data'][0]['m_isSucess']){
  1563. echo json_encode(array('msg'=>'u9同步失败,请重试!','success'=>false));exit;
  1564. }
  1565. $scid = $res[0]['Data'][0]['m_iD']."~".$res[0]['Data'][0]['m_code']."~".$drck;
  1566. $post['scid'] = $scid;
  1567. $post['scapi'] = 1;
  1568. $post['dbapi'] = 0;
  1569. $this->db->trans_begin();
  1570. $post['shipremarks'] = $data['shipremarks'];
  1571. for($i = 0;$i < $n;$i++){
  1572. $post['label'] = $label.$i;
  1573. $rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['pm'],'n'=>1);
  1574. $this->whlabel_bh_transfer->insert($post);
  1575. }
  1576. if ($this->db->trans_status() === TRUE)
  1577. {
  1578. $this->db->trans_commit();
  1579. echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1580. }else{
  1581. $this->db->trans_rollback();
  1582. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1583. }
  1584. }
  1585. }
  1586. public function _bdbb()
  1587. {
  1588. $post = $this->input->post(NULL, TRUE);
  1589. if(isset($post['s']))
  1590. {
  1591. $id_arr = $this->input->post('s');
  1592. $id_arr = explode(',',trim($id_arr,','));
  1593. if(!$id_arr)
  1594. {
  1595. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1596. }
  1597. //循环删除记录
  1598. foreach ($id_arr as $v)
  1599. {
  1600. $t = $this->whlabel_bh_transfer->read($v);
  1601. if(!isset($t['number']))
  1602. {
  1603. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1604. }
  1605. $rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>1);
  1606. }
  1607. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1608. }
  1609. }
  1610. public function _out()
  1611. {
  1612. $post = $this->input->post(NULL, TRUE);
  1613. if(isset($post['label']))
  1614. {
  1615. $time = time();
  1616. $label = $this->input->post('label',true);
  1617. $cz = $this->input->post('cz',true);
  1618. $transfer = $this->input->post('transfer',true);
  1619. if(!$label)
  1620. {
  1621. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  1622. }
  1623. if(!$transfer)
  1624. {
  1625. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  1626. }
  1627. $lb = $this->whlabel_bh_transfer->get_label($label);
  1628. if(!$lb)
  1629. {
  1630. echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
  1631. }
  1632. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1633. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1634. $tdata = $this->transfer->find_all();
  1635. $t = array();
  1636. foreach ($tdata as $v)
  1637. {
  1638. $t[$v['id']] = $v['title'];
  1639. }
  1640. if($cz == 1)
  1641. {
  1642. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1643. {
  1644. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1645. }
  1646. }
  1647. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1648. {
  1649. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1650. }
  1651. if($cz == 1)
  1652. {
  1653. $lb['rk'] .= $transfer.'|';
  1654. $lb['rktime'] .= $time.'|';
  1655. if($lbrk[0] == $transfer)
  1656. {
  1657. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1658. }
  1659. //必须走配货
  1660. if(($transfer != 1) && (strpos($lb['rk'],'|1|') === false) ){
  1661. echo json_encode(array('msg'=>'请先到配货!','success'=>false));exit;
  1662. }
  1663. }
  1664. else if($cz == 2)
  1665. {
  1666. $lb['ck'] .= $transfer.'|';
  1667. $lb['cktime'] .= $time.'|';
  1668. if($lbck[0] == $transfer)
  1669. {
  1670. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1671. }
  1672. }
  1673. $cztime = 'ctime'.$transfer;
  1674. //如果是完成扫出 这样会通知erp生成一个调出单
  1675. if($transfer == 3 && $cz == 2 && $lb['dbapi'] < 99){
  1676. $this->db->trans_begin();
  1677. $this->whlabel_bh_transfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time,'status'=>2,'dbapi'=>99),$lb['id']);
  1678. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1]);
  1679. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1680. if($ct_info){
  1681. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1682. }
  1683. $this->zzquque_u9->insert([
  1684. 'platform'=>'',
  1685. 'warehouse'=>0,
  1686. 'type'=>21,
  1687. 'order_no'=>$lb['orderinfo'],
  1688. 'child_order_no'=>$lb['id'],
  1689. 'status'=>0,
  1690. 'create_time'=>time(),
  1691. 'update_time'=>time(),
  1692. ]);
  1693. if ($this->db->trans_status() === TRUE){
  1694. $this->db->trans_commit();
  1695. echo json_encode(array('music'=>'1','success'=>true));exit;
  1696. }else{
  1697. $this->db->trans_rollback();
  1698. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1699. }
  1700. }
  1701. //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1702. if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
  1703. {
  1704. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1705. }
  1706. $save_data = [
  1707. 'rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time
  1708. ];
  1709. //配货入库需更新一下配货状态
  1710. if($transfer == 1 && $cz == 1 && $lb['status'] == 0){
  1711. $save_data['status'] = 1;
  1712. }
  1713. $this->db->trans_begin();
  1714. $this->whlabel_bh_transfer->save($save_data,$lb['id']);
  1715. if($cz == 2){
  1716. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1]);
  1717. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1718. if($ct_info){
  1719. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1720. }
  1721. }else{
  1722. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>0]);
  1723. }
  1724. if ($this->db->trans_status() === TRUE){
  1725. $this->db->trans_commit();
  1726. echo json_encode(array('music'=>'1','success'=>true));exit;
  1727. }else{
  1728. $this->db->trans_rollback();
  1729. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1730. }
  1731. }
  1732. }
  1733. protected function getOperateList(){
  1734. $api = $this->input->post('api',true);
  1735. $page = $this->input->post('page',true);
  1736. $perpage = $this->input->post('perpage',true);
  1737. $orderinfo = $this->input->post('number',true);
  1738. $color = $this->input->post('color',true);
  1739. $pm = $this->input->post('pm',true);
  1740. $purchase = $this->input->post('purchase',true);
  1741. $transfer = $this->input->post('transfer',true);
  1742. $lx = $this->input->post('lx',true);
  1743. $timetk = $this->input->post('timetk',true);
  1744. $timetj = $this->input->post('timetj',true);
  1745. $timetk = strtotime($timetk);
  1746. $timetj = strtotime($timetj);
  1747. $where = "1=1";
  1748. if($transfer)
  1749. {
  1750. $ctime = 'ctime'.$transfer;
  1751. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1752. }
  1753. else
  1754. {
  1755. $where .= " and time > '$timetk' and time < '$timetj'";
  1756. }
  1757. if($orderinfo)
  1758. {
  1759. $where .= " and orderinfo like '%$orderinfo%'";
  1760. }
  1761. if($transfer)
  1762. {
  1763. $where .= " and rk like '%|".$transfer."|%'";
  1764. }
  1765. if($purchase)
  1766. {
  1767. $where .= " and purchase = '$purchase'";
  1768. }
  1769. if($pm)
  1770. {
  1771. $where .= " and pm like '%$pm%'";
  1772. }
  1773. if($color)
  1774. {
  1775. $where .= " and fpdata like '%-".$color."-%'";
  1776. }
  1777. //数据排序
  1778. $order_str = "id desc";
  1779. if(empty($page))
  1780. {
  1781. $start = 0;
  1782. $perpage = 1;
  1783. }
  1784. else
  1785. {
  1786. $start = ($page - 1)*$perpage;
  1787. }
  1788. //取得信息列表
  1789. $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage);
  1790. $transfer = $this->transfer->find_all();
  1791. $t = array();$ot = array();
  1792. foreach ($transfer as $v)
  1793. {
  1794. $t[$v['id']] = $v['title'];
  1795. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1796. }
  1797. //格式化数据
  1798. foreach ($info_list as $key=>$value)
  1799. {
  1800. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1801. $log_list= $this->whlabel_bh_transfer_cr->find_all("fid = ".$value['id']);
  1802. $tmp_operate_str = "";
  1803. foreach($log_list as $k=>$v){
  1804. $tmp_operate_str.= $t[$v['lx']]."".($v['type']==1?'入库':'出库').":".date('Y-m-d H:i:s',$v['time'])."<br>";
  1805. }
  1806. $info_list[$key]['time'] = trim($tmp_operate_str,'<br>');
  1807. }
  1808. $total = $this->whlabel_bh_transfer->find_count($where);
  1809. $pagenum = ceil($total/$perpage);
  1810. $over = $total-($start+$perpage);
  1811. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'where'=>$where);
  1812. return $rows;
  1813. }
  1814. public function _operate()
  1815. {
  1816. $post = $this->input->post(NULL, TRUE);
  1817. if(isset($post['page']))
  1818. {
  1819. $rows = $this->getOperateList();
  1820. echo json_encode($rows);exit;
  1821. }
  1822. if(isset($_SESSION['api']))
  1823. {
  1824. $user = $this->user->get_api($_SESSION['api']);
  1825. $usp = $user;
  1826. $pid = "";$tid="";$sid="";$wid="";
  1827. $purchase = explode('|',trim($user['purchase'],'|'));
  1828. $transfer = explode('|',trim($user['transfer'],'|'));
  1829. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1830. foreach ($purchase as $value)
  1831. {
  1832. $pid .= " id = ".$value." or";
  1833. }
  1834. foreach ($transfer as $value)
  1835. {
  1836. $tid .= " id = ".$value." or";
  1837. }
  1838. foreach ($warehouse as $value)
  1839. {
  1840. $wid .= " id = ".$value." or";
  1841. }
  1842. }
  1843. else
  1844. {
  1845. header('Location: /');exit;
  1846. }
  1847. $kx = '';$zjtab = '';
  1848. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1849. $this->data['warehouse'] = $warehouse;
  1850. $purchase = $this->purchase->find_all("yyid != ''");
  1851. $this->data['purchase'] = $purchase;
  1852. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1853. $this->data['transfer'] = $transfer;
  1854. $ids = array_column($transfer,'id');
  1855. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  1856. $start_time = $end_time - 14 * 24 * 60 * 60;
  1857. $count = $this->whlabel_bh_transfer_cr->find_count("type = 1 and is_over = 0 and lx in (".implode(",",$ids).") and time >= ".$start_time." and time <= ".$end_time );
  1858. $this->data['count'] = $count;
  1859. $this->data['vip'] = $user['vip'];
  1860. $this->_Template('whlabel_bh_operate',$this->data);
  1861. }
  1862. public function _rk()
  1863. {
  1864. $post = $this->input->post(NULL, TRUE);
  1865. if(isset($post['page']))
  1866. {
  1867. $res = $this->getOperateList();
  1868. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  1869. echo json_encode($rows);exit;
  1870. }
  1871. if(isset($_SESSION['api']))
  1872. {
  1873. $user = $this->user->get_api($_SESSION['api']);
  1874. $usp = $user;
  1875. $pid = "";$tid="";$sid="";$wid="";
  1876. $purchase = explode('|',trim($user['purchase'],'|'));
  1877. $transfer = explode('|',trim($user['transfer'],'|'));
  1878. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1879. foreach ($purchase as $value)
  1880. {
  1881. $pid .= " id = ".$value." or";
  1882. }
  1883. foreach ($transfer as $value)
  1884. {
  1885. $tid .= " id = ".$value." or";
  1886. }
  1887. foreach ($warehouse as $value)
  1888. {
  1889. $wid .= " id = ".$value." or";
  1890. }
  1891. }
  1892. else
  1893. {
  1894. header('Location: /');exit;
  1895. }
  1896. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1897. $this->data['transfer'] = $transfer;
  1898. $this->_Template('whlabel_bh_rk',$this->data);
  1899. }
  1900. public function _ck()
  1901. {
  1902. $post = $this->input->post(NULL, TRUE);
  1903. if(isset($post['page']))
  1904. {
  1905. $res = $this->getOperateList();
  1906. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  1907. echo json_encode($rows);exit;
  1908. }
  1909. if(isset($_SESSION['api']))
  1910. {
  1911. $user = $this->user->get_api($_SESSION['api']);
  1912. $usp = $user;
  1913. $pid = "";$tid="";$sid="";$wid="";
  1914. $purchase = explode('|',trim($user['purchase'],'|'));
  1915. $transfer = explode('|',trim($user['transfer'],'|'));
  1916. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1917. foreach ($purchase as $value)
  1918. {
  1919. $pid .= " id = ".$value." or";
  1920. }
  1921. foreach ($transfer as $value)
  1922. {
  1923. $tid .= " id = ".$value." or";
  1924. }
  1925. foreach ($warehouse as $value)
  1926. {
  1927. $wid .= " id = ".$value." or";
  1928. }
  1929. }
  1930. else
  1931. {
  1932. header('Location: /');exit;
  1933. }
  1934. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1935. $this->data['transfer'] = $transfer;
  1936. $this->_Template('whlabel_bh_ck',$this->data);
  1937. }
  1938. //备货流转记录表
  1939. public function _transfer_log(){
  1940. $post = $this->input->post(NULL, TRUE);
  1941. if($post){
  1942. $page = $this->input->post('page',true);
  1943. $perpage = $this->input->post('perpage',true);
  1944. $where = "";
  1945. if(empty($page))
  1946. {
  1947. $start = 0;
  1948. $perpage = 1;
  1949. }
  1950. else
  1951. {
  1952. $start = ($page - 1)*$perpage;
  1953. }
  1954. $list = $this->whlabel_bh->find_all($where,"*",'id desc',$start,$perpage);
  1955. $rows = [];
  1956. foreach($list as $k=>$v){
  1957. $list = $this->whlabel_bh_transfer->find_all(" orderinfo= '".$v['orderinfo']."'");
  1958. $ydysl = $wdysl = $yphsl = $yjgsj = $wwgsl = 0;
  1959. foreach($list as $vv){
  1960. $ydysl += 1;
  1961. if($vv['status'] == 1){
  1962. $yphsl += 1;
  1963. }
  1964. if($vv['status'] == 2){
  1965. $yjgsj += 1;
  1966. }
  1967. }
  1968. $rows[$k]['id'] = $v['id'];
  1969. $rows[$k]['orderinfo'] = "<h9 class='window' data-h='/whlabel_bh/transfer_detail/".$v['id']."' data-t='订单号:".$v['orderinfo']."'><p>".$v['orderinfo']."</p></h9>" ;
  1970. $rows[$k]['ddsl'] = $v['bhnum']; //订单数量
  1971. $rows[$k]['ydysl'] = $ydysl; //已打印数量
  1972. $rows[$k]['wdysl'] = $v['bhnum'] - $ydysl; //未打印数量
  1973. $rows[$k]['yphsl'] = $yphsl; //已配货数量
  1974. $rows[$k]['yjgsj'] = $yjgsj; //已完工数量
  1975. $rows[$k]['wwgsl'] = $v['bhnum'] - $yjgsj; //未完工数量
  1976. }
  1977. $total = $this->whlabel_bh->find_count($where);
  1978. $pagenum = ceil($total/$perpage);
  1979. $over = $total-($start+$perpage);
  1980. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  1981. echo json_encode($rows);exit;
  1982. }
  1983. $this->_Template('whlabel_bh_transfer_log',$this->data);
  1984. }
  1985. public function _transfer_detail($arg_array){
  1986. var_dump($arg_array);exit;
  1987. }
  1988. }