Specialstock.php 141 KB

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