Systemfout.php 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Systemfout extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_whlabel','whlabel');
  8. $this->load->_model('Model_warehouse','warehouse');
  9. $this->load->_model('Model_productprice','productprice');
  10. $this->load->_model('Model_excel','excel');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_fullorderamz','fullorderamz');
  14. $this->load->_model('Model_fullordersmt','fullordersmt');
  15. $this->load->_model('Model_outbound','outbound');
  16. $this->load->_model('Model_express','express');
  17. $this->load->_model('Model_shop','shop');
  18. $this->load->_model('Model_typeclass','typeclass');
  19. $this->load->_model('Model_country','country');
  20. $this->load->_model('Model_kdniao','kdniao');
  21. $this->load->_model('Model_notice','notice');
  22. $this->load->_model('Model_dhl','dhl');
  23. $this->load->_model('Model_dhlhz','dhlhz');
  24. $this->load->_model('Model_usps','usps');
  25. $this->load->_model('Model_fedex','fedex');
  26. $this->load->_model('Model_fedex_cby','fedex_cby');
  27. $this->load->_model('Model_ups','ups');
  28. $this->load->_model('Model_ali','ali');
  29. $this->load->_model('Model_dpd','dpd');
  30. $this->load->_model('Model_shop','shop');
  31. $this->load->_model('Model_user','user');
  32. $this->load->_model('Model_whlabel','whlabel');
  33. $this->load->_model('Model_specialstock','specialstock');
  34. $this->load->_model('Model_ck','ck');
  35. $this->load->_model('Model_whlabellabel','whlabellabel');
  36. $this->load->_model('Model_apiyy','apiyy');
  37. $this->load->helper('url');
  38. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  39. $this->load->_model('Model_systemtransfer','systemtransfer');
  40. $this->load->_model('Model_classid','classid');
  41. $this->load->_model('Model_allocation','allocation');
  42. $this->load->_model('Model_fullorderxw','fullorderxw');
  43. $this->load->_model('Model_fullorderpaypal','fullorderpaypal');
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_fedexv1",'fedexv1');
  46. $this->load->_model("Model_zzquque_u9","zzquque_u9");
  47. $this->load->_model("Model_customsdeclaration","customsdeclaration");
  48. $this->load->_model("Model_check","check");
  49. $this->load->_model("Model_logic_express","logic_express");
  50. $this->load->_model('Model_outerrors','outerrors');
  51. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  52. }
  53. //定义方法的调用规则 获取URI第二段值
  54. public function _remap($arg,$arg_array)
  55. {
  56. if($arg == 'fedexhz')
  57. {
  58. $this->_fedexhz();
  59. }
  60. else if($arg == 'fout')
  61. {
  62. $this->_fout($arg_array);
  63. }
  64. else if($arg == 'fouthb')//合并出库的
  65. {
  66. $this->_fouthb($arg_array);
  67. }
  68. else if($arg == 'excel')
  69. {
  70. $this->_excel($arg_array);
  71. }
  72. else if($arg == 'cpexcel')
  73. {
  74. $this->_cpexcel($arg_array);
  75. }
  76. else if($arg == 'orderyz')
  77. {
  78. $this->_orderyz();
  79. }
  80. else if($arg == 'hwyz')
  81. {
  82. $this->_hwyz();
  83. }
  84. else if($arg == 'outnumber')
  85. {
  86. $this->_outnumber();
  87. }
  88. else if($arg == 'hb')
  89. {
  90. $this->_hb();
  91. }
  92. else if($arg == 'indexmc'){
  93. $this->_indexmc();
  94. }
  95. else
  96. {
  97. $this->_index();
  98. }
  99. }
  100. public function _index()
  101. {
  102. $post = $this->input->post(NULL, TRUE);
  103. $xw = '';
  104. if(isset($_SESSION['api']))
  105. {
  106. $user = $this->user->get_api($_SESSION['api']);
  107. $usp = $user;
  108. $fgshop = "";$sid = "";$wid="";$wtype="";
  109. $usersp = explode('|',trim($user['shop'],'|'));
  110. $userwh = explode('|',trim($user['warehouse'],'|'));
  111. foreach ($usersp as $value)
  112. {
  113. $fgshop .= " shop = ".$value." or";
  114. $sid .= " id = ".$value." or";
  115. }
  116. foreach ($userwh as $value)
  117. {
  118. $wid .= " id = ".$value." or";
  119. $wtype .= " type = ".$value." or";
  120. }
  121. if($user['userid'] == 'xw')
  122. {
  123. $xw = 1;
  124. }
  125. }
  126. if(isset($post['page']))
  127. {
  128. $page = $this->input->post('page',true);
  129. $perpage = $this->input->post('perpage',true);
  130. $timetk = $this->input->post('timetk',true);
  131. $timetj = $this->input->post('timetj',true);
  132. $shop = $this->input->post('shop',true);
  133. $source = $this->input->post('source',true);
  134. $orderinfo = $this->input->post('orderinfo',true);
  135. $number = $this->input->post('number',true);
  136. $library = $this->input->post('library',true);
  137. $waybill = $this->input->post('waybill',true);
  138. $express = $this->input->post('express',true);
  139. $type = $this->input->post('type',true);
  140. $lowe = $this->input->post('lowe',true);
  141. $so = $this->input->post('so',true);
  142. $is_jiaji = $this->input->post('is_jiaji',true);
  143. $librarytime = $this->input->post('librarytime',true);
  144. $timetk = strtotime($timetk);
  145. $timetj = strtotime($timetj);
  146. $cxtime = 'id';
  147. $where = "library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")";
  148. if($timetk && $timetj && $library == 1)
  149. {
  150. $tmp_timetj = time();
  151. //$cxtime = 'reviewtime';
  152. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$tmp_timetj '";
  153. $where .= " and state != 217";
  154. }
  155. else if($timetk && $timetj && $library == 2)
  156. {
  157. $cxtime = 'librarytime';
  158. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  159. }
  160. if($shop)
  161. {
  162. $where .= " and shop = '$shop'";
  163. }
  164. if($number)
  165. {
  166. $where .= " and number = '$number'";
  167. }
  168. if($library)
  169. {
  170. $where .= " and library = '$library'";
  171. }
  172. if($waybill)
  173. {
  174. $where .= " and waybill = '$waybill'";
  175. }
  176. if($express)
  177. {
  178. $where .= " and express = '$express'";
  179. }
  180. if($orderinfo)
  181. {
  182. $where .= " and orderinfo = '$orderinfo'";
  183. }
  184. if($type)
  185. {
  186. $where .= " and type = '$type'";
  187. }
  188. if($lowe)
  189. {
  190. $where .= " and shipremarks like '%$lowe%'";
  191. }
  192. if($so)
  193. {
  194. $where .= " and shipremarks like '%$so%'";
  195. }
  196. if($is_jiaji >-1){
  197. $where .= " and is_jiaji = ".$is_jiaji." ";
  198. }
  199. //数据排序
  200. $order_str = $cxtime." desc";
  201. if(empty($page))
  202. {
  203. $start = 0;
  204. $perpage = 1;
  205. }
  206. else
  207. {
  208. $start = ($page - 1)*$perpage;
  209. }
  210. //取得信息列表
  211. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  212. //格式化数据
  213. foreach ($info_list as $key=>$value)
  214. {
  215. $shop = $this->shop->read($value['shop']);
  216. $info_list[$key]['shop'] = $shop['shopname'];
  217. if($value['waybill'] == '0')
  218. {
  219. $info_list[$key]['waybill'] = "";
  220. }
  221. $express = $this->express->read($value['express']);
  222. $info_list[$key]['express'] = $express['servicename'];
  223. $warehouse = $this->warehouse->read($value['type']);
  224. $info_list[$key]['type'] = $warehouse['title'];
  225. if($value['print'] == 1)
  226. {
  227. $info_list[$key]['print'] = '不可打印';
  228. }
  229. else if($value['print'] == 2)
  230. {
  231. $info_list[$key]['print'] = '未打印';
  232. }
  233. else if($value['print'] == 3)
  234. {
  235. $info_list[$key]['print'] = '已打印';
  236. }
  237. if($value['library'] == 1)
  238. {
  239. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  240. }
  241. else if($value['library'] == 2)
  242. {
  243. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  244. }
  245. else if($value['library'] == 3)
  246. {
  247. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  248. }
  249. if($value['librarytime'] == '0')
  250. {
  251. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  252. }
  253. else
  254. {
  255. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  256. }
  257. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  258. }
  259. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  260. //格式化数据
  261. foreach ($info_listtt as $key=>$value)
  262. {
  263. $shop = $this->shop->read($value['shop']);
  264. $info_listtt[$key]['shop'] = $shop['shopname'];
  265. if($value['waybill'] == '0')
  266. {
  267. $info_listtt[$key]['waybill'] = "";
  268. }
  269. $express = $this->express->read($value['express']);
  270. $info_listtt[$key]['express'] = $express['servicename'];
  271. $warehouse = $this->warehouse->read($value['type']);
  272. $info_listtt[$key]['type'] = $warehouse['title'];
  273. if($value['print'] == 1)
  274. {
  275. $info_listtt[$key]['print'] = '不可打印';
  276. }
  277. else if($value['print'] == 2)
  278. {
  279. $info_listtt[$key]['print'] = '未打印';
  280. }
  281. else if($value['print'] == 3)
  282. {
  283. $info_listtt[$key]['print'] = '已打印';
  284. }
  285. if($value['library'] == 1)
  286. {
  287. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  288. }
  289. else if($value['library'] == 2)
  290. {
  291. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  292. }
  293. else if($value['library'] == 3)
  294. {
  295. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  296. }
  297. if($value['librarytime'] == '0')
  298. {
  299. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  300. }
  301. else
  302. {
  303. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  304. }
  305. }
  306. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  307. //格式化数据
  308. foreach ($info_listamz as $key=>$value)
  309. {
  310. $shop = $this->shop->read($value['shop']);
  311. $info_listamz[$key]['shop'] = $shop['shopname'];
  312. if($value['waybill'] == '0')
  313. {
  314. $info_listamz[$key]['waybill'] = "";
  315. }
  316. $express = $this->express->read($value['express']);
  317. $info_listamz[$key]['express'] = $express['servicename'];
  318. $warehouse = $this->warehouse->read($value['type']);
  319. $info_listamz[$key]['type'] = $warehouse['title'];
  320. if($value['print'] == 1)
  321. {
  322. $info_listamz[$key]['print'] = '不可打印';
  323. }
  324. else if($value['print'] == 2)
  325. {
  326. $info_listamz[$key]['print'] = '未打印';
  327. }
  328. else if($value['print'] == 3)
  329. {
  330. $info_listamz[$key]['print'] = '已打印';
  331. }
  332. if($value['library'] == 1)
  333. {
  334. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  335. }
  336. else if($value['library'] == 2)
  337. {
  338. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  339. }
  340. else if($value['library'] == 3)
  341. {
  342. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  343. }
  344. if($value['librarytime'] == '0')
  345. {
  346. $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  347. }
  348. else
  349. {
  350. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  351. }
  352. }
  353. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  354. //格式化数据
  355. foreach ($info_listxw as $key=>$value)
  356. {
  357. $shop = $this->shop->read($value['shop']);
  358. $info_listxw[$key]['shop'] = $shop['shopname'];
  359. if($value['waybill'] == '0')
  360. {
  361. $info_listxw[$key]['waybill'] = "";
  362. }
  363. $express = $this->express->read($value['express']);
  364. $info_listxw[$key]['express'] = $express['servicename'];
  365. $warehouse = $this->warehouse->read($value['type']);
  366. $info_listxw[$key]['type'] = $warehouse['title'];
  367. if($value['print'] == 1)
  368. {
  369. $info_listxw[$key]['print'] = '不可打印';
  370. }
  371. else if($value['print'] == 2)
  372. {
  373. $info_listxw[$key]['print'] = '未打印';
  374. }
  375. else if($value['print'] == 3)
  376. {
  377. $info_listxw[$key]['print'] = '已打印';
  378. }
  379. if($value['library'] == 1)
  380. {
  381. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  382. }
  383. else if($value['library'] == 2)
  384. {
  385. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  386. }
  387. else if($value['library'] == 3)
  388. {
  389. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  390. }
  391. if($value['librarytime'] == '0')
  392. {
  393. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  394. }
  395. else
  396. {
  397. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  398. }
  399. }
  400. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  401. //格式化数据
  402. foreach ($info_listsmt as $key=>$value)
  403. {
  404. $shop = $this->shop->read($value['shop']);
  405. $info_listsmt[$key]['shop'] = $shop['shopname'];
  406. if($value['waybill'] == '0')
  407. {
  408. $info_listsmt[$key]['waybill'] = "";
  409. }
  410. $express = $this->express->read($value['express']);
  411. $info_listsmt[$key]['express'] = $express['servicename'];
  412. $warehouse = $this->warehouse->read($value['type']);
  413. $info_listsmt[$key]['type'] = $warehouse['title'];
  414. if($value['print'] == 1)
  415. {
  416. $info_listsmt[$key]['print'] = '不可打印';
  417. }
  418. else if($value['print'] == 2)
  419. {
  420. $info_listsmt[$key]['print'] = '未打印';
  421. }
  422. else if($value['print'] == 3)
  423. {
  424. $info_listsmt[$key]['print'] = '已打印';
  425. }
  426. if($value['library'] == 1)
  427. {
  428. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  429. }
  430. else if($value['library'] == 2)
  431. {
  432. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  433. }
  434. else if($value['library'] == 3)
  435. {
  436. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  437. }
  438. if($value['librarytime'] == '0')
  439. {
  440. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  441. }
  442. else
  443. {
  444. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  445. }
  446. }
  447. $total = $this->fullorder->find_count($where);
  448. $total += $this->fullordertt->find_count($where);
  449. $total += $this->fullorderamz->find_count($where);
  450. $total += $this->fullorderxw->find_count($where);
  451. $total += $this->fullordersmt->find_count($where);
  452. $pagenum = ceil($total/$perpage);
  453. $over = $total-($start+$perpage);
  454. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt)));
  455. echo json_encode($rows);exit;
  456. }
  457. if(isset($_SESSION['api']))
  458. {
  459. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  460. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  461. $this->data['wlshop'] = $wlshop;
  462. $this->data['warehouse'] = $warehouse;
  463. }
  464. $this->data['xw'] = $xw;
  465. $this->_Template('systemfout',$this->data);
  466. }
  467. public function _indexmc()
  468. {
  469. $post = $this->input->post(NULL, TRUE);
  470. $xw = '';
  471. if(isset($_SESSION['api']))
  472. {
  473. $user = $this->user->get_api($_SESSION['api']);
  474. $usp = $user;
  475. $fgshop = "";$sid = "";$wid="";$wtype="";
  476. $usersp = explode('|',trim($user['shop'],'|'));
  477. $userwh = explode('|',trim($user['warehouse'],'|'));
  478. foreach ($usersp as $value)
  479. {
  480. $fgshop .= " shop = ".$value." or";
  481. $sid .= " id = ".$value." or";
  482. }
  483. foreach ($userwh as $value)
  484. {
  485. $wid .= " id = ".$value." or";
  486. $wtype .= " type = ".$value." or";
  487. }
  488. if($user['userid'] == 'xw')
  489. {
  490. $xw = 1;
  491. }
  492. }
  493. if(isset($_SESSION['api']))
  494. {
  495. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  496. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  497. $this->data['wlshop'] = $wlshop;
  498. $this->data['warehouse'] = $warehouse;
  499. }else{
  500. //未登录不允许访问
  501. header("location:/");
  502. exit;
  503. }
  504. $this->data['xw'] = $xw;
  505. $this->_Template('systemfoutmc',$this->data);
  506. }
  507. public function _fout()
  508. {
  509. $post = $this->input->post(NULL, TRUE);
  510. if(isset($post['order']))
  511. {
  512. $time = time();
  513. $order = $this->input->post('order',true);
  514. $weight = $this->input->post('weight',true);
  515. if(!isset($weight))//测试没问题后可以删
  516. {
  517. $weight = '';
  518. }
  519. if(substr($order,0,3) == '788' && substr($order,-4,4) == '0430')//Fedex联邦
  520. {
  521. $order = substr($order,0,12);
  522. }
  523. if(strlen($order) == '34')//联邦杭州超长运单截取
  524. {
  525. $str = substr($order, 0,3);
  526. if($str == "420"){
  527. $order = substr($order,12);
  528. }else{
  529. $order = substr($order,22,12);
  530. }
  531. }
  532. if(!$order)
  533. {
  534. echo json_encode(array('msg'=>'出库信息不能为空!','success'=>false));exit;
  535. }
  536. if(strlen($order) == 30)
  537. {
  538. $order = substr($order, 8);
  539. }
  540. $fullorder_name = 'fullorder';$outtype = 1;
  541. $y = $this->fullorder->get_waybill($order);
  542. // $this->logic_ding->sendToDing("排查五次数据的原有".$order);
  543. // $this->logic_ding->sendToDing("排查五次数据的订单".json_encode($y));
  544. if(!$y)
  545. {
  546. $y = $this->fullorder->get_number($order);
  547. $outtype = 2;
  548. // $this->logic_ding->sendToDing("排查五次数据的原有".$order);
  549. // $this->logic_ding->sendToDing("排查五次数据的订单".json_encode($y));
  550. if(!$y)
  551. {
  552. $fullorder_name = 'fullordersmt';$outtype = 1;
  553. $y = $this->fullordersmt->get_waybill($order);
  554. if(!$y)
  555. {
  556. $y = $this->fullordersmt->get_number($order);
  557. $outtype = 2;
  558. if(!$y)
  559. {
  560. $fullorder_name = 'fullordertt';$outtype = 1;
  561. $y = $this->fullordertt->get_waybill($order);
  562. if(!$y)
  563. {
  564. $y = $this->fullordertt->get_number($order);
  565. $outtype = 2;
  566. if(!$y)
  567. {
  568. $fullorder_name = 'fullorderamz';$outtype = 1;
  569. $y = $this->fullorderamz->get_waybill($order);
  570. if(!$y)
  571. {
  572. $y = $this->fullorderamz->get_number($order);
  573. $outtype = 2;
  574. if(!$y){
  575. $fullorder_name = 'fullorderxw';$outtype = 1;
  576. $y = $this->fullorderxw->get_waybill($order);
  577. if(!$y)
  578. {
  579. $y = $this->fullorderxw->get_number($order);
  580. $outtype = 2;
  581. if(!$y)
  582. {
  583. $this->logic_ding->sendToDing("排查五次数据的原有".$order);
  584. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  585. }
  586. }
  587. }
  588. }
  589. }
  590. }
  591. }
  592. }
  593. }
  594. }
  595. if($y['mergeid'] == '1')
  596. {
  597. $y = $this->$fullorder_name->read($y['merge']);
  598. }
  599. //云尚-FedEx普货专线 如果出库时打印的快递面单超过6天,不允许出库
  600. // if($y['express'] == 75 ){
  601. // $printtime = $y['printtime'];
  602. // $set_time = 24 * 60 * 60 * 6;
  603. // $time = time();
  604. // if(($time - $set_time) > $printtime){
  605. // //允许出库状态
  606. // if($y['libraryconfirm'] == 2){
  607. // echo json_encode(array('msg'=>"该单超时,请重新打印后再出库。".$y['number'],'success'=>false));exit;
  608. // }else{
  609. // echo json_encode(array('msg'=>"该单超时且禁止出库,请联系梦体做后续处理!".$y['number'],'success'=>false));exit;
  610. // }
  611. // }
  612. // }
  613. // 66 云途(欧洲) 67 云途(欧洲)-带保险 如果是欧洲云途 需要检擦出库时间是否超过15天
  614. if(in_array($y['express'],[66,67,82])){
  615. if((time() - $y['printtime']) >= (14*24*3600)){
  616. echo json_encode(array('msg'=>'运单超时!请联系梦体处理!','success'=>false));exit;
  617. }
  618. }
  619. // 50 惠程-联邦-9610 93 惠程-联邦-不报关 超过90小时不允许出库
  620. if(in_array($y['express'],[50,93])){
  621. if((time() - $y['printtime']) >= (90*3600)){
  622. echo json_encode(array('msg'=>'该运单超时,请联系梦体处理!','success'=>false));exit;
  623. }
  624. }
  625. // 78 dpd英国 和 79dpd欧盟
  626. if(in_array($y['express'],[78,79,84,92])){
  627. $r = $this->check->checkOverdue($y['name'],$y['number'],$y['address']);
  628. if(!$r){
  629. echo json_encode(array('msg'=>'同一个客户3天内发货超过2包,不可出库!请联系店员做申报信息修改!'.$y['name']."-".$y['number']."-".$r*1,'success'=>false));exit;
  630. }
  631. }
  632. $express = $this->express->read($y['express']);
  633. if($y['state'] == 216 && $fullorder_name == 'fullordersmt')
  634. {
  635. $y['librarynot'] = '客户已取消!';
  636. }
  637. if($y['print'] != 3 || $y['libraryconfirm'] == 1 || $y['state'] == 214 || $y['state'] == 217 || $y['state'] == 283 || $y['state'] == 206 || $y['state'] == 205 || $y['state'] == 204 || $y['state'] == 210 || $y['state'] == 211 || $y['state'] == 212 || ($y['state'] == 216 && $fullorder_name == 'fullordersmt'))//独立站216先关了
  638. {
  639. echo json_encode(array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false));exit;
  640. }
  641. if($y['library'] > 1)
  642. {
  643. echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
  644. }
  645. if($express['out'] != 3)
  646. {
  647. if($express['out'] != $outtype)
  648. {
  649. $smlx = ($express['out']=='1')?'运单':'发货单';
  650. echo json_encode(array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false));exit;
  651. }
  652. }
  653. if($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1')
  654. {
  655. // $y['waybill'] = trim($y['waybill'],' ');
  656. // if(strlen($y['waybill']) == 12 && $y['express'] != 24 && $y['express'] != 31 && $y['express'] != 38 && $y['express'] != 41 && $y['express'] != 6 && $y['express'] != 43 && $y['express'] != 48 && $y['express'] != 50 && $y['express'] != 51 && $y['express'] != 63 && $y['express'] != 70 && $y['express'] != 71 && $y['express'] != 73 && $y['express'] != 74 && $y['express'] != 75 && $y['express'] != 78 && $y['express'] != 79 && $y['express'] != 83 && $y['express'] != 85)
  657. // {
  658. // echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-1','success'=>false));exit;
  659. // }
  660. // else if(strlen($y['waybill']) == 10 && $y['express'] != 1 && $y['express'] != 37 && $y['express'] != 49 && $y['express'] != 42 && $y['express'] != 69 && $y['express'] != 78 && $y['express'] != 79 && $y['express'] != 83 && $y['express'] != 85)
  661. // {
  662. // echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-2','success'=>false));exit;
  663. // }
  664. // else if(strlen($y['waybill']) == 18 && $y['express'] != 3 && $y['express'] != 66 && $y['express'] != 67 && $y['express'] != 72 && $y['express'] != 2 && $y['express'] != 82 && $y['express'] != 83 && $y['express'] != 85)
  665. // {
  666. // echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-3','success'=>false));exit;
  667. // }
  668. // else if(strlen($y['waybill']) == 16 && $y['express'] != 76 && $y['express'] != 77 && $y['express'] != 80 && $y['express'] != 83 && $y['express'] != 85)
  669. // {
  670. // echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-4','success'=>false));exit;
  671. // }
  672. $r = $this->logic_express->ydCheckById($y['waybill'],$y['express']);
  673. if(!$r){
  674. echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'],'success'=>false));exit;
  675. }
  676. }
  677. if(stripos($weight,',') !== false){
  678. $tmp_arr = explode(",",$weight);
  679. $weight = end($tmp_arr);
  680. $numweight = (float)$weight;
  681. $weight = $numweight."kg";
  682. }
  683. $numweight = str_replace('kg','',$weight);
  684. // if(($y['express'] == '24' || $y['express'] == '3' || $y['express'] == '28' || $y['express'] == '33' || $y['express'] == '42') && $y['type'] != 6)//杭州除外
  685. // {
  686. // if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  687. // {
  688. // echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  689. // }
  690. // $yzweight = explode('.',$numweight);
  691. // if($yzweight[0] == '')
  692. // {
  693. // echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  694. // }
  695. // if($numweight < ($y['jweight']/1000))
  696. // {
  697. // echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
  698. // }
  699. // if($numweight -($y['jweight']/1000) > 0.9 && $y['number'] != 'QQS-30401-002')
  700. // {
  701. // echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会或梦体处理!','success'=>false));exit;
  702. // }
  703. // if($numweight > '0.98' && $y['express'] == '3')
  704. // {
  705. // echo json_encode(array('msg'=>'UPS大于0.98公斤需要拆包!','success'=>false));exit;
  706. // }
  707. // if($numweight > '2' && $y['express'] == '37')
  708. // {
  709. // echo json_encode(array('msg'=>'杭州DHL大于2公斤需要联系店员!','success'=>false));exit;
  710. // }
  711. // if($numweight >= '10' && ($y['express'] == '24' || $y['express'] == '31'))
  712. // {
  713. // echo json_encode(array('msg'=>'联邦不能大于10公斤!','success'=>false));exit;
  714. // }
  715. // }
  716. //根据要求 USPS-USA 2 FEDEX-US2 63 USPS-US2 64 这三个快递方式除外的所有快递都需要称重再发货 或者说是【国内发货】的都需要称重
  717. //还有翔文仓库的 不执行
  718. //源代码是
  719. //所有快递必须称重
  720. //所有快递必须称重 翔文除外
  721. //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']."-".$weight."[".$numweight."]");
  722. if(!in_array($y['express'],[2,8,39,43,44,45,47,48,49,55,61,63,64,65,74,81,83,85])){
  723. if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
  724. {
  725. echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
  726. }
  727. $yzweight = explode('.',$numweight);
  728. if($yzweight[0] == '')
  729. {
  730. echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  731. }
  732. if(empty($numweight)){
  733. echo json_encode(array('msg'=>'此单需要称重2!','success'=>false));exit;
  734. }
  735. //$this->logic_ding->sendToDing("检测订单---------------------标记需要认证的东西".$y['number']);
  736. }
  737. //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']);
  738. $express_info = $this->express->read($y['express']);
  739. if(empty($express_info)){
  740. echo json_encode(array('msg'=>'该快递信息异常,请联系技术!','success'=>false));exit;
  741. }
  742. $weight_limit = $express_info['weight_limit']*1;
  743. if($weight_limit > 0 && $y['type'] != 5){
  744. $yzweight = explode('.',$numweight);
  745. if($yzweight[0] == '')
  746. {
  747. echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
  748. }
  749. if($numweight < ($y['jweight']/1000)){
  750. echo json_encode(array('msg'=>'重量小于净重,请重新称重!','success'=>false));exit;
  751. }
  752. //Fedex(杭州),UPS,DHL官方-美国 需要判断实际重量和净重差 其他快递不需要
  753. if(in_array($y['express'],[3,24,42])){
  754. //规定实际重量不允许超过 净重为1kg
  755. if($numweight -($y['jweight']/1000) > 1 )
  756. {
  757. echo json_encode(array('msg'=>'称重重量和净重相差过大,请找成会处理!','success'=>false));exit;
  758. }
  759. }
  760. if($weight_limit < $numweight){
  761. echo json_encode(array('msg'=>$express['servicename'].'大于'.$weight_limit.'公斤需要拆包!','success'=>false));exit;
  762. }
  763. }
  764. if(((time() - $y['printtime']) > (15*24*3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6)//杭州店铺除外
  765. {
  766. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  767. }
  768. if((time() - $y['printtime']) > (6*24*3600) && $y['express'] == '3' && $y['type'] != 6)//杭州店铺除外
  769. {
  770. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  771. echo json_encode(array('msg'=>'此运单过期无法出库,请联系成会处理!','success'=>false));exit;
  772. }
  773. if((time() - $y['printtime']) > (7*24*3600) && $y['express'] == '37' && $y['type'] != 6)//杭州店铺除外
  774. {
  775. //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
  776. }
  777. $this->db->trans_begin();
  778. $warehouse = $this->warehouse->read($y['type']);
  779. $bdck = $warehouse['bdck'];
  780. if($warehouse['zd'] == '1')
  781. {
  782. if($warehouse['bdck'] == '')
  783. {
  784. $this->db->trans_rollback();
  785. echo json_encode(array('msg'=>'仓库设置错误!','success'=>false));exit;
  786. }
  787. $wh = $this->_fout_db($y,$warehouse,$bdck);
  788. if($wh['fh'] == 2)
  789. {
  790. $kcyz = $this->ck->get_kc($y['state'],$warehouse,$y['shop'],$y['number'],$y['whlabel'],$y['fpdata']);
  791. if($kcyz['t'] == '0')
  792. {
  793. if($kcyz['fpdata'] != '')
  794. {
  795. $x['whlabel'] = $kcyz['whlabel'];
  796. $x['fpdata'] = $kcyz['fpdata'];
  797. $y['whlabel'] = $x['whlabel'];
  798. $this->$fullorder_name->save($x,$y['id']);
  799. }
  800. }
  801. $wh = $this->_fout_db($y,$warehouse,$bdck);
  802. if($wh['fh'] == 2)
  803. {
  804. $this->db->trans_rollback();
  805. echo json_encode(array('msg'=>'库存占用量与实际出库量不符!','success'=>false));exit;
  806. }
  807. }
  808. foreach ($wh['sj'] as $v)
  809. {
  810. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  811. }
  812. }
  813. /**
  814. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') === false)
  815. {
  816. $whlabel = $this->whlabel->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  817. $cpsl = 0;
  818. $pp = explode('|',trim($y['whlabel'],'|'));
  819. foreach ($pp as $va)
  820. {
  821. $num = explode('-',$va);
  822. $cpsl += $num[1];
  823. }
  824. if(count($whlabel) != $cpsl)
  825. {
  826. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  827. }
  828. foreach ($whlabel as $v)
  829. {
  830. $this->whlabel->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
  831. }
  832. }
  833. if($warehouse['zd'] == '1' && stripos($y['whlabel'],'z|') !== false)
  834. {
  835. $wh = $this->specialstock->find_all("zd = '".$y['number']."' and state = '0'");
  836. $cpsl = 0;
  837. $pp = explode('|',trim($y['whlabel'],'|'));
  838. foreach ($pp as $va)
  839. {
  840. $num = explode('-',$va);
  841. if(stripos($num[2],'z') !== false)//如果是特殊库存
  842. {
  843. $cpsl += $num[1];
  844. }
  845. }
  846. if(count($wh) != $cpsl)
  847. {
  848. echo json_encode(array('msg'=>'库存占用量与实际出库量不符','success'=>false));exit;
  849. }
  850. foreach ($wh as $v)
  851. {
  852. if(!$this->specialstock->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']))
  853. {
  854. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  855. }
  856. }
  857. }
  858. **/
  859. /**
  860. if($y['dbapi'] == 99 && $y['scapi'] == 99)
  861. {
  862. $d = $this->apiyy->get_chd($y);
  863. if($d['Data'][0]['m_isSucess'] != 1)
  864. {
  865. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  866. }
  867. }
  868. $systemtransfer = $this->systemtransfer->find_all("number = '".$y['number']."'");
  869. if(isset($systemtransfer[0]))
  870. {
  871. foreach ($systemtransfer as $v)
  872. {
  873. if($v['dbapi'] != 99)
  874. {
  875. echo json_encode(array('msg'=>'此订单货物:'.$v['pm'].'没有成功扫布标入库,无法出库!','success'=>false));exit;
  876. }
  877. }
  878. $y['ts'] = count($systemtransfer);
  879. $d = $this->apiyy->get_chd($y);
  880. if($d['Data'][0]['m_isSucess'] != 1)
  881. {
  882. echo json_encode(array('msg'=>'用友出库失败:'.$d['Data'][0]['m_errorMsg'],'success'=>false));exit;
  883. }
  884. }
  885. **/
  886. $shop = $this->shop->read($y['shop']);
  887. if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
  888. {
  889. $type = $this->typeclass->read($shop['type']);
  890. $y['shoptype'] = $type['title'];
  891. $y['weight'] = $weight;
  892. $d = $this->dhl->get_data_9610($y);
  893. if($d != 1)
  894. {
  895. $this->db->trans_rollback();
  896. $this->allocation->insert(array('order'=>1,'title'=>$y['number'],'content'=>$d));
  897. echo json_encode(array('msg'=>'9610失败,'.$d,'success'=>false));exit;
  898. }
  899. $this->allocation->insert(array('order'=>9610,'title'=>$y['number']));
  900. }
  901. if($fullorder_name == 'fullordersmt')
  902. {
  903. $stt = ($y['waybill']!='')?209:$y['state'];
  904. $post = array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  905. /**
  906. if($this->$fullorder_name->save(array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  907. {
  908. echo json_encode(array('success'=>true));exit;
  909. }
  910. else
  911. {
  912. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  913. }
  914. **/
  915. }
  916. else if(($fullorder_name == 'fullordertt' || $fullorder_name == 'fullorderxw' || $fullorder_name == 'fullorder' || $fullorder_name = 'fullorderamz') && $y['source'] == 1)
  917. {
  918. /**
  919. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  920. {
  921. echo json_encode(array('success'=>true));exit;
  922. }
  923. else
  924. {
  925. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  926. }
  927. **/
  928. $post = array('library'=>2,'state'=>216,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  929. }
  930. else
  931. {
  932. /**
  933. if($this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']))
  934. {
  935. echo json_encode(array('success'=>true));exit;
  936. }
  937. else
  938. {
  939. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  940. }
  941. **/
  942. $post = array('library'=>2,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
  943. }
  944. /**
  945. if($fullorder_name == 'fullorder')
  946. {
  947. $orderinfo = preg_replace('/^' . preg_quote($y['shop'], '/') . '/', '', $y['orderinfo']);
  948. $post['incrementId'] = $orderinfo;
  949. $post['trackingNumber'] = $y['waybill'];
  950. $ex = $this->express->read($y['express']);
  951. $post['carrier'] = $ex['iscode'];
  952. $url = 'https://www.romandhair.com/applepay/payment/addTrack';
  953. $ch = curl_init();
  954. curl_setopt($ch,CURLOPT_URL,$url);
  955. curl_setopt($ch, CURLOPT_POST, 1);
  956. curl_setopt($ch, CURLOPT_HEADER, 0);
  957. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  958. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  959. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  960. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  961. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  962. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
  963. $res = curl_exec($ch);
  964. curl_close($ch);
  965. $res = json_decode($res,true);
  966. if($res['success'] == 0)
  967. {
  968. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'cw'=>$res['msg']));//失败
  969. }
  970. else
  971. {
  972. $this->fullorderpaypal->insert(array('orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'time'=>$time,'type'=>1));
  973. }
  974. }
  975. **/
  976. //开始录入执行u9队列的数据
  977. $queue_u9_list = [];
  978. $queue_u9_list[] = [
  979. 'platform'=>$fullorder_name,
  980. 'warehouse'=>$y['type'],
  981. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  982. 'order_no'=>$y['number'],
  983. 'status'=>0,
  984. 'create_time'=>time(),
  985. 'update_time'=>time(),
  986. ];
  987. //将要执行的队列数据添加进去
  988. foreach($queue_u9_list as $item){
  989. if($item['platform'] != 'fullorderxw'){
  990. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  991. // $this->zzquque_u9->insert($item);
  992. // }
  993. if( !in_array($item['warehouse'],[5,7,8,9]) ){
  994. $this->zzquque_u9->insert($item);
  995. }
  996. }
  997. }
  998. //$this->logic_ding->sendToDing("u9小单队列监听数据".json_encode($queue_u9_list,JSON_UNESCAPED_UNICODE));
  999. if($outtype == 2 && $y['printnumber'] > 1)
  1000. {
  1001. $p = json_encode($post);
  1002. $this->db->trans_rollback();
  1003. echo json_encode(array('msg'=>'该单共打印过'.$y['printnumber'].'次,请注意核对当前发货单是否是最新发货单!','outnumber'=>$y['id'],'post'=>$p,'fullorder_name'=>$fullorder_name,'success'=>false));exit;
  1004. }
  1005. $this->$fullorder_name->save($post,$y['id']);
  1006. //检测单子是否是扫不出库单子重新出库 如果是 就更正
  1007. $outerrors_info = $this->outerrors->find("number = '".$y['number']."'");
  1008. if(!empty($outerrors_info)){
  1009. $this->outerrors->save(array('order_status'=>1,'library_time'=>$time),$outerrors_info['id']);
  1010. }
  1011. $this->logic_ding->sendJobs('order_out',['number'=>$y['number']],0,'');
  1012. //合并订单自动发货
  1013. $hb = $this->$fullorder_name->find_all("merge = '".$y['id']."' and id != '".$y['id']."'");
  1014. $post['waybill'] = $y['waybill'];
  1015. $post['express'] = $y['express'];
  1016. $post['printtype'] = $y['printtype'];
  1017. $post['ioss'] = $y['ioss'];
  1018. $post['review'] = 6;
  1019. $post['bx'] = $y['bx'];
  1020. $post['qm'] = $y['qm'];
  1021. $post['js'] = $y['js'];
  1022. //$post['state'] = 216;
  1023. $post['print'] = $y['print'];
  1024. $post['printtime'] = $y['printtime'];
  1025. $post['library'] = 2;
  1026. $post['librarytime'] = $time;
  1027. $post['libraryconfirm'] = 2;
  1028. $post['librarynot'] = '';
  1029. foreach ($hb as $v)
  1030. {
  1031. $post['state'] = $v['state'];
  1032. $vshop = $this->shop->read($v['shop']);
  1033. $vwarehouse = $this->warehouse->read($v['type']);
  1034. $this->$fullorder_name->save($post,$v['id']);
  1035. //2025年1月25日发现翔文合并订单发现此问题
  1036. if($warehouse['zd'] == '1'){
  1037. $wh = $this->_fout_db($v,$warehouse,$bdck);
  1038. foreach ($wh['sj'] as $vv)
  1039. {
  1040. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
  1041. }
  1042. }
  1043. }
  1044. if ($this->db->trans_status() === TRUE)
  1045. {
  1046. $this->db->trans_commit();
  1047. echo json_encode(array('success'=>true));
  1048. }
  1049. else
  1050. {
  1051. $this->db->trans_rollback();
  1052. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  1053. }
  1054. }
  1055. }
  1056. //之所以用订单已占的库存,就循环更新 为什么不用全部检索是因为牵扯到可能是工厂有可能直接生产后 带到成品库 不入成品库 可能会直接发走,所以只检索已占库存的订单 然后更新
  1057. public function _outnumber()//对比占单是否正确
  1058. {
  1059. $post = $this->input->post(NULL, TRUE);
  1060. if(isset($post['outnumber']))
  1061. {
  1062. $post = $this->input->post('post',true);
  1063. $fullorder_name = $this->input->post('fullorder_name',true);
  1064. $outnumber = $this->input->post('outnumber',true);
  1065. $post = json_decode($post,true);
  1066. $y = $this->$fullorder_name->read($outnumber);
  1067. if(empty($y)){
  1068. echo json_encode(array('msg'=>'订单异常不能出库','success'=>false));exit;
  1069. }
  1070. $warehouse = $this->warehouse->read($y['type']);
  1071. if(empty($warehouse)){
  1072. echo json_encode(array('msg'=>'仓库异常不能出库','success'=>false));exit;
  1073. }
  1074. if($y['library']== 2){
  1075. echo json_encode(array('msg'=>'订单已出库,请勿重复出库','success'=>false));exit;
  1076. }
  1077. if($y['library']== 3){
  1078. echo json_encode(array('msg'=>'订单已退库,请勿重复出库','success'=>false));exit;
  1079. }
  1080. $bdck = $warehouse['bdck'];
  1081. if(!empty($bdck)){
  1082. // $warehouse = $this->warehouse->read($y['type']);
  1083. $list = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  1084. $this->db->trans_begin();
  1085. foreach ($list as $v)
  1086. {
  1087. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$post['librarytime'],'time'=>$post['librarytime']),$v['id']);
  1088. }
  1089. $this->$fullorder_name->save($post,$y['id']);
  1090. //检测单子是否是扫不出库单子重新出库 如果是 就更正
  1091. $outerrors_info = $this->outerrors->find("number = '".$y['number']."'");
  1092. if(!empty($outerrors_info)){
  1093. $this->outerrors->save(array('order_status'=>1,'library_time'=>$post['librarytime']),$outerrors_info['id']);
  1094. }
  1095. //需要添加上合并订单的订单信息更新
  1096. $hb = $this->$fullorder_name->find_all("merge = '".$y['id']."' and id != '".$y['id']."'");
  1097. $save_arr = [];
  1098. $save_arr['waybill'] = $y['waybill'];
  1099. $save_arr['express'] = $y['express'];
  1100. $save_arr['printtype'] = $y['printtype'];
  1101. $save_arr['ioss'] = $y['ioss'];
  1102. $save_arr['review'] = 6;
  1103. $save_arr['bx'] = $y['bx'];
  1104. $save_arr['qm'] = $y['qm'];
  1105. $save_arr['js'] = $y['js'];
  1106. $post['state'] = $y['state'];
  1107. $save_arr['print'] = $y['print'];
  1108. $save_arr['printtime'] = $y['printtime'];
  1109. $save_arr['library'] = 2;
  1110. $save_arr['librarytime'] = $post['librarytime'];
  1111. $save_arr['libraryconfirm'] = 2;
  1112. $save_arr['librarynot'] = '';
  1113. foreach($hb as $v){
  1114. $this->$fullorder_name->save($save_arr,$v['id']);
  1115. }
  1116. if ($this->db->trans_status() === TRUE)
  1117. {
  1118. $this->db->trans_commit();
  1119. if($fullorder_name != 'fullorderxw'){
  1120. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  1121. // $this->zzquque_u9->insert($item);
  1122. // }
  1123. $y = $this->$fullorder_name->read($outnumber);
  1124. if( !in_array($y['type'],[5,7,8,9]) ){
  1125. $data = [
  1126. 'platform'=>$fullorder_name,
  1127. 'warehouse'=>$y['type'],
  1128. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  1129. 'order_no'=>$y['number'],
  1130. 'status'=>0,
  1131. 'create_time'=>time(),
  1132. 'update_time'=>time(),
  1133. ];
  1134. $this->zzquque_u9->insert($data);
  1135. }
  1136. }
  1137. echo json_encode(array('success'=>true));
  1138. die;
  1139. }
  1140. else
  1141. {
  1142. $this->db->trans_rollback();
  1143. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  1144. die;
  1145. }
  1146. }else{
  1147. $this->$fullorder_name->save($post,$y['id']);
  1148. //检测单子是否是扫不出库单子重新出库 如果是 就更正
  1149. $outerrors_info = $this->outerrors->find("number = '".$y['number']."'");
  1150. if(!empty($outerrors_info)){
  1151. $this->outerrors->save(array('order_status'=>1,'library_time'=>$post['librarytime']),$outerrors_info['id']);
  1152. }
  1153. //需要添加上合并订单的订单信息更新
  1154. $hb = $this->$fullorder_name->find_all("merge = '".$y['id']."' and id != '".$y['id']."'");
  1155. $save_arr = [];
  1156. $save_arr['waybill'] = $y['waybill'];
  1157. $save_arr['express'] = $y['express'];
  1158. $save_arr['printtype'] = $y['printtype'];
  1159. $save_arr['ioss'] = $y['ioss'];
  1160. $save_arr['review'] = 6;
  1161. $save_arr['bx'] = $y['bx'];
  1162. $save_arr['qm'] = $y['qm'];
  1163. $save_arr['js'] = $y['js'];
  1164. $post['state'] = $y['state'];
  1165. $save_arr['print'] = $y['print'];
  1166. $save_arr['printtime'] = $y['printtime'];
  1167. $save_arr['library'] = 2;
  1168. $save_arr['librarytime'] = $post['librarytime'];
  1169. $save_arr['libraryconfirm'] = 2;
  1170. $save_arr['librarynot'] = '';
  1171. foreach($hb as $v){
  1172. $this->$fullorder_name->save($save_arr,$v['id']);
  1173. }
  1174. if($fullorder_name != 'fullorderxw'){
  1175. // if(($item['warehouse'] != 5) || ($item['warehouse'] != 7) || ($item['warehouse'] != 8) || ($item['warehouse'] != 9) ){
  1176. // $this->zzquque_u9->insert($item);
  1177. // }
  1178. $y = $this->$fullorder_name->read($outnumber);
  1179. if( !in_array($y['type'],[5,7,8,9]) ){
  1180. $data = [
  1181. 'platform'=>$fullorder_name,
  1182. 'warehouse'=>$y['type'],
  1183. 'type'=>($y['type'] == 5)?11:10, //5代表美仓
  1184. 'order_no'=>$y['number'],
  1185. 'status'=>0,
  1186. 'create_time'=>time(),
  1187. 'update_time'=>time(),
  1188. ];
  1189. $this->zzquque_u9->insert($data);
  1190. }
  1191. }
  1192. echo json_encode(array('success'=>true));
  1193. die;
  1194. }
  1195. }else{
  1196. echo json_encode(array('msg'=>'传参异常,请重试','success'=>false));
  1197. die;
  1198. }
  1199. }
  1200. public function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
  1201. {
  1202. $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  1203. $cpsl = 0;
  1204. $pp = explode('|',trim($y['whlabel'],'|'));
  1205. foreach ($pp as $va)
  1206. {
  1207. $num = explode('-',$va);
  1208. if(isset($num[2]))
  1209. {
  1210. if(stripos($num[2],$warehouse['hz']) !== false)
  1211. {
  1212. $cpsl += $num[1];
  1213. }
  1214. }
  1215. }
  1216. if(count($wh) == $cpsl)
  1217. {
  1218. return array('fh'=>1,'sj'=>$wh);
  1219. }
  1220. else
  1221. {
  1222. return array('fh'=>2);
  1223. }
  1224. }
  1225. public function _fedexhz()
  1226. {
  1227. $post = $this->input->post(NULL, TRUE);
  1228. if(isset($post['id']))
  1229. {
  1230. $id = $this->input->post('id',true);
  1231. $fullorder_name = $this->input->post('name',true);
  1232. $express = $this->input->post('express',true);
  1233. $express = $this->express->read($express);
  1234. $fullorder = $this->$fullorder_name->read($id);
  1235. if($fullorder['type'] == '2')
  1236. {
  1237. $fullorder['type'] = 1;
  1238. }
  1239. $time = time();
  1240. $fullorder = $this->_text($fullorder);//获取所需信息
  1241. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  1242. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  1243. $time = time();
  1244. if($express['printcode'] == "FEDEXGF")
  1245. {
  1246. //$barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  1247. //升级的api
  1248. $barcode = $this->fedexv1->get_data($fullorder);//获取联邦快递信息
  1249. if($barcode['x'] == 1)
  1250. {
  1251. $bctime = date('Ymd',$time);
  1252. $Hwaybill = $barcode['waybill'];
  1253. // $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  1254. // $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1255. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1256. $Hfp = $this->_pdfurl($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1257. if(isset($barcode['label']) && isset($Hwaybill))
  1258. {
  1259. if($fullorder['waybill'] != "")
  1260. {
  1261. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1262. }
  1263. else
  1264. {
  1265. $oldwaybill = $fullorder['oldwaybill'];
  1266. }
  1267. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1268. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1269. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  1270. {
  1271. $warehouse = $this->warehouse->read($fullorder['type']);
  1272. $text = array();
  1273. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  1274. $text['number'] = $fullorder['number'];
  1275. $text['mode'] = '95';
  1276. $text['pdfnum'] = 1;
  1277. $rows = array('text'=>$text);
  1278. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1279. }
  1280. else
  1281. {
  1282. echo json_encode(array($fullorder['number'].'msg'=>'打印错误,请联系店员','cw'=>'写入数据库错误','success'=>false));exit;
  1283. }
  1284. }
  1285. }
  1286. else
  1287. {
  1288. echo json_encode(array('msg'=>'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1289. }
  1290. }
  1291. else if($express['printcode'] == "UPS")//接口UPS暂时不打
  1292. {
  1293. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会处理','success'=>false));exit;
  1294. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  1295. if($barcode['x'] == 1)
  1296. {
  1297. $bctime = date('Ymd',$time);
  1298. $Hwaybill = $barcode['waybill'];
  1299. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1300. if(isset($barcode['label']) && isset($Hwaybill))
  1301. {
  1302. if($fullorder['waybill'] != "")
  1303. {
  1304. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1305. }
  1306. else
  1307. {
  1308. $oldwaybill = $fullorder['oldwaybill'];
  1309. }
  1310. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1311. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1312. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1313. {
  1314. $type = 1;
  1315. $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder,'id'=>$fullorder['id'],'pt'=>$fullorder_name);
  1316. }
  1317. }
  1318. }
  1319. else
  1320. {
  1321. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1322. }
  1323. }
  1324. else if($express['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  1325. {
  1326. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  1327. if($barcode['c'] == 1)
  1328. {
  1329. $bctime = date('Ymd',$time);
  1330. $Hwaybill = $barcode['data']['waybill'];
  1331. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  1332. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  1333. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  1334. {
  1335. if($fullorder['waybill'] != "")
  1336. {
  1337. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1338. }
  1339. else
  1340. {
  1341. $oldwaybill = $fullorder['oldwaybill'];
  1342. }
  1343. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1344. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删d
  1345. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  1346. {
  1347. $warehouse = $this->warehouse->read($fullorder['type']);
  1348. $text = array();
  1349. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  1350. $text['number'] = $fullorder['number'];
  1351. $text['mode'] = '95';
  1352. $text['pdfnum'] = 1;
  1353. $rows = array('text'=>$text);
  1354. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1355. }
  1356. }
  1357. }
  1358. else
  1359. {
  1360. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1361. }
  1362. }
  1363. else
  1364. {
  1365. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会或者梦体处理','success'=>false));exit;
  1366. }
  1367. }
  1368. }
  1369. public function _text($fullorder)
  1370. {
  1371. /** 发票地址信息暂时无用
  1372. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1373. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1374. $fullorder['baddress'][1] = $country['ename'];
  1375. **/
  1376. //获取所用相关信息
  1377. $warehouse = $this->warehouse->read($fullorder['type']);
  1378. $country = $this->country->read($fullorder['country']);//订单国家信息
  1379. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1380. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1381. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1382. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1383. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1384. $fullorder['country'] = $country['ename'];//订单国家名
  1385. $fullorder['zhou'] = $country['continent'];//所属州
  1386. $express = $this->express->read($fullorder['express']);
  1387. $fullorder['express'] = $express['servicename'];
  1388. $fullorder['account'] = $express['account'];
  1389. $fullorder['printcode'] = $express['printcode'];
  1390. $fullorder['time'] = date('Y-m-d',time());
  1391. $fullorder['times'] = date('Y-m-d H:i',time());
  1392. //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1393. // 修复报关编码问题
  1394. $declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
  1395. $sbbm = "";
  1396. if(empty($declara_info)){
  1397. $sbbm = "";
  1398. }else{
  1399. $sbbm = $declara_info['bname'];
  1400. }
  1401. $fullorder['sbbm']= $sbbm;
  1402. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1403. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1404. $shop = $this->shop->read($fullorder['shop']);
  1405. $fullorder['shop'] = $shop['shopname'];
  1406. return $fullorder;
  1407. }
  1408. public function _lowe()
  1409. {
  1410. $post = $this->input->post(NULL, TRUE);
  1411. if(isset($post['lowe']))
  1412. {
  1413. $lowe = $this->typeclass->find_all('classid = 15 and id != 105 and id != 107 and id != 108 and id != 112 and id != 114 and id != 115 and id != 116 and id != 117 and id != 118 and id != 119 and id != 120 and id != 121 and id != 122 and id != 123 and id != 124 and id != 125 and id != 292 and id != 63 and id != 289 and id != 290 and id != 181 and id != 273 and id != 148 and id != 38 and id != 291 and id != 55 and id != 271 and id != 285 and id != 186 and id != 187 and id != 188 and id != 189');
  1414. echo json_encode(array('msg'=>$lowe));exit;
  1415. }
  1416. }
  1417. public function _pdf($pdf,$title,$bctime)
  1418. {
  1419. $pdf_path = './data/pdf/'.$bctime.'/';
  1420. $file_base64 = $pdf;
  1421. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1422. $file_base64 = base64_decode($file_base64);
  1423. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1424. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1425. return $bctime;
  1426. }
  1427. public function _pdfurl($pdf,$title,$bctime)
  1428. {
  1429. $pdf_path = './data/pdf/'.$bctime.'/';
  1430. $pdf = fopen($pdf,"r");
  1431. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1432. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1433. return $bctime;
  1434. }
  1435. public function _excel()
  1436. {
  1437. $xw = '';
  1438. if(isset($_SESSION['api']))
  1439. {
  1440. $user = $this->user->get_api($_SESSION['api']);
  1441. $usp = $user;
  1442. $fgshop = "";$sid = "";$wid="";$wtype="";
  1443. $usersp = explode('|',trim($user['shop'],'|'));
  1444. $userwh = explode('|',trim($user['warehouse'],'|'));
  1445. foreach ($usersp as $value)
  1446. {
  1447. $fgshop .= " shop = ".$value." or";
  1448. $sid .= " id = ".$value." or";
  1449. }
  1450. foreach ($userwh as $value)
  1451. {
  1452. $wid .= " id = ".$value." or";
  1453. $wtype .= " type = ".$value." or";
  1454. }
  1455. if($user['userid'] == 'xw')
  1456. {
  1457. $xw = 1;
  1458. }
  1459. }
  1460. if(isset($_GET['fexcel']))
  1461. {
  1462. $dowid = $this->input->get('a');
  1463. $wid = "";
  1464. if($dowid != "")
  1465. {
  1466. $id_arr = explode(',',rtrim($dowid,','));
  1467. foreach ($id_arr as $v)
  1468. {
  1469. $wid .= " id = '$v' or";
  1470. }
  1471. $wid = " and ( ".rtrim($wid,'or') ." ) ";
  1472. }
  1473. $t = $this->input->get('t',true);
  1474. $timetk = $this->input->get('timetk',true);
  1475. $timetj = $this->input->get('timetj',true);
  1476. $shop = $this->input->get('shop',true);
  1477. $source = $this->input->get('source',true);
  1478. $orderinfo = $this->input->get('orderinfo',true);
  1479. $number = $this->input->get('number',true);
  1480. $library = $this->input->get('library',true);
  1481. $waybill = $this->input->get('waybill',true);
  1482. $express = $this->input->get('express',true);
  1483. $type = $this->input->get('type',true);
  1484. $so = $this->input->get('so',true);
  1485. $timetk = strtotime($timetk);
  1486. $timetj = strtotime($timetj);
  1487. $where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
  1488. if($timetk && $timetj && $library == 1)
  1489. {
  1490. //$cxtime = 'reviewtime';
  1491. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  1492. $where .= " and state != 217";
  1493. }
  1494. else if($timetk && $timetj && $library == 2)
  1495. {
  1496. $cxtime = 'librarytime';
  1497. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1498. }
  1499. /**
  1500. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  1501. if($timetk && $timetj && $library == 1)
  1502. {
  1503. //$cxtime = 'reviewtime';
  1504. //$where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1505. }
  1506. else if($timetk && $timetj && $library == 2)
  1507. {
  1508. $cxtime = 'librarytime';
  1509. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1510. }
  1511. **/
  1512. if(isset($_SESSION['api']))
  1513. {
  1514. if($type)
  1515. {
  1516. $where .= " and type = '$type'";
  1517. }
  1518. else
  1519. {
  1520. $uw = '';
  1521. $u = $this->user->get_api($_SESSION['api']);
  1522. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1523. foreach ($u['warehouse'] as $v)
  1524. {
  1525. $uw .= " type = '$v' or";
  1526. }
  1527. $uw = rtrim($uw,'or');
  1528. $uw = " and (".ltrim($uw,' ').")";
  1529. $where .= $uw;
  1530. }
  1531. }
  1532. else
  1533. {
  1534. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1535. }
  1536. if($shop)
  1537. {
  1538. $where .= " and shop = '$shop'";
  1539. }
  1540. if($number)
  1541. {
  1542. $where .= " and number = '$number'";
  1543. }
  1544. if($library)
  1545. {
  1546. $where .= " and library = '$library'";
  1547. }
  1548. if($waybill)
  1549. {
  1550. $where .= " and waybill = '$waybill'";
  1551. }
  1552. if($express)
  1553. {
  1554. $where .= " and express = '$express'";
  1555. }
  1556. if($orderinfo)
  1557. {
  1558. $where .= " and orderinfo = '$orderinfo'";
  1559. }
  1560. if($so)
  1561. {
  1562. $where .= " and shipremarks like '%$so%'";
  1563. }
  1564. //数据排序
  1565. //$order_str = ($print != 3)?"id desc":"librarytime desc";
  1566. $order_str = "librarytime desc";
  1567. if(empty($page))
  1568. {
  1569. $start = 0;
  1570. $perpage = 1;
  1571. }
  1572. else
  1573. {
  1574. $start = ($page - 1)*$perpage;
  1575. }
  1576. $typeclass = array();
  1577. $tclass = $this->typeclass->find_all();
  1578. foreach ($tclass as $v)
  1579. {
  1580. $typeclass[$v['id']] = $v;
  1581. }
  1582. //取得信息列表
  1583. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1584. //格式化数据
  1585. foreach ($info_list as $key=>$value)
  1586. {
  1587. $shop = $this->shop->read($value['shop']);
  1588. $info_list[$key]['shop'] = $shop['shopname'];
  1589. if($value['waybill'] == '0')
  1590. {
  1591. $info_list[$key]['waybill'] = "";
  1592. }
  1593. $express = $this->express->read($value['express']);
  1594. $info_list[$key]['express'] = $express['servicename'];
  1595. $warehouse = $this->warehouse->read($value['type']);
  1596. $info_list[$key]['type'] = $warehouse['title'];
  1597. if($value['print'] == 1)
  1598. {
  1599. $info_list[$key]['print'] = '不可打印';
  1600. }
  1601. else if($value['print'] == 2)
  1602. {
  1603. $info_list[$key]['print'] = '未打印';
  1604. }
  1605. else if($value['print'] == 3)
  1606. {
  1607. $info_list[$key]['print'] = '已打印';
  1608. }
  1609. if($value['library'] == 1)
  1610. {
  1611. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1612. }
  1613. else if($value['library'] == 2)
  1614. {
  1615. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1616. }
  1617. else if($value['library'] == 3)
  1618. {
  1619. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1620. }
  1621. if($value['librarytime'] == '0')
  1622. {
  1623. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  1624. }
  1625. else
  1626. {
  1627. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1628. }
  1629. $classid = $classid = $this->classid->sku();
  1630. $dbapi = explode(';',trim($value['fpdata'],';'));
  1631. $tmp_jm = "";
  1632. $tmp_zh = "";
  1633. foreach ($dbapi as $va)
  1634. {
  1635. $pm = $classid;
  1636. $jm = $classid;
  1637. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1638. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1639. $ts = explode('|',trim($features,'|'));
  1640. if(stripos($ts[0],',') !== false)
  1641. {
  1642. $ft = explode(',',$ts[0]);
  1643. $features = explode('-',trim($ft[1],'-'));
  1644. $features[] = $ft[0];
  1645. }
  1646. else
  1647. {
  1648. $features = explode('-',trim($ts[0],'-'));
  1649. }
  1650. foreach($features as $k=>$v)
  1651. {
  1652. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1653. {
  1654. if($typeclass[$v]['bm'] != '')
  1655. {
  1656. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1657. }
  1658. }
  1659. if($v != 0 && isset($typeclass[$v]))
  1660. {
  1661. if($typeclass[$v]['classid'] == 13)
  1662. {
  1663. $dj = $typeclass[$v]['title'];
  1664. }
  1665. if($typeclass[$v]['classid'] == 8)
  1666. {
  1667. $ys = $typeclass[$v]['title'];
  1668. }
  1669. if($typeclass[$v]['classid'] == 15)
  1670. {
  1671. $hx = $typeclass[$v]['title'];
  1672. }
  1673. if(isset($pm[$typeclass[$v]['classid']]))
  1674. {
  1675. if($typeclass[$v]['title'] == '9A')
  1676. {
  1677. $pm[$typeclass[$v]['classid']] = '9A';
  1678. }
  1679. else if($typeclass[$v]['title'] == '10A')
  1680. {
  1681. $pm[$typeclass[$v]['classid']] = '10A';
  1682. }
  1683. else
  1684. {
  1685. $clzh = $typeclass[$v]['zh'];
  1686. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1687. {
  1688. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1689. $clzh = $clzh[0];
  1690. }
  1691. $pm[$typeclass[$v]['classid']] = $clzh;
  1692. }
  1693. }
  1694. if(isset($jm[$typeclass[$v]['classid']]))
  1695. {
  1696. if($typeclass[$v]['jm'])
  1697. {
  1698. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1699. }
  1700. }
  1701. }
  1702. }
  1703. $jm = array_filter($jm);//去除空值
  1704. $jm = implode("-",$jm);
  1705. $tmp_jm .= $jm.";";
  1706. $pm = array_filter($pm);//去除空值
  1707. $zh = implode(" ",$pm);
  1708. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1709. $tmp_zh .= $zh.";";
  1710. }
  1711. $info_list[$key]['jm'] = trim($tmp_jm,';');
  1712. $info_list[$key]['zh'] = trim($tmp_zh,';');
  1713. }
  1714. //取得信息列表
  1715. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1716. //格式化数据
  1717. foreach ($info_listsmt as $key=>$value)
  1718. {
  1719. $shop = $this->shop->read($value['shop']);
  1720. $info_listsmt[$key]['shop'] = $shop['shopname'];
  1721. if($value['waybill'] == '0')
  1722. {
  1723. $info_listsmt[$key]['waybill'] = "";
  1724. }
  1725. $express = $this->express->read($value['express']);
  1726. $info_listsmt[$key]['express'] = $express['servicename'];
  1727. $warehouse = $this->warehouse->read($value['type']);
  1728. $info_listsmt[$key]['type'] = $warehouse['title'];
  1729. if($value['print'] == 1)
  1730. {
  1731. $info_listsmt[$key]['print'] = '不可打印';
  1732. }
  1733. else if($value['print'] == 2)
  1734. {
  1735. $info_listsmt[$key]['print'] = '未打印';
  1736. }
  1737. else if($value['print'] == 3)
  1738. {
  1739. $info_listsmt[$key]['print'] = '已打印';
  1740. }
  1741. if($value['library'] == 1)
  1742. {
  1743. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  1744. }
  1745. else if($value['library'] == 2)
  1746. {
  1747. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  1748. }
  1749. else if($value['library'] == 3)
  1750. {
  1751. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  1752. }
  1753. if($value['librarytime'] == '0')
  1754. {
  1755. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  1756. }
  1757. else
  1758. {
  1759. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1760. }
  1761. $classid = $classid = $this->classid->sku();
  1762. $dbapi = explode(';',trim($value['fpdata'],';'));
  1763. $tmp_jm = "";
  1764. $tmp_zh = "";
  1765. foreach ($dbapi as $va)
  1766. {
  1767. $pm = $classid;
  1768. $jm = $classid;
  1769. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1770. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1771. $ts = explode('|',trim($features,'|'));
  1772. if(stripos($ts[0],',') !== false)
  1773. {
  1774. $ft = explode(',',$ts[0]);
  1775. $features = explode('-',trim($ft[1],'-'));
  1776. $features[] = $ft[0];
  1777. }
  1778. else
  1779. {
  1780. $features = explode('-',trim($ts[0],'-'));
  1781. }
  1782. foreach($features as $k=>$v)
  1783. {
  1784. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1785. {
  1786. if($typeclass[$v]['bm'] != '')
  1787. {
  1788. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1789. }
  1790. }
  1791. if($v != 0 && isset($typeclass[$v]))
  1792. {
  1793. if($typeclass[$v]['classid'] == 13)
  1794. {
  1795. $dj = $typeclass[$v]['title'];
  1796. }
  1797. if($typeclass[$v]['classid'] == 8)
  1798. {
  1799. $ys = $typeclass[$v]['title'];
  1800. }
  1801. if($typeclass[$v]['classid'] == 15)
  1802. {
  1803. $hx = $typeclass[$v]['title'];
  1804. }
  1805. if(isset($pm[$typeclass[$v]['classid']]))
  1806. {
  1807. if($typeclass[$v]['title'] == '9A')
  1808. {
  1809. $pm[$typeclass[$v]['classid']] = '9A';
  1810. }
  1811. else if($typeclass[$v]['title'] == '10A')
  1812. {
  1813. $pm[$typeclass[$v]['classid']] = '10A';
  1814. }
  1815. else
  1816. {
  1817. $clzh = $typeclass[$v]['zh'];
  1818. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1819. {
  1820. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1821. $clzh = $clzh[0];
  1822. }
  1823. $pm[$typeclass[$v]['classid']] = $clzh;
  1824. }
  1825. }
  1826. if(isset($jm[$typeclass[$v]['classid']]))
  1827. {
  1828. if($typeclass[$v]['jm'])
  1829. {
  1830. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1831. }
  1832. }
  1833. }
  1834. }
  1835. $jm = array_filter($jm);//去除空值
  1836. $jm = implode("-",$jm);
  1837. $pm = array_filter($pm);//去除空值
  1838. $zh = implode(" ",$pm);
  1839. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1840. $tmp_jm .= $jm.";";
  1841. $tmp_zh .= $zh.";";
  1842. }
  1843. $info_listsmt[$key]['jm'] = trim($tmp_jm,';');
  1844. $info_listsmt[$key]['zh'] = trim($tmp_zh,';');
  1845. }
  1846. //取得信息列表
  1847. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1848. //格式化数据
  1849. foreach ($info_listtt as $key=>$value)
  1850. {
  1851. $shop = $this->shop->read($value['shop']);
  1852. $info_listtt[$key]['shop'] = $shop['shopname'];
  1853. if($value['waybill'] == '0')
  1854. {
  1855. $info_listtt[$key]['waybill'] = "";
  1856. }
  1857. $express = $this->express->read($value['express']);
  1858. $info_listtt[$key]['express'] = $express['servicename'];
  1859. $warehouse = $this->warehouse->read($value['type']);
  1860. $info_listtt[$key]['type'] = $warehouse['title'];
  1861. if($value['print'] == 1)
  1862. {
  1863. $info_listtt[$key]['print'] = '不可打印';
  1864. }
  1865. else if($value['print'] == 2)
  1866. {
  1867. $info_listtt[$key]['print'] = '未打印';
  1868. }
  1869. else if($value['print'] == 3)
  1870. {
  1871. $info_listtt[$key]['print'] = '已打印';
  1872. }
  1873. if($value['library'] == 1)
  1874. {
  1875. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  1876. }
  1877. else if($value['library'] == 2)
  1878. {
  1879. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  1880. }
  1881. else if($value['library'] == 3)
  1882. {
  1883. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  1884. }
  1885. if($value['librarytime'] == '0')
  1886. {
  1887. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  1888. }
  1889. else
  1890. {
  1891. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1892. }
  1893. $classid = $classid = $this->classid->sku();
  1894. $tmp_jm = "";
  1895. $tmp_zh = "";
  1896. $dbapi = explode(';',trim($value['fpdata'],';'));
  1897. foreach ($dbapi as $va)
  1898. {
  1899. $pm = $classid;
  1900. $jm = $classid;
  1901. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1902. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1903. $ts = explode('|',trim($features,'|'));
  1904. if(stripos($ts[0],',') !== false)
  1905. {
  1906. $ft = explode(',',$ts[0]);
  1907. $features = explode('-',trim($ft[1],'-'));
  1908. $features[] = $ft[0];
  1909. }
  1910. else
  1911. {
  1912. $features = explode('-',trim($ts[0],'-'));
  1913. }
  1914. foreach($features as $k=>$v)
  1915. {
  1916. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1917. {
  1918. if($typeclass[$v]['bm'] != '')
  1919. {
  1920. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1921. }
  1922. }
  1923. if($v != 0 && isset($typeclass[$v]))
  1924. {
  1925. if($typeclass[$v]['classid'] == 13)
  1926. {
  1927. $dj = $typeclass[$v]['title'];
  1928. }
  1929. if($typeclass[$v]['classid'] == 8)
  1930. {
  1931. $ys = $typeclass[$v]['title'];
  1932. }
  1933. if($typeclass[$v]['classid'] == 15)
  1934. {
  1935. $hx = $typeclass[$v]['title'];
  1936. }
  1937. if(isset($pm[$typeclass[$v]['classid']]))
  1938. {
  1939. if($typeclass[$v]['title'] == '9A')
  1940. {
  1941. $pm[$typeclass[$v]['classid']] = '9A';
  1942. }
  1943. else if($typeclass[$v]['title'] == '10A')
  1944. {
  1945. $pm[$typeclass[$v]['classid']] = '10A';
  1946. }
  1947. else
  1948. {
  1949. $clzh = $typeclass[$v]['zh'];
  1950. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1951. {
  1952. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1953. $clzh = $clzh[0];
  1954. }
  1955. $pm[$typeclass[$v]['classid']] = $clzh;
  1956. }
  1957. }
  1958. if(isset($jm[$typeclass[$v]['classid']]))
  1959. {
  1960. if($typeclass[$v]['jm'])
  1961. {
  1962. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1963. }
  1964. }
  1965. }
  1966. }
  1967. $jm = array_filter($jm);//去除空值
  1968. $jm = implode("-",$jm);
  1969. $pm = array_filter($pm);//去除空值
  1970. $zh = implode(" ",$pm);
  1971. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1972. $tmp_jm .= $jm.";";
  1973. $tmp_zh .= $zh.";";
  1974. }
  1975. $info_listtt[$key]['jm'] = trim($tmp_jm,';');
  1976. $info_listtt[$key]['zh'] = trim($tmp_zh,';');
  1977. }
  1978. //取得信息列表
  1979. $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1980. //格式化数据
  1981. foreach ($info_listamz as $key=>$value)
  1982. {
  1983. $shop = $this->shop->read($value['shop']);
  1984. $info_listamz[$key]['shop'] = $shop['shopname'];
  1985. if($value['waybill'] == '0')
  1986. {
  1987. $info_listamz[$key]['waybill'] = "";
  1988. }
  1989. $express = $this->express->read($value['express']);
  1990. $info_listamz[$key]['express'] = $express['servicename'];
  1991. $warehouse = $this->warehouse->read($value['type']);
  1992. $info_listamz[$key]['type'] = $warehouse['title'];
  1993. if($value['print'] == 1)
  1994. {
  1995. $info_listamz[$key]['print'] = '不可打印';
  1996. }
  1997. else if($value['print'] == 2)
  1998. {
  1999. $info_listamz[$key]['print'] = '未打印';
  2000. }
  2001. else if($value['print'] == 3)
  2002. {
  2003. $info_listamz[$key]['print'] = '已打印';
  2004. }
  2005. if($value['library'] == 1)
  2006. {
  2007. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  2008. }
  2009. else if($value['library'] == 2)
  2010. {
  2011. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  2012. }
  2013. else if($value['library'] == 3)
  2014. {
  2015. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  2016. }
  2017. if($value['librarytime'] == '0')
  2018. {
  2019. $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  2020. }
  2021. else
  2022. {
  2023. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2024. }
  2025. $classid = $classid = $this->classid->sku();
  2026. $dbapi = explode(';',trim($value['fpdata'],';'));
  2027. $tmp_jm = "";
  2028. $tmp_zh = "";
  2029. foreach ($dbapi as $va)
  2030. {
  2031. $pm = $classid;
  2032. $jm = $classid;
  2033. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2034. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2035. $ts = explode('|',trim($features,'|'));
  2036. if(stripos($ts[0],',') !== false)
  2037. {
  2038. $ft = explode(',',$ts[0]);
  2039. $features = explode('-',trim($ft[1],'-'));
  2040. $features[] = $ft[0];
  2041. }
  2042. else
  2043. {
  2044. $features = explode('-',trim($ts[0],'-'));
  2045. }
  2046. foreach($features as $k=>$v)
  2047. {
  2048. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2049. {
  2050. if($typeclass[$v]['bm'] != '')
  2051. {
  2052. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2053. }
  2054. }
  2055. if($v != 0 && isset($typeclass[$v]))
  2056. {
  2057. if($typeclass[$v]['classid'] == 13)
  2058. {
  2059. $dj = $typeclass[$v]['title'];
  2060. }
  2061. if($typeclass[$v]['classid'] == 8)
  2062. {
  2063. $ys = $typeclass[$v]['title'];
  2064. }
  2065. if($typeclass[$v]['classid'] == 15)
  2066. {
  2067. $hx = $typeclass[$v]['title'];
  2068. }
  2069. if(isset($pm[$typeclass[$v]['classid']]))
  2070. {
  2071. if($typeclass[$v]['title'] == '9A')
  2072. {
  2073. $pm[$typeclass[$v]['classid']] = '9A';
  2074. }
  2075. else if($typeclass[$v]['title'] == '10A')
  2076. {
  2077. $pm[$typeclass[$v]['classid']] = '10A';
  2078. }
  2079. else
  2080. {
  2081. $clzh = $typeclass[$v]['zh'];
  2082. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2083. {
  2084. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2085. $clzh = $clzh[0];
  2086. }
  2087. $pm[$typeclass[$v]['classid']] = $clzh;
  2088. }
  2089. }
  2090. if(isset($jm[$typeclass[$v]['classid']]))
  2091. {
  2092. if($typeclass[$v]['jm'])
  2093. {
  2094. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2095. }
  2096. }
  2097. }
  2098. }
  2099. $jm = array_filter($jm);//去除空值
  2100. $jm = implode("-",$jm);
  2101. $pm = array_filter($pm);//去除空值
  2102. $zh = implode(" ",$pm);
  2103. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2104. $tmp_jm .= $jm.";";
  2105. $tmp_zh .= $zh.";";
  2106. }
  2107. $info_listamz[$key]['jm'] = trim($tmp_jm,';');
  2108. $info_listamz[$key]['zh'] = trim($tmp_zh,';');
  2109. }
  2110. //取得信息列表
  2111. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,waybillid,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  2112. //格式化数据
  2113. foreach ($info_listxw as $key=>$value)
  2114. {
  2115. $shop = $this->shop->read($value['shop']);
  2116. $info_listxw[$key]['shop'] = $shop['shopname'];
  2117. if($value['waybill'] == '0')
  2118. {
  2119. $info_listxw[$key]['waybill'] = "";
  2120. }
  2121. $express = $this->express->read($value['express']);
  2122. $info_listxw[$key]['express'] = $express['servicename'];
  2123. $warehouse = $this->warehouse->read($value['type']);
  2124. $info_listxw[$key]['type'] = $warehouse['title'];
  2125. if($value['print'] == 1)
  2126. {
  2127. $info_listxw[$key]['print'] = '不可打印';
  2128. }
  2129. else if($value['print'] == 2)
  2130. {
  2131. $info_listxw[$key]['print'] = '未打印';
  2132. }
  2133. else if($value['print'] == 3)
  2134. {
  2135. $info_listxw[$key]['print'] = '已打印';
  2136. }
  2137. if($value['library'] == 1)
  2138. {
  2139. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2140. }
  2141. else if($value['library'] == 2)
  2142. {
  2143. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2144. }
  2145. else if($value['library'] == 3)
  2146. {
  2147. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2148. }
  2149. if($value['librarytime'] == '0')
  2150. {
  2151. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  2152. }
  2153. else
  2154. {
  2155. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2156. }
  2157. $classid = $classid = $this->classid->sku();
  2158. $dbapi = explode(';',trim($value['fpdata'],';'));
  2159. foreach ($dbapi as $va)
  2160. {
  2161. $pm = $classid;
  2162. $jm = $classid;
  2163. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2164. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2165. $ts = explode('|',trim($features,'|'));
  2166. if(stripos($ts[0],',') !== false)
  2167. {
  2168. $ft = explode(',',$ts[0]);
  2169. $features = explode('-',trim($ft[1],'-'));
  2170. $features[] = $ft[0];
  2171. }
  2172. else
  2173. {
  2174. $features = explode('-',trim($ts[0],'-'));
  2175. }
  2176. foreach($features as $k=>$v)
  2177. {
  2178. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2179. {
  2180. if($typeclass[$v]['bm'] != '')
  2181. {
  2182. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2183. }
  2184. }
  2185. if($v != 0 && isset($typeclass[$v]))
  2186. {
  2187. if($typeclass[$v]['classid'] == 13)
  2188. {
  2189. $dj = $typeclass[$v]['title'];
  2190. }
  2191. if($typeclass[$v]['classid'] == 8)
  2192. {
  2193. $ys = $typeclass[$v]['title'];
  2194. }
  2195. if($typeclass[$v]['classid'] == 15)
  2196. {
  2197. $hx = $typeclass[$v]['title'];
  2198. }
  2199. if(isset($pm[$typeclass[$v]['classid']]))
  2200. {
  2201. if($typeclass[$v]['title'] == '9A')
  2202. {
  2203. $pm[$typeclass[$v]['classid']] = '9A';
  2204. }
  2205. else if($typeclass[$v]['title'] == '10A')
  2206. {
  2207. $pm[$typeclass[$v]['classid']] = '10A';
  2208. }
  2209. else
  2210. {
  2211. $clzh = $typeclass[$v]['zh'];
  2212. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2213. {
  2214. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2215. $clzh = $clzh[0];
  2216. }
  2217. $pm[$typeclass[$v]['classid']] = $clzh;
  2218. }
  2219. }
  2220. if(isset($jm[$typeclass[$v]['classid']]))
  2221. {
  2222. if($typeclass[$v]['jm'])
  2223. {
  2224. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2225. }
  2226. }
  2227. }
  2228. }
  2229. $jm = array_filter($jm);//去除空值
  2230. $jm = implode("-",$jm);
  2231. $pm = array_filter($pm);//去除空值
  2232. $zh = implode(" ",$pm);
  2233. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2234. }
  2235. $info_listxw[$key]['jm'] = $jm;
  2236. $info_listxw[$key]['zh'] = $zh;
  2237. }
  2238. $title = '订单出库-'.date('Ymd',time());
  2239. $t = str_replace("<td>运单号</td>","<td>运单号</td><td>转单号</td>",$t);
  2240. $titlename = "<table border=1>".$t."<td>条数</td><td>料品</td><td>品名</td></table>";
  2241. $tail = "\n";
  2242. $filename = $title.".xls";
  2243. $this->excel->get_fz2(array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt),$titlename,$filename,$tail);
  2244. }
  2245. }
  2246. public function _cpexcel()
  2247. {
  2248. if(isset($_SESSION['api']))
  2249. {
  2250. $user = $this->user->get_api($_SESSION['api']);
  2251. $usp = $user;
  2252. $fgshop = "";$sid = "";$excelshop="";
  2253. $usersp = explode('|',trim($user['shop'],'|'));
  2254. foreach ($usersp as $value)
  2255. {
  2256. $fgshop .= " shop = ".$value." or";
  2257. $sid .= " id = ".$value." or";
  2258. }
  2259. $userexcel = explode('|',trim($user['excelshop'],'|'));
  2260. foreach ($userexcel as $value)
  2261. {
  2262. $excelshop .= " shop = ".$value." or";
  2263. }
  2264. if($excelshop != "")
  2265. {
  2266. $excelshop = "(".rtrim($excelshop,'or').")";
  2267. }
  2268. }
  2269. if(isset($_GET['excel']))
  2270. {
  2271. $timetk = $this->input->get('timetk',true);
  2272. $timetj = $this->input->get('timetj',true);
  2273. $shop = $this->input->get('shop',true);
  2274. $library = $this->input->get('library',true);
  2275. $type = $this->input->get('type',true);
  2276. $number = $this->input->get('number',true);
  2277. $orderinfo = $this->input->get('orderinfo',true);
  2278. $so = $this->input->get('so',true);
  2279. $number = $this->input->get('number',true);
  2280. $express = $this->input->get('express',true);
  2281. $timetk = strtotime($timetk);
  2282. $timetj = strtotime($timetj);
  2283. $where = "mergeid = 0";
  2284. if($timetk && $timetj && $library == 2)
  2285. {
  2286. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2287. }
  2288. else
  2289. {
  2290. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  2291. }
  2292. if(isset($_SESSION['api']))
  2293. {
  2294. if($type)
  2295. {
  2296. $where .= " and type = '$type'";
  2297. }
  2298. else
  2299. {
  2300. $uw = '';
  2301. $u = $this->user->get_api($_SESSION['api']);
  2302. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  2303. foreach ($u['warehouse'] as $v)
  2304. {
  2305. $uw .= " type = '$v' or";
  2306. }
  2307. $uw = rtrim($uw,'or');
  2308. $uw = " and (".ltrim($uw,' ').")";
  2309. $where .= $uw;
  2310. }
  2311. }
  2312. else
  2313. {
  2314. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  2315. }
  2316. if($shop)
  2317. {
  2318. $where .= " and shop = '$shop'";
  2319. }
  2320. else
  2321. {
  2322. $where .= " and ".$excelshop;
  2323. }
  2324. if($library)
  2325. {
  2326. $where .= " and library = '$library'";
  2327. }
  2328. if($number)
  2329. {
  2330. $where .= " and number = '$number'";
  2331. }
  2332. if($orderinfo)
  2333. {
  2334. $where .= " and orderinfo = '$orderinfo'";
  2335. }
  2336. if($so)
  2337. {
  2338. $where .= " and shipremarks like '%$so%'";
  2339. }
  2340. if($express)
  2341. {
  2342. $where .= " and express = '$express'";
  2343. }
  2344. /* 匹配ID加入 */
  2345. $tc = array();
  2346. $typeclass = $this->typeclass->find_all();
  2347. foreach ($typeclass as $v)
  2348. {
  2349. $tc[$v['id']] = $v['title'];
  2350. }
  2351. $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$refundj=0;$cost=0;$lr=0;
  2352. //取得信息列表
  2353. $info_lista = $this->fullordersmt->find_all($where,'fpdata');
  2354. $info_listb = $this->fullorder->find_all($where,'fpdata');
  2355. $info_list = array_merge($info_lista,$info_listb);
  2356. //格式化数据
  2357. $i = 0;$cpexcel = array();
  2358. foreach ($info_list as $key=>$value)
  2359. {
  2360. if(stripos($value['fpdata'],';') !== false)
  2361. {
  2362. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  2363. foreach ($fpdata as $ke=>$va)
  2364. {
  2365. $title = '';
  2366. $fg = explode('|',$va);
  2367. $fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);
  2368. $cp = explode('-',rtrim($fg[0],'-'));
  2369. if(isset($cp[2])){
  2370. $kw = $this->logic_u9tools->checkLengthLocal($fg[0]);
  2371. if($kw == 3){
  2372. if(isset($cp[3])){
  2373. $title = $tc[$cp[3]];
  2374. }else{
  2375. $dj = "";
  2376. }
  2377. }else{
  2378. $dj = $tc[$cp[2]];
  2379. }
  2380. }else{
  2381. $dj= "";
  2382. }
  2383. if(!isset($cp[3]))
  2384. {
  2385. $ys = json_encode($cp);
  2386. }
  2387. else
  2388. {
  2389. $ys = $tc[$cp[3]];
  2390. }
  2391. unset($cp[0],$cp[1],$cp[2],$cp[3]);
  2392. foreach ($cp as $v)
  2393. {
  2394. $title .= $tc[$v].' ';
  2395. }
  2396. if(stripos($fg[0],'131-') !== false){
  2397. $title = "";
  2398. $ys="";
  2399. }
  2400. $cpexcel[$ke] = array($fg[5],$dj,$ys,$title,$fg[2]);//内容,尺寸,等级,颜色,数量
  2401. }
  2402. }
  2403. $i++;
  2404. }
  2405. $title = "统计信息";
  2406. $titlename = "<table border=1>
  2407. <tr>
  2408. <td>尺寸</td>
  2409. <td>等级</td>
  2410. <td>颜色</td>
  2411. <td>花型</td>
  2412. <td>数量</td>
  2413. </tr>
  2414. </table>";
  2415. $filename = $title.".xls";
  2416. $tail = "\n";
  2417. $this->excel->get_fz2($cpexcel,$titlename,$filename,$tail);
  2418. }
  2419. }
  2420. public function _orderyz()
  2421. {
  2422. $post = $this->input->post(NULL, TRUE);
  2423. if(isset($post['yz']))
  2424. {
  2425. $yz = $this->input->post('yz',true);
  2426. $number = $this->input->post('number',true);
  2427. $y = $this->fullorder->get_number($number);
  2428. if(!$y)
  2429. {
  2430. $y = $this->fullordersmt->get_number($number);
  2431. if(!$y)
  2432. {
  2433. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2434. }
  2435. }
  2436. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2437. foreach($whlabel as $k=>$v)
  2438. {
  2439. $w = explode('-',trim($v,'-'));
  2440. $wldata[$w[0]] = $w;
  2441. }
  2442. $whlabellabel = $this->whlabellabel->get_label($yz);
  2443. if(!$whlabellabel)
  2444. {
  2445. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2446. }
  2447. else
  2448. {
  2449. if(isset($wldata[$whlabellabel['number']]))
  2450. {
  2451. if(!isset($wldata[$whlabellabel['number']][2]))
  2452. {
  2453. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2454. }
  2455. else if($wldata[$whlabellabel['number']][2] == 0)
  2456. {
  2457. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2458. }
  2459. }
  2460. else
  2461. {
  2462. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2463. }
  2464. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2465. }
  2466. }
  2467. if(isset($post['number']))
  2468. {
  2469. $number = $this->input->post('number',true);
  2470. $f = 'fullorder';
  2471. $y = $this->fullorder->get_number($number);
  2472. if(!$y)
  2473. {
  2474. $f = 'fullordersmt';
  2475. $y = $this->fullordersmt->get_number($number);
  2476. if(!$y)
  2477. {
  2478. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2479. }
  2480. }
  2481. if($y['librarytime'] > 0)
  2482. {
  2483. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2484. }
  2485. $warehouse = $this->warehouse->read($y['type']);
  2486. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2487. {
  2488. echo json_encode(array('msg'=>'pz','success'=>false));exit;
  2489. }
  2490. $data = explode('|',trim($y['whlabel'],'|'));
  2491. $fpdata = explode(';',trim($y['fpdata'],';'));
  2492. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2493. foreach($fpdata as $val)
  2494. {
  2495. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2496. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2497. $fp = explode('|',$val);
  2498. $fp[0] = str_replace(',','-',$fp[0]);
  2499. $value = explode('-',$fp[0]);
  2500. foreach($value as $v)
  2501. {
  2502. $typeclass = $this->typeclass->read($v);
  2503. $zh = explode('|',trim($typeclass['zh'],'|'));
  2504. $pm[$typeclass['classid']] = $zh[0];
  2505. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2506. }
  2507. $scsku = implode("-",$scsku);
  2508. $zh = implode(" ",$pm);
  2509. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2510. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2511. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2512. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2513. $data[$i] = explode('-',$data[$i]);
  2514. for($j=0;$j<$data[$i][1];$j++)
  2515. {
  2516. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2517. {
  2518. $znum++;//只计算现货
  2519. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2520. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2521. }
  2522. else
  2523. {
  2524. //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
  2525. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
  2526. }
  2527. $x++;//所有数量
  2528. }
  2529. $i++;
  2530. }
  2531. //ksort($cp);//区别位置模式,暂不使用
  2532. $cp = array_values($cp);
  2533. if($this->$f->save(array('yhs'=>1),$y['id']))
  2534. {
  2535. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2536. }
  2537. else
  2538. {
  2539. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2540. }
  2541. }
  2542. if(isset($post['tid']))
  2543. {
  2544. $typeclass = array();
  2545. $tc = $this->typeclass->find_all();
  2546. foreach($tc as $v)
  2547. {
  2548. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2549. }
  2550. $tid = $this->input->post('tid',true);
  2551. $id = $this->input->post('id',true);
  2552. $number = $this->input->post('n',true);
  2553. $ful = 'fullorder';
  2554. $y = $this->fullorder->get_number($number);
  2555. if(!$y)
  2556. {
  2557. $ful = 'fullordersmt';
  2558. $y = $this->fullordersmt->get_number($number);
  2559. if(!$y)
  2560. {
  2561. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2562. }
  2563. }
  2564. $wtid = $this->whlabellabel->get_label($tid);
  2565. if(!$wtid)
  2566. {
  2567. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2568. }
  2569. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2570. $fpdata = explode(';',trim($y['fpdata'],';'));
  2571. $warehouse = $this->warehouse->read($y['type']);
  2572. $zdkc = $warehouse['bdck'];
  2573. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2574. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2575. if((count($ptc)+count($zsc)) < 1)
  2576. {
  2577. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2578. }
  2579. $this->db->trans_begin();
  2580. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2581. if($zsc)
  2582. {
  2583. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2584. $xrid = $zsc[0]['id'];
  2585. }
  2586. else if($ptc)
  2587. {
  2588. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2589. $xrid = $ptc[0]['id'];
  2590. }
  2591. $xr = $this->$zdkc->read($xrid);
  2592. $features = explode('-',trim($xr['features'],'-'));
  2593. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2594. foreach($features as $kk=>$v)
  2595. {
  2596. if($typeclass[$v]['classid'] == 14)
  2597. {
  2598. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2599. unset($kk);
  2600. }
  2601. }
  2602. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2603. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2604. $wldata = array();
  2605. $fdata = array();
  2606. foreach($whlabel as $k=>$v)
  2607. {
  2608. $w = explode('-',trim($v,'-'));
  2609. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2610. }
  2611. if(!isset($wldata[$id]))
  2612. {
  2613. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2614. }
  2615. if(isset($wldata[$wtid['number']]['sj']))
  2616. {
  2617. $tw = $wldata[$wtid['number']]['sj'];
  2618. if($wtid['number'] != $id)
  2619. {
  2620. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2621. }
  2622. else
  2623. {
  2624. if(isset($tw[2]) && $tw[2] != 0)
  2625. {
  2626. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2627. }
  2628. }
  2629. if($tw[1] > 1)
  2630. {
  2631. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2632. }
  2633. }
  2634. $thfpdata = $y['thfpdata'];
  2635. $w = $wldata[$id]['sj'];
  2636. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2637. $zdkc = $warehouse['bdck'];
  2638. if($w[1] > 1)
  2639. {
  2640. if(isset($w[2]) && $w[2] != 0)
  2641. {
  2642. $hz = explode('~',trim($w[2],'~'));
  2643. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2644. $zd = str_replace($hz[0],'',$w[2]);
  2645. $zd = trim($zd,'~');
  2646. $w[2] = $zd;
  2647. }
  2648. foreach($w as $kk=>$v)
  2649. {
  2650. if($kk == 1)
  2651. {
  2652. $v = $v-1;
  2653. }
  2654. $ww .= $v .'-';
  2655. }
  2656. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2657. foreach($f as $kk=>$v)
  2658. {
  2659. if($kk == 2)
  2660. {
  2661. $v = $v-1;
  2662. $thff .= '1|';
  2663. }
  2664. else
  2665. {
  2666. $thff .= $v .'|';
  2667. }
  2668. $ff .= $v .'|';
  2669. }
  2670. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2671. $thfpdata .= trim($thff,'|');
  2672. }
  2673. else
  2674. {
  2675. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2676. unset($whlabel[$wldata[$id]['wz']]);
  2677. unset($fpdata[$wldata[$id]['wz']]);
  2678. }
  2679. $thfpdata .= '~'.$dataf;
  2680. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2681. $fpdata = implode(";",$fpdata).';'.$dataf;
  2682. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2683. if ($this->db->trans_status() === TRUE)
  2684. {
  2685. $this->db->trans_commit();
  2686. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2687. }
  2688. else
  2689. {
  2690. $this->db->trans_rollback();
  2691. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2692. }
  2693. }
  2694. if(isset($post['yhs']))
  2695. {
  2696. $f = 'fullorder';
  2697. $number = $this->input->post('yhs',true);
  2698. $y = $this->fullorder->get_number($number);
  2699. if(!$y)
  2700. {
  2701. $f = 'fullordersmt';
  2702. $y = $this->fullordersmt->get_number($number);
  2703. }
  2704. if($this->$f->save(array('yhs'=>0),$y['id']))
  2705. {
  2706. echo json_encode(array('success'=>true));exit;
  2707. }
  2708. else
  2709. {
  2710. echo json_encode(array('success'=>false));exit;
  2711. }
  2712. }
  2713. $this->_Template('systemfout_orderyz',$this->data);
  2714. }
  2715. public function _hwyz()
  2716. {
  2717. $post = $this->input->post(NULL, TRUE);
  2718. if(isset($post['yz']))
  2719. {
  2720. $yz = $this->input->post('yz',true);
  2721. $number = $this->input->post('number',true);
  2722. $y = $this->fullorder->get_number($number);
  2723. if(!$y)
  2724. {
  2725. $y = $this->fullordersmt->get_number($number);
  2726. if(!$y)
  2727. {
  2728. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2729. }
  2730. }
  2731. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2732. foreach($whlabel as $k=>$v)
  2733. {
  2734. $w = explode('-',trim($v,'-'));
  2735. $wldata[$w[0]] = $w;
  2736. }
  2737. $whlabellabel = $this->whlabellabel->get_label($yz);
  2738. if(!$whlabellabel)
  2739. {
  2740. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2741. }
  2742. else
  2743. {
  2744. if(isset($wldata[$whlabellabel['number']]))
  2745. {
  2746. if(!isset($wldata[$whlabellabel['number']][2]))
  2747. {
  2748. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2749. }
  2750. else if($wldata[$whlabellabel['number']][2] == 0)
  2751. {
  2752. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2753. }
  2754. }
  2755. else
  2756. {
  2757. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2758. }
  2759. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2760. }
  2761. }
  2762. if(isset($post['number']))
  2763. {
  2764. $number = $this->input->post('number',true);
  2765. $f = 'fullorder';
  2766. $y = $this->fullorder->get_number($number);
  2767. if(!$y)
  2768. {
  2769. $f = 'fullordersmt';
  2770. $y = $this->fullordersmt->get_number($number);
  2771. if(!$y)
  2772. {
  2773. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2774. }
  2775. }
  2776. if($y['librarytime'] > 0)
  2777. {
  2778. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2779. }
  2780. $warehouse = $this->warehouse->read($y['type']);
  2781. $data = explode('|',trim($y['whlabel'],'|'));
  2782. $fpdata = explode(';',trim($y['fpdata'],';'));
  2783. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2784. foreach($fpdata as $val)
  2785. {
  2786. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2787. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2788. $fp = explode('|',$val);
  2789. $fp[0] = str_replace(',','-',$fp[0]);
  2790. $value = explode('-',$fp[0]);
  2791. foreach($value as $v)
  2792. {
  2793. $typeclass = $this->typeclass->read($v);
  2794. $zh = explode('|',trim($typeclass['zh'],'|'));
  2795. $pm[$typeclass['classid']] = $zh[0];
  2796. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2797. }
  2798. $scsku = implode("-",$scsku);
  2799. $zh = implode(" ",$pm);
  2800. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2801. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2802. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2803. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2804. $data[$i] = explode('-',$data[$i]);
  2805. for($j=0;$j<$data[$i][1];$j++)
  2806. {
  2807. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2808. {
  2809. $znum++;//只计算现货
  2810. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2811. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2812. }
  2813. else
  2814. {
  2815. //$cp[999+$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#ccc">增加现货</sapn>','c'=>0,'color'=>'#999');//区别位置模式,暂不使用
  2816. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'','t'=>'<span data-id="'.$data[$i][0].'" style="background-color:#e7ba08">增加现货</sapn>','c'=>0,'color'=>'#666');
  2817. }
  2818. $x++;//所有数量
  2819. }
  2820. $i++;
  2821. }
  2822. //ksort($cp);//区别位置模式,暂不使用
  2823. $cp = array_values($cp);
  2824. if($this->$f->save(array('yhs'=>1),$y['id']))
  2825. {
  2826. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2827. {
  2828. echo json_encode(array('rows'=>$cp,'z'=>$znum,'msg'=>'pz','success'=>false));exit;
  2829. }
  2830. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2831. }
  2832. else
  2833. {
  2834. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2835. }
  2836. }
  2837. if(isset($post['tid']))
  2838. {
  2839. $typeclass = array();
  2840. $tc = $this->typeclass->find_all();
  2841. foreach($tc as $v)
  2842. {
  2843. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2844. }
  2845. $tid = $this->input->post('tid',true);
  2846. $id = $this->input->post('id',true);
  2847. $number = $this->input->post('n',true);
  2848. $ful = 'fullorder';
  2849. $y = $this->fullorder->get_number($number);
  2850. if(!$y)
  2851. {
  2852. $ful = 'fullordersmt';
  2853. $y = $this->fullordersmt->get_number($number);
  2854. if(!$y)
  2855. {
  2856. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2857. }
  2858. }
  2859. $wtid = $this->whlabellabel->get_label($tid);
  2860. if(!$wtid)
  2861. {
  2862. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2863. }
  2864. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2865. $fpdata = explode(';',trim($y['fpdata'],';'));
  2866. $warehouse = $this->warehouse->read($y['type']);
  2867. $zdkc = $warehouse['bdck'];
  2868. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2869. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2870. if((count($ptc)+count($zsc)) < 1)
  2871. {
  2872. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2873. }
  2874. $this->db->trans_begin();
  2875. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2876. if($zsc)
  2877. {
  2878. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2879. $xrid = $zsc[0]['id'];
  2880. }
  2881. else if($ptc)
  2882. {
  2883. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2884. $xrid = $ptc[0]['id'];
  2885. }
  2886. $xr = $this->$zdkc->read($xrid);
  2887. $features = explode('-',trim($xr['features'],'-'));
  2888. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2889. foreach($features as $kk=>$v)
  2890. {
  2891. if($typeclass[$v]['classid'] == 14)
  2892. {
  2893. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2894. unset($kk);
  2895. }
  2896. }
  2897. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2898. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2899. $wldata = array();
  2900. $fdata = array();
  2901. foreach($whlabel as $k=>$v)
  2902. {
  2903. $w = explode('-',trim($v,'-'));
  2904. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2905. }
  2906. if(!isset($wldata[$id]))
  2907. {
  2908. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2909. }
  2910. if(isset($wldata[$wtid['number']]['sj']))
  2911. {
  2912. $tw = $wldata[$wtid['number']]['sj'];
  2913. if($wtid['number'] != $id)
  2914. {
  2915. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2916. }
  2917. else
  2918. {
  2919. if(isset($tw[2]) && $tw[2] != 0)
  2920. {
  2921. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2922. }
  2923. }
  2924. if($tw[1] > 1)
  2925. {
  2926. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2927. }
  2928. }
  2929. $thfpdata = $y['thfpdata'];
  2930. $w = $wldata[$id]['sj'];
  2931. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2932. $zdkc = $warehouse['bdck'];
  2933. if($w[1] > 1)
  2934. {
  2935. if(isset($w[2]) && $w[2] != 0)
  2936. {
  2937. $hz = explode('~',trim($w[2],'~'));
  2938. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2939. $zd = str_replace($hz[0],'',$w[2]);
  2940. $zd = trim($zd,'~');
  2941. $w[2] = $zd;
  2942. }
  2943. foreach($w as $kk=>$v)
  2944. {
  2945. if($kk == 1)
  2946. {
  2947. $v = $v-1;
  2948. }
  2949. $ww .= $v .'-';
  2950. }
  2951. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2952. foreach($f as $kk=>$v)
  2953. {
  2954. if($kk == 2)
  2955. {
  2956. $v = $v-1;
  2957. $thff .= '1|';
  2958. }
  2959. else
  2960. {
  2961. $thff .= $v .'|';
  2962. }
  2963. $ff .= $v .'|';
  2964. }
  2965. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2966. $thfpdata .= trim($thff,'|');
  2967. }
  2968. else
  2969. {
  2970. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2971. unset($whlabel[$wldata[$id]['wz']]);
  2972. unset($fpdata[$wldata[$id]['wz']]);
  2973. }
  2974. $thfpdata .= '~'.$dataf;
  2975. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2976. $fpdata = implode(";",$fpdata).';'.$dataf;
  2977. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2978. if ($this->db->trans_status() === TRUE)
  2979. {
  2980. $this->db->trans_commit();
  2981. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2982. }
  2983. else
  2984. {
  2985. $this->db->trans_rollback();
  2986. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2987. }
  2988. }
  2989. if(isset($post['yhs']))
  2990. {
  2991. $f = 'fullorder';
  2992. $number = $this->input->post('yhs',true);
  2993. $y = $this->fullorder->get_number($number);
  2994. if(!$y)
  2995. {
  2996. $f = 'fullordersmt';
  2997. $y = $this->fullordersmt->get_number($number);
  2998. }
  2999. if($this->$f->save(array('yhs'=>0),$y['id']))
  3000. {
  3001. echo json_encode(array('success'=>true));exit;
  3002. }
  3003. else
  3004. {
  3005. echo json_encode(array('success'=>false));exit;
  3006. }
  3007. }
  3008. $this->_Template('systemfout_hwyz',$this->data);
  3009. }
  3010. public function _fouthb()
  3011. {
  3012. $post = $this->input->post(NULL, TRUE);
  3013. $xw = '';
  3014. if(isset($_SESSION['api']))
  3015. {
  3016. $user = $this->user->get_api($_SESSION['api']);
  3017. $usp = $user;
  3018. $fgshop = "";$sid = "";$wid="";$wtype="";
  3019. $usersp = explode('|',trim($user['shop'],'|'));
  3020. $userwh = explode('|',trim($user['warehouse'],'|'));
  3021. foreach ($usersp as $value)
  3022. {
  3023. $fgshop .= " shop = ".$value." or";
  3024. $sid .= " id = ".$value." or";
  3025. }
  3026. foreach ($userwh as $value)
  3027. {
  3028. $wid .= " id = ".$value." or";
  3029. $wtype .= " type = ".$value." or";
  3030. }
  3031. if($user['userid'] == 'xw')
  3032. {
  3033. $xw = 1;
  3034. }
  3035. }
  3036. if(isset($post['page']))
  3037. {
  3038. $page = $this->input->post('page',true);
  3039. $perpage = $this->input->post('perpage',true);
  3040. $timetk = $this->input->post('timetk',true);
  3041. $timetj = $this->input->post('timetj',true);
  3042. $shop = $this->input->post('shop',true);
  3043. $type = $this->input->post('type',true);
  3044. $express = $this->input->post('express',true);
  3045. $number = $this->input->post('number',true);
  3046. $waybill = $this->input->post('waybill',true);
  3047. $librarytime = $this->input->post('librarytime',true);
  3048. $timetk = strtotime($timetk);
  3049. $timetj = strtotime($timetj);
  3050. $where = "mergeid = '1'";
  3051. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  3052. if($shop)
  3053. {
  3054. $where .= " and shop = '$shop'";
  3055. }
  3056. if($number)
  3057. {
  3058. $where .= " and number like '$number%'";
  3059. }
  3060. if($waybill)
  3061. {
  3062. $where .= " and waybill = '$waybill'";
  3063. }
  3064. if($type)
  3065. {
  3066. $where .= " and type = '$type'";
  3067. }
  3068. if($express)
  3069. {
  3070. $where .= " and express = '$express'";
  3071. }
  3072. //数据排序
  3073. $order_str = "librarytime desc";
  3074. if(empty($page))
  3075. {
  3076. $start = 0;
  3077. $perpage = 1;
  3078. }
  3079. else
  3080. {
  3081. $start = ($page - 1)*$perpage;
  3082. }
  3083. //取得信息列表
  3084. $info_list = $this->fullorder->find_all($where,'id,shop,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3085. //格式化数据
  3086. foreach ($info_list as $key=>$value)
  3087. {
  3088. $shop = $this->shop->read($value['shop']);
  3089. $info_list[$key]['shop'] = $shop['shopname'];
  3090. $express = $this->express->read($value['express']);
  3091. $info_list[$key]['express'] = $express['servicename'];
  3092. $warehouse = $this->warehouse->read($value['type']);
  3093. $info_list[$key]['type'] = $warehouse['title'];
  3094. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  3095. }
  3096. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  3097. //格式化数据
  3098. foreach ($info_listtt as $key=>$value)
  3099. {
  3100. $shop = $this->shop->read($value['shop']);
  3101. $info_listtt[$key]['shop'] = $shop['shopname'];
  3102. $express = $this->express->read($value['express']);
  3103. $info_listtt[$key]['express'] = $express['servicename'];
  3104. $warehouse = $this->warehouse->read($value['type']);
  3105. $info_listtt[$key]['type'] = $warehouse['title'];
  3106. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3107. }
  3108. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  3109. //格式化数据
  3110. foreach ($info_listamz as $key=>$value)
  3111. {
  3112. $shop = $this->shop->read($value['shop']);
  3113. $info_listamz[$key]['shop'] = $shop['shopname'];
  3114. $express = $this->express->read($value['express']);
  3115. $info_listamz[$key]['express'] = $express['servicename'];
  3116. $warehouse = $this->warehouse->read($value['type']);
  3117. $info_listamz[$key]['type'] = $warehouse['title'];
  3118. $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3119. }
  3120. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  3121. //格式化数据
  3122. foreach ($info_listxw as $key=>$value)
  3123. {
  3124. $shop = $this->shop->read($value['shop']);
  3125. $info_listxw[$key]['shop'] = $shop['shopname'];
  3126. $express = $this->express->read($value['express']);
  3127. $info_listxw[$key]['express'] = $express['servicename'];
  3128. $warehouse = $this->warehouse->read($value['type']);
  3129. $info_listxw[$key]['type'] = $warehouse['title'];
  3130. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3131. }
  3132. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid = '0'",'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  3133. //格式化数据
  3134. foreach ($info_listsmt as $key=>$value)
  3135. {
  3136. $shop = $this->shop->read($value['shop']);
  3137. $info_listsmt[$key]['shop'] = $shop['shopname'];
  3138. $express = $this->express->read($value['express']);
  3139. $info_listsmt[$key]['express'] = $express['servicename'];
  3140. $warehouse = $this->warehouse->read($value['type']);
  3141. $info_listsmt[$key]['type'] = $warehouse['title'];
  3142. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3143. }
  3144. $total = $this->fullorder->find_count($where);
  3145. $total += $this->fullordertt->find_count($where);
  3146. $total += $this->fullorderamz->find_count($where);
  3147. $total += $this->fullorderxw->find_count($where);
  3148. $total += $this->fullordersmt->find_count($where);
  3149. $pagenum = ceil($total/$perpage);
  3150. $over = $total-($start+$perpage);
  3151. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt)));
  3152. echo json_encode($rows);exit;
  3153. }
  3154. if(isset($_SESSION['api']))
  3155. {
  3156. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3157. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  3158. $this->data['wlshop'] = $wlshop;
  3159. $this->data['warehouse'] = $warehouse;
  3160. }
  3161. $this->data['xw'] = $xw;
  3162. $this->_Template('systemfout_fouthb',$this->data);
  3163. }
  3164. public function _hb()
  3165. {
  3166. $post = $this->input->post(NULL, TRUE);
  3167. $xw = '';
  3168. if(isset($_SESSION['api']))
  3169. {
  3170. $user = $this->user->get_api($_SESSION['api']);
  3171. $usp = $user;
  3172. $fgshop = "";$sid = "";$wid="";$wtype="";
  3173. $usersp = explode('|',trim($user['shop'],'|'));
  3174. $userwh = explode('|',trim($user['warehouse'],'|'));
  3175. foreach ($usersp as $value)
  3176. {
  3177. $fgshop .= " shop = ".$value." or";
  3178. $sid .= " id = ".$value." or";
  3179. }
  3180. foreach ($userwh as $value)
  3181. {
  3182. $wid .= " id = ".$value." or";
  3183. $wtype .= " type = ".$value." or";
  3184. }
  3185. if($user['userid'] == 'xw')
  3186. {
  3187. $xw = 1;
  3188. }
  3189. }
  3190. if(isset($post['page']))
  3191. {
  3192. $page = $this->input->post('page',true);
  3193. $perpage = $this->input->post('perpage',true);
  3194. $timetk = $this->input->post('timetk',true);
  3195. $timetj = $this->input->post('timetj',true);
  3196. $shop = $this->input->post('shop',true);
  3197. $source = $this->input->post('source',true);
  3198. $orderinfo = $this->input->post('orderinfo',true);
  3199. $number = $this->input->post('number',true);
  3200. $library = $this->input->post('library',true);
  3201. $waybill = $this->input->post('waybill',true);
  3202. $express = $this->input->post('express',true);
  3203. $type = $this->input->post('type',true);
  3204. $lowe = $this->input->post('lowe',true);
  3205. $so = $this->input->post('so',true);
  3206. $librarytime = $this->input->post('librarytime',true);
  3207. $timetk = strtotime($timetk);
  3208. $timetj = strtotime($timetj);
  3209. $cxtime = 'id';
  3210. $where = (isset($_SESSION['api']))?"library!=3 and mergeid = 1 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0' and mergeid = 1";
  3211. if($timetk && $timetj && $library == 1)
  3212. {
  3213. //$cxtime = 'reviewtime';
  3214. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  3215. $where .= " and state != 217";
  3216. }
  3217. else if($timetk && $timetj && $library == 2)
  3218. {
  3219. $cxtime = 'librarytime';
  3220. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  3221. }
  3222. if($shop)
  3223. {
  3224. $where .= " and shop = '$shop'";
  3225. }
  3226. if($number)
  3227. {
  3228. $where .= " and number = '$number'";
  3229. }
  3230. if($library)
  3231. {
  3232. $where .= " and library = '$library'";
  3233. }
  3234. if($waybill)
  3235. {
  3236. $where .= " and waybill = '$waybill'";
  3237. }
  3238. if($express)
  3239. {
  3240. $where .= " and express = '$express'";
  3241. }
  3242. if($orderinfo)
  3243. {
  3244. $where .= " and orderinfo = '$orderinfo'";
  3245. }
  3246. if($type)
  3247. {
  3248. $where .= " and type = '$type'";
  3249. }
  3250. if($lowe)
  3251. {
  3252. $where .= " and shipremarks like '%$lowe%'";
  3253. }
  3254. if($so)
  3255. {
  3256. $where .= " and shipremarks like '%$so%'";
  3257. }
  3258. //数据排序
  3259. $order_str = $cxtime." desc";
  3260. if(empty($page))
  3261. {
  3262. $start = 0;
  3263. $perpage = 1;
  3264. }
  3265. else
  3266. {
  3267. $start = ($page - 1)*$perpage;
  3268. }
  3269. //取得信息列表
  3270. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str);
  3271. //格式化数据
  3272. // foreach ($info_list as $key=>$value)
  3273. // {
  3274. // $shop = $this->shop->read($value['shop']);
  3275. // $info_list[$key]['shop'] = $shop['shopname'];
  3276. // if($value['waybill'] == '0')
  3277. // {
  3278. // $info_list[$key]['waybill'] = "";
  3279. // }
  3280. // $express = $this->express->read($value['express']);
  3281. // $info_list[$key]['express'] = $express['servicename'];
  3282. // $warehouse = $this->warehouse->read($value['type']);
  3283. // $info_list[$key]['type'] = $warehouse['title'];
  3284. // if($value['print'] == 1)
  3285. // {
  3286. // $info_list[$key]['print'] = '不可打印';
  3287. // }
  3288. // else if($value['print'] == 2)
  3289. // {
  3290. // $info_list[$key]['print'] = '未打印';
  3291. // }
  3292. // else if($value['print'] == 3)
  3293. // {
  3294. // $info_list[$key]['print'] = '已打印';
  3295. // }
  3296. // if($value['library'] == 1)
  3297. // {
  3298. // $info_list[$key]['library'] = '<em class="c">未出库</em>';
  3299. // }
  3300. // else if($value['library'] == 2)
  3301. // {
  3302. // $info_list[$key]['library'] = '<em class="c">已出库</em>';
  3303. // }
  3304. // else if($value['library'] == 3)
  3305. // {
  3306. // $info_list[$key]['library'] = '<em class="c">已退库</em>';
  3307. // }
  3308. // if($value['librarytime'] == '0')
  3309. // {
  3310. // $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3311. // }
  3312. // else
  3313. // {
  3314. // $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  3315. // }
  3316. // $info_list[$key]['orderremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['orderremarks']);
  3317. // }
  3318. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str);
  3319. //格式化数据
  3320. // foreach ($info_listtt as $key=>$value)
  3321. // {
  3322. // $shop = $this->shop->read($value['shop']);
  3323. // $info_listtt[$key]['shop'] = $shop['shopname'];
  3324. // if($value['waybill'] == '0')
  3325. // {
  3326. // $info_listtt[$key]['waybill'] = "";
  3327. // }
  3328. // $express = $this->express->read($value['express']);
  3329. // $info_listtt[$key]['express'] = $express['servicename'];
  3330. // $warehouse = $this->warehouse->read($value['type']);
  3331. // $info_listtt[$key]['type'] = $warehouse['title'];
  3332. // if($value['print'] == 1)
  3333. // {
  3334. // $info_listtt[$key]['print'] = '不可打印';
  3335. // }
  3336. // else if($value['print'] == 2)
  3337. // {
  3338. // $info_listtt[$key]['print'] = '未打印';
  3339. // }
  3340. // else if($value['print'] == 3)
  3341. // {
  3342. // $info_listtt[$key]['print'] = '已打印';
  3343. // }
  3344. // if($value['library'] == 1)
  3345. // {
  3346. // $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  3347. // }
  3348. // else if($value['library'] == 2)
  3349. // {
  3350. // $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  3351. // }
  3352. // else if($value['library'] == 3)
  3353. // {
  3354. // $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  3355. // }
  3356. // if($value['librarytime'] == '0')
  3357. // {
  3358. // $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  3359. // }
  3360. // else
  3361. // {
  3362. // $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3363. // }
  3364. // }
  3365. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str);
  3366. //格式化数据
  3367. // foreach ($info_listamz as $key=>$value)
  3368. // {
  3369. // $shop = $this->shop->read($value['shop']);
  3370. // $info_listamz[$key]['shop'] = $shop['shopname'];
  3371. // if($value['waybill'] == '0')
  3372. // {
  3373. // $info_listamz[$key]['waybill'] = "";
  3374. // }
  3375. // $express = $this->express->read($value['express']);
  3376. // $info_listamz[$key]['express'] = $express['servicename'];
  3377. // $warehouse = $this->warehouse->read($value['type']);
  3378. // $info_listamz[$key]['type'] = $warehouse['title'];
  3379. // if($value['print'] == 1)
  3380. // {
  3381. // $info_listamz[$key]['print'] = '不可打印';
  3382. // }
  3383. // else if($value['print'] == 2)
  3384. // {
  3385. // $info_listamz[$key]['print'] = '未打印';
  3386. // }
  3387. // else if($value['print'] == 3)
  3388. // {
  3389. // $info_listamz[$key]['print'] = '已打印';
  3390. // }
  3391. // if($value['library'] == 1)
  3392. // {
  3393. // $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  3394. // }
  3395. // else if($value['library'] == 2)
  3396. // {
  3397. // $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  3398. // }
  3399. // else if($value['library'] == 3)
  3400. // {
  3401. // $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  3402. // }
  3403. // if($value['librarytime'] == '0')
  3404. // {
  3405. // $info_listamz[$key]['librarytime'] = '<em class="t"></em>';
  3406. // }
  3407. // else
  3408. // {
  3409. // $info_listamz[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3410. // }
  3411. // }
  3412. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str);
  3413. //格式化数据
  3414. // foreach ($info_listxw as $key=>$value)
  3415. // {
  3416. // $shop = $this->shop->read($value['shop']);
  3417. // $info_listxw[$key]['shop'] = $shop['shopname'];
  3418. // if($value['waybill'] == '0')
  3419. // {
  3420. // $info_listxw[$key]['waybill'] = "";
  3421. // }
  3422. // $express = $this->express->read($value['express']);
  3423. // $info_listxw[$key]['express'] = $express['servicename'];
  3424. // $warehouse = $this->warehouse->read($value['type']);
  3425. // $info_listxw[$key]['type'] = $warehouse['title'];
  3426. // if($value['print'] == 1)
  3427. // {
  3428. // $info_listxw[$key]['print'] = '不可打印';
  3429. // }
  3430. // else if($value['print'] == 2)
  3431. // {
  3432. // $info_listxw[$key]['print'] = '未打印';
  3433. // }
  3434. // else if($value['print'] == 3)
  3435. // {
  3436. // $info_listxw[$key]['print'] = '已打印';
  3437. // }
  3438. // if($value['library'] == 1)
  3439. // {
  3440. // $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  3441. // }
  3442. // else if($value['library'] == 2)
  3443. // {
  3444. // $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  3445. // }
  3446. // else if($value['library'] == 3)
  3447. // {
  3448. // $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  3449. // }
  3450. // if($value['librarytime'] == '0')
  3451. // {
  3452. // $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  3453. // }
  3454. // else
  3455. // {
  3456. // $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3457. // }
  3458. // }
  3459. $info_listsmt = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str);
  3460. //格式化数据
  3461. // foreach ($info_listsmt as $key=>$value)
  3462. // {
  3463. // $shop = $this->shop->read($value['shop']);
  3464. // $info_listsmt[$key]['shop'] = $shop['shopname'];
  3465. // if($value['waybill'] == '0')
  3466. // {
  3467. // $info_listsmt[$key]['waybill'] = "";
  3468. // }
  3469. // $express = $this->express->read($value['express']);
  3470. // $info_listsmt[$key]['express'] = $express['servicename'];
  3471. // $warehouse = $this->warehouse->read($value['type']);
  3472. // $info_listsmt[$key]['type'] = $warehouse['title'];
  3473. // if($value['print'] == 1)
  3474. // {
  3475. // $info_listsmt[$key]['print'] = '不可打印';
  3476. // }
  3477. // else if($value['print'] == 2)
  3478. // {
  3479. // $info_listsmt[$key]['print'] = '未打印';
  3480. // }
  3481. // else if($value['print'] == 3)
  3482. // {
  3483. // $info_listsmt[$key]['print'] = '已打印';
  3484. // }
  3485. // if($value['library'] == 1)
  3486. // {
  3487. // $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  3488. // }
  3489. // else if($value['library'] == 2)
  3490. // {
  3491. // $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  3492. // }
  3493. // else if($value['library'] == 3)
  3494. // {
  3495. // $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  3496. // }
  3497. // if($value['librarytime'] == '0')
  3498. // {
  3499. // $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  3500. // }
  3501. // else
  3502. // {
  3503. // $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3504. // }
  3505. // }
  3506. // $total = $this->fullorder->find_count($where);
  3507. // $total += $this->fullordertt->find_count($where);
  3508. // $total += $this->fullorderamz->find_count($where);
  3509. // $total += $this->fullorderxw->find_count($where);
  3510. // $total += $this->fullordersmt->find_count($where);
  3511. $total_list = array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt);
  3512. $sort_list = [];
  3513. foreach($total_list as $key => $value){
  3514. $tmp_librarytime = (int)($value['librarytime']."0000");
  3515. if(isset($sort_list[$tmp_librarytime])){
  3516. $tmp_librarytime =(int)($value['librarytime'].rand(1000,9999));
  3517. $sort_list[$tmp_librarytime] = $value;
  3518. }else{
  3519. $sort_list[$tmp_librarytime] = $value;
  3520. }
  3521. }
  3522. krsort($sort_list);
  3523. if(!empty($sort_list)){
  3524. $split_list = array_chunk($sort_list, $perpage, true);
  3525. $shop_list = $this->shop->find_all('1=1');
  3526. $shop_arr = array_column($shop_list,'shopname','id');
  3527. $express_list = $this->express->find_all('1=1');
  3528. $express_arr = array_column($express_list,'servicename','id');
  3529. $warehouse_list = $this->warehouse->find_all('1=1');
  3530. $warehouse_arr = array_column($warehouse_list,'title','id');
  3531. $final_list = $split_list[$page-1];
  3532. foreach ($final_list as $key=>$value)
  3533. {
  3534. $final_list[$key]['shop'] = isset($shop_arr[$value['shop']])? $shop_arr[$value['shop']] :"";
  3535. if($value['waybill'] == '0')
  3536. {
  3537. $final_list[$key]['waybill'] = "";
  3538. }
  3539. $final_list[$key]['express'] = isset($express_arr[$value['express']])? $express_arr[$value['express']] :"";
  3540. $final_list[$key]['type'] = isset($warehouse_arr[$value['type']])? $warehouse_arr[$value['type']] :"";
  3541. if($value['print'] == 1)
  3542. {
  3543. $final_list[$key]['print'] = '不可打印';
  3544. }
  3545. else if($value['print'] == 2)
  3546. {
  3547. $final_list[$key]['print'] = '未打印';
  3548. }
  3549. else if($value['print'] == 3)
  3550. {
  3551. $final_list[$key]['print'] = '已打印';
  3552. }
  3553. if($value['library'] == 1)
  3554. {
  3555. $final_list[$key]['library'] = '<em class="c">未出库</em>';
  3556. }
  3557. else if($value['library'] == 2)
  3558. {
  3559. $final_list[$key]['library'] = '<em class="c">已出库</em>';
  3560. }
  3561. else if($value['library'] == 3)
  3562. {
  3563. $final_list[$key]['library'] = '<em class="c">已退库</em>';
  3564. }
  3565. if($value['librarytime'] == '0')
  3566. {
  3567. $final_list[$key]['librarytime'] = '<em class="t"></em>';
  3568. }
  3569. else
  3570. {
  3571. $final_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3572. }
  3573. }
  3574. $final_list = array_values($final_list);
  3575. }else{
  3576. $final_list = [];
  3577. }
  3578. $total = count($total_list);
  3579. $pagenum = ceil($total/$perpage);
  3580. $over = $total-($start+$perpage);
  3581. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_list));
  3582. echo json_encode($rows);exit;
  3583. }
  3584. if(isset($_SESSION['api']))
  3585. {
  3586. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3587. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  3588. $this->data['wlshop'] = $wlshop;
  3589. $this->data['warehouse'] = $warehouse;
  3590. }
  3591. $this->data['xw'] = $xw;
  3592. $this->_Template('systemfout_hb',$this->data);
  3593. }
  3594. }