Whlabel_bh.php 117 KB

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