Systemfout.php 125 KB

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