Whlabel_bh.php 99 KB

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