Systemfout.php 117 KB

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