Systemfout.php 100 KB

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