Whlabel_bh.php 116 KB

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