Whlabel_bh.php 111 KB

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