Specialstock.php 142 KB

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