Systemfout.php 118 KB

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