Systemfout.php 124 KB

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