Systemfout.php 111 KB

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