Whlabel_bh.php 89 KB

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