Whlabel_bh.php 94 KB

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