Whlabel_bh.php 116 KB

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