Systemfout.php 110 KB

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