Specialstock.php 139 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Specialstock extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_specialstock','specialstock');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  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_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_whlabelwz','whlabelwz');
  27. $this->load->_model('Model_classid','classid');
  28. }
  29. //定义方法的调用规则 获取URI第二段值
  30. public function _remap($arg,$arg_array)
  31. {
  32. if($arg == 'existence')//在库标签
  33. {
  34. $this->_existence();
  35. }
  36. else if($arg == 'cpbqdc')//在库标签
  37. {
  38. $this->_cpbqdc();
  39. }
  40. else if($arg == 'type')//进销存浏览
  41. {
  42. $this->_type($arg_array);
  43. }
  44. else if($arg == 'xhctype')//现货仓进销存浏览
  45. {
  46. $this->_xhctype($arg_array);
  47. }
  48. else if($arg == 'typedy')//进销存浏览店员浏览
  49. {
  50. $this->_typedy();
  51. }
  52. else if($arg == 'xhctypedy')//现货仓进销存浏览店员浏览
  53. {
  54. $this->_xhctypedy();
  55. }
  56. else if($arg == 'usatype')//美仓进销存浏览
  57. {
  58. $this->_usatype();
  59. }
  60. else if($arg == 'usatypeapp')//美仓APP进销存浏览
  61. {
  62. $this->_usatypeapp();
  63. }
  64. else if($arg == 'enteradd')//入库操作
  65. {
  66. $this->_enteradd();
  67. }
  68. else if($arg == 'enteredit')//修改
  69. {
  70. $this->_enteredit($arg_array);
  71. }
  72. else if($arg == 'enter')//入库浏览
  73. {
  74. $this->_enter();
  75. }
  76. else if($arg == 'xhcenter')//入库浏览
  77. {
  78. $this->_xhcenter();
  79. }
  80. else if($arg == 'out')//出库浏览
  81. {
  82. $this->_out();
  83. }
  84. else if($arg == 'label')//出库标签浏览
  85. {
  86. $this->_label();
  87. }
  88. else if($arg == 'outorder')//独立站出库订单
  89. {
  90. $this->_outorder();
  91. }
  92. else if($arg == 'soutorder')//速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. }
  96. else if($arg == 'retreat')//退库订单
  97. {
  98. $this->_retreat();
  99. }
  100. else if($arg == 'retreatlk')//退库订单
  101. {
  102. $this->_retreatlk();
  103. }
  104. else if($arg == 'change')//更换标签
  105. {
  106. $this->_change();
  107. }
  108. else if($arg == 'del')//删除
  109. {
  110. $this->_del($arg_array);
  111. }
  112. else if($arg == 'exceljxc')//进销存信息导出
  113. {
  114. $this->_exceljxc();
  115. }
  116. else if($arg == 'excelr')//入库信息导出
  117. {
  118. $this->_excelr();
  119. }
  120. else if($arg == 'excelct')//出库、退库信息导出
  121. {
  122. $this->_excelct();
  123. }
  124. else if($arg == 'kcyz')//库存验证
  125. {
  126. $this->_kcyz();
  127. }
  128. else if($arg == 'kj')//库存扣减
  129. {
  130. $this->_kj($arg_array);
  131. }
  132. else if($arg == 'presetout')//预设库存导入
  133. {
  134. $this->_presetout($arg_array);
  135. }
  136. else if($arg == 'presetedit')//预设库存导入
  137. {
  138. $this->_presetedit($arg_array);
  139. }
  140. else if($arg == 'summary')//汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. }
  144. else if($arg == 'manifest')//usps发货清单
  145. {
  146. $this->_manifest();
  147. }
  148. else if($arg == 'abnormal')//占单异常
  149. {
  150. $this->_abnormal();
  151. }
  152. else if($arg == 'error')
  153. {
  154. $this->_error();
  155. }
  156. else if($arg == 'ppkc')
  157. {
  158. $this->_ppkc();
  159. }
  160. else if($arg == 'list')
  161. {
  162. $this->_list($arg_array);
  163. }
  164. else if($arg == 'hwwz')
  165. {
  166. $this->_hwwz();
  167. }
  168. else if($arg == 'order')
  169. {
  170. $this->_order();
  171. }
  172. else if($arg == 'placeorder')
  173. {
  174. $this->_placeorder();
  175. }
  176. else
  177. {
  178. $this->_index();
  179. }
  180. }
  181. public function _del($id_arr)
  182. {
  183. if($id_arr)
  184. {
  185. $id_arr = explode(',',$id_arr);
  186. //循环删除记录
  187. foreach ($id_arr as $value)
  188. {
  189. $data = $this->specialstock->read($value);
  190. $z = $this->specialstock->find_all('sku = "'.$data['sku'].'" and number = "'.$data['number'].'" and zd = "" and state = 0 and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
  191. foreach ($z as $v)
  192. {
  193. $this->specialstock->remove($v['id']);
  194. }
  195. }
  196. return json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  197. }
  198. else
  199. {
  200. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  201. }
  202. }
  203. public function _list($arg_array)
  204. {
  205. $ppid = array();
  206. $number = (isset($arg_array[1]))?$arg_array[1]:'no';
  207. if(!isset($arg_array[2]))
  208. {
  209. echo "特殊产品信息错误!清除浏览器缓存后再试";exit;
  210. }
  211. $hz = '';
  212. $bdck = $this->warehouse->get_bdck('specialstock');
  213. if($bdck)
  214. {
  215. if($bdck['hz'] != '' && stripos($arg_array[2],$bdck['hz']) !== false)
  216. {
  217. $hz = $bdck['hz'];
  218. }
  219. }
  220. if(stripos($arg_array[2],'-') !== false)
  221. {
  222. $dcp = explode('-',$arg_array[2]);
  223. foreach ($dcp as $v)
  224. {
  225. if($hz != '')
  226. {
  227. $ppid[] = trim($v,$hz);
  228. }
  229. else
  230. {
  231. $ppid[] = 0;
  232. }
  233. }
  234. if($hz != '')
  235. {
  236. $xzid = trim($dcp[0],$hz);
  237. }
  238. else
  239. {
  240. $xzid = 0;
  241. }
  242. }
  243. else
  244. {
  245. if($arg_array[2] != 0 && $hz != '')
  246. {
  247. $xzid = trim($arg_array[2],$hz);//已选择产品用
  248. $ppid[] = $xzid;
  249. }
  250. else
  251. {
  252. $xzid = $arg_array[0];//未选择产品用
  253. $ppid[] = 0;
  254. }
  255. }
  256. $thisdata = $this->specialstock->read($xzid);
  257. $data = array();$dataw = array();
  258. //本单已占用的,无论是否已出库
  259. if(stripos($thisdata['featurespp'],'-149') !== false)//如果是360头套 那么也可以匹配370头套
  260. {
  261. $tjd = explode('-',$thisdata['featurespp']);
  262. $dataally = $this->specialstock->find_all("(featurespp = '".$thisdata['featurespp']."' or featurespp = '".$tjd[0]."-".$tjd[1]."-".$tjd[2]."-329"."') and zd = '".$number."'");
  263. }
  264. else
  265. {
  266. $dataally = $this->specialstock->find_all("featurespp = '".$thisdata['featurespp']."' and zd = '".$number."'");
  267. }
  268. foreach ($dataally as $v)
  269. {
  270. $sm = '';
  271. $zd = ($number == $v['zd'])?1:0;
  272. $cpid = ($v['cpid']>0)?' - 编码:'.$v['cpid']:'';
  273. $cpbz = ($v['cpbz']!='')?'<p style="color:#f00">货物说明:'.$v['cpbz'].'</p>':'';
  274. $features = '-';$c = '';
  275. $td = explode('-',trim($v['features'],'-'));
  276. foreach ($td as $va)
  277. {
  278. $s = $this->typeclass->read($va);
  279. if($s['classid'] == '14')
  280. {
  281. $c = $va;
  282. }
  283. else
  284. {
  285. $features .= $va.'-';
  286. }
  287. }
  288. foreach ($ppid as $va)
  289. {
  290. if($va == $v['id'])
  291. {
  292. $sm = '<p style="color:#F00">当前选择的产品</p>';
  293. }
  294. else if(stripos($sm,'当前选择的产品') === false)
  295. {
  296. $sm = '<p style="color:#F00">本单已占用</p>';
  297. }
  298. }
  299. $tp = $this->typeclass->read($c);
  300. $data[] = array('id'=>$v['id'],'z'=>$zd,'title'=>$v['title'].$sm,'features'=>$c.','.$features,'cc'=>$tp['spare'],'num'=>1,'details'=>'位置:'.$v['details'].$cpid.$cpbz,'sm'=>$sm);
  301. }
  302. //未占用的库存
  303. if(stripos($thisdata['featurespp'],'-149') !== false)//如果是360头套 那么也可以匹配370头套
  304. {
  305. $tjd = explode('-',$thisdata['featurespp']);
  306. $dataallw = $this->specialstock->find_all("(featurespp = '".$thisdata['featurespp']."' or featurespp = '".$tjd[0]."-".$tjd[1]."-".$tjd[2]."-329"."') and zd = '' and state = '0'");
  307. }
  308. else
  309. {
  310. $dataallw = $this->specialstock->find_all("featurespp = '".$thisdata['featurespp']."' and zd = '' and state = '0'");
  311. }
  312. foreach ($dataallw as $v)
  313. {
  314. $zd = ($number == $v['zd'])?1:0;
  315. $cpid = ($v['cpid']>0)?' - 编码:'.$v['cpid']:'';
  316. $cpbz = ($v['cpbz']!='')?'<p style="color:#f00">货物说明:'.$v['cpbz'].'</p>':'';
  317. $features = '-';$c = '';
  318. $td = explode('-',trim($v['features'],'-'));
  319. foreach ($td as $va)
  320. {
  321. $sm = '';
  322. $s = $this->typeclass->read($va);
  323. if($s['classid'] == '14')
  324. {
  325. $c = $va;
  326. }
  327. else
  328. {
  329. $features .= $va.'-';
  330. }
  331. foreach ($ppid as $va)
  332. {
  333. if($va == $v['id'])
  334. {
  335. $sm = '<p style="color:#F00">当前选择的产品,需提交后占单</p>';
  336. }
  337. }
  338. }
  339. $tp = $this->typeclass->read($c);
  340. $dataw[] = array('id'=>$v['id'],'z'=>$zd,'title'=>$v['title'].$sm,'ct'=>$v['title'],'features'=>$c.','.$features,'cc'=>$tp['spare'],'num'=>1,'details'=>'位置:'.$v['details'].$cpid.$cpbz);
  341. }
  342. $this->data['data'] = $data;
  343. $this->data['dataw'] = $dataw;
  344. $this->data['id'] = $arg_array[0];
  345. $this->data['ppid'] = $ppid;
  346. $this->_Template('specialstock_list',$this->data);
  347. }
  348. //检查是否匹配特殊库存
  349. public function _ppkc()
  350. {
  351. $post = $this->input->post(NULL, TRUE);
  352. if(isset($post['data']))
  353. {
  354. $data = $this->input->post('data',true);
  355. $number = $this->input->post('number',true);
  356. $whlabel = $this->input->post('whlabel',true);
  357. $data = explode('|',rtrim($data,'|'));
  358. $whlabel = explode('|',trim($whlabel,'|'));
  359. $i = 0;$list = array();$a=array();
  360. foreach ($data as $v)
  361. {
  362. $v = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
  363. $vfl = explode('-',trim($v,'-'));
  364. $num = explode('-',trim($whlabel[$i],'-'));
  365. if(isset($vfl[4]))
  366. {
  367. if($vfl[4] == 149)//如果是360头套 那么也可以匹配370头套
  368. {
  369. $pp = $this->specialstock->find_all("featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' and zd = '' and state = '0'");
  370. if(!$pp)
  371. {
  372. $pp = $this->specialstock->find_all("(featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' or featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3]."-329') and zd = '' and state = '0'");
  373. }
  374. }
  375. else
  376. {
  377. $pp = $this->specialstock->find_all("featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' and zd = '' and state = '0'");
  378. }
  379. $yzd='';
  380. if(isset($num[2]))
  381. {
  382. preg_match_all('/\d+/',$num[2],$n);
  383. $n = join('',$n[0]);
  384. $yzd = $this->specialstock->find_all("id = '$n' and zd = '$number'");
  385. }
  386. if(count($pp) >= $num[1] && !$yzd)
  387. {
  388. $w = '特殊';//有现货仓的设置后面特殊更改为现货
  389. $list[] = array($i,$pp[0]['id'],$w);
  390. }
  391. else if($yzd)
  392. {
  393. foreach ($yzd as $val)
  394. {
  395. if($num[2] == $val['id'].'z')
  396. {
  397. $w = '特殊';//有现货仓的设置后面特殊更改为现货
  398. $list[] = array($i,$yzd[0]['id'],$w);
  399. }
  400. }
  401. }
  402. }
  403. $i++;
  404. }
  405. if($list)
  406. {
  407. echo json_encode(array('list'=>$list,'success'=>true));exit;
  408. }
  409. }
  410. }
  411. //管理
  412. public function _index()
  413. {
  414. $post = $this->input->post(NULL, TRUE);
  415. if(isset($post['page']))
  416. {
  417. $page = $this->input->post('page',true);
  418. $perpage = $this->input->post('perpage',true);
  419. $sku = $this->input->post('sku',true);
  420. $number = $this->input->post('number',true);
  421. $warehouse = $this->input->post('warehouse',true);
  422. $purchase = $this->input->post('purchase',true);
  423. $orderinfo = $this->input->post('orderinfo',true);
  424. $waybill = $this->input->post('waybill',true);
  425. $category = $this->input->post('category',true);
  426. $size = $this->input->post('size',true);
  427. $grade = $this->input->post('grade',true);
  428. $color = $this->input->post('color',true);
  429. $lowe = $this->input->post('lowe',true);
  430. $state = $this->input->post('state',true);
  431. $label = $this->input->post('label',true);
  432. $timetk = $this->input->post('timetkk',true);
  433. $timetj = $this->input->post('timetjj',true);
  434. $timetk = strtotime($timetk);
  435. $timetj = strtotime($timetj);
  436. $where = "1=1 ";
  437. if($timetk && $timetj)
  438. {
  439. $where .= " and time > '$timetk' and time < '$timetj'";
  440. }
  441. if($sku)
  442. {
  443. $where .= " and sku = '$sku'";
  444. }
  445. if($number)
  446. {
  447. $where .= " and number = '$number'";
  448. }
  449. if($warehouse)
  450. {
  451. $where .= " and warehouse = '$warehouse'";
  452. }
  453. if($purchase)
  454. {
  455. $where .= " and purchase = '$purchase'";
  456. }
  457. if($orderinfo)
  458. {
  459. $where .= " and orderinfo = '$orderinfo'";
  460. }
  461. if($waybill)
  462. {
  463. $where .= " and waybill = '$waybill'";
  464. }
  465. if($category)
  466. {
  467. $where .= " and features like '%-$category-%'";
  468. }
  469. if($size)
  470. {
  471. $where .= " and features like '%-$size-%'";
  472. }
  473. if($grade)
  474. {
  475. $where .= " and features like '%-$grade-%'";
  476. }
  477. if($color)
  478. {
  479. $where .= " and features like '%-$color-%'";
  480. }
  481. if($lowe)
  482. {
  483. $where .= " and features like '%-$lowe-%'";
  484. }
  485. if($label)
  486. {
  487. $where .= " and label = '$label'";
  488. }
  489. if($state || $state == 0)
  490. {
  491. $where .= " and state = '$state'";
  492. }
  493. //数据排序
  494. $order_str = "time desc";
  495. if(empty($page))
  496. {
  497. $start = 0;
  498. $perpage = 1;
  499. }
  500. else
  501. {
  502. $start = ($page - 1)*$perpage;
  503. }
  504. //取得信息列表
  505. $info_list = $this->specialstock->find_all($where,'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time',$order_str,$start,$perpage);
  506. foreach ($info_list as $key=>$value)
  507. {
  508. $warehouse = $this->warehouse->read($value['warehouse']);
  509. $info_list[$key]['warehouse'] = $warehouse['title'];
  510. $purchase = $this->purchase->read($value['purchase']);
  511. $info_list[$key]['purchase'] = $purchase['title'];
  512. if($value['enter'] != 0)
  513. {
  514. $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
  515. }
  516. else
  517. {
  518. $info_list[$key]['enter'] = "";
  519. }
  520. if($value['outk'] != 0)
  521. {
  522. $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
  523. }
  524. else
  525. {
  526. $info_list[$key]['outk'] = "";
  527. }
  528. if($value['printing'] != 0)
  529. {
  530. $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
  531. }
  532. else
  533. {
  534. $info_list[$key]['printing'] = "";
  535. }
  536. if($value['orderinfo'] == 0)
  537. {
  538. $info_list[$key]['orderinfo'] = "";
  539. }
  540. if($value['waybill'] == 0)
  541. {
  542. $info_list[$key]['waybill'] = "";
  543. }
  544. if($value['state'] == 0)
  545. {
  546. $info_list[$key]['state'] = "在库";
  547. }
  548. else if($value['state'] == 1)
  549. {
  550. $info_list[$key]['state'] = "出库";
  551. }
  552. else if($value['state'] == 2)
  553. {
  554. $info_list[$key]['state'] = "退库";
  555. }
  556. else if($value['state'] == 3)
  557. {
  558. $info_list[$key]['state'] = "调拨中";
  559. }
  560. else if($value['state'] == 4)
  561. {
  562. $info_list[$key]['state'] = "再加工";
  563. }
  564. else if($value['state'] == 5)
  565. {
  566. $info_list[$key]['state'] = "维修中";
  567. }
  568. else if($value['state'] == 6)
  569. {
  570. $info_list[$key]['state'] = "盘亏";
  571. }
  572. else if($value['state'] == 7)
  573. {
  574. $info_list[$key]['state'] = "更换标签";
  575. }
  576. else if($value['state'] == 8)
  577. {
  578. $info_list[$key]['state'] = "其它";
  579. }
  580. else if($value['state'] == 9)
  581. {
  582. $info_list[$key]['state'] = "预设";
  583. }
  584. if($value['text'] == "")
  585. {
  586. $info_list[$key]['text'] = "";
  587. }
  588. $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
  589. }
  590. $total = $this->specialstock->find_count($where);
  591. $pagenum = ceil($total/$perpage);
  592. $over = $total-($start+$perpage);
  593. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  594. echo json_encode($rows);exit;
  595. }
  596. if(isset($post['outsku']))
  597. {
  598. $cz = $this->input->post('cz',true);
  599. if($cz == '1')
  600. {
  601. $sku = $this->input->post('outsku',true);
  602. if($sku)
  603. {
  604. $data = $this->specialstock->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  605. if(count($data) < 1)
  606. {
  607. echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
  608. }
  609. $this->specialstock->save(array('state'=>10,'outk'=>time(),'time'=>time()),$data[0]['id']);
  610. echo json_encode(array('success'=>true));exit;
  611. }
  612. }
  613. else
  614. {
  615. $sku = $this->input->post('outsku',true);
  616. if($sku)
  617. {
  618. $data = $this->specialstock->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  619. if(count($data) < 1)
  620. {
  621. echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
  622. }
  623. $this->specialstock->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
  624. echo json_encode(array('success'=>true));exit;
  625. }
  626. }
  627. }
  628. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  629. $this->_Template('specialstock',$this->data);
  630. }
  631. //在库标签
  632. public function _existence()
  633. {
  634. $post = $this->input->post(NULL, TRUE);
  635. if(isset($post['s']))
  636. {
  637. $id_arr = $this->input->post('s');
  638. $id_arr = explode(',',$id_arr);
  639. if(!$id_arr)
  640. {
  641. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  642. }
  643. //循环删除记录
  644. foreach ($id_arr as $v)
  645. {
  646. $this->specialstock->remove($v);
  647. }
  648. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  649. }
  650. if(isset($post['page']))
  651. {
  652. $page = $this->input->post('page',true);
  653. $perpage = $this->input->post('perpage',true);
  654. $warehouse = $this->input->post('warehouse',true);
  655. $label = $this->input->post('label',true);
  656. $where = "1=1 and state = 0";
  657. if($warehouse)
  658. {
  659. $where .= " and warehouse = '$warehouse'";
  660. }
  661. if($label)
  662. {
  663. $where .= " and label = '$label'";
  664. }
  665. //数据排序
  666. $order_str = "time asc";
  667. if(empty($page))
  668. {
  669. $start = 0;
  670. $perpage = 1;
  671. }
  672. else
  673. {
  674. $start = ($page - 1)*$perpage;
  675. }
  676. //取得信息列表
  677. $info_list = $this->specialstock->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
  678. foreach ($info_list as $key=>$value)
  679. {
  680. if($value['enter'] != 0)
  681. {
  682. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  683. }
  684. else
  685. {
  686. $info_list[$key]['enter'] = "";
  687. }
  688. if($value['printing'] != 0)
  689. {
  690. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  691. }
  692. else
  693. {
  694. $info_list[$key]['printing'] = "";
  695. }
  696. }
  697. $total = $this->specialstock->find_count($where);
  698. $pagenum = ceil($total/$perpage);
  699. $over = $total-($start+$perpage);
  700. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  701. echo json_encode($rows);exit;
  702. }
  703. $this->_Template('specialstock_existence',$this->data);
  704. }
  705. public function _typedy()
  706. {
  707. $post = $this->input->post(NULL, TRUE);
  708. if(isset($post['page']))
  709. {
  710. $page = $this->input->post('page',true);
  711. $perpage = $this->input->post('perpage',true);
  712. $category = $this->input->post('category',true);
  713. $size = $this->input->post('size',true);
  714. $grade = $this->input->post('grade',true);
  715. $color = $this->input->post('color',true);
  716. $lowe = $this->input->post('lowe',true);
  717. $sku = $this->input->post('sku');
  718. $title = $this->input->post('title');
  719. $warehouse = $this->input->post('warehouse',true);
  720. $usa = $this->input->post('usa',true);
  721. $purchase = $this->input->post('purchase',true);
  722. $lacetype = $this->input->post('lacetype',true);
  723. $haircap = $this->input->post('haircap',true);
  724. $density = $this->input->post('density',true);
  725. $details = $this->input->post('details',true);
  726. $state = $this->input->post('state',true);
  727. $ktime = $this->input->post('ktime',true);
  728. $jtime = $this->input->post('jtime',true);
  729. $ktime = strtotime($ktime);
  730. $jtime = strtotime($jtime);
  731. $where = "1=1";$gj = "";$ck = "";
  732. if($lacetype)
  733. {
  734. $where .= " and features like '%-$lacetype-%'";
  735. }
  736. if($category)
  737. {
  738. $where .= " and features like '%-$category-%'";
  739. }
  740. if($size)
  741. {
  742. $where .= " and features like '%-$size-%'";
  743. }
  744. if($grade)
  745. {
  746. $where .= " and features like '%-$grade-%'";
  747. }
  748. if($color)
  749. {
  750. $where .= " and features like '%-$color-%'";
  751. }
  752. if($lowe)
  753. {
  754. $where .= " and features like '%-$lowe-%'";
  755. }
  756. if($haircap)
  757. {
  758. $where .= " and features like '%-$haircap-%'";
  759. }
  760. if($density)
  761. {
  762. $where .= " and features like '%-$density-%'";
  763. }
  764. if($usa)
  765. {
  766. if(!$warehouse)
  767. {
  768. $where .= " and (warehouse = '5' or warehouse = '8')";
  769. }
  770. }
  771. if($warehouse)
  772. {
  773. $where .= " and warehouse = '$warehouse'";
  774. }
  775. if($details)
  776. {
  777. $where .= " and details = '$details'";
  778. }
  779. if($purchase)
  780. {
  781. $where .= " and purchase = '$purchase'";
  782. }
  783. if($state)
  784. {
  785. $where .= " and state = '$state'";
  786. }
  787. if($ktime && $jtime)
  788. {
  789. $gj = " and enter > '$ktime' and enter < '$jtime'";
  790. $ck = " and outk > '$ktime' and outk < '$jtime'";
  791. }
  792. //数据排序
  793. $order_str = "id desc";
  794. if(empty($page))
  795. {
  796. $start = 0;
  797. $perpage = 1;
  798. }
  799. else
  800. {
  801. $start = ($page - 1)*$perpage;
  802. }
  803. if($sku)
  804. {
  805. $sku = trim($sku,' ');
  806. $sku = trim($sku,' ');
  807. $where .= " and sku like '%$sku%'";
  808. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
  809. }
  810. else if($title)
  811. {
  812. $title = trim($title,' ');
  813. $title = trim($title,' ');
  814. $where .= " and title like '%$title%'";
  815. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
  816. }
  817. else
  818. {
  819. //$where .= " and time > '$ktime' and time < '$jtime'";
  820. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
  821. }
  822. //取得信息列表
  823. $rows = array();$list = array();
  824. foreach ($info_list as $key=>$value)
  825. {
  826. $wid = $this->specialstock->read($value['id']);
  827. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  828. $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
  829. $number = $value['number'];$ftime = time()-15*24*3600;
  830. $z = count($z);//查看订单号
  831. $info_list[$key]['features'] = count($c);
  832. $info_list[$key]['number'] = $z;
  833. $details = array();
  834. $cpid = array();
  835. foreach ($c as $k=>$v)
  836. {
  837. $details[$v['details']] = $v['details'];
  838. if($v['cpid'] != 0)
  839. {
  840. $cpid[$v['cpid']] = $v['cpid'];
  841. }
  842. }
  843. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  844. }
  845. $total = count($this->specialstock->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  846. $pagenum = ceil($total/$perpage);
  847. $over = $total-($start+$perpage);
  848. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  849. echo json_encode($rows);exit;
  850. }
  851. $this->_Template('specialstock_typedy',$this->data);
  852. }
  853. //进销存浏览
  854. public function _type($arg_array)
  855. {
  856. $vip = 0;
  857. if(isset($_SESSION['api']))
  858. {
  859. $user = $this->user->get_api($_SESSION['api']);
  860. if($user['vip'] == 1)
  861. {
  862. $vip = 1;
  863. }
  864. }
  865. else
  866. {
  867. header('Location: /');exit;
  868. }
  869. if(isset($arg_array[0]))
  870. {
  871. if($arg_array[0] == 'del')
  872. {
  873. $s = $this->input->post('s',true);
  874. $del = $this->_0kcdel($s);
  875. echo $del;exit;
  876. }
  877. }
  878. $post = $this->input->post(NULL, TRUE);
  879. if(isset($post['page']))
  880. {
  881. $page = $this->input->post('page',true);
  882. $perpage = $this->input->post('perpage',true);
  883. $category = $this->input->post('category',true);
  884. $size = $this->input->post('size',true);
  885. $grade = $this->input->post('grade',true);
  886. $color = $this->input->post('color',true);
  887. $lowe = $this->input->post('lowe',true);
  888. $sku = $this->input->post('sku');
  889. $title = $this->input->post('title');
  890. $warehouse = $this->input->post('warehouse',true);
  891. $usa = $this->input->post('usa',true);
  892. $purchase = $this->input->post('purchase',true);
  893. $lacetype = $this->input->post('lacetype',true);
  894. $haircap = $this->input->post('haircap',true);
  895. $density = $this->input->post('density',true);
  896. $details = $this->input->post('details',true);
  897. $state = $this->input->post('state',true);
  898. $ktime = $this->input->post('ktime',true);
  899. $jtime = $this->input->post('jtime',true);
  900. $ktime = strtotime($ktime);
  901. $jtime = strtotime($jtime);
  902. $where = "1=1";$gj = "";$ck = "";
  903. if($lacetype)
  904. {
  905. $where .= " and features like '%-$lacetype-%'";
  906. }
  907. if($category)
  908. {
  909. $where .= " and features like '%-$category-%'";
  910. }
  911. if($size)
  912. {
  913. $where .= " and features like '%-$size-%'";
  914. }
  915. if($grade)
  916. {
  917. $where .= " and features like '%-$grade-%'";
  918. }
  919. if($color)
  920. {
  921. $where .= " and features like '%-$color-%'";
  922. }
  923. if($lowe)
  924. {
  925. $where .= " and features like '%-$lowe-%'";
  926. }
  927. if($haircap)
  928. {
  929. $where .= " and features like '%-$haircap-%'";
  930. }
  931. if($density)
  932. {
  933. $where .= " and features like '%-$density-%'";
  934. }
  935. if($usa)
  936. {
  937. if(!$warehouse)
  938. {
  939. $where .= " and (warehouse = '5' or warehouse = '8')";
  940. }
  941. }
  942. if($warehouse)
  943. {
  944. $where .= " and warehouse = '$warehouse'";
  945. }
  946. if($details)
  947. {
  948. $where .= " and details = '$details'";
  949. }
  950. if($purchase)
  951. {
  952. $where .= " and purchase = '$purchase'";
  953. }
  954. if($state)
  955. {
  956. $where .= " and state = '$state'";
  957. }
  958. if($ktime && $jtime)
  959. {
  960. $gj = " and enter > '$ktime' and enter < '$jtime'";
  961. $ck = " and outk > '$ktime' and outk < '$jtime'";
  962. }
  963. //数据排序
  964. $order_str = "id desc";
  965. if(empty($page))
  966. {
  967. $start = 0;
  968. $perpage = 1;
  969. }
  970. else
  971. {
  972. $start = ($page - 1)*$perpage;
  973. }
  974. if($sku)
  975. {
  976. $sku = trim($sku,' ');
  977. $sku = trim($sku,' ');
  978. $where .= " and sku like '%$sku%'";
  979. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
  980. }
  981. else if($title)
  982. {
  983. $title = trim($title,' ');
  984. $title = trim($title,' ');
  985. $where .= " and title like '%$title%'";
  986. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
  987. }
  988. else
  989. {
  990. //$where .= " and time > '$ktime' and time < '$jtime'";
  991. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
  992. }
  993. //取得信息列表
  994. $rows = array();$list = array();
  995. foreach ($info_list as $key=>$value)
  996. {
  997. $wid = $this->specialstock->read($value['id']);
  998. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  999. $g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
  1000. $x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
  1001. $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$wid['warehouse'].'"');
  1002. $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
  1003. $od = array();$odid = '';
  1004. foreach ($z as $v)
  1005. {
  1006. if(!isset($od[$v['zd']]))
  1007. {
  1008. $od[$v['zd']] = 1;//所有数据sku
  1009. }
  1010. else
  1011. {
  1012. $od[$v['zd']] = $od[$v['zd']]+1;
  1013. }
  1014. }
  1015. foreach ($od as $k=>$vv)
  1016. {
  1017. $odid .= $k.'数量'.$vv;
  1018. }
  1019. $ftime = time()-15*24*3600;
  1020. $z = count($z).'('.$odid.')';//查看订单号
  1021. $info_list[$key]['features'] = count($c);
  1022. $info_list[$key]['g'] = $g;
  1023. $info_list[$key]['x'] = $x;
  1024. $info_list[$key]['t'] = $t;
  1025. $info_list[$key]['z'] = $z;
  1026. $details = array();
  1027. $cpid = array();
  1028. foreach ($c as $k=>$v)
  1029. {
  1030. $details[$v['details']] = $v['details'];
  1031. if($v['cpid'] != 0)
  1032. {
  1033. $cpid[$v['cpid']] = $v['cpid'];
  1034. }
  1035. }
  1036. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1037. }
  1038. $total = count($this->specialstock->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features'));
  1039. $pagenum = ceil($total/$perpage);
  1040. $over = $total-($start+$perpage);
  1041. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1042. echo json_encode($rows);exit;
  1043. }
  1044. $this->data['vip'] = $vip;
  1045. $this->_Template('specialstock_type',$this->data);
  1046. }
  1047. public function _xhctypedy()
  1048. {
  1049. $post = $this->input->post(NULL, TRUE);
  1050. if(isset($post['page']))
  1051. {
  1052. $page = $this->input->post('page',true);
  1053. $perpage = $this->input->post('perpage',true);
  1054. $category = $this->input->post('category',true);
  1055. $size = $this->input->post('size',true);
  1056. $grade = $this->input->post('grade',true);
  1057. $color = $this->input->post('color',true);
  1058. $lowe = $this->input->post('lowe',true);
  1059. $sku = $this->input->post('sku',true);
  1060. $details = $this->input->post('details',true);
  1061. $warehouse = $this->input->post('warehouse',true);
  1062. $purchase = $this->input->post('purchase',true);
  1063. $lacetype = $this->input->post('lacetype',true);
  1064. $state = $this->input->post('state',true);
  1065. $ktime = $this->input->post('ktime',true);
  1066. $jtime = $this->input->post('jtime',true);
  1067. $ktime = strtotime($ktime);
  1068. $jtime = strtotime($jtime);
  1069. $where = "warehouse != '12'";$gj = "";$ck = "";
  1070. if($category)
  1071. {
  1072. $where .= " and features like '%-$category-%'";
  1073. }
  1074. if($size)
  1075. {
  1076. $where .= " and features like '%-$size-%'";
  1077. }
  1078. if($grade)
  1079. {
  1080. $where .= " and features like '%-$grade-%'";
  1081. }
  1082. if($color)
  1083. {
  1084. $where .= " and features like '%-$color-%'";
  1085. }
  1086. if($lowe)
  1087. {
  1088. $where .= " and features like '%-$lowe-%'";
  1089. }
  1090. if($lacetype)
  1091. {
  1092. $where .= " and features like '%-$lacetype-%'";
  1093. }
  1094. if($warehouse)
  1095. {
  1096. $where .= " and warehouse = '$warehouse'";
  1097. }
  1098. if($purchase)
  1099. {
  1100. $where .= " and purchase = '$purchase'";
  1101. }
  1102. if($state)
  1103. {
  1104. $where .= " and state = '$state'";
  1105. }
  1106. if($sku)
  1107. {
  1108. $where .= " and sku like '%$sku%'";
  1109. }
  1110. if($details)
  1111. {
  1112. $where .= " and details like '%$details%'";
  1113. }
  1114. if($ktime && $jtime)
  1115. {
  1116. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1117. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1118. }
  1119. //数据排序
  1120. $order_str = "id desc";
  1121. if(empty($page))
  1122. {
  1123. $start = 0;
  1124. $perpage = 1;
  1125. }
  1126. else
  1127. {
  1128. $start = ($page - 1)*$perpage;
  1129. }
  1130. //取得信息列表
  1131. $info_list = $this->specialstock->find_all($where,'*');
  1132. $rows = array();$list = array();
  1133. foreach ($info_list as $key=>$value)
  1134. {
  1135. $rows[$value['number'].$value['details'].$value['warehouse']] = $value;//所有数据sku
  1136. }
  1137. foreach ($rows as $k=>$value)
  1138. {
  1139. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1140. if($c < 1)
  1141. {
  1142. unset($rows[$k]);
  1143. }
  1144. }
  1145. $rowsdq = array_slice($rows,$start,$perpage);
  1146. foreach ($rowsdq as $value)
  1147. {
  1148. $warehouse = $this->warehouse->read($value['warehouse']);
  1149. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1150. $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1151. $number = $value['number'];$ftime = time()-15*24*3600;
  1152. $z = count($z);//查看订单号
  1153. //$z = $od;
  1154. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'wz'=>$value['details'],'bz'=>$value['cpbz'],'c'=>$c,'z'=>$z);
  1155. }
  1156. $total = count($rows);
  1157. $pagenum = ceil($total/$perpage);
  1158. $over = $total-($start+$perpage);
  1159. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1160. echo json_encode($rows);exit;
  1161. }
  1162. $this->_Template('specialstock_xhctypedy',$this->data);
  1163. }
  1164. //进销存浏览
  1165. public function _xhctype($arg_array)
  1166. {
  1167. $post = $this->input->post(NULL, TRUE);
  1168. if(isset($arg_array[0]))
  1169. {
  1170. if($arg_array[0] == 'del')
  1171. {
  1172. $s = $this->input->post('s',true);
  1173. $del = $this->_del($s);
  1174. echo $del;exit;
  1175. }
  1176. }
  1177. if(isset($post['page']))
  1178. {
  1179. $page = $this->input->post('page',true);
  1180. $perpage = $this->input->post('perpage',true);
  1181. $category = $this->input->post('category',true);
  1182. $size = $this->input->post('size',true);
  1183. $grade = $this->input->post('grade',true);
  1184. $color = $this->input->post('color',true);
  1185. $lowe = $this->input->post('lowe',true);
  1186. $sku = $this->input->post('sku',true);
  1187. $details = $this->input->post('details',true);
  1188. $warehouse = $this->input->post('warehouse',true);
  1189. $purchase = $this->input->post('purchase',true);
  1190. $lacetype = $this->input->post('lacetype',true);
  1191. $state = $this->input->post('state',true);
  1192. $ktime = $this->input->post('ktime',true);
  1193. $jtime = $this->input->post('jtime',true);
  1194. $ktime = strtotime($ktime);
  1195. $jtime = strtotime($jtime);
  1196. $where = "warehouse != '12'";$gj = "";$ck = "";
  1197. if($category)
  1198. {
  1199. $where .= " and features like '%-$category-%'";
  1200. }
  1201. if($size)
  1202. {
  1203. $where .= " and features like '%-$size-%'";
  1204. }
  1205. if($grade)
  1206. {
  1207. $where .= " and features like '%-$grade-%'";
  1208. }
  1209. if($color)
  1210. {
  1211. $where .= " and features like '%-$color-%'";
  1212. }
  1213. if($lowe)
  1214. {
  1215. $where .= " and features like '%-$lowe-%'";
  1216. }
  1217. if($lacetype)
  1218. {
  1219. $where .= " and features like '%-$lacetype-%'";
  1220. }
  1221. if($warehouse)
  1222. {
  1223. $where .= " and warehouse = '$warehouse'";
  1224. }
  1225. if($purchase)
  1226. {
  1227. $where .= " and purchase = '$purchase'";
  1228. }
  1229. if($state)
  1230. {
  1231. $where .= " and state = '$state'";
  1232. }
  1233. if($sku)
  1234. {
  1235. $where .= " and sku like '%$sku%'";
  1236. }
  1237. if($details)
  1238. {
  1239. $where .= " and details like '%$details%'";
  1240. }
  1241. if($ktime && $jtime)
  1242. {
  1243. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1244. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1245. }
  1246. //数据排序
  1247. $order_str = "id desc";
  1248. if(empty($page))
  1249. {
  1250. $start = 0;
  1251. $perpage = 1;
  1252. }
  1253. else
  1254. {
  1255. $start = ($page - 1)*$perpage;
  1256. }
  1257. //取得信息列表
  1258. $info_list = $this->specialstock->find_all($where,'*');
  1259. $rows = array();$list = array();
  1260. foreach ($info_list as $key=>$value)
  1261. {
  1262. $rows[$value['number'].$value['details'].$value['warehouse']] = $value;//所有数据sku
  1263. }
  1264. $rowsdq = array_slice($rows,$start,$perpage);
  1265. foreach ($rowsdq as $k=>$value)
  1266. {
  1267. $warehouse = $this->warehouse->read($value['warehouse']);
  1268. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1269. $g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1270. $x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1271. $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1272. $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1273. $od = array();$odid = '';
  1274. foreach ($z as $v)
  1275. {
  1276. if(!isset($od[$v['zd']]))
  1277. {
  1278. $od[$v['zd']] = 1;//所有数据sku
  1279. }
  1280. else
  1281. {
  1282. $od[$v['zd']] = $od[$v['zd']]+1;
  1283. }
  1284. }
  1285. foreach ($od as $k=>$vv)
  1286. {
  1287. $odid .= $k.'数量'.$vv;
  1288. }
  1289. $number = $value['number'];$ftime = time()-15*24*3600;
  1290. /**
  1291. if($value['shop'] != '')
  1292. {
  1293. $shop = $value['shop'];
  1294. $orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  1295. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  1296. $order = array_merge($orderdlz,$ordersmt);
  1297. $od = 0;$a = '';$orid = '';
  1298. foreach ($order as $v)
  1299. {
  1300. $or = explode('|',ltrim($v['specialstock'],'|'));
  1301. for($i=0;$i<count($or);$i++)
  1302. {
  1303. $orod = explode('-',$or[$i]);
  1304. if($orod[0] == $number)
  1305. {
  1306. $od += $orod[1];
  1307. }
  1308. }
  1309. $orid .= $v['number'].'-';
  1310. }
  1311. }
  1312. else
  1313. {
  1314. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  1315. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  1316. $order = array_merge($orderdlz,$ordersmt);
  1317. $od = 0;$a = '';$orid = '';$qt = array();
  1318. foreach ($order as $v)
  1319. {
  1320. $or = explode('|',ltrim($v['specialstock'],'|'));
  1321. for($i=0;$i<count($or);$i++)
  1322. {
  1323. $orod = explode('-',$or[$i]);
  1324. if($orod[0] == $number)
  1325. {
  1326. $czzs = $this->specialstock->find_count("number = '$number' and warehouse = '".$value['warehouse']."' and shop = '".$v['shop']."' and state = 0");
  1327. if($czzs > 0)
  1328. {
  1329. if(isset($qt[$v['shop']]))
  1330. {
  1331. if($qt[$v['shop']] < $orod[1])
  1332. {
  1333. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  1334. $orid .= $v['number'].'+数量'.$orod[1].'-';
  1335. }
  1336. else
  1337. {
  1338. $qt[$v['shop']] -= $orod[1];
  1339. }
  1340. }
  1341. else
  1342. {
  1343. $qt[$v['shop']] = $czzs;
  1344. }
  1345. }
  1346. else
  1347. {
  1348. $od += $orod[1];
  1349. $orid .= $v['number'].'+数量'.$orod[1].'-';
  1350. }
  1351. }
  1352. }
  1353. }
  1354. }
  1355. **/
  1356. $z = count($z).'('.$odid.')';//查看订单号
  1357. //$z = $od;
  1358. $wz = ($value['cpid'] > 0)?$value['details'].'-'.$value['cpid']:$value['details'];
  1359. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'wz'=>$wz,'bz'=>$value['cpbz'],'c'=>$c,'g'=>$g,'x'=>$x,'t'=>$t,'z'=>$z);
  1360. }
  1361. $total = count($rows);
  1362. $pagenum = ceil($total/$perpage);
  1363. $over = $total-($start+$perpage);
  1364. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1365. echo json_encode($rows);exit;
  1366. }
  1367. $this->_Template('specialstock_xhctype',$this->data);
  1368. }
  1369. //美仓进销存浏览
  1370. public function _usatype()
  1371. {
  1372. $this->_Template('specialstock_typeusa',$this->data);
  1373. }
  1374. //美仓进销存浏览
  1375. public function _usatypeapp()
  1376. {
  1377. $post = $this->input->post(NULL, TRUE);
  1378. if(isset($post['page']))
  1379. {
  1380. $page = $this->input->post('page',true);
  1381. $perpage = $this->input->post('perpage',true);
  1382. $sku = $this->input->post('sku',true);
  1383. $warehouse = '5';
  1384. $title = $this->input->post('title',true);
  1385. $state = $this->input->post('state',true);
  1386. $ktime = $this->input->post('ktime',true);
  1387. $jtime = $this->input->post('jtime',true);
  1388. $ktime = strtotime($ktime);
  1389. $jtime = strtotime($jtime);
  1390. $where = "1=1";$gj = "";$ck = "";
  1391. if($title)
  1392. {
  1393. $st = explode(' ',trim($title,' '));
  1394. foreach ($st as $v)
  1395. {
  1396. $where .= " and title like '%$v%'";
  1397. }
  1398. }
  1399. if($warehouse)
  1400. {
  1401. $where .= " and warehouse = '$warehouse'";
  1402. }
  1403. if($state)
  1404. {
  1405. $where .= " and state = '$state'";
  1406. }
  1407. if($sku)
  1408. {
  1409. $where .= " and sku like '%$sku%'";
  1410. }
  1411. if($ktime && $jtime)
  1412. {
  1413. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1414. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1415. }
  1416. //数据排序
  1417. $order_str = "id desc";
  1418. if(empty($page))
  1419. {
  1420. $start = 0;
  1421. $perpage = 1;
  1422. }
  1423. else
  1424. {
  1425. $start = ($page - 1)*$perpage;
  1426. }
  1427. //取得信息列表
  1428. $info_list = $this->specialstock->find_all($where,'*');
  1429. $rows = array();$list = array();
  1430. foreach ($info_list as $key=>$value)
  1431. {
  1432. $rows[$value['sku'].'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1433. }
  1434. $rowsdq = array_slice($rows,$start,$perpage);
  1435. foreach ($rowsdq as $value)
  1436. {
  1437. $warehouse = $this->warehouse->read($value['warehouse']);
  1438. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1439. $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1440. $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1441. $od = array();$odid = '';
  1442. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1443. }
  1444. $total = count($rows);
  1445. $pagenum = ceil($total/$perpage);
  1446. $over = $total-($start+$perpage);
  1447. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1448. echo json_encode($rows);exit;
  1449. }
  1450. $this->_Template('phone/p_usatypeapp',$this->data);
  1451. }
  1452. //入库操作
  1453. public function _enteradd()
  1454. {
  1455. $dt = 0;
  1456. if(isset($_SESSION['api']))
  1457. {
  1458. $user = $this->user->get_api($_SESSION['api']);
  1459. $usp = $user;
  1460. $fgshop = "";$sid = "";
  1461. $user = explode('|',trim($user['shop'],'|'));
  1462. foreach ($user as $value)
  1463. {
  1464. $fgshop .= " shop = ".$value." or";
  1465. $sid .= " id = ".$value." or";
  1466. }
  1467. }
  1468. $post = $this->input->post(NULL, TRUE);
  1469. if(isset($post['details']))
  1470. {
  1471. $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
  1472. $order = $this->input->post('order',true);
  1473. $post['details'] = $this->input->post('details',true);
  1474. $post['sku'] = $this->input->post('sku',true);
  1475. $category = $this->input->post('category',true);
  1476. $list['category'] = $category;
  1477. $list['hairtype'] = $this->input->post('hairtype',true);
  1478. $list['grade'] = $this->input->post('grade',true);
  1479. $size = $this->input->post('size',true);
  1480. $list['size'] = rtrim($size,',');
  1481. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1482. $list['extension'] = $this->input->post('extension',true);
  1483. if($category == 1297)
  1484. {
  1485. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1486. }
  1487. if($category == 1702)
  1488. {
  1489. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1490. $list['syother'] = $this->input->post('syother',true);
  1491. }
  1492. if($category == 133)
  1493. {
  1494. $list['fittype'] = $this->input->post('fittype',true);
  1495. $list['acother'] = $this->input->post('acother',true);
  1496. }
  1497. $list['color'] = $this->input->post('color',true);
  1498. $list['lowe'] = $this->input->post('lowe',true);
  1499. $post['warehouse'] = $this->input->post('warehouse',true);
  1500. if($category == 127)
  1501. {
  1502. $list['type'] = $this->input->post('type',true);
  1503. $list['headroad'] = $this->input->post('headroad',true);
  1504. $list['density'] = $this->input->post('density',true);
  1505. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1506. {
  1507. $list['lacesize'] = $this->input->post('lacesize',true);
  1508. }
  1509. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1510. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1511. }
  1512. if($category == 128)
  1513. {
  1514. $list['lacetype'] = $this->input->post('lacetype',true);
  1515. $list['haircap'] = $this->input->post('haircap',true);
  1516. $list['density'] = $this->input->post('density',true);
  1517. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1518. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1519. $list['wigother'] = $this->input->post('wigother',true);
  1520. }
  1521. if($category == 129)
  1522. {
  1523. $list['wide'] = $this->input->post('wide',true);
  1524. }
  1525. if($category == 131)
  1526. {
  1527. $list['gifttype'] = $this->input->post('gifttype',true);
  1528. $list['giftother'] = $this->input->post('giftother',true);
  1529. }
  1530. if($category == 134)
  1531. {
  1532. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1533. }
  1534. if($category == 1297)
  1535. {
  1536. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1537. $list['sywigother'] = $this->input->post('sywigother',true);
  1538. }
  1539. if($category == 130 || $category == 133 || $category == 1702)
  1540. {
  1541. $list['items'] = $this->input->post('items',true);
  1542. }
  1543. else if($category == 1702)
  1544. {
  1545. $list['syhairther'] = $this->input->post('syhairther',true);
  1546. }
  1547. foreach($list as $k=>$v)
  1548. {
  1549. if($v != 0)
  1550. {
  1551. $num .=$v;
  1552. $features .=$v.'-';
  1553. $post[$k] = $v;
  1554. $typeclass = $this->typeclass->read($v);
  1555. if($k != 'size')
  1556. {
  1557. $title .= $typeclass['title']." ";
  1558. }
  1559. }
  1560. }
  1561. $typeclass = $this->typeclass->read($list['size']);
  1562. $title .= $typeclass['title'];
  1563. $time = time();
  1564. $post['title'] = rtrim($title,' ');
  1565. $post['number'] = $num;
  1566. $post['features'] = '-'.$features;
  1567. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  1568. $featurespp = explode('-',trim($featurespp,'-'));
  1569. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  1570. $post['enter'] = $time;
  1571. $post['time'] = $time;//操作时间
  1572. for($i=0;$i<$order;$i++)
  1573. {
  1574. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1575. $this->specialstock->insert($post);
  1576. }
  1577. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  1578. }
  1579. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1580. $this->data['wlshop'] = $wlshop;
  1581. $this->_Template('specialstock_enteradd',$this->data);
  1582. }
  1583. //修改产品
  1584. public function _enteredit($arg_array)
  1585. {
  1586. $dt = 0;
  1587. if(isset($_SESSION['api']))
  1588. {
  1589. $user = $this->user->get_api($_SESSION['api']);
  1590. $usp = $user;
  1591. $fgshop = "";$sid = "";
  1592. $user = explode('|',trim($user['shop'],'|'));
  1593. foreach ($user as $value)
  1594. {
  1595. $fgshop .= " shop = ".$value." or";
  1596. $sid .= " id = ".$value." or";
  1597. }
  1598. }
  1599. $post = $this->input->post(NULL, TRUE);
  1600. if(isset($post['details']))
  1601. {
  1602. $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
  1603. $id = $this->input->post('id',true);
  1604. $order = $this->input->post('order',true);
  1605. $post['details'] = $this->input->post('details',true);
  1606. $post['sku'] = $this->input->post('sku',true);
  1607. $category = $this->input->post('category',true);
  1608. $list['category'] = $category;
  1609. $list['hairtype'] = $this->input->post('hairtype',true);
  1610. $list['grade'] = $this->input->post('grade',true);
  1611. $size = $this->input->post('size',true);
  1612. $list['size'] = rtrim($size,',');
  1613. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1614. $list['extension'] = $this->input->post('extension',true);
  1615. if($category == 1297)
  1616. {
  1617. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1618. }
  1619. if($category == 1702)
  1620. {
  1621. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1622. $list['syother'] = $this->input->post('syother',true);
  1623. }
  1624. if($category == 133)
  1625. {
  1626. $list['fittype'] = $this->input->post('fittype',true);
  1627. $list['acother'] = $this->input->post('acother',true);
  1628. }
  1629. $list['color'] = $this->input->post('color',true);
  1630. $list['lowe'] = $this->input->post('lowe',true);
  1631. $post['warehouse'] = $this->input->post('warehouse',true);
  1632. if($category == 127)
  1633. {
  1634. $list['type'] = $this->input->post('type',true);
  1635. $list['headroad'] = $this->input->post('headroad',true);
  1636. $list['density'] = $this->input->post('density',true);
  1637. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1638. {
  1639. $list['lacesize'] = $this->input->post('lacesize',true);
  1640. }
  1641. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1642. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1643. }
  1644. if($category == 128)
  1645. {
  1646. $list['lacetype'] = $this->input->post('lacetype',true);
  1647. $list['haircap'] = $this->input->post('haircap',true);
  1648. $list['density'] = $this->input->post('density',true);
  1649. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1650. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1651. $list['wigother'] = $this->input->post('wigother',true);
  1652. }
  1653. if($category == 129)
  1654. {
  1655. $list['wide'] = $this->input->post('wide',true);
  1656. }
  1657. if($category == 131)
  1658. {
  1659. $list['gifttype'] = $this->input->post('gifttype',true);
  1660. $list['giftother'] = $this->input->post('giftother',true);
  1661. }
  1662. if($category == 134)
  1663. {
  1664. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1665. }
  1666. if($category == 1297)
  1667. {
  1668. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1669. $list['sywigother'] = $this->input->post('sywigother',true);
  1670. }
  1671. if($category == 130 || $category == 133 || $category == 1702)
  1672. {
  1673. $list['items'] = $this->input->post('items',true);
  1674. }
  1675. else if($category == 1702)
  1676. {
  1677. $list['syhairther'] = $this->input->post('syhairther',true);
  1678. }
  1679. foreach($list as $k=>$v)
  1680. {
  1681. if($v != 0)
  1682. {
  1683. $num .=$v;
  1684. $features .=$v.'-';
  1685. $typeclass = $this->typeclass->read($v);
  1686. if($k != 'size')
  1687. {
  1688. $title .= $typeclass['title']." ";
  1689. }
  1690. }
  1691. }
  1692. $typeclass = $this->typeclass->read($list['size']);
  1693. $title .= $typeclass['title'];
  1694. $time = time();
  1695. $post['title'] = rtrim($title,' ');
  1696. $post['number'] = $num;
  1697. $post['features'] = '-'.$features;
  1698. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  1699. $featurespp = explode('-',trim($featurespp,'-'));
  1700. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  1701. $post['time'] = $time;//操作时间
  1702. $uid = $this->specialstock->read($id);
  1703. $datanum = $this->specialstock->find_count("state = 0 and number = '".$uid['number']."' and zd != ''");
  1704. if($datanum > 0)
  1705. {
  1706. echo json_encode(array('msg'=>'此库存有占单,请解除占单后再修改!','success'=>false));exit;
  1707. }
  1708. $data = $this->specialstock->find_all("number = '".$uid['number']."' and enter = '".$uid['enter']."'");// and enter = '".$uid['enter']."'
  1709. foreach ($data as $v)
  1710. {
  1711. $post['id'] = $v['id'];
  1712. $this->specialstock->save($post,$v['id']);
  1713. }
  1714. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  1715. }
  1716. $uid = $this->specialstock->read($arg_array[0]);
  1717. $uid['order'] = $this->specialstock->find_count('enter = '.$uid['enter']);
  1718. $this->data['enter'] = $uid ;
  1719. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1720. $this->data['wlshop'] = $wlshop;
  1721. $whlabelwz = $this->whlabelwz->find_all();
  1722. $this->data['whlabelwz'] = $whlabelwz;
  1723. $this->_Template('specialstock_enteredit',$this->data);
  1724. }
  1725. //入库浏览
  1726. public function _enter()
  1727. {
  1728. $post = $this->input->post(NULL, TRUE);
  1729. if(isset($post['s']))
  1730. {
  1731. $id_arr = $this->input->post('s');
  1732. $id_arr = explode(',',$id_arr);
  1733. if(!$id_arr)
  1734. {
  1735. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1736. }
  1737. //循环删除记录
  1738. foreach ($id_arr as $v)
  1739. {
  1740. $sid = $this->specialstock->read($v);
  1741. $info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
  1742. foreach ($info_list as $va)
  1743. {
  1744. $this->specialstock->remove($va['id']);
  1745. }
  1746. }
  1747. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  1748. }
  1749. if(isset($post['page']))
  1750. {
  1751. $page = $this->input->post('page',true);
  1752. $perpage = $this->input->post('perpage',true);
  1753. $category = $this->input->post('category',true);
  1754. $size = $this->input->post('size',true);
  1755. $grade = $this->input->post('grade',true);
  1756. $color = $this->input->post('color',true);
  1757. $details = $this->input->post('details',true);
  1758. $sku = $this->input->post('sku',true);
  1759. $warehouse = '';//12
  1760. $ktime = $this->input->post('ktime',true);
  1761. $jtime = $this->input->post('jtime',true);
  1762. $ktime = strtotime($ktime);
  1763. $jtime = strtotime($jtime);
  1764. $where = "1=1";$gj = "";$ck = "";
  1765. if($category)
  1766. {
  1767. $where .= " and features like '%-$category-%'";
  1768. }
  1769. if($size)
  1770. {
  1771. $where .= " and features like '%-$size-%'";
  1772. }
  1773. if($grade)
  1774. {
  1775. $where .= " and features like '%-$grade-%'";
  1776. }
  1777. if($color)
  1778. {
  1779. $where .= " and features like '%-$color-%'";
  1780. }
  1781. if($details)
  1782. {
  1783. $where .= " and details like '%$details%'";
  1784. }
  1785. if($sku)
  1786. {
  1787. $where .= " and sku like '%$sku%'";
  1788. }
  1789. if($warehouse)
  1790. {
  1791. $where .= " and warehouse = '$warehouse'";
  1792. }
  1793. if($ktime && $jtime)
  1794. {
  1795. $where .= " and enter > '$ktime' and enter < '$jtime'";
  1796. }
  1797. //数据排序
  1798. $order_str = "enter desc";
  1799. if(empty($page))
  1800. {
  1801. $start = 0;
  1802. $perpage = 1;
  1803. }
  1804. else
  1805. {
  1806. $start = ($page - 1)*$perpage;
  1807. }
  1808. //取得信息列表
  1809. $info_list = $this->specialstock->find_all($where,'*',$order_str);
  1810. $rows = array();$list = array();
  1811. foreach ($info_list as $key=>$value)
  1812. {
  1813. $rows[$value['enter'].$value['number']] = $value;//所有数据sku
  1814. }
  1815. foreach ($rows as $value)
  1816. {
  1817. $g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9');
  1818. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'details'=>$value['details'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  1819. }
  1820. $total = count($list);
  1821. $pagenum = ceil($total/$perpage);
  1822. $over = $total-($start+$perpage);
  1823. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  1824. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list),'abc'=>($where));
  1825. echo json_encode($rows);exit;
  1826. }
  1827. $this->_Template('specialstock_enter',$this->data);
  1828. }
  1829. //入库浏览
  1830. public function _xhcenter()
  1831. {
  1832. $post = $this->input->post(NULL, TRUE);
  1833. if(isset($post['s']))
  1834. {
  1835. $id_arr = $this->input->post('s');
  1836. $id_arr = explode(',',$id_arr);
  1837. if(!$id_arr)
  1838. {
  1839. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1840. }
  1841. //循环删除记录
  1842. foreach ($id_arr as $v)
  1843. {
  1844. $sid = $this->specialstock->read($v);
  1845. $info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
  1846. foreach ($info_list as $va)
  1847. {
  1848. $this->specialstock->remove($va['id']);
  1849. }
  1850. }
  1851. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  1852. }
  1853. if(isset($post['page']))
  1854. {
  1855. $page = $this->input->post('page',true);
  1856. $perpage = $this->input->post('perpage',true);
  1857. $category = $this->input->post('category',true);
  1858. $size = $this->input->post('size',true);
  1859. $grade = $this->input->post('grade',true);
  1860. $color = $this->input->post('color',true);
  1861. $details = $this->input->post('details',true);
  1862. $sku = $this->input->post('sku',true);
  1863. $warehouse = $this->input->post('warehouse',true);
  1864. $ktime = $this->input->post('ktime',true);
  1865. $jtime = $this->input->post('jtime',true);
  1866. $ktime = strtotime($ktime);
  1867. $jtime = strtotime($jtime);
  1868. $where = "warehouse != '12'";$gj = "";$ck = "";
  1869. if($category)
  1870. {
  1871. $where .= " and features like '%-$category-%'";
  1872. }
  1873. if($size)
  1874. {
  1875. $where .= " and features like '%-$size-%'";
  1876. }
  1877. if($grade)
  1878. {
  1879. $where .= " and features like '%-$grade-%'";
  1880. }
  1881. if($color)
  1882. {
  1883. $where .= " and features like '%-$color-%'";
  1884. }
  1885. if($details)
  1886. {
  1887. $where .= " and details like '%$details%'";
  1888. }
  1889. if($sku)
  1890. {
  1891. $where .= " and sku like '%$sku%'";
  1892. }
  1893. if($warehouse)
  1894. {
  1895. $where .= " and warehouse = '$warehouse'";
  1896. }
  1897. if($ktime && $jtime)
  1898. {
  1899. $where .= " and enter > '$ktime' and enter < '$jtime'";
  1900. }
  1901. //数据排序
  1902. $order_str = "enter desc";
  1903. if(empty($page))
  1904. {
  1905. $start = 0;
  1906. $perpage = 1;
  1907. }
  1908. else
  1909. {
  1910. $start = ($page - 1)*$perpage;
  1911. }
  1912. //取得信息列表
  1913. $info_list = $this->specialstock->find_all($where,'*',$order_str);
  1914. $rows = array();$list = array();
  1915. foreach ($info_list as $key=>$value)
  1916. {
  1917. $rows[$value['enter'].$value['number']] = $value;//所有数据sku
  1918. }
  1919. foreach ($rows as $value)
  1920. {
  1921. $g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9');
  1922. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'details'=>$value['details'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  1923. }
  1924. $total = count($list);
  1925. $pagenum = ceil($total/$perpage);
  1926. $over = $total-($start+$perpage);
  1927. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  1928. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1929. echo json_encode($rows);exit;
  1930. }
  1931. $this->_Template('specialstock_xhcenter',$this->data);
  1932. }
  1933. //出库浏览
  1934. public function _out()
  1935. {
  1936. $post = $this->input->post(NULL, TRUE);
  1937. if(isset($post['page']))
  1938. {
  1939. $page = $this->input->post('page',true);
  1940. $perpage = $this->input->post('perpage',true);
  1941. $category = $this->input->post('category',true);
  1942. $size = $this->input->post('size',true);
  1943. $grade = $this->input->post('grade',true);
  1944. $color = $this->input->post('color',true);
  1945. $lowe = $this->input->post('lowe',true);
  1946. $sku = $this->input->post('sku',true);
  1947. $warehouse = $this->input->post('warehouse',true);
  1948. $purchase = $this->input->post('purchase',true);
  1949. $ktime = $this->input->post('ktime',true);
  1950. $jtime = $this->input->post('jtime',true);
  1951. $ktime = strtotime($ktime);
  1952. $jtime = strtotime($jtime);
  1953. $where = "state=3";$gj = "";$ck = "";
  1954. if($category)
  1955. {
  1956. $where .= " and features like '%-$category-%'";
  1957. }
  1958. if($size)
  1959. {
  1960. $where .= " and features like '%-$size-%'";
  1961. }
  1962. if($grade)
  1963. {
  1964. $where .= " and features like '%-$grade-%'";
  1965. }
  1966. if($color)
  1967. {
  1968. $where .= " and features like '%-$color-%'";
  1969. }
  1970. if($lowe)
  1971. {
  1972. $where .= " and features like '%-$lowe-%'";
  1973. }
  1974. if($state)
  1975. {
  1976. $where .= " and state = '$state'";
  1977. }
  1978. if($warehouse)
  1979. {
  1980. $where .= " and warehouse = '$warehouse'";
  1981. }
  1982. if($purchase)
  1983. {
  1984. $where .= " and purchase = '$purchase'";
  1985. }
  1986. if($sku)
  1987. {
  1988. $where .= " and sku = '$sku'";
  1989. }
  1990. if($ktime && $jtime)
  1991. {
  1992. $where .= " and outk > '$ktime' and outk < '$jtime'";
  1993. }
  1994. //数据排序
  1995. $order_str = "id desc";
  1996. if(empty($page))
  1997. {
  1998. $start = 0;
  1999. $perpage = 1;
  2000. }
  2001. else
  2002. {
  2003. $start = ($page - 1)*$perpage;
  2004. }
  2005. //取得信息列表
  2006. $info_list = $this->specialstock->find_all($where,'sku');
  2007. $rows = array();$list = array();
  2008. foreach ($info_list as $key=>$value)
  2009. {
  2010. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2011. }
  2012. $rows = array_unique($rows);//删除重复记录
  2013. foreach ($rows as $key=>$value)
  2014. {
  2015. $data = $this->specialstock->get_sku($value);//获取目前sku的所有数据
  2016. $ck = $this->warehouse->read($data['warehouse']);
  2017. $warehouse = $ck['title'];
  2018. $gy = $this->purchase->read($data['purchase']);
  2019. $purchase = $gy['purchase'];
  2020. $g = $this->specialstock->find_count($where.' and sku = "'.$value.'" and state = 3');
  2021. $list[] = array('id'=>$data['id'],'warehouse'=>$warehouse,'purchase'=>$purchase,'sku'=>$data['sku'],'title'=>$data['title'],'time'=>date('Y-m-d H:i:s',$data['enter']),'number'=>$g);
  2022. }
  2023. $total = count($list);
  2024. $pagenum = ceil($total/$perpage);
  2025. $over = $total-($start+$perpage);
  2026. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2027. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2028. echo json_encode($rows);exit;
  2029. }
  2030. $this->_Template('specialstock_out',$this->data);
  2031. }
  2032. //出库标签浏览
  2033. public function _label()
  2034. {
  2035. $post = $this->input->post(NULL, TRUE);
  2036. if(isset($post['page']))
  2037. {
  2038. $page = $this->input->post('page',true);
  2039. $perpage = $this->input->post('perpage',true);
  2040. $sku = $this->input->post('sku',true);
  2041. $warehouse = $this->input->post('warehouse',true);
  2042. $purchase = $this->input->post('purchase',true);
  2043. $orderinfo = $this->input->post('orderinfo',true);
  2044. $waybill = $this->input->post('waybill',true);
  2045. $category = $this->input->post('category',true);
  2046. $size = $this->input->post('size',true);
  2047. $grade = $this->input->post('grade',true);
  2048. $color = $this->input->post('color',true);
  2049. $lowe = $this->input->post('lowe',true);
  2050. $where = "state=1";
  2051. if($sku)
  2052. {
  2053. $where .= " and sku = '$sku'";
  2054. }
  2055. if($warehouse)
  2056. {
  2057. $where .= " and warehouse = '$warehouse'";
  2058. }
  2059. if($purchase)
  2060. {
  2061. $where .= " and purchase = '$purchase'";
  2062. }
  2063. if($orderinfo)
  2064. {
  2065. $where .= " and orderinfo = '$orderinfo'";
  2066. }
  2067. if($waybill)
  2068. {
  2069. $where .= " and waybill = '$waybill'";
  2070. }
  2071. if($category)
  2072. {
  2073. $where .= " and features like '%-$category-%'";
  2074. }
  2075. if($size)
  2076. {
  2077. $where .= " and features like '%-$size-%'";
  2078. }
  2079. if($grade)
  2080. {
  2081. $where .= " and features like '%-$grade-%'";
  2082. }
  2083. if($color)
  2084. {
  2085. $where .= " and features like '%-$color-%'";
  2086. }
  2087. if($lowe)
  2088. {
  2089. $where .= " and features like '%-$lowe-%'";
  2090. }
  2091. //数据排序
  2092. $order_str = "outk desc";
  2093. if(empty($page))
  2094. {
  2095. $start = 0;
  2096. $perpage = 1;
  2097. }
  2098. else
  2099. {
  2100. $start = ($page - 1)*$perpage;
  2101. }
  2102. //取得信息列表
  2103. $info_list = $this->specialstock->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2104. foreach ($info_list as $key=>$value)
  2105. {
  2106. $warehouse = $this->warehouse->read($value['warehouse']);
  2107. $info_list[$key]['warehouse'] = $warehouse['title'];
  2108. $purchase = $this->purchase->read($value['purchase']);
  2109. $info_list[$key]['purchase'] = $purchase['title'];
  2110. if($value['outk'] != 0)
  2111. {
  2112. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2113. }
  2114. else
  2115. {
  2116. $info_list[$key]['outk'] = "";
  2117. }
  2118. if($value['orderinfo'] == 0)
  2119. {
  2120. $info_list[$key]['orderinfo'] = "";
  2121. }
  2122. if($value['waybill'] == 0)
  2123. {
  2124. $info_list[$key]['waybill'] = "";
  2125. }
  2126. }
  2127. $total = $this->specialstock->find_count($where);
  2128. $pagenum = ceil($total/$perpage);
  2129. $over = $total-($start+$perpage);
  2130. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2131. echo json_encode($rows);exit;
  2132. }
  2133. $this->_Template('specialstock_label',$this->data);
  2134. }
  2135. //独立站出库订单
  2136. public function _outorder()
  2137. {
  2138. if(isset($_SESSION['api']))
  2139. {
  2140. $user = $this->user->get_api($_SESSION['api']);
  2141. $usp = $user;
  2142. $fgshop = "";$sid = "";
  2143. $user = explode('|',trim($user['shop'],'|'));
  2144. foreach ($user as $value)
  2145. {
  2146. $sid .= " id = ".$value." or";
  2147. }
  2148. }
  2149. $post = $this->input->post(NULL, TRUE);
  2150. if(isset($post['page']))
  2151. {
  2152. $page = $this->input->post('page',true);
  2153. $perpage = $this->input->post('perpage',true);
  2154. $warehouse = $this->input->post('warehouse',true);
  2155. $xztime = $this->input->post('xztime',true);
  2156. $timetk = $this->input->post('timetkk',true);
  2157. $timetj = $this->input->post('timetjj',true);
  2158. $shop = $this->input->post('shop',true);
  2159. $source = $this->input->post('source',true);
  2160. $orderinfo = $this->input->post('orderinfo',true);
  2161. $number = $this->input->post('number',true);
  2162. $express = $this->input->post('express',true);
  2163. $waybill = $this->input->post('waybill',true);
  2164. $library = $this->input->post('library',true);
  2165. $country = $this->input->post('country',true);
  2166. $so = $this->input->post('so',true);
  2167. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2168. $print = $this->input->post('print',true);
  2169. $state = $this->input->post('state',true);
  2170. $timetk = strtotime($timetk);
  2171. $timetj = strtotime($timetj);
  2172. /**
  2173. $sj = $this->input->post('sj',true);
  2174. if($sj)
  2175. {
  2176. $sj = $this->input->post('sj',true);
  2177. }
  2178. else
  2179. {
  2180. $sj = "fullorder";
  2181. }
  2182. **/
  2183. $sj = "fullorder";
  2184. $where = "mergeid = 0";
  2185. if($warehouse)
  2186. {
  2187. $where .= " and type = '$warehouse'";
  2188. }
  2189. if($timetk && $timetj)
  2190. {
  2191. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2192. }
  2193. if($orderinfo)
  2194. {
  2195. $where .= " and orderinfo = '$orderinfo'";
  2196. }
  2197. if($number)
  2198. {
  2199. $where .= " and number = '$number'";
  2200. }
  2201. if($express)
  2202. {
  2203. $where .= " and express = '$express'";
  2204. }
  2205. if($waybill)
  2206. {
  2207. $where .= " and waybill = '$waybill'";
  2208. }
  2209. if($library)
  2210. {
  2211. $where .= " and library = '$library'";
  2212. }
  2213. if($print)
  2214. {
  2215. $where .= " and print = '$print'";
  2216. }
  2217. if($libraryconfirm)
  2218. {
  2219. $where .= " and libraryconfirm = '$libraryconfirm'";
  2220. }
  2221. if($state)
  2222. {
  2223. $where .= " and state = '$state'";
  2224. }
  2225. if($shop)
  2226. {
  2227. $where .= " and shop = '$shop'";
  2228. }
  2229. if($country)
  2230. {
  2231. $where .= " and country = '$country'";
  2232. }
  2233. if($so)
  2234. {
  2235. $where .= " and shipremarks like '%$so%'";
  2236. }
  2237. if($source)
  2238. {
  2239. $where .= " and source = '$source'";
  2240. }
  2241. else
  2242. {
  2243. if(isset($_SESSION['api']))
  2244. {
  2245. foreach ($user as $value)
  2246. {
  2247. $fgshop .= " shop = ".$value." or";
  2248. }
  2249. $where .= " and (".rtrim($fgshop,'or').")";
  2250. }
  2251. }
  2252. //数据排序
  2253. $order_str = "librarytime desc";
  2254. if(empty($page))
  2255. {
  2256. $start = 0;
  2257. $perpage = 1;
  2258. }
  2259. else
  2260. {
  2261. $start = ($page - 1)*$perpage;
  2262. }
  2263. //取得信息列表
  2264. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2265. //格式化数据
  2266. foreach ($info_list as $key=>$value)
  2267. {
  2268. $shop = $this->shop->read($value['shop']);
  2269. $info_list[$key]['shop'] = $shop['shopname'];
  2270. $express = $this->express->read($value['express']);
  2271. $info_list[$key]['express'] = $express['servicename'];
  2272. $warehouse = $this->warehouse->read($value['type']);
  2273. $info_list[$key]['type'] = $warehouse['title'];
  2274. if($value['librarytime'] == '0')
  2275. {
  2276. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2277. }
  2278. else
  2279. {
  2280. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2281. }
  2282. }
  2283. $total = $this->$sj->find_count($where);
  2284. $pagenum = ceil($total/$perpage);
  2285. $over = $total-($start+$perpage);
  2286. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2287. echo json_encode($rows);exit;
  2288. }
  2289. $this->data['express'] = $this->express->find_all();
  2290. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2291. $this->data['wlshop'] = $wlshop;
  2292. $this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=2','*','idorder desc');//导出模板
  2293. $this->_Template('specialstock_outorder',$this->data);
  2294. }
  2295. //速卖通出库订单
  2296. public function _soutorder()
  2297. {
  2298. if(isset($_SESSION['api']))
  2299. {
  2300. $user = $this->user->get_api($_SESSION['api']);
  2301. $usp = $user;
  2302. $fgshop = "";$sid = "";
  2303. $user = explode('|',trim($user['shop'],'|'));
  2304. foreach ($user as $value)
  2305. {
  2306. $sid .= " id = ".$value." or";
  2307. }
  2308. }
  2309. $post = $this->input->post(NULL, TRUE);
  2310. if(isset($post['page']))
  2311. {
  2312. $page = $this->input->post('page',true);
  2313. $perpage = $this->input->post('perpage',true);
  2314. $warehouse = $this->input->post('warehouse',true);
  2315. $xztime = $this->input->post('xztime',true);
  2316. $timetk = $this->input->post('timetkk',true);
  2317. $timetj = $this->input->post('timetjj',true);
  2318. $shop = $this->input->post('shop',true);
  2319. $source = $this->input->post('source',true);
  2320. $orderinfo = $this->input->post('orderinfo',true);
  2321. $number = $this->input->post('number',true);
  2322. $express = $this->input->post('express',true);
  2323. $waybill = $this->input->post('waybill',true);
  2324. $library = $this->input->post('library',true);
  2325. $country = $this->input->post('country',true);
  2326. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2327. $print = $this->input->post('print',true);
  2328. $state = $this->input->post('state',true);
  2329. $so = $this->input->post('so',true);
  2330. $timetk = strtotime($timetk);
  2331. $timetj = strtotime($timetj);
  2332. /**
  2333. $sj = $this->input->post('sj',true);
  2334. if($sj)
  2335. {
  2336. $sj = $this->input->post('sj',true);
  2337. }
  2338. else
  2339. {
  2340. $sj = "fullorder";
  2341. }
  2342. **/
  2343. $sj = "fullordersmt";
  2344. $where = "mergeid = 0";
  2345. if($warehouse)
  2346. {
  2347. $where .= " and type = '$warehouse'";
  2348. }
  2349. if($timetk && $timetj)
  2350. {
  2351. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2352. }
  2353. if($orderinfo)
  2354. {
  2355. $where .= " and orderinfo = '$orderinfo'";
  2356. }
  2357. if($number)
  2358. {
  2359. $where .= " and number = '$number'";
  2360. }
  2361. if($express)
  2362. {
  2363. $where .= " and express = '$express'";
  2364. }
  2365. if($waybill)
  2366. {
  2367. $where .= " and waybill = '$waybill'";
  2368. }
  2369. if($library)
  2370. {
  2371. $where .= " and library = '$library'";
  2372. }
  2373. if($print)
  2374. {
  2375. $where .= " and print = '$print'";
  2376. }
  2377. if($libraryconfirm)
  2378. {
  2379. $where .= " and libraryconfirm = '$libraryconfirm'";
  2380. }
  2381. if($state)
  2382. {
  2383. $where .= " and state = '$state'";
  2384. }
  2385. if($shop)
  2386. {
  2387. $where .= " and shop = '$shop'";
  2388. }
  2389. if($so)
  2390. {
  2391. $where .= " and shipremarks like '%$so%'";
  2392. }
  2393. if($source)
  2394. {
  2395. $where .= " and source = '$source'";
  2396. }
  2397. if($country)
  2398. {
  2399. $where .= " and country = '$country'";
  2400. }
  2401. else
  2402. {
  2403. if(isset($_SESSION['api']))
  2404. {
  2405. foreach ($user as $value)
  2406. {
  2407. $fgshop .= " shop = ".$value." or";
  2408. }
  2409. $where .= " and (".rtrim($fgshop,'or').")";
  2410. }
  2411. }
  2412. //数据排序
  2413. $order_str = "librarytime desc";
  2414. if(empty($page))
  2415. {
  2416. $start = 0;
  2417. $perpage = 1;
  2418. }
  2419. else
  2420. {
  2421. $start = ($page - 1)*$perpage;
  2422. }
  2423. //取得信息列表
  2424. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2425. //格式化数据
  2426. foreach ($info_list as $key=>$value)
  2427. {
  2428. $shop = $this->shop->read($value['shop']);
  2429. $info_list[$key]['shop'] = $shop['shopname'];
  2430. $express = $this->express->read($value['express']);
  2431. $info_list[$key]['express'] = $express['servicename'];
  2432. $warehouse = $this->warehouse->read($value['type']);
  2433. $info_list[$key]['type'] = $warehouse['title'];
  2434. if($value['librarytime'] == '0')
  2435. {
  2436. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2437. }
  2438. else
  2439. {
  2440. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2441. }
  2442. }
  2443. $total = $this->$sj->find_count($where);
  2444. $pagenum = ceil($total/$perpage);
  2445. $over = $total-($start+$perpage);
  2446. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2447. echo json_encode($rows);exit;
  2448. }
  2449. $this->data['express'] = $this->express->find_all();
  2450. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2451. $this->data['wlshop'] = $wlshop;
  2452. $this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=5','*','idorder desc');//导出模板
  2453. $this->_Template('specialstock_soutorder',$this->data);
  2454. }
  2455. //订单退库
  2456. public function _retreat()
  2457. {
  2458. $post = $this->input->post(NULL, TRUE);
  2459. if(isset($post['page']))
  2460. {
  2461. $page = $this->input->post('page',true);
  2462. $perpage = $this->input->post('perpage',true);
  2463. $warehouse = $this->input->post('warehouse',true);
  2464. $timetk = $this->input->post('timetk',true);
  2465. $timetj = $this->input->post('timetj',true);
  2466. $shop = $this->input->post('shop',true);
  2467. $source = $this->input->post('source',true);
  2468. $state = $this->input->post('state',true);
  2469. $review = $this->input->post('review',true);
  2470. $state = $this->input->post('state',true);
  2471. $express = $this->input->post('express',true);
  2472. $orderinfo = $this->input->post('orderinfo',true);
  2473. $user = $this->input->post('user',true);
  2474. $name = $this->input->post('name',true);
  2475. $waybill = $this->input->post('waybill',true);
  2476. $timetk = strtotime($timetk);
  2477. $timetj = strtotime($timetj);
  2478. $where = "(state=206 or state=210) and mergeid = 0";
  2479. if($warehouse)
  2480. {
  2481. $where .= " and state = '$warehouse'";
  2482. }
  2483. if($timetk && $timetj)
  2484. {
  2485. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2486. }
  2487. if($shop)
  2488. {
  2489. $where .= " and shop = '$shop'";
  2490. }
  2491. if($source)
  2492. {
  2493. $where .= " and source = '$source'";
  2494. }
  2495. if($state)
  2496. {
  2497. $where .= " and state = '$state'";
  2498. }
  2499. if($review)
  2500. {
  2501. $where .= " and review = '$review'";
  2502. }
  2503. if($state)
  2504. {
  2505. $where .= " and state = '$state'";
  2506. }
  2507. if($express)
  2508. {
  2509. $where .= " and express = '$express'";
  2510. }
  2511. if($orderinfo)
  2512. {
  2513. $where .= " and orderinfo = '$orderinfo'";
  2514. }
  2515. if($user)
  2516. {
  2517. $where .= " and user = '$user'";
  2518. }
  2519. if($name)
  2520. {
  2521. $where .= " and name = '$name'";
  2522. }
  2523. if($waybill)
  2524. {
  2525. $where .= " and waybill = '$waybill'";
  2526. }
  2527. //数据排序
  2528. $order_str = "id desc";
  2529. if(empty($page))
  2530. {
  2531. $start = 0;
  2532. $perpage = 1;
  2533. }
  2534. else
  2535. {
  2536. $start = ($page - 1)*$perpage;
  2537. }
  2538. //取得信息列表
  2539. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  2540. //格式化数据
  2541. foreach ($info_list as $key=>$value)
  2542. {
  2543. $shop = $this->shop->read($value['shop']);
  2544. $info_list[$key]['shop'] = $shop['shopname'];
  2545. $warehouse = $this->warehouse->read($value['warehouse']);
  2546. $info_list[$key]['warehouse'] = $warehouse['title'];
  2547. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  2548. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  2549. if($value['waybill'] == 0)
  2550. {
  2551. $info_list[$key]['waybill'] = "";
  2552. }
  2553. $express = $this->express->read($value['express']);
  2554. $info_list[$key]['express'] = $express['title'];
  2555. $typeclass = $this->typeclass->read($value['state']);
  2556. $info_list[$key]['state'] = $typeclass['title'];
  2557. }
  2558. $total = $this->fullorder->find_count($where);
  2559. $pagenum = ceil($total/$perpage);
  2560. $over = $total-($start+$perpage);
  2561. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2562. echo json_encode($rows);exit;
  2563. }
  2564. $this->data['express'] = $this->express->find_all();
  2565. $this->_Template('specialstock_retreat',$this->data);
  2566. }
  2567. //退库标签浏览
  2568. public function _retreatlk()
  2569. {
  2570. $post = $this->input->post(NULL, TRUE);
  2571. if(isset($post['page']))
  2572. {
  2573. $page = $this->input->post('page',true);
  2574. $perpage = $this->input->post('perpage',true);
  2575. $timetk = $this->input->post('timetk',true);
  2576. $timetj = $this->input->post('timetj',true);
  2577. $sku = $this->input->post('sku',true);
  2578. $warehouse = $this->input->post('warehouse',true);
  2579. $purchase = $this->input->post('purchase',true);
  2580. $orderinfo = $this->input->post('orderinfo',true);
  2581. $waybill = $this->input->post('waybill',true);
  2582. $category = $this->input->post('category',true);
  2583. $size = $this->input->post('size',true);
  2584. $grade = $this->input->post('grade',true);
  2585. $color = $this->input->post('color',true);
  2586. $lowe = $this->input->post('lowe',true);
  2587. $state = $this->input->post('state',true);
  2588. $timetk = strtotime($timetk);
  2589. $timetj = strtotime($timetj);
  2590. $where = "state=2";
  2591. if($timetk && $timetj)
  2592. {
  2593. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  2594. }
  2595. if($sku)
  2596. {
  2597. $where .= " and sku = '$sku'";
  2598. }
  2599. if($warehouse)
  2600. {
  2601. $where .= " and warehouse = '$warehouse'";
  2602. }
  2603. if($purchase)
  2604. {
  2605. $where .= " and purchase = '$purchase'";
  2606. }
  2607. if($orderinfo)
  2608. {
  2609. $where .= " and orderinfo = '$orderinfo'";
  2610. }
  2611. if($waybill)
  2612. {
  2613. $where .= " and waybill = '$waybill'";
  2614. }
  2615. if($category)
  2616. {
  2617. $where .= " and features like '%-$category-%'";
  2618. }
  2619. if($size)
  2620. {
  2621. $where .= " and features like '%-$size-%'";
  2622. }
  2623. if($grade)
  2624. {
  2625. $where .= " and features like '%-$grade-%'";
  2626. }
  2627. if($color)
  2628. {
  2629. $where .= " and features like '%-$color-%'";
  2630. }
  2631. if($lowe)
  2632. {
  2633. $where .= " and features like '%-$lowe-%'";
  2634. }
  2635. //数据排序
  2636. $order_str = "time desc";
  2637. if(empty($page))
  2638. {
  2639. $start = 0;
  2640. $perpage = 1;
  2641. }
  2642. else
  2643. {
  2644. $start = ($page - 1)*$perpage;
  2645. }
  2646. //取得信息列表
  2647. $info_list = $this->specialstock->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  2648. foreach ($info_list as $key=>$value)
  2649. {
  2650. $warehouse = $this->warehouse->read($value['warehouse']);
  2651. $info_list[$key]['warehouse'] = $warehouse['title'];
  2652. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  2653. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  2654. $purchase = $this->purchase->read($value['purchase']);
  2655. $info_list[$key]['purchase'] = $purchase['title'];
  2656. if($value['outk'] != 0)
  2657. {
  2658. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2659. }
  2660. else
  2661. {
  2662. $info_list[$key]['outk'] = "";
  2663. }
  2664. if($value['retreat'] != 0)
  2665. {
  2666. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  2667. }
  2668. else
  2669. {
  2670. $info_list[$key]['retreat'] = "";
  2671. }
  2672. if($value['orderinfo'] == 0)
  2673. {
  2674. $info_list[$key]['orderinfo'] = "";
  2675. }
  2676. if($value['waybill'] == 0)
  2677. {
  2678. $info_list[$key]['waybill'] = "";
  2679. }
  2680. }
  2681. $total = $this->specialstock->find_count($where);
  2682. $pagenum = ceil($total/$perpage);
  2683. $over = $total-($start+$perpage);
  2684. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2685. echo json_encode($rows);exit;
  2686. }
  2687. $this->_Template('specialstock_retreatlk',$this->data);
  2688. }
  2689. //更换标签及浏览
  2690. public function _change()
  2691. {
  2692. $post = $this->input->post(NULL, TRUE);
  2693. if(isset($post['page']))
  2694. {
  2695. $page = $this->input->post('page',true);
  2696. $perpage = $this->input->post('perpage',true);
  2697. $timetk = $this->input->post('timetk',true);
  2698. $timetj = $this->input->post('timetj',true);
  2699. $label = $this->input->post('label',true);
  2700. $oldlabel = $this->input->post('oldlabel',true);
  2701. $timetk = strtotime($timetk);
  2702. $timetj = strtotime($timetj);
  2703. $where = "state=10 ";
  2704. if($timetk && $timetj)
  2705. {
  2706. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  2707. }
  2708. if($label)
  2709. {
  2710. $where .= " and label = '$label'";
  2711. }
  2712. if($oldlabel)
  2713. {
  2714. $where .= " and oldlabel = '$oldlabel'";
  2715. }
  2716. //数据排序
  2717. $order_str = "time asc";
  2718. if(empty($page))
  2719. {
  2720. $start = 0;
  2721. $perpage = 1;
  2722. }
  2723. else
  2724. {
  2725. $start = ($page - 1)*$perpage;
  2726. }
  2727. //取得信息列表
  2728. $info_list = $this->specialstock->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  2729. foreach ($info_list as $key=>$value)
  2730. {
  2731. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  2732. }
  2733. $total = $this->specialstock->find_count($where);
  2734. $pagenum = ceil($total/$perpage);
  2735. $over = $total-($start+$perpage);
  2736. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2737. echo json_encode($rows);exit;
  2738. }
  2739. $this->_Template('specialstock_change',$this->data);
  2740. }
  2741. //产品标签
  2742. public function _cpbqdc()
  2743. {
  2744. if(isset($_GET['excel']))
  2745. {
  2746. $where = "1=1";
  2747. //数据排序
  2748. $order_str = "id desc";
  2749. if(empty($page))
  2750. {
  2751. $start = 0;
  2752. $perpage = 1;
  2753. }
  2754. else
  2755. {
  2756. $start = ($page - 1)*$perpage;
  2757. }
  2758. $warehouse = $this->input->get('warehouse',true);
  2759. $state = $this->input->get('state',true);
  2760. $timetk = $this->input->get('timetkk',true);
  2761. $timetj = $this->input->get('timetjj',true);
  2762. $timetk = strtotime($timetk);
  2763. $timetj = strtotime($timetj);
  2764. if($warehouse)
  2765. {
  2766. $where .= " and warehouse = '$warehouse'";
  2767. }
  2768. if($state || $state == 0)
  2769. {
  2770. $where .= " and state = '$state'";
  2771. }
  2772. if($timetk && $timetj)
  2773. {
  2774. $where .= " and time > '$timetk' and time < '$timetj'";
  2775. }
  2776. //取得信息列表
  2777. $info_list = $this->specialstock->find_all($where,'*');
  2778. $rows = array();$list = array();
  2779. foreach ($info_list as $key=>$value)
  2780. {
  2781. $rows[$value['time']] = $value;//所有数据sku
  2782. }
  2783. foreach ($rows as $value)
  2784. {
  2785. $warehouse = $this->warehouse->read($value['warehouse']);
  2786. $s = $this->specialstock->find_count($where.' and time = "'.$value['time'].'"');
  2787. $list[] = array($warehouse['title'],$value['sku'],$value['title'],date('Y-m-d H:i:s',$value['enter']),date('Y-m-d H:i:s',$value['time']),$value['details'],$s);
  2788. }
  2789. $title = "产品标签统计表";
  2790. $titlename = "<table border=1>
  2791. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  2792. <tr align='center'>
  2793. <td>仓库</td>
  2794. <td>SKU</td>
  2795. <td>产品</td>
  2796. <td>入库时间</td>
  2797. <td>操作时间</td>
  2798. <td>备注</td>
  2799. <td>数量</td>
  2800. </tr>
  2801. </table>";
  2802. $filename = $title.".xls";
  2803. $tail = "";
  2804. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  2805. }
  2806. }
  2807. //进销存导出
  2808. public function _exceljxc()
  2809. {
  2810. if(isset($_GET['excel']))
  2811. {
  2812. $where = "1=1";
  2813. //数据排序
  2814. $order_str = "id desc";
  2815. if(empty($page))
  2816. {
  2817. $start = 0;
  2818. $perpage = 1;
  2819. }
  2820. else
  2821. {
  2822. $start = ($page - 1)*$perpage;
  2823. }
  2824. $category = $this->input->get('category',true);
  2825. $warehouse = $this->input->get('warehouse',true);
  2826. $pc = $this->input->get('pc',true);
  2827. if($pc)
  2828. {
  2829. $pc = trim($pc,'x');
  2830. $pc = explode('x',$pc);
  2831. foreach ($pc as $v)
  2832. {
  2833. $where .= " and warehouse != '".$v."'";
  2834. }
  2835. }
  2836. if($category)
  2837. {
  2838. $where .= " and features like '%-$category-%'";
  2839. }
  2840. if($warehouse)
  2841. {
  2842. $where .= " and warehouse = '$warehouse'";
  2843. }
  2844. //取得信息列表
  2845. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,features,sku,details,warehouse,number,title,cpbz');
  2846. $list = array();
  2847. foreach ($info_list as $value)
  2848. {
  2849. $classid = $this->classid->sku();
  2850. $pm = $classid;
  2851. //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2852. $features = explode('-',trim($value['features'],'-'));
  2853. foreach ($features as $v)
  2854. {
  2855. $typeclass = $this->typeclass->read($v);
  2856. $pm[$typeclass['classid']] = $typeclass['zh'];
  2857. //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2858. }
  2859. $typeclass = $this->typeclass->read($v);
  2860. //$scsku = implode("-",$scsku);
  2861. $zh = implode(" ",$pm);
  2862. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2863. //$scsku = str_replace('- ','-',trim($scsku,'-'));
  2864. //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2865. $cpid = '';
  2866. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"','cpid');
  2867. foreach ($c as $v)
  2868. {
  2869. if($v['cpid'] != 0)
  2870. {
  2871. $cpid .= $v['cpid'].' ';
  2872. }
  2873. }
  2874. $g = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
  2875. $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  2876. $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "2" and features = "'.$value['features'].'"');
  2877. $number = $value['number'];$ftime = time()-15*24*3600;
  2878. $warehouse = $this->warehouse->read($value['warehouse']);
  2879. $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$g,count($c),$x,$t,$value['cpbz']);
  2880. }
  2881. $title = "总进销存统计表";
  2882. $titlename = "<table border=1>
  2883. <tr><th colspan='10' align='center'><h3>".$title."<h3></th></tr>
  2884. <tr align='center'>
  2885. <td>位置</td>
  2886. <td>库存编码</td>
  2887. <td>产品</td>
  2888. <td>SKU</td>
  2889. <td>中文</td>
  2890. <td>入库总量</td>
  2891. <td>库存数量</td>
  2892. <td>销售数量</td>
  2893. <td>退货数量</td>
  2894. <td>备注</td>
  2895. </tr>
  2896. </table>";
  2897. $filename = $title.".xls";
  2898. $tail = "";
  2899. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  2900. }
  2901. }
  2902. //入库导出
  2903. public function _excelr()
  2904. {
  2905. if(isset($_GET['excel']))
  2906. {
  2907. $category = $this->input->get('category',true);
  2908. $size = $this->input->get('size',true);
  2909. $grade = $this->input->get('grade',true);
  2910. $color = $this->input->get('color',true);
  2911. $lowe = $this->input->get('lowe',true);
  2912. $sku = $this->input->get('sku',true);
  2913. $warehouse = $this->input->get('warehouse',true);
  2914. $purchase = $this->input->get('purchase',true);
  2915. $ktime = $this->input->get('ktime',true);
  2916. $jtime = $this->input->get('jtime',true);
  2917. $ktime = strtotime($ktime);
  2918. $jtime = strtotime($jtime);
  2919. $where = "1=1";$gj = "";$ck = "";
  2920. $pc = $this->input->get('pc',true);
  2921. if($pc)
  2922. {
  2923. $pc = trim($pc,'x');
  2924. $pc = explode('x',$pc);
  2925. foreach ($pc as $v)
  2926. {
  2927. $where .= " and warehouse != '".$v."'";
  2928. }
  2929. }
  2930. if($category)
  2931. {
  2932. $where .= " and features like '%-$category-%'";
  2933. }
  2934. if($size)
  2935. {
  2936. $where .= " and features like '%-$size-%'";
  2937. }
  2938. if($grade)
  2939. {
  2940. $where .= " and features like '%-$grade-%'";
  2941. }
  2942. if($color)
  2943. {
  2944. $where .= " and features like '%-$color-%'";
  2945. }
  2946. if($lowe)
  2947. {
  2948. $where .= " and features like '%-$lowe-%'";
  2949. }
  2950. if($warehouse)
  2951. {
  2952. $where .= " and warehouse = '$warehouse'";
  2953. }
  2954. if($purchase)
  2955. {
  2956. $where .= " and purchase = '$purchase'";
  2957. }
  2958. if($sku)
  2959. {
  2960. $where .= " and sku = '$sku'";
  2961. }
  2962. if($ktime && $jtime)
  2963. {
  2964. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  2965. }
  2966. //数据排序
  2967. $order_str = "id desc";
  2968. if(empty($page))
  2969. {
  2970. $start = 0;
  2971. $perpage = 1;
  2972. }
  2973. else
  2974. {
  2975. $start = ($page - 1)*$perpage;
  2976. }
  2977. //取得信息列表
  2978. $info_list = $this->specialstock->find_pc($where,'enter','*',$order_str);
  2979. $list = array();
  2980. foreach ($info_list as $value)
  2981. {
  2982. $ck = $this->warehouse->read($value['warehouse']);
  2983. $warehouse = $ck['title'];
  2984. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  2985. $retreatwarehouse = $tkck['title'];
  2986. $gy = $this->purchase->read($value['purchase']);
  2987. $purchase = $gy['title'];
  2988. $cpid = '';
  2989. $g = $this->specialstock->find_all($where.' and enter = "'.$value['enter'].'"','cpid');
  2990. foreach ($g as $v)
  2991. {
  2992. if($v['cpid'] != 0)
  2993. {
  2994. $cpid .= $v['cpid'].' ';
  2995. }
  2996. }
  2997. $list[] = array('details'=>$value['details'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>count($g),'cpid'=>$cpid);
  2998. }
  2999. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3000. $titlename = "<table border=1>
  3001. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  3002. <tr align='center'>
  3003. <td>备注</td>
  3004. <td>产品</td>
  3005. <td>时间</td>
  3006. <td>数量</td>
  3007. <td>编码</td>
  3008. </tr>
  3009. </table>";
  3010. $filename = $title.".xls";
  3011. $tail = "";
  3012. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3013. }
  3014. }
  3015. //出库、退库导出
  3016. public function _excelct()
  3017. {
  3018. if(isset($_GET['excel']))
  3019. {
  3020. $type = $this->input->get('excel',true);
  3021. $category = $this->input->get('category',true);
  3022. $size = $this->input->get('size',true);
  3023. $grade = $this->input->get('grade',true);
  3024. $color = $this->input->get('color',true);
  3025. $lowe = $this->input->get('lowe',true);
  3026. $lacetype = $this->input->get('lacetype',true);
  3027. $details = $this->input->get('details',true);
  3028. $sku = $this->input->get('sku',true);
  3029. $warehouse = $this->input->get('warehouse',true);
  3030. $purchase = $this->input->get('purchase',true);
  3031. $state = $this->input->get('state',true);
  3032. $sid = $this->input->get('sid',true);
  3033. $ktime = $this->input->get('ktime',true);
  3034. $jtime = $this->input->get('jtime',true);
  3035. $ktime = strtotime($ktime);
  3036. $jtime = strtotime($jtime);
  3037. $where = "1=1";$gj = "";$ck = "";
  3038. $pc = $this->input->get('pc',true);
  3039. if($pc)
  3040. {
  3041. $pc = trim($pc,'x');
  3042. $pc = explode('x',$pc);
  3043. foreach ($pc as $v)
  3044. {
  3045. $where .= " and warehouse != '".$v."'";
  3046. }
  3047. }
  3048. if($category)
  3049. {
  3050. $where .= " and features like '%-$category-%'";
  3051. }
  3052. if($size)
  3053. {
  3054. $where .= " and features like '%-$size-%'";
  3055. }
  3056. if($grade)
  3057. {
  3058. $where .= " and features like '%-$grade-%'";
  3059. }
  3060. if($color)
  3061. {
  3062. $where .= " and features like '%-$color-%'";
  3063. }
  3064. if($lowe)
  3065. {
  3066. $where .= " and features like '%-$lowe-%'";
  3067. }
  3068. if($warehouse)
  3069. {
  3070. $where .= " and warehouse = '$warehouse'";
  3071. }
  3072. if($purchase)
  3073. {
  3074. $where .= " and purchase = '$purchase'";
  3075. }
  3076. if($state)
  3077. {
  3078. $where .= " and state = '$state'";
  3079. }
  3080. if($sku)
  3081. {
  3082. $where .= " and sku like '%$sku%'";
  3083. }
  3084. if($lacetype)
  3085. {
  3086. $where .= " and features like '%-$lacetype-%'";
  3087. }
  3088. if($details)
  3089. {
  3090. $where .= " and details like '%$details%'";
  3091. }
  3092. if($ktime && $jtime)
  3093. {
  3094. if($type == 1)
  3095. {
  3096. $tl = '出库';
  3097. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3098. }
  3099. else if($type == 2)
  3100. {
  3101. $tl = '退库';
  3102. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3103. }
  3104. else if($type == 3)
  3105. {
  3106. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3107. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3108. }
  3109. else if($type == 4)
  3110. {
  3111. $tl = '出库+零售';
  3112. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3113. }
  3114. else if($type == 5)
  3115. {
  3116. $tl = '零售';
  3117. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3118. }
  3119. }
  3120. if($sid)
  3121. {
  3122. $sd = "";
  3123. $s = explode(',',trim($sid,','));
  3124. foreach ($s as $value)
  3125. {
  3126. $sd .= " id = ".$value." or";
  3127. }
  3128. $sidwhere .= " and (".rtrim($sd,'or').")";
  3129. }
  3130. //数据排序
  3131. $order_str = "time desc";
  3132. if(empty($page))
  3133. {
  3134. $start = 0;
  3135. $perpage = 1;
  3136. }
  3137. else
  3138. {
  3139. $start = ($page - 1)*$perpage;
  3140. }
  3141. //取得信息列表
  3142. if($type != 3 && $type != 5)
  3143. {
  3144. if($type == 1 || $type == 4)
  3145. {
  3146. $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,outk,cpbz',$order_str);
  3147. foreach ($info_list as $key=>$value)
  3148. {
  3149. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  3150. }
  3151. }
  3152. else
  3153. {
  3154. $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,retreat,cpbz',$order_str);
  3155. foreach ($info_list as $key=>$value)
  3156. {
  3157. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  3158. }
  3159. }
  3160. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  3161. $titlename = "<table border=1>
  3162. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  3163. <tr align='center'>
  3164. <td>位置</td>
  3165. <td>产品编码</td>
  3166. <td>产品</td>
  3167. <td>标签</td>
  3168. <td>订单号</td>
  3169. <td>运单号</td>
  3170. <td>".$tl."时间(中国时间)</td>
  3171. <td>备注</td>
  3172. </tr>
  3173. </table>";
  3174. $filename = $title.".xls";
  3175. $tail = "";
  3176. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  3177. }
  3178. else if($type == 5)
  3179. {
  3180. $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,outk,cpbz',$order_str);
  3181. foreach ($info_list as $key=>$value)
  3182. {
  3183. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  3184. $warehouse = $this->warehouse->read($value['warehouse']);
  3185. $info_list[$key]['warehouse'] = $warehouse['title'];
  3186. }
  3187. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  3188. $titlename = "<table border=1>
  3189. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3190. <tr align='center'>
  3191. <td>位置</td>
  3192. <td>产品编码</td>
  3193. <td>产品</td>
  3194. <td>标签</td>
  3195. <td>".$tl."时间(中国时间)</td>
  3196. <td>备注</td>
  3197. </tr>
  3198. </table>";
  3199. $filename = $title.".xls";
  3200. $tail = "";
  3201. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  3202. }
  3203. else
  3204. {
  3205. $info_list = $this->specialstock->find_pc($where.$sidwhere,'sku,warehouse,features','*');
  3206. $list = array();
  3207. foreach ($info_list as $value)
  3208. {
  3209. $classid = $this->classid->sku();
  3210. $pm = $classid;
  3211. //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  3212. $features = explode('-',trim($value['features'],'-'));
  3213. foreach ($features as $v)
  3214. {
  3215. $typeclass = $this->typeclass->read($v);
  3216. $pm[$typeclass['classid']] = $typeclass['zh'];
  3217. //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
  3218. }
  3219. $typeclass = $this->typeclass->read($v);
  3220. //$scsku = implode("-",$scsku);
  3221. $zh = implode(" ",$pm);
  3222. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  3223. //$scsku = str_replace('- ','-',trim($scsku,'-'));
  3224. //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  3225. $cpid = '';
  3226. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"','cpid');
  3227. foreach ($c as $v)
  3228. {
  3229. if($v['cpid'] != 0)
  3230. {
  3231. $cpid .= $v['cpid'].' ';
  3232. }
  3233. }
  3234. $g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state != "9"');
  3235. $x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "1"');
  3236. $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "2"');
  3237. $number = $value['number'];$ftime = time()-15*24*3600;
  3238. $warehouse = $this->warehouse->read($value['warehouse']);
  3239. $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$g,count($c),$x,$t,$value['cpbz']);
  3240. }
  3241. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  3242. $titlename = "<table border=1>
  3243. <tr><th colspan='9' align='center'><h3>".$title."<h3></th></tr>
  3244. <tr align='center'>
  3245. <td>位置</td>
  3246. <td>库存编码</td>
  3247. <td>产品</td>
  3248. <td>SKU</td>
  3249. <td>中文</td>
  3250. <td>入库总量</td>
  3251. <td>库存数量</td>
  3252. <td>销售数量</td>
  3253. <td>退货数量</td>
  3254. <td>备注</td>
  3255. </tr>
  3256. </table>";
  3257. $filename = $title.".xls";
  3258. $tail = "";
  3259. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3260. }
  3261. }
  3262. }
  3263. //数量调整模板导出
  3264. public function _presetout()
  3265. {
  3266. if(isset($_GET['excel']))
  3267. {
  3268. $where = "1=1";
  3269. //数据排序
  3270. $order_str = "id desc";
  3271. if(empty($page))
  3272. {
  3273. $start = 0;
  3274. $perpage = 1;
  3275. }
  3276. else
  3277. {
  3278. $start = ($page - 1)*$perpage;
  3279. }
  3280. $pc = $this->input->get('pc',true);
  3281. if($pc)
  3282. {
  3283. $pc = trim($pc,'x');
  3284. $pc = explode('x',$pc);
  3285. foreach ($pc as $v)
  3286. {
  3287. $where .= " and warehouse != '".$v."'";
  3288. }
  3289. }
  3290. //取得信息列表
  3291. $info_list = $this->specialstock->find_all($where,'*');
  3292. $rows = array();$list = array();
  3293. foreach ($info_list as $key=>$value)
  3294. {
  3295. $rows[$value['number']] = $value;//所有数据sku
  3296. }
  3297. foreach ($rows as $value)
  3298. {
  3299. $warehouse = $this->warehouse->read($value['warehouse']);
  3300. $number = $value['number'];$ftime = time()-15*24*3600;
  3301. $list[] = array($value['features'],$value['sku'],'0','','0',$warehouse['title']);
  3302. }
  3303. $title = "库存模板";
  3304. $titlename = "<table border=1>
  3305. <tr align='center'>
  3306. <td>编码号</td>
  3307. <td>SKU</td>
  3308. <td>增减数量(正数或负数)</td>
  3309. <td>扣减备注</td>
  3310. <td>扣减方式:0减少库存1删除库存</td>
  3311. <td>所属仓库</td>
  3312. </tr>
  3313. </table>";
  3314. $filename = $title.".xls";
  3315. $tail = "";
  3316. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3317. }
  3318. }
  3319. //数量调整模板导入
  3320. public function _presetedit()
  3321. {
  3322. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3323. $config['upload_path'] = '.'.$dir ;
  3324. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3325. $config['allowed_types'] = 'xls|xlsx|csv';
  3326. $config['max_size'] = 10240;
  3327. $this->load->library('upload', $config);
  3328. $this->upload->initialize($config);
  3329. if ($this->upload->do_upload('userfile'))
  3330. {
  3331. $full_path = $dir.$this->upload->data('file_name');
  3332. $fileName = '.' . $full_path;
  3333. if (!file_exists($fileName))
  3334. {
  3335. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3336. }
  3337. else
  3338. {
  3339. libxml_use_internal_errors(true);
  3340. require_once "./data/excel/PHPExcel/IOFactory.php";
  3341. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3342. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3343. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3344. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3345. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3346. ++$column;//如果列数大于26行
  3347. $list = array();
  3348. for ($i = 2; $i <= $row; $i++) // 行数循环
  3349. {
  3350. $data = array();
  3351. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3352. {
  3353. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3354. }
  3355. $list[] = $data;
  3356. }
  3357. }
  3358. $i = 0;$j = 0;$ed = array();
  3359. foreach ($list as $key=>$value)
  3360. {
  3361. $time = time();
  3362. if($value['0'] == "")
  3363. {
  3364. continue;
  3365. }
  3366. $features = $value['0'];
  3367. $num = $value['2'];//调整数量
  3368. $text = $value['3'];//扣减说明
  3369. $type = $value['4'];//调整方式0扣减1删除
  3370. $d = $this->specialstock->get_features($features);
  3371. if(!$d)//如果没有这个SKU
  3372. {
  3373. $ed[] = array($title.'-库存中不存在此编码');
  3374. $j++;
  3375. continue;
  3376. }
  3377. if($num < 0)//扣减库存
  3378. {
  3379. $data = $this->specialstock->find_all('warehouse = "'.$warehouse['id'].'" and features = "'.$features.'" and zd = "" and state = 0');
  3380. if(count($data) < abs($num))
  3381. {
  3382. $ed[] = array($title.'-扣减数量大于库存剩余数量!');
  3383. $j++;
  3384. continue;
  3385. }
  3386. if($type == 0)//如果扣减方式为 扣减库存
  3387. {
  3388. for($i=0;$i<abs($num);$i++)
  3389. {
  3390. $this->specialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$data[$i]['id']);
  3391. }
  3392. }
  3393. else
  3394. {
  3395. for($i=0;$i<abs($num);$i++)
  3396. {
  3397. $this->specialstock->remove($data[$i]['id']);
  3398. }
  3399. }
  3400. }
  3401. else if($num > 0)//增加库存
  3402. {
  3403. $post['shop'] = $d['shop'];
  3404. $post['purchase'] = $d['purchase'];
  3405. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  3406. $post['state'] = 0;
  3407. $post['title'] = $d['title'];
  3408. $post['number'] = $d['number'];
  3409. $post['features'] = $d['features'];
  3410. $post['enter'] = $time;
  3411. $post['time'] = $time;//操作时间
  3412. for($i=0;$i<$num;$i++)
  3413. {
  3414. $post['label'] = time().rand(100,999).$i;
  3415. $this->specialstock->insert($post);
  3416. }
  3417. }
  3418. sleep(1);//防止入库时间一样,需要延迟1秒
  3419. }
  3420. if($j > 0)
  3421. {
  3422. $tt = date('Ymd',time());
  3423. $title = '库存导入错误信息-'.$tt;
  3424. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3425. $tail = "\n";
  3426. $filename = $title.".xls";
  3427. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3428. $dir = '/data/excel/'.$time.'/';
  3429. $file_name = 'error_'.$time.rand(1000,9999);
  3430. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3431. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3432. fwrite($myfile,$ecl);
  3433. fclose($myfile);
  3434. $error = $dir.$file_name.'.xls';
  3435. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  3436. }
  3437. else
  3438. {
  3439. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  3440. }
  3441. }
  3442. }
  3443. //笛卡儿积
  3444. function cp($ps,$sets,$list)
  3445. {
  3446. $result = array();$j=0;
  3447. for($i=0,$count=count($sets); $i<$count-1; $i++)
  3448. {
  3449. if($i==0)
  3450. {
  3451. $result = $sets[$i];
  3452. }
  3453. $tmp = array();
  3454. foreach($result as $res)
  3455. {
  3456. foreach($sets[$i+1] as $set)
  3457. {
  3458. $tmp[] = $res.','.$set;
  3459. }
  3460. }
  3461. $result = $tmp;
  3462. }
  3463. $this->db->trans_begin();
  3464. foreach ($result as $v)
  3465. {
  3466. $post = array();$title = "";$num="";
  3467. $data = explode(',',$v);
  3468. for($i=0;$i<count($list); $i++)
  3469. {
  3470. $post[$list[$i]] = $data[$i];
  3471. $typeclass = $this->typeclass->read($data[$i]);
  3472. $title = $title.$typeclass['title']." ";
  3473. if($data[$i] != 0)
  3474. {
  3475. $num .=$data[$i];//所有数据ID拼接
  3476. }
  3477. }
  3478. foreach ($ps as $kp=>$vp)
  3479. {
  3480. $post[$kp] = $vp;
  3481. }
  3482. $post['number'] = $num;
  3483. $info_list = $this->specialstock->get_number($num);//查询specialstock是否存在此拼接的数据ID
  3484. if($info_list)
  3485. {
  3486. $j++;
  3487. }
  3488. else
  3489. {
  3490. $skunum = $this->specialstock->find_count();
  3491. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  3492. $post['title'] = rtrim($title,' ');
  3493. $this->specialstock->insert($post);
  3494. }
  3495. }
  3496. if ($this->db->trans_status() === FALSE)
  3497. {
  3498. $this->db->trans_commit();
  3499. return NULL;
  3500. }
  3501. else
  3502. {
  3503. $this->db->trans_commit();
  3504. return $j;
  3505. }
  3506. }
  3507. public function _kj($arg_array)
  3508. {
  3509. if(isset($_POST['number']))
  3510. {
  3511. $time = time();
  3512. $number = $this->input->post('number',true);
  3513. $num = $this->input->post('num',true);
  3514. $text = $this->input->post('text',true);
  3515. $order = $this->specialstock->find_all("number = '$number' and zd = '' and state = 0");
  3516. if($num > count($order))
  3517. {
  3518. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  3519. }
  3520. else
  3521. {
  3522. for($i=0;$i<$num;$i++)
  3523. {
  3524. $this->specialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$order[$i]['id']);
  3525. }
  3526. }
  3527. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  3528. }
  3529. $uid = $this->specialstock->read($arg_array[0]);
  3530. $uid['num'] = $this->specialstock->find_count('number = "'.$uid['number']. '" and zd = "" and state = 0');
  3531. $this->data['data'] = $uid ;
  3532. $this->_Template('specialstock_kj',$this->data);
  3533. }
  3534. public function _summary($arg_array)
  3535. {
  3536. if(isset($_GET['excel']))
  3537. {
  3538. $ktime = $this->input->get('ktime',true);
  3539. $jtime = $this->input->get('jtime',true);
  3540. $ktime = strtotime($ktime);
  3541. $jtime = strtotime($jtime);
  3542. $where = "1=1";
  3543. if($ktime && $jtime)
  3544. {
  3545. $where .= " and outk > '$ktime' and outk < '$jtime'";
  3546. }
  3547. //数据排序
  3548. $order_str = "time desc";
  3549. if(empty($page))
  3550. {
  3551. $start = 0;
  3552. $perpage = 1;
  3553. }
  3554. else
  3555. {
  3556. $start = ($page - 1)*$perpage;
  3557. }
  3558. $pc = $this->input->get('pc',true);
  3559. if($pc)
  3560. {
  3561. $pc = trim($pc,'x');
  3562. $pc = explode('x',$pc);
  3563. foreach ($pc as $v)
  3564. {
  3565. $where .= " and warehouse != '".$v."'";
  3566. }
  3567. }
  3568. //取得信息列表
  3569. $info_list = $this->specialstock->find_pc($where,'number','*');
  3570. foreach ($info_list as $value)
  3571. {
  3572. $xcpid = '';$scpid = '';
  3573. $x = $this->specialstock->find_all($where.' and number = "'.$value['number'].'"');
  3574. foreach ($x as $v)
  3575. {
  3576. if($v['cpid'] != 0)
  3577. {
  3578. $xcpid .= $v['cpid'].' ';
  3579. }
  3580. }
  3581. $s = $this->specialstock->find_all('state = 0 and number = "'.$value['number'].'"');
  3582. foreach ($s as $v)
  3583. {
  3584. if($v['cpid'] != 0)
  3585. {
  3586. $scpid .= $v['cpid'].' ';
  3587. }
  3588. }
  3589. $list[] = array('details'=>$value['details'],'title'=>$value['title'],'s'=>count($s),'x'=>count($x),'scpid'=>$scpid,'xcpid'=>$xcpid,'outk'=>date('Y-m-d H:i:s',$value['outk']));
  3590. }
  3591. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  3592. $titlename = "<table border=1>
  3593. <tr align='center'>
  3594. <td>仓库备注</td>
  3595. <td>产品名</td>
  3596. <td>总剩余库存</td>
  3597. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  3598. <td>剩余产品编码</td>
  3599. <td>销售产品编码</td>
  3600. <td>出库时间</td>
  3601. </tr>
  3602. </table>";
  3603. $filename = $title.".xls";
  3604. $tail = "";
  3605. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3606. }
  3607. }
  3608. //usps发货清单
  3609. public function _manifest()
  3610. {
  3611. if(isset($_POST['manifest']))
  3612. {
  3613. $wltext = $this->input->post('wltext',true);
  3614. $time = time()-16*3600;
  3615. $ptime = strtotime(date('Y-m-d',$time));
  3616. $waybill = array();
  3617. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  3618. foreach ($fullorder as $v)
  3619. {
  3620. $waybill[$v['waybill']] = $v['waybill'];
  3621. }
  3622. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  3623. foreach ($fullordersmt as $v)
  3624. {
  3625. $waybill[$v['waybill']] = $v['waybill'];
  3626. }
  3627. $wltext = explode(';',$wltext);
  3628. foreach ($wltext as $v)
  3629. {
  3630. if(isset($waybill[$v]))
  3631. {
  3632. unset($waybill[$v]);
  3633. }
  3634. }
  3635. $data = $this->usps->get_manifest($waybill);
  3636. if(isset($data['Description']))
  3637. {
  3638. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  3639. }
  3640. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  3641. {
  3642. $bctime = date('Ymd',time());
  3643. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  3644. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  3645. }
  3646. else
  3647. {
  3648. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  3649. }
  3650. }
  3651. }
  3652. public function _pdf($pdf,$title,$bctime)
  3653. {
  3654. $pdf_path = './data/pdf/'.$bctime.'/';
  3655. $file_base64 = $pdf;
  3656. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  3657. $file_base64 = base64_decode($file_base64);
  3658. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  3659. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  3660. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  3661. }
  3662. /**
  3663. *
  3664. *
  3665. *
  3666. 进销存占单异常索引
  3667. *
  3668. *
  3669. *
  3670. **/
  3671. public function _abnormal()
  3672. {
  3673. $post = $this->input->post(NULL, TRUE);
  3674. if(isset($post['page']))
  3675. {
  3676. $page = $this->input->post('page',true);
  3677. $perpage = $this->input->post('perpage',true);
  3678. $sku = $this->input->post('sku',true);
  3679. $where = "1=1";
  3680. //数据排序
  3681. $order_str = "id desc";
  3682. if(empty($page))
  3683. {
  3684. $start = 0;
  3685. $perpage = 1;
  3686. }
  3687. else
  3688. {
  3689. $start = ($page - 1)*$perpage;
  3690. }
  3691. //取得信息列表
  3692. $info_list = $this->specialstock->find_all($where,'*');
  3693. $rows = array();$list = array();
  3694. foreach ($info_list as $key=>$value)
  3695. {
  3696. $rows[$value['sku']] = $value;//所有数据sku
  3697. }
  3698. foreach ($rows as $value)
  3699. {
  3700. $warehouse = $this->warehouse->read($value['warehouse']);
  3701. $c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  3702. $number = $value['number'];$ftime = time()-15*24*3600;
  3703. if($value['shop'] != '')
  3704. {
  3705. $shop = $value['shop'];
  3706. $orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  3707. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  3708. $order = array_merge($orderdlz,$ordersmt);
  3709. $od = 0;$a = '';$orid = '';
  3710. foreach ($order as $v)
  3711. {
  3712. $or = explode('|',ltrim($v['specialstock'],'|'));
  3713. for($i=0;$i<count($or);$i++)
  3714. {
  3715. $orod = explode('-',$or[$i]);
  3716. if($orod[0] == $number)
  3717. {
  3718. $od += $orod[1];
  3719. }
  3720. }
  3721. $orid .= $v['number'].'-';
  3722. }
  3723. }
  3724. else
  3725. {
  3726. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  3727. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  3728. $order = array_merge($orderdlz,$ordersmt);
  3729. $od = 0;$a = '';$orid = '';$qt = array();
  3730. foreach ($order as $v)
  3731. {
  3732. $or = explode('|',ltrim($v['specialstock'],'|'));
  3733. for($i=0;$i<count($or);$i++)
  3734. {
  3735. $orod = explode('-',$or[$i]);
  3736. if($orod[0] == $number)
  3737. {
  3738. $czzs = $this->specialstock->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  3739. if($czzs > 0)
  3740. {
  3741. if(isset($qt[$v['shop']]))
  3742. {
  3743. if($qt[$v['shop']] < $orod[1])
  3744. {
  3745. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  3746. $orid .= $v['number'].'+数量'.$orod[1].'-';
  3747. }
  3748. else
  3749. {
  3750. $qt[$v['shop']] -= $orod[1];
  3751. }
  3752. }
  3753. else
  3754. {
  3755. $qt[$v['shop']] = $czzs;
  3756. }
  3757. }
  3758. else
  3759. {
  3760. $od += $orod[1];
  3761. $orid .= $v['number'].'+数量'.$orod[1].'-';
  3762. }
  3763. }
  3764. }
  3765. }
  3766. }
  3767. $z = $od.'('.$orid.')';//查看订单号
  3768. //$z = $od;
  3769. if($od > $c)
  3770. {
  3771. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  3772. }
  3773. }
  3774. $listdata = array_slice($list,$start,$perpage);
  3775. $total = count($list);
  3776. $pagenum = ceil($total/$perpage);
  3777. $over = $total-($start+$perpage);
  3778. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  3779. echo json_encode($rows);exit;
  3780. }
  3781. $this->_Template('specialstock_abnormal',$this->data);
  3782. }
  3783. /**
  3784. *
  3785. *
  3786. *
  3787. 进销存占单异常索引
  3788. *
  3789. *
  3790. *
  3791. **/
  3792. public function _error()
  3793. {
  3794. $post = $this->input->post(NULL, TRUE);
  3795. if(isset($post['page']))
  3796. {
  3797. $page = $this->input->post('page',true);
  3798. $perpage = $this->input->post('perpage',true);
  3799. $sku = $this->input->post('sku',true);
  3800. $warehouse = $this->input->post('warehouse',true);
  3801. $where = "1=1";
  3802. if($sku)
  3803. {
  3804. $where .= " and sku = '$sku'";
  3805. }
  3806. if($warehouse)
  3807. {
  3808. $where .= " and warehouse = '$warehouse'";
  3809. }
  3810. //数据排序
  3811. $order_str = "id desc";
  3812. if(empty($page))
  3813. {
  3814. $start = 0;
  3815. $perpage = 1;
  3816. }
  3817. else
  3818. {
  3819. $start = ($page - 1)*$perpage;
  3820. }
  3821. //取得信息列表
  3822. $info_list = $this->specialstock->find_all($where,'*');
  3823. $rows = array();$list = array();
  3824. foreach ($info_list as $key=>$value)
  3825. {
  3826. if($value['sku'] != '')
  3827. {
  3828. $rows[$value['sku']] = $value;//所有数据sku
  3829. }
  3830. }
  3831. foreach ($rows as $value)
  3832. {
  3833. $warehouse = $this->warehouse->read($value['warehouse']);
  3834. $c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  3835. $number = $value['number'];$ftime = time()-15*24*3600;
  3836. if($c < 1)
  3837. {
  3838. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  3839. }
  3840. }
  3841. $listdata = array_slice($list,$start,$perpage);
  3842. $total = count($list);
  3843. $pagenum = ceil($total/$perpage);
  3844. $over = $total-($start+$perpage);
  3845. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  3846. echo json_encode($rows);exit;
  3847. }
  3848. if(isset($post['s']))
  3849. {
  3850. $id_arr = $this->input->post('s');
  3851. $id_arr = explode(',',$id_arr);
  3852. if(!$id_arr)
  3853. {
  3854. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3855. }
  3856. //循环删除记录
  3857. foreach ($id_arr as $v)
  3858. {
  3859. $dd = $this->specialstock->read($v);
  3860. $deldd = $this->specialstock->find_all("sku = '".$dd['sku']."'");
  3861. foreach ($deldd as $vv)
  3862. {
  3863. $this->specialstock->remove($vv['id']);
  3864. }
  3865. }
  3866. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  3867. }
  3868. $this->_Template('specialstock_error',$this->data);
  3869. }
  3870. /**
  3871. *
  3872. *
  3873. * 占单
  3874. *
  3875. *
  3876. **/
  3877. public function _kcyz()
  3878. {
  3879. $post = $this->input->post(NULL, TRUE);
  3880. if(isset($post['warehouse']))
  3881. {
  3882. $warehouse = $this->input->post('warehouse',true);
  3883. $specialstock = $this->input->post('specialstock',true);
  3884. $id = $this->input->post('id',true);
  3885. $shop = $this->input->post('shop',true);
  3886. $number = $this->input->post('number',true);
  3887. if(!$specialstock || $specialstock == '|')
  3888. {
  3889. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  3890. }
  3891. $pp = explode('|',trim($specialstock,'|'));
  3892. $x = 0;$save = array();
  3893. foreach ($pp as $va)
  3894. {
  3895. $num = explode('-',$va);
  3896. if($number)
  3897. {
  3898. $specialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')");//通用
  3899. $shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  3900. }
  3901. else
  3902. {
  3903. $specialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  3904. $shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  3905. }
  3906. $x++;
  3907. if(count($specialstock)+count($shopspecialstock) < $num[1])
  3908. {
  3909. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  3910. }
  3911. }
  3912. if(isset($save[0]))
  3913. {
  3914. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  3915. }
  3916. else
  3917. {
  3918. echo json_encode(array('success'=>true));exit;
  3919. }
  3920. }
  3921. }
  3922. public function _hwwz()//货物位置
  3923. {
  3924. if(isset($_GET['id']))
  3925. {
  3926. $id = $this->input->get('id',true);
  3927. $sku = $this->input->get('sku',true);
  3928. $bs = $this->input->get('bs',true);
  3929. $number = $this->input->get('number',true);
  3930. $warehouse = $this->input->get('warehouse',true);
  3931. $purchase = $this->input->get('purchase',true);
  3932. $orderinfo = $this->input->get('orderinfo',true);
  3933. $waybill = $this->input->get('waybill',true);
  3934. $category = $this->input->get('category',true);
  3935. $size = $this->input->get('size',true);
  3936. $grade = $this->input->get('grade',true);
  3937. $color = $this->input->get('color',true);
  3938. $lowe = $this->input->get('lowe',true);
  3939. $state = $this->input->get('state',true);
  3940. $label = $this->input->get('label',true);
  3941. $px = $this->input->get('px',true);
  3942. $details = $this->input->get('details',true);
  3943. $timetk = $this->input->get('timetkk',true);
  3944. $timetj = $this->input->get('timetjj',true);
  3945. $timetk = strtotime($timetk);
  3946. $timetj = strtotime($timetj);
  3947. $where = "state='0'";
  3948. //数据排序
  3949. $order_str = $px." desc";
  3950. if(empty($page))
  3951. {
  3952. $start = 0;
  3953. $perpage = 1;
  3954. }
  3955. else
  3956. {
  3957. $start = ($page - 1)*$perpage;
  3958. }
  3959. $category = $this->input->get('category',true);
  3960. $warehouse = $this->input->get('warehouse',true);
  3961. if($category)
  3962. {
  3963. $where .= " and features like '%-$category-%'";
  3964. }
  3965. if($warehouse)
  3966. {
  3967. $where .= " and warehouse = '$warehouse'";
  3968. }
  3969. if($details)
  3970. {
  3971. $where .= " and details = '$details'";
  3972. }
  3973. if($id != '')
  3974. {
  3975. $sid = "";
  3976. $usersp = explode(',',trim($id,','));
  3977. foreach ($usersp as $value)
  3978. {
  3979. $sid .= " id = ".$value." or";
  3980. }
  3981. $info_list = $this->specialstock->find_all($where." and (".rtrim($sid,'or').")",'*','details desc');
  3982. }
  3983. else
  3984. {
  3985. $info_list = $this->specialstock->find_all($where,'*','details desc');
  3986. }
  3987. $rows = array();$list = array();
  3988. foreach ($info_list as $key=>$value)
  3989. {
  3990. $rows[$value['sku'].$value['warehouse'].$value['details']] = $value;//所有数据sku
  3991. }
  3992. foreach ($rows as $value)
  3993. {
  3994. $classid = $this->classid->sku();
  3995. $pm = $classid;
  3996. //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  3997. $features = explode('-',trim($value['features'],'-'));
  3998. foreach ($features as $v)
  3999. {
  4000. $typeclass = $this->typeclass->read($v);
  4001. $pm[$typeclass['classid']] = $typeclass['zh'];
  4002. //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
  4003. }
  4004. $typeclass = $this->typeclass->read($v);
  4005. //$scsku = implode("-",$scsku);
  4006. $zh = implode(" ",$pm);
  4007. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  4008. //$scsku = str_replace('- ','-',trim($scsku,'-'));
  4009. //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  4010. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"');
  4011. $number = $value['number'];$ftime = time()-15*24*3600;
  4012. $warehouse = $this->warehouse->read($value['warehouse']);
  4013. $list[] = array($value['id'],$value['details'],$zh,$c);
  4014. }
  4015. $title = "库存表";
  4016. $titlename = "";
  4017. $filename = $title.".xls";
  4018. $tail = "";
  4019. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4020. }
  4021. }
  4022. public function _order()
  4023. {
  4024. $post = $this->input->post(NULL, TRUE);
  4025. if(isset($arg_array[0]))
  4026. {
  4027. if($arg_array[0] == 'del')
  4028. {
  4029. $s = $this->input->post('s',true);
  4030. $del = $this->_del($s);
  4031. echo $del;exit;
  4032. }
  4033. }
  4034. if(isset($post['page']))
  4035. {
  4036. $page = $this->input->post('page',true);
  4037. $perpage = $this->input->post('perpage',true);
  4038. $category = $this->input->post('category',true);
  4039. $size = $this->input->post('size',true);
  4040. $grade = $this->input->post('grade',true);
  4041. $color = $this->input->post('color',true);
  4042. $lowe = $this->input->post('lowe',true);
  4043. $sku = $this->input->post('sku',true);
  4044. $details = $this->input->post('details',true);
  4045. $warehouse = $this->input->post('warehouse',true);
  4046. $purchase = $this->input->post('purchase',true);
  4047. $lacetype = $this->input->post('lacetype',true);
  4048. $state = $this->input->post('state',true);
  4049. $ktime = $this->input->post('ktime',true);
  4050. $jtime = $this->input->post('jtime',true);
  4051. $ktime = strtotime($ktime);
  4052. $jtime = strtotime($jtime);
  4053. $where = "zd =''";$gj = "";$ck = "";
  4054. if($category)
  4055. {
  4056. $where .= " and features like '%-$category-%'";
  4057. }
  4058. if($size)
  4059. {
  4060. $where .= " and features like '%-$size-%'";
  4061. }
  4062. if($grade)
  4063. {
  4064. $where .= " and features like '%-$grade-%'";
  4065. }
  4066. if($color)
  4067. {
  4068. $where .= " and features like '%-$color-%'";
  4069. }
  4070. if($lowe)
  4071. {
  4072. $where .= " and features like '%-$lowe-%'";
  4073. }
  4074. if($lacetype)
  4075. {
  4076. $where .= " and features like '%-$lacetype-%'";
  4077. }
  4078. if($warehouse)
  4079. {
  4080. $where .= " and warehouse = '$warehouse'";
  4081. }
  4082. if($purchase)
  4083. {
  4084. $where .= " and purchase = '$purchase'";
  4085. }
  4086. if($state)
  4087. {
  4088. $where .= " and state = '$state'";
  4089. }
  4090. if($sku)
  4091. {
  4092. $where .= " and sku like '%$sku%'";
  4093. }
  4094. if($details)
  4095. {
  4096. $where .= " and details like '%$details%'";
  4097. }
  4098. if($ktime && $jtime)
  4099. {
  4100. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4101. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4102. }
  4103. //数据排序
  4104. $order_str = "id desc";
  4105. if(empty($page))
  4106. {
  4107. $start = 0;
  4108. $perpage = 1;
  4109. }
  4110. else
  4111. {
  4112. $start = ($page - 1)*$perpage;
  4113. }
  4114. //取得信息列表
  4115. $info_list = $this->specialstock->find_all($where,'*');
  4116. $rows = array();$list = array();
  4117. foreach ($info_list as $key=>$value)
  4118. {
  4119. $rows[$value['number'].$value['warehouse']] = $value;//所有数据sku
  4120. }
  4121. $rowsdq = array_slice($rows,$start,$perpage);
  4122. $inch = '';$zh = '';
  4123. $classid = $this->classid->sku();
  4124. $pm = $classid;
  4125. foreach ($rowsdq as $value)
  4126. {
  4127. $features = '-';
  4128. $td = explode('-',trim($value['features'],'-'));
  4129. foreach ($td as $va)
  4130. {
  4131. $s = $this->typeclass->read($va);
  4132. if($s['classid'] == '14')
  4133. {
  4134. $c = $va;
  4135. $inch = $s['spare'];
  4136. if(isset($pm[$s['classid']]))
  4137. {
  4138. $pm[$s['classid']] = $s['zh'];
  4139. }
  4140. }
  4141. else
  4142. {
  4143. $features .= $va.'-';
  4144. if(isset($pm[$s['classid']]))
  4145. {
  4146. $pm[$s['classid']] = $s['zh'];
  4147. }
  4148. }
  4149. }
  4150. $features = $c.','.$features;
  4151. $warehouse = $this->warehouse->read($value['warehouse']);
  4152. $cpid = ($value['cpid']>0)?' - 编码:'.$value['cpid']:'';
  4153. $nr = implode(" ",$pm);
  4154. $nr = preg_replace(array('/(\s+)/','/分\s/u'),array(' ','分'),$nr);
  4155. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  4156. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'tj'=>"<span data-f='".$features."' data-t='".$value['title']."' data-i='".$inch."' data-n='".$c."' data-id='".$value['id']."' data-id='".$value['id']."' data-wz='".$nr.' - 位置:'.$value['details'].$cpid.";'>添加</span>");
  4157. }
  4158. $total = count($rows);
  4159. $pagenum = ceil($total/$perpage);
  4160. $over = $total-($start+$perpage);
  4161. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  4162. echo json_encode($rows);exit;
  4163. }
  4164. $this->_Template('specialstock_order',$this->data);
  4165. }
  4166. public function _0kcdel($id_arr)
  4167. {
  4168. if($id_arr)
  4169. {
  4170. $id_arr = explode(',',$id_arr);
  4171. $j = count($id_arr);
  4172. $i = 0;
  4173. //循环删除记录
  4174. foreach ($id_arr as $value)
  4175. {
  4176. $data = $this->specialstock->read($value);
  4177. $z = $this->specialstock->find_count('sku = "'.$data['sku'].'" and zd = "" and state = 0 and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
  4178. if($z < 1)
  4179. {
  4180. $z = $this->specialstock->find_all('sku = "'.$data['sku'].'" and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
  4181. foreach ($z as $v)
  4182. {
  4183. $this->specialstock->remove($v['id']);
  4184. }
  4185. $i++;
  4186. }
  4187. }
  4188. if($i != $j && $i != 0)
  4189. {
  4190. return json_encode(array('del'=>$id_arr,'msg'=>'有非0库存数据,0库存删除成功!','success'=>true));
  4191. }
  4192. else if($i != $j && $i == 0)
  4193. {
  4194. return json_encode(array('del'=>$id_arr,'msg'=>'库存非0不允许删除!','success'=>false));
  4195. }
  4196. else
  4197. {
  4198. return json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  4199. }
  4200. }
  4201. else
  4202. {
  4203. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4204. }
  4205. }
  4206. }