Systemfout.php 111 KB

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