Systemfout.php 100 KB

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