Specialstock.php 142 KB

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