Whlabel_bh.php 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790
  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. $this->db->trans_begin();
  1834. $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']);
  1835. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);
  1836. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1837. if($ct_info){
  1838. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1839. }
  1840. $this->zzquque_u9->insert([
  1841. 'platform'=>'',
  1842. 'warehouse'=>0,
  1843. 'type'=>21,
  1844. 'order_no'=>$lb['orderinfo'],
  1845. 'child_order_no'=>$lb['id'],
  1846. 'status'=>0,
  1847. 'create_time'=>time(),
  1848. 'update_time'=>time(),
  1849. ]);
  1850. if ($this->db->trans_status() === TRUE){
  1851. $this->db->trans_commit();
  1852. echo json_encode(array('music'=>'1','success'=>true));exit;
  1853. }else{
  1854. $this->db->trans_rollback();
  1855. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1856. }
  1857. }
  1858. //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1859. if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
  1860. {
  1861. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1862. }
  1863. $save_data = [
  1864. 'rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time
  1865. ];
  1866. //配货入库需更新一下配货状态
  1867. if($transfer == 1 && $cz == 2 && $lb['status'] == 0){
  1868. $save_data['status'] = 1;
  1869. }
  1870. $this->db->trans_begin();
  1871. $this->whlabel_bh_transfer->save($save_data,$lb['id']);
  1872. if($cz == 2){
  1873. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>1,'number'=>$lb['number']]);
  1874. $ct_info = $this->whlabel_bh_transfer_cr->find("fid = ".$lb['id']." and lx = ".$transfer." and type = 1 and is_over = 0","*",'id desc');
  1875. if($ct_info){
  1876. $this->whlabel_bh_transfer_cr->save(['is_over'=>1],$ct_info['id']);
  1877. }
  1878. }else{
  1879. $this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time(),'is_over'=>0,'number'=>$lb['number']]);
  1880. }
  1881. if ($this->db->trans_status() === TRUE){
  1882. $this->db->trans_commit();
  1883. echo json_encode(array('music'=>'1','success'=>true));exit;
  1884. }else{
  1885. $this->db->trans_rollback();
  1886. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1887. }
  1888. }
  1889. }
  1890. protected function getOperateList(){
  1891. $api = $this->input->post('api',true);
  1892. $page = $this->input->post('page',true);
  1893. $perpage = $this->input->post('perpage',true);
  1894. $orderinfo = $this->input->post('number',true);
  1895. $color = $this->input->post('color',true);
  1896. $pm = $this->input->post('pm',true);
  1897. $purchase = $this->input->post('purchase',true);
  1898. $transfer = $this->input->post('transfer',true);
  1899. $lx = $this->input->post('lx',true);
  1900. $timetk = $this->input->post('timetk',true);
  1901. $timetj = $this->input->post('timetj',true);
  1902. $timetk = strtotime($timetk);
  1903. $timetj = strtotime($timetj);
  1904. $where = "1=1";
  1905. if($transfer)
  1906. {
  1907. $ctime = 'ctime'.$transfer;
  1908. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1909. }
  1910. else
  1911. {
  1912. $where .= " and time > '$timetk' and time < '$timetj'";
  1913. }
  1914. if($orderinfo)
  1915. {
  1916. $where .= " and orderinfo like '%$orderinfo%'";
  1917. }
  1918. if($transfer)
  1919. {
  1920. $where .= " and rk like '%|".$transfer."|%'";
  1921. }
  1922. if($purchase)
  1923. {
  1924. $where .= " and purchase = '$purchase'";
  1925. }
  1926. if($pm)
  1927. {
  1928. $where .= " and pm like '%$pm%'";
  1929. }
  1930. if($color)
  1931. {
  1932. $where .= " and fpdata like '%-".$color."-%'";
  1933. }
  1934. //数据排序
  1935. $order_str = "id desc";
  1936. if(empty($page))
  1937. {
  1938. $start = 0;
  1939. $perpage = 1;
  1940. }
  1941. else
  1942. {
  1943. $start = ($page - 1)*$perpage;
  1944. }
  1945. //取得信息列表
  1946. $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage);
  1947. $transfer = $this->transfer->find_all();
  1948. $t = array();$ot = array();
  1949. foreach ($transfer as $v)
  1950. {
  1951. $t[$v['id']] = $v['title'];
  1952. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1953. }
  1954. //格式化数据
  1955. foreach ($info_list as $key=>$value)
  1956. {
  1957. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1958. $log_list= $this->whlabel_bh_transfer_cr->find_all("fid = ".$value['id']);
  1959. $tmp_operate_str = "";
  1960. foreach($log_list as $k=>$v){
  1961. $tmp_operate_str.= $t[$v['lx']]."".($v['type']==1?'入库':'出库').":".date('Y-m-d H:i:s',$v['time'])."<br>";
  1962. }
  1963. $info_list[$key]['time'] = trim($tmp_operate_str,'<br>');
  1964. }
  1965. $total = $this->whlabel_bh_transfer->find_count($where);
  1966. $pagenum = ceil($total/$perpage);
  1967. $over = $total-($start+$perpage);
  1968. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'where'=>$where);
  1969. return $rows;
  1970. }
  1971. public function _operate()
  1972. {
  1973. $post = $this->input->post(NULL, TRUE);
  1974. if(isset($post['page']))
  1975. {
  1976. $rows = $this->getOperateList();
  1977. echo json_encode($rows);exit;
  1978. }
  1979. if(isset($_SESSION['api']))
  1980. {
  1981. $user = $this->user->get_api($_SESSION['api']);
  1982. $usp = $user;
  1983. $pid = "";$tid="";$sid="";$wid="";
  1984. $purchase = explode('|',trim($user['purchase'],'|'));
  1985. $transfer = explode('|',trim($user['transfer'],'|'));
  1986. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1987. foreach ($purchase as $value)
  1988. {
  1989. $pid .= " id = ".$value." or";
  1990. }
  1991. foreach ($transfer as $value)
  1992. {
  1993. $tid .= " id = ".$value." or";
  1994. }
  1995. foreach ($warehouse as $value)
  1996. {
  1997. $wid .= " id = ".$value." or";
  1998. }
  1999. }
  2000. else
  2001. {
  2002. header('Location: /');exit;
  2003. }
  2004. $kx = '';$zjtab = '';
  2005. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2006. $this->data['warehouse'] = $warehouse;
  2007. $purchase = $this->purchase->find_all("yyid != ''");
  2008. $this->data['purchase'] = $purchase;
  2009. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2010. $this->data['transfer'] = $transfer;
  2011. $ids = array_column($transfer,'id');
  2012. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2013. $start_time = $end_time - 14 * 24 * 60 * 60;
  2014. //$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 );
  2015. //$this->data['count'] = $count;
  2016. $this->data['vip'] = $user['vip'];
  2017. $this->_Template('whlabel_bh_operate',$this->data);
  2018. }
  2019. public function _rk()
  2020. {
  2021. $post = $this->input->post(NULL, TRUE);
  2022. if(isset($post['page']))
  2023. {
  2024. $res = $this->getOperateList();
  2025. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  2026. echo json_encode($rows);exit;
  2027. }
  2028. if(isset($_SESSION['api']))
  2029. {
  2030. $user = $this->user->get_api($_SESSION['api']);
  2031. $usp = $user;
  2032. $pid = "";$tid="";$sid="";$wid="";
  2033. $purchase = explode('|',trim($user['purchase'],'|'));
  2034. $transfer = explode('|',trim($user['transfer'],'|'));
  2035. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2036. foreach ($purchase as $value)
  2037. {
  2038. $pid .= " id = ".$value." or";
  2039. }
  2040. foreach ($transfer as $value)
  2041. {
  2042. $tid .= " id = ".$value." or";
  2043. }
  2044. foreach ($warehouse as $value)
  2045. {
  2046. $wid .= " id = ".$value." or";
  2047. }
  2048. }
  2049. else
  2050. {
  2051. header('Location: /');exit;
  2052. }
  2053. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2054. $this->data['transfer'] = $transfer;
  2055. $this->_Template('whlabel_bh_rk',$this->data);
  2056. }
  2057. public function _ck()
  2058. {
  2059. $post = $this->input->post(NULL, TRUE);
  2060. if(isset($post['page']))
  2061. {
  2062. $res = $this->getOperateList();
  2063. $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
  2064. echo json_encode($rows);exit;
  2065. }
  2066. if(isset($_SESSION['api']))
  2067. {
  2068. $user = $this->user->get_api($_SESSION['api']);
  2069. $usp = $user;
  2070. $pid = "";$tid="";$sid="";$wid="";
  2071. $purchase = explode('|',trim($user['purchase'],'|'));
  2072. $transfer = explode('|',trim($user['transfer'],'|'));
  2073. $warehouse = explode('|',trim($user['warehouse'],'|'));
  2074. foreach ($purchase as $value)
  2075. {
  2076. $pid .= " id = ".$value." or";
  2077. }
  2078. foreach ($transfer as $value)
  2079. {
  2080. $tid .= " id = ".$value." or";
  2081. }
  2082. foreach ($warehouse as $value)
  2083. {
  2084. $wid .= " id = ".$value." or";
  2085. }
  2086. }
  2087. else
  2088. {
  2089. header('Location: /');exit;
  2090. }
  2091. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  2092. $this->data['transfer'] = $transfer;
  2093. $this->_Template('whlabel_bh_ck',$this->data);
  2094. }
  2095. //备货流转记录表
  2096. public function _transfer_log(){
  2097. $post = $this->input->post(NULL, TRUE);
  2098. if($post){
  2099. $page = $this->input->post('page',true);
  2100. $perpage = $this->input->post('perpage',true);
  2101. $where = " extra_type = 1 ";
  2102. $orderinfo = $this->input->post('orderinfo',true);
  2103. $timetk = $this->input->post('timetk',true);
  2104. $timetj = $this->input->post('timetj',true);
  2105. $timetk = strtotime($timetk);
  2106. $timetj = strtotime($timetj);
  2107. if($timetk && $timetj)
  2108. {
  2109. $where .= " and time > '$timetk' and time < '$timetj'";
  2110. }
  2111. if($orderinfo){
  2112. $where.= " and orderinfo like '%$orderinfo%' ";
  2113. }
  2114. if(empty($page))
  2115. {
  2116. $start = 0;
  2117. $perpage = 1;
  2118. }
  2119. else
  2120. {
  2121. $start = ($page - 1)*$perpage;
  2122. }
  2123. $list = $this->whlabel_bh->find_pc($where,'orderinfo',"id,orderinfo,jgtime",'id desc',$start,$perpage);
  2124. $rows = [];
  2125. foreach($list as $k=>$v){
  2126. $tmp_order_info = $this->whlabel_bh->find_all(" orderinfo = '".$v['orderinfo']."'","id,orderinfo,bhnum");
  2127. $tmp_ids = [];
  2128. $tmp_bhnum = 0;
  2129. foreach($tmp_order_info as $vv){
  2130. $tmp_ids[] = $vv['id'];
  2131. $tmp_bhnum += $vv['bhnum'];
  2132. }
  2133. $ydysl = $wdysl = $yphsl = $yjgsj = $wwgsl = 0;
  2134. if(!empty($tmp_ids)){
  2135. $list = $this->whlabel_bh_transfer->find_all(" wbid in (".implode(",",$tmp_ids).")");
  2136. foreach($list as $vv){
  2137. $ydysl += 1;
  2138. if($vv['status'] == 1){
  2139. $yphsl += 1;
  2140. }
  2141. if($vv['status'] == 2){
  2142. $yjgsj += 1;
  2143. }
  2144. }
  2145. }
  2146. $rows[$k]['id'] = $v['id'];
  2147. $rows[$k]['orderinfo'] = "<h9 class='window' data-h='/whlabel_bh/transfer_detail/".$v['id']."' data-t='备货单号:".$v['orderinfo']."'><p>".$v['orderinfo']."</p></h9>" ;
  2148. $rows[$k]['ddsl'] = $tmp_bhnum; //订单数量
  2149. $rows[$k]['ydysl'] = $ydysl; //已打印数量
  2150. $rows[$k]['wdysl'] = $tmp_bhnum - $ydysl; //未打印数量
  2151. $rows[$k]['yphsl'] = $yphsl; //已配货数量
  2152. $rows[$k]['yjgsj'] = $yjgsj; //已完工数量
  2153. $rows[$k]['wwgsl'] = $tmp_bhnum - $yjgsj; //未完工数量
  2154. $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>';
  2155. }
  2156. $total = $this->whlabel_bh->find_count($where);
  2157. $pagenum = ceil($total/$perpage);
  2158. $over = $total-($start+$perpage);
  2159. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  2160. echo json_encode($rows);exit;
  2161. }
  2162. $start_time = strtotime(date('Y-m-d')) - 14* 24 * 60 * 60;
  2163. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2164. $all_list = $this->whlabel_bh->find_all("extra_type = 1 and time >= ".$start_time." and time <= ".$end_time);
  2165. $orderinfo_list =[];
  2166. $total_num = 0;
  2167. foreach($all_list as $k=>$v){
  2168. $orderinfo_list[$v['id']] = $v['id'];
  2169. $total_num += $v['bhnum'];
  2170. }
  2171. $wbids = array_values($orderinfo_list);
  2172. if(empty($wbids)){
  2173. $over_num = 0;
  2174. }else{
  2175. $over_num = $this->whlabel_bh_transfer->find_count(" status = 2 and wbid in (".implode(",",$wbids).")");
  2176. }
  2177. $this->data['total_num'] = $total_num;
  2178. $this->data['wwcsl'] = $total_num - $over_num;
  2179. $this->_Template('whlabel_bh_transfer_log',$this->data);
  2180. }
  2181. public function _edit_jgtime(){
  2182. $post = $this->input->post(NULL, TRUE);
  2183. $info = $this->whlabel_bh->read($post['id']);
  2184. if(empty($info)){
  2185. echo json_encode(['code'=>-1,'msg'=>'信息异常']);exit;
  2186. }
  2187. $jgtime = strtotime($post['jgtime']);
  2188. $list = $this->whlabel_bh->find_all(" orderinfo = '".$info['orderinfo']."'");
  2189. foreach($list as $k=>$v){
  2190. $this->whlabel_bh->save(['jgtime'=>$jgtime],$v['id']);
  2191. }
  2192. echo json_encode(['code'=>1,'msg'=>'操作成功']);exit;
  2193. }
  2194. public function _transfer_detail($arg_array){
  2195. $id = $arg_array[0];
  2196. $transfer_list = $this->transfer->find_all();
  2197. $t_list = array_column($transfer_list,'title','id');
  2198. $info = $this->whlabel_bh->read($id);
  2199. $list = $this->whlabel_bh_transfer->find_all(" orderinfo= '".$info['orderinfo']."'");
  2200. $ids = array_column($list,'id');
  2201. $final_list = [];
  2202. if(!empty($ids)){
  2203. $log_list = $this->whlabel_bh_transfer_cr->find_all( " type = 1 and fid in (".implode(",",$ids).")","*","id asc");
  2204. $collect_list = [];
  2205. foreach($log_list as $k=>$v){
  2206. $collect_list[$v['lx']][$v['fid']] = $v;
  2207. }
  2208. foreach($collect_list as $k=>$v){
  2209. $js_num = $zk_num = $wc_num = 0;
  2210. foreach($v as $kk=>$vv){
  2211. $js_num += 1;
  2212. if($vv['is_over'] == 0){
  2213. $zk_num += 1;
  2214. }
  2215. if($vv['is_over'] == 1){
  2216. $wc_num += 1;
  2217. }
  2218. }
  2219. $final_list[$k] = [
  2220. 'cj' => $t_list[$k],
  2221. 'js_num' => $js_num,
  2222. 'zk_num' => $zk_num,
  2223. 'wc_num' => $wc_num,
  2224. 'list' => $v,
  2225. ];
  2226. }
  2227. }
  2228. // echo "<pre>";
  2229. // print_r($final_list);
  2230. // die;
  2231. $this->data['final_list'] = $final_list;
  2232. $this->_Template('whlabel_bh_transfer_detail',$this->data);
  2233. }
  2234. public function _cj_transfer_log(){
  2235. $post = $this->input->post(NULL, TRUE);
  2236. if(!empty($post)){
  2237. $orderinfo = $this->input->post('orderinfo',true);
  2238. $pm = $this->input->post('pm',true);
  2239. $tid = $this->input->post('tid',true);
  2240. $page = $this->input->post('page',true);
  2241. $perpage = $this->input->post('perpage',true);
  2242. $timetk = $this->input->post('timetk',true);
  2243. $timetj = $this->input->post('timetj',true);
  2244. $timetk = strtotime($timetk);
  2245. $timetj = strtotime($timetj);
  2246. $where = " rk like '%|".$tid."|%' ";
  2247. if($timetk && $timetj)
  2248. {
  2249. $where .= " and time > '$timetk' and time < '$timetj'";
  2250. }
  2251. if($pm){
  2252. if(empty($orderinfo)){
  2253. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]),'cwxx'=>"请先输入订单号");
  2254. echo json_encode($rows);exit;
  2255. }else{
  2256. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");
  2257. $numbers = array_column($number_list,'number');
  2258. if(empty($numbers)){
  2259. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));
  2260. echo json_encode($rows);exit;
  2261. }
  2262. $where.= " and number in (".implode(",",$numbers).") ";
  2263. }
  2264. }else{
  2265. if($orderinfo){
  2266. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2267. $numbers = array_column($number_list,'number');
  2268. if(empty($numbers)){
  2269. $rows = array('total'=>0,'over'=>1,'pagenum'=>1,'rows'=>([]));
  2270. echo json_encode($rows);exit;
  2271. }
  2272. $where.= " and number in (".implode(",",$numbers).") ";
  2273. }
  2274. }
  2275. if(empty($page))
  2276. {
  2277. $start = 0;
  2278. $perpage = 20;
  2279. }
  2280. else
  2281. {
  2282. $start = ($page - 1)*$perpage;
  2283. }
  2284. $list = $this->whlabel_bh_transfer->find_pc($where,'number',"id,number,orderinfo,pm",'id desc',$start,$perpage);
  2285. $count = $this->whlabel_bh_transfer->find_all($where,'COUNT(DISTINCT number) as total');
  2286. $total = $count[0]['total'];
  2287. $pagenum = ceil($total/$perpage);
  2288. $over = $total-($start+$perpage);
  2289. $final_list = [];
  2290. foreach($list as $k=>$v){
  2291. $yjs_arr =[];//避免多次扫入的重复计算
  2292. $yjs = $wck= $yck = 0;
  2293. $log_list = $this->whlabel_bh_transfer_cr->find_all("lx = ".$tid." and type = 1 and number = ".$v['number'],"*",'id desc');
  2294. foreach($log_list as $kk=>$vv){
  2295. if(!isset($yjs_arr[$vv['fid']])){
  2296. $yjs += 1;
  2297. if($vv['is_over'] == 0){
  2298. $wck += 1;
  2299. }
  2300. if($vv['is_over'] == 1){
  2301. $yck += 1;
  2302. }
  2303. $yjs_arr[$vv['fid']] = 1;
  2304. }
  2305. }
  2306. $whlabel_bh_info = $this->whlabel_bh->find("number = ".$v['number']);
  2307. $final_list[$k]['id'] = $v['id'];
  2308. $final_list[$k]['orderinfo'] = $v['orderinfo'] ;
  2309. $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>";
  2310. $final_list[$k]['pm'] = $v['pm'];
  2311. $final_list[$k]['ddsl'] = empty($whlabel_bh_info)?0:$whlabel_bh_info['bhnum'];
  2312. $final_list[$k]['yjs'] = $yjs;
  2313. $final_list[$k]['wck'] = $wck;
  2314. $final_list[$k]['yck'] = $yck;
  2315. }
  2316. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2317. echo json_encode($rows);exit;
  2318. }
  2319. if(isset($_SESSION['api']))
  2320. {
  2321. $user = $this->user->get_api($_SESSION['api']);
  2322. $usp = $user;
  2323. $transfer = explode('|',trim($user['transfer'],'|'));
  2324. $stid = "";
  2325. foreach ($transfer as $value)
  2326. {
  2327. $stid .= " id = ".$value." or";
  2328. }
  2329. if(empty($transfer)){
  2330. exit("您的账号没有赋予车间权限");
  2331. }
  2332. // if(count($transfer) > 1){
  2333. // exit("您的账号只能分配一个车间,多车间系统无法处理");
  2334. // }
  2335. $tid = $transfer[0];
  2336. }
  2337. else
  2338. {
  2339. header('Location: /');exit;
  2340. }
  2341. $transfer = $this->transfer->read($tid);
  2342. $this->data['transfer'] = $transfer;
  2343. $transfer_list = $this->transfer->find_all( trim($stid,'or'));
  2344. $start_time = strtotime(date('Y-m-d')) - 14* 24 * 60 * 60;
  2345. $end_time = strtotime(date('Y-m-d')) + 24 * 60 * 60;
  2346. $log_list = $this->whlabel_bh_transfer_cr->find_all(" lx = ".$tid." and type = 1 and time >= ".$start_time." and time <= ".$end_time,"*","id desc");
  2347. $wwcsl = $jszs = $wgzs = 0;
  2348. $tmp_list = [];
  2349. foreach($log_list as $k=>$v){
  2350. if(!isset($tmp_list[$v['fid']])){
  2351. $tmp_list[$v['fid']] = $v;
  2352. $jszs += 1;
  2353. if($v['is_over'] == 1){
  2354. $wgzs += 1;
  2355. }else{
  2356. $wwcsl += 1;
  2357. }
  2358. }
  2359. }
  2360. $this->data['wwcsl'] = $wwcsl;
  2361. $this->data['jszs'] = $jszs;
  2362. $this->data['wgzs'] = $wgzs;
  2363. $this->data['transfer_list'] = $transfer_list;
  2364. $this->_Template('whlabel_bh_cj_transfer_log',$this->data);
  2365. }
  2366. public function _cj_transfer_zklog(){
  2367. $post = $this->input->post(NULL, TRUE);
  2368. if(!empty($post)){
  2369. $orderinfo = $this->input->post('orderinfo',true);
  2370. $pm = $this->input->post('pm',true);
  2371. $tid = $this->input->post('tid',true);
  2372. $page = $this->input->post('page',true);
  2373. $perpage = $this->input->post('perpage',true);
  2374. $timetk = $this->input->post('timetk',true);
  2375. $timetj = $this->input->post('timetj',true);
  2376. $timetk = strtotime($timetk);
  2377. $timetj = strtotime($timetj);
  2378. $where = " time > '$timetk' and time < '$timetj' and lx = ".$tid." and type = 1 and is_over = 0 ";
  2379. if(empty($page))
  2380. {
  2381. $start = 0;
  2382. $perpage = 20;
  2383. }
  2384. else
  2385. {
  2386. $start = ($page - 1)*$perpage;
  2387. }
  2388. $list = $this->whlabel_bh_transfer_cr->find_all($where,"*",'id asc',$start,$perpage);
  2389. $count = $this->whlabel_bh_transfer_cr->find_all($where,'COUNT(*) as total');
  2390. $total = $count[0]['total'];
  2391. $pagenum = ceil($total/$perpage);
  2392. $over = $total-($start+$perpage);
  2393. $final_list = [];
  2394. foreach($list as $k=>$v){
  2395. $transfer_info = $this->whlabel_bh_transfer->read($v['fid']);
  2396. $final_list[$k]['id'] = $v['id'];
  2397. $final_list[$k]['orderinfo'] = $transfer_info['orderinfo'];
  2398. $final_list[$k]['pm'] = $transfer_info['pm'];
  2399. $final_list[$k]['time'] = date('Y-m-d H:i:s',$v['time']);
  2400. }
  2401. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  2402. echo json_encode($rows);exit;
  2403. }
  2404. $tid = $this->input->get('tid',true);
  2405. if(isset($_SESSION['api']))
  2406. {
  2407. $user = $this->user->get_api($_SESSION['api']);
  2408. $transfer = explode('|',trim($user['transfer'],'|'));
  2409. $stid = "";
  2410. foreach ($transfer as $value)
  2411. {
  2412. $stid .= " id = ".$value." or";
  2413. }
  2414. if(empty($transfer)){
  2415. exit("您的账号没有赋予车间权限");
  2416. }
  2417. }
  2418. else
  2419. {
  2420. header('Location: /');exit;
  2421. }
  2422. $transfer = $this->transfer->read($tid);
  2423. $this->data['transfer'] = $transfer;
  2424. $transfer_list = $this->transfer->find_all( trim($stid,'or'));
  2425. $this->data['transfer_list'] = $transfer_list;
  2426. $this->_Template('whlabel_bh_cj_transfer_zklog',$this->data);
  2427. }
  2428. //针对车间的变动筛选条件的
  2429. public function _cj_transfer_log_count(){
  2430. $orderinfo = $this->input->post('orderinfo',true);
  2431. $tid = $this->input->post('tid',true);
  2432. $timetk = $this->input->post('timetk',true);
  2433. $timetj = $this->input->post('timetj',true);
  2434. $pm = $this->input->post('pm',true);
  2435. $start_time = strtotime($timetk);
  2436. $end_time = strtotime($timetj);
  2437. $where = " lx = ".$tid." and type = 1 and time >= ".$start_time." and time <= ".$end_time;
  2438. // if($orderinfo){
  2439. // $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2440. // $numbers = array_column($number_list,'number');
  2441. // $where.= " and number in (".implode(",",$numbers).") ";
  2442. // }
  2443. if($pm){
  2444. if(empty($orderinfo)){
  2445. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2446. }else{
  2447. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo' and pm like '%".$pm."%' " ,"orderinfo,number");
  2448. $numbers = array_column($number_list,'number');
  2449. if(empty($numbers)){
  2450. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2451. }
  2452. $where.= " and number in (".implode(",",$numbers).") ";
  2453. }
  2454. }else{
  2455. if($orderinfo){
  2456. $number_list = $this->whlabel_bh->find_all(" orderinfo = '$orderinfo'","orderinfo,number");
  2457. $numbers = array_column($number_list,'number');
  2458. if(empty($numbers)){
  2459. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => 0,'jszs'=>0,'wgzs'=>0]]));
  2460. }
  2461. $where.= " and number in (".implode(",",$numbers).") ";
  2462. }
  2463. }
  2464. $log_list = $this->whlabel_bh_transfer_cr->find_all($where);
  2465. $wwcsl = $jszs = $wgzs = 0;
  2466. $tmp_list = [];
  2467. foreach($log_list as $k=>$v){
  2468. if(!isset($tmp_list[$v['fid']])){
  2469. $tmp_list[$v['fid']] = $v;
  2470. $jszs += 1;
  2471. if($v['is_over'] == 1){
  2472. $wgzs += 1;
  2473. }else{
  2474. $wwcsl += 1;
  2475. }
  2476. }
  2477. }
  2478. exit(json_encode(['code'=>1,'msg'=>'ok', 'data'=>['wwcsl' => $wwcsl,'jszs'=>$jszs,'wgzs'=>$wgzs]]));
  2479. }
  2480. public function _cj_transfer_detail($arg_array){
  2481. $number = $arg_array[0];
  2482. $tid = $arg_array[1];
  2483. $transfer_info = $this->transfer->read($tid);
  2484. $whlabel_bh_info = $this->whlabel_bh->find(" number = ".$number);
  2485. $final_list = [];
  2486. $log_list = $this->whlabel_bh_transfer_cr->find_all( " number = ".$number." and lx = ".$tid,"*","id asc");
  2487. $collect_list = [];
  2488. foreach($log_list as $k=>$v){
  2489. if(isset($final_list[$v['fid']])){
  2490. if($v['type'] == 1){
  2491. $final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);
  2492. }else{
  2493. $final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);
  2494. }
  2495. }else{
  2496. if($v['type'] == 1){
  2497. $final_list[$v['fid']]['sr_time'] = date('Y-m-d H:i:s',$v['time']);
  2498. }else{
  2499. $final_list[$v['fid']]['sc_time'] = date('Y-m-d H:i:s',$v['time']);
  2500. }
  2501. }
  2502. }
  2503. $this->data['whlabel_bh_info'] = $whlabel_bh_info;
  2504. $this->data['transfer_info'] = $transfer_info;
  2505. $this->data['final_list'] = $final_list;
  2506. $this->_Template('whlabel_bh_cj_transfer_detail',$this->data);
  2507. }
  2508. public function _excelwchz(){
  2509. $classid = $this->classid->sku();
  2510. $pm = $classid;
  2511. $typeclass = array();
  2512. $tc = $this->typeclass->find_all();
  2513. foreach ($tc as $v)
  2514. {
  2515. $typeclass[$v['id']] = $v;
  2516. }
  2517. $prc = array();
  2518. $purchase = $this->purchase->find_all();
  2519. foreach($purchase as $k=>$v)
  2520. {
  2521. $prc[$v['id']] = $v['title'];
  2522. }
  2523. if(isset($_GET['fexcel']))
  2524. {
  2525. $number = $this->input->get('number',true);
  2526. $pm = $this->input->get('pm',true);
  2527. $color = $this->input->get('color',true);
  2528. $transfer = $this->input->get('transfer',true);
  2529. $ktime = $this->input->get('timetk',true);
  2530. $jtime = $this->input->get('timetj',true);
  2531. $ktime = strtotime($ktime);
  2532. $jtime = strtotime($jtime);
  2533. $where = " time >= ".$ktime." and time <= ".$jtime." ";$gj = "";$ck = "";
  2534. $where .=" and status = 2 and ck like '%|".$transfer."|' ";
  2535. if($number)
  2536. {
  2537. $where .= " and number like '%$number%'";
  2538. }
  2539. if($pm)
  2540. {
  2541. $where .= " and pm like '%$pm%'";
  2542. }
  2543. if($color)
  2544. {
  2545. $where .= " and features like '%-$color-%'";
  2546. }
  2547. $list = array();
  2548. $rows = $this->whlabel_bh_transfer->find_all($where,'id,wbid,orderinfo,jm,pm,time,label');
  2549. foreach($rows as $k=>$v){
  2550. if(isset($list[$v['wbid']])){
  2551. $list[$v['wbid']]['sl'] = $list[$v['wbid']]['sl'] + 1;
  2552. $list[$v['wbid']]['time'][] = date("Y-m-d H:i:s",$v['time']);
  2553. $list[$v['wbid']]['label'][] = $v['label'];
  2554. }else{
  2555. $list[$v['wbid']] = [
  2556. 'wbid'=>$v['wbid'],
  2557. 'orderinfo'=>$v['orderinfo'],
  2558. 'jm'=>$v['jm'],
  2559. 'pm'=>$v['pm'],
  2560. 'sl'=>1,
  2561. 'time'=>[
  2562. date("Y-m-d H:i:s",$v['time'])
  2563. ],
  2564. 'label'=>[
  2565. $v['label'],
  2566. ]
  2567. ];
  2568. }
  2569. }
  2570. $filename = date("Y-m-d")."工厂备货完成汇总.xls";
  2571. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2572. <head>
  2573. <!--[if gte mso 9]><xml>
  2574. <x:ExcelWorkbook>
  2575. <x:ExcelWorksheets>
  2576. <x:ExcelWorksheet>
  2577. <x:Name>EXCEL</x:Name>
  2578. <x:WorksheetOptions>
  2579. <x:Print>
  2580. <x:ValidPrinterInfo />
  2581. </x:Print>
  2582. </x:WorksheetOptions>
  2583. </x:ExcelWorksheet>
  2584. </x:ExcelWorksheets>
  2585. </x:ExcelWorkbook>
  2586. </xml>
  2587. <![endif]-->
  2588. </head><body>";
  2589. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  2590. $str .= "<tr><td>ID</td><td>编号</td><td>简码</td><td>品名</td><td>数量</td><td>扫描时间</td><td>扫描条码</td></tr>";
  2591. foreach ($list as $key=>$value)
  2592. {
  2593. $str .= "<tr>";
  2594. $str .= "<td>". $value['wbid']. "</td>";
  2595. $str .= "<td>". $value['orderinfo']. "</td>";
  2596. $str .= "<td>". $value['jm']. "</td>";
  2597. $str .= "<td>". $value['pm']. "</td>";
  2598. $str .= "<td>". $value['sl']. "</td>";
  2599. $str .="<td>";
  2600. $tmp = "";
  2601. foreach($value['time'] as $kk=>$vv){
  2602. $tmp .=$vv."<br/>";
  2603. }
  2604. $str .= trim($tmp,"<br/>");
  2605. $str .="</td>";
  2606. $str .="<td>";
  2607. $tmp_l = "";
  2608. foreach($value['label'] as $kk=>$vv){
  2609. $tmp_l .= "`".$vv."<br/>";
  2610. }
  2611. $str .= trim($tmp_l,"<br/>");
  2612. $str .="</td>";
  2613. $str .= "</tr>";
  2614. }
  2615. $str .= "</table></body></html>";
  2616. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2617. header( "Content-type: application/octet-stream" );
  2618. header( "Content-Disposition: attachment; filename=".$filename );
  2619. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2620. header( "Pragma: no-cache" );
  2621. header( "Expires: 0" );
  2622. exit($str);
  2623. }
  2624. }
  2625. }