Systemfout.php 100 KB

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