Whlabel_bh.php 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564
  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 if($arg == 'cj_transfer_log'){
  120. $this->_cj_transfer_log();
  121. }
  122. else if($arg == 'cj_transfer_detail'){
  123. $this->_cj_transfer_detail($arg_array);
  124. }
  125. else if($arg == 'cj_transfer_log_count'){
  126. $this->_cj_transfer_log_count();
  127. }
  128. else if($arg == 'excelwchz'){
  129. $this->_excelwchz();
  130. }
  131. else
  132. {
  133. $this->_index();
  134. }
  135. }
  136. //管理
  137. public function _index()
  138. {
  139. $post = $this->input->post(NULL, TRUE);
  140. if(isset($post['page']))
  141. {
  142. $page = $this->input->post('page',true);
  143. $perpage = $this->input->post('perpage',true);
  144. $orderinfo = $this->input->post('orderinfo',true);
  145. $jm = $this->input->post('jm',true);
  146. $title = $this->input->post('title',true);
  147. $pm = $this->input->post('pm',true);
  148. $category = $this->input->post('category',true);
  149. $size = $this->input->post('size',true);
  150. $grade = $this->input->post('grade',true);
  151. $color = $this->input->post('color',true);
  152. $lowe = $this->input->post('lowe',true);
  153. $type = $this->input->post('type',true);
  154. $shipremarks = $this->input->post('shipremarks',true);
  155. $type = $this->input->post('type',true);
  156. $state = $this->input->post('state',true);
  157. $timetk = $this->input->post('timetk',true);
  158. $timetj = $this->input->post('timetj',true);
  159. $timetk = strtotime($timetk);
  160. $timetj = strtotime($timetj);
  161. $where = "1=1 ";
  162. if($timetk && $timetj)
  163. {
  164. $where .= " and time > '$timetk' and time < '$timetj'";
  165. }
  166. if($orderinfo)
  167. {
  168. $where .= " and orderinfo like '%$orderinfo%'";
  169. }
  170. if($type != '')
  171. {
  172. $where .= " and type = '$type'";
  173. }
  174. if($jm)
  175. {
  176. $where .= " and jm like '%$jm%'";
  177. }
  178. if($title)
  179. {
  180. $where .= " and title like '%$title%'";
  181. }
  182. if($pm)
  183. {
  184. $where .= " and pm like '%$pm%'";
  185. }
  186. if($category)
  187. {
  188. $where .= " and shipremarks like '%-$category-%'";
  189. }
  190. if($size)
  191. {
  192. $where .= " and shipremarks like '%-$size-%'";
  193. }
  194. if($grade)
  195. {
  196. $where .= " and shipremarks like '%-$grade-%'";
  197. }
  198. if($color)
  199. {
  200. $where .= " and shipremarks like '%-$color-%'";
  201. }
  202. if($lowe)
  203. {
  204. $where .= " and shipremarks like '%-$lowe-%'";
  205. }
  206. if($type)
  207. {
  208. $where .= " and type = '$type'";
  209. }
  210. if($state)
  211. {
  212. $where .= " and state = '$state'";
  213. }
  214. if($shipremarks)
  215. {
  216. $where .= " and shipremarks like '%$shipremarks%'";
  217. }
  218. //数据排序
  219. $order_str = "time desc";
  220. if(empty($page))
  221. {
  222. $start = 0;
  223. $perpage = 1;
  224. }
  225. else
  226. {
  227. $start = ($page - 1)*$perpage;
  228. }
  229. $warehouse = $this->warehouse->find_all();
  230. $ck = array();
  231. foreach ($warehouse as $v)
  232. {
  233. $ck[$v['id']] = $v['title'];
  234. }
  235. //取得信息列表
  236. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,printsl,time,extra_type',$order_str,$start,$perpage);
  237. foreach ($info_list as $key=>$value)
  238. {
  239. $d = $this->whlabel_bh->read($value['id']);
  240. $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'];
  241. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$d['number']."'");
  242. $printnum = array_sum(array_column($printnum,'ts'));
  243. $info_list[$key]['printnum'] = $printnum;
  244. $info_list[$key]['num'] = $value['bhnum']-$printnum;
  245. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  246. if($value['extra_type'] == 1){
  247. $info_list[$key]['extra_type'] = "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";
  248. }else{
  249. $info_list[$key]['extra_type'] = "";
  250. }
  251. }
  252. $total = $this->whlabel_bh->find_count($where);
  253. $pagenum = ceil($total/$perpage);
  254. $over = $total-($start+$perpage);
  255. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  256. echo json_encode($rows);exit;
  257. /**
  258. $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);
  259. foreach ($info_list as $key=>$value)
  260. {
  261. $d = $this->whlabel_bh->read($value['id']);
  262. if($d['print'] == 0)
  263. {
  264. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #2ca8a1;'>未打印</span></p>";
  265. }
  266. else
  267. {
  268. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #999;'>已打印</span></p>";
  269. }
  270. if($value['state'] == 0)
  271. {
  272. $info_list[$key]['state'] = "<p>待生产/外购</p><p><span data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>传输料号</span></p>";//开 始
  273. }
  274. else if($value['state'] == 1)
  275. {
  276. $info_list[$key]['state'] = "<p>生产/外购中</p><p><span data-id='".$value['id']."' data-cz='1' class='whlabel_bh_ks'>完成入库</span></p>".$print;
  277. }
  278. else if($value['state'] == 2)
  279. {
  280. $info_list[$key]['state'] = "<p>已完成</p><p>已全部入库</p>";
  281. }
  282. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  283. $info_list[$key]['title'] = $d['jm'].'<br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  284. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  285. $zc = '';
  286. foreach ($zd as $v)
  287. {
  288. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  289. }
  290. $info_list[$key]['scapi'] = $zc;
  291. $info_list[$key]['dbapi'] = "<span data-id='".$value['id']."' class='whlabel_bh_db'>调拨出库</span>";
  292. $info_list[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  293. }
  294. **/
  295. }
  296. $start_time = time() - 3600*24*29;
  297. $end_time = time() + 3600*24;
  298. $count_list = $this->whlabel_bh->find_all("extra_type = 1 and time > ".$start_time." and time < ".$end_time);
  299. $wdysl = 0;
  300. foreach($count_list as $k=>$v){
  301. $wdysl = $wdysl + ($v['bhnum'] - $v['printsl']);
  302. }
  303. $this->data['wdysl'] = $wdysl;
  304. if(isset($_SESSION['api']))
  305. {
  306. $user = $this->user->get_api($_SESSION['api']);
  307. }
  308. else
  309. {
  310. header('Location: /');exit;
  311. }
  312. $w = $this->shop->find_all("yyid != ''");
  313. $this->data['yyck'] = $w;
  314. if($user['userid'] == 'ch')
  315. {
  316. $user['vip'] = 1;
  317. }
  318. $this->data['vip'] = $user['vip'];
  319. $this->_Template('whlabel_bh',$this->data);
  320. }
  321. //入库操作
  322. public function _add()
  323. {
  324. $tc = $this->typeclass->find_all();
  325. $typeclass = array();
  326. foreach ($tc as $v)
  327. {
  328. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  329. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  330. }
  331. $post = $this->input->post(NULL, TRUE);
  332. if(isset($post['num']))
  333. {
  334. $list = array();
  335. $sku = $this->input->post('sku',true);
  336. $category = $this->input->post('category',true);
  337. $list['category'] = $category;
  338. $list['hairtype'] = $this->input->post('hairtype',true);
  339. $list['grade'] = $this->input->post('grade',true);
  340. $size = $this->input->post('size',true);
  341. $xzsku = $this->input->post('xzsku',true);
  342. $list['size'] = rtrim($size,',');
  343. $list['hairnumber'] = $this->input->post('hairnumber',true);
  344. $list['extension'] = $this->input->post('extension',true);
  345. if($category == 1297)
  346. {
  347. $list['sywignumber'] = $this->input->post('sywignumber',true);
  348. }
  349. if($category == 1702)
  350. {
  351. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  352. $list['syother'] = $this->input->post('syother',true);
  353. }
  354. if($category == 133)
  355. {
  356. $list['fittype'] = $this->input->post('fittype',true);
  357. $list['acother'] = $this->input->post('acother',true);
  358. }
  359. $list['color'] = $this->input->post('color',true);
  360. $list['lowe'] = $this->input->post('lowe',true);
  361. if($category == 127)
  362. {
  363. $list['type'] = $this->input->post('type',true);
  364. $list['headroad'] = $this->input->post('headroad',true);
  365. $list['density'] = $this->input->post('density',true);
  366. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  367. {
  368. $list['lacesize'] = $this->input->post('lacesize',true);
  369. }
  370. $list['lacecolor'] = $this->input->post('lacecolor',true);
  371. $list['lacetypes'] = $this->input->post('lacetypes',true);
  372. }
  373. if($category == 128)
  374. {
  375. $list['lacetype'] = $this->input->post('lacetype',true);
  376. $list['haircap'] = $this->input->post('haircap',true);
  377. $list['density'] = $this->input->post('density',true);
  378. $list['lacecolor'] = $this->input->post('lacecolor',true);
  379. $list['lacetypes'] = $this->input->post('lacetypes',true);
  380. $list['wigother'] = $this->input->post('wigother',true);
  381. $list['wigother1'] = $this->input->post('wigother1',true);
  382. $list['wigother2'] = $this->input->post('wigother2',true);
  383. }
  384. if($category == 129)
  385. {
  386. $list['wide'] = $this->input->post('wide',true);
  387. }
  388. if($category == 131)
  389. {
  390. $list['gifttype'] = $this->input->post('gifttype',true);
  391. $list['giftother'] = $this->input->post('giftother',true);
  392. }
  393. if($category == 134)
  394. {
  395. $list['pieceweight'] = $this->input->post('pieceweight',true);
  396. }
  397. if($category == 1297)
  398. {
  399. $list['synthetictype'] = $this->input->post('synthetictype',true);
  400. $list['sywigother'] = $this->input->post('sywigother',true);
  401. }
  402. if($category == 130 || $category == 133 || $category == 1702)
  403. {
  404. $list['items'] = $this->input->post('items',true);
  405. $list['weight'] = $this->input->post('weight',true);
  406. }
  407. if($category == 1702)
  408. {
  409. $list['syhairther'] = $this->input->post('syhairther',true);
  410. }
  411. $classid = $this->classid->sku();
  412. $pm = $classid;
  413. $jm = $classid;
  414. $sku = $sku;
  415. $title = '';$features = '';$cs = array();
  416. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  417. foreach($list as $k=>$v)
  418. {
  419. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  420. {
  421. if($typeclass[$v]['bm'] != '')
  422. {
  423. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  424. }
  425. }
  426. if($v != 0)
  427. {
  428. if($k != 'size')
  429. {
  430. $title .= $typeclass[$v]['title']." ";
  431. }
  432. $features .=$v.'-';
  433. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  434. if(isset($pm[$typeclass[$v]['classid']]))
  435. {
  436. if($typeclass[$v]['title'] == '9A')
  437. {
  438. $pm[$typeclass[$v]['classid']] = '9A';
  439. }
  440. else if($typeclass[$v]['title'] == '10A')
  441. {
  442. $pm[$typeclass[$v]['classid']] = '10A';
  443. }
  444. else
  445. {
  446. $clzh = $typeclass[$v]['zh'];
  447. if(stripos($typeclass[$v]['zh'],'|') !== false)
  448. {
  449. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  450. $clzh = $clzh[0];
  451. }
  452. $pm[$typeclass[$v]['classid']] = $clzh;
  453. }
  454. }
  455. if(isset($jm[$typeclass[$v]['classid']]))
  456. {
  457. if($typeclass[$v]['jm'])
  458. {
  459. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  460. }
  461. }
  462. }
  463. }
  464. $jm = array_filter($jm);//去除空值
  465. $jm = implode("-",$jm);
  466. $sku = array_filter($sku);//去除空值
  467. $sku = implode("-",$sku);
  468. $pm = array_filter($pm);//去除空值
  469. $pm = implode(" ",$pm);
  470. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  471. if($list['size'])
  472. {
  473. $typeclass = $this->typeclass->read($list['size']);
  474. $title .= $typeclass['title'];
  475. }
  476. $title = trim($title,' ');
  477. $post['num'] = $this->input->post('num',true);
  478. $ztime = $this->input->post('ztime',true);
  479. $post['ztime'] = strtotime($ztime);
  480. $post['bm'] = '03'.implode("",$bmpx);
  481. $post['jm'] = $jm;
  482. $post['sku'] = $sku;
  483. $post['pm'] = $pm;
  484. $post['title'] = $title;
  485. $post['features'] = '-'.$features;
  486. $post['number'] = date('YmdHis',time()).rand(1000,9999);
  487. if(!$post['num'])
  488. {
  489. $post['number'] = date("YmdHis").rand(1000,9999);
  490. }
  491. $time = time();
  492. $post['time'] = $time;//操作时间
  493. $post['printnum'] = $time;
  494. $post['type'] = 0;
  495. $post['extra_type'] = (int)trim($post['extra_type'],',');
  496. //传输料号开始
  497. $lc = 0;
  498. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  499. if(isset($lh['Data'][0]))
  500. {
  501. if($lh['Data'][0]['m_isSucess'] != 1)
  502. {
  503. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  504. {
  505. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$post['bm'],'jm'=>$post['jm'],'success'=>false));exit;
  506. }
  507. }
  508. }
  509. else
  510. {
  511. echo json_encode(array('msg'=>'料号错误','cs'=>$lh,'success'=>false));exit;
  512. }
  513. if($this->whlabel_bh->insert($post))
  514. {
  515. echo json_encode(array('msg'=>'添加成功','cs'=>$cs,'success'=>true));exit;
  516. }
  517. else
  518. {
  519. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  520. }
  521. }
  522. $w = $this->shop->find_all("yyid != ''");
  523. $this->data['yyck'] = $w;
  524. $purchase = $this->purchase->find_all("yyid != ''");
  525. $this->data['purchase'] = $purchase;
  526. $this->data['data'] = (isset($_GET['data']))?$_GET['data']:'';
  527. $this->_Template('whlabel_bh_add',$this->data);
  528. }
  529. public function get_cjlp($data)//创建料品
  530. {
  531. $list["0"]["Code"] = $data['jm'];//料号,SKU
  532. $list["0"]["Code1"] = '';
  533. $list["0"]["Name"] = $data['zh'];//产品名称
  534. $list["0"]["MainItemCategory"]["Code"] = $data['bm'];
  535. $list["0"]["Org"]["Code"] = 001;
  536. $list["0"]["OtherID"] = 1;
  537. $list["0"]["PurchaseInfo"]["BudgetControlType"] = -1;
  538. $list["0"]["PurchaseInfo"]["PriceSource"] = 2;
  539. $list["0"]["PurchaseInfo"]["InquireRule"] = -1;
  540. $list["0"]["PurchaseInfo"]["InquireFixedPeriod"] = 0;
  541. $list["0"]["PurchaseInfo"]["StatisticPeriod"] = -1;
  542. $list["0"]["PurchaseInfo"]["IsPUTradePathModify"] = true;
  543. $list["0"]["PurchaseInfo"]["IsPURtnTradePathModify"] = true;
  544. $list["0"]["InventoryUOM"]["Code"] = '条';
  545. $list["0"]["InventorySecondUOM"]["Code"] = '';
  546. $list["0"]["IsDualUOM"] = false;
  547. $list["0"]["InventoryInfo"]["InventoryPlanningMethod"] = 4;
  548. $list["0"]["InventoryInfo"]["InventoryPlanTime"] = -1;
  549. $list["0"]["InventoryInfo"]["TurnOverRate"] = 1;
  550. $list["0"]["InventoryInfo"]["ReserveMode"] = -1;
  551. $list["0"]["InventoryInfo"]["SupplyMethod"] = -1;
  552. $list["0"]["DescFlexField"]["PrivateDescSeg1"] = 01;
  553. $list["0"]["DescFlexField"]["PubDescSeg5"] = 01;
  554. $list["0"]["Description"] = $data['title'];
  555. $list["0"]["ItemForm"] = 2001;
  556. $list["0"]["ItemFormAttribute"] = 10;
  557. $list["0"]["IsInventoryEnable"] = true;
  558. $list["0"]["IsPurchaseEnable"] = true;
  559. $list["0"]["IsSalesEnable"] = true;
  560. $list["0"]["IsBuildEnable"] = true;
  561. $list["0"]["IsOutsideOperationEnable"] = true;
  562. $list["0"]["IsMRPEnable"] = true;
  563. $list["0"]["IsBOMEnable"] = true;
  564. $list["0"]["IsCostCalByGrade"] = false;
  565. $list["0"]["IsCostCalByPotency"] = false;
  566. $list["0"]["IsGradeControl"] = false;
  567. $list["0"]["StandardGrade"] = -1;
  568. $list["0"]["StartGrade"] = -1;
  569. $list["0"]["EndGrade"] = -1;
  570. $list["0"]["IsPotencyControl"] = false;
  571. $list["0"]["StandardPotency"] = -1;
  572. $list["0"]["StartPotency"] = -1;
  573. $list["0"]["EndPotency"] = -1;
  574. $asd = $list;
  575. $list = json_encode($list);
  576. $token = $this->setting->get_yytoken_130();
  577. $url = 'http://172.31.105.167/U9C/webapi/ItemMaster/Create';
  578. $header[] = "Content-Type: application/json";
  579. $header[] = "Token: ".$token;
  580. $ch = curl_init();
  581. curl_setopt($ch, CURLOPT_URL, $url);
  582. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  583. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  584. curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
  585. curl_setopt($ch, CURLOPT_POST, 1);
  586. curl_setopt($ch, CURLOPT_POSTFIELDS, $list);
  587. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  588. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  589. $res = curl_exec($ch);
  590. $res = json_decode($res,true);
  591. return $asd;
  592. }
  593. //修改产品
  594. public function _edit($arg_array)
  595. {
  596. $tc = $this->typeclass->find_all();
  597. $typeclass = array();
  598. foreach ($tc as $v)
  599. {
  600. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  601. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  602. }
  603. $post = $this->input->post(NULL, TRUE);
  604. if(isset($post['id']))
  605. {
  606. $id = $this->input->post('id',true);
  607. $list = array();
  608. $sku = $this->input->post('sku',true);
  609. $category = $this->input->post('category',true);
  610. $list['category'] = $category;
  611. $list['hairtype'] = $this->input->post('hairtype',true);
  612. $list['grade'] = $this->input->post('grade',true);
  613. $size = $this->input->post('size',true);
  614. $xzsku = $this->input->post('xzsku',true);
  615. $list['size'] = rtrim($size,',');
  616. $list['hairnumber'] = $this->input->post('hairnumber',true);
  617. $list['extension'] = $this->input->post('extension',true);
  618. if($category == 1297)
  619. {
  620. $list['sywignumber'] = $this->input->post('sywignumber',true);
  621. }
  622. if($category == 1702)
  623. {
  624. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  625. $list['syother'] = $this->input->post('syother',true);
  626. }
  627. if($category == 133)
  628. {
  629. $list['fittype'] = $this->input->post('fittype',true);
  630. $list['acother'] = $this->input->post('acother',true);
  631. }
  632. $list['color'] = $this->input->post('color',true);
  633. $list['lowe'] = $this->input->post('lowe',true);
  634. if($category == 127)
  635. {
  636. $list['type'] = $this->input->post('type',true);
  637. $list['headroad'] = $this->input->post('headroad',true);
  638. $list['density'] = $this->input->post('density',true);
  639. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  640. {
  641. $list['lacesize'] = $this->input->post('lacesize',true);
  642. }
  643. $list['lacecolor'] = $this->input->post('lacecolor',true);
  644. $list['lacetypes'] = $this->input->post('lacetypes',true);
  645. }
  646. if($category == 128)
  647. {
  648. $list['lacetype'] = $this->input->post('lacetype',true);
  649. $list['haircap'] = $this->input->post('haircap',true);
  650. $list['density'] = $this->input->post('density',true);
  651. $list['lacecolor'] = $this->input->post('lacecolor',true);
  652. $list['lacetypes'] = $this->input->post('lacetypes',true);
  653. $list['wigother'] = $this->input->post('wigother',true);
  654. $list['wigother1'] = $this->input->post('wigother1',true);
  655. $list['wigother2'] = $this->input->post('wigother2',true);
  656. }
  657. if($category == 129)
  658. {
  659. $list['wide'] = $this->input->post('wide',true);
  660. }
  661. if($category == 131)
  662. {
  663. $list['gifttype'] = $this->input->post('gifttype',true);
  664. $list['giftother'] = $this->input->post('giftother',true);
  665. }
  666. if($category == 134)
  667. {
  668. $list['pieceweight'] = $this->input->post('pieceweight',true);
  669. }
  670. if($category == 1297)
  671. {
  672. $list['synthetictype'] = $this->input->post('synthetictype',true);
  673. $list['sywigother'] = $this->input->post('sywigother',true);
  674. }
  675. if($category == 130 || $category == 133 || $category == 1702)
  676. {
  677. $list['items'] = $this->input->post('items',true);
  678. $list['weight'] = $this->input->post('weight',true);
  679. }
  680. if($category == 1702)
  681. {
  682. $list['syhairther'] = $this->input->post('syhairther',true);
  683. }
  684. $classid = $this->classid->sku();
  685. $pm = $classid;
  686. $jm = $classid;
  687. $sku = $sku;
  688. $title = '';$features = '';$cs = array();
  689. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  690. foreach($list as $k=>$v)
  691. {
  692. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  693. {
  694. if($typeclass[$v]['bm'] != '')
  695. {
  696. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  697. }
  698. }
  699. if($v != 0)
  700. {
  701. if($k != 'size')
  702. {
  703. $title .= $typeclass[$v]['title']." ";
  704. }
  705. $features .=$v.'-';
  706. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  707. if(isset($pm[$typeclass[$v]['classid']]))
  708. {
  709. if($typeclass[$v]['title'] == '9A')
  710. {
  711. $pm[$typeclass[$v]['classid']] = '9A';
  712. }
  713. else if($typeclass[$v]['title'] == '10A')
  714. {
  715. $pm[$typeclass[$v]['classid']] = '10A';
  716. }
  717. else
  718. {
  719. $clzh = $typeclass[$v]['zh'];
  720. if(stripos($typeclass[$v]['zh'],'|') !== false)
  721. {
  722. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  723. $clzh = $clzh[0];
  724. }
  725. $pm[$typeclass[$v]['classid']] = $clzh;
  726. }
  727. }
  728. if(isset($jm[$typeclass[$v]['classid']]))
  729. {
  730. if($typeclass[$v]['jm'])
  731. {
  732. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  733. }
  734. }
  735. }
  736. }
  737. $jm = array_filter($jm);//去除空值
  738. $jm = implode("-",$jm);
  739. $sku = array_filter($sku);//去除空值
  740. $sku = implode("-",$sku);
  741. $pm = array_filter($pm);//去除空值
  742. $pm = implode(" ",$pm);
  743. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  744. if($list['size'])
  745. {
  746. $typeclass = $this->typeclass->read($list['size']);
  747. $title .= $typeclass['title'];
  748. }
  749. $title = trim($title,' ');
  750. $post['num'] = $this->input->post('num',true);
  751. $ztime = $this->input->post('ztime',true);
  752. $post['ztime'] = strtotime($ztime);
  753. $post['bm'] = '03'.implode("",$bmpx);
  754. $post['jm'] = $jm;
  755. $post['sku'] = $sku;
  756. $post['pm'] = $pm;
  757. $post['title'] = $title;
  758. $post['features'] = '-'.$features;
  759. $ztime = $this->input->post('ztime',true);
  760. if($ztime)
  761. {
  762. $post['ztime'] = strtotime($ztime);
  763. }
  764. if($this->whlabel_bh->save($post,$id))
  765. {
  766. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  767. }
  768. else
  769. {
  770. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  771. }
  772. }
  773. $w = $this->shop->find_all("yyid != ''");
  774. $this->data['yyck'] = $w;
  775. $whlabel_bh = $this->whlabel_bh->read($arg_array[0]);
  776. $this->data['whlabel_bh'] = $whlabel_bh ;
  777. $purchase = $this->purchase->find_all("yyid != ''");
  778. $this->data['purchase'] = $purchase;
  779. $this->_Template('whlabel_bh_edit',$this->data);
  780. }
  781. public function _cz()
  782. {
  783. $post = $this->input->post(NULL, TRUE);
  784. if(isset($post['id']))
  785. {
  786. $id = $this->input->post('id',true);
  787. $cz = $this->input->post('cz',true);
  788. $num = $this->input->post('num',true);
  789. $cz = $cz+1;
  790. $w = $this->whlabel_bh->read($id);
  791. if(!$w)
  792. {
  793. echo json_encode(array('msg'=>'操作的信息不存在!','success'=>false));exit;
  794. }
  795. //传输料号开始
  796. $lc = 0;
  797. $lh = $this->apiyy->get_cjlp(array('jm'=>$w['jm'],'title'=>$w['title'],'zh'=>$w['pm'],'bm'=>$w['bm']));
  798. if(isset($lh['Data'][0]))
  799. {
  800. if($lh['Data'][0]['m_isSucess'] != 1)
  801. {
  802. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  803. {
  804. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$w['bm'],'jm'=>$w['jm'],'success'=>false));exit;
  805. }
  806. }
  807. }
  808. else
  809. {
  810. echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit;
  811. }
  812. echo json_encode(array('msg'=>'操作成功!'.$lh['Data'][0]['m_isSucess'],'id'=>$id,'typetext'=>'传输料号','text'=>'','num'=>0,'cs'=>$lh,'bm'=>$w['bm'],'success'=>true));
  813. /** 投产
  814. if($w['scapi'] != 99)
  815. {
  816. if($w['state'] == $cz)
  817. {
  818. echo json_encode(array('msg'=>'请刷新页面后再进行操作!','success'=>false));exit;
  819. }
  820. if($w['type'] == '0')
  821. {
  822. $type = '生产';
  823. $bhlx = 0;
  824. }
  825. else
  826. {
  827. $type = '外购';
  828. $bhlx = 1;
  829. }
  830. $yy = $this->apiyy->_peihuo($w,$w['kh'],$w['orderinfo'],$w['num'],2000);
  831. if($yy['c'] == 0)
  832. {
  833. if($this->whlabel_bh->save(array('state'=>$cz,'scapi'=>99,'scid'=>$yy['scid'],'sctime'=>time()),$id))
  834. {
  835. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已操作','text'=>$type.'中','success'=>true));
  836. }
  837. else
  838. {
  839. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  840. }
  841. }
  842. else
  843. {
  844. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  845. }
  846. }
  847. else if($w['dbapi'] != 99 && $w['type'] == '0')
  848. {
  849. $cz = 1;
  850. if(!is_numeric($num))
  851. {
  852. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  853. }
  854. if($num > $w['num']-$w['rknum'])
  855. {
  856. echo json_encode(array('msg'=>'完成数量大于生产总数量!','success'=>false));exit;
  857. }
  858. if($w['rknum']+$num == $w['num'])
  859. {
  860. $dbapi = 99;
  861. $cz = 2;
  862. }
  863. else
  864. {
  865. $dbapi = 0;
  866. }
  867. $w['ts'] = $num;
  868. $rk = $this->apiyy->_newrk($w);
  869. if($rk['c'] == 0)
  870. {
  871. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>$dbapi,'scid'=>$rk['scid']),$id))
  872. {
  873. if($dbapi == 99)
  874. {
  875. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  876. }
  877. else
  878. {
  879. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  880. }
  881. }
  882. else
  883. {
  884. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  885. }
  886. }
  887. else
  888. {
  889. $this->whlabel_bh->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$id);
  890. echo json_encode(array('msg'=>$rk['error'],'success'=>false));exit;
  891. }
  892. }
  893. else if($w['dbapi'] != 99 && $w['type'] == '1')
  894. {
  895. $cz = 1;
  896. if(!is_numeric($num))
  897. {
  898. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  899. }
  900. if($num > $w['num']-$w['rknum'])
  901. {
  902. echo json_encode(array('msg'=>'完成数量大于外购总数量!','success'=>false));exit;
  903. }
  904. if($w['rknum']+$num == $w['num'])
  905. {
  906. $dbapi = 99;
  907. $cz = 2;
  908. }
  909. else
  910. {
  911. $dbapi = 0;
  912. }
  913. $scid = explode('~',$w['scid']);
  914. $rkdata = array('od'=>$scid[1],'ts'=>$num,'title'=>$w['title']);
  915. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>99),$id))
  916. {
  917. if($dbapi == 99)
  918. {
  919. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  920. }
  921. else
  922. {
  923. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  924. }
  925. }
  926. else
  927. {
  928. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  929. }
  930. }
  931. **/
  932. }
  933. }
  934. public function _db()
  935. {
  936. $post = $this->input->post(NULL, TRUE);
  937. if(isset($post['id']))
  938. {
  939. $id = $this->input->post('id',true);
  940. $num = $this->input->post('num',true);
  941. $warehouse = $this->input->post('warehouse',true);
  942. $w = $this->warehouse->read($warehouse);
  943. $data = $this->whlabel_bh->read($id);
  944. if(!$data)
  945. {
  946. echo json_encode(array('msg'=>'此备货信息已被删除','success'=>false));exit;
  947. }
  948. $d = $this->whlabel_bh_list->find_all("uid = '".$id."'");
  949. $ydbnum = sprintf("%01.2f",array_sum(array_column($d,'num')));
  950. if($num > $data['rknum']-$ydbnum)
  951. {
  952. echo json_encode(array('msg'=>'调拨数量不允许大于(备货入库数量-已调拨数量)','success'=>false));exit;
  953. }
  954. $data['dccbm'] = 13001;//默认从许昌仓调出
  955. $data['ts'] = $num;
  956. $data['drcbm'] = $w['yybm'];
  957. $dc = $this->apiyy->get_cpdc($data);
  958. if(isset($dc['Data'][0]))
  959. {
  960. if($dc['Data'][0]['IsSucess'] != 1)
  961. {
  962. echo json_encode(array('msg'=>$dc['Data'][0]['ErrorMsg'].'-1','success'=>false));exit;
  963. }
  964. else
  965. {
  966. $sh = $this->apiyy->get_order_sh($data,'SO/Submit','SO/Approve',130);
  967. if(isset($sh['Data'][0]))
  968. {
  969. $code = $sh['Data'][0]['Code'];
  970. echo json_encode(array('msg'=>$sh['Data'][0]['ErrorMsg'].'-2','success'=>false));
  971. }
  972. else
  973. {
  974. $code = '';
  975. echo json_encode(array('msg'=>'调出成功!','success'=>true));
  976. }
  977. $p['uid'] = $id;
  978. $p['bm'] = $data['bm'];
  979. $p['sku'] = $data['jm'];
  980. $p['shipremarks'] = $data['shipremarks'];
  981. $p['title'] = $data['title'];
  982. $p['zh'] = $data['pm'];
  983. $p['fpdata'] = $data['features'];
  984. $p['num'] = $num;
  985. $p['warehouse'] = 13;//默认从许昌仓调出
  986. $p['rwarehouse'] = $warehouse;
  987. $p['time'] = time();//操作时间
  988. $p['code'] = $code;
  989. $this->whlabel_bh_list->insert($p);
  990. }
  991. }
  992. else
  993. {
  994. echo json_encode(array('msg'=>json_encode($dc),'success'=>false));exit;
  995. }
  996. }
  997. }
  998. public function _del()
  999. {
  1000. $post = $this->input->post(NULL, TRUE);
  1001. if(isset($post['s']))
  1002. {
  1003. $id_arr = $this->input->post('s');
  1004. $id_arr = explode(',',trim($id_arr,','));
  1005. if(!$id_arr)
  1006. {
  1007. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1008. }
  1009. //循环删除记录
  1010. foreach ($id_arr as $v)
  1011. {
  1012. $w = $this->whlabel_bh->read($v);
  1013. if($w['state'] > 0)
  1014. {
  1015. // echo json_encode(array('msg'=>'有已投产产品,无法删除!','success'=>true));exit;
  1016. }
  1017. }
  1018. foreach ($id_arr as $v)
  1019. {
  1020. $this->whlabel_bh->remove($v);
  1021. }
  1022. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1023. }
  1024. }
  1025. public function _deltransfer()
  1026. {
  1027. $post = $this->input->post(NULL, TRUE);
  1028. if(isset($post['s']))
  1029. {
  1030. $id_arr = $this->input->post('s');
  1031. $id_arr = explode(',',trim($id_arr,','));
  1032. if(!$id_arr)
  1033. {
  1034. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1035. }
  1036. if(count($id_arr) > 1)
  1037. {
  1038. echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit;
  1039. }
  1040. foreach ($id_arr as $v)
  1041. {
  1042. $this->whlabel_bh_transfer->remove($v);
  1043. }
  1044. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1045. }
  1046. }
  1047. public function _kc()
  1048. {
  1049. $post = $this->input->post(NULL, TRUE);
  1050. if(isset($post['category']))
  1051. {
  1052. $list = array();
  1053. $sku = $this->input->post('sku',true);
  1054. $features = $this->input->post('features',true);
  1055. $category = $this->input->post('category',true);
  1056. $list['category'] = $category;
  1057. $list['hairtype'] = $this->input->post('hairtype',true);
  1058. $list['grade'] = $this->input->post('grade',true);
  1059. $size = $this->input->post('size',true);
  1060. $xzsku = $this->input->post('xzsku',true);
  1061. $list['size'] = rtrim($size,',');
  1062. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1063. $list['extension'] = $this->input->post('extension',true);
  1064. if($category == 1297)
  1065. {
  1066. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1067. }
  1068. if($category == 1702)
  1069. {
  1070. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1071. $list['syother'] = $this->input->post('syother',true);
  1072. }
  1073. if($category == 133)
  1074. {
  1075. $list['fittype'] = $this->input->post('fittype',true);
  1076. $list['acother'] = $this->input->post('acother',true);
  1077. }
  1078. $list['color'] = $this->input->post('color',true);
  1079. $list['lowe'] = $this->input->post('lowe',true);
  1080. if($category == 127)
  1081. {
  1082. $list['type'] = $this->input->post('type',true);
  1083. $list['headroad'] = $this->input->post('headroad',true);
  1084. $list['density'] = $this->input->post('density',true);
  1085. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1086. {
  1087. $list['lacesize'] = $this->input->post('lacesize',true);
  1088. }
  1089. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1090. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1091. }
  1092. if($category == 128)
  1093. {
  1094. $list['lacetype'] = $this->input->post('lacetype',true);
  1095. $list['haircap'] = $this->input->post('haircap',true);
  1096. $list['density'] = $this->input->post('density',true);
  1097. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1098. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1099. $list['wigother'] = $this->input->post('wigother',true);
  1100. $list['wigother1'] = $this->input->post('wigother1',true);
  1101. $list['wigother2'] = $this->input->post('wigother2',true);
  1102. }
  1103. if($category == 129)
  1104. {
  1105. $list['wide'] = $this->input->post('wide',true);
  1106. }
  1107. if($category == 131)
  1108. {
  1109. $list['gifttype'] = $this->input->post('gifttype',true);
  1110. $list['giftother'] = $this->input->post('giftother',true);
  1111. }
  1112. if($category == 134)
  1113. {
  1114. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1115. }
  1116. if($category == 1297)
  1117. {
  1118. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1119. $list['sywigother'] = $this->input->post('sywigother',true);
  1120. }
  1121. if($category == 130 || $category == 133 || $category == 1702)
  1122. {
  1123. $list['items'] = $this->input->post('items',true);
  1124. $list['weight'] = $this->input->post('weight',true);
  1125. }
  1126. if($category == 1702)
  1127. {
  1128. $list['syhairther'] = $this->input->post('syhairther',true);
  1129. }
  1130. $shipremarks = '';
  1131. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1132. foreach($list as $k=>$v)
  1133. {
  1134. if($v != 0)
  1135. {
  1136. $shipremarks .=$v.'-';
  1137. }
  1138. }
  1139. $shipremarks = '-'.$shipremarks;
  1140. if($features)
  1141. {
  1142. $shipremarks = $features;
  1143. }
  1144. $w = $this->whlabel->find_count("features = '$shipremarks' and state = '0' and zd = '' and warehouse = '13'");//默认许昌仓
  1145. if($w > 0)
  1146. {
  1147. echo json_encode(array('msg'=>$w,'success'=>true));exit;
  1148. }
  1149. else
  1150. {
  1151. echo json_encode(array('msg'=>'没有可用库存','cs'=>$shipremarks,'success'=>false));
  1152. }
  1153. }
  1154. }
  1155. public function _excel()
  1156. {
  1157. $classid = $this->classid->sku();
  1158. $pm = $classid;
  1159. $typeclass = array();
  1160. $tc = $this->typeclass->find_all();
  1161. foreach ($tc as $v)
  1162. {
  1163. $typeclass[$v['id']] = $v;
  1164. }
  1165. $prc = array();
  1166. $purchase = $this->purchase->find_all();
  1167. foreach($purchase as $k=>$v)
  1168. {
  1169. $prc[$v['id']] = $v['title'];
  1170. }
  1171. if(isset($_GET['excel']))
  1172. {
  1173. $number = $this->input->post('number',true);
  1174. $sku = $this->input->post('sku',true);
  1175. $title = $this->input->post('title',true);
  1176. $pm = $this->input->post('pm',true);
  1177. $category = $this->input->post('category',true);
  1178. $size = $this->input->post('size',true);
  1179. $grade = $this->input->post('grade',true);
  1180. $color = $this->input->post('color',true);
  1181. $lowe = $this->input->post('lowe',true);
  1182. $state = $this->input->post('state',true);
  1183. $shipremarks = $this->input->post('shipremarks',true);
  1184. $type = $this->input->post('type',true);
  1185. $sid = $this->input->get('sid',true);
  1186. $ktime = $this->input->get('ktime',true);
  1187. $jtime = $this->input->get('jtime',true);
  1188. $ktime = strtotime($ktime);
  1189. $jtime = strtotime($jtime);
  1190. $where = "1=1";$gj = "";$ck = "";
  1191. if($number)
  1192. {
  1193. $where .= " and number like '%$number%'";
  1194. }
  1195. if($type != '')
  1196. {
  1197. $where .= " and type = '$type'";
  1198. }
  1199. if($sku)
  1200. {
  1201. $where .= " and sku like '%$sku%'";
  1202. }
  1203. if($title)
  1204. {
  1205. $where .= " and title like '%$title%'";
  1206. }
  1207. if($pm)
  1208. {
  1209. $where .= " and pm like '%$pm%'";
  1210. }
  1211. if($category)
  1212. {
  1213. $where .= " and shipremarks like '%-$category-%'";
  1214. }
  1215. if($size)
  1216. {
  1217. $where .= " and shipremarks like '%-$size-%'";
  1218. }
  1219. if($grade)
  1220. {
  1221. $where .= " and shipremarks like '%-$grade-%'";
  1222. }
  1223. if($color)
  1224. {
  1225. $where .= " and shipremarks like '%-$color-%'";
  1226. }
  1227. if($lowe)
  1228. {
  1229. $where .= " and shipremarks like '%-$lowe-%'";
  1230. }
  1231. if($state)
  1232. {
  1233. $where .= " and state = '$state'";
  1234. }
  1235. if($shipremarks)
  1236. {
  1237. $where .= " and shipremarks like '%$shipremarks%'";
  1238. }
  1239. $sidwhere = '';
  1240. if($sid)
  1241. {
  1242. $sd = "";
  1243. $s = explode(',',trim($sid,','));
  1244. foreach ($s as $value)
  1245. {
  1246. $sd .= " id = ".$value." or";
  1247. }
  1248. $sidwhere = " and (".rtrim($sd,'or').")";
  1249. }
  1250. //数据排序
  1251. $order_str = "time desc";
  1252. if(empty($page))
  1253. {
  1254. $start = 0;
  1255. $perpage = 1;
  1256. }
  1257. else
  1258. {
  1259. $start = ($page - 1)*$perpage;
  1260. }
  1261. //取得信息列表
  1262. /**
  1263. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  1264. $rows = array();$list = array();
  1265. foreach ($info_list as $key=>$value)
  1266. {
  1267. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1268. }
  1269. **/
  1270. $warehouse = $this->warehouse->find_all();
  1271. $ck = array();
  1272. foreach ($warehouse as $v)
  1273. {
  1274. $ck[$v['id']] = $v['title'];
  1275. }
  1276. $list = array();
  1277. $rows = $this->whlabel_bh->find_all($where.$sidwhere,'state,orderinfo,number,jm,title,pm,shipremarks,bhnum,kcnum,num,rknum,dbnum,id,sctime,time');
  1278. foreach ($rows as $key=>$value)
  1279. {
  1280. if($value['state'] == 0)
  1281. {
  1282. $rows[$key]['state'] = "待生产/外购";
  1283. }
  1284. else if($value['state'] == 1)
  1285. {
  1286. $rows[$key]['state'] = "生产/外购中";
  1287. }
  1288. else if($value['state'] == 2)
  1289. {
  1290. $rows[$key]['state'] = "已完成";
  1291. }
  1292. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  1293. $zc = '';
  1294. foreach ($zd as $v)
  1295. {
  1296. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  1297. }
  1298. $rows[$key]['id'] = $zc;
  1299. $rows[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  1300. $rows[$key]['sctime'] = ($value['sctime']>0)?date('Y-m-d',$value['sctime']):'未记录';
  1301. $rows[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  1302. }
  1303. $title = '备货详情';
  1304. $titlename = "<table border=1>
  1305. <tr align='center'>
  1306. <td>状态</td>
  1307. <td>标题</td>
  1308. <td>流水码</td>
  1309. <td>简码</td>
  1310. <td>英文</td>
  1311. <td>中文</td>
  1312. <td>备注</td>
  1313. <td>备货数量</td>
  1314. <td>库存数量</td>
  1315. <td>生产/外购数量</td>
  1316. <td>入库数量</td>
  1317. <td>调拨数量</td>
  1318. <td>调拨详情</td>>
  1319. <td>生产时间</td>>
  1320. <td>操作时间</td>>
  1321. </tr>
  1322. </table>";
  1323. $filename = $title.".xls";
  1324. $tail = "";
  1325. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1326. }
  1327. }
  1328. public function _xxpl()
  1329. {
  1330. /* 订单加入键值-j */
  1331. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1332. $config['upload_path'] = '.'.$dir ;
  1333. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1334. $config['allowed_types'] = 'xls|xlsx|csv';
  1335. $config['max_size'] = 10240;
  1336. $this->load->library('upload', $config);
  1337. $this->upload->initialize($config);
  1338. if ($this->upload->do_upload('userfile'))
  1339. {
  1340. $full_path = $dir.$this->upload->data('file_name');
  1341. $fileName = '.' . $full_path;
  1342. if (!file_exists($fileName))
  1343. {
  1344. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1345. }
  1346. else
  1347. {
  1348. require_once "./data/excel/PHPExcel/IOFactory.php";
  1349. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1350. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1351. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1352. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1353. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1354. ++$column;//如果列数大于26行
  1355. $list = array();
  1356. for ($i = 2; $i <= $row; $i++) // 行数循环
  1357. {
  1358. $data = array();
  1359. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1360. {
  1361. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1362. }
  1363. $list[] = $data;
  1364. }
  1365. }
  1366. $tc = $this->typeclass->find_all();
  1367. $typeclass = array();
  1368. foreach ($tc as $v)
  1369. {
  1370. $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']);
  1371. }
  1372. $i = 0;$j = 0;$ed = array();
  1373. $classid = $this->classid->sku();
  1374. $typeclassid = [];
  1375. foreach($tc as $v){
  1376. $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']);
  1377. }
  1378. $i = 0;$j = 0;$ed = [];
  1379. $ck = [
  1380. "成品仓"=>'99001',
  1381. "美国仓"=>'02031',
  1382. "AP"=>'0103001',
  1383. "WK"=>'0103002',
  1384. "QV"=>'0103003',
  1385. "AS"=>'0103004',
  1386. "H"=>"0103005",
  1387. "AP英"=>"0103006",
  1388. "YMS"=>"0103007",
  1389. "AP新"=>"0103008",
  1390. "WK新"=>"0103009",
  1391. "H新"=>"0103010",
  1392. "Bilisar"=>"0103011",
  1393. "Estilar"=>"0103012",
  1394. "QM"=>"0103013",
  1395. "Afola"=>"0103014",
  1396. "拼多多-Finsa"=>"0106002",
  1397. "拼多多-艾彩"=>"0105001",
  1398. "拼多多-Estilar"=>"0106001",
  1399. "拼多多-QM"=>"0106003",
  1400. ];
  1401. foreach($list as $k=>$v){
  1402. $res = $this->logic_u9tools->getGoodInfoByErpSku($v[0],$v[1],$typeclass,$typeclassid,$classid);
  1403. if($res['code']==1){
  1404. //传输料号开始
  1405. $post = $res['data'];
  1406. $post['number'] = $post['number'].$k;
  1407. $post['orderinfo'] = $v[2];
  1408. $post['num'] = $v[5];
  1409. $post['state'] = ($v[3] == '生产')?0:1;
  1410. $post['purchase'] = "";//供货商
  1411. $post['shipremarks'] = empty($v[6])?" ":$v[6];//
  1412. $post['rknum'] = 0;
  1413. $post['scapi'] = 0;
  1414. $post['dbapi'] = 0;
  1415. $post['bhnum'] = $v[5];
  1416. $post['extra_type'] = (strpos($v[2],"美国销售-") !== false)?1:0;
  1417. if(isset($ck[$v[4]])){
  1418. $post['kh'] = $ck[$v[4]];
  1419. }else{
  1420. $j++;
  1421. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1422. continue;
  1423. }
  1424. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  1425. $this->logic_ding->sendToDing("备货批量导入出现的错误信息".json_encode($lh,JSON_UNESCAPED_UNICODE));
  1426. if(isset($lh['Data'][0]))
  1427. {
  1428. if($lh['Data'][0]['m_isSucess'] != 1)
  1429. {
  1430. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1431. {
  1432. $j++;
  1433. $ed[] = array($lh['Data'][0]['m_errorMsg'],$post['jm'],$post['bm']);
  1434. }
  1435. }
  1436. }
  1437. else
  1438. {
  1439. $j++;
  1440. $ed[] = array('料号错误',$post['jm'],$post['bm']);
  1441. }
  1442. if($this->whlabel_bh->insert($post))
  1443. {
  1444. $i++;
  1445. }
  1446. else
  1447. {
  1448. $j++;
  1449. $ed[] = array('添加失败,请重试',$post['jm'],$post['bm']);
  1450. }
  1451. }else{
  1452. $j++;
  1453. $ed[] = array($res['msg'],$v[1],"");
  1454. }
  1455. }
  1456. if($j > 0)
  1457. {
  1458. $time = date('Ymd',time());
  1459. $title = '错误信息-'.$time;
  1460. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  1461. $tail = "\n";
  1462. $filename = $title.".xls";
  1463. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  1464. $dir = '/data/excel/'.$time.'/';
  1465. $file_name = 'error_'.$time.rand(1000,9999);
  1466. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  1467. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  1468. fwrite($myfile,$ecl);
  1469. fclose($myfile);
  1470. $error = $dir.$file_name.'.xls';
  1471. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  1472. }
  1473. else
  1474. {
  1475. echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>1,'success'=>true));exit;
  1476. }
  1477. }
  1478. else
  1479. {
  1480. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  1481. }
  1482. }
  1483. public function _cslh($jm,$title,$pm,$bm)
  1484. {
  1485. $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$title,'zh'=>$pm,'bm'=>$bm));
  1486. if(isset($lh['Data'][0]))
  1487. {
  1488. if($lh['Data'][0]['m_isSucess'] != 1)
  1489. {
  1490. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1491. {
  1492. return array('msg'=>$lh['Data'][0]['m_errorMsg'],'x'=>1);exit;
  1493. }
  1494. }
  1495. }
  1496. else
  1497. {
  1498. return array('msg'=>'料号错误','x'=>1);exit;
  1499. }
  1500. return array('x'=>2);exit;
  1501. }
  1502. public function _bbprint()
  1503. {
  1504. $time = time();
  1505. $post = $this->input->post(NULL);
  1506. if(isset($post['d']))
  1507. {
  1508. $order = 0;$time = time();
  1509. $d = $this->input->post('d',true);
  1510. $n = $this->input->post('n',true);//打印数量
  1511. $data = $this->whlabel_bh->read($d);
  1512. if(!$data)
  1513. {
  1514. echo json_encode(array('msg'=>'未找到此备货信息,请刷新页面重试','success'=>false));exit;
  1515. }
  1516. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$data['number']."'");
  1517. $printnum = array_sum(array_column($printnum,'ts'));
  1518. if(($data['bhnum'] + 1)-$printnum-$n < 0)
  1519. {
  1520. echo json_encode(array('msg'=>'打印数量不可超出备货数量!','success'=>false));exit;
  1521. }
  1522. $post['number'] = $data['number'];
  1523. $post['orderinfo'] = $data['orderinfo'];
  1524. $post['type'] = 0;//0生产 1外购
  1525. $post['features'] = $data['features'];
  1526. $post['jm'] = $data['jm'];
  1527. $post['bm'] = $data['bm'];
  1528. $post['pm'] = $data['pm'];
  1529. $post['sku'] = $data['sku'];
  1530. $post['features'] = $data['features'];
  1531. $post['number'] = $data['number'];
  1532. $post['title'] = $data['title'];
  1533. $post['printtime'] = $time;
  1534. $post['ts'] = 1;
  1535. // $post['rk'] = "";//默认订单中心 打印后直接入库
  1536. // $post['rktime'] = "";
  1537. // $post['ctime15'] = $time;
  1538. $post['time'] = $time;
  1539. $post['gtime'] = date('Yms',$time);
  1540. $post['wbid'] = $data['id'];
  1541. $rows = array();
  1542. $label = date("ymdHis").rand(1000,9999);
  1543. $post['label'] = $label;
  1544. // if($this->whlabel_bh_transfer->insert($post))
  1545. // {
  1546. // echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1547. // }
  1548. // else
  1549. // {
  1550. // $this->db->trans_rollback();
  1551. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1552. // }
  1553. if(stripos($post['features'],'-126-') !== false)
  1554. {
  1555. $drck = '12003';//进入发条库
  1556. }
  1557. else if(stripos($post['features'],'-127-') !== false)
  1558. {
  1559. $drck = '12004';//进入发块库
  1560. }
  1561. else
  1562. {
  1563. $drck = '12006';//其它进入完成库
  1564. }
  1565. //创建u9的生产单
  1566. $token = $this->settingtest->get_yytoken_120();
  1567. $params = [
  1568. 'org_code'=>"120",
  1569. 'djhlx'=>'2000',
  1570. 'scbm_code'=>"12008",
  1571. "time"=>time(),
  1572. 'owner_org_code'=>"120",
  1573. 'title'=>$post['orderinfo'],
  1574. 'shipremarks'=>$data['shipremarks'],
  1575. 'list'=>[
  1576. [
  1577. 'drck'=>$drck,
  1578. 'jm'=>$post['jm'],
  1579. 'sl'=>$n,
  1580. 'drck'=>$drck,
  1581. ]
  1582. ]
  1583. ];
  1584. $res = $this->apiyyv1->scdCreate($params,$token);
  1585. $this->logic_ding->sendToDing("【".$post['orderinfo']."-".$data['id']."】生产备货同步u9||".json_encode($res,JSON_UNESCAPED_UNICODE));
  1586. if(!isset($res[0]['Data'])){
  1587. echo json_encode(array('msg'=>'u9同步返回异常,请重试!','success'=>false));exit;
  1588. }
  1589. if(!$res[0]['Data'][0]['m_isSucess']){
  1590. echo json_encode(array('msg'=>'u9同步失败,请重试!','success'=>false));exit;
  1591. }
  1592. $scid = $res[0]['Data'][0]['m_iD']."~".$res[0]['Data'][0]['m_code']."~".$drck;
  1593. $post['scid'] = $scid;
  1594. $post['scapi'] = 1;
  1595. $post['dbapi'] = 0;
  1596. $this->db->trans_begin();
  1597. $post['shipremarks'] = $data['shipremarks'];
  1598. for($i = 0;$i < $n;$i++){
  1599. $post['label'] = $label.$i;
  1600. $rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['pm'],'n'=>1);
  1601. $this->whlabel_bh_transfer->insert($post);
  1602. }
  1603. $printsl = $data['printsl']*1 + $n*1;
  1604. $this->whlabel_bh->save(['printsl'=>$printsl],$data['id']);
  1605. if ($this->db->trans_status() === TRUE)
  1606. {
  1607. $this->db->trans_commit();
  1608. echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1609. }else{
  1610. $this->db->trans_rollback();
  1611. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1612. }
  1613. }
  1614. }
  1615. public function _bdbb()
  1616. {
  1617. $post = $this->input->post(NULL, TRUE);
  1618. if(isset($post['s']))
  1619. {
  1620. $id_arr = $this->input->post('s');
  1621. $id_arr = explode(',',trim($id_arr,','));
  1622. if(!$id_arr)
  1623. {
  1624. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1625. }
  1626. //循环删除记录
  1627. foreach ($id_arr as $v)
  1628. {
  1629. $t = $this->whlabel_bh_transfer->read($v);
  1630. if(!isset($t['number']))
  1631. {
  1632. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1633. }
  1634. $rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>1);
  1635. }
  1636. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1637. }
  1638. }
  1639. public function _out()
  1640. {
  1641. $post = $this->input->post(NULL, TRUE);
  1642. if(isset($post['label']))
  1643. {
  1644. $time = time();
  1645. $label = $this->input->post('label',true);
  1646. $cz = $this->input->post('cz',true);
  1647. $transfer = $this->input->post('transfer',true);
  1648. if(!$label)
  1649. {
  1650. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  1651. }
  1652. if(!$transfer)
  1653. {
  1654. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  1655. }
  1656. $lb = $this->whlabel_bh_transfer->get_label($label);
  1657. if(!$lb)
  1658. {
  1659. echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
  1660. }
  1661. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1662. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1663. $tdata = $this->transfer->find_all();
  1664. $t = array();
  1665. foreach ($tdata as $v)
  1666. {
  1667. $t[$v['id']] = $v['title'];
  1668. }
  1669. if($cz == 1)
  1670. {
  1671. if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
  1672. {
  1673. echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
  1674. }
  1675. }
  1676. if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
  1677. {
  1678. echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
  1679. }
  1680. if($cz == 1)
  1681. {
  1682. $lb['rk'] .= $transfer.'|';
  1683. $lb['rktime'] .= $time.'|';
  1684. if($lbrk[0] == $transfer)
  1685. {
  1686. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1687. }
  1688. //必须走配货
  1689. if(($transfer != 1) && (strpos($lb['rk'],'|1|') === false) ){
  1690. echo json_encode(array('msg'=>'请先到配货!','success'=>false));exit;
  1691. }
  1692. }
  1693. else if($cz == 2)
  1694. {
  1695. $lb['ck'] .= $transfer.'|';
  1696. $lb['cktime'] .= $time.'|';
  1697. if($lbck[0] == $transfer)
  1698. {
  1699. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1700. }
  1701. }
  1702. $cztime = 'ctime'.$transfer;
  1703. //如果是完成扫出 这样会通知erp生成一个调出单
  1704. //中转库如果扫出的话 应该是马尾 其它的没有
  1705. if(($transfer == 3 || $transfer == 13) && $cz == 2 && $lb['dbapi'] < 99){
  1706. $this->db->trans_begin();
  1707. $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']);
  1708. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);
  1709. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1710. if($ct_info){
  1711. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1712. }
  1713. $this->zzquque_u9->insert([
  1714. 'platform'=>'',
  1715. 'warehouse'=>0,
  1716. 'type'=>21,
  1717. 'order_no'=>$lb['orderinfo'],
  1718. 'child_order_no'=>$lb['id'],
  1719. 'status'=>0,
  1720. 'create_time'=>time(),
  1721. 'update_time'=>time(),
  1722. ]);
  1723. if ($this->db->trans_status() === TRUE){
  1724. $this->db->trans_commit();
  1725. echo json_encode(array('music'=>'1','success'=>true));exit;
  1726. }else{
  1727. $this->db->trans_rollback();
  1728. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1729. }
  1730. }
  1731. //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1732. if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
  1733. {
  1734. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1735. }
  1736. $save_data = [
  1737. 'rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time
  1738. ];
  1739. //配货入库需更新一下配货状态
  1740. if($transfer == 1 && $cz == 2 && $lb['status'] == 0){
  1741. $save_data['status'] = 1;
  1742. }
  1743. $this->db->trans_begin();
  1744. $this->whlabel_bh_transfer->save($save_data,$lb['id']);
  1745. if($cz == 2){
  1746. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);
  1747. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1748. if($ct_info){
  1749. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1750. }
  1751. }else{
  1752. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>0,'number'=>$lb['number']]);
  1753. }
  1754. if ($this->db->trans_status() === TRUE){
  1755. $this->db->trans_commit();
  1756. echo json_encode(array('music'=>'1','success'=>true));exit;
  1757. }else{
  1758. $this->db->trans_rollback();
  1759. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1760. }
  1761. }
  1762. }
  1763. protected function getOperateList(){
  1764. $api = $this->input->post('api',true);
  1765. $page = $this->input->post('page',true);
  1766. $perpage = $this->input->post('perpage',true);
  1767. $orderinfo = $this->input->post('number',true);
  1768. $color = $this->input->post('color',true);
  1769. $pm = $this->input->post('pm',true);
  1770. $purchase = $this->input->post('purchase',true);
  1771. $transfer = $this->input->post('transfer',true);
  1772. $lx = $this->input->post('lx',true);
  1773. $timetk = $this->input->post('timetk',true);
  1774. $timetj = $this->input->post('timetj',true);
  1775. $timetk = strtotime($timetk);
  1776. $timetj = strtotime($timetj);
  1777. $where = "1=1";
  1778. if($transfer)
  1779. {
  1780. $ctime = 'ctime'.$transfer;
  1781. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1782. }
  1783. else
  1784. {
  1785. $where .= " and time > '$timetk' and time < '$timetj'";
  1786. }
  1787. if($orderinfo)
  1788. {
  1789. $where .= " and orderinfo like '%$orderinfo%'";
  1790. }
  1791. if($transfer)
  1792. {
  1793. $where .= " and rk like '%|".$transfer."|%'";
  1794. }
  1795. if($purchase)
  1796. {
  1797. $where .= " and purchase = '$purchase'";
  1798. }
  1799. if($pm)
  1800. {
  1801. $where .= " and pm like '%$pm%'";
  1802. }
  1803. if($color)
  1804. {
  1805. $where .= " and fpdata like '%-".$color."-%'";
  1806. }
  1807. //数据排序
  1808. $order_str = "id desc";
  1809. if(empty($page))
  1810. {
  1811. $start = 0;
  1812. $perpage = 1;
  1813. }
  1814. else
  1815. {
  1816. $start = ($page - 1)*$perpage;
  1817. }
  1818. //取得信息列表
  1819. $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage);
  1820. $transfer = $this->transfer->find_all();
  1821. $t = array();$ot = array();
  1822. foreach ($transfer as $v)
  1823. {
  1824. $t[$v['id']] = $v['title'];
  1825. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1826. }
  1827. //格式化数据
  1828. foreach ($info_list as $key=>$value)
  1829. {
  1830. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1831. $log_list= $this->whlabel_bh_transfer_cr->find_all("fid = ".$value['id']);
  1832. $tmp_operate_str = "";
  1833. foreach($log_list as $k=>$v){
  1834. $tmp_operate_str.= $t[$v['lx']]."".($v['type']==1?'入库':'出库').":".date('Y-m-d H:i:s',$v['time'])."<br>";
  1835. }
  1836. $info_list[$key]['time'] = trim($tmp_operate_str,'<br>');
  1837. }
  1838. $total = $this->whlabel_bh_transfer->find_count($where);
  1839. $pagenum = ceil($total/$perpage);
  1840. $over = $total-($start+$perpage);
  1841. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'where'=>$where);
  1842. return $rows;
  1843. }
  1844. public function _operate()
  1845. {
  1846. $post = $this->input->post(NULL, TRUE);
  1847. if(isset($post['page']))
  1848. {
  1849. $rows = $this->getOperateList();
  1850. echo json_encode($rows);exit;
  1851. }
  1852. if(isset($_SESSION['api']))
  1853. {
  1854. $user = $this->user->get_api($_SESSION['api']);
  1855. $usp = $user;
  1856. $pid = "";$tid="";$sid="";$wid="";
  1857. $purchase = explode('|',trim($user['purchase'],'|'));
  1858. $transfer = explode('|',trim($user['transfer'],'|'));
  1859. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1860. foreach ($purchase as $value)
  1861. {
  1862. $pid .= " id = ".$value." or";
  1863. }
  1864. foreach ($transfer as $value)
  1865. {
  1866. $tid .= " id = ".$value." or";
  1867. }
  1868. foreach ($warehouse as $value)
  1869. {
  1870. $wid .= " id = ".$value." or";
  1871. }
  1872. }
  1873. else
  1874. {
  1875. header('Location: /');exit;
  1876. }
  1877. $kx = '';$zjtab = '';
  1878. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1879. $this->data['warehouse'] = $warehouse;
  1880. $purchase = $this->purchase->find_all("yyid != ''");
  1881. $this->data['purchase'] = $purchase;
  1882. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1883. $this->data['transfer'] = $transfer;
  1884. $ids = array_column($transfer,'id');
  1885. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  1886. $start_time = $end_time - 14 * 24 * 60 * 60;
  1887. //$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 );
  1888. //$this->data['count'] = $count;
  1889. $this->data['vip'] = $user['vip'];
  1890. $this->_Template('whlabel_bh_operate',$this->data);
  1891. }
  1892. public function _rk()
  1893. {
  1894. $post = $this->input->post(NULL, TRUE);
  1895. if(isset($post['page']))
  1896. {
  1897. $res = $this->getOperateList();
  1898. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  1899. echo json_encode($rows);exit;
  1900. }
  1901. if(isset($_SESSION['api']))
  1902. {
  1903. $user = $this->user->get_api($_SESSION['api']);
  1904. $usp = $user;
  1905. $pid = "";$tid="";$sid="";$wid="";
  1906. $purchase = explode('|',trim($user['purchase'],'|'));
  1907. $transfer = explode('|',trim($user['transfer'],'|'));
  1908. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1909. foreach ($purchase as $value)
  1910. {
  1911. $pid .= " id = ".$value." or";
  1912. }
  1913. foreach ($transfer as $value)
  1914. {
  1915. $tid .= " id = ".$value." or";
  1916. }
  1917. foreach ($warehouse as $value)
  1918. {
  1919. $wid .= " id = ".$value." or";
  1920. }
  1921. }
  1922. else
  1923. {
  1924. header('Location: /');exit;
  1925. }
  1926. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1927. $this->data['transfer'] = $transfer;
  1928. $this->_Template('whlabel_bh_rk',$this->data);
  1929. }
  1930. public function _ck()
  1931. {
  1932. $post = $this->input->post(NULL, TRUE);
  1933. if(isset($post['page']))
  1934. {
  1935. $res = $this->getOperateList();
  1936. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  1937. echo json_encode($rows);exit;
  1938. }
  1939. if(isset($_SESSION['api']))
  1940. {
  1941. $user = $this->user->get_api($_SESSION['api']);
  1942. $usp = $user;
  1943. $pid = "";$tid="";$sid="";$wid="";
  1944. $purchase = explode('|',trim($user['purchase'],'|'));
  1945. $transfer = explode('|',trim($user['transfer'],'|'));
  1946. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1947. foreach ($purchase as $value)
  1948. {
  1949. $pid .= " id = ".$value." or";
  1950. }
  1951. foreach ($transfer as $value)
  1952. {
  1953. $tid .= " id = ".$value." or";
  1954. }
  1955. foreach ($warehouse as $value)
  1956. {
  1957. $wid .= " id = ".$value." or";
  1958. }
  1959. }
  1960. else
  1961. {
  1962. header('Location: /');exit;
  1963. }
  1964. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1965. $this->data['transfer'] = $transfer;
  1966. $this->_Template('whlabel_bh_ck',$this->data);
  1967. }
  1968. //备货流转记录表
  1969. public function _transfer_log(){
  1970. $post = $this->input->post(NULL, TRUE);
  1971. if($post){
  1972. $page = $this->input->post('page',true);
  1973. $perpage = $this->input->post('perpage',true);
  1974. $where = " extra_type = 1 ";
  1975. $orderinfo = $this->input->post('orderinfo',true);
  1976. $timetk = $this->input->post('timetk',true);
  1977. $timetj = $this->input->post('timetj',true);
  1978. $timetk = strtotime($timetk);
  1979. $timetj = strtotime($timetj);
  1980. if($timetk && $timetj)
  1981. {
  1982. $where .= " and time > '$timetk' and time < '$timetj'";
  1983. }
  1984. if($orderinfo){
  1985. $where.= " and orderinfo like '%$orderinfo%' ";
  1986. }
  1987. if(empty($page))
  1988. {
  1989. $start = 0;
  1990. $perpage = 1;
  1991. }
  1992. else
  1993. {
  1994. $start = ($page - 1)*$perpage;
  1995. }
  1996. $list = $this->whlabel_bh->find_pc($where,'orderinfo',"id,orderinfo",'id desc',$start,$perpage);
  1997. $rows = [];
  1998. foreach($list as $k=>$v){
  1999. $tmp_order_info = $this->whlabel_bh->find_all(" orderinfo = '".$v['orderinfo']."'","id,orderinfo,bhnum");
  2000. $tmp_ids = [];
  2001. $tmp_bhnum = 0;
  2002. foreach($tmp_order_info as $vv){
  2003. $tmp_ids[] = $vv['id'];
  2004. $tmp_bhnum += $vv['bhnum'];
  2005. }
  2006. $ydysl = $wdysl = $yphsl = $yjgsj = $wwgsl = 0;
  2007. if(!empty($tmp_ids)){
  2008. $list = $this->whlabel_bh_transfer->find_all(" wbid in (".implode(",",$tmp_ids).")");
  2009. foreach($list as $vv){
  2010. $ydysl += 1;
  2011. if($vv['status'] == 1){
  2012. $yphsl += 1;
  2013. }
  2014. if($vv['status'] == 2){
  2015. $yjgsj += 1;
  2016. }
  2017. }
  2018. }
  2019. $rows[$k]['id'] = $v['id'];
  2020. $rows[$k]['orderinfo'] = "<h9 class='window' data-h='/whlabel_bh/transfer_detail/".$v['id']."' data-t='备货单号:".$v['orderinfo']."'><p>".$v['orderinfo']."</p></h9>" ;
  2021. $rows[$k]['ddsl'] = $tmp_bhnum; //订单数量
  2022. $rows[$k]['ydysl'] = $ydysl; //已打印数量
  2023. $rows[$k]['wdysl'] = $tmp_bhnum - $ydysl; //未打印数量
  2024. $rows[$k]['yphsl'] = $yphsl; //已配货数量
  2025. $rows[$k]['yjgsj'] = $yjgsj; //已完工数量
  2026. $rows[$k]['wwgsl'] = $tmp_bhnum - $yjgsj; //未完工数量
  2027. }
  2028. $total = $this->whlabel_bh->find_count($where);
  2029. $pagenum = ceil($total/$perpage);
  2030. $over = $total-($start+$perpage);
  2031. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  2032. echo json_encode($rows);exit;
  2033. }
  2034. $start_time = strtotime(date('Y-m-d')) - 14* 24 * 60 * 60;
  2035. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2036. $all_list = $this->whlabel_bh->find_all("extra_type = 1 and time >= ".$start_time." and time <= ".$end_time);
  2037. $orderinfo_list =[];
  2038. $total_num = 0;
  2039. foreach($all_list as $k=>$v){
  2040. $orderinfo_list[$v['id']] = $v['id'];
  2041. $total_num += $v['bhnum'];
  2042. }
  2043. $wbids = array_values($orderinfo_list);
  2044. if(empty($wbids)){
  2045. $over_num = 0;
  2046. }else{
  2047. $over_num = $this->whlabel_bh_transfer->find_count(" status = 2 and wbid in (".implode(",",$wbids).")");
  2048. }
  2049. $this->data['total_num'] = $total_num;
  2050. $this->data['wwcsl'] = $total_num - $over_num;
  2051. $this->_Template('whlabel_bh_transfer_log',$this->data);
  2052. }
  2053. public function _transfer_detail($arg_array){
  2054. $id = $arg_array[0];
  2055. $transfer_list = $this->transfer->find_all();
  2056. $t_list = array_column($transfer_list,'title','id');
  2057. $info = $this->whlabel_bh->read($id);
  2058. $list = $this->whlabel_bh_transfer->find_all(" orderinfo= '".$info['orderinfo']."'");
  2059. $ids = array_column($list,'id');
  2060. $final_list = [];
  2061. if(!empty($ids)){
  2062. $log_list = $this->whlabel_bh_transfer_cr->find_all( " type = 1 and fid in (".implode(",",$ids).")","*","id asc");
  2063. $collect_list = [];
  2064. foreach($log_list as $k=>$v){
  2065. $collect_list[$v['lx']][$v['fid']] = $v;
  2066. }
  2067. foreach($collect_list as $k=>$v){
  2068. $js_num = $zk_num = $wc_num = 0;
  2069. foreach($v as $kk=>$vv){
  2070. $js_num += 1;
  2071. if($vv['is_over'] == 0){
  2072. $zk_num += 1;
  2073. }
  2074. if($vv['is_over'] == 1){
  2075. $wc_num += 1;
  2076. }
  2077. }
  2078. $final_list[$k] = [
  2079. 'cj' => $t_list[$k],
  2080. 'js_num' => $js_num,
  2081. 'zk_num' => $zk_num,
  2082. 'wc_num' => $wc_num,
  2083. 'list' => $v,
  2084. ];
  2085. }
  2086. }
  2087. // echo "<pre>";
  2088. // print_r($final_list);
  2089. // die;
  2090. $this->data['final_list'] = $final_list;
  2091. $this->_Template('whlabel_bh_transfer_detail',$this->data);
  2092. }
  2093. public function _cj_transfer_log(){
  2094. $post = $this->input->post(NULL, TRUE);
  2095. if(!empty($post)){
  2096. $orderinfo = $this->input->post('orderinfo',true);
  2097. $pm = $this->input->post('pm',true);
  2098. $tid = $this->input->post('tid',true);
  2099. $page = $this->input->post('page',true);
  2100. $perpage = $this->input->post('perpage',true);
  2101. $timetk = $this->input->post('timetk',true);
  2102. $timetj = $this->input->post('timetj',true);
  2103. $timetk = strtotime($timetk);
  2104. $timetj = strtotime($timetj);
  2105. $where = " rk like '%|".$tid."|%' ";
  2106. if($timetk && $timetj)
  2107. {
  2108. $where .= " and time > '$timetk' and time < '$timetj'";
  2109. }
  2110. if($pm){
  2111. if(empty($orderinfo)){
  2112. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]),'cwxx'=>"请先输入订单号");
  2113. echo json_encode($rows);exit;
  2114. }else{
  2115. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");
  2116. $numbers = array_column($number_list,'number');
  2117. if(empty($numbers)){
  2118. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));
  2119. echo json_encode($rows);exit;
  2120. }
  2121. $where.= " and number in (".implode(",",$numbers).") ";
  2122. }
  2123. }else{
  2124. if($orderinfo){
  2125. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2126. $numbers = array_column($number_list,'number');
  2127. if(empty($numbers)){
  2128. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));
  2129. echo json_encode($rows);exit;
  2130. }
  2131. $where.= " and number in (".implode(",",$numbers).") ";
  2132. }
  2133. }
  2134. if(empty($page))
  2135. {
  2136. $start = 0;
  2137. $perpage = 20;
  2138. }
  2139. else
  2140. {
  2141. $start = ($page - 1)*$perpage;
  2142. }
  2143. $list = $this->whlabel_bh_transfer->find_pc($where,'number',"id,number,orderinfo,pm",'id desc',$start,$perpage);
  2144. $count = $this->whlabel_bh_transfer->find_all($where,'COUNT(DISTINCT number) as total');
  2145. $total = $count[0]['total'];
  2146. $pagenum = ceil($total/$perpage);
  2147. $over = $total-($start+$perpage);
  2148. $final_list = [];
  2149. foreach($list as $k=>$v){
  2150. $yjs_arr =[];//避免多次扫入的重复计算
  2151. $yjs = $wck= $yck = 0;
  2152. $log_list = $this->whlabel_bh_transfer_cr->find_all("lx = ".$tid." and type = 1 and number = ".$v['number'],"*",'id desc');
  2153. foreach($log_list as $kk=>$vv){
  2154. if(!isset($yjs_arr[$vv['fid']])){
  2155. $yjs += 1;
  2156. if($vv['is_over'] == 0){
  2157. $wck += 1;
  2158. }
  2159. if($vv['is_over'] == 1){
  2160. $yck += 1;
  2161. }
  2162. $yjs_arr[$vv['fid']] = 1;
  2163. }
  2164. }
  2165. $whlabel_bh_info = $this->whlabel_bh->find("number = ".$v['number']);
  2166. $final_list[$k]['id'] = $v['id'];
  2167. $final_list[$k]['orderinfo'] = $v['orderinfo'] ;
  2168. $final_list[$k]['number'] ="<h9 class='window' data-h='/whlabel_bh/cj_transfer_detail/".$v['number']."/".$tid."' data-t='备货单号:".$v['number']."'><p>".$v['number']."</p></h9>";
  2169. $final_list[$k]['pm'] = $v['pm'];
  2170. $final_list[$k]['ddsl'] = empty($whlabel_bh_info)?0:$whlabel_bh_info['bhnum'];
  2171. $final_list[$k]['yjs'] = $yjs;
  2172. $final_list[$k]['wck'] = $wck;
  2173. $final_list[$k]['yck'] = $yck;
  2174. }
  2175. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2176. echo json_encode($rows);exit;
  2177. }
  2178. if(isset($_SESSION['api']))
  2179. {
  2180. $user = $this->user->get_api($_SESSION['api']);
  2181. $usp = $user;
  2182. $transfer = explode('|',trim($user['transfer'],'|'));
  2183. $stid = "";
  2184. foreach ($transfer as $value)
  2185. {
  2186. $stid .= " id = ".$value." or";
  2187. }
  2188. if(empty($transfer)){
  2189. exit("您的账号没有赋予车间权限");
  2190. }
  2191. // if(count($transfer) > 1){
  2192. // exit("您的账号只能分配一个车间,多车间系统无法处理");
  2193. // }
  2194. $tid = $transfer[0];
  2195. }
  2196. else
  2197. {
  2198. header('Location: /');exit;
  2199. }
  2200. $transfer = $this->transfer->read($tid);
  2201. $this->data['transfer'] = $transfer;
  2202. $transfer_list = $this->transfer->find_all( trim($stid,'or'));
  2203. $start_time = strtotime(date('Y-m-d')) - 14* 24 * 60 * 60;
  2204. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2205. $log_list = $this->whlabel_bh_transfer_cr->find_all(" lx = ".$tid." and type = 1 and time >= ".$start_time." and time <= ".$end_time,"*","id desc");
  2206. $wwcsl = $jszs = $wgzs = 0;
  2207. $tmp_list = [];
  2208. foreach($log_list as $k=>$v){
  2209. if(!isset($tmp_list[$v['fid']])){
  2210. $tmp_list[$v['fid']] = $v;
  2211. $jszs += 1;
  2212. if($v['is_over'] == 1){
  2213. $wgzs += 1;
  2214. }else{
  2215. $wwcsl += 1;
  2216. }
  2217. }
  2218. }
  2219. $this->data['wwcsl'] = $wwcsl;
  2220. $this->data['jszs'] = $jszs;
  2221. $this->data['wgzs'] = $wgzs;
  2222. $this->data['transfer_list'] = $transfer_list;
  2223. $this->_Template('whlabel_bh_cj_transfer_log',$this->data);
  2224. }
  2225. //针对车间的变动筛选条件的
  2226. public function _cj_transfer_log_count(){
  2227. $orderinfo = $this->input->post('orderinfo',true);
  2228. $tid = $this->input->post('tid',true);
  2229. $timetk = $this->input->post('timetk',true);
  2230. $timetj = $this->input->post('timetj',true);
  2231. $pm = $this->input->post('pm',true);
  2232. $start_time = strtotime($timetk);
  2233. $end_time = strtotime($timetj);
  2234. $where = " lx = ".$tid." and type = 1 and time >= ".$start_time." and time <= ".$end_time;
  2235. // if($orderinfo){
  2236. // $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2237. // $numbers = array_column($number_list,'number');
  2238. // $where.= " and number in (".implode(",",$numbers).") ";
  2239. // }
  2240. if($pm){
  2241. if(empty($orderinfo)){
  2242. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2243. }else{
  2244. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");
  2245. $numbers = array_column($number_list,'number');
  2246. if(empty($numbers)){
  2247. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2248. }
  2249. $where.= " and number in (".implode(",",$numbers).") ";
  2250. }
  2251. }else{
  2252. if($orderinfo){
  2253. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2254. $numbers = array_column($number_list,'number');
  2255. if(empty($numbers)){
  2256. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2257. }
  2258. $where.= " and number in (".implode(",",$numbers).") ";
  2259. }
  2260. }
  2261. $log_list = $this->whlabel_bh_transfer_cr->find_all($where);
  2262. $wwcsl = $jszs = $wgzs = 0;
  2263. $tmp_list = [];
  2264. foreach($log_list as $k=>$v){
  2265. if(!isset($tmp_list[$v['fid']])){
  2266. $tmp_list[$v['fid']] = $v;
  2267. $jszs += 1;
  2268. if($v['is_over'] == 1){
  2269. $wgzs += 1;
  2270. }else{
  2271. $wwcsl += 1;
  2272. }
  2273. }
  2274. }
  2275. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => $wwcsl,'jszs'=>$jszs,'wgzs'=>$wgzs]]));
  2276. }
  2277. public function _cj_transfer_detail($arg_array){
  2278. $number = $arg_array[0];
  2279. $tid = $arg_array[1];
  2280. $transfer_info = $this->transfer->read($tid);
  2281. $whlabel_bh_info = $this->whlabel_bh->find(" number = ".$number);
  2282. $final_list = [];
  2283. $log_list = $this->whlabel_bh_transfer_cr->find_all( " number = ".$number." and lx = ".$tid,"*","id asc");
  2284. $collect_list = [];
  2285. foreach($log_list as $k=>$v){
  2286. if(isset($final_list[$v['fid']])){
  2287. if($v['type'] == 1){
  2288. $final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);
  2289. }else{
  2290. $final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);
  2291. }
  2292. }else{
  2293. if($v['type'] == 1){
  2294. $final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);
  2295. }else{
  2296. $final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);
  2297. }
  2298. }
  2299. }
  2300. $this->data['whlabel_bh_info'] = $whlabel_bh_info;
  2301. $this->data['transfer_info'] = $transfer_info;
  2302. $this->data['final_list'] = $final_list;
  2303. $this->_Template('whlabel_bh_cj_transfer_detail',$this->data);
  2304. }
  2305. public function _excelwchz(){
  2306. $classid = $this->classid->sku();
  2307. $pm = $classid;
  2308. $typeclass = array();
  2309. $tc = $this->typeclass->find_all();
  2310. foreach ($tc as $v)
  2311. {
  2312. $typeclass[$v['id']] = $v;
  2313. }
  2314. $prc = array();
  2315. $purchase = $this->purchase->find_all();
  2316. foreach($purchase as $k=>$v)
  2317. {
  2318. $prc[$v['id']] = $v['title'];
  2319. }
  2320. if(isset($_GET['fexcel']))
  2321. {
  2322. $number = $this->input->get('number',true);
  2323. $pm = $this->input->get('pm',true);
  2324. $color = $this->input->get('color',true);
  2325. $transfer = $this->input->get('transfer',true);
  2326. $ktime = $this->input->get('timetk',true);
  2327. $jtime = $this->input->get('timetj',true);
  2328. $ktime = strtotime($ktime);
  2329. $jtime = strtotime($jtime);
  2330. $where = " time >= ".$ktime." and time <= ".$jtime." ";$gj = "";$ck = "";
  2331. $where .=" and status = 2 and ck like '%|".$transfer."|' ";
  2332. if($number)
  2333. {
  2334. $where .= " and number like '%$number%'";
  2335. }
  2336. if($pm)
  2337. {
  2338. $where .= " and pm like '%$pm%'";
  2339. }
  2340. if($color)
  2341. {
  2342. $where .= " and features like '%-$color-%'";
  2343. }
  2344. $list = array();
  2345. $rows = $this->whlabel_bh_transfer->find_all($where,'id,wbid,orderinfo,jm,pm,time,label');
  2346. foreach($rows as $k=>$v){
  2347. if(isset($list[$v['wbid']])){
  2348. $list[$v['wbid']]['sl'] = $list[$v['wbid']]['sl'] + 1;
  2349. $list[$v['wbid']]['time'][] = date("Y-m-d H:i:s",$v['time']);
  2350. $list[$v['wbid']]['label'][] = $v['label'];
  2351. }else{
  2352. $list[$v['wbid']] = [
  2353. 'wbid'=>$v['wbid'],
  2354. 'orderinfo'=>$v['orderinfo'],
  2355. 'jm'=>$v['jm'],
  2356. 'pm'=>$v['pm'],
  2357. 'sl'=>1,
  2358. 'time'=>[
  2359. date("Y-m-d H:i:s",$v['time'])
  2360. ],
  2361. 'label'=>[
  2362. $v['label'],
  2363. ]
  2364. ];
  2365. }
  2366. }
  2367. $filename = date("Y-m-d")."工厂备货完成汇总.xls";
  2368. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2369. <head>
  2370. <!--[if gte mso 9]><xml>
  2371. <x:ExcelWorkbook>
  2372. <x:ExcelWorksheets>
  2373. <x:ExcelWorksheet>
  2374. <x:Name>EXCEL</x:Name>
  2375. <x:WorksheetOptions>
  2376. <x:Print>
  2377. <x:ValidPrinterInfo />
  2378. </x:Print>
  2379. </x:WorksheetOptions>
  2380. </x:ExcelWorksheet>
  2381. </x:ExcelWorksheets>
  2382. </x:ExcelWorkbook>
  2383. </xml>
  2384. <![endif]-->
  2385. </head><body>";
  2386. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2387. $str .= "<tr><td>ID</td><td>编号</td><td>简码</td><td>品名</td><td>数量</td><td>扫描时间</td><td>扫描条码</td></tr>";
  2388. foreach ($list as $key=>$value)
  2389. {
  2390. $str .= "<tr>";
  2391. $str .= "<td>". $value['wbid']. "</td>";
  2392. $str .= "<td>". $value['orderinfo']. "</td>";
  2393. $str .= "<td>". $value['jm']. "</td>";
  2394. $str .= "<td>". $value['pm']. "</td>";
  2395. $str .= "<td>". $value['sl']. "</td>";
  2396. $str .="<td>";
  2397. $tmp = "";
  2398. foreach($value['time'] as $kk=>$vv){
  2399. $tmp .=$vv."<br/>";
  2400. }
  2401. $str .= trim($tmp,"<br/>");
  2402. $str .="</td>";
  2403. $str .="<td>";
  2404. $tmp_l = "";
  2405. foreach($value['label'] as $kk=>$vv){
  2406. $tmp_l .= "`".$vv."<br/>";
  2407. }
  2408. $str .= trim($tmp_l,"<br/>");
  2409. $str .="</td>";
  2410. $str .= "</tr>";
  2411. }
  2412. $str .= "</table></body></html>";
  2413. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2414. header( "Content-type: application/octet-stream" );
  2415. header( "Content-Disposition: attachment; filename=".$filename );
  2416. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2417. header( "Pragma: no-cache" );
  2418. header( "Expires: 0" );
  2419. exit($str);
  2420. }
  2421. }
  2422. }