Systemfout.php 100 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989
  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. $wh = $this->_fout_db($v,$warehouse,$bdck);
  832. foreach ($wh['sj'] as $vv)
  833. {
  834. $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$v['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$vv['id']);
  835. }
  836. //$this->ck->get_kc($post['state'],$vwarehouse,$vshop,$v['number'],$v['whlabel'],$v['fpdata']);
  837. }
  838. if ($this->db->trans_status() === TRUE)
  839. {
  840. $this->db->trans_commit();
  841. echo json_encode(array('success'=>true));
  842. }
  843. else
  844. {
  845. $this->db->trans_rollback();
  846. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));
  847. }
  848. }
  849. }
  850. public function _outnumber()//对比占单是否正确
  851. {
  852. $post = $this->input->post(NULL, TRUE);
  853. if(isset($post['outnumber']))
  854. {
  855. $post = $this->input->post('post',true);
  856. $fullorder_name = $this->input->post('fullorder_name',true);
  857. $outnumber = $this->input->post('outnumber',true);
  858. $post = json_decode($post,true);
  859. $this->$fullorder_name->save($post,$outnumber);
  860. }
  861. }
  862. public function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
  863. {
  864. $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
  865. $cpsl = 0;
  866. $pp = explode('|',trim($y['whlabel'],'|'));
  867. foreach ($pp as $va)
  868. {
  869. $num = explode('-',$va);
  870. if(isset($num[2]))
  871. {
  872. if(stripos($num[2],$warehouse['hz']) !== false)
  873. {
  874. $cpsl += $num[1];
  875. }
  876. }
  877. }
  878. if(count($wh) == $cpsl)
  879. {
  880. return array('fh'=>1,'sj'=>$wh);
  881. }
  882. else
  883. {
  884. return array('fh'=>2);
  885. }
  886. }
  887. public function _fedexhz()
  888. {
  889. $post = $this->input->post(NULL, TRUE);
  890. if(isset($post['id']))
  891. {
  892. $id = $this->input->post('id',true);
  893. $fullorder_name = $this->input->post('name',true);
  894. $express = $this->input->post('express',true);
  895. $express = $this->express->read($express);
  896. $fullorder = $this->$fullorder_name->read($id);
  897. if($fullorder['type'] == '2')
  898. {
  899. $fullorder['type'] = 1;
  900. }
  901. $time = time();
  902. $fullorder = $this->_text($fullorder);//获取所需信息
  903. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  904. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  905. $time = time();
  906. if($express['printcode'] == "FEDEXGF")
  907. {
  908. $barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  909. if($barcode['x'] == 1)
  910. {
  911. $bctime = date('Ymd',$time);
  912. $Hwaybill = $barcode['waybill'];
  913. $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  914. $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  915. if(isset($barcode['label']) && isset($Hwaybill))
  916. {
  917. if($fullorder['waybill'] != "")
  918. {
  919. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  920. }
  921. else
  922. {
  923. $oldwaybill = $fullorder['oldwaybill'];
  924. }
  925. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  926. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  927. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  928. {
  929. $warehouse = $this->warehouse->read($fullorder['type']);
  930. $text = array();
  931. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  932. $text['number'] = $fullorder['number'];
  933. $text['mode'] = '95';
  934. $text['pdfnum'] = 1;
  935. $rows = array('text'=>$text);
  936. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  937. }
  938. else
  939. {
  940. echo json_encode(array($fullorder['number'].'msg'=>'打印错误,请联系店员','cw'=>'写入数据库错误','success'=>false));exit;
  941. }
  942. }
  943. }
  944. else
  945. {
  946. echo json_encode(array('msg'=>'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  947. }
  948. }
  949. else if($express['printcode'] == "UPS")//接口UPS暂时不打
  950. {
  951. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会处理','success'=>false));exit;
  952. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  953. if($barcode['x'] == 1)
  954. {
  955. $bctime = date('Ymd',$time);
  956. $Hwaybill = $barcode['waybill'];
  957. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  958. if(isset($barcode['label']) && isset($Hwaybill))
  959. {
  960. if($fullorder['waybill'] != "")
  961. {
  962. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  963. }
  964. else
  965. {
  966. $oldwaybill = $fullorder['oldwaybill'];
  967. }
  968. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  969. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  970. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  971. {
  972. $type = 1;
  973. $text = array('yd'=>'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','data'=>$fullorder,'id'=>$fullorder['id'],'pt'=>$fullorder_name);
  974. }
  975. }
  976. }
  977. else
  978. {
  979. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  980. }
  981. }
  982. else if($express['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  983. {
  984. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  985. if($barcode['c'] == 1)
  986. {
  987. $bctime = date('Ymd',$time);
  988. $Hwaybill = $barcode['data']['waybill'];
  989. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  990. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  991. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  992. {
  993. if($fullorder['waybill'] != "")
  994. {
  995. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  996. }
  997. else
  998. {
  999. $oldwaybill = $fullorder['oldwaybill'];
  1000. }
  1001. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1002. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删d
  1003. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$fullorder['id']))
  1004. {
  1005. $warehouse = $this->warehouse->read($fullorder['type']);
  1006. $text = array();
  1007. $text['yd'] = base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  1008. $text['number'] = $fullorder['number'];
  1009. $text['mode'] = '95';
  1010. $text['pdfnum'] = 1;
  1011. $rows = array('text'=>$text);
  1012. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1013. }
  1014. }
  1015. }
  1016. else
  1017. {
  1018. echo json_encode(array('msg'=>$fullorder['number'].'打印错误,请联系店员','cw'=>$barcode['Description'],'success'=>false));exit;
  1019. }
  1020. }
  1021. else
  1022. {
  1023. echo json_encode(array('msg'=>'此订单超期无法出库,请联系成会或者梦体处理','success'=>false));exit;
  1024. }
  1025. }
  1026. }
  1027. public function _text($fullorder)
  1028. {
  1029. /** 发票地址信息暂时无用
  1030. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1031. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1032. $fullorder['baddress'][1] = $country['ename'];
  1033. **/
  1034. //获取所用相关信息
  1035. $warehouse = $this->warehouse->read($fullorder['type']);
  1036. $country = $this->country->read($fullorder['country']);//订单国家信息
  1037. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1038. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1039. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1040. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1041. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1042. $fullorder['country'] = $country['ename'];//订单国家名
  1043. $fullorder['zhou'] = $country['continent'];//所属州
  1044. $express = $this->express->read($fullorder['express']);
  1045. $fullorder['express'] = $express['servicename'];
  1046. $fullorder['account'] = $express['account'];
  1047. $fullorder['printcode'] = $express['printcode'];
  1048. $fullorder['time'] = date('Y-m-d',time());
  1049. $fullorder['times'] = date('Y-m-d H:i',time());
  1050. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1051. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1052. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1053. $shop = $this->shop->read($fullorder['shop']);
  1054. $fullorder['shop'] = $shop['shopname'];
  1055. return $fullorder;
  1056. }
  1057. public function _lowe()
  1058. {
  1059. $post = $this->input->post(NULL, TRUE);
  1060. if(isset($post['lowe']))
  1061. {
  1062. $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');
  1063. echo json_encode(array('msg'=>$lowe));exit;
  1064. }
  1065. }
  1066. public function _pdf($pdf,$title,$bctime)
  1067. {
  1068. $pdf_path = './data/pdf/'.$bctime.'/';
  1069. $file_base64 = $pdf;
  1070. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1071. $file_base64 = base64_decode($file_base64);
  1072. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1073. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1074. return $bctime;
  1075. }
  1076. public function _pdfurl($pdf,$title,$bctime)
  1077. {
  1078. $pdf_path = './data/pdf/'.$bctime.'/';
  1079. $pdf = fopen($pdf,"r");
  1080. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1081. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1082. return $bctime;
  1083. }
  1084. public function _excel()
  1085. {
  1086. $xw = '';
  1087. if(isset($_SESSION['api']))
  1088. {
  1089. $user = $this->user->get_api($_SESSION['api']);
  1090. $usp = $user;
  1091. $fgshop = "";$sid = "";$wid="";$wtype="";
  1092. $usersp = explode('|',trim($user['shop'],'|'));
  1093. $userwh = explode('|',trim($user['warehouse'],'|'));
  1094. foreach ($usersp as $value)
  1095. {
  1096. $fgshop .= " shop = ".$value." or";
  1097. $sid .= " id = ".$value." or";
  1098. }
  1099. foreach ($userwh as $value)
  1100. {
  1101. $wid .= " id = ".$value." or";
  1102. $wtype .= " type = ".$value." or";
  1103. }
  1104. if($user['userid'] == 'xw')
  1105. {
  1106. $xw = 1;
  1107. }
  1108. }
  1109. if(isset($_GET['fexcel']))
  1110. {
  1111. $dowid = $this->input->get('a');
  1112. $wid = "";
  1113. if($dowid != "")
  1114. {
  1115. $id_arr = explode(',',rtrim($dowid,','));
  1116. foreach ($id_arr as $v)
  1117. {
  1118. $wid .= " id = '$v' or";
  1119. }
  1120. $wid = " and".rtrim($wid,'or');
  1121. }
  1122. $t = $this->input->get('t',true);
  1123. $timetk = $this->input->get('timetk',true);
  1124. $timetj = $this->input->get('timetj',true);
  1125. $shop = $this->input->get('shop',true);
  1126. $source = $this->input->get('source',true);
  1127. $orderinfo = $this->input->get('orderinfo',true);
  1128. $number = $this->input->get('number',true);
  1129. $library = $this->input->get('library',true);
  1130. $waybill = $this->input->get('waybill',true);
  1131. $express = $this->input->get('express',true);
  1132. $type = $this->input->get('type',true);
  1133. $so = $this->input->get('so',true);
  1134. $timetk = strtotime($timetk);
  1135. $timetj = strtotime($timetj);
  1136. $where = (isset($_SESSION['api']))?"library!=3 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0'";
  1137. if($timetk && $timetj && $library == 1)
  1138. {
  1139. //$cxtime = 'reviewtime';
  1140. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  1141. $where .= " and state != 217";
  1142. }
  1143. else if($timetk && $timetj && $library == 2)
  1144. {
  1145. $cxtime = 'librarytime';
  1146. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1147. }
  1148. /**
  1149. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  1150. if($timetk && $timetj && $library == 1)
  1151. {
  1152. //$cxtime = 'reviewtime';
  1153. //$where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1154. }
  1155. else if($timetk && $timetj && $library == 2)
  1156. {
  1157. $cxtime = 'librarytime';
  1158. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1159. }
  1160. **/
  1161. if(isset($_SESSION['api']))
  1162. {
  1163. if($type)
  1164. {
  1165. $where .= " and type = '$type'";
  1166. }
  1167. else
  1168. {
  1169. $uw = '';
  1170. $u = $this->user->get_api($_SESSION['api']);
  1171. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1172. foreach ($u['warehouse'] as $v)
  1173. {
  1174. $uw .= " type = '$v' or";
  1175. }
  1176. $uw = rtrim($uw,'or');
  1177. $uw = " and (".ltrim($uw,' ').")";
  1178. $where .= $uw;
  1179. }
  1180. }
  1181. else
  1182. {
  1183. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1184. }
  1185. if($shop)
  1186. {
  1187. $where .= " and shop = '$shop'";
  1188. }
  1189. if($number)
  1190. {
  1191. $where .= " and number = '$number'";
  1192. }
  1193. if($library)
  1194. {
  1195. $where .= " and library = '$library'";
  1196. }
  1197. if($waybill)
  1198. {
  1199. $where .= " and waybill = '$waybill'";
  1200. }
  1201. if($express)
  1202. {
  1203. $where .= " and express = '$express'";
  1204. }
  1205. if($orderinfo)
  1206. {
  1207. $where .= " and orderinfo = '$orderinfo'";
  1208. }
  1209. if($so)
  1210. {
  1211. $where .= " and shipremarks like '%$so%'";
  1212. }
  1213. //数据排序
  1214. //$order_str = ($print != 3)?"id desc":"librarytime desc";
  1215. $order_str = "librarytime desc";
  1216. if(empty($page))
  1217. {
  1218. $start = 0;
  1219. $perpage = 1;
  1220. }
  1221. else
  1222. {
  1223. $start = ($page - 1)*$perpage;
  1224. }
  1225. $typeclass = array();
  1226. $tclass = $this->typeclass->find_all();
  1227. foreach ($tclass as $v)
  1228. {
  1229. $typeclass[$v['id']] = $v;
  1230. }
  1231. //取得信息列表
  1232. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1233. //格式化数据
  1234. foreach ($info_list as $key=>$value)
  1235. {
  1236. $shop = $this->shop->read($value['shop']);
  1237. $info_list[$key]['shop'] = $shop['shopname'];
  1238. if($value['waybill'] == '0')
  1239. {
  1240. $info_list[$key]['waybill'] = "";
  1241. }
  1242. $express = $this->express->read($value['express']);
  1243. $info_list[$key]['express'] = $express['servicename'];
  1244. $warehouse = $this->warehouse->read($value['type']);
  1245. $info_list[$key]['type'] = $warehouse['title'];
  1246. if($value['print'] == 1)
  1247. {
  1248. $info_list[$key]['print'] = '不可打印';
  1249. }
  1250. else if($value['print'] == 2)
  1251. {
  1252. $info_list[$key]['print'] = '未打印';
  1253. }
  1254. else if($value['print'] == 3)
  1255. {
  1256. $info_list[$key]['print'] = '已打印';
  1257. }
  1258. if($value['library'] == 1)
  1259. {
  1260. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  1261. }
  1262. else if($value['library'] == 2)
  1263. {
  1264. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  1265. }
  1266. else if($value['library'] == 3)
  1267. {
  1268. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  1269. }
  1270. if($value['librarytime'] == '0')
  1271. {
  1272. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  1273. }
  1274. else
  1275. {
  1276. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1277. }
  1278. $classid = $classid = $this->classid->sku();
  1279. $dbapi = explode(';',trim($value['fpdata'],';'));
  1280. foreach ($dbapi as $va)
  1281. {
  1282. $pm = $classid;
  1283. $jm = $classid;
  1284. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1285. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1286. $ts = explode('|',trim($features,'|'));
  1287. if(stripos($ts[0],',') !== false)
  1288. {
  1289. $ft = explode(',',$ts[0]);
  1290. $features = explode('-',trim($ft[1],'-'));
  1291. $features[] = $ft[0];
  1292. }
  1293. else
  1294. {
  1295. $features = explode('-',trim($ts[0],'-'));
  1296. }
  1297. foreach($features as $k=>$v)
  1298. {
  1299. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1300. {
  1301. if($typeclass[$v]['bm'] != '')
  1302. {
  1303. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1304. }
  1305. }
  1306. if($v != 0 && isset($typeclass[$v]))
  1307. {
  1308. if($typeclass[$v]['classid'] == 13)
  1309. {
  1310. $dj = $typeclass[$v]['title'];
  1311. }
  1312. if($typeclass[$v]['classid'] == 8)
  1313. {
  1314. $ys = $typeclass[$v]['title'];
  1315. }
  1316. if($typeclass[$v]['classid'] == 15)
  1317. {
  1318. $hx = $typeclass[$v]['title'];
  1319. }
  1320. if(isset($pm[$typeclass[$v]['classid']]))
  1321. {
  1322. if($typeclass[$v]['title'] == '9A')
  1323. {
  1324. $pm[$typeclass[$v]['classid']] = '9A';
  1325. }
  1326. else if($typeclass[$v]['title'] == '10A')
  1327. {
  1328. $pm[$typeclass[$v]['classid']] = '10A';
  1329. }
  1330. else
  1331. {
  1332. $clzh = $typeclass[$v]['zh'];
  1333. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1334. {
  1335. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1336. $clzh = $clzh[0];
  1337. }
  1338. $pm[$typeclass[$v]['classid']] = $clzh;
  1339. }
  1340. }
  1341. if(isset($jm[$typeclass[$v]['classid']]))
  1342. {
  1343. if($typeclass[$v]['jm'])
  1344. {
  1345. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1346. }
  1347. }
  1348. }
  1349. }
  1350. $jm = array_filter($jm);//去除空值
  1351. $jm = implode("-",$jm);
  1352. $pm = array_filter($pm);//去除空值
  1353. $zh = implode(" ",$pm);
  1354. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1355. }
  1356. $info_list[$key]['jm'] = $jm;
  1357. $info_list[$key]['zh'] = $zh;
  1358. }
  1359. //取得信息列表
  1360. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1361. //格式化数据
  1362. foreach ($info_listsmt as $key=>$value)
  1363. {
  1364. $shop = $this->shop->read($value['shop']);
  1365. $info_listsmt[$key]['shop'] = $shop['shopname'];
  1366. if($value['waybill'] == '0')
  1367. {
  1368. $info_listsmt[$key]['waybill'] = "";
  1369. }
  1370. $express = $this->express->read($value['express']);
  1371. $info_listsmt[$key]['express'] = $express['servicename'];
  1372. $warehouse = $this->warehouse->read($value['type']);
  1373. $info_listsmt[$key]['type'] = $warehouse['title'];
  1374. if($value['print'] == 1)
  1375. {
  1376. $info_listsmt[$key]['print'] = '不可打印';
  1377. }
  1378. else if($value['print'] == 2)
  1379. {
  1380. $info_listsmt[$key]['print'] = '未打印';
  1381. }
  1382. else if($value['print'] == 3)
  1383. {
  1384. $info_listsmt[$key]['print'] = '已打印';
  1385. }
  1386. if($value['library'] == 1)
  1387. {
  1388. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  1389. }
  1390. else if($value['library'] == 2)
  1391. {
  1392. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  1393. }
  1394. else if($value['library'] == 3)
  1395. {
  1396. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  1397. }
  1398. if($value['librarytime'] == '0')
  1399. {
  1400. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  1401. }
  1402. else
  1403. {
  1404. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1405. }
  1406. $classid = $classid = $this->classid->sku();
  1407. $dbapi = explode(';',trim($value['fpdata'],';'));
  1408. foreach ($dbapi as $va)
  1409. {
  1410. $pm = $classid;
  1411. $jm = $classid;
  1412. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1413. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1414. $ts = explode('|',trim($features,'|'));
  1415. if(stripos($ts[0],',') !== false)
  1416. {
  1417. $ft = explode(',',$ts[0]);
  1418. $features = explode('-',trim($ft[1],'-'));
  1419. $features[] = $ft[0];
  1420. }
  1421. else
  1422. {
  1423. $features = explode('-',trim($ts[0],'-'));
  1424. }
  1425. foreach($features as $k=>$v)
  1426. {
  1427. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1428. {
  1429. if($typeclass[$v]['bm'] != '')
  1430. {
  1431. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1432. }
  1433. }
  1434. if($v != 0 && isset($typeclass[$v]))
  1435. {
  1436. if($typeclass[$v]['classid'] == 13)
  1437. {
  1438. $dj = $typeclass[$v]['title'];
  1439. }
  1440. if($typeclass[$v]['classid'] == 8)
  1441. {
  1442. $ys = $typeclass[$v]['title'];
  1443. }
  1444. if($typeclass[$v]['classid'] == 15)
  1445. {
  1446. $hx = $typeclass[$v]['title'];
  1447. }
  1448. if(isset($pm[$typeclass[$v]['classid']]))
  1449. {
  1450. if($typeclass[$v]['title'] == '9A')
  1451. {
  1452. $pm[$typeclass[$v]['classid']] = '9A';
  1453. }
  1454. else if($typeclass[$v]['title'] == '10A')
  1455. {
  1456. $pm[$typeclass[$v]['classid']] = '10A';
  1457. }
  1458. else
  1459. {
  1460. $clzh = $typeclass[$v]['zh'];
  1461. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1462. {
  1463. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1464. $clzh = $clzh[0];
  1465. }
  1466. $pm[$typeclass[$v]['classid']] = $clzh;
  1467. }
  1468. }
  1469. if(isset($jm[$typeclass[$v]['classid']]))
  1470. {
  1471. if($typeclass[$v]['jm'])
  1472. {
  1473. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1474. }
  1475. }
  1476. }
  1477. }
  1478. $jm = array_filter($jm);//去除空值
  1479. $jm = implode("-",$jm);
  1480. $pm = array_filter($pm);//去除空值
  1481. $zh = implode(" ",$pm);
  1482. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1483. }
  1484. $info_listsmt[$key]['jm'] = $jm;
  1485. $info_listsmt[$key]['zh'] = $zh;
  1486. }
  1487. //取得信息列表
  1488. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1489. //格式化数据
  1490. foreach ($info_listtt as $key=>$value)
  1491. {
  1492. $shop = $this->shop->read($value['shop']);
  1493. $info_listtt[$key]['shop'] = $shop['shopname'];
  1494. if($value['waybill'] == '0')
  1495. {
  1496. $info_listtt[$key]['waybill'] = "";
  1497. }
  1498. $express = $this->express->read($value['express']);
  1499. $info_listtt[$key]['express'] = $express['servicename'];
  1500. $warehouse = $this->warehouse->read($value['type']);
  1501. $info_listtt[$key]['type'] = $warehouse['title'];
  1502. if($value['print'] == 1)
  1503. {
  1504. $info_listtt[$key]['print'] = '不可打印';
  1505. }
  1506. else if($value['print'] == 2)
  1507. {
  1508. $info_listtt[$key]['print'] = '未打印';
  1509. }
  1510. else if($value['print'] == 3)
  1511. {
  1512. $info_listtt[$key]['print'] = '已打印';
  1513. }
  1514. if($value['library'] == 1)
  1515. {
  1516. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  1517. }
  1518. else if($value['library'] == 2)
  1519. {
  1520. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  1521. }
  1522. else if($value['library'] == 3)
  1523. {
  1524. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  1525. }
  1526. if($value['librarytime'] == '0')
  1527. {
  1528. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  1529. }
  1530. else
  1531. {
  1532. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1533. }
  1534. $classid = $classid = $this->classid->sku();
  1535. $dbapi = explode(';',trim($value['fpdata'],';'));
  1536. foreach ($dbapi as $va)
  1537. {
  1538. $pm = $classid;
  1539. $jm = $classid;
  1540. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1541. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1542. $ts = explode('|',trim($features,'|'));
  1543. if(stripos($ts[0],',') !== false)
  1544. {
  1545. $ft = explode(',',$ts[0]);
  1546. $features = explode('-',trim($ft[1],'-'));
  1547. $features[] = $ft[0];
  1548. }
  1549. else
  1550. {
  1551. $features = explode('-',trim($ts[0],'-'));
  1552. }
  1553. foreach($features as $k=>$v)
  1554. {
  1555. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1556. {
  1557. if($typeclass[$v]['bm'] != '')
  1558. {
  1559. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1560. }
  1561. }
  1562. if($v != 0 && isset($typeclass[$v]))
  1563. {
  1564. if($typeclass[$v]['classid'] == 13)
  1565. {
  1566. $dj = $typeclass[$v]['title'];
  1567. }
  1568. if($typeclass[$v]['classid'] == 8)
  1569. {
  1570. $ys = $typeclass[$v]['title'];
  1571. }
  1572. if($typeclass[$v]['classid'] == 15)
  1573. {
  1574. $hx = $typeclass[$v]['title'];
  1575. }
  1576. if(isset($pm[$typeclass[$v]['classid']]))
  1577. {
  1578. if($typeclass[$v]['title'] == '9A')
  1579. {
  1580. $pm[$typeclass[$v]['classid']] = '9A';
  1581. }
  1582. else if($typeclass[$v]['title'] == '10A')
  1583. {
  1584. $pm[$typeclass[$v]['classid']] = '10A';
  1585. }
  1586. else
  1587. {
  1588. $clzh = $typeclass[$v]['zh'];
  1589. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1590. {
  1591. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1592. $clzh = $clzh[0];
  1593. }
  1594. $pm[$typeclass[$v]['classid']] = $clzh;
  1595. }
  1596. }
  1597. if(isset($jm[$typeclass[$v]['classid']]))
  1598. {
  1599. if($typeclass[$v]['jm'])
  1600. {
  1601. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1602. }
  1603. }
  1604. }
  1605. }
  1606. $jm = array_filter($jm);//去除空值
  1607. $jm = implode("-",$jm);
  1608. $pm = array_filter($pm);//去除空值
  1609. $zh = implode(" ",$pm);
  1610. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1611. }
  1612. $info_listtt[$key]['jm'] = $jm;
  1613. $info_listtt[$key]['zh'] = $zh;
  1614. }
  1615. //取得信息列表
  1616. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks,ts,fpdata',$order_str);
  1617. //格式化数据
  1618. foreach ($info_listxw as $key=>$value)
  1619. {
  1620. $shop = $this->shop->read($value['shop']);
  1621. $info_listxw[$key]['shop'] = $shop['shopname'];
  1622. if($value['waybill'] == '0')
  1623. {
  1624. $info_listxw[$key]['waybill'] = "";
  1625. }
  1626. $express = $this->express->read($value['express']);
  1627. $info_listxw[$key]['express'] = $express['servicename'];
  1628. $warehouse = $this->warehouse->read($value['type']);
  1629. $info_listxw[$key]['type'] = $warehouse['title'];
  1630. if($value['print'] == 1)
  1631. {
  1632. $info_listxw[$key]['print'] = '不可打印';
  1633. }
  1634. else if($value['print'] == 2)
  1635. {
  1636. $info_listxw[$key]['print'] = '未打印';
  1637. }
  1638. else if($value['print'] == 3)
  1639. {
  1640. $info_listxw[$key]['print'] = '已打印';
  1641. }
  1642. if($value['library'] == 1)
  1643. {
  1644. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  1645. }
  1646. else if($value['library'] == 2)
  1647. {
  1648. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  1649. }
  1650. else if($value['library'] == 3)
  1651. {
  1652. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  1653. }
  1654. if($value['librarytime'] == '0')
  1655. {
  1656. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  1657. }
  1658. else
  1659. {
  1660. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  1661. }
  1662. $classid = $classid = $this->classid->sku();
  1663. $dbapi = explode(';',trim($value['fpdata'],';'));
  1664. foreach ($dbapi as $va)
  1665. {
  1666. $pm = $classid;
  1667. $jm = $classid;
  1668. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1669. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1670. $ts = explode('|',trim($features,'|'));
  1671. if(stripos($ts[0],',') !== false)
  1672. {
  1673. $ft = explode(',',$ts[0]);
  1674. $features = explode('-',trim($ft[1],'-'));
  1675. $features[] = $ft[0];
  1676. }
  1677. else
  1678. {
  1679. $features = explode('-',trim($ts[0],'-'));
  1680. }
  1681. foreach($features as $k=>$v)
  1682. {
  1683. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1684. {
  1685. if($typeclass[$v]['bm'] != '')
  1686. {
  1687. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1688. }
  1689. }
  1690. if($v != 0 && isset($typeclass[$v]))
  1691. {
  1692. if($typeclass[$v]['classid'] == 13)
  1693. {
  1694. $dj = $typeclass[$v]['title'];
  1695. }
  1696. if($typeclass[$v]['classid'] == 8)
  1697. {
  1698. $ys = $typeclass[$v]['title'];
  1699. }
  1700. if($typeclass[$v]['classid'] == 15)
  1701. {
  1702. $hx = $typeclass[$v]['title'];
  1703. }
  1704. if(isset($pm[$typeclass[$v]['classid']]))
  1705. {
  1706. if($typeclass[$v]['title'] == '9A')
  1707. {
  1708. $pm[$typeclass[$v]['classid']] = '9A';
  1709. }
  1710. else if($typeclass[$v]['title'] == '10A')
  1711. {
  1712. $pm[$typeclass[$v]['classid']] = '10A';
  1713. }
  1714. else
  1715. {
  1716. $clzh = $typeclass[$v]['zh'];
  1717. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1718. {
  1719. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1720. $clzh = $clzh[0];
  1721. }
  1722. $pm[$typeclass[$v]['classid']] = $clzh;
  1723. }
  1724. }
  1725. if(isset($jm[$typeclass[$v]['classid']]))
  1726. {
  1727. if($typeclass[$v]['jm'])
  1728. {
  1729. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1730. }
  1731. }
  1732. }
  1733. }
  1734. $jm = array_filter($jm);//去除空值
  1735. $jm = implode("-",$jm);
  1736. $pm = array_filter($pm);//去除空值
  1737. $zh = implode(" ",$pm);
  1738. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1739. }
  1740. $info_listxw[$key]['jm'] = $jm;
  1741. $info_listxw[$key]['zh'] = $zh;
  1742. }
  1743. $title = '订单出库-'.date('Ymd',time());
  1744. $titlename = "<table border=1>".$t."<td>条数</td><td>料品</td><td>品名</td></table>";
  1745. $tail = "\n";
  1746. $filename = $title.".xls";
  1747. $this->excel->get_fz2(array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt),$titlename,$filename,$tail);
  1748. }
  1749. }
  1750. public function _cpexcel()
  1751. {
  1752. if(isset($_SESSION['api']))
  1753. {
  1754. $user = $this->user->get_api($_SESSION['api']);
  1755. $usp = $user;
  1756. $fgshop = "";$sid = "";$excelshop="";
  1757. $usersp = explode('|',trim($user['shop'],'|'));
  1758. foreach ($usersp as $value)
  1759. {
  1760. $fgshop .= " shop = ".$value." or";
  1761. $sid .= " id = ".$value." or";
  1762. }
  1763. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1764. foreach ($userexcel as $value)
  1765. {
  1766. $excelshop .= " shop = ".$value." or";
  1767. }
  1768. if($excelshop != "")
  1769. {
  1770. $excelshop = "(".rtrim($excelshop,'or').")";
  1771. }
  1772. }
  1773. if(isset($_GET['excel']))
  1774. {
  1775. $timetk = $this->input->get('timetk',true);
  1776. $timetj = $this->input->get('timetj',true);
  1777. $shop = $this->input->get('shop',true);
  1778. $library = $this->input->get('library',true);
  1779. $type = $this->input->get('type',true);
  1780. $number = $this->input->get('number',true);
  1781. $orderinfo = $this->input->get('orderinfo',true);
  1782. $so = $this->input->get('so',true);
  1783. $number = $this->input->get('number',true);
  1784. $express = $this->input->get('express',true);
  1785. $timetk = strtotime($timetk);
  1786. $timetj = strtotime($timetj);
  1787. $where = "mergeid = 0";
  1788. if($timetk && $timetj && $library == 2)
  1789. {
  1790. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  1791. }
  1792. else
  1793. {
  1794. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1795. }
  1796. if(isset($_SESSION['api']))
  1797. {
  1798. if($type)
  1799. {
  1800. $where .= " and type = '$type'";
  1801. }
  1802. else
  1803. {
  1804. $uw = '';
  1805. $u = $this->user->get_api($_SESSION['api']);
  1806. $u['warehouse'] = explode('|',trim($u['warehouse'],'|'));
  1807. foreach ($u['warehouse'] as $v)
  1808. {
  1809. $uw .= " type = '$v' or";
  1810. }
  1811. $uw = rtrim($uw,'or');
  1812. $uw = " and (".ltrim($uw,' ').")";
  1813. $where .= $uw;
  1814. }
  1815. }
  1816. else
  1817. {
  1818. echo json_encode(array('msg'=>'导出失败,请重新登陆!','success'=>false));exit;
  1819. }
  1820. if($shop)
  1821. {
  1822. $where .= " and shop = '$shop'";
  1823. }
  1824. else
  1825. {
  1826. $where .= " and ".$excelshop;
  1827. }
  1828. if($library)
  1829. {
  1830. $where .= " and library = '$library'";
  1831. }
  1832. if($number)
  1833. {
  1834. $where .= " and number = '$number'";
  1835. }
  1836. if($orderinfo)
  1837. {
  1838. $where .= " and orderinfo = '$orderinfo'";
  1839. }
  1840. if($so)
  1841. {
  1842. $where .= " and shipremarks like '%$so%'";
  1843. }
  1844. if($express)
  1845. {
  1846. $where .= " and express = '$express'";
  1847. }
  1848. /* 匹配ID加入 */
  1849. $tc = array();
  1850. $typeclass = $this->typeclass->find_all();
  1851. foreach ($typeclass as $v)
  1852. {
  1853. $tc[$v['id']] = $v['title'];
  1854. }
  1855. $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$refundj=0;$cost=0;$lr=0;
  1856. //取得信息列表
  1857. $info_lista = $this->fullordersmt->find_all($where,'fpdata');
  1858. $info_listb = $this->fullorder->find_all($where,'fpdata');
  1859. $info_list = array_merge($info_lista,$info_listb);
  1860. //格式化数据
  1861. $i = 0;$cpexcel = array();
  1862. foreach ($info_list as $key=>$value)
  1863. {
  1864. if(stripos($value['fpdata'],';') !== false)
  1865. {
  1866. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  1867. foreach ($fpdata as $ke=>$va)
  1868. {
  1869. $title = '';
  1870. $fg = explode('|',$va);
  1871. $fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);
  1872. $cp = explode('-',rtrim($fg[0],'-'));
  1873. $dj = $tc[$cp[2]];
  1874. if(!isset($cp[3]))
  1875. {
  1876. $ys = json_encode($cp);
  1877. }
  1878. else
  1879. {
  1880. $ys = $tc[$cp[3]];
  1881. }
  1882. unset($cp[0],$cp[1],$cp[2],$cp[3]);
  1883. foreach ($cp as $v)
  1884. {
  1885. $title .= $tc[$v].' ';
  1886. }
  1887. $cpexcel[$ke] = array($fg[5],$dj,$ys,$title,$fg[2]);//内容,尺寸,等级,颜色,数量
  1888. }
  1889. }
  1890. $i++;
  1891. }
  1892. $title = "统计信息";
  1893. $titlename = "<table border=1>
  1894. <tr>
  1895. <td>尺寸</td>
  1896. <td>等级</td>
  1897. <td>颜色</td>
  1898. <td>花型</td>
  1899. <td>数量</td>
  1900. </tr>
  1901. </table>";
  1902. $filename = $title.".xls";
  1903. $tail = "\n";
  1904. $this->excel->get_fz2($cpexcel,$titlename,$filename,$tail);
  1905. }
  1906. }
  1907. public function _orderyz()
  1908. {
  1909. $post = $this->input->post(NULL, TRUE);
  1910. if(isset($post['yz']))
  1911. {
  1912. $yz = $this->input->post('yz',true);
  1913. $number = $this->input->post('number',true);
  1914. $y = $this->fullorder->get_number($number);
  1915. if(!$y)
  1916. {
  1917. $y = $this->fullordersmt->get_number($number);
  1918. if(!$y)
  1919. {
  1920. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  1921. }
  1922. }
  1923. $whlabel = explode('|',trim($y['whlabel'],'|'));
  1924. foreach($whlabel as $k=>$v)
  1925. {
  1926. $w = explode('-',trim($v,'-'));
  1927. $wldata[$w[0]] = $w;
  1928. }
  1929. $whlabellabel = $this->whlabellabel->get_label($yz);
  1930. if(!$whlabellabel)
  1931. {
  1932. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  1933. }
  1934. else
  1935. {
  1936. if(isset($wldata[$whlabellabel['number']]))
  1937. {
  1938. if(!isset($wldata[$whlabellabel['number']][2]))
  1939. {
  1940. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  1941. }
  1942. else if($wldata[$whlabellabel['number']][2] == 0)
  1943. {
  1944. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  1945. }
  1946. }
  1947. else
  1948. {
  1949. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  1950. }
  1951. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  1952. }
  1953. }
  1954. if(isset($post['number']))
  1955. {
  1956. $number = $this->input->post('number',true);
  1957. $f = 'fullorder';
  1958. $y = $this->fullorder->get_number($number);
  1959. if(!$y)
  1960. {
  1961. $f = 'fullordersmt';
  1962. $y = $this->fullordersmt->get_number($number);
  1963. if(!$y)
  1964. {
  1965. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  1966. }
  1967. }
  1968. if($y['librarytime'] > 0)
  1969. {
  1970. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  1971. }
  1972. $warehouse = $this->warehouse->read($y['type']);
  1973. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  1974. {
  1975. echo json_encode(array('msg'=>'pz','success'=>false));exit;
  1976. }
  1977. $data = explode('|',trim($y['whlabel'],'|'));
  1978. $fpdata = explode(';',trim($y['fpdata'],';'));
  1979. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  1980. foreach($fpdata as $val)
  1981. {
  1982. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  1983. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  1984. $fp = explode('|',$val);
  1985. $fp[0] = str_replace(',','-',$fp[0]);
  1986. $value = explode('-',$fp[0]);
  1987. foreach($value as $v)
  1988. {
  1989. $typeclass = $this->typeclass->read($v);
  1990. $zh = explode('|',trim($typeclass['zh'],'|'));
  1991. $pm[$typeclass['classid']] = $zh[0];
  1992. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  1993. }
  1994. $scsku = implode("-",$scsku);
  1995. $zh = implode(" ",$pm);
  1996. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1997. $scsku = str_replace('- ','-',trim($scsku,'-'));
  1998. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  1999. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2000. $data[$i] = explode('-',$data[$i]);
  2001. for($j=0;$j<$data[$i][1];$j++)
  2002. {
  2003. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2004. {
  2005. $znum++;//只计算现货
  2006. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2007. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2008. }
  2009. else
  2010. {
  2011. //$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');//区别位置模式,暂不使用
  2012. $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');
  2013. }
  2014. $x++;//所有数量
  2015. }
  2016. $i++;
  2017. }
  2018. //ksort($cp);//区别位置模式,暂不使用
  2019. $cp = array_values($cp);
  2020. if($this->$f->save(array('yhs'=>1),$y['id']))
  2021. {
  2022. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2023. }
  2024. else
  2025. {
  2026. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2027. }
  2028. }
  2029. if(isset($post['tid']))
  2030. {
  2031. $typeclass = array();
  2032. $tc = $this->typeclass->find_all();
  2033. foreach($tc as $v)
  2034. {
  2035. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2036. }
  2037. $tid = $this->input->post('tid',true);
  2038. $id = $this->input->post('id',true);
  2039. $number = $this->input->post('n',true);
  2040. $ful = 'fullorder';
  2041. $y = $this->fullorder->get_number($number);
  2042. if(!$y)
  2043. {
  2044. $ful = 'fullordersmt';
  2045. $y = $this->fullordersmt->get_number($number);
  2046. if(!$y)
  2047. {
  2048. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2049. }
  2050. }
  2051. $wtid = $this->whlabellabel->get_label($tid);
  2052. if(!$wtid)
  2053. {
  2054. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2055. }
  2056. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2057. $fpdata = explode(';',trim($y['fpdata'],';'));
  2058. $warehouse = $this->warehouse->read($y['type']);
  2059. $zdkc = $warehouse['bdck'];
  2060. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2061. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2062. if((count($ptc)+count($zsc)) < 1)
  2063. {
  2064. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2065. }
  2066. $this->db->trans_begin();
  2067. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2068. if($zsc)
  2069. {
  2070. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2071. $xrid = $zsc[0]['id'];
  2072. }
  2073. else if($ptc)
  2074. {
  2075. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2076. $xrid = $ptc[0]['id'];
  2077. }
  2078. $xr = $this->$zdkc->read($xrid);
  2079. $features = explode('-',trim($xr['features'],'-'));
  2080. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2081. foreach($features as $kk=>$v)
  2082. {
  2083. if($typeclass[$v]['classid'] == 14)
  2084. {
  2085. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2086. unset($kk);
  2087. }
  2088. }
  2089. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2090. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2091. $wldata = array();
  2092. $fdata = array();
  2093. foreach($whlabel as $k=>$v)
  2094. {
  2095. $w = explode('-',trim($v,'-'));
  2096. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2097. }
  2098. if(!isset($wldata[$id]))
  2099. {
  2100. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2101. }
  2102. if(isset($wldata[$wtid['number']]['sj']))
  2103. {
  2104. $tw = $wldata[$wtid['number']]['sj'];
  2105. if($wtid['number'] != $id)
  2106. {
  2107. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2108. }
  2109. else
  2110. {
  2111. if(isset($tw[2]) && $tw[2] != 0)
  2112. {
  2113. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2114. }
  2115. }
  2116. if($tw[1] > 1)
  2117. {
  2118. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2119. }
  2120. }
  2121. $thfpdata = $y['thfpdata'];
  2122. $w = $wldata[$id]['sj'];
  2123. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2124. $zdkc = $warehouse['bdck'];
  2125. if($w[1] > 1)
  2126. {
  2127. if(isset($w[2]) && $w[2] != 0)
  2128. {
  2129. $hz = explode('~',trim($w[2],'~'));
  2130. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2131. $zd = str_replace($hz[0],'',$w[2]);
  2132. $zd = trim($zd,'~');
  2133. $w[2] = $zd;
  2134. }
  2135. foreach($w as $kk=>$v)
  2136. {
  2137. if($kk == 1)
  2138. {
  2139. $v = $v-1;
  2140. }
  2141. $ww .= $v .'-';
  2142. }
  2143. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2144. foreach($f as $kk=>$v)
  2145. {
  2146. if($kk == 2)
  2147. {
  2148. $v = $v-1;
  2149. $thff .= '1|';
  2150. }
  2151. else
  2152. {
  2153. $thff .= $v .'|';
  2154. }
  2155. $ff .= $v .'|';
  2156. }
  2157. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2158. $thfpdata .= trim($thff,'|');
  2159. }
  2160. else
  2161. {
  2162. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2163. unset($whlabel[$wldata[$id]['wz']]);
  2164. unset($fpdata[$wldata[$id]['wz']]);
  2165. }
  2166. $thfpdata .= '~'.$dataf;
  2167. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2168. $fpdata = implode(";",$fpdata).';'.$dataf;
  2169. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2170. if ($this->db->trans_status() === TRUE)
  2171. {
  2172. $this->db->trans_commit();
  2173. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2174. }
  2175. else
  2176. {
  2177. $this->db->trans_rollback();
  2178. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2179. }
  2180. }
  2181. if(isset($post['yhs']))
  2182. {
  2183. $f = 'fullorder';
  2184. $number = $this->input->post('yhs',true);
  2185. $y = $this->fullorder->get_number($number);
  2186. if(!$y)
  2187. {
  2188. $f = 'fullordersmt';
  2189. $y = $this->fullordersmt->get_number($number);
  2190. }
  2191. if($this->$f->save(array('yhs'=>0),$y['id']))
  2192. {
  2193. echo json_encode(array('success'=>true));exit;
  2194. }
  2195. else
  2196. {
  2197. echo json_encode(array('success'=>false));exit;
  2198. }
  2199. }
  2200. $this->_Template('systemfout_orderyz',$this->data);
  2201. }
  2202. public function _hwyz()
  2203. {
  2204. $post = $this->input->post(NULL, TRUE);
  2205. if(isset($post['yz']))
  2206. {
  2207. $yz = $this->input->post('yz',true);
  2208. $number = $this->input->post('number',true);
  2209. $y = $this->fullorder->get_number($number);
  2210. if(!$y)
  2211. {
  2212. $y = $this->fullordersmt->get_number($number);
  2213. if(!$y)
  2214. {
  2215. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2216. }
  2217. }
  2218. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2219. foreach($whlabel as $k=>$v)
  2220. {
  2221. $w = explode('-',trim($v,'-'));
  2222. $wldata[$w[0]] = $w;
  2223. }
  2224. $whlabellabel = $this->whlabellabel->get_label($yz);
  2225. if(!$whlabellabel)
  2226. {
  2227. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2228. }
  2229. else
  2230. {
  2231. if(isset($wldata[$whlabellabel['number']]))
  2232. {
  2233. if(!isset($wldata[$whlabellabel['number']][2]))
  2234. {
  2235. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2236. }
  2237. else if($wldata[$whlabellabel['number']][2] == 0)
  2238. {
  2239. echo json_encode(array('msg'=>'此货物没有占单!','success'=>false));exit;
  2240. }
  2241. }
  2242. else
  2243. {
  2244. echo json_encode(array('msg'=>'此订单中没有扫码产品!','success'=>false));exit;
  2245. }
  2246. echo json_encode(array('number'=>$whlabellabel['number'],'success'=>true));exit;
  2247. }
  2248. }
  2249. if(isset($post['number']))
  2250. {
  2251. $number = $this->input->post('number',true);
  2252. $f = 'fullorder';
  2253. $y = $this->fullorder->get_number($number);
  2254. if(!$y)
  2255. {
  2256. $f = 'fullordersmt';
  2257. $y = $this->fullordersmt->get_number($number);
  2258. if(!$y)
  2259. {
  2260. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2261. }
  2262. }
  2263. if($y['librarytime'] > 0)
  2264. {
  2265. echo json_encode(array('msg'=>'错误,此订单已出库!','success'=>false));exit;
  2266. }
  2267. $warehouse = $this->warehouse->read($y['type']);
  2268. $data = explode('|',trim($y['whlabel'],'|'));
  2269. $fpdata = explode(';',trim($y['fpdata'],';'));
  2270. $cp = array();$i = 0;$x=0;$byz = array();$znum = 0;
  2271. foreach($fpdata as $val)
  2272. {
  2273. $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2274. $scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2275. $fp = explode('|',$val);
  2276. $fp[0] = str_replace(',','-',$fp[0]);
  2277. $value = explode('-',$fp[0]);
  2278. foreach($value as $v)
  2279. {
  2280. $typeclass = $this->typeclass->read($v);
  2281. $zh = explode('|',trim($typeclass['zh'],'|'));
  2282. $pm[$typeclass['classid']] = $zh[0];
  2283. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2284. }
  2285. $scsku = implode("-",$scsku);
  2286. $zh = implode(" ",$pm);
  2287. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2288. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2289. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2290. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2291. $data[$i] = explode('-',$data[$i]);
  2292. for($j=0;$j<$data[$i][1];$j++)
  2293. {
  2294. if(isset($data[$i][2]) && $warehouse['hz'] != '' && stripos($data[$i][2],$warehouse['hz']) !== false)
  2295. {
  2296. $znum++;//只计算现货
  2297. //$cp[$x] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');//区别位置模式,暂不使用
  2298. $cp[] = array('id'=>$data[$i][0],'sku'=>$scsku,'zh'=>$zh,'y'=>'已占单','t'=>'<span data-id="'.$data[$i][0].'">替换现货</sapn>','c'=>1,'color'=>'#333');
  2299. }
  2300. else
  2301. {
  2302. //$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');//区别位置模式,暂不使用
  2303. $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');
  2304. }
  2305. $x++;//所有数量
  2306. }
  2307. $i++;
  2308. }
  2309. //ksort($cp);//区别位置模式,暂不使用
  2310. $cp = array_values($cp);
  2311. if($this->$f->save(array('yhs'=>1),$y['id']))
  2312. {
  2313. if(stripos($y['whlabel'],$warehouse['hz']) === false)
  2314. {
  2315. echo json_encode(array('rows'=>$cp,'z'=>$znum,'msg'=>'pz','success'=>false));exit;
  2316. }
  2317. echo json_encode(array('rows'=>$cp,'z'=>$znum,'success'=>true));exit;
  2318. }
  2319. else
  2320. {
  2321. echo json_encode(array('msg'=>'处理信息失败,请重试','success'=>false));exit;
  2322. }
  2323. }
  2324. if(isset($post['tid']))
  2325. {
  2326. $typeclass = array();
  2327. $tc = $this->typeclass->find_all();
  2328. foreach($tc as $v)
  2329. {
  2330. $typeclass[$v['id']] = array('id'=>$v['id'],'classid'=>$v['classid'],'spare'=>$v['spare']);
  2331. }
  2332. $tid = $this->input->post('tid',true);
  2333. $id = $this->input->post('id',true);
  2334. $number = $this->input->post('n',true);
  2335. $ful = 'fullorder';
  2336. $y = $this->fullorder->get_number($number);
  2337. if(!$y)
  2338. {
  2339. $ful = 'fullordersmt';
  2340. $y = $this->fullordersmt->get_number($number);
  2341. if(!$y)
  2342. {
  2343. echo json_encode(array('msg'=>'没有找到此订单,请检查是否扫描错误','success'=>false));exit;
  2344. }
  2345. }
  2346. $wtid = $this->whlabellabel->get_label($tid);
  2347. if(!$wtid)
  2348. {
  2349. echo json_encode(array('msg'=>'没有找到此产品条码','success'=>false));exit;
  2350. }
  2351. $whlabel = explode('|',trim($y['whlabel'],'|'));
  2352. $fpdata = explode(';',trim($y['fpdata'],';'));
  2353. $warehouse = $this->warehouse->read($y['type']);
  2354. $zdkc = $warehouse['bdck'];
  2355. $ptc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and (shop IS NULL or shop = '')");//通用
  2356. $zsc = $this->$zdkc->find_all("state = '0' and number = '".$wtid['number']."' and warehouse = '".$warehouse['id']."' and zd = '' and shop like '%,".$y['shop'].",%'");//专属
  2357. if((count($ptc)+count($zsc)) < 1)
  2358. {
  2359. echo json_encode(array('msg'=>'录入的产品没有足够的库存!-'.(count($ptc)+count($zsc)),'success'=>false));exit;
  2360. }
  2361. $this->db->trans_begin();
  2362. $dataw = '';$dataf = '';$fhdata = array();$ww = '';$ff = '';$thff = '';
  2363. if($zsc)
  2364. {
  2365. $this->$zdkc->save(array('zd'=>$number),$zsc[0]['id']);
  2366. $xrid = $zsc[0]['id'];
  2367. }
  2368. else if($ptc)
  2369. {
  2370. $this->$zdkc->save(array('zd'=>$number),$ptc[0]['id']);
  2371. $xrid = $ptc[0]['id'];
  2372. }
  2373. $xr = $this->$zdkc->read($xrid);
  2374. $features = explode('-',trim($xr['features'],'-'));
  2375. $fhdata = array('sku'=>$xr['sku'],'title'=>$xr['title'],'id'=>$xr['features']);
  2376. foreach($features as $kk=>$v)
  2377. {
  2378. if($typeclass[$v]['classid'] == 14)
  2379. {
  2380. $cc = array('id'=>$typeclass[$v]['id'],'spare'=>$typeclass[$v]['spare']);
  2381. unset($kk);
  2382. }
  2383. }
  2384. $dataw = $tid.'-1-'.$xrid.$warehouse['hz'].'|';
  2385. $dataf = $cc['id'].',-'.implode("-",$features).'-|'.$xr['title'].' |1|0|0|'.$cc['spare'].'|0|0|0|'.$xr['id'].$warehouse['hz'].';';
  2386. $wldata = array();
  2387. $fdata = array();
  2388. foreach($whlabel as $k=>$v)
  2389. {
  2390. $w = explode('-',trim($v,'-'));
  2391. $wldata[$w[0]] = array('wz'=>$k,'sj'=>$w);
  2392. }
  2393. if(!isset($wldata[$id]))
  2394. {
  2395. echo json_encode(array('msg'=>'错误,未找到需要替换的产品,请重新扫发货单条码验货','success'=>false));exit;
  2396. }
  2397. if(isset($wldata[$wtid['number']]['sj']))
  2398. {
  2399. $tw = $wldata[$wtid['number']]['sj'];
  2400. if($wtid['number'] != $id)
  2401. {
  2402. echo json_encode(array('msg'=>'替换的产品已存在,请操作此产品','success'=>false));exit;
  2403. }
  2404. else
  2405. {
  2406. if(isset($tw[2]) && $tw[2] != 0)
  2407. {
  2408. echo json_encode(array('msg'=>'替换的产品已存在,并且已占单,无法操作替换!','success'=>false));exit;
  2409. }
  2410. }
  2411. if($tw[1] > 1)
  2412. {
  2413. echo json_encode(array('msg'=>'替换的产品已存在,并且已数量为大于1,无法操作替换!','success'=>false));exit;
  2414. }
  2415. }
  2416. $thfpdata = $y['thfpdata'];
  2417. $w = $wldata[$id]['sj'];
  2418. $f = explode('|',trim($fpdata[$wldata[$id]['wz']],'|'));
  2419. $zdkc = $warehouse['bdck'];
  2420. if($w[1] > 1)
  2421. {
  2422. if(isset($w[2]) && $w[2] != 0)
  2423. {
  2424. $hz = explode('~',trim($w[2],'~'));
  2425. $this->$zdkc->save(array('zd'=>''),trim($hz[0],$warehouse['hz']));
  2426. $zd = str_replace($hz[0],'',$w[2]);
  2427. $zd = trim($zd,'~');
  2428. $w[2] = $zd;
  2429. }
  2430. foreach($w as $kk=>$v)
  2431. {
  2432. if($kk == 1)
  2433. {
  2434. $v = $v-1;
  2435. }
  2436. $ww .= $v .'-';
  2437. }
  2438. $whlabel[$wldata[$id]['wz']] = trim($ww,'-');
  2439. foreach($f as $kk=>$v)
  2440. {
  2441. if($kk == 2)
  2442. {
  2443. $v = $v-1;
  2444. $thff .= '1|';
  2445. }
  2446. else
  2447. {
  2448. $thff .= $v .'|';
  2449. }
  2450. $ff .= $v .'|';
  2451. }
  2452. $fpdata[$wldata[$id]['wz']] = trim($ff,'|');
  2453. $thfpdata .= trim($thff,'|');
  2454. }
  2455. else
  2456. {
  2457. $thfpdata .= $fpdata[$wldata[$id]['wz']];
  2458. unset($whlabel[$wldata[$id]['wz']]);
  2459. unset($fpdata[$wldata[$id]['wz']]);
  2460. }
  2461. $thfpdata .= '~'.$dataf;
  2462. $whlabel = '|'.implode("|",$whlabel).'|'.$dataw;
  2463. $fpdata = implode(";",$fpdata).';'.$dataf;
  2464. $this->$ful->save(array('whlabel'=>$whlabel,'fpdata'=>$fpdata,'thfpdata'=>$thfpdata),$y['id']);
  2465. if ($this->db->trans_status() === TRUE)
  2466. {
  2467. $this->db->trans_commit();
  2468. echo json_encode(array('sku'=>$fhdata['sku'],'title'=>$fhdata['title'],'id'=>$fhdata['id'],'msg'=>321,'success'=>true));exit;
  2469. }
  2470. else
  2471. {
  2472. $this->db->trans_rollback();
  2473. echo json_encode(array('msg'=>'条码录入失败,请重试','success'=>false));exit;
  2474. }
  2475. }
  2476. if(isset($post['yhs']))
  2477. {
  2478. $f = 'fullorder';
  2479. $number = $this->input->post('yhs',true);
  2480. $y = $this->fullorder->get_number($number);
  2481. if(!$y)
  2482. {
  2483. $f = 'fullordersmt';
  2484. $y = $this->fullordersmt->get_number($number);
  2485. }
  2486. if($this->$f->save(array('yhs'=>0),$y['id']))
  2487. {
  2488. echo json_encode(array('success'=>true));exit;
  2489. }
  2490. else
  2491. {
  2492. echo json_encode(array('success'=>false));exit;
  2493. }
  2494. }
  2495. $this->_Template('systemfout_hwyz',$this->data);
  2496. }
  2497. public function _fouthb()
  2498. {
  2499. $post = $this->input->post(NULL, TRUE);
  2500. $xw = '';
  2501. if(isset($_SESSION['api']))
  2502. {
  2503. $user = $this->user->get_api($_SESSION['api']);
  2504. $usp = $user;
  2505. $fgshop = "";$sid = "";$wid="";$wtype="";
  2506. $usersp = explode('|',trim($user['shop'],'|'));
  2507. $userwh = explode('|',trim($user['warehouse'],'|'));
  2508. foreach ($usersp as $value)
  2509. {
  2510. $fgshop .= " shop = ".$value." or";
  2511. $sid .= " id = ".$value." or";
  2512. }
  2513. foreach ($userwh as $value)
  2514. {
  2515. $wid .= " id = ".$value." or";
  2516. $wtype .= " type = ".$value." or";
  2517. }
  2518. if($user['userid'] == 'xw')
  2519. {
  2520. $xw = 1;
  2521. }
  2522. }
  2523. if(isset($post['page']))
  2524. {
  2525. $page = $this->input->post('page',true);
  2526. $perpage = $this->input->post('perpage',true);
  2527. $timetk = $this->input->post('timetk',true);
  2528. $timetj = $this->input->post('timetj',true);
  2529. $shop = $this->input->post('shop',true);
  2530. $type = $this->input->post('type',true);
  2531. $express = $this->input->post('express',true);
  2532. $number = $this->input->post('number',true);
  2533. $waybill = $this->input->post('waybill',true);
  2534. $librarytime = $this->input->post('librarytime',true);
  2535. $timetk = strtotime($timetk);
  2536. $timetj = strtotime($timetj);
  2537. $where = "mergeid = '1'";
  2538. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2539. if($shop)
  2540. {
  2541. $where .= " and shop = '$shop'";
  2542. }
  2543. if($number)
  2544. {
  2545. $where .= " and number like '$number%'";
  2546. }
  2547. if($waybill)
  2548. {
  2549. $where .= " and waybill = '$waybill'";
  2550. }
  2551. if($type)
  2552. {
  2553. $where .= " and type = '$type'";
  2554. }
  2555. if($express)
  2556. {
  2557. $where .= " and express = '$express'";
  2558. }
  2559. //数据排序
  2560. $order_str = "librarytime desc";
  2561. if(empty($page))
  2562. {
  2563. $start = 0;
  2564. $perpage = 1;
  2565. }
  2566. else
  2567. {
  2568. $start = ($page - 1)*$perpage;
  2569. }
  2570. //取得信息列表
  2571. $info_list = $this->fullorder->find_all($where,'id,shop,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2572. //格式化数据
  2573. foreach ($info_list as $key=>$value)
  2574. {
  2575. $shop = $this->shop->read($value['shop']);
  2576. $info_list[$key]['shop'] = $shop['shopname'];
  2577. $express = $this->express->read($value['express']);
  2578. $info_list[$key]['express'] = $express['servicename'];
  2579. $warehouse = $this->warehouse->read($value['type']);
  2580. $info_list[$key]['type'] = $warehouse['title'];
  2581. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  2582. }
  2583. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2584. //格式化数据
  2585. foreach ($info_listtt as $key=>$value)
  2586. {
  2587. $shop = $this->shop->read($value['shop']);
  2588. $info_listtt[$key]['shop'] = $shop['shopname'];
  2589. $express = $this->express->read($value['express']);
  2590. $info_listtt[$key]['express'] = $express['servicename'];
  2591. $warehouse = $this->warehouse->read($value['type']);
  2592. $info_listtt[$key]['type'] = $warehouse['title'];
  2593. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2594. }
  2595. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,shipremarks',$order_str,$start,$perpage);
  2596. //格式化数据
  2597. foreach ($info_listxw as $key=>$value)
  2598. {
  2599. $shop = $this->shop->read($value['shop']);
  2600. $info_listxw[$key]['shop'] = $shop['shopname'];
  2601. $express = $this->express->read($value['express']);
  2602. $info_listxw[$key]['express'] = $express['servicename'];
  2603. $warehouse = $this->warehouse->read($value['type']);
  2604. $info_listxw[$key]['type'] = $warehouse['title'];
  2605. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2606. }
  2607. $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);
  2608. //格式化数据
  2609. foreach ($info_listsmt as $key=>$value)
  2610. {
  2611. $shop = $this->shop->read($value['shop']);
  2612. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2613. $express = $this->express->read($value['express']);
  2614. $info_listsmt[$key]['express'] = $express['servicename'];
  2615. $warehouse = $this->warehouse->read($value['type']);
  2616. $info_listsmt[$key]['type'] = $warehouse['title'];
  2617. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2618. }
  2619. $total = $this->fullorder->find_count($where);
  2620. $total += $this->fullordertt->find_count($where);
  2621. $total += $this->fullorderxw->find_count($where);
  2622. $total += $this->fullordersmt->find_count($where);
  2623. $pagenum = ceil($total/$perpage);
  2624. $over = $total-($start+$perpage);
  2625. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt)));
  2626. echo json_encode($rows);exit;
  2627. }
  2628. if(isset($_SESSION['api']))
  2629. {
  2630. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2631. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2632. $this->data['wlshop'] = $wlshop;
  2633. $this->data['warehouse'] = $warehouse;
  2634. }
  2635. $this->data['xw'] = $xw;
  2636. $this->_Template('systemfout_fouthb',$this->data);
  2637. }
  2638. public function _hb()
  2639. {
  2640. $post = $this->input->post(NULL, TRUE);
  2641. $xw = '';
  2642. if(isset($_SESSION['api']))
  2643. {
  2644. $user = $this->user->get_api($_SESSION['api']);
  2645. $usp = $user;
  2646. $fgshop = "";$sid = "";$wid="";$wtype="";
  2647. $usersp = explode('|',trim($user['shop'],'|'));
  2648. $userwh = explode('|',trim($user['warehouse'],'|'));
  2649. foreach ($usersp as $value)
  2650. {
  2651. $fgshop .= " shop = ".$value." or";
  2652. $sid .= " id = ".$value." or";
  2653. }
  2654. foreach ($userwh as $value)
  2655. {
  2656. $wid .= " id = ".$value." or";
  2657. $wtype .= " type = ".$value." or";
  2658. }
  2659. if($user['userid'] == 'xw')
  2660. {
  2661. $xw = 1;
  2662. }
  2663. }
  2664. if(isset($post['page']))
  2665. {
  2666. $page = $this->input->post('page',true);
  2667. $perpage = $this->input->post('perpage',true);
  2668. $timetk = $this->input->post('timetk',true);
  2669. $timetj = $this->input->post('timetj',true);
  2670. $shop = $this->input->post('shop',true);
  2671. $source = $this->input->post('source',true);
  2672. $orderinfo = $this->input->post('orderinfo',true);
  2673. $number = $this->input->post('number',true);
  2674. $library = $this->input->post('library',true);
  2675. $waybill = $this->input->post('waybill',true);
  2676. $express = $this->input->post('express',true);
  2677. $type = $this->input->post('type',true);
  2678. $lowe = $this->input->post('lowe',true);
  2679. $so = $this->input->post('so',true);
  2680. $librarytime = $this->input->post('librarytime',true);
  2681. $timetk = strtotime($timetk);
  2682. $timetj = strtotime($timetj);
  2683. $cxtime = 'id';
  2684. $where = (isset($_SESSION['api']))?"library!=3 and mergeid = 1 and libraryconfirm=2 and print = 3 and (".rtrim($wtype,'or').")":"id = '0' and mergeid = 1";
  2685. if($timetk && $timetj && $library == 1)
  2686. {
  2687. //$cxtime = 'reviewtime';
  2688. $where .= " and printtime > '$timetk - 180*24*3600' and printtime < '$timetj'";
  2689. $where .= " and state != 217";
  2690. }
  2691. else if($timetk && $timetj && $library == 2)
  2692. {
  2693. $cxtime = 'librarytime';
  2694. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  2695. }
  2696. if($shop)
  2697. {
  2698. $where .= " and shop = '$shop'";
  2699. }
  2700. if($number)
  2701. {
  2702. $where .= " and number = '$number'";
  2703. }
  2704. if($library)
  2705. {
  2706. $where .= " and library = '$library'";
  2707. }
  2708. if($waybill)
  2709. {
  2710. $where .= " and waybill = '$waybill'";
  2711. }
  2712. if($express)
  2713. {
  2714. $where .= " and express = '$express'";
  2715. }
  2716. if($orderinfo)
  2717. {
  2718. $where .= " and orderinfo = '$orderinfo'";
  2719. }
  2720. if($type)
  2721. {
  2722. $where .= " and type = '$type'";
  2723. }
  2724. if($lowe)
  2725. {
  2726. $where .= " and shipremarks like '%$lowe%'";
  2727. }
  2728. if($so)
  2729. {
  2730. $where .= " and shipremarks like '%$so%'";
  2731. }
  2732. //数据排序
  2733. $order_str = $cxtime." desc";
  2734. if(empty($page))
  2735. {
  2736. $start = 0;
  2737. $perpage = 1;
  2738. }
  2739. else
  2740. {
  2741. $start = ($page - 1)*$perpage;
  2742. }
  2743. //取得信息列表
  2744. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2745. //格式化数据
  2746. foreach ($info_list as $key=>$value)
  2747. {
  2748. $shop = $this->shop->read($value['shop']);
  2749. $info_list[$key]['shop'] = $shop['shopname'];
  2750. if($value['waybill'] == '0')
  2751. {
  2752. $info_list[$key]['waybill'] = "";
  2753. }
  2754. $express = $this->express->read($value['express']);
  2755. $info_list[$key]['express'] = $express['servicename'];
  2756. $warehouse = $this->warehouse->read($value['type']);
  2757. $info_list[$key]['type'] = $warehouse['title'];
  2758. if($value['print'] == 1)
  2759. {
  2760. $info_list[$key]['print'] = '不可打印';
  2761. }
  2762. else if($value['print'] == 2)
  2763. {
  2764. $info_list[$key]['print'] = '未打印';
  2765. }
  2766. else if($value['print'] == 3)
  2767. {
  2768. $info_list[$key]['print'] = '已打印';
  2769. }
  2770. if($value['library'] == 1)
  2771. {
  2772. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  2773. }
  2774. else if($value['library'] == 2)
  2775. {
  2776. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  2777. }
  2778. else if($value['library'] == 3)
  2779. {
  2780. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  2781. }
  2782. if($value['librarytime'] == '0')
  2783. {
  2784. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2785. }
  2786. else
  2787. {
  2788. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i',$value['librarytime']).'</em>';
  2789. }
  2790. $info_list[$key]['orderremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['orderremarks']);
  2791. }
  2792. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2793. //格式化数据
  2794. foreach ($info_listtt as $key=>$value)
  2795. {
  2796. $shop = $this->shop->read($value['shop']);
  2797. $info_listtt[$key]['shop'] = $shop['shopname'];
  2798. if($value['waybill'] == '0')
  2799. {
  2800. $info_listtt[$key]['waybill'] = "";
  2801. }
  2802. $express = $this->express->read($value['express']);
  2803. $info_listtt[$key]['express'] = $express['servicename'];
  2804. $warehouse = $this->warehouse->read($value['type']);
  2805. $info_listtt[$key]['type'] = $warehouse['title'];
  2806. if($value['print'] == 1)
  2807. {
  2808. $info_listtt[$key]['print'] = '不可打印';
  2809. }
  2810. else if($value['print'] == 2)
  2811. {
  2812. $info_listtt[$key]['print'] = '未打印';
  2813. }
  2814. else if($value['print'] == 3)
  2815. {
  2816. $info_listtt[$key]['print'] = '已打印';
  2817. }
  2818. if($value['library'] == 1)
  2819. {
  2820. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  2821. }
  2822. else if($value['library'] == 2)
  2823. {
  2824. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  2825. }
  2826. else if($value['library'] == 3)
  2827. {
  2828. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  2829. }
  2830. if($value['librarytime'] == '0')
  2831. {
  2832. $info_listtt[$key]['librarytime'] = '<em class="t"></em>';
  2833. }
  2834. else
  2835. {
  2836. $info_listtt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2837. }
  2838. }
  2839. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime,orderremarks',$order_str,$start,$perpage);
  2840. //格式化数据
  2841. foreach ($info_listxw as $key=>$value)
  2842. {
  2843. $shop = $this->shop->read($value['shop']);
  2844. $info_listxw[$key]['shop'] = $shop['shopname'];
  2845. if($value['waybill'] == '0')
  2846. {
  2847. $info_listxw[$key]['waybill'] = "";
  2848. }
  2849. $express = $this->express->read($value['express']);
  2850. $info_listxw[$key]['express'] = $express['servicename'];
  2851. $warehouse = $this->warehouse->read($value['type']);
  2852. $info_listxw[$key]['type'] = $warehouse['title'];
  2853. if($value['print'] == 1)
  2854. {
  2855. $info_listxw[$key]['print'] = '不可打印';
  2856. }
  2857. else if($value['print'] == 2)
  2858. {
  2859. $info_listxw[$key]['print'] = '未打印';
  2860. }
  2861. else if($value['print'] == 3)
  2862. {
  2863. $info_listxw[$key]['print'] = '已打印';
  2864. }
  2865. if($value['library'] == 1)
  2866. {
  2867. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2868. }
  2869. else if($value['library'] == 2)
  2870. {
  2871. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2872. }
  2873. else if($value['library'] == 3)
  2874. {
  2875. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2876. }
  2877. if($value['librarytime'] == '0')
  2878. {
  2879. $info_listxw[$key]['librarytime'] = '<em class="t"></em>';
  2880. }
  2881. else
  2882. {
  2883. $info_listxw[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2884. }
  2885. }
  2886. $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);
  2887. //格式化数据
  2888. foreach ($info_listsmt as $key=>$value)
  2889. {
  2890. $shop = $this->shop->read($value['shop']);
  2891. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2892. if($value['waybill'] == '0')
  2893. {
  2894. $info_listsmt[$key]['waybill'] = "";
  2895. }
  2896. $express = $this->express->read($value['express']);
  2897. $info_listsmt[$key]['express'] = $express['servicename'];
  2898. $warehouse = $this->warehouse->read($value['type']);
  2899. $info_listsmt[$key]['type'] = $warehouse['title'];
  2900. if($value['print'] == 1)
  2901. {
  2902. $info_listsmt[$key]['print'] = '不可打印';
  2903. }
  2904. else if($value['print'] == 2)
  2905. {
  2906. $info_listsmt[$key]['print'] = '未打印';
  2907. }
  2908. else if($value['print'] == 3)
  2909. {
  2910. $info_listsmt[$key]['print'] = '已打印';
  2911. }
  2912. if($value['library'] == 1)
  2913. {
  2914. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  2915. }
  2916. else if($value['library'] == 2)
  2917. {
  2918. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  2919. }
  2920. else if($value['library'] == 3)
  2921. {
  2922. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  2923. }
  2924. if($value['librarytime'] == '0')
  2925. {
  2926. $info_listsmt[$key]['librarytime'] = '<em class="t"></em>';
  2927. }
  2928. else
  2929. {
  2930. $info_listsmt[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2931. }
  2932. }
  2933. $total = $this->fullorder->find_count($where);
  2934. $total += $this->fullordertt->find_count($where);
  2935. $total += $this->fullorderxw->find_count($where);
  2936. $total += $this->fullordersmt->find_count($where);
  2937. $pagenum = ceil($total/$perpage);
  2938. $over = $total-($start+$perpage);
  2939. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt)));
  2940. echo json_encode($rows);exit;
  2941. }
  2942. if(isset($_SESSION['api']))
  2943. {
  2944. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2945. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2946. $this->data['wlshop'] = $wlshop;
  2947. $this->data['warehouse'] = $warehouse;
  2948. }
  2949. $this->data['xw'] = $xw;
  2950. $this->_Template('systemfout_hb',$this->data);
  2951. }
  2952. }