Whlabel.php 257 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. }
  45. //定义方法的调用规则 获取URI第二段值
  46. public function _remap($arg, $arg_array)
  47. {
  48. if ($arg == 'existence') //在库标签
  49. {
  50. $this->_existence();
  51. } else if ($arg == 'cpbqdc') //在库标签
  52. {
  53. $this->_cpbqdc();
  54. } else if ($arg == 'type') //进销存浏览
  55. {
  56. $this->_type();
  57. } else if ($arg == 'typedy') //进销存浏览店员页面
  58. {
  59. $this->_typedy($arg_array);
  60. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. } else if ($arg == 'typeck') {
  64. $this->_typeck($arg_array);
  65. } else if ($arg == 'whlabeckdc') {
  66. $this->_whlabeckdc($arg_array);
  67. } else if ($arg == 'usatype') //美仓进销存浏览
  68. {
  69. $this->_usatype();
  70. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  71. {
  72. $this->_usatypeapp();
  73. } else if ($arg == 'enteradd') //入库操作
  74. {
  75. $this->_enteradd();
  76. } else if ($arg == 'enteredit') //修改
  77. {
  78. $this->_enteredit($arg_array);
  79. } else if ($arg == 'enter') //入库浏览
  80. {
  81. $this->_enter();
  82. } else if ($arg == 'out') //出库浏览
  83. {
  84. $this->_out();
  85. } else if ($arg == 'label') //出库标签浏览
  86. {
  87. $this->_label();
  88. } else if ($arg == 'outorder') //独立站出库订单
  89. {
  90. $this->_outorder();
  91. } else if ($arg == 'soutorder') //速卖通出库订单
  92. {
  93. $this->_soutorder();
  94. } else if ($arg == 'toutorder') //TT出库订单
  95. {
  96. $this->_toutorder();
  97. }else if ($arg == 'aoutorder') //amz出库订单
  98. {
  99. $this->_aoutorder();
  100. } else if ($arg == 'retreat') //退库订单
  101. {
  102. $this->_retreat();
  103. } else if ($arg == 'retreatlk') //退库订单
  104. {
  105. $this->_retreatlk();
  106. } else if ($arg == 'change') //更换标签
  107. {
  108. $this->_change();
  109. } else if ($arg == 'del') //删除
  110. {
  111. $this->_del();
  112. } else if ($arg == 'exceljxc') //进销存信息导出
  113. {
  114. $this->_exceljxc();
  115. } else if ($arg == 'excelr') //入库信息导出
  116. {
  117. $this->_excelr();
  118. } else if ($arg == 'excelct') //出库、退库信息导出
  119. {
  120. $this->_excelct();
  121. } else if ($arg == 'dccrtype') //根据出入库类型导出
  122. {
  123. $this->_dccrtype();
  124. } else if ($arg == 'excelcr') //出库、退库信息导出
  125. {
  126. $this->_excelcr();
  127. } else if ($arg == 'kcyz') //库存验证
  128. {
  129. $this->_kcyz();
  130. } else if ($arg == 'kj') //库存扣减
  131. {
  132. $this->_kj($arg_array);
  133. } else if ($arg == 'presetout') //预设库存导入
  134. {
  135. $this->_presetout($arg_array);
  136. } else if ($arg == 'presetedit') //预设库存导入
  137. {
  138. $this->_presetedit($arg_array);
  139. } else if ($arg == 'summary') //汇总导出
  140. {
  141. $this->_summary($arg_array);
  142. } else if ($arg == 'manifest') //usps发货清单
  143. {
  144. $this->_manifest();
  145. } else if ($arg == 'abnormal') //占单异常
  146. {
  147. $this->_abnormal();
  148. } else if ($arg == 'error') //0库存SKU
  149. {
  150. $this->_error();
  151. } else if ($arg == 'errorexcel') //0库存SKU导出
  152. {
  153. $this->_errorexcel();
  154. } else if ($arg == 'db') {
  155. $this->_db();
  156. } else if ($arg == 'dbrk') {
  157. $this->_dbrk();
  158. } else if ($arg == 'whlabelczdc') {
  159. $this->_whlabelczdc();
  160. } else if ($arg == 'print') {
  161. $this->_print($arg_array);
  162. } else if ($arg == 'usaprint') {
  163. $this->_usaprint($arg_array);
  164. } else if ($arg == 'printck') {
  165. $this->_printck($arg_array);
  166. } else if ($arg == 'printrk') {
  167. $this->_printrk($arg_array);
  168. } else if ($arg == 'printxzrk') {
  169. $this->_printxzrk($arg_array);
  170. } else if ($arg == 'printexcel') {
  171. $this->_printexcel($arg_array);
  172. } else if ($arg == 'uck') {
  173. $this->_uck();
  174. } else if ($arg == 'whlabelexcelzh') {
  175. $this->_whlabelexcelzh();
  176. } else if ($arg == 'fc') {
  177. $this->_fc();
  178. } else if ($arg == 'fcmb') {
  179. $this->_fcmb();
  180. } else if ($arg == 'fcexcel') {
  181. $this->_fcexcel();
  182. } else if ($arg == 'fcjxc') {
  183. $this->_fcjxc($arg_array);
  184. } else if ($arg == '0kcdel') {
  185. $this->_0kcdel(); //导表删除0库存
  186. } else if ($arg == 'gbhtype') {
  187. $this->_gbhtype(); //更改备货状态
  188. } else {
  189. $this->_index();
  190. }
  191. }
  192. //管理
  193. public function _index()
  194. {
  195. $post = $this->input->post(NULL, TRUE);
  196. if (isset($post['page'])) {
  197. $page = $this->input->post('page', true);
  198. $perpage = $this->input->post('perpage', true);
  199. $sku = $this->input->post('sku', true);
  200. $number = $this->input->post('number', true);
  201. $warehouse = $this->input->post('warehouse', true);
  202. $purchase = $this->input->post('purchase', true);
  203. $orderinfo = $this->input->post('orderinfo', true);
  204. $waybill = $this->input->post('waybill', true);
  205. $category = $this->input->post('category', true);
  206. $size = $this->input->post('size', true);
  207. $grade = $this->input->post('grade', true);
  208. $color = $this->input->post('color', true);
  209. $lowe = $this->input->post('lowe', true);
  210. $state = $this->input->post('state', true);
  211. $label = $this->input->post('label', true);
  212. $timetk = $this->input->post('timetkk', true);
  213. $timetj = $this->input->post('timetjj', true);
  214. $timetk = strtotime($timetk);
  215. $timetj = strtotime($timetj);
  216. $where = "1=1 ";
  217. if ($timetk && $timetj) {
  218. $where .= " and time > '$timetk' and time < '$timetj'";
  219. }
  220. if ($sku) {
  221. $where .= " and sku = '$sku'";
  222. }
  223. if ($number) {
  224. $where .= " and number = '$number'";
  225. }
  226. if ($warehouse) {
  227. $where .= " and warehouse = '$warehouse'";
  228. }
  229. if ($purchase) {
  230. $where .= " and purchase = '$purchase'";
  231. }
  232. if ($orderinfo) {
  233. $where .= " and orderinfo = '$orderinfo'";
  234. }
  235. if ($waybill) {
  236. $where .= " and waybill = '$waybill'";
  237. }
  238. if ($category) {
  239. $where .= " and features like '%-$category-%'";
  240. }
  241. if ($size) {
  242. $where .= " and features like '%-$size-%'";
  243. }
  244. if ($grade) {
  245. $where .= " and features like '%-$grade-%'";
  246. }
  247. if ($color) {
  248. $where .= " and features like '%-$color-%'";
  249. }
  250. if ($lowe) {
  251. $where .= " and features like '%-$lowe-%'";
  252. }
  253. if ($label) {
  254. $where .= " and label = '$label'";
  255. }
  256. if ($state != '') {
  257. $where .= " and state = '$state'";
  258. }
  259. //数据排序
  260. $order_str = "time desc";
  261. if (empty($page)) {
  262. $start = 0;
  263. $perpage = 1;
  264. } else {
  265. $start = ($page - 1) * $perpage;
  266. }
  267. //取得信息列表
  268. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  269. foreach ($info_list as $key => $value) {
  270. $warehouse = $this->warehouse->read($value['warehouse']);
  271. $info_list[$key]['warehouse'] = $warehouse['title'];
  272. $purchase = $this->purchase->read($value['purchase']);
  273. $info_list[$key]['purchase'] = $purchase['title'];
  274. if ($value['enter'] != 0) {
  275. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  276. } else {
  277. $info_list[$key]['enter'] = "";
  278. }
  279. if ($value['outk'] != 0) {
  280. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  281. } else {
  282. $info_list[$key]['outk'] = "";
  283. }
  284. if ($value['printing'] != 0) {
  285. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  286. } else {
  287. $info_list[$key]['printing'] = "";
  288. }
  289. if ($value['orderinfo'] == 0) {
  290. $info_list[$key]['orderinfo'] = "";
  291. }
  292. if ($value['waybill'] == 0) {
  293. $info_list[$key]['waybill'] = "";
  294. }
  295. if ($value['state'] == 0) {
  296. $info_list[$key]['state'] = "在库";
  297. } else if ($value['state'] == 1) {
  298. $info_list[$key]['state'] = "出库";
  299. } else if ($value['state'] == 2) {
  300. $info_list[$key]['state'] = "退库";
  301. } else if ($value['state'] == 3) {
  302. $info_list[$key]['state'] = "调拨中";
  303. } else if ($value['state'] == 4) {
  304. $info_list[$key]['state'] = "再加工";
  305. } else if ($value['state'] == 5) {
  306. $info_list[$key]['state'] = "维修中";
  307. } else if ($value['state'] == 6) {
  308. $info_list[$key]['state'] = "盘亏";
  309. } else if ($value['state'] == 7) {
  310. $info_list[$key]['state'] = "更换标签";
  311. } else if ($value['state'] == 8) {
  312. $info_list[$key]['state'] = "其它";
  313. } else if ($value['state'] == 9) {
  314. $info_list[$key]['state'] = "预设";
  315. } else if ($value['state'] == 10) {
  316. $info_list[$key]['state'] = "美店零售";
  317. }
  318. if ($value['text'] == "") {
  319. $info_list[$key]['text'] = "";
  320. }
  321. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  322. }
  323. $total = $this->whlabel->find_count($where);
  324. $pagenum = ceil($total / $perpage);
  325. $over = $total - ($start + $perpage);
  326. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  327. echo json_encode($rows);
  328. exit;
  329. }
  330. if (isset($post['outsku'])) {
  331. $cz = $this->input->post('cz', true);
  332. if ($cz == '1') {
  333. $sku = $this->input->post('outsku', true);
  334. if ($sku) {
  335. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  336. if (count($data) < 1) {
  337. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  338. exit;
  339. }
  340. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  341. echo json_encode(array('success' => true));
  342. exit;
  343. }
  344. } else {
  345. $sku = $this->input->post('outsku', true);
  346. if ($sku) {
  347. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  348. if (count($data) < 1) {
  349. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  350. exit;
  351. }
  352. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  353. echo json_encode(array('success' => true));
  354. exit;
  355. }
  356. }
  357. }
  358. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  359. $this->_Template('whlabel', $this->data);
  360. }
  361. //在库标签
  362. public function _existence()
  363. {
  364. $post = $this->input->post(NULL, TRUE);
  365. if (isset($post['s'])) {
  366. $id_arr = $this->input->post('s');
  367. $id_arr = explode(',', $id_arr);
  368. if (!$id_arr) {
  369. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  370. exit;
  371. }
  372. //循环删除记录
  373. foreach ($id_arr as $v) {
  374. $sid = $this->whlabel->read($v);
  375. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  376. if ($count > 0) {
  377. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  378. exit;
  379. }
  380. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  381. if (count($zt) > 0) {
  382. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  383. exit;
  384. }
  385. $this->whlabel->remove($v);
  386. }
  387. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  388. exit;
  389. }
  390. if (isset($post['page'])) {
  391. $page = $this->input->post('page', true);
  392. $perpage = $this->input->post('perpage', true);
  393. $warehouse = $this->input->post('warehouse', true);
  394. $label = $this->input->post('label', true);
  395. $where = "1=1 and state = 0";
  396. if ($warehouse) {
  397. $where .= " and warehouse = '$warehouse'";
  398. }
  399. if ($label) {
  400. $where .= " and label = '$label'";
  401. }
  402. //数据排序
  403. $order_str = "time asc";
  404. if (empty($page)) {
  405. $start = 0;
  406. $perpage = 1;
  407. } else {
  408. $start = ($page - 1) * $perpage;
  409. }
  410. //取得信息列表
  411. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  412. foreach ($info_list as $key => $value) {
  413. if ($value['enter'] != 0) {
  414. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  415. } else {
  416. $info_list[$key]['enter'] = "";
  417. }
  418. if ($value['printing'] != 0) {
  419. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  420. } else {
  421. $info_list[$key]['printing'] = "";
  422. }
  423. }
  424. $total = $this->whlabel->find_count($where);
  425. $pagenum = ceil($total / $perpage);
  426. $over = $total - ($start + $perpage);
  427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  428. echo json_encode($rows);
  429. exit;
  430. }
  431. $this->_Template('whlabel_existence', $this->data);
  432. }
  433. //进销存浏览
  434. public function _typedy($arg_array)
  435. {
  436. $prc = array();
  437. $purchase = $this->purchase->find_all();
  438. foreach ($purchase as $k => $v) {
  439. $prc[$v['id']] = $v['title'];
  440. }
  441. $post = $this->input->post(NULL, TRUE);
  442. if (isset($post['page'])) {
  443. $page = $this->input->post('page', true);
  444. $perpage = $this->input->post('perpage', true);
  445. $category = $this->input->post('category', true);
  446. $size = $this->input->post('size', true);
  447. $grade = $this->input->post('grade', true);
  448. $color = $this->input->post('color', true);
  449. $lowe = $this->input->post('lowe', true);
  450. $sku = $this->input->post('sku');
  451. $title = $this->input->post('title');
  452. $warehouse = $this->input->post('warehouse', true);
  453. $usa = $this->input->post('usa', true);
  454. $purchase = $this->input->post('purchase', true);
  455. $lacetype = $this->input->post('lacetype', true);
  456. $haircap = $this->input->post('haircap', true);
  457. $density = $this->input->post('density', true);
  458. $details = $this->input->post('details', true);
  459. $state = $this->input->post('state', true);
  460. $lacecolor = $this->input->post('lacecolor', true);
  461. $hairnumber = $this->input->post('hairnumber', true);
  462. $cklx = $this->input->post('cklx', true);
  463. $ktime = $this->input->post('ktime', true);
  464. $jtime = $this->input->post('jtime', true);
  465. $ktime = strtotime($ktime);
  466. $jtime = strtotime($jtime);
  467. $where = "1=1";
  468. $gj = "";
  469. $ck = "";
  470. if ($usa) {
  471. if (!$warehouse) {
  472. $where .= " and (warehouse = '5' or warehouse = '8')";
  473. }
  474. }
  475. if ($warehouse) {
  476. $where .= " and warehouse = '$warehouse'";
  477. }
  478. if ($details) {
  479. $where .= " and details = '$details'";
  480. }
  481. if ($purchase) {
  482. $where .= " and purchase = '$purchase'";
  483. }
  484. if ($state) {
  485. $where .= " and state = '$state'";
  486. }
  487. if ($lacetype) {
  488. $where .= " and features like '%-$lacetype-%'";
  489. }
  490. if ($category) {
  491. $where .= " and features like '%-$category-%'";
  492. }
  493. if ($size) {
  494. $where .= " and features like '%-$size-%'";
  495. }
  496. if ($grade) {
  497. $where .= " and features like '%-$grade-%'";
  498. }
  499. if ($color) {
  500. $where .= " and features like '%-$color-%'";
  501. }
  502. if ($lowe) {
  503. $where .= " and features like '%-$lowe-%'";
  504. }
  505. if ($haircap) {
  506. $where .= " and features like '%-$haircap-%'";
  507. }
  508. if ($density) {
  509. $where .= " and features like '%-$density-%'";
  510. }
  511. if ($lacecolor) {
  512. $where .= " and features like '%-$lacecolor-%'";
  513. }
  514. if (!empty($hairnumber)) {
  515. $where .= " and features like '%-128-%' ";
  516. if ($hairnumber < 0) {
  517. $class_list = $this->typeclass->find_all('classid = 43');
  518. foreach ($class_list as $v) {
  519. $where .= " and features not like '%-" . $v['id'] . "-%'";
  520. }
  521. } else {
  522. $where .= " and features like '%-$hairnumber-%'";
  523. }
  524. }
  525. $where_add = '';
  526. if ($cklx) {
  527. $shop = $this->shop->read($cklx);
  528. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  529. }
  530. if ($ktime && $jtime) {
  531. $gj = " and enter > '$ktime' and enter < '$jtime'";
  532. $ck = " and outk > '$ktime' and outk < '$jtime'";
  533. }
  534. //数据排序
  535. $order_str = "id desc";
  536. if (empty($page)) {
  537. $start = 0;
  538. $perpage = 1;
  539. } else {
  540. $start = ($page - 1) * $perpage;
  541. }
  542. if ($sku) {
  543. $sku = trim($sku, ' ');
  544. $sku = trim($sku, ' ');
  545. $where .= " and sku like '%$sku%'";
  546. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  547. } else if ($title) {
  548. $title = trim($title, ' ');
  549. $title = trim($title, ' ');
  550. $where .= " and title like '%$title%'";
  551. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  552. } else {
  553. //$where .= " and time > '$ktime' and time < '$jtime'";
  554. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  555. }
  556. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  557. foreach ($info_list as $k => $v) {
  558. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  559. unset($info_list[$k]['pm']);
  560. unset($info_list[$k]['jm']);
  561. unset($info_list[$k]['bm']);
  562. }
  563. //取得信息列表
  564. $rows = array();
  565. $list = array();
  566. foreach ($info_list as $key => $value) {
  567. $warehouse = $this->warehouse->read($value['warehouse']);
  568. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  569. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  570. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  571. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  572. $number = $value['number'];
  573. $ftime = time() - 15 * 24 * 3600;
  574. $info_list[$key]['warehouse'] = $warehouse['title'];
  575. $info_list[$key]['features'] = count($c);
  576. $z = count($z); //查看订单号
  577. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  578. $ztdata = '';
  579. if (count($zt) > 0) {
  580. foreach ($zt as $vv) {
  581. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  582. }
  583. }
  584. $info_list[$key]['number'] = $ztdata;
  585. $info_list[$key]['sm'] = $z;
  586. $details = array();
  587. $cpid = array();
  588. foreach ($c as $k => $v) {
  589. $details[$v['details']] = $v['details'];
  590. if ($v['cpid'] != 0) {
  591. $cpid[$v['cpid']] = $v['cpid'];
  592. }
  593. }
  594. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  595. if ($value['shop'] != '') {
  596. $shop = explode(',', trim($value['shop'], ','));
  597. $shop = $this->shop->read($shop[0]);
  598. $info_list[$key]['shop'] = $shop['shopname'];
  599. }
  600. }
  601. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  602. $pagenum = ceil($total / $perpage);
  603. $over = $total - ($start + $perpage);
  604. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  605. echo json_encode($rows);
  606. exit;
  607. }
  608. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  609. $this->_Template('whlabel_typedy', $this->data);
  610. }
  611. //进销存浏览
  612. public function _typedy_ck($arg_array)
  613. {
  614. $prc = array();
  615. $purchase = $this->purchase->find_all();
  616. foreach ($purchase as $k => $v) {
  617. $prc[$v['id']] = $v['title'];
  618. }
  619. $post = $this->input->post(NULL, TRUE);
  620. if (isset($post['page'])) {
  621. $page = $this->input->post('page', true);
  622. $perpage = $this->input->post('perpage', true);
  623. $category = $this->input->post('category', true);
  624. $size = $this->input->post('size', true);
  625. $grade = $this->input->post('grade', true);
  626. $color = $this->input->post('color', true);
  627. $lowe = $this->input->post('lowe', true);
  628. $sku = $this->input->post('sku');
  629. $title = $this->input->post('title');
  630. $warehouse = $this->input->post('warehouse', true);
  631. $usa = $this->input->post('usa', true);
  632. $purchase = $this->input->post('purchase', true);
  633. $lacetype = $this->input->post('lacetype', true);
  634. $haircap = $this->input->post('haircap', true);
  635. $density = $this->input->post('density', true);
  636. $details = $this->input->post('details', true);
  637. $state = $this->input->post('state', true);
  638. $lacecolor = $this->input->post('lacecolor', true);
  639. $cklx = $this->input->post('cklx', true);
  640. $ktime = $this->input->post('ktime', true);
  641. $jtime = $this->input->post('jtime', true);
  642. $ktime = strtotime($ktime);
  643. $jtime = strtotime($jtime);
  644. $where = "1=1";
  645. $gj = "";
  646. $ck = "";
  647. if ($lacetype) {
  648. $where .= " and features like '%-$lacetype-%'";
  649. }
  650. if ($category) {
  651. $where .= " and features like '%-$category-%'";
  652. }
  653. if ($size) {
  654. $where .= " and features like '%-$size-%'";
  655. }
  656. if ($grade) {
  657. $where .= " and features like '%-$grade-%'";
  658. }
  659. if ($color) {
  660. $where .= " and features like '%-$color-%'";
  661. }
  662. if ($lowe) {
  663. $where .= " and features like '%-$lowe-%'";
  664. }
  665. if ($haircap) {
  666. $where .= " and features like '%-$haircap-%'";
  667. }
  668. if ($density) {
  669. $where .= " and features like '%-$density-%'";
  670. }
  671. if ($lacecolor) {
  672. $where .= " and features like '%-$lacecolor-%'";
  673. }
  674. if ($usa) {
  675. if (!$warehouse) {
  676. $where .= " and (warehouse = '5' or warehouse = '8')";
  677. }
  678. }
  679. if ($warehouse) {
  680. $where .= " and warehouse = '$warehouse'";
  681. }
  682. if ($details) {
  683. $where .= " and details = '$details'";
  684. }
  685. if ($purchase) {
  686. $where .= " and purchase = '$purchase'";
  687. }
  688. if ($state) {
  689. $where .= " and state = '$state'";
  690. }
  691. $where_add = '';
  692. if ($cklx) {
  693. $shop = $this->shop->read($cklx);
  694. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  695. }
  696. if ($ktime && $jtime) {
  697. $gj = " and enter > '$ktime' and enter < '$jtime'";
  698. $ck = " and outk > '$ktime' and outk < '$jtime'";
  699. }
  700. //数据排序
  701. $order_str = "id desc";
  702. if (empty($page)) {
  703. $start = 0;
  704. $perpage = 1;
  705. } else {
  706. $start = ($page - 1) * $perpage;
  707. }
  708. if ($sku) {
  709. $sku = trim($sku, ' ');
  710. $sku = trim($sku, ' ');
  711. $where .= " and sku like '%$sku%'";
  712. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  713. } else if ($title) {
  714. $title = trim($title, ' ');
  715. $title = trim($title, ' ');
  716. $where .= " and title like '%$title%'";
  717. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  718. } else {
  719. //$where .= " and time > '$ktime' and time < '$jtime'";
  720. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  721. }
  722. //取得信息列表
  723. $rows = array();
  724. $list = array();
  725. foreach ($info_list as $key => $value) {
  726. $warehouse = $this->warehouse->read($value['warehouse']);
  727. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  728. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  729. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  730. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  731. $ftime = time() - 15 * 24 * 3600;
  732. $info_list[$key]['warehouse'] = $warehouse['title'];
  733. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  734. //$z = count($z);//查看订单号
  735. //$info_list[$key]['zd'] = $z;
  736. $details = array();
  737. $cpid = array();
  738. foreach ($c as $k => $v) {
  739. $details[$v['details']] = $v['details'];
  740. if ($v['cpid'] != 0) {
  741. $cpid[$v['cpid']] = $v['cpid'];
  742. }
  743. }
  744. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  745. if ($value['shop'] != '') {
  746. $shop = explode(',', trim($value['shop'], ','));
  747. $shop = $this->shop->read($shop[0]);
  748. $info_list[$key]['shop'] = $shop['shopname'];
  749. }
  750. }
  751. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  752. $pagenum = ceil($total / $perpage);
  753. $over = $total - ($start + $perpage);
  754. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  755. echo json_encode($rows);
  756. exit;
  757. }
  758. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  759. $this->_Template('whlabel_typedy_ck', $this->data);
  760. }
  761. public function _typeck($arg_array)
  762. {
  763. $prc = array();
  764. $purchase = $this->purchase->find_all();
  765. foreach ($purchase as $k => $v) {
  766. $prc[$v['id']] = $v['title'];
  767. }
  768. $post = $this->input->post(NULL, TRUE);
  769. if (isset($post['page'])) {
  770. $page = $this->input->post('page', true);
  771. $perpage = $this->input->post('perpage', true);
  772. $category = $this->input->post('category', true);
  773. $size = $this->input->post('size', true);
  774. $grade = $this->input->post('grade', true);
  775. $color = $this->input->post('color', true);
  776. $lacecolor = $this->input->post('lacecolor', true);
  777. $lowe = $this->input->post('lowe', true);
  778. $sku = $this->input->post('sku');
  779. $title = $this->input->post('title');
  780. $warehouse = 13;
  781. $usa = $this->input->post('usa', true);
  782. $purchase = $this->input->post('purchase', true);
  783. $lacetype = $this->input->post('lacetype', true);
  784. $haircap = $this->input->post('haircap', true);
  785. $density = $this->input->post('density', true);
  786. $details = $this->input->post('details', true);
  787. $state = $this->input->post('state', true);
  788. $ktime = $this->input->post('ktime', true);
  789. $jtime = $this->input->post('jtime', true);
  790. $ktime = strtotime($ktime);
  791. $jtime = strtotime($jtime);
  792. $where = "1=1";
  793. $gj = "";
  794. $ck = "";
  795. if ($lacetype) {
  796. $where .= " and features like '%-$lacetype-%'";
  797. }
  798. if ($category) {
  799. $where .= " and features like '%-$category-%'";
  800. }
  801. if ($size) {
  802. $where .= " and features like '%-$size-%'";
  803. }
  804. if ($grade) {
  805. $where .= " and features like '%-$grade-%'";
  806. }
  807. if ($color) {
  808. $where .= " and features like '%-$color-%'";
  809. }
  810. if ($lacecolor) {
  811. $where .= " and features like '%-$lacecolor-%'";
  812. }
  813. if ($lowe) {
  814. $where .= " and features like '%-$lowe-%'";
  815. }
  816. if ($haircap) {
  817. $where .= " and features like '%-$haircap-%'";
  818. }
  819. if ($density) {
  820. $where .= " and features like '%-$density-%'";
  821. }
  822. if ($warehouse) {
  823. $where .= " and warehouse = '$warehouse'";
  824. }
  825. if ($details) {
  826. $where .= " and details = '$details'";
  827. }
  828. if ($purchase) {
  829. $where .= " and purchase = '$purchase'";
  830. }
  831. if ($state) {
  832. $where .= " and state = '$state'";
  833. }
  834. if ($ktime && $jtime) {
  835. $gj = " and enter > '$ktime' and enter < '$jtime'";
  836. $ck = " and outk > '$ktime' and outk < '$jtime'";
  837. }
  838. //数据排序
  839. $order_str = "id desc";
  840. if (empty($page)) {
  841. $start = 0;
  842. $perpage = 1;
  843. } else {
  844. $start = ($page - 1) * $perpage;
  845. }
  846. if ($sku) {
  847. $sku = trim($sku, ' ');
  848. $sku = trim($sku, ' ');
  849. $where .= " and sku like '%$sku%'";
  850. } else if ($title) {
  851. $title = trim($title, ' ');
  852. $title = trim($title, ' ');
  853. $where .= " and title like '%$title%'";
  854. }
  855. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  856. //取得信息列表
  857. $t = array();
  858. $typeclass = $this->typeclass->find_all();
  859. foreach ($typeclass as $v) {
  860. $t[$v['id']] = $v;
  861. }
  862. $rows = array();
  863. $list = array();
  864. foreach ($info_list as $key => $value) {
  865. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  866. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  867. $warehouse = $this->warehouse->read($value['warehouse']);
  868. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  869. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  870. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  871. $number = $value['number'];
  872. $ftime = time() - 15 * 24 * 3600;
  873. $z = count($z); //查看订单号
  874. $info_list[$key]['warehouse'] = $warehouse['title'];
  875. $info_list[$key]['features'] = count($c);
  876. $info_list[$key]['number'] = $z;
  877. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  878. $details = array();
  879. $cpid = array();
  880. foreach ($c as $k => $v) {
  881. $details[$v['details']] = $v['details'];
  882. if ($v['cpid'] != 0) {
  883. $cpid[$v['cpid']] = $v['cpid'];
  884. }
  885. }
  886. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  887. $classid = $this->classid->sku();
  888. $pm = $classid;
  889. $features = explode('-', trim($value['features'], '-'));
  890. foreach ($features as $v) {
  891. $zh = explode('|', trim($t[$v]['zh'], '|'));
  892. $pm[$t[$v]['classid']] = $zh[0];
  893. }
  894. $zh = implode(" ", $pm);
  895. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  896. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  897. $info_list[$key]['sm'] = $zh;
  898. }
  899. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  900. $pagenum = ceil($total / $perpage);
  901. $over = $total - ($start + $perpage);
  902. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  903. echo json_encode($rows);
  904. exit;
  905. }
  906. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  907. $this->_Template('whlabel_typeck', $this->data);
  908. }
  909. //进销存导出
  910. public function _whlabeckdc()
  911. {
  912. $prc = array();
  913. $purchase = $this->purchase->find_all();
  914. foreach ($purchase as $k => $v) {
  915. $prc[$v['id']] = $v['title'];
  916. }
  917. if (isset($_GET['excel'])) {
  918. $where = "sku != 'Preset'";
  919. //数据排序
  920. $order_str = "id desc";
  921. if (empty($page)) {
  922. $start = 0;
  923. $perpage = 1;
  924. } else {
  925. $start = ($page - 1) * $perpage;
  926. }
  927. $category = $this->input->get('category', true);
  928. $color = $this->input->get('color', true);
  929. $lowe = $this->input->get('lowe', true);
  930. $lacetype = $this->input->get('lacetype', true);
  931. $size = $this->input->get('size', true);
  932. $density = $this->input->get('density', true);
  933. $haircap = $this->input->get('haircap', true);
  934. $sku = $this->input->get('sku', true);
  935. $details = $this->input->get('details', true);
  936. $warehouse = 13;
  937. $excelid = $this->input->get('sid', true);
  938. if ($category) {
  939. $where .= " and features like '%-$category-%'";
  940. }
  941. if ($color) {
  942. $where .= " and features like '%-$color-%'";
  943. }
  944. if ($lowe) {
  945. $where .= " and features like '%-$lowe-%'";
  946. }
  947. if ($lacetype) {
  948. $where .= " and features like '%-$lacetype-%'";
  949. }
  950. if ($size) {
  951. $where .= " and features like '%-$size-%'";
  952. }
  953. if ($density) {
  954. $where .= " and features like '%-$density-%'";
  955. }
  956. if ($haircap) {
  957. $where .= " and features like '%-$haircap-%'";
  958. }
  959. if ($warehouse) {
  960. $where .= " and warehouse = '$warehouse'";
  961. }
  962. if ($sku) {
  963. $where .= " and sku like '%$sku%'";
  964. }
  965. if ($details) {
  966. $where .= " and details = '$details'";
  967. }
  968. $xzid = '';
  969. if ($excelid) {
  970. $excelid = explode(',', trim($excelid, ','));
  971. foreach ($excelid as $key => $value) {
  972. $xzid .= " id = " . $value . " or";
  973. }
  974. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  975. }
  976. //取得信息列表
  977. /**
  978. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  979. $rows = array();$list = array();
  980. foreach ($info_list as $key=>$value)
  981. {
  982. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  983. }
  984. **/
  985. $wh = array();
  986. $w = $this->warehouse->find_all('1=1', 'id,title');
  987. foreach ($w as $v) {
  988. $wh[$v['id']] = $v['title'];
  989. }
  990. $tc = array();
  991. $tcdata = array();
  992. $typeclass = $this->typeclass->find_all();
  993. foreach ($typeclass as $v) {
  994. $tc[$v['id']] = $v;
  995. }
  996. $list = array();
  997. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  998. foreach ($rows as $key => $value) {
  999. $bm = '03';
  1000. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  1001. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1002. $classid = $this->classid->sku();
  1003. $pm = $classid;
  1004. $jm = $classid;
  1005. $features = explode('-', trim($value['features'], '-'));
  1006. foreach ($features as $v) {
  1007. if (isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']])) {
  1008. if ($tc[$v]['bm'] != '') {
  1009. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1010. }
  1011. }
  1012. if (isset($tc[$v])) {
  1013. $zh = explode('|', trim($tc[$v]['zh'], '|'));
  1014. $pm[$tc[$v]['classid']] = $zh[0];
  1015. }
  1016. if (isset($tc[$v])) {
  1017. if (isset($jm[$tc[$v]['classid']])) {
  1018. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1019. }
  1020. }
  1021. }
  1022. $zh = implode(" ", $pm);
  1023. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  1024. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1025. $rows[$key]['dbcontent'] = $zh;
  1026. $rows[$key]['cpbz'] = $bm . implode("", $bmpx);
  1027. $jm = array_filter($jm);
  1028. $rows[$key]['cs'] = implode("-", $jm);
  1029. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1030. $details = array();
  1031. $cpid = array();
  1032. $cpbz = array();
  1033. $c = 0;
  1034. $g = 0;
  1035. $x = 0;
  1036. $t = 0;
  1037. $s = 0;
  1038. $q = 0;
  1039. foreach ($sd as $k => $v) {
  1040. if ($v['state'] == 0) {
  1041. $c++;
  1042. }
  1043. if ($v['state'] != 9) {
  1044. $g++;
  1045. }
  1046. if ($v['state'] == 1) {
  1047. $x++;
  1048. }
  1049. if ($v['state'] == 2) {
  1050. $t++;
  1051. }
  1052. if ($v['state'] == 8) {
  1053. $s++;
  1054. }
  1055. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1056. $q++;
  1057. }
  1058. $details[$v['details']] = $v['details'];
  1059. if ($v['cpid'] != 0) {
  1060. $cpid[$v['cpid']] = $v['cpid'];
  1061. }
  1062. if ($v['cpbz'] != '') {
  1063. $cpbz[$v['cpbz']] = $v['cpbz'];
  1064. }
  1065. }
  1066. $rows[$key]['details'] = implode("、", $details);
  1067. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1068. $number = $value['number'];
  1069. $ftime = time() - 15 * 24 * 3600;
  1070. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1071. $rows[$key]['number'] = $g;
  1072. $rows[$key]['features'] = $c;
  1073. $rows[$key]['x'] = $x;
  1074. $rows[$key]['t'] = $t;
  1075. $rows[$key]['s'] = $s;
  1076. $rows[$key]['q'] = $q;
  1077. $rows[$key]['wzsl'] = count($details);
  1078. }
  1079. $title = "进销存统计表" . date('Y-m-d', time());
  1080. $titlename = "<table border=1>
  1081. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1082. <tr align='center'>
  1083. <td>仓库</td>
  1084. <td>供应商</td>
  1085. <td>位置</td>
  1086. <td>库存编码</td>
  1087. <td>SKU</td>
  1088. <td>用友编码</td>
  1089. <td>用友料号</td>
  1090. <td>产品英文名</td>
  1091. <td>产品中文名</td>
  1092. <td>入库总量</td>
  1093. <td>库存数量</td>
  1094. <td>销售数量</td>
  1095. <td>退货数量</td>
  1096. <td>删除数量</td>
  1097. <td>其它操作</td>
  1098. <td>位置数量</td>
  1099. </tr>
  1100. </table>";
  1101. $filename = $title . ".xls";
  1102. $tail = "";
  1103. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1104. }
  1105. }
  1106. public function _type()
  1107. {
  1108. $vip = 0;
  1109. if (isset($_SESSION['api'])) {
  1110. $user = $this->user->get_api($_SESSION['api']);
  1111. $fgshop = "";
  1112. $sid = "";
  1113. $usersp = explode('|', trim($user['shop'], '|'));
  1114. foreach ($usersp as $value) {
  1115. $fgshop .= " shop = " . $value . " or";
  1116. $sid .= " id = " . $value . " or";
  1117. }
  1118. if ($user['vip'] == 1) {
  1119. $vip = 1;
  1120. }
  1121. } else {
  1122. header('Location: /');
  1123. exit;
  1124. }
  1125. $prc = array();
  1126. $purchase = $this->purchase->find_all();
  1127. foreach ($purchase as $k => $v) {
  1128. $prc[$v['id']] = $v['title'];
  1129. }
  1130. $company = array();
  1131. $ct = $this->company->find_all();
  1132. foreach ($ct as $k => $v) {
  1133. $company[$v['id']] = $v['title'];
  1134. }
  1135. $sp = array();
  1136. $s = $this->shop->find_all('1=1', 'id,shopname');
  1137. foreach ($s as $v) {
  1138. $sp[$v['id']] = $v['shopname'];
  1139. }
  1140. $wh = array();
  1141. $w = $this->warehouse->find_all('1=1', 'id,title');
  1142. foreach ($w as $v) {
  1143. $wh[$v['id']] = $v['title'];
  1144. }
  1145. $post = $this->input->post(NULL, TRUE);
  1146. if (isset($post['page'])) {
  1147. $page = $this->input->post('page', true);
  1148. $perpage = $this->input->post('perpage', true);
  1149. $category = $this->input->post('category', true);
  1150. $size = $this->input->post('size', true);
  1151. $grade = $this->input->post('grade', true);
  1152. $color = $this->input->post('color', true);
  1153. $lowe = $this->input->post('lowe', true);
  1154. $sku = $this->input->post('sku');
  1155. $title = $this->input->post('title');
  1156. $warehouse = $this->input->post('warehouse', true);
  1157. $usa = $this->input->post('usa', true);
  1158. $purchase = $this->input->post('purchase', true);
  1159. $lacetype = $this->input->post('lacetype', true);
  1160. $haircap = $this->input->post('haircap', true);
  1161. $density = $this->input->post('density', true);
  1162. $details = $this->input->post('details', true);
  1163. $state = $this->input->post('state', true);
  1164. $shop = $this->input->post('shop', true);
  1165. $lacecolor = $this->input->post('lacecolor', true);
  1166. $hairnumber = $this->input->post('hairnumber', true);
  1167. $type = $this->input->post('type', true);
  1168. $ktime = $this->input->post('ktime', true);
  1169. $jtime = $this->input->post('jtime', true);
  1170. $ktime = strtotime($ktime);
  1171. $jtime = strtotime($jtime);
  1172. $cpbz = $this->input->post('cpbz', true);
  1173. $where = "1=1";
  1174. $gj = "";
  1175. $ck = "";
  1176. if ($usa) {
  1177. if (!$warehouse) {
  1178. $where .= " and (warehouse = '5' or warehouse = '8')";
  1179. }
  1180. }
  1181. if ($warehouse) {
  1182. $where .= " and warehouse = '$warehouse'";
  1183. }
  1184. if ($details) {
  1185. $where .= " and details = '$details'";
  1186. }
  1187. if ($purchase) {
  1188. $where .= " and purchase = '$purchase'";
  1189. }
  1190. if ($state) {
  1191. $where .= " and state = '$state'";
  1192. }
  1193. if ($shop) {
  1194. $where .= " and shop like '%$shop%'";
  1195. }
  1196. if ($type) {
  1197. $where .= " and type = '$type'";
  1198. }
  1199. if ($ktime && $jtime) {
  1200. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1201. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1202. }
  1203. if ($cpbz) {
  1204. $where .= " and cpbz like '%$cpbz%' ";
  1205. }
  1206. if ($lacecolor) {
  1207. $where .= " and features like '%-$lacecolor-%'";
  1208. }
  1209. if ($lacetype) {
  1210. $where .= " and features like '%-$lacetype-%'";
  1211. }
  1212. if ($category) {
  1213. $where .= " and features like '%-$category-%'";
  1214. }
  1215. if ($size) {
  1216. $where .= " and features like '%-$size-%'";
  1217. }
  1218. if ($grade) {
  1219. $where .= " and features like '%-$grade-%'";
  1220. }
  1221. if ($color) {
  1222. $where .= " and features like '%-$color-%'";
  1223. }
  1224. if ($lowe) {
  1225. $where .= " and features like '%-$lowe-%'";
  1226. }
  1227. if ($haircap) {
  1228. $where .= " and features like '%-$haircap-%'";
  1229. }
  1230. if ($density) {
  1231. $where .= " and features like '%-$density-%'";
  1232. }
  1233. if (!empty($hairnumber)) {
  1234. $where .= " and features like '%-128-%' ";
  1235. if ($hairnumber < 0) {
  1236. $class_list = $this->typeclass->find_all('classid = 43');
  1237. foreach ($class_list as $v) {
  1238. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1239. }
  1240. } else {
  1241. $where .= " and features like '%-$hairnumber-%'";
  1242. }
  1243. }
  1244. //数据排序
  1245. $order_str = "id desc";
  1246. if (empty($page)) {
  1247. $start = 0;
  1248. $perpage = 1;
  1249. } else {
  1250. $start = ($page - 1) * $perpage;
  1251. }
  1252. $fjnr = '';
  1253. if ($sku) {
  1254. $sku = trim($sku, ' ');
  1255. $sku = trim($sku, ' ');
  1256. $fjnr .= " and sku like '%$sku%'";
  1257. }
  1258. if ($title) {
  1259. $title = trim($title, ' ');
  1260. $title = trim($title, ' ');
  1261. $fjnr .= " and title like '%$title%'";
  1262. }
  1263. $wt = array();
  1264. $whlabel_type = $this->whlabel_type->find_all();
  1265. foreach ($whlabel_type as $v) {
  1266. $wt[$v['id']] = $v['title'];
  1267. }
  1268. //$where .= " and time > '$ktime' and time < '$jtime'";
  1269. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1270. //取得信息列表
  1271. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1272. $rows = array();
  1273. $list = array();
  1274. foreach ($info_list as $key => $value) {
  1275. if (isset($wt[$value['type']])) {
  1276. $info_list[$key]['type'] = $wt[$value['type']];
  1277. } else {
  1278. $info_list[$key]['type'] = '未设置';
  1279. }
  1280. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1281. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1282. $ztdata = '';
  1283. if (count($zt) > 0) {
  1284. foreach ($zt as $vv) {
  1285. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1286. }
  1287. }
  1288. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1289. $cdata = array_filter($qbdata, function ($item) {
  1290. return $item['state'] < 1;
  1291. });
  1292. $c = array_sum(array_column($cdata, 'jnum'));
  1293. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1294. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1295. });
  1296. $g = array_sum(array_column($gdata, 'jnum'));
  1297. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1298. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1299. });
  1300. $x = array_sum(array_column($xdata, 'jnum'));
  1301. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1302. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1303. });
  1304. $t = array_sum(array_column($tdata, 'jnum'));
  1305. $zdata = array_filter($qbdata, function ($item) {
  1306. return $item['zd'] != "" && $item['state'] < 1;
  1307. });
  1308. $z = array_sum(array_column($zdata, 'jnum'));
  1309. $zdata = array_filter($qbdata, function ($item) {
  1310. return $item['zd'] != "" && $item['state'] < 1;
  1311. });
  1312. $z = array_sum(array_column($zdata, 'jnum'));
  1313. //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1314. //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1315. //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1316. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1317. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1318. $details = array();
  1319. $cpid = array();
  1320. $od = array();
  1321. $odid = '';
  1322. $companytitle = '';
  1323. foreach ($qbdata as $v) {
  1324. if ($v['zd'] != "" && $v['state'] < 1) {
  1325. if (!isset($od[$v['zd']])) {
  1326. $od[$v['zd']] = 1; //所有数据sku
  1327. } else {
  1328. $od[$v['zd']] = $od[$v['zd']] + 1;
  1329. }
  1330. }
  1331. if ($v['state'] < 1) {
  1332. $details[$v['details']] = $v['details'];
  1333. if ($v['cpid'] != 0) {
  1334. $cpid[$v['cpid']] = $v['cpid'];
  1335. }
  1336. }
  1337. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1338. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1339. }
  1340. }
  1341. foreach ($od as $k => $vv) {
  1342. $odid .= $k . '数量' . $vv;
  1343. }
  1344. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  1345. $number = $value['number'];
  1346. $ftime = time() - 15 * 24 * 3600;
  1347. $z = $z . '(' . $odid . ')'; //查看订单号
  1348. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1349. $info_list[$key]['features'] = $c;
  1350. $info_list[$key]['number'] = $ztdata;
  1351. $info_list[$key]['sm'] = $g;
  1352. $info_list[$key]['x'] = $x;
  1353. $info_list[$key]['t'] = $t;
  1354. $info_list[$key]['z'] = $z;
  1355. /**
  1356. foreach ($cdata as $k=>$v)
  1357. {
  1358. $details[$v['details']] = $v['details'];
  1359. if($v['cpid'] != 0)
  1360. {
  1361. $cpid[$v['cpid']] = $v['cpid'];
  1362. }
  1363. }
  1364. **/
  1365. $info_list[$key]['shop'] = '';
  1366. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1367. if ($value['shop'] != '') {
  1368. $shop = explode(',', trim($value['shop'], ','));
  1369. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1370. }
  1371. $info_list[$key]['shop'] .= $companytitle;
  1372. /**
  1373. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1374. if(isset($companytitle[0]))
  1375. {
  1376. foreach ($companytitle as $k=>$v)
  1377. {
  1378. if($v['companytitle'] != '')
  1379. {
  1380. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1381. }
  1382. }
  1383. }
  1384. **/
  1385. }
  1386. $final_all_list = [];
  1387. foreach ($info_list as $k => $v) {
  1388. $final_all_list[] = [
  1389. 'id' => $v['id'],
  1390. "warehouse" => $v["warehouse"],
  1391. "purchase" => $v["purchase"],
  1392. "sku" => $v["sku"],
  1393. "title" => $v["title"] . "<br/>" . $v["pm"],
  1394. "details" => $v["details"],
  1395. "shop" => $v["shop"],
  1396. "cpbz" => $v["cpbz"],
  1397. "type" => $v["type"],
  1398. "features" => $v["features"],
  1399. "number" => $v["number"],
  1400. "sm" => $v["sm"],
  1401. "x" => $v["x"],
  1402. "t" => $v["t"],
  1403. "z" => $v["z"]
  1404. ];
  1405. }
  1406. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1407. $pagenum = ceil($total / $perpage);
  1408. $over = $total - ($start + $perpage);
  1409. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1410. echo json_encode($rows);
  1411. exit;
  1412. }
  1413. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1414. $this->data['shop'] = $wlshop;
  1415. $this->data['vip'] = $vip;
  1416. $this->_Template('whlabel_type', $this->data);
  1417. }
  1418. //美仓进销存浏览
  1419. public function _usatype()
  1420. {
  1421. if (isset($_SESSION['api'])) {
  1422. $user = $this->user->get_api($_SESSION['api']);
  1423. $usp = $user;
  1424. $fgshop = "";
  1425. $sid = "";
  1426. $wid = "";
  1427. $wtype = "";
  1428. $userwh = explode('|', trim($user['warehouse'], '|'));
  1429. foreach ($userwh as $value) {
  1430. $wid .= " id = " . $value . " or";
  1431. $wtype .= " type = " . $value . " or";
  1432. }
  1433. }
  1434. $prc = array();
  1435. $purchase = $this->purchase->find_all();
  1436. foreach ($purchase as $k => $v) {
  1437. $prc[$v['id']] = $v['title'];
  1438. }
  1439. $post = $this->input->post(NULL, TRUE);
  1440. if (isset($post['page'])) {
  1441. $page = $this->input->post('page', true);
  1442. $perpage = $this->input->post('perpage', true);
  1443. $category = $this->input->post('category', true);
  1444. $size = $this->input->post('size', true);
  1445. $grade = $this->input->post('grade', true);
  1446. $color = $this->input->post('color', true);
  1447. $lowe = $this->input->post('lowe', true);
  1448. $sku = $this->input->post('sku');
  1449. $title = $this->input->post('title');
  1450. $warehouse = $this->input->post('warehouse', true);
  1451. $usa = $this->input->post('usa', true);
  1452. $purchase = $this->input->post('purchase', true);
  1453. $lacetype = $this->input->post('lacetype', true);
  1454. $haircap = $this->input->post('haircap', true);
  1455. $density = $this->input->post('density', true);
  1456. $details = $this->input->post('details', true);
  1457. $state = $this->input->post('state', true);
  1458. $lacecolor = $this->input->post('lacecolor', true);
  1459. $cklx = $this->input->post('cklx', true);
  1460. $ktime = $this->input->post('ktime', true);
  1461. $jtime = $this->input->post('jtime', true);
  1462. $ktime = strtotime($ktime);
  1463. $jtime = strtotime($jtime);
  1464. $where = "1=1";
  1465. $gj = "";
  1466. $ck = "";
  1467. if ($lacetype) {
  1468. $where .= " and features like '%-$lacetype-%'";
  1469. }
  1470. if ($category) {
  1471. $where .= " and features like '%-$category-%'";
  1472. }
  1473. if ($size) {
  1474. $where .= " and features like '%-$size-%'";
  1475. }
  1476. if ($grade) {
  1477. $where .= " and features like '%-$grade-%'";
  1478. }
  1479. if ($color) {
  1480. $where .= " and features like '%-$color-%'";
  1481. }
  1482. if ($lowe) {
  1483. $where .= " and features like '%-$lowe-%'";
  1484. }
  1485. if ($haircap) {
  1486. $where .= " and features like '%-$haircap-%'";
  1487. }
  1488. if ($density) {
  1489. $where .= " and features like '%-$density-%'";
  1490. }
  1491. if ($lacecolor) {
  1492. $where .= " and features like '%-$lacecolor-%'";
  1493. }
  1494. if ($usa) {
  1495. if (!$warehouse) {
  1496. $where .= " and (warehouse = '5' or warehouse = '8')";
  1497. }
  1498. }
  1499. if ($warehouse) {
  1500. $where .= " and warehouse = '$warehouse'";
  1501. }
  1502. if ($details) {
  1503. $where .= " and details = '$details'";
  1504. }
  1505. if ($purchase) {
  1506. $where .= " and purchase = '$purchase'";
  1507. }
  1508. if ($state) {
  1509. $where .= " and state = '$state'";
  1510. }
  1511. $where_add = '';
  1512. if ($cklx) {
  1513. $shop = $this->shop->read($cklx);
  1514. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1515. }
  1516. if ($ktime && $jtime) {
  1517. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1518. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1519. }
  1520. //数据排序
  1521. $order_str = "id desc";
  1522. if (empty($page)) {
  1523. $start = 0;
  1524. $perpage = 1;
  1525. } else {
  1526. $start = ($page - 1) * $perpage;
  1527. }
  1528. if ($sku) {
  1529. $sku = trim($sku, ' ');
  1530. $sku = trim($sku, ' ');
  1531. $where .= " and sku like '%$sku%'";
  1532. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1533. } else if ($title) {
  1534. $title = trim($title, ' ');
  1535. $title = trim($title, ' ');
  1536. $where .= " and title like '%$title%'";
  1537. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1538. } else {
  1539. //$where .= " and time > '$ktime' and time < '$jtime'";
  1540. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1541. }
  1542. //取得信息列表
  1543. $rows = array();
  1544. $list = array();
  1545. foreach ($info_list as $key => $value) {
  1546. $warehouse = $this->warehouse->read($value['warehouse']);
  1547. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1548. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1549. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1550. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1551. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1552. $od = array();
  1553. $odid = '';
  1554. foreach ($z as $v) {
  1555. if (!isset($od[$v['zd']])) {
  1556. $od[$v['zd']] = 1; //所有数据sku
  1557. } else {
  1558. $od[$v['zd']] = $od[$v['zd']] + 1;
  1559. }
  1560. }
  1561. foreach ($od as $k => $vv) {
  1562. $odid .= $k . '数量' . $vv . ' ';
  1563. }
  1564. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1565. $info_list[$key]['features'] = $c;
  1566. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1567. $ztdata = '';
  1568. if (count($zt) > 0) {
  1569. foreach ($zt as $vv) {
  1570. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1571. }
  1572. }
  1573. $info_list[$key]['warehouse'] = $ztdata;
  1574. $info_list[$key]['g'] = $g;
  1575. $info_list[$key]['x'] = $x;
  1576. $info_list[$key]['t'] = $t;
  1577. $info_list[$key]['z'] = $z;
  1578. }
  1579. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1580. $pagenum = ceil($total / $perpage);
  1581. $over = $total - ($start + $perpage);
  1582. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1583. echo json_encode($rows);
  1584. exit;
  1585. }
  1586. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1587. $this->data['warehouse'] = $warehouse;
  1588. $this->_Template('whlabel_typeusa', $this->data);
  1589. }
  1590. //美仓进销存浏览
  1591. public function _usatypeapp()
  1592. {
  1593. $post = $this->input->post(NULL, TRUE);
  1594. if (isset($post['page'])) {
  1595. $page = $this->input->post('page', true);
  1596. $perpage = $this->input->post('perpage', true);
  1597. $sku = $this->input->post('sku', true);
  1598. $warehouse = 5;
  1599. $title = $this->input->post('title', true);
  1600. $state = $this->input->post('state', true);
  1601. $ktime = $this->input->post('ktime', true);
  1602. $jtime = $this->input->post('jtime', true);
  1603. $ktime = strtotime($ktime);
  1604. $jtime = strtotime($jtime);
  1605. $where = "1=1";
  1606. $gj = "";
  1607. $ck = "";
  1608. if ($title) {
  1609. $st = explode(' ', trim($title, ' '));
  1610. foreach ($st as $v) {
  1611. $where .= " and title like '%$v%'";
  1612. }
  1613. }
  1614. if ($warehouse) {
  1615. $where .= " and warehouse = '$warehouse'";
  1616. }
  1617. if ($state) {
  1618. $where .= " and state = '$state'";
  1619. }
  1620. if ($sku) {
  1621. $where .= " and sku like '%$sku%'";
  1622. }
  1623. if ($ktime && $jtime) {
  1624. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1625. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1626. }
  1627. //数据排序
  1628. $order_str = "id desc";
  1629. if (empty($page)) {
  1630. $start = 0;
  1631. $perpage = 1;
  1632. } else {
  1633. $start = ($page - 1) * $perpage;
  1634. }
  1635. //取得信息列表
  1636. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1637. $rows = array();
  1638. $list = array();
  1639. foreach ($info_list as $key => $value) {
  1640. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1641. }
  1642. $rowsdq = array_slice($rows, $start, $perpage);
  1643. foreach ($rowsdq as $value) {
  1644. $warehouse = $this->warehouse->read($value['warehouse']);
  1645. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1646. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1647. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1648. $od = array();
  1649. $odid = '';
  1650. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1651. }
  1652. $total = count($rows);
  1653. $pagenum = ceil($total / $perpage);
  1654. $over = $total - ($start + $perpage);
  1655. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1656. echo json_encode($rows);
  1657. exit;
  1658. }
  1659. $this->_Template('phone/p_usatypeapp', $this->data);
  1660. }
  1661. //入库操作
  1662. public function _enteradd()
  1663. {
  1664. $dt = 0;
  1665. if (isset($_SESSION['api'])) {
  1666. $user = $this->user->get_api($_SESSION['api']);
  1667. $usp = $user;
  1668. $fgshop = "";
  1669. $sid = "";
  1670. $user = explode('|', trim($user['shop'], '|'));
  1671. foreach ($user as $value) {
  1672. $fgshop .= " shop = " . $value . " or";
  1673. $sid .= " id = " . $value . " or";
  1674. }
  1675. }
  1676. $tc = $this->typeclass->find_all();
  1677. $typeclass = array();
  1678. foreach ($tc as $v) {
  1679. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1680. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1681. }
  1682. $post = $this->input->post(NULL, TRUE);
  1683. if (isset($post['sku'])) {
  1684. $list = array();
  1685. $num = "";
  1686. $title = "";
  1687. $features = "";
  1688. $order = $this->input->post('order', true);
  1689. $shop = $this->input->post('shop', true);
  1690. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1691. $sku = $this->input->post('sku', true);
  1692. $post['sm'] = $this->input->post('sm', true);
  1693. $post['warehouse'] = $this->input->post('warehouse', true);
  1694. $post['purchase'] = $this->input->post('purchase', true);
  1695. $post['retreatwarehouse'] = $post['warehouse'];
  1696. $post['state'] = $this->input->post('state', true);
  1697. $post['rktype'] = $this->input->post('rktype', true);
  1698. $post['text'] = $this->input->post('text', true);
  1699. $category = $this->input->post('category', true);
  1700. $list['category'] = $category;
  1701. $list['hairtype'] = $this->input->post('hairtype', true);
  1702. $list['grade'] = $this->input->post('grade', true);
  1703. $size = $this->input->post('size', true);
  1704. $xzsku = $this->input->post('xzsku', true);
  1705. $list['size'] = rtrim($size, ',');
  1706. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1707. $list['extension'] = $this->input->post('extension', true);
  1708. if ($category == 1297) {
  1709. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1710. }
  1711. if ($category == 1702) {
  1712. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1713. $list['syother'] = $this->input->post('syother', true);
  1714. }
  1715. if ($category == 133) {
  1716. $list['fittype'] = $this->input->post('fittype', true);
  1717. $list['acother'] = $this->input->post('acother', true);
  1718. }
  1719. $list['color'] = $this->input->post('color', true);
  1720. $list['lowe'] = $this->input->post('lowe', true);
  1721. if (!$post['purchase']) {
  1722. $post['purchase'] = 1;
  1723. }
  1724. if ($category == 127) {
  1725. $list['type'] = $this->input->post('type', true);
  1726. $list['headroad'] = $this->input->post('headroad', true);
  1727. $list['density'] = $this->input->post('density', true);
  1728. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1729. $list['lacesize'] = $this->input->post('lacesize', true);
  1730. }
  1731. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1732. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1733. }
  1734. if ($category == 128) {
  1735. $list['lacetype'] = $this->input->post('lacetype', true);
  1736. $list['haircap'] = $this->input->post('haircap', true);
  1737. $list['density'] = $this->input->post('density', true);
  1738. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1739. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1740. $list['wigother'] = $this->input->post('wigother', true);
  1741. $list['wigother2'] = $this->input->post('wigother2', true);
  1742. }
  1743. if ($category == 129) {
  1744. $list['wide'] = $this->input->post('wide', true);
  1745. }
  1746. if ($category == 131) {
  1747. $list['gifttype'] = $this->input->post('gifttype', true);
  1748. $list['giftother'] = $this->input->post('giftother', true);
  1749. }
  1750. if ($category == 134) {
  1751. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1752. }
  1753. if ($category == 1297) {
  1754. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1755. $list['sywigother'] = $this->input->post('sywigother', true);
  1756. }
  1757. if ($category == 130 || $category == 133 || $category == 1702) {
  1758. $list['items'] = $this->input->post('items', true);
  1759. $list['weight'] = $this->input->post('weight', true);
  1760. }
  1761. if ($category == 1702) {
  1762. $list['syhairther'] = $this->input->post('syhairther', true);
  1763. }
  1764. $classid = $this->classid->sku();
  1765. $scsku = $classid;
  1766. $pm = $classid;
  1767. foreach ($list as $k => $v) {
  1768. if ($v != 0) {
  1769. $num .= $v;
  1770. $features .= $v . '-';
  1771. $post[$k] = $v;
  1772. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1773. if ($k != 'size') {
  1774. $title .= $typeclass[$v]['title'] . " ";
  1775. }
  1776. if (isset($pm[$typeclass[$v]['classid']])) {
  1777. if ($typeclass[$v]['title'] == '9A') {
  1778. $pm[$typeclass[$v]['classid']] = '9A';
  1779. } else if ($typeclass[$v]['title'] == '10A') {
  1780. $pm[$typeclass[$v]['classid']] = '10A';
  1781. } else {
  1782. $clzh = $typeclass[$v]['zh'];
  1783. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1784. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1785. $clzh = $clzh[0];
  1786. }
  1787. $pm[$typeclass[$v]['classid']] = $clzh;
  1788. }
  1789. }
  1790. }
  1791. }
  1792. $zh = implode(" ", $pm);
  1793. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1794. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1795. if ($list['size']) {
  1796. $typeclass = $this->typeclass->read($list['size']);
  1797. $title .= $typeclass['title'];
  1798. }
  1799. $time = time();
  1800. if ($xzsku) {
  1801. $scsku = implode("-", $scsku);
  1802. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1803. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1804. $post['sku'] = trim($scsku, ' ');
  1805. } else {
  1806. $post['sku'] = $sku;
  1807. }
  1808. //$post['sku'] = trim($sku,' ');
  1809. $post['title'] = rtrim($title, ' ');
  1810. $post['number'] = $num;
  1811. $post['features'] = '-' . $features;
  1812. $post['enter'] = $time;
  1813. $post['time'] = $time; //操作时间
  1814. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1815. if ($yza) {
  1816. if ($post['features'] != $yza[0]['features']) {
  1817. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1818. exit;
  1819. }
  1820. }
  1821. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1822. if ($yzb) {
  1823. if ($post['sku'] != $yzb[0]['sku']) {
  1824. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1825. exit;
  1826. }
  1827. }
  1828. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1829. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1830. exit;
  1831. }
  1832. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1833. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1834. exit;
  1835. }
  1836. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1837. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1838. exit;
  1839. }
  1840. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1841. if (isset($yz[0]['type'])) {
  1842. $post['type'] = $yz[0]['type'];
  1843. }
  1844. if ($post['state'] == 9) //如果选择预设库存
  1845. {
  1846. $this->whlabel->insert($post);
  1847. } else {
  1848. /**
  1849. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1850. if($ljg == 1)
  1851. {
  1852. for($i=0;$i<$order;$i++)
  1853. {
  1854. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1855. $this->whlabel->insert($post);
  1856. }
  1857. }
  1858. **/
  1859. //if($post['warehouse'] == '5')
  1860. //{
  1861. //}
  1862. $yydata = $post;
  1863. $yydata['zh'] = $zh;
  1864. /**
  1865. $wl = $this->apiyy->get_cjlp($yydata);
  1866. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1867. {
  1868. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1869. }
  1870. if($wl['Data'][0]['m_isSucess'] != 1)
  1871. {
  1872. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1873. }
  1874. **/
  1875. for ($i = 0; $i < $order; $i++) {
  1876. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1877. $this->whlabel->insert($post);
  1878. }
  1879. }
  1880. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1881. exit;
  1882. }
  1883. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1884. $this->data['wlshop'] = $wlshop;
  1885. $this->_Template('whlabel_enteradd', $this->data);
  1886. }
  1887. //修改产品
  1888. public function _enteredit($arg_array)
  1889. {
  1890. $dt = 0;
  1891. if (isset($_SESSION['api'])) {
  1892. $user = $this->user->get_api($_SESSION['api']);
  1893. $usp = $user;
  1894. $fgshop = "";
  1895. $sid = "";
  1896. $user = explode('|', trim($user['shop'], '|'));
  1897. foreach ($user as $value) {
  1898. $fgshop .= " shop = " . $value . " or";
  1899. $sid .= " id = " . $value . " or";
  1900. }
  1901. }
  1902. $post = $this->input->post(NULL, TRUE);
  1903. if (isset($post['sku'])) {
  1904. $list = array();
  1905. $num = "";
  1906. $title = "";
  1907. $features = "";
  1908. $id = $this->input->post('id', true);
  1909. $order = $this->input->post('order', true);
  1910. $shop = $this->input->post('shop', true);
  1911. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1912. $post['sku'] = $this->input->post('sku', true);
  1913. $post['sm'] = $this->input->post('sm', true);
  1914. $post['warehouse'] = $this->input->post('warehouse', true);
  1915. $post['purchase'] = $this->input->post('purchase', true);
  1916. $post['retreatwarehouse'] = $post['warehouse'];
  1917. $category = $this->input->post('category', true);
  1918. $list['category'] = $category;
  1919. $list['hairtype'] = $this->input->post('hairtype', true);
  1920. $list['grade'] = $this->input->post('grade', true);
  1921. $size = $this->input->post('size', true);
  1922. $list['size'] = rtrim($size, ',');
  1923. $post['rktype'] = $this->input->post('rktype', true);
  1924. $post['text'] = $this->input->post('text', true);
  1925. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1926. $list['extension'] = $this->input->post('extension', true);
  1927. if ($category == 1297) {
  1928. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1929. }
  1930. if ($category == 1702) {
  1931. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1932. $list['syother'] = $this->input->post('syother', true);
  1933. }
  1934. if ($category == 133) {
  1935. $list['fittype'] = $this->input->post('fittype', true);
  1936. $list['acother'] = $this->input->post('acother', true);
  1937. }
  1938. $list['color'] = $this->input->post('color', true);
  1939. $list['lowe'] = $this->input->post('lowe', true);
  1940. if (!$post['purchase']) {
  1941. $post['purchase'] = 1;
  1942. }
  1943. if ($category == 127) {
  1944. $list['type'] = $this->input->post('type', true);
  1945. $list['headroad'] = $this->input->post('headroad', true);
  1946. $list['density'] = $this->input->post('density', true);
  1947. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1948. $list['lacesize'] = $this->input->post('lacesize', true);
  1949. }
  1950. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1951. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1952. }
  1953. if ($category == 128) {
  1954. $list['lacetype'] = $this->input->post('lacetype', true);
  1955. $list['haircap'] = $this->input->post('haircap', true);
  1956. $list['density'] = $this->input->post('density', true);
  1957. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1958. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1959. $list['wigother'] = $this->input->post('wigother', true);
  1960. $list['wigother2'] = $this->input->post('wigother2', true);
  1961. }
  1962. if ($category == 129) {
  1963. $list['wide'] = $this->input->post('wide', true);
  1964. }
  1965. if ($category == 131) {
  1966. $list['gifttype'] = $this->input->post('gifttype', true);
  1967. $list['giftother'] = $this->input->post('giftother', true);
  1968. }
  1969. if ($category == 134) {
  1970. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1971. }
  1972. if ($category == 1297) {
  1973. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1974. $list['sywigother'] = $this->input->post('sywigother', true);
  1975. }
  1976. if ($category == 130 || $category == 133 || $category == 1702) {
  1977. $list['items'] = $this->input->post('items', true);
  1978. $list['weight'] = $this->input->post('weight', true);
  1979. }
  1980. if ($category == 1702) {
  1981. $list['syhairther'] = $this->input->post('syhairther', true);
  1982. }
  1983. foreach ($list as $k => $v) {
  1984. if ($v != 0) {
  1985. $num .= $v;
  1986. $features .= $v . '-';
  1987. $typeclass = $this->typeclass->read($v);
  1988. if ($k != 'size') {
  1989. $title .= $typeclass['title'] . " ";
  1990. }
  1991. }
  1992. }
  1993. $typeclass = $this->typeclass->read($list['size']);
  1994. $title .= $typeclass['title'];
  1995. $time = time();
  1996. $post['title'] = rtrim($title, ' ');
  1997. $post['number'] = $num;
  1998. $post['features'] = '-' . $features;
  1999. $post['time'] = $time; //操作时间
  2000. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2001. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2002. exit;
  2003. }
  2004. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2005. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2006. exit;
  2007. }
  2008. $uid = $this->whlabel->read($id);
  2009. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2010. if ($datanum > 0) {
  2011. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2012. exit;
  2013. }
  2014. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2015. {
  2016. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2017. if ($yza) {
  2018. if ($post['features'] != $yza[0]['features']) {
  2019. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2020. exit;
  2021. }
  2022. }
  2023. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2024. if ($yzb) {
  2025. if ($post['sku'] != $yzb[0]['sku']) {
  2026. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2027. exit;
  2028. }
  2029. }
  2030. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2031. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2032. exit;
  2033. }
  2034. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2035. foreach ($data as $v) {
  2036. $post['id'] = $v['id'];
  2037. $this->whlabel->save($post, $v['id']);
  2038. }
  2039. } else {
  2040. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2041. if ($data > 0) {
  2042. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2043. exit;
  2044. } else {
  2045. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2046. foreach ($data as $v) {
  2047. $post['id'] = $v['id'];
  2048. $this->whlabel->save($post, $v['id']);
  2049. }
  2050. }
  2051. }
  2052. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2053. exit;
  2054. }
  2055. $uid = $this->whlabel->read($arg_array[0]);
  2056. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2057. $this->data['enter'] = $uid;
  2058. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2059. $this->data['wlshop'] = $wlshop;
  2060. $this->_Template('whlabel_enteredit', $this->data);
  2061. }
  2062. //入库浏览
  2063. public function _enter()
  2064. {
  2065. $post = $this->input->post(NULL, TRUE);
  2066. if (isset($post['s'])) {
  2067. $id_arr = $this->input->post('s');
  2068. $id_arr = explode(',', $id_arr);
  2069. if (!$id_arr) {
  2070. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2071. exit;
  2072. }
  2073. //循环删除记录
  2074. foreach ($id_arr as $v) {
  2075. $sid = $this->whlabel->read($v);
  2076. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2077. if ($count > 0) {
  2078. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2079. exit;
  2080. }
  2081. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2082. foreach ($info_list as $va) {
  2083. $this->whlabel->remove($va['id']);
  2084. }
  2085. }
  2086. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2087. exit;
  2088. }
  2089. $sp = array();
  2090. $s = $this->shop->find_all('1=1', 'id,shopname');
  2091. foreach ($s as $v) {
  2092. $sp[$v['id']] = $v['shopname'];
  2093. }
  2094. $wh = array();
  2095. $w = $this->warehouse->find_all('1=1', 'id,title');
  2096. foreach ($w as $v) {
  2097. $wh[$v['id']] = $v['title'];
  2098. }
  2099. if (isset($post['page'])) {
  2100. $page = $this->input->post('page', true);
  2101. $perpage = $this->input->post('perpage', true);
  2102. $category = $this->input->post('category', true);
  2103. $size = $this->input->post('size', true);
  2104. $grade = $this->input->post('grade', true);
  2105. $color = $this->input->post('color', true);
  2106. $lowe = $this->input->post('lowe', true);
  2107. $sku = $this->input->post('sku', true);
  2108. $warehouse = $this->input->post('warehouse', true);
  2109. $purchase = $this->input->post('purchase', true);
  2110. $ktime = $this->input->post('ktime', true);
  2111. $jtime = $this->input->post('jtime', true);
  2112. $ktime = strtotime($ktime);
  2113. $jtime = strtotime($jtime);
  2114. $where = "1=1";
  2115. $gj = "";
  2116. $ck = "";
  2117. if ($category) {
  2118. $where .= " and features like '%-$category-%'";
  2119. }
  2120. if ($size) {
  2121. $where .= " and features like '%-$size-%'";
  2122. }
  2123. if ($grade) {
  2124. $where .= " and features like '%-$grade-%'";
  2125. }
  2126. if ($color) {
  2127. $where .= " and features like '%-$color-%'";
  2128. }
  2129. if ($lowe) {
  2130. $where .= " and features like '%-$lowe-%'";
  2131. }
  2132. if ($warehouse) {
  2133. $where .= " and warehouse = '$warehouse'";
  2134. }
  2135. if ($purchase) {
  2136. $where .= " and purchase = '$purchase'";
  2137. }
  2138. if ($sku) {
  2139. $where .= " and sku like '%$sku%'";
  2140. }
  2141. if ($ktime && $jtime) {
  2142. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2143. }
  2144. //数据排序
  2145. $order_str = "enter desc";
  2146. if (empty($page)) {
  2147. $start = 0;
  2148. $perpage = 1;
  2149. } else {
  2150. $start = ($page - 1) * $perpage;
  2151. }
  2152. //取得信息列表
  2153. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2154. foreach ($info_list as $k => $v) {
  2155. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2156. if ($v['shop'] == '') {
  2157. $s = '通用';
  2158. } else {
  2159. $info_list[$k]['shop'] = '';
  2160. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2161. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2162. }
  2163. }
  2164. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2165. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2166. $info_list[$k]['g'] = $g;
  2167. }
  2168. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2169. $pagenum = ceil($total / $perpage);
  2170. $over = $total - ($start + $perpage);
  2171. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2172. echo json_encode($rows);
  2173. exit;
  2174. }
  2175. $this->_Template('whlabel_enter', $this->data);
  2176. }
  2177. //出库浏览
  2178. public function _out()
  2179. {
  2180. $post = $this->input->post(NULL, TRUE);
  2181. if (isset($post['page'])) {
  2182. $page = $this->input->post('page', true);
  2183. $perpage = $this->input->post('perpage', true);
  2184. $category = $this->input->post('category', true);
  2185. $size = $this->input->post('size', true);
  2186. $grade = $this->input->post('grade', true);
  2187. $color = $this->input->post('color', true);
  2188. $lowe = $this->input->post('lowe', true);
  2189. $sku = $this->input->post('sku', true);
  2190. $warehouse = $this->input->post('warehouse', true);
  2191. $purchase = $this->input->post('purchase', true);
  2192. $state = $this->input->post('state', true);
  2193. $ktime = $this->input->post('ktime', true);
  2194. $jtime = $this->input->post('jtime', true);
  2195. $ktime = strtotime($ktime);
  2196. $jtime = strtotime($jtime);
  2197. $where = "state=3";
  2198. $gj = "";
  2199. $ck = "";
  2200. if ($category) {
  2201. $where .= " and features like '%-$category-%'";
  2202. }
  2203. if ($size) {
  2204. $where .= " and features like '%-$size-%'";
  2205. }
  2206. if ($grade) {
  2207. $where .= " and features like '%-$grade-%'";
  2208. }
  2209. if ($color) {
  2210. $where .= " and features like '%-$color-%'";
  2211. }
  2212. if ($lowe) {
  2213. $where .= " and features like '%-$lowe-%'";
  2214. }
  2215. if ($state) {
  2216. $where .= " and state = '$state'";
  2217. }
  2218. if ($warehouse) {
  2219. $where .= " and warehouse = '$warehouse'";
  2220. }
  2221. if ($purchase) {
  2222. $where .= " and purchase = '$purchase'";
  2223. }
  2224. if ($sku) {
  2225. $where .= " and sku = '$sku'";
  2226. }
  2227. if ($ktime && $jtime) {
  2228. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2229. }
  2230. //数据排序
  2231. $order_str = "id desc";
  2232. if (empty($page)) {
  2233. $start = 0;
  2234. $perpage = 1;
  2235. } else {
  2236. $start = ($page - 1) * $perpage;
  2237. }
  2238. //取得信息列表
  2239. $info_list = $this->whlabel->find_all($where, 'sku');
  2240. $rows = array();
  2241. $list = array();
  2242. foreach ($info_list as $key => $value) {
  2243. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2244. }
  2245. $rows = array_unique($rows); //删除重复记录
  2246. foreach ($rows as $key => $value) {
  2247. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2248. $ck = $this->warehouse->read($data['warehouse']);
  2249. $warehouse = $ck['title'];
  2250. $gy = $this->purchase->read($data['purchase']);
  2251. $purchase = $gy['purchase'];
  2252. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2253. $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);
  2254. }
  2255. $total = count($list);
  2256. $pagenum = ceil($total / $perpage);
  2257. $over = $total - ($start + $perpage);
  2258. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2259. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2260. echo json_encode($rows);
  2261. exit;
  2262. }
  2263. $this->_Template('whlabel_out', $this->data);
  2264. }
  2265. //出库标签浏览
  2266. public function _label()
  2267. {
  2268. $post = $this->input->post(NULL, TRUE);
  2269. if (isset($post['page'])) {
  2270. $page = $this->input->post('page', true);
  2271. $perpage = $this->input->post('perpage', true);
  2272. $sku = $this->input->post('sku', true);
  2273. $warehouse = $this->input->post('warehouse', true);
  2274. $purchase = $this->input->post('purchase', true);
  2275. $orderinfo = $this->input->post('orderinfo', true);
  2276. $waybill = $this->input->post('waybill', true);
  2277. $category = $this->input->post('category', true);
  2278. $size = $this->input->post('size', true);
  2279. $grade = $this->input->post('grade', true);
  2280. $color = $this->input->post('color', true);
  2281. $lowe = $this->input->post('lowe', true);
  2282. $where = "state=1";
  2283. if ($sku) {
  2284. $where .= " and sku = '$sku'";
  2285. }
  2286. if ($warehouse) {
  2287. $where .= " and warehouse = '$warehouse'";
  2288. }
  2289. if ($purchase) {
  2290. $where .= " and purchase = '$purchase'";
  2291. }
  2292. if ($orderinfo) {
  2293. $where .= " and orderinfo = '$orderinfo'";
  2294. }
  2295. if ($waybill) {
  2296. $where .= " and waybill = '$waybill'";
  2297. }
  2298. if ($category) {
  2299. $where .= " and features like '%-$category-%'";
  2300. }
  2301. if ($size) {
  2302. $where .= " and features like '%-$size-%'";
  2303. }
  2304. if ($grade) {
  2305. $where .= " and features like '%-$grade-%'";
  2306. }
  2307. if ($color) {
  2308. $where .= " and features like '%-$color-%'";
  2309. }
  2310. if ($lowe) {
  2311. $where .= " and features like '%-$lowe-%'";
  2312. }
  2313. //数据排序
  2314. $order_str = "outk desc";
  2315. if (empty($page)) {
  2316. $start = 0;
  2317. $perpage = 1;
  2318. } else {
  2319. $start = ($page - 1) * $perpage;
  2320. }
  2321. //取得信息列表
  2322. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2323. foreach ($info_list as $key => $value) {
  2324. $warehouse = $this->warehouse->read($value['warehouse']);
  2325. $info_list[$key]['warehouse'] = $warehouse['title'];
  2326. $purchase = $this->purchase->read($value['purchase']);
  2327. $info_list[$key]['purchase'] = $purchase['title'];
  2328. if ($value['outk'] != 0) {
  2329. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2330. } else {
  2331. $info_list[$key]['outk'] = "";
  2332. }
  2333. if ($value['orderinfo'] == 0) {
  2334. $info_list[$key]['orderinfo'] = "";
  2335. }
  2336. if ($value['waybill'] == 0) {
  2337. $info_list[$key]['waybill'] = "";
  2338. }
  2339. }
  2340. $total = $this->whlabel->find_count($where);
  2341. $pagenum = ceil($total / $perpage);
  2342. $over = $total - ($start + $perpage);
  2343. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2344. echo json_encode($rows);
  2345. exit;
  2346. }
  2347. $this->_Template('whlabel_label', $this->data);
  2348. }
  2349. //独立站出库订单
  2350. public function _outorder()
  2351. {
  2352. if (isset($_SESSION['api'])) {
  2353. $user = $this->user->get_api($_SESSION['api']);
  2354. $usp = $user;
  2355. $fgshop = "";
  2356. $sid = "";
  2357. $user = explode('|', trim($user['shop'], '|'));
  2358. foreach ($user as $value) {
  2359. $fgshop .= " shop = " . $value . " or";
  2360. $sid .= " id = " . $value . " or";
  2361. }
  2362. } else {
  2363. echo "请重新登录";
  2364. }
  2365. $post = $this->input->post(NULL, TRUE);
  2366. if (isset($post['page'])) {
  2367. $page = $this->input->post('page', true);
  2368. $perpage = $this->input->post('perpage', true);
  2369. $warehouse = $this->input->post('warehouse', true);
  2370. $xztime = $this->input->post('xztime', true);
  2371. $timetk = $this->input->post('timetkk', true);
  2372. $timetj = $this->input->post('timetjj', true);
  2373. $shop = $this->input->post('shop', true);
  2374. $source = $this->input->post('source', true);
  2375. $orderinfo = $this->input->post('orderinfo', true);
  2376. $number = $this->input->post('number', true);
  2377. $sfxh = $this->input->post('sfxh', true);
  2378. $express = $this->input->post('express', true);
  2379. $waybill = $this->input->post('waybill', true);
  2380. $library = $this->input->post('library', true);
  2381. $country = $this->input->post('country', true);
  2382. $so = $this->input->post('so', true);
  2383. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2384. $print = $this->input->post('print', true);
  2385. $state = $this->input->post('state', true);
  2386. $orderurl = $this->input->post('orderurl', true);
  2387. $timetk = strtotime($timetk);
  2388. $timetj = strtotime($timetj);
  2389. /**
  2390. $sj = $this->input->post('sj',true);
  2391. if($sj)
  2392. {
  2393. $sj = $this->input->post('sj',true);
  2394. }
  2395. else
  2396. {
  2397. $sj = "fullorder";
  2398. }
  2399. **/
  2400. $sj = "fullorder";
  2401. $where = "1=1";
  2402. if ($warehouse) {
  2403. $where .= " and type = '$warehouse'";
  2404. }
  2405. if ($timetk && $timetj) {
  2406. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2407. }
  2408. if ($orderinfo) {
  2409. $where .= " and orderinfo = '$orderinfo'";
  2410. }
  2411. if ($number) {
  2412. $where .= " and number = '$number'";
  2413. }
  2414. if ($express) {
  2415. $where .= " and express = '$express'";
  2416. }
  2417. if ($waybill) {
  2418. $where .= " and waybill = '$waybill'";
  2419. }
  2420. if ($library) {
  2421. $where .= " and library = '$library'";
  2422. }
  2423. if ($print) {
  2424. $where .= " and print = '$print'";
  2425. }
  2426. if ($libraryconfirm) {
  2427. $where .= " and libraryconfirm = '$libraryconfirm'";
  2428. }
  2429. if ($state) {
  2430. $where .= " and state = '$state'";
  2431. }
  2432. if ($shop) {
  2433. $where .= " and shop = '$shop'";
  2434. }
  2435. if ($country) {
  2436. $where .= " and country = '$country'";
  2437. }
  2438. if ($sfxh != '') {
  2439. $where .= " and sfxh = '$sfxh'";
  2440. }
  2441. if ($so) {
  2442. $where .= " and shipremarks like '%$so%'";
  2443. }
  2444. if ($source) {
  2445. if ($source == '2d') {
  2446. $where .= " and source >= '2'";
  2447. } else {
  2448. $where .= " and source = '$source'";
  2449. }
  2450. }
  2451. if (isset($_SESSION['api'])) {
  2452. foreach ($user as $value) {
  2453. $fgshop .= " shop = " . $value . " or";
  2454. }
  2455. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2456. }
  2457. if ($orderurl) {
  2458. $url = $this->orderurl->read($orderurl);
  2459. $where .= " and link like '%" . $url['url'] . "%'";
  2460. }
  2461. //数据排序
  2462. $order_str = "librarytime desc";
  2463. if (empty($page)) {
  2464. $start = 0;
  2465. $perpage = 1;
  2466. } else {
  2467. $start = ($page - 1) * $perpage;
  2468. }
  2469. //取得信息列表
  2470. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2471. //格式化数据
  2472. foreach ($info_list as $key => $value) {
  2473. $shop = $this->shop->read($value['shop']);
  2474. $info_list[$key]['shop'] = $shop['shopname'];
  2475. $express = $this->express->read($value['express']);
  2476. $info_list[$key]['express'] = $express['servicename'];
  2477. $warehouse = $this->warehouse->read($value['type']);
  2478. $info_list[$key]['type'] = $warehouse['title'];
  2479. if ($value['librarytime'] == '0') {
  2480. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2481. } else {
  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);
  2490. exit;
  2491. }
  2492. $this->data['express'] = $this->express->find_all();
  2493. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2494. $this->data['wlshop'] = $wlshop;
  2495. $user = $this->user->get_api($_SESSION['api']);
  2496. $powerid = $this->power->read($user['power']);
  2497. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2498. $pid = '';
  2499. foreach ($powertext as $v) {
  2500. $pid .= " id = " . $v . " or";
  2501. }
  2502. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2503. $this->data['fullorderexcel'] = $fullorderexcel;
  2504. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2505. $this->data['orderurl'] = $orderurl;
  2506. $this->_Template('whlabel_outorder', $this->data);
  2507. }
  2508. //tt出库
  2509. public function _toutorder()
  2510. {
  2511. if (isset($_SESSION['api'])) {
  2512. $user = $this->user->get_api($_SESSION['api']);
  2513. $usp = $user;
  2514. $fgshop = "";
  2515. $sid = "";
  2516. $user = explode('|', trim($user['shop'], '|'));
  2517. foreach ($user as $value) {
  2518. $fgshop .= " shop = " . $value . " or";
  2519. $sid .= " id = " . $value . " or";
  2520. }
  2521. } else {
  2522. echo "请重新登录";
  2523. }
  2524. $post = $this->input->post(NULL, TRUE);
  2525. if (isset($post['page'])) {
  2526. $page = $this->input->post('page', true);
  2527. $perpage = $this->input->post('perpage', true);
  2528. $warehouse = $this->input->post('warehouse', true);
  2529. $xztime = $this->input->post('xztime', true);
  2530. $timetk = $this->input->post('timetkk', true);
  2531. $timetj = $this->input->post('timetjj', true);
  2532. $shop = $this->input->post('shop', true);
  2533. $source = $this->input->post('source', true);
  2534. $orderinfo = $this->input->post('orderinfo', true);
  2535. $number = $this->input->post('number', true);
  2536. $sfxh = $this->input->post('sfxh', true);
  2537. $express = $this->input->post('express', true);
  2538. $waybill = $this->input->post('waybill', true);
  2539. $library = $this->input->post('library', true);
  2540. $country = $this->input->post('country', true);
  2541. $so = $this->input->post('so', true);
  2542. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2543. $print = $this->input->post('print', true);
  2544. $state = $this->input->post('state', true);
  2545. $orderurl = $this->input->post('orderurl', true);
  2546. $timetk = strtotime($timetk);
  2547. $timetj = strtotime($timetj);
  2548. /**
  2549. $sj = $this->input->post('sj',true);
  2550. if($sj)
  2551. {
  2552. $sj = $this->input->post('sj',true);
  2553. }
  2554. else
  2555. {
  2556. $sj = "fullorder";
  2557. }
  2558. **/
  2559. $sj = "fullordertt";
  2560. $where = "1=1";
  2561. if ($warehouse) {
  2562. $where .= " and type = '$warehouse'";
  2563. }
  2564. if ($timetk && $timetj) {
  2565. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2566. }
  2567. if ($orderinfo) {
  2568. $where .= " and orderinfo = '$orderinfo'";
  2569. }
  2570. if ($number) {
  2571. $where .= " and number = '$number'";
  2572. }
  2573. if ($express) {
  2574. $where .= " and express = '$express'";
  2575. }
  2576. if ($waybill) {
  2577. $where .= " and waybill = '$waybill'";
  2578. }
  2579. if ($library) {
  2580. $where .= " and library = '$library'";
  2581. }
  2582. if ($print) {
  2583. $where .= " and print = '$print'";
  2584. }
  2585. if ($libraryconfirm) {
  2586. $where .= " and libraryconfirm = '$libraryconfirm'";
  2587. }
  2588. if ($state) {
  2589. $where .= " and state = '$state'";
  2590. }
  2591. if ($shop) {
  2592. $where .= " and shop = '$shop'";
  2593. }
  2594. if ($country) {
  2595. $where .= " and country = '$country'";
  2596. }
  2597. if ($sfxh != '') {
  2598. $where .= " and sfxh = '$sfxh'";
  2599. }
  2600. if ($so) {
  2601. $where .= " and shipremarks like '%$so%'";
  2602. }
  2603. if ($source) {
  2604. if ($source == '2d') {
  2605. $where .= " and source >= '2'";
  2606. } else {
  2607. $where .= " and source = '$source'";
  2608. }
  2609. }
  2610. if (isset($_SESSION['api'])) {
  2611. foreach ($user as $value) {
  2612. $fgshop .= " shop = " . $value . " or";
  2613. }
  2614. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2615. }
  2616. if ($orderurl) {
  2617. $url = $this->orderurl->read($orderurl);
  2618. $where .= " and link like '%" . $url['url'] . "%'";
  2619. }
  2620. //数据排序
  2621. $order_str = "librarytime desc";
  2622. if (empty($page)) {
  2623. $start = 0;
  2624. $perpage = 1;
  2625. } else {
  2626. $start = ($page - 1) * $perpage;
  2627. }
  2628. //取得信息列表
  2629. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2630. //格式化数据
  2631. foreach ($info_list as $key => $value) {
  2632. $shop = $this->shop->read($value['shop']);
  2633. $info_list[$key]['shop'] = $shop['shopname'];
  2634. $express = $this->express->read($value['express']);
  2635. $info_list[$key]['express'] = $express['servicename'];
  2636. $warehouse = $this->warehouse->read($value['type']);
  2637. $info_list[$key]['type'] = $warehouse['title'];
  2638. if ($value['librarytime'] == '0') {
  2639. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2640. } else {
  2641. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2642. }
  2643. }
  2644. $total = $this->$sj->find_count($where);
  2645. $pagenum = ceil($total / $perpage);
  2646. $over = $total - ($start + $perpage);
  2647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2648. echo json_encode($rows);
  2649. exit;
  2650. }
  2651. $this->data['express'] = $this->express->find_all();
  2652. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2653. $this->data['wlshop'] = $wlshop;
  2654. $user = $this->user->get_api($_SESSION['api']);
  2655. $powerid = $this->power->read($user['power']);
  2656. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2657. $pid = '';
  2658. foreach ($powertext as $v) {
  2659. $pid .= " id = " . $v . " or";
  2660. }
  2661. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2662. $this->data['fullorderexcel'] = $fullorderexcel;
  2663. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2664. $this->data['orderurl'] = $orderurl;
  2665. $this->_Template('whlabel_toutorder', $this->data);
  2666. }
  2667. //tt出库
  2668. public function _aoutorder()
  2669. {
  2670. if (isset($_SESSION['api'])) {
  2671. $user = $this->user->get_api($_SESSION['api']);
  2672. $usp = $user;
  2673. $fgshop = "";
  2674. $sid = "";
  2675. $user = explode('|', trim($user['shop'], '|'));
  2676. foreach ($user as $value) {
  2677. $fgshop .= " shop = " . $value . " or";
  2678. $sid .= " id = " . $value . " or";
  2679. }
  2680. } else {
  2681. echo "请重新登录";
  2682. }
  2683. $post = $this->input->post(NULL, TRUE);
  2684. if (isset($post['page'])) {
  2685. $page = $this->input->post('page', true);
  2686. $perpage = $this->input->post('perpage', true);
  2687. $warehouse = $this->input->post('warehouse', true);
  2688. $xztime = $this->input->post('xztime', true);
  2689. $timetk = $this->input->post('timetkk', true);
  2690. $timetj = $this->input->post('timetjj', true);
  2691. $shop = $this->input->post('shop', true);
  2692. $source = $this->input->post('source', true);
  2693. $orderinfo = $this->input->post('orderinfo', true);
  2694. $number = $this->input->post('number', true);
  2695. $sfxh = $this->input->post('sfxh', true);
  2696. $express = $this->input->post('express', true);
  2697. $waybill = $this->input->post('waybill', true);
  2698. $library = $this->input->post('library', true);
  2699. $country = $this->input->post('country', true);
  2700. $so = $this->input->post('so', true);
  2701. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2702. $print = $this->input->post('print', true);
  2703. $state = $this->input->post('state', true);
  2704. $orderurl = $this->input->post('orderurl', true);
  2705. $timetk = strtotime($timetk);
  2706. $timetj = strtotime($timetj);
  2707. /**
  2708. $sj = $this->input->post('sj',true);
  2709. if($sj)
  2710. {
  2711. $sj = $this->input->post('sj',true);
  2712. }
  2713. else
  2714. {
  2715. $sj = "fullorder";
  2716. }
  2717. **/
  2718. $sj = "fullorderamz";
  2719. $where = "1=1";
  2720. if ($warehouse) {
  2721. $where .= " and type = '$warehouse'";
  2722. }
  2723. if ($timetk && $timetj) {
  2724. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2725. }
  2726. if ($orderinfo) {
  2727. $where .= " and orderinfo = '$orderinfo'";
  2728. }
  2729. if ($number) {
  2730. $where .= " and number = '$number'";
  2731. }
  2732. if ($express) {
  2733. $where .= " and express = '$express'";
  2734. }
  2735. if ($waybill) {
  2736. $where .= " and waybill = '$waybill'";
  2737. }
  2738. if ($library) {
  2739. $where .= " and library = '$library'";
  2740. }
  2741. if ($print) {
  2742. $where .= " and print = '$print'";
  2743. }
  2744. if ($libraryconfirm) {
  2745. $where .= " and libraryconfirm = '$libraryconfirm'";
  2746. }
  2747. if ($state) {
  2748. $where .= " and state = '$state'";
  2749. }
  2750. if ($shop) {
  2751. $where .= " and shop = '$shop'";
  2752. }
  2753. if ($country) {
  2754. $where .= " and country = '$country'";
  2755. }
  2756. if ($sfxh != '') {
  2757. $where .= " and sfxh = '$sfxh'";
  2758. }
  2759. if ($so) {
  2760. $where .= " and shipremarks like '%$so%'";
  2761. }
  2762. if ($source) {
  2763. if ($source == '2d') {
  2764. $where .= " and source >= '2'";
  2765. } else {
  2766. $where .= " and source = '$source'";
  2767. }
  2768. }
  2769. if (isset($_SESSION['api'])) {
  2770. foreach ($user as $value) {
  2771. $fgshop .= " shop = " . $value . " or";
  2772. }
  2773. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2774. }
  2775. if ($orderurl) {
  2776. $url = $this->orderurl->read($orderurl);
  2777. $where .= " and link like '%" . $url['url'] . "%'";
  2778. }
  2779. //数据排序
  2780. $order_str = "librarytime desc";
  2781. if (empty($page)) {
  2782. $start = 0;
  2783. $perpage = 1;
  2784. } else {
  2785. $start = ($page - 1) * $perpage;
  2786. }
  2787. //取得信息列表
  2788. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2789. //格式化数据
  2790. foreach ($info_list as $key => $value) {
  2791. $shop = $this->shop->read($value['shop']);
  2792. $info_list[$key]['shop'] = $shop['shopname'];
  2793. $express = $this->express->read($value['express']);
  2794. $info_list[$key]['express'] = $express['servicename'];
  2795. $warehouse = $this->warehouse->read($value['type']);
  2796. $info_list[$key]['type'] = $warehouse['title'];
  2797. if ($value['librarytime'] == '0') {
  2798. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2799. } else {
  2800. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2801. }
  2802. }
  2803. $total = $this->$sj->find_count($where);
  2804. $pagenum = ceil($total / $perpage);
  2805. $over = $total - ($start + $perpage);
  2806. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2807. echo json_encode($rows);
  2808. exit;
  2809. }
  2810. $this->data['express'] = $this->express->find_all();
  2811. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2812. $this->data['wlshop'] = $wlshop;
  2813. $user = $this->user->get_api($_SESSION['api']);
  2814. $powerid = $this->power->read($user['power']);
  2815. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2816. $pid = '';
  2817. foreach ($powertext as $v) {
  2818. $pid .= " id = " . $v . " or";
  2819. }
  2820. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2821. $this->data['fullorderexcel'] = $fullorderexcel;
  2822. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2823. $this->data['orderurl'] = $orderurl;
  2824. $this->_Template('whlabel_aoutorder', $this->data);
  2825. }
  2826. //速卖通出库订单
  2827. public function _soutorder()
  2828. {
  2829. if (isset($_SESSION['api'])) {
  2830. $user = $this->user->get_api($_SESSION['api']);
  2831. $usp = $user;
  2832. $fgshop = "";
  2833. $sid = "";
  2834. $user = explode('|', trim($user['shop'], '|'));
  2835. foreach ($user as $value) {
  2836. $sid .= " id = " . $value . " or";
  2837. }
  2838. }
  2839. $post = $this->input->post(NULL, TRUE);
  2840. if (isset($post['page'])) {
  2841. $page = $this->input->post('page', true);
  2842. $perpage = $this->input->post('perpage', true);
  2843. $warehouse = $this->input->post('warehouse', true);
  2844. $xztime = $this->input->post('xztime', true);
  2845. $timetk = $this->input->post('timetkk', true);
  2846. $timetj = $this->input->post('timetjj', true);
  2847. $shop = $this->input->post('shop', true);
  2848. $source = $this->input->post('source', true);
  2849. $orderinfo = $this->input->post('orderinfo', true);
  2850. $number = $this->input->post('number', true);
  2851. $express = $this->input->post('express', true);
  2852. $waybill = $this->input->post('waybill', true);
  2853. $library = $this->input->post('library', true);
  2854. $country = $this->input->post('country', true);
  2855. $sfxh = $this->input->post('sfxh', true);
  2856. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2857. $print = $this->input->post('print', true);
  2858. $state = $this->input->post('state', true);
  2859. $so = $this->input->post('so', true);
  2860. $timetk = strtotime($timetk);
  2861. $timetj = strtotime($timetj);
  2862. /**
  2863. $sj = $this->input->post('sj',true);
  2864. if($sj)
  2865. {
  2866. $sj = $this->input->post('sj',true);
  2867. }
  2868. else
  2869. {
  2870. $sj = "fullorder";
  2871. }
  2872. **/
  2873. $sj = "fullordersmt";
  2874. $where = "1=1";
  2875. if ($warehouse) {
  2876. $where .= " and type = '$warehouse'";
  2877. }
  2878. if ($timetk && $timetj) {
  2879. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2880. }
  2881. if ($orderinfo) {
  2882. $where .= " and orderinfo = '$orderinfo'";
  2883. }
  2884. if ($number) {
  2885. $where .= " and number = '$number'";
  2886. }
  2887. if ($express) {
  2888. $where .= " and express = '$express'";
  2889. }
  2890. if ($waybill) {
  2891. $where .= " and waybill = '$waybill'";
  2892. }
  2893. if ($library) {
  2894. $where .= " and library = '$library'";
  2895. }
  2896. if ($print) {
  2897. $where .= " and print = '$print'";
  2898. }
  2899. if ($libraryconfirm) {
  2900. $where .= " and libraryconfirm = '$libraryconfirm'";
  2901. }
  2902. if ($state) {
  2903. $where .= " and state = '$state'";
  2904. }
  2905. if ($shop) {
  2906. $where .= " and shop = '$shop'";
  2907. }
  2908. if ($sfxh != '') {
  2909. $where .= " and sfxh = '$sfxh'";
  2910. }
  2911. if ($so) {
  2912. $where .= " and shipremarks like '%$so%'";
  2913. }
  2914. if ($source) {
  2915. $where .= " and source = '$source'";
  2916. }
  2917. if ($country) {
  2918. $where .= " and country = '$country'";
  2919. } else {
  2920. if (isset($_SESSION['api'])) {
  2921. foreach ($user as $value) {
  2922. $fgshop .= " shop = " . $value . " or";
  2923. }
  2924. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2925. }
  2926. }
  2927. //数据排序
  2928. $order_str = "librarytime desc";
  2929. if (empty($page)) {
  2930. $start = 0;
  2931. $perpage = 1;
  2932. } else {
  2933. $start = ($page - 1) * $perpage;
  2934. }
  2935. //取得信息列表
  2936. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2937. //格式化数据
  2938. foreach ($info_list as $key => $value) {
  2939. $shop = $this->shop->read($value['shop']);
  2940. $info_list[$key]['shop'] = $shop['shopname'];
  2941. $express = $this->express->read($value['express']);
  2942. $info_list[$key]['express'] = $express['servicename'];
  2943. $warehouse = $this->warehouse->read($value['type']);
  2944. $info_list[$key]['type'] = $warehouse['title'];
  2945. if ($value['librarytime'] == '0') {
  2946. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2947. } else {
  2948. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2949. }
  2950. }
  2951. $total = $this->$sj->find_count($where);
  2952. $pagenum = ceil($total / $perpage);
  2953. $over = $total - ($start + $perpage);
  2954. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2955. echo json_encode($rows);
  2956. exit;
  2957. }
  2958. $this->data['express'] = $this->express->find_all();
  2959. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2960. $this->data['wlshop'] = $wlshop;
  2961. $user = $this->user->get_api($_SESSION['api']);
  2962. $powerid = $this->power->read($user['power']);
  2963. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2964. $pid = '';
  2965. foreach ($powertext as $v) {
  2966. $pid .= " id = " . $v . " or";
  2967. }
  2968. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2969. $this->data['fullorderexcel'] = $fullorderexcel;
  2970. $this->_Template('whlabel_soutorder', $this->data);
  2971. }
  2972. //订单退库
  2973. public function _retreat()
  2974. {
  2975. $post = $this->input->post(NULL, TRUE);
  2976. if (isset($post['page'])) {
  2977. $page = $this->input->post('page', true);
  2978. $perpage = $this->input->post('perpage', true);
  2979. $warehouse = $this->input->post('warehouse', true);
  2980. $timetk = $this->input->post('timetk', true);
  2981. $timetj = $this->input->post('timetj', true);
  2982. $shop = $this->input->post('shop', true);
  2983. $source = $this->input->post('source', true);
  2984. $state = $this->input->post('state', true);
  2985. $review = $this->input->post('review', true);
  2986. $state = $this->input->post('state', true);
  2987. $express = $this->input->post('express', true);
  2988. $orderinfo = $this->input->post('orderinfo', true);
  2989. $user = $this->input->post('user', true);
  2990. $name = $this->input->post('name', true);
  2991. $waybill = $this->input->post('waybill', true);
  2992. $timetk = strtotime($timetk);
  2993. $timetj = strtotime($timetj);
  2994. $where = "(state=206 or state=210) and mergeid = 0";
  2995. if ($warehouse) {
  2996. $where .= " and state = '$warehouse'";
  2997. }
  2998. if ($timetk && $timetj) {
  2999. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3000. }
  3001. if ($shop) {
  3002. $where .= " and shop = '$shop'";
  3003. }
  3004. if ($source) {
  3005. $where .= " and source = '$source'";
  3006. }
  3007. if ($state) {
  3008. $where .= " and state = '$state'";
  3009. }
  3010. if ($review) {
  3011. $where .= " and review = '$review'";
  3012. }
  3013. if ($state) {
  3014. $where .= " and state = '$state'";
  3015. }
  3016. if ($express) {
  3017. $where .= " and express = '$express'";
  3018. }
  3019. if ($orderinfo) {
  3020. $where .= " and orderinfo = '$orderinfo'";
  3021. }
  3022. if ($user) {
  3023. $where .= " and user = '$user'";
  3024. }
  3025. if ($name) {
  3026. $where .= " and name = '$name'";
  3027. }
  3028. if ($waybill) {
  3029. $where .= " and waybill = '$waybill'";
  3030. }
  3031. //数据排序
  3032. $order_str = "id desc";
  3033. if (empty($page)) {
  3034. $start = 0;
  3035. $perpage = 1;
  3036. } else {
  3037. $start = ($page - 1) * $perpage;
  3038. }
  3039. //取得信息列表
  3040. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3041. //格式化数据
  3042. foreach ($info_list as $key => $value) {
  3043. $shop = $this->shop->read($value['shop']);
  3044. $info_list[$key]['shop'] = $shop['shopname'];
  3045. $warehouse = $this->warehouse->read($value['warehouse']);
  3046. $info_list[$key]['warehouse'] = $warehouse['title'];
  3047. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3048. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3049. if ($value['waybill'] == 0) {
  3050. $info_list[$key]['waybill'] = "";
  3051. }
  3052. $express = $this->express->read($value['express']);
  3053. $info_list[$key]['express'] = $express['title'];
  3054. $typeclass = $this->typeclass->read($value['state']);
  3055. $info_list[$key]['state'] = $typeclass['title'];
  3056. }
  3057. $total = $this->fullorder->find_count($where);
  3058. $pagenum = ceil($total / $perpage);
  3059. $over = $total - ($start + $perpage);
  3060. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3061. echo json_encode($rows);
  3062. exit;
  3063. }
  3064. $this->data['express'] = $this->express->find_all();
  3065. $this->_Template('whlabel_retreat', $this->data);
  3066. }
  3067. //退库标签浏览
  3068. public function _retreatlk()
  3069. {
  3070. $post = $this->input->post(NULL, TRUE);
  3071. if (isset($post['page'])) {
  3072. $page = $this->input->post('page', true);
  3073. $perpage = $this->input->post('perpage', true);
  3074. $timetk = $this->input->post('timetk', true);
  3075. $timetj = $this->input->post('timetj', true);
  3076. $sku = $this->input->post('sku', true);
  3077. $warehouse = $this->input->post('warehouse', true);
  3078. $purchase = $this->input->post('purchase', true);
  3079. $orderinfo = $this->input->post('orderinfo', true);
  3080. $waybill = $this->input->post('waybill', true);
  3081. $category = $this->input->post('category', true);
  3082. $size = $this->input->post('size', true);
  3083. $grade = $this->input->post('grade', true);
  3084. $color = $this->input->post('color', true);
  3085. $lowe = $this->input->post('lowe', true);
  3086. $state = $this->input->post('state', true);
  3087. $timetk = strtotime($timetk);
  3088. $timetj = strtotime($timetj);
  3089. $where = "state=2";
  3090. if ($timetk && $timetj) {
  3091. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3092. }
  3093. if ($sku) {
  3094. $where .= " and sku = '$sku'";
  3095. }
  3096. if ($warehouse) {
  3097. $where .= " and warehouse = '$warehouse'";
  3098. }
  3099. if ($purchase) {
  3100. $where .= " and purchase = '$purchase'";
  3101. }
  3102. if ($orderinfo) {
  3103. $where .= " and orderinfo = '$orderinfo'";
  3104. }
  3105. if ($waybill) {
  3106. $where .= " and waybill = '$waybill'";
  3107. }
  3108. if ($category) {
  3109. $where .= " and features like '%-$category-%'";
  3110. }
  3111. if ($size) {
  3112. $where .= " and features like '%-$size-%'";
  3113. }
  3114. if ($grade) {
  3115. $where .= " and features like '%-$grade-%'";
  3116. }
  3117. if ($color) {
  3118. $where .= " and features like '%-$color-%'";
  3119. }
  3120. if ($lowe) {
  3121. $where .= " and features like '%-$lowe-%'";
  3122. }
  3123. //数据排序
  3124. $order_str = "time desc";
  3125. if (empty($page)) {
  3126. $start = 0;
  3127. $perpage = 1;
  3128. } else {
  3129. $start = ($page - 1) * $perpage;
  3130. }
  3131. //取得信息列表
  3132. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3133. foreach ($info_list as $key => $value) {
  3134. $warehouse = $this->warehouse->read($value['warehouse']);
  3135. $info_list[$key]['warehouse'] = $warehouse['title'];
  3136. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3137. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3138. $purchase = $this->purchase->read($value['purchase']);
  3139. $info_list[$key]['purchase'] = $purchase['title'];
  3140. if ($value['outk'] != 0) {
  3141. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3142. } else {
  3143. $info_list[$key]['outk'] = "";
  3144. }
  3145. if ($value['retreat'] != 0) {
  3146. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3147. } else {
  3148. $info_list[$key]['retreat'] = "";
  3149. }
  3150. if ($value['orderinfo'] == 0) {
  3151. $info_list[$key]['orderinfo'] = "";
  3152. }
  3153. if ($value['waybill'] == 0) {
  3154. $info_list[$key]['waybill'] = "";
  3155. }
  3156. }
  3157. $total = $this->whlabel->find_count($where);
  3158. $pagenum = ceil($total / $perpage);
  3159. $over = $total - ($start + $perpage);
  3160. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3161. echo json_encode($rows);
  3162. exit;
  3163. }
  3164. $this->_Template('whlabel_retreatlk', $this->data);
  3165. }
  3166. //更换标签及浏览
  3167. public function _change()
  3168. {
  3169. $post = $this->input->post(NULL, TRUE);
  3170. if (isset($post['page'])) {
  3171. $page = $this->input->post('page', true);
  3172. $perpage = $this->input->post('perpage', true);
  3173. $timetk = $this->input->post('timetk', true);
  3174. $timetj = $this->input->post('timetj', true);
  3175. $label = $this->input->post('label', true);
  3176. $oldlabel = $this->input->post('oldlabel', true);
  3177. $timetk = strtotime($timetk);
  3178. $timetj = strtotime($timetj);
  3179. $where = "state=10 ";
  3180. if ($timetk && $timetj) {
  3181. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3182. }
  3183. if ($label) {
  3184. $where .= " and label = '$label'";
  3185. }
  3186. if ($oldlabel) {
  3187. $where .= " and oldlabel = '$oldlabel'";
  3188. }
  3189. //数据排序
  3190. $order_str = "time asc";
  3191. if (empty($page)) {
  3192. $start = 0;
  3193. $perpage = 1;
  3194. } else {
  3195. $start = ($page - 1) * $perpage;
  3196. }
  3197. //取得信息列表
  3198. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3199. foreach ($info_list as $key => $value) {
  3200. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3201. }
  3202. $total = $this->whlabel->find_count($where);
  3203. $pagenum = ceil($total / $perpage);
  3204. $over = $total - ($start + $perpage);
  3205. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3206. echo json_encode($rows);
  3207. exit;
  3208. }
  3209. $this->_Template('whlabel_change', $this->data);
  3210. }
  3211. //产品标签
  3212. public function _cpbqdc()
  3213. {
  3214. if (isset($_GET['excel'])) {
  3215. $where = "1=1";
  3216. //数据排序
  3217. $order_str = "id desc";
  3218. if (empty($page)) {
  3219. $start = 0;
  3220. $perpage = 1;
  3221. } else {
  3222. $start = ($page - 1) * $perpage;
  3223. }
  3224. $warehouse = $this->input->get('warehouse', true);
  3225. $state = $this->input->get('state', true);
  3226. $timetk = $this->input->get('timetkk', true);
  3227. $timetj = $this->input->get('timetjj', true);
  3228. $timetk = strtotime($timetk);
  3229. $timetj = strtotime($timetj);
  3230. if ($warehouse) {
  3231. $where .= " and warehouse = '$warehouse'";
  3232. }
  3233. if ($state || $state == 0) {
  3234. $where .= " and state = '$state'";
  3235. }
  3236. if ($timetk && $timetj) {
  3237. $where .= " and time > '$timetk' and time < '$timetj'";
  3238. }
  3239. //取得信息列表
  3240. $info_list = $this->whlabel->find_all($where, '*');
  3241. $rows = array();
  3242. $list = array();
  3243. foreach ($info_list as $key => $value) {
  3244. $rows[$value['time']] = $value; //所有数据sku
  3245. }
  3246. foreach ($rows as $value) {
  3247. $warehouse = $this->warehouse->read($value['warehouse']);
  3248. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3249. $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['text'], $s);
  3250. }
  3251. $title = "产品标签统计表";
  3252. $titlename = "<table border=1>
  3253. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3254. <tr align='center'>
  3255. <td>仓库</td>
  3256. <td>SKU</td>
  3257. <td>产品</td>
  3258. <td>入库时间</td>
  3259. <td>操作时间</td>
  3260. <td>备注</td>
  3261. <td>数量</td>
  3262. </tr>
  3263. </table>";
  3264. $filename = $title . ".xls";
  3265. $tail = "";
  3266. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3267. }
  3268. }
  3269. //进销存导出
  3270. public function _exceljxc()
  3271. {
  3272. $classid = $this->classid->sku();
  3273. $pm = $classid;
  3274. $typeclass = array();
  3275. $tc = $this->typeclass->find_all();
  3276. foreach ($tc as $v) {
  3277. $typeclass[$v['id']] = $v;
  3278. }
  3279. $prc = array();
  3280. $purchase = $this->purchase->find_all();
  3281. foreach ($purchase as $k => $v) {
  3282. $prc[$v['id']] = $v['title'];
  3283. }
  3284. if (isset($_GET['excel'])) {
  3285. $where = "sku != 'Preset'";
  3286. //数据排序
  3287. $order_str = "id desc";
  3288. if (empty($page)) {
  3289. $start = 0;
  3290. $perpage = 1;
  3291. } else {
  3292. $start = ($page - 1) * $perpage;
  3293. }
  3294. $category = $this->input->get('category', true);
  3295. $warehouse = $this->input->get('warehouse', true);
  3296. $excelid = $this->input->get('sid', true);
  3297. if ($category) {
  3298. $where .= " and features like '%-$category-%'";
  3299. }
  3300. if ($warehouse) {
  3301. $where .= " and warehouse = '$warehouse'";
  3302. }
  3303. $xzid = '';
  3304. if ($excelid) {
  3305. $excelid = explode(',', trim($excelid, ','));
  3306. foreach ($excelid as $key => $value) {
  3307. $xzid .= " id = " . $value . " or";
  3308. }
  3309. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3310. }
  3311. //取得信息列表
  3312. /**
  3313. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3314. $rows = array();$list = array();
  3315. foreach ($info_list as $key=>$value)
  3316. {
  3317. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3318. }
  3319. **/
  3320. $wt = array();
  3321. $whlabel_type = $this->whlabel_type->find_all();
  3322. foreach ($whlabel_type as $v) {
  3323. $wt[$v['id']] = $v['title'];
  3324. }
  3325. $wh = array();
  3326. $w = $this->warehouse->find_all('1=1', 'id,title');
  3327. foreach ($w as $v) {
  3328. $wh[$v['id']] = $v['title'];
  3329. }
  3330. $list = array();
  3331. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3332. foreach ($rows as $key => $value) {
  3333. if (isset($wt[$value['type']])) {
  3334. $rows[$key]['type'] = $wt[$value['type']];
  3335. } else {
  3336. $rows[$key]['type'] = '未设置';
  3337. }
  3338. $bm = '03';
  3339. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3340. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3341. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  3342. $details = array();
  3343. $cpid = array();
  3344. $cpbz = array();
  3345. $c = 0;
  3346. $g = 0;
  3347. $x = 0;
  3348. $t = 0;
  3349. $s = 0;
  3350. $q = 0;
  3351. foreach ($sd as $k => $v) {
  3352. if ($v['state'] == 0) {
  3353. $c++;
  3354. if ($v['cpid'] != 0) {
  3355. $cpid[$v['cpid']] = $v['cpid'];
  3356. }
  3357. if ($v['cpbz'] != '') {
  3358. $cpbz[$v['cpbz']] = $v['cpbz'];
  3359. }
  3360. }
  3361. if ($v['state'] != 9) {
  3362. $g++;
  3363. }
  3364. if ($v['state'] == 1) {
  3365. $x++;
  3366. }
  3367. if ($v['state'] == 2) {
  3368. $t++;
  3369. }
  3370. if ($v['state'] == 8) {
  3371. $s++;
  3372. }
  3373. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3374. $q++;
  3375. }
  3376. $details[$v['details']] = $v['details'];
  3377. }
  3378. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  3379. $rows[$key]['details'] = implode("、", $details);
  3380. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3381. $number = $value['number'];
  3382. $ftime = time() - 15 * 24 * 3600;
  3383. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3384. $rows[$key]['number'] = $g;
  3385. $rows[$key]['c'] = $c;
  3386. $rows[$key]['x'] = $x;
  3387. $rows[$key]['t'] = $t;
  3388. $rows[$key]['s'] = $s;
  3389. $rows[$key]['q'] = $q;
  3390. $rows[$key]['z'] = $z;
  3391. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3392. $features = explode('-', trim($features, '-'));
  3393. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3394. // $pm = $classid;
  3395. // $jm = $classid;
  3396. // foreach($features as $k=>$v)
  3397. // {
  3398. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3399. // {
  3400. // if($typeclass[$v]['bm'] != '')
  3401. // {
  3402. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3403. // }
  3404. // }
  3405. // if($v != 0)
  3406. // {
  3407. // if(!isset($typeclass[$v]))
  3408. // {
  3409. // continue;
  3410. // }
  3411. // if(isset($pm[$typeclass[$v]['classid']]))
  3412. // {
  3413. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3414. // {
  3415. // $tz = explode('|',$typeclass[$v]['zh']);
  3416. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3417. // }
  3418. // else
  3419. // {
  3420. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3421. // }
  3422. // }
  3423. // if(isset($jm[$typeclass[$v]['classid']]))
  3424. // {
  3425. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3426. // }
  3427. // }
  3428. // }
  3429. // $jm = array_filter($jm);
  3430. // $rows[$key]['bs'] = implode("-",$jm);
  3431. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3432. // $zh = implode(" ",$pm);
  3433. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3434. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3435. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3436. // $rows[$key]['features'] = $zh;
  3437. }
  3438. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3439. $final_list = [];
  3440. foreach ($list as $k => $v) {
  3441. if (empty($v['sku'])) {
  3442. continue;
  3443. }
  3444. $final_list[] = [
  3445. "warehouse" => $v["warehouse"],
  3446. "purchase" => $v["purchase"],
  3447. "details" => $v["details"],
  3448. "cpid" => $v["cpid"],
  3449. "dbcontent" => $v["dbcontent"],
  3450. "sku" => $v["sku"],
  3451. "cs" => $v["bm"],
  3452. "bs" => $v["jm"],
  3453. "title" => $v["title"],
  3454. "features" => $v["pm"],
  3455. "cpbz" => $v["cpbz"],
  3456. "sm" => $v["sm"],
  3457. "type" => $v["type"],
  3458. "number" => $v["number"],
  3459. "c" => $v["c"],
  3460. "x" => $v["x"],
  3461. "t" => $v["t"],
  3462. "s" => $v["s"],
  3463. "q" => $v["q"],
  3464. "z" => $v["z"],
  3465. "weight" => $v['weight'],
  3466. ];
  3467. }
  3468. $title = "总进销存统计表";
  3469. $titlename = "<table border=1>
  3470. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3471. <tr align='center'>
  3472. <td>仓库</td>
  3473. <td>供应商</td>
  3474. <td>位置</td>
  3475. <td>库存编码</td>
  3476. <td>类目</td>
  3477. <td>SKU</td>
  3478. <td>用友编码</td>
  3479. <td>用友料号</td>
  3480. <td>商品名称</td>
  3481. <td>商品中文</td>
  3482. <td>产品备注</td>
  3483. <td>说明</td>
  3484. <td>类型</td>
  3485. <td>入库总量</td>
  3486. <td>库存数量</td>
  3487. <td>销售数量</td>
  3488. <td>退货数量</td>
  3489. <td>删除数量</td>
  3490. <td>其它操作</td>
  3491. <td>占单数量</td>
  3492. <td>重量(g)</td>
  3493. </tr>
  3494. </table>";
  3495. $filename = $title . ".xls";
  3496. $tail = "";
  3497. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3498. }
  3499. }
  3500. //入库导出
  3501. public function _excelr()
  3502. {
  3503. if (isset($_GET['excel'])) {
  3504. $category = $this->input->get('category', true);
  3505. $size = $this->input->get('size', true);
  3506. $grade = $this->input->get('grade', true);
  3507. $color = $this->input->get('color', true);
  3508. $lowe = $this->input->get('lowe', true);
  3509. $sku = $this->input->get('sku', true);
  3510. $warehouse = $this->input->get('warehouse', true);
  3511. $purchase = $this->input->get('purchase', true);
  3512. $ktime = $this->input->get('ktime', true);
  3513. $jtime = $this->input->get('jtime', true);
  3514. $ktime = strtotime($ktime);
  3515. $jtime = strtotime($jtime);
  3516. $where = "1=1";
  3517. $gj = "";
  3518. $ck = "";
  3519. if ($category) {
  3520. $where .= " and features like '%-$category-%'";
  3521. }
  3522. if ($size) {
  3523. $where .= " and features like '%-$size-%'";
  3524. }
  3525. if ($grade) {
  3526. $where .= " and features like '%-$grade-%'";
  3527. }
  3528. if ($color) {
  3529. $where .= " and features like '%-$color-%'";
  3530. }
  3531. if ($lowe) {
  3532. $where .= " and features like '%-$lowe-%'";
  3533. }
  3534. if ($warehouse) {
  3535. $where .= " and warehouse = '$warehouse'";
  3536. }
  3537. if ($purchase) {
  3538. $where .= " and purchase = '$purchase'";
  3539. }
  3540. if ($sku) {
  3541. $where .= " and sku = '$sku'";
  3542. }
  3543. if ($ktime && $jtime) {
  3544. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3545. }
  3546. //数据排序
  3547. $order_str = "id desc";
  3548. if (empty($page)) {
  3549. $start = 0;
  3550. $perpage = 1;
  3551. } else {
  3552. $start = ($page - 1) * $perpage;
  3553. }
  3554. $list = array();
  3555. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3556. foreach ($rows as $value) {
  3557. $ck = $this->warehouse->read($value['warehouse']);
  3558. $warehouse = $ck['title'];
  3559. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3560. $retreatwarehouse = $tkck['title'];
  3561. $gy = $this->purchase->read($value['purchase']);
  3562. $purchase = $gy['title'];
  3563. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3564. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3565. }
  3566. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3567. $titlename = "<table border=1>
  3568. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3569. <tr align='center'>
  3570. <td>仓库</td>
  3571. <td>SKU</td>
  3572. <td>产品</td>
  3573. <td>时间</td>
  3574. <td>数量</td>
  3575. </tr>
  3576. </table>";
  3577. $filename = $title . ".xls";
  3578. $tail = "";
  3579. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3580. }
  3581. }
  3582. //出库、退库导出
  3583. public function _excelct()
  3584. {
  3585. $classid = $this->classid->sku();
  3586. $pm = $classid;
  3587. $typeclass = array();
  3588. $tc = $this->typeclass->find_all();
  3589. foreach ($tc as $v) {
  3590. $typeclass[$v['id']] = $v;
  3591. }
  3592. $prc = array();
  3593. $purchase = $this->purchase->find_all();
  3594. foreach ($purchase as $k => $v) {
  3595. $prc[$v['id']] = $v['title'];
  3596. }
  3597. if (isset($_GET['excel'])) {
  3598. $wh = array();
  3599. $w = $this->warehouse->find_all('1=1', 'id,title');
  3600. foreach ($w as $v) {
  3601. $wh[$v['id']] = $v['title'];
  3602. }
  3603. $type = $this->input->get('excel', true);
  3604. $category = $this->input->get('category', true);
  3605. $size = $this->input->get('size', true);
  3606. $grade = $this->input->get('grade', true);
  3607. $color = $this->input->get('color', true);
  3608. $lowe = $this->input->get('lowe', true);
  3609. $sku = $this->input->get('sku', true);
  3610. $warehouse = $this->input->get('warehouse', true);
  3611. $lacetype = $this->input->get('lacetype', true);
  3612. $lacecolor = $this->input->get('lacecolor', true);
  3613. $density = $this->input->get('density', true);
  3614. $haircap = $this->input->get('haircap', true);
  3615. $purchase = $this->input->get('purchase', true);
  3616. $title = $this->input->get('title', true);
  3617. $state = $this->input->get('state', true);
  3618. $sid = $this->input->get('sid', true);
  3619. $ktime = $this->input->get('ktime', true);
  3620. $jtime = $this->input->get('jtime', true);
  3621. $ktime = strtotime($ktime);
  3622. $jtime = strtotime($jtime);
  3623. $where = "1=1";
  3624. $gj = "";
  3625. $ck = "";
  3626. if ($category) {
  3627. $where .= " and features like '%-$category-%'";
  3628. }
  3629. if ($size) {
  3630. $where .= " and features like '%-$size-%'";
  3631. }
  3632. if ($grade) {
  3633. $where .= " and features like '%-$grade-%'";
  3634. }
  3635. if ($color) {
  3636. $where .= " and features like '%-$color-%'";
  3637. }
  3638. if ($lowe) {
  3639. $where .= " and features like '%-$lowe-%'";
  3640. }
  3641. if ($warehouse) {
  3642. $where .= " and warehouse = '$warehouse'";
  3643. }
  3644. if ($purchase) {
  3645. $where .= " and purchase = '$purchase'";
  3646. }
  3647. if ($state) {
  3648. $where .= " and state = '$state'";
  3649. }
  3650. if ($lacetype) {
  3651. $where .= " and features like '%-$lacetype-%'";
  3652. }
  3653. if ($lacecolor) {
  3654. $where .= " and features like '%-$lacecolor-%'";
  3655. }
  3656. if ($density) {
  3657. $where .= " and features like '%-$density-%'";
  3658. }
  3659. if ($haircap) {
  3660. $where .= " and features like '%-$haircap-%'";
  3661. }
  3662. if ($title) {
  3663. $title = trim($title, ' ');
  3664. $title = trim($title, ' ');
  3665. $where .= " and title like '%$title%'";
  3666. }
  3667. if ($sku) {
  3668. $sku = trim($sku, ' ');
  3669. $sku = trim($sku, ' ');
  3670. $where .= " and sku like '%$sku%'";
  3671. }
  3672. if ($ktime && $jtime) {
  3673. if ($type == 1) {
  3674. $tl = '出库';
  3675. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3676. } else if ($type == 2) {
  3677. $tl = '退库';
  3678. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3679. } else if ($type == 3) {
  3680. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3681. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3682. } else if ($type == 4) {
  3683. $tl = '出库+零售';
  3684. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3685. } else if ($type == 5) {
  3686. $tl = '零售';
  3687. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3688. }
  3689. }
  3690. $sidwhere = '';
  3691. if ($sid) {
  3692. $sd = "";
  3693. $s = explode(',', trim($sid, ','));
  3694. foreach ($s as $value) {
  3695. $sd .= " id = " . $value . " or";
  3696. }
  3697. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3698. }
  3699. //数据排序
  3700. $order_str = "time desc";
  3701. if (empty($page)) {
  3702. $start = 0;
  3703. $perpage = 1;
  3704. } else {
  3705. $start = ($page - 1) * $perpage;
  3706. }
  3707. //取得信息列表
  3708. if ($type != 3 && $type != 5) {
  3709. if ($type == 1 || $type == 4) {
  3710. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3711. foreach ($info_list as $key => $value) {
  3712. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3713. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3714. $warehouse = $this->warehouse->read($value['warehouse']);
  3715. $info_list[$key]['warehouse'] = $warehouse['title'];
  3716. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3717. $features = explode('-', trim($features, '-'));
  3718. $pm = $classid;
  3719. foreach ($features as $k => $v) {
  3720. if ($v != 0) {
  3721. if (!isset($typeclass[$v])) {
  3722. continue;
  3723. }
  3724. if (isset($pm[$typeclass[$v]['classid']])) {
  3725. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3726. $tz = explode('|', $typeclass[$v]['zh']);
  3727. $pm[$typeclass[$v]['classid']] = $tz[0];
  3728. } else {
  3729. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3730. }
  3731. }
  3732. }
  3733. }
  3734. $zh = implode(" ", $pm);
  3735. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3736. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3737. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3738. $info_list[$key]['features'] = $zh;
  3739. }
  3740. $final_list = [];
  3741. foreach($info_list as $k=>$v){
  3742. $number = "";
  3743. if(!empty($v['orderinfo'])){
  3744. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3745. if(!empty($tmp_info['number'])){
  3746. $number = $tmp_info['number'];
  3747. }
  3748. }
  3749. $final_list[] = [
  3750. 'warehouse'=>$v['warehouse'],
  3751. 'purchase'=>$v['purchase'],
  3752. 'sku'=>$v['sku'],
  3753. 'title'=>$v['title'],
  3754. 'features'=>$v['features'],
  3755. 'label'=>$v['label'],
  3756. 'orderinfo'=>$v['orderinfo'],
  3757. 'number'=>$number,
  3758. 'waybill'=>$v['waybill'],
  3759. 'outtk'=>$v['outtk'],
  3760. ];
  3761. }
  3762. } else {
  3763. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3764. foreach ($info_list as $key => $value) {
  3765. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3766. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3767. $warehouse = $this->warehouse->read($value['warehouse']);
  3768. $info_list[$key]['warehouse'] = $warehouse['title'];
  3769. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3770. $features = explode('-', trim($features, '-'));
  3771. $pm = $classid;
  3772. foreach ($features as $k => $v) {
  3773. if ($v != 0) {
  3774. if (!isset($typeclass[$v])) {
  3775. continue;
  3776. }
  3777. if (isset($pm[$typeclass[$v]['classid']])) {
  3778. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3779. $tz = explode('|', $typeclass[$v]['zh']);
  3780. $pm[$typeclass[$v]['classid']] = $tz[0];
  3781. } else {
  3782. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3783. }
  3784. }
  3785. }
  3786. }
  3787. $zh = implode(" ", $pm);
  3788. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3789. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3790. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3791. $info_list[$key]['features'] = $zh;
  3792. }
  3793. $final_list = [];
  3794. foreach($info_list as $k=>$v){
  3795. $number = "";
  3796. if(!empty($v['orderinfo'])){
  3797. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3798. if(!empty($tmp_info['number'])){
  3799. $number = $tmp_info['number'];
  3800. }
  3801. }
  3802. $final_list[] = [
  3803. 'warehouse'=>$v['warehouse'],
  3804. 'purchase'=>$v['purchase'],
  3805. 'sku'=>$v['sku'],
  3806. 'title'=>$v['title'],
  3807. 'features'=>$v['features'],
  3808. 'label'=>$v['label'],
  3809. 'orderinfo'=>$v['orderinfo'],
  3810. 'number'=>$number,
  3811. 'waybill'=>$v['waybill'],
  3812. 'retreat'=>$v['retreat'],
  3813. ];
  3814. }
  3815. }
  3816. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3817. $titlename = "<table border=1>
  3818. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3819. <tr align='center'>
  3820. <td>仓库</td>
  3821. <td>供应商</td>
  3822. <td>SKU</td>
  3823. <td>商品名称</td>
  3824. <td>商品中文</td>
  3825. <td>标签</td>
  3826. <td>订单号</td>
  3827. <td>订单编码</td>
  3828. <td>运单号</td>
  3829. <td>" . $tl . "时间(中国时间)</td>
  3830. </tr>
  3831. </table>";
  3832. $filename = $title . ".xls";
  3833. $tail = "";
  3834. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3835. } else if ($type == 5) {
  3836. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3837. foreach ($info_list as $key => $value) {
  3838. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3839. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3840. $warehouse = $this->warehouse->read($value['warehouse']);
  3841. $info_list[$key]['warehouse'] = $warehouse['title'];
  3842. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3843. $features = explode('-', trim($features, '-'));
  3844. $pm = $classid;
  3845. foreach ($features as $k => $v) {
  3846. if ($v != 0) {
  3847. if (!isset($typeclass[$v])) {
  3848. continue;
  3849. }
  3850. if (isset($pm[$typeclass[$v]['classid']])) {
  3851. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3852. $tz = explode('|', $typeclass[$v]['zh']);
  3853. $pm[$typeclass[$v]['classid']] = $tz[0];
  3854. } else {
  3855. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3856. }
  3857. }
  3858. }
  3859. }
  3860. $zh = implode(" ", $pm);
  3861. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3862. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3863. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3864. $info_list[$key]['features'] = $zh;
  3865. }
  3866. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3867. $titlename = "<table border=1>
  3868. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3869. <tr align='center'>
  3870. <td>仓库</td>
  3871. <td>供应商</td>
  3872. <td>SKU</td>
  3873. <td>商品名称</td>
  3874. <td>商品中文</td>
  3875. <td>标签</td>
  3876. <td>" . $tl . "时间(中国时间)</td>
  3877. </tr>
  3878. </table>";
  3879. $filename = $title . ".xls";
  3880. $tail = "";
  3881. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3882. } else {
  3883. /**
  3884. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3885. $rows = array();$list = array();
  3886. foreach ($info_list as $key=>$value)
  3887. {
  3888. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3889. }
  3890. **/
  3891. $wh = array();
  3892. $w = $this->warehouse->find_all('1=1', 'id,title');
  3893. foreach ($w as $v) {
  3894. $wh[$v['id']] = $v['title'];
  3895. }
  3896. $wt = array();
  3897. $whlabel_type = $this->whlabel_type->find_all();
  3898. foreach ($whlabel_type as $v) {
  3899. $wt[$v['id']] = $v['title'];
  3900. }
  3901. $classid = $this->classid->sku();
  3902. $list = array();
  3903. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3904. foreach ($rows as $key => $value) {
  3905. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3906. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3907. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state,outk,retreat');
  3908. $details = array();
  3909. $cpid = array();
  3910. $cpbz = array();
  3911. $c = 0;
  3912. $g = 0;
  3913. $x = 0;
  3914. $t = 0;
  3915. $s = 0;
  3916. $q = 0;
  3917. foreach ($sd as $k => $v) {
  3918. if ($v['state'] == 0) {
  3919. $c++;
  3920. }
  3921. if ($v['state'] != 9) {
  3922. $g++;
  3923. }
  3924. if ($v['outk'] > 1) {
  3925. $x++;
  3926. }
  3927. if ($v['retreat'] > 0) {
  3928. $t++;
  3929. }
  3930. if ($v['state'] == 8) {
  3931. $s++;
  3932. }
  3933. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3934. $q++;
  3935. }
  3936. $details[$v['details']] = $v['details'];
  3937. if ($v['cpid'] != 0) {
  3938. $cpid[$v['cpid']] = $v['cpid'];
  3939. }
  3940. if ($v['cpbz'] != '') {
  3941. $cpbz[$v['cpbz']] = $v['cpbz'];
  3942. }
  3943. }
  3944. if (isset($wt[$value['type']])) {
  3945. $rows[$key]['type'] = $wt[$value['type']];
  3946. } else {
  3947. $rows[$key]['type'] = '未设置';
  3948. }
  3949. $rows[$key]['details'] = implode("、", $details);
  3950. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3951. $ftime = time() - 15 * 24 * 3600;
  3952. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3953. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3954. $rows[$key]['g'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state != 9' . $gj);
  3955. $rows[$key]['c'] = $c;
  3956. $rows[$key]['x'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state = 1' . $ck);
  3957. $rows[$key]['t'] = $t;
  3958. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  3959. $rows[$key]['z'] = $z;
  3960. // $jm = $classid;
  3961. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3962. $features = explode('-', trim($features, '-'));
  3963. // $pm = $classid;
  3964. // foreach ($features as $k => $v) {
  3965. // if ($v != 0) {
  3966. // if (!isset($typeclass[$v])) {
  3967. // continue;
  3968. // }
  3969. // if (isset($pm[$typeclass[$v]['classid']])) {
  3970. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3971. // $tz = explode('|', $typeclass[$v]['zh']);
  3972. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3973. // } else {
  3974. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3975. // }
  3976. // if (isset($jm[$typeclass[$v]['classid']])) {
  3977. // if ($typeclass[$v]['jm']) {
  3978. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3979. // }
  3980. // }
  3981. // }
  3982. // }
  3983. // }
  3984. // $zh = implode(" ", $pm);
  3985. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3986. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3987. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3988. // $rows[$key]['features'] = $zh;
  3989. // $jm = array_filter($jm); //去除空值
  3990. // $jm = implode("-", $jm);
  3991. // $rows[$key]['jm'] = $jm;
  3992. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3993. }
  3994. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3995. // echo "<pre>";
  3996. // print_r($tmp_list);
  3997. // die;
  3998. $final_list =[];
  3999. foreach($tmp_list as $k=>$v){
  4000. $final_list[] = [
  4001. "warehouse"=>$v['warehouse'],
  4002. "purchase"=>$v['purchase'],
  4003. "details"=>$v['details'],
  4004. "cpid"=>$v['cpid'],
  4005. "sku"=>$v['sku'],
  4006. "title"=>$v['title'],
  4007. "features"=>$v['pm'],
  4008. "cpbz"=>$v['cpbz'],
  4009. "sm"=>$v['sm'],
  4010. "type"=>$v['type'],
  4011. "g"=>$v["g"],
  4012. "c"=>$v["c"],
  4013. "x"=>$v["x"],
  4014. "t"=>$v["t"],
  4015. "z"=>$v["z"],
  4016. "jm"=>$v["jm"],
  4017. "weight"=>$v["weight"],
  4018. "asd"=>$v["asd"],
  4019. ];
  4020. }
  4021. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4022. $titlename = "<table border=1>
  4023. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4024. <tr align='center'>
  4025. <td>仓库</td>
  4026. <td>供应商</td>
  4027. <td>位置</td>
  4028. <td>库存编码</td>
  4029. <td>SKU</td>
  4030. <td>商品名称</td>
  4031. <td>商品中文</td>
  4032. <td>产品备注</td>
  4033. <td>说明</td>
  4034. <td>类型</td>
  4035. <td>入库总量</td>
  4036. <td>库存数量</td>
  4037. <td>销售数量</td>
  4038. <td>退货数量</td>
  4039. <td>占单数量</td>
  4040. <td>料号</td>
  4041. <td>重量</td>
  4042. <td>类目</td>
  4043. </tr>
  4044. </table>";
  4045. $filename = $title . ".xls";
  4046. $tail = "";
  4047. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4048. }
  4049. }
  4050. }
  4051. //出库+入库数据整合
  4052. public function _excelcr()
  4053. {
  4054. if (isset($_GET['excel'])) {
  4055. $type = $this->input->get('excel', true);
  4056. $category = $this->input->get('category', true);
  4057. $size = $this->input->get('size', true);
  4058. $grade = $this->input->get('grade', true);
  4059. $color = $this->input->get('color', true);
  4060. $lowe = $this->input->get('lowe', true);
  4061. $sku = $this->input->get('sku', true);
  4062. $warehouse = $this->input->get('warehouse', true);
  4063. $purchase = $this->input->get('purchase', true);
  4064. $state = $this->input->get('state', true);
  4065. $sid = $this->input->get('sid', true);
  4066. $ktime = $this->input->get('ktime', true);
  4067. $jtime = $this->input->get('jtime', true);
  4068. $ktime = strtotime($ktime);
  4069. $jtime = strtotime($jtime);
  4070. $where = "1=1";
  4071. $gj = "";
  4072. $ck = "";
  4073. if ($category) {
  4074. $where .= " and features like '%-$category-%'";
  4075. }
  4076. if ($size) {
  4077. $where .= " and features like '%-$size-%'";
  4078. }
  4079. if ($grade) {
  4080. $where .= " and features like '%-$grade-%'";
  4081. }
  4082. if ($color) {
  4083. $where .= " and features like '%-$color-%'";
  4084. }
  4085. if ($lowe) {
  4086. $where .= " and features like '%-$lowe-%'";
  4087. }
  4088. if ($warehouse) {
  4089. $where .= " and warehouse = '$warehouse'";
  4090. }
  4091. if ($purchase) {
  4092. $where .= " and purchase = '$purchase'";
  4093. }
  4094. if ($state) {
  4095. $where .= " and state = '$state'";
  4096. }
  4097. if ($sku) {
  4098. $where .= " and sku like '%$sku%'";
  4099. }
  4100. if ($ktime && $jtime) {
  4101. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4102. }
  4103. $sidwhere = '';
  4104. if ($sid) {
  4105. $sd = "";
  4106. $s = explode(',', trim($sid, ','));
  4107. foreach ($s as $value) {
  4108. $sd .= " id = " . $value . " or";
  4109. }
  4110. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4111. }
  4112. //取得信息列表
  4113. $timeread = $ktime;
  4114. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4115. $timelist = array();
  4116. for ($i = 0; $i < $timenum; $i++) {
  4117. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4118. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4119. }
  4120. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4121. //echo "<pre>";
  4122. //print_r($info_list);
  4123. //exit();
  4124. $rows = array();
  4125. $list = array();
  4126. foreach ($info_list as $key => $value) {
  4127. $thistime = $timelist;
  4128. if (isset($rows[strtolower($value['sku'])])) {
  4129. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4130. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4131. }
  4132. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4133. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4134. }
  4135. } else {
  4136. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4137. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4138. }
  4139. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4140. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4141. }
  4142. $rows[strtolower($value['sku'])] = $thistime;
  4143. }
  4144. }
  4145. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4146. <head>
  4147. <!--[if gte mso 9]><xml>
  4148. <x:ExcelWorkbook>
  4149. <x:ExcelWorksheets>
  4150. <x:ExcelWorksheet>
  4151. <x:Name>EXCEL</x:Name>
  4152. <x:WorksheetOptions>
  4153. <x:Print>
  4154. <x:ValidPrinterInfo />
  4155. </x:Print>
  4156. </x:WorksheetOptions>
  4157. </x:ExcelWorksheet>
  4158. </x:ExcelWorksheets>
  4159. </x:ExcelWorkbook>
  4160. </xml>
  4161. <![endif]-->
  4162. </head><body>";
  4163. $str .= "<table border=1><tr><td>SKU</td>";
  4164. foreach ($timelist as $k => $v) {
  4165. $str .= "<td>" . $k . "出库</td>";
  4166. $str .= "<td>" . $k . "入库</td>";
  4167. }
  4168. $str .= "</tr></table>";
  4169. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4170. foreach ($rows as $key => $val) {
  4171. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4172. foreach ($val as $k => $v) {
  4173. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4174. if ($val[$k]['r'] > 0) {
  4175. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4176. } else {
  4177. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4178. }
  4179. }
  4180. $str .= "</tr>";
  4181. }
  4182. $str .= "</table>";
  4183. $str .= "</body></html>";
  4184. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4185. header("Content-type: application/octet-stream");
  4186. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4187. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4188. header("Pragma: no-cache");
  4189. header("Expires: 0");
  4190. exit($str);
  4191. }
  4192. }
  4193. //数量调整模板导出
  4194. public function _presetout()
  4195. {
  4196. if (isset($_GET['excel'])) {
  4197. $where = "sku != 'Preset' and purchase != 0";
  4198. //数据排序
  4199. $order_str = "id desc";
  4200. if (empty($page)) {
  4201. $start = 0;
  4202. $perpage = 1;
  4203. } else {
  4204. $start = ($page - 1) * $perpage;
  4205. }
  4206. //取得信息列表
  4207. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4208. $rows = array();
  4209. $list = array();
  4210. foreach ($info_list as $value) {
  4211. $warehouse = $this->warehouse->read($value['warehouse']);
  4212. $number = $value['number'];
  4213. $ftime = time() - 15 * 24 * 3600;
  4214. $purchase = $this->purchase->read($value['purchase']);
  4215. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4216. }
  4217. $title = "库存模板";
  4218. $titlename = "<table border=1>
  4219. <tr align='center'>
  4220. <td>仓库</td>
  4221. <td>供应商编码</td>
  4222. <td>SKU</td>
  4223. <td>增减数量(正数或负数)</td>
  4224. <td>增减备注</td>
  4225. <td>扣减方式:0减少库存1删除库存</td>
  4226. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4227. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4228. </tr>
  4229. </table>";
  4230. $filename = $title . ".xls";
  4231. $tail = "";
  4232. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4233. }
  4234. }
  4235. //数量调整模板导入
  4236. public function _presetedit()
  4237. {
  4238. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4239. $config['upload_path'] = '.' . $dir;
  4240. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4241. $config['allowed_types'] = 'xls|xlsx|csv';
  4242. $config['max_size'] = 10240;
  4243. $this->load->library('upload', $config);
  4244. $this->upload->initialize($config);
  4245. if ($this->upload->do_upload('userfile')) {
  4246. $full_path = $dir . $this->upload->data('file_name');
  4247. $fileName = '.' . $full_path;
  4248. if (!file_exists($fileName)) {
  4249. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4250. exit;
  4251. } else {
  4252. require_once "./data/excel/PHPExcel/IOFactory.php";
  4253. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4254. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4255. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4256. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4257. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4258. ++$column; //如果列数大于26行
  4259. $list = array();
  4260. for ($i = 2; $i <= $row; $i++) // 行数循环
  4261. {
  4262. $data = array();
  4263. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4264. {
  4265. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4266. }
  4267. $list[] = $data;
  4268. }
  4269. }
  4270. $i = 0;
  4271. $j = 0;
  4272. $ed = array();
  4273. foreach ($list as $key => $value) {
  4274. $time = time();
  4275. if ($value['0'] == "") {
  4276. continue;
  4277. }
  4278. $warehouse = $this->warehouse->get_title($value['0']);
  4279. $purchase = $this->purchase->get_bm($value['1']);
  4280. $sku = $value['2'];
  4281. $num = $value['3']; //调整数量
  4282. $text = $value['4']; //扣减说明
  4283. $type = $value['5']; //调整方式0扣减1删除
  4284. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4285. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4286. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4287. if (!$purchase) //如果没有这个SKU
  4288. {
  4289. $ed[] = array($purchase . '-不存在此供应商编码');
  4290. $j++;
  4291. continue;
  4292. }
  4293. if (!$d) //如果没有这个SKU
  4294. {
  4295. $ed[] = array($sku . '-库存中不存在此SKU');
  4296. $j++;
  4297. continue;
  4298. }
  4299. if (!isset($warehouse['id'])) {
  4300. $ed[] = array($sku . '-仓库名错误!');
  4301. $j++;
  4302. continue;
  4303. }
  4304. if ($type != '0' && $type != '1') {
  4305. $ed[] = array($sku . '-扣减方式填写错误!');
  4306. $j++;
  4307. continue;
  4308. }
  4309. if ($num < 0) //扣减库存
  4310. {
  4311. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4312. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4313. $j++;
  4314. continue;
  4315. }
  4316. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4317. if (count($data) < abs($num)) {
  4318. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4319. $j++;
  4320. continue;
  4321. }
  4322. if ($type == 0) //如果扣减方式为 扣减库存
  4323. {
  4324. for ($i = 0; $i < abs($num); $i++) {
  4325. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4326. }
  4327. } else if ($type == 1) {
  4328. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4329. if (count($zt) > 0) {
  4330. $ed[] = array($sku . '-有在途库存无法删除!');
  4331. $j++;
  4332. continue;
  4333. }
  4334. for ($i = 0; $i < abs($num); $i++) {
  4335. $this->whlabel->remove($data[$i]['id']);
  4336. }
  4337. }
  4338. } else if ($num > 0) //增加库存
  4339. {
  4340. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4341. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4342. $j++;
  4343. continue;
  4344. }
  4345. $post['sku'] = $d['sku'];
  4346. $post['shop'] = $d['shop'];
  4347. $post['warehouse'] = $warehouse['id'];
  4348. $post['purchase'] = $purchase['id'];
  4349. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4350. $post['state'] = 0;
  4351. $post['title'] = $d['title'];
  4352. $post['number'] = $d['number'];
  4353. $post['features'] = $d['features'];
  4354. $post['enter'] = $time;
  4355. $post['time'] = $time; //操作时间
  4356. $post['rktype'] = $rktype;
  4357. for ($i = 0; $i < $num; $i++) {
  4358. $post['label'] = time() . rand(100, 999) . $i;
  4359. $this->whlabel->insert($post);
  4360. }
  4361. }
  4362. sleep(1); //防止入库时间一样,需要延迟1秒
  4363. }
  4364. if ($j > 0) {
  4365. $tt = date('Ymd', time());
  4366. $title = '库存导入错误信息-' . $tt;
  4367. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4368. $tail = "\n";
  4369. $filename = $title . ".xls";
  4370. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4371. $dir = '/data/excel/' . $time . '/';
  4372. $file_name = 'error_' . $time . rand(1000, 9999);
  4373. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4374. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4375. fwrite($myfile, $ecl);
  4376. fclose($myfile);
  4377. $error = $dir . $file_name . '.xls';
  4378. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4379. exit;
  4380. } else {
  4381. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4382. exit;
  4383. }
  4384. }
  4385. }
  4386. //笛卡儿积
  4387. function cp($ps, $sets, $list)
  4388. {
  4389. $result = array();
  4390. $j = 0;
  4391. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4392. if ($i == 0) {
  4393. $result = $sets[$i];
  4394. }
  4395. $tmp = array();
  4396. foreach ($result as $res) {
  4397. foreach ($sets[$i + 1] as $set) {
  4398. $tmp[] = $res . ',' . $set;
  4399. }
  4400. }
  4401. $result = $tmp;
  4402. }
  4403. $this->db->trans_begin();
  4404. foreach ($result as $v) {
  4405. $post = array();
  4406. $title = "";
  4407. $num = "";
  4408. $data = explode(',', $v);
  4409. for ($i = 0; $i < count($list); $i++) {
  4410. $post[$list[$i]] = $data[$i];
  4411. $typeclass = $this->typeclass->read($data[$i]);
  4412. $title = $title . $typeclass['title'] . " ";
  4413. if ($data[$i] != 0) {
  4414. $num .= $data[$i]; //所有数据ID拼接
  4415. }
  4416. }
  4417. foreach ($ps as $kp => $vp) {
  4418. $post[$kp] = $vp;
  4419. }
  4420. $post['number'] = $num;
  4421. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4422. if ($info_list) {
  4423. $j++;
  4424. } else {
  4425. $skunum = $this->whlabel->find_count();
  4426. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4427. $post['title'] = rtrim($title, ' ');
  4428. $this->whlabel->insert($post);
  4429. }
  4430. }
  4431. if ($this->db->trans_status() === FALSE) {
  4432. $this->db->trans_commit();
  4433. return NULL;
  4434. } else {
  4435. $this->db->trans_commit();
  4436. return $j;
  4437. }
  4438. }
  4439. public function _kj($arg_array)
  4440. {
  4441. if (isset($_POST['sku'])) {
  4442. $time = time();
  4443. $sku = $this->input->post('sku', true);
  4444. $warehouse = $this->input->post('warehouse', true);
  4445. $num = $this->input->post('num', true);
  4446. $text = $this->input->post('text', true);
  4447. $purchase = $this->input->post('purchase', true);
  4448. $cktype = $this->input->post('cktype', true);
  4449. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4450. if ($cktype != 1 && $text == '') {
  4451. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4452. exit;
  4453. }
  4454. if ($num > count($order)) {
  4455. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4456. exit;
  4457. } else {
  4458. for ($i = 0; $i < $num; $i++) {
  4459. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4460. }
  4461. }
  4462. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4463. exit;
  4464. }
  4465. $uid = $this->whlabel->read($arg_array[0]);
  4466. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4467. $this->data['data'] = $uid;
  4468. $this->_Template('whlabel_kj', $this->data);
  4469. }
  4470. public function _summary($arg_array)
  4471. {
  4472. $prc = array();
  4473. $purchase = $this->purchase->find_all();
  4474. foreach ($purchase as $k => $v) {
  4475. $prc[$v['id']] = $v['title'];
  4476. }
  4477. if (isset($_GET['excel'])) {
  4478. $ktime = $this->input->get('ktime', true);
  4479. $jtime = $this->input->get('jtime', true);
  4480. $ktime = strtotime($ktime);
  4481. $jtime = strtotime($jtime);
  4482. $where = "1=1";
  4483. if ($ktime && $jtime) {
  4484. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4485. }
  4486. //数据排序
  4487. $order_str = "time desc";
  4488. if (empty($page)) {
  4489. $start = 0;
  4490. $perpage = 1;
  4491. } else {
  4492. $start = ($page - 1) * $perpage;
  4493. }
  4494. //取得信息列表
  4495. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4496. foreach ($info_list as $key => $value) {
  4497. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4498. $warehouse = $this->warehouse->read($value['warehouse']);
  4499. $info_list[$key]['warehouse'] = $warehouse['title'];
  4500. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4501. $details = array();
  4502. $cpid = array();
  4503. foreach ($x as $k => $v) {
  4504. if ($v['details'] != '') {
  4505. $details[$v['details']] = $v['details'];
  4506. }
  4507. if ($v['cpid'] != 0) {
  4508. $cpid[$v['cpid']] = $v['cpid'];
  4509. }
  4510. }
  4511. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4512. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4513. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4514. $info_list[$key]['s'] = $s;
  4515. $info_list[$key]['x'] = count($x);
  4516. }
  4517. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4518. $titlename = "<table border=1>
  4519. <tr align='center'>
  4520. <td>仓库</td>
  4521. <td>供应商</td>
  4522. <td>出库位置</td>
  4523. <td>出库编码</td>
  4524. <td>SKU</td>
  4525. <td>产品名</td>
  4526. <td>总剩余库存</td>
  4527. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4528. </tr>
  4529. </table>";
  4530. $filename = $title . ".xls";
  4531. $tail = "";
  4532. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4533. }
  4534. }
  4535. //usps发货清单
  4536. public function _manifest()
  4537. {
  4538. if (isset($_POST['manifest'])) {
  4539. $wltext = $this->input->post('wltext', true);
  4540. $time = time() - 16 * 3600;
  4541. $ptime = strtotime(date('Y-m-d', $time));
  4542. $waybill = array();
  4543. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4544. foreach ($fullorder as $v) {
  4545. $waybill[$v['waybill']] = $v['waybill'];
  4546. }
  4547. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4548. foreach ($fullordersmt as $v) {
  4549. $waybill[$v['waybill']] = $v['waybill'];
  4550. }
  4551. $wltext = explode(';', $wltext);
  4552. foreach ($wltext as $v) {
  4553. if (isset($waybill[$v])) {
  4554. unset($waybill[$v]);
  4555. }
  4556. }
  4557. $data = $this->usps->get_manifest($waybill);
  4558. if (isset($data['Description'])) {
  4559. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4560. exit;
  4561. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4562. $bctime = date('Ymd', time());
  4563. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4564. echo json_encode(array('msg' => $pdf, 'success' => true));
  4565. exit;
  4566. } else {
  4567. echo json_encode(array('msg' => $data, 'success' => false));
  4568. exit;
  4569. }
  4570. }
  4571. }
  4572. public function _pdf($pdf, $title, $bctime)
  4573. {
  4574. $pdf_path = './data/pdf/' . $bctime . '/';
  4575. $file_base64 = $pdf;
  4576. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4577. $file_base64 = base64_decode($file_base64);
  4578. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4579. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4580. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4581. }
  4582. /**
  4583. *
  4584. *
  4585. *
  4586. 进销存占单异常索引
  4587. *
  4588. *
  4589. *
  4590. **/
  4591. public function _abnormal()
  4592. {
  4593. $post = $this->input->post(NULL, TRUE);
  4594. if (isset($post['page'])) {
  4595. $page = $this->input->post('page', true);
  4596. $perpage = $this->input->post('perpage', true);
  4597. $sku = $this->input->post('sku', true);
  4598. $where = "1=1";
  4599. //数据排序
  4600. $order_str = "id desc";
  4601. if (empty($page)) {
  4602. $start = 0;
  4603. $perpage = 1;
  4604. } else {
  4605. $start = ($page - 1) * $perpage;
  4606. }
  4607. //取得信息列表
  4608. $info_list = $this->whlabel->find_all($where, '*');
  4609. $rows = array();
  4610. $list = array();
  4611. foreach ($info_list as $key => $value) {
  4612. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4613. }
  4614. foreach ($rows as $value) {
  4615. $warehouse = $this->warehouse->read($value['warehouse']);
  4616. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4617. $number = $value['number'];
  4618. $ftime = time() - 15 * 24 * 3600;
  4619. if ($value['shop'] != '') {
  4620. $shop = $value['shop'];
  4621. $orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4622. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4623. $order = array_merge($orderdlz, $ordersmt);
  4624. $od = 0;
  4625. $a = '';
  4626. $orid = '';
  4627. foreach ($order as $v) {
  4628. $or = explode('|', ltrim($v['whlabel'], '|'));
  4629. for ($i = 0; $i < count($or); $i++) {
  4630. $orod = explode('-', $or[$i]);
  4631. if ($orod[0] == $number) {
  4632. $od += $orod[1];
  4633. }
  4634. }
  4635. $orid .= $v['number'] . '-';
  4636. }
  4637. } else {
  4638. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4639. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4640. $order = array_merge($orderdlz, $ordersmt);
  4641. $od = 0;
  4642. $a = '';
  4643. $orid = '';
  4644. $qt = array();
  4645. foreach ($order as $v) {
  4646. $or = explode('|', ltrim($v['whlabel'], '|'));
  4647. for ($i = 0; $i < count($or); $i++) {
  4648. $orod = explode('-', $or[$i]);
  4649. if ($orod[0] == $number) {
  4650. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4651. if ($czzs > 0) {
  4652. if (isset($qt[$v['shop']])) {
  4653. if ($qt[$v['shop']] < $orod[1]) {
  4654. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4655. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4656. } else {
  4657. $qt[$v['shop']] -= $orod[1];
  4658. }
  4659. } else {
  4660. $qt[$v['shop']] = $czzs;
  4661. }
  4662. } else {
  4663. $od += $orod[1];
  4664. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4665. }
  4666. }
  4667. }
  4668. }
  4669. }
  4670. $z = $od . '(' . $orid . ')'; //查看订单号
  4671. //$z = $od;
  4672. if ($od > $c) {
  4673. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4674. }
  4675. }
  4676. $listdata = array_slice($list, $start, $perpage);
  4677. $total = count($list);
  4678. $pagenum = ceil($total / $perpage);
  4679. $over = $total - ($start + $perpage);
  4680. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4681. echo json_encode($rows);
  4682. exit;
  4683. }
  4684. $this->_Template('whlabel_abnormal', $this->data);
  4685. }
  4686. /**
  4687. *
  4688. *
  4689. *
  4690. 进销存占单异常索引
  4691. *
  4692. *
  4693. *
  4694. **/
  4695. public function _error()
  4696. {
  4697. $post = $this->input->post(NULL, TRUE);
  4698. if (isset($post['page'])) {
  4699. $page = $this->input->post('page', true);
  4700. $perpage = $this->input->post('perpage', true);
  4701. $sku = $this->input->post('sku', true);
  4702. $warehouse = $this->input->post('warehouse', true);
  4703. $ktime = $this->input->post('ktime', true);
  4704. $jtime = $this->input->post('jtime', true);
  4705. $ktime = strtotime($ktime);
  4706. $jtime = strtotime($jtime);
  4707. $where = "sku != 'Preset'";
  4708. $gj = '';
  4709. if ($sku) {
  4710. $where .= " and sku like '%$sku%'";
  4711. } else {
  4712. if ($ktime && $jtime) {
  4713. $gj = " and time > '$ktime' and time < '$jtime'";
  4714. }
  4715. }
  4716. if ($warehouse) {
  4717. $where .= " and warehouse = '$warehouse'";
  4718. }
  4719. //数据排序
  4720. $order_str = "id desc";
  4721. if (empty($page)) {
  4722. $start = 0;
  4723. $perpage = 1;
  4724. } else {
  4725. $start = ($page - 1) * $perpage;
  4726. }
  4727. //取得信息列表
  4728. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4729. $rows = array();
  4730. $list = array();
  4731. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4732. // foreach ($info_list as $value)
  4733. // {
  4734. // $warehouse = $this->warehouse->read($value['warehouse']);
  4735. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4736. // $number = $value['number'];$ftime = time()-15*24*3600;
  4737. // if($c < 1)
  4738. // {
  4739. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4740. // }
  4741. // }
  4742. $warehouse_list = $this->warehouse->find_all();
  4743. $warehouse_list = array_column($warehouse_list, null, 'id');
  4744. foreach ($info_list as $value) {
  4745. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4746. 'title' => "",
  4747. ];
  4748. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4749. $number = $value['number'];
  4750. $ftime = time() - 15 * 24 * 3600;
  4751. if ($c < 1) {
  4752. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4753. }
  4754. }
  4755. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4756. // $query = $this->db->query($sql);
  4757. // $info_list = $query->result_array();
  4758. // $sql_two = "select title,id from crowd_warehouse";
  4759. // $query_two = $this->db->query($sql_two);
  4760. // $warehouse_list = $query_two->result_array();
  4761. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4762. // foreach ($info_list as $value)
  4763. // {
  4764. // if(isset($warehouse_arr[$value['warehouse']])){
  4765. // $warehouse = $warehouse_arr[$value['warehouse']];
  4766. // }else{
  4767. // $warehouse = [
  4768. // 'id'=>0,
  4769. // 'title'=>"异常",
  4770. // ];
  4771. // }
  4772. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4773. // $number = $value['number'];$ftime = time()-15*24*3600;
  4774. // if($c < 1)
  4775. // {
  4776. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4777. // }
  4778. // }
  4779. $listdata = array_slice($list, $start, $perpage);
  4780. $total = count($list);
  4781. $pagenum = ceil($total / $perpage);
  4782. $over = $total - ($start + $perpage);
  4783. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4784. echo json_encode($rows);
  4785. exit;
  4786. }
  4787. if (isset($post['s'])) {
  4788. $id_arr = $this->input->post('s');
  4789. $id_arr = explode(',', trim($id_arr, ','));
  4790. if (!$id_arr) {
  4791. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4792. exit;
  4793. }
  4794. //循环删除记录
  4795. foreach ($id_arr as $v) {
  4796. $dd = $this->whlabel->read($v);
  4797. if (!isset($dd['id'])) {
  4798. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4799. exit;
  4800. }
  4801. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4802. if (isset($zt[0])) {
  4803. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4804. exit;
  4805. }
  4806. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4807. foreach ($deldd as $vv) {
  4808. $this->whlabel->remove($vv['id']);
  4809. }
  4810. }
  4811. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4812. exit;
  4813. }
  4814. $this->_Template('whlabel_error', $this->data);
  4815. }
  4816. public function _errorexcel()
  4817. {
  4818. $post = $this->input->post(NULL, TRUE);
  4819. if (isset($_GET['page'])) {
  4820. $page = $this->input->get('page', true);
  4821. $perpage = $this->input->get('perpage', true);
  4822. $sku = $this->input->get('sku', true);
  4823. $warehouse = $this->input->get('warehouse', true);
  4824. $ktime = $this->input->get('ktime', true);
  4825. $jtime = $this->input->get('jtime', true);
  4826. $ktime = strtotime($ktime);
  4827. $jtime = strtotime($jtime);
  4828. $where = "sku != 'Preset'";
  4829. $gj = '';
  4830. if ($sku) {
  4831. $where .= " and sku like '%$sku%'";
  4832. } else {
  4833. if ($ktime && $jtime) {
  4834. $gj = " and time > '$ktime' and time < '$jtime'";
  4835. }
  4836. }
  4837. if ($warehouse) {
  4838. $where .= " and warehouse = '$warehouse'";
  4839. }
  4840. //数据排序
  4841. $order_str = "id desc";
  4842. if (empty($page)) {
  4843. $start = 0;
  4844. $perpage = 1;
  4845. } else {
  4846. $start = ($page - 1) * $perpage;
  4847. }
  4848. //取得信息列表
  4849. $rows = array();
  4850. $list = array();
  4851. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4852. foreach ($info_list as $value) {
  4853. $warehouse = $this->warehouse->read($value['warehouse']);
  4854. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4855. $number = $value['number'];
  4856. $ftime = time() - 15 * 24 * 3600;
  4857. if ($c < 1) {
  4858. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4859. }
  4860. }
  4861. $title = "0库存汇总";
  4862. $titlename = "<table border=1>
  4863. <tr align='center'>
  4864. <td>仓库</td>
  4865. <td>SKU</td>
  4866. <td>产品</td>
  4867. <td>当前库存</td>
  4868. </tr>
  4869. </table>";
  4870. $filename = $title . ".xls";
  4871. $tail = "";
  4872. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4873. }
  4874. }
  4875. /**
  4876. *
  4877. *
  4878. * 占单
  4879. *
  4880. *
  4881. **/
  4882. public function _kcyz()
  4883. {
  4884. $post = $this->input->post(NULL, TRUE);
  4885. if (isset($post['warehouse'])) {
  4886. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4887. exit; //不再使用
  4888. $warehouse = $this->input->post('warehouse', true);
  4889. $whlabel = $this->input->post('whlabel', true);
  4890. $id = $this->input->post('id', true);
  4891. $shop = $this->input->post('shop', true);
  4892. $number = $this->input->post('number', true);
  4893. if (!$whlabel || $whlabel == '|') {
  4894. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4895. exit;
  4896. }
  4897. $pp = explode('|', trim($whlabel, '|'));
  4898. $x = 0;
  4899. $save = array();
  4900. foreach ($pp as $va) {
  4901. $num = explode('-', $va);
  4902. if ($number) {
  4903. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')"); //通用
  4904. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4905. } else {
  4906. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4907. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4908. }
  4909. $x++;
  4910. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4911. $save[] = $x - 1;
  4912. continue; //提前先加X不然出错,所以要减1
  4913. }
  4914. }
  4915. if (isset($save[0])) {
  4916. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4917. exit;
  4918. } else {
  4919. echo json_encode(array('success' => true));
  4920. exit;
  4921. }
  4922. }
  4923. }
  4924. public function _db()
  4925. {
  4926. $post = $this->input->post(NULL, TRUE);
  4927. if (isset($post['page'])) {
  4928. $page = $this->input->post('page', true);
  4929. $perpage = $this->input->post('perpage', true);
  4930. $sku = $this->input->post('sku', true);
  4931. $number = $this->input->post('number', true);
  4932. $warehouse = $this->input->post('warehouse', true);
  4933. $purchase = $this->input->post('purchase', true);
  4934. $orderinfo = $this->input->post('orderinfo', true);
  4935. $waybill = $this->input->post('waybill', true);
  4936. $category = $this->input->post('category', true);
  4937. $size = $this->input->post('size', true);
  4938. $grade = $this->input->post('grade', true);
  4939. $color = $this->input->post('color', true);
  4940. $lowe = $this->input->post('lowe', true);
  4941. $state = $this->input->post('state', true);
  4942. $label = $this->input->post('label', true);
  4943. $timetk = $this->input->post('timetkk', true);
  4944. $timetj = $this->input->post('timetjj', true);
  4945. $timetk = strtotime($timetk);
  4946. $timetj = strtotime($timetj);
  4947. $where = "dbtime > 0";
  4948. if ($timetk && $timetj) {
  4949. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4950. }
  4951. if ($sku) {
  4952. $where .= " and sku = '$sku'";
  4953. }
  4954. if ($warehouse) {
  4955. $where .= " and warehouse = '$warehouse'";
  4956. if ($warehouse == 12) {
  4957. $w = 'specialstock';
  4958. } else {
  4959. $w = 'whlabel';
  4960. }
  4961. }
  4962. if ($purchase) {
  4963. $where .= " and purchase = '$purchase'";
  4964. }
  4965. if ($category) {
  4966. $where .= " and features like '%-$category-%'";
  4967. }
  4968. if ($size) {
  4969. $where .= " and features like '%-$size-%'";
  4970. }
  4971. if ($grade) {
  4972. $where .= " and features like '%-$grade-%'";
  4973. }
  4974. if ($color) {
  4975. $where .= " and features like '%-$color-%'";
  4976. }
  4977. if ($lowe) {
  4978. $where .= " and features like '%-$lowe-%'";
  4979. }
  4980. if ($state != '') {
  4981. $where .= " and state = '$state'";
  4982. }
  4983. //数据排序
  4984. $order_str = "dbtime desc";
  4985. if (empty($page)) {
  4986. $start = 0;
  4987. $perpage = 1;
  4988. } else {
  4989. $start = ($page - 1) * $perpage;
  4990. }
  4991. //取得信息列表
  4992. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4993. foreach ($info_list as $key => $value) {
  4994. $warehouse = $this->$w->read($value['warehouse']);
  4995. $info_list[$key]['warehouse'] = $warehouse['title'];
  4996. $purchase = $this->purchase->read($value['purchase']);
  4997. $info_list[$key]['purchase'] = $purchase['title'];
  4998. if ($value['enter'] != 0) {
  4999. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5000. } else {
  5001. $info_list[$key]['enter'] = "";
  5002. }
  5003. if ($value['dbtime'] != 0) {
  5004. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5005. } else {
  5006. $info_list[$key]['dbtime'] = "";
  5007. }
  5008. if ($value['state'] == 0) {
  5009. $info_list[$key]['state'] = "在库";
  5010. } else if ($value['state'] == 1) {
  5011. $info_list[$key]['state'] = "出库";
  5012. } else if ($value['state'] == 2) {
  5013. $info_list[$key]['state'] = "退库";
  5014. } else if ($value['state'] == 3) {
  5015. $info_list[$key]['state'] = "调拨中";
  5016. } else if ($value['state'] == 4) {
  5017. $info_list[$key]['state'] = "再加工";
  5018. } else if ($value['state'] == 5) {
  5019. $info_list[$key]['state'] = "维修中";
  5020. } else if ($value['state'] == 6) {
  5021. $info_list[$key]['state'] = "盘亏";
  5022. } else if ($value['state'] == 7) {
  5023. $info_list[$key]['state'] = "更换标签";
  5024. } else if ($value['state'] == 8) {
  5025. $info_list[$key]['state'] = "其它";
  5026. } else if ($value['state'] == 9) {
  5027. $info_list[$key]['state'] = "预设";
  5028. }
  5029. }
  5030. $total = $this->whlabel->find_count($where);
  5031. $pagenum = ceil($total / $perpage);
  5032. $over = $total - ($start + $perpage);
  5033. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5034. echo json_encode($rows);
  5035. exit;
  5036. }
  5037. if (isset($post['outsku'])) {
  5038. $time = time();
  5039. $cz = $this->input->post('cz', true);
  5040. $label = $this->input->post('outsku', true);
  5041. $sl = $this->input->post('sl', true);
  5042. $num = $this->input->post('num', true);
  5043. //$warehouse = $this->input->post('warehouse',true);
  5044. if (!$sl) {
  5045. $sl = 1;
  5046. }
  5047. if (!$warehouse) {
  5048. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5049. exit;
  5050. }
  5051. $dblabel = $this->whlabellabel->get_label($label);
  5052. if ($dblabel) {
  5053. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5054. if (count($data) < 1) {
  5055. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5056. exit;
  5057. }
  5058. if (count($data) < $num) {
  5059. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5060. exit;
  5061. }
  5062. for ($i = 0; $i < $sl; $i++) {
  5063. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5064. }
  5065. echo json_encode(array('success' => true));
  5066. exit;
  5067. } else {
  5068. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5069. exit;
  5070. }
  5071. }
  5072. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5073. $this->_Template('whlabel_db', $this->data);
  5074. }
  5075. public function _dbrk()
  5076. {
  5077. $post = $this->input->post(NULL, TRUE);
  5078. if (isset($post['page'])) {
  5079. $page = $this->input->post('page', true);
  5080. $perpage = $this->input->post('perpage', true);
  5081. $sku = $this->input->post('sku', true);
  5082. $number = $this->input->post('number', true);
  5083. $warehouse = $this->input->post('warehouse', true);
  5084. $purchase = $this->input->post('purchase', true);
  5085. $orderinfo = $this->input->post('orderinfo', true);
  5086. $waybill = $this->input->post('waybill', true);
  5087. $category = $this->input->post('category', true);
  5088. $size = $this->input->post('size', true);
  5089. $grade = $this->input->post('grade', true);
  5090. $color = $this->input->post('color', true);
  5091. $lowe = $this->input->post('lowe', true);
  5092. $state = $this->input->post('state', true);
  5093. $label = $this->input->post('label', true);
  5094. $ctime = $this->input->post('ctime', true);
  5095. $timetk = $this->input->post('timetkk', true);
  5096. $timetj = $this->input->post('timetjj', true);
  5097. $timetk = strtotime($timetk);
  5098. $timetj = strtotime($timetj);
  5099. $where = "dbtime > 0";
  5100. if ($timetk && $timetj) {
  5101. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5102. }
  5103. if ($sku) {
  5104. $where .= " and sku = '$sku'";
  5105. }
  5106. if ($warehouse) {
  5107. $where .= " and warehouse = '$warehouse'";
  5108. }
  5109. if ($purchase) {
  5110. $where .= " and purchase = '$purchase'";
  5111. }
  5112. if ($category) {
  5113. $where .= " and features like '%-$category-%'";
  5114. }
  5115. if ($size) {
  5116. $where .= " and features like '%-$size-%'";
  5117. }
  5118. if ($grade) {
  5119. $where .= " and features like '%-$grade-%'";
  5120. }
  5121. if ($color) {
  5122. $where .= " and features like '%-$color-%'";
  5123. }
  5124. if ($lowe) {
  5125. $where .= " and features like '%-$lowe-%'";
  5126. }
  5127. if ($state != '') {
  5128. $where .= " and state = '$state'";
  5129. }
  5130. //数据排序
  5131. $order_str = "dbtime desc";
  5132. if (empty($page)) {
  5133. $start = 0;
  5134. $perpage = 1;
  5135. } else {
  5136. $start = ($page - 1) * $perpage;
  5137. }
  5138. //取得信息列表
  5139. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5140. foreach ($info_list as $key => $value) {
  5141. $warehouse = $this->warehouse->read($value['warehouse']);
  5142. $info_list[$key]['warehouse'] = $warehouse['title'];
  5143. $purchase = $this->purchase->read($value['purchase']);
  5144. $info_list[$key]['purchase'] = $purchase['title'];
  5145. if ($value['enter'] != 0) {
  5146. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5147. } else {
  5148. $info_list[$key]['enter'] = "";
  5149. }
  5150. if ($value['dbtime'] != 0) {
  5151. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5152. } else {
  5153. $info_list[$key]['dbtime'] = "";
  5154. }
  5155. if ($value['state'] == 0) {
  5156. $info_list[$key]['state'] = "在库";
  5157. } else if ($value['state'] == 1) {
  5158. $info_list[$key]['state'] = "出库";
  5159. } else if ($value['state'] == 2) {
  5160. $info_list[$key]['state'] = "退库";
  5161. } else if ($value['state'] == 3) {
  5162. $info_list[$key]['state'] = "调拨中";
  5163. } else if ($value['state'] == 4) {
  5164. $info_list[$key]['state'] = "再加工";
  5165. } else if ($value['state'] == 5) {
  5166. $info_list[$key]['state'] = "维修中";
  5167. } else if ($value['state'] == 6) {
  5168. $info_list[$key]['state'] = "盘亏";
  5169. } else if ($value['state'] == 7) {
  5170. $info_list[$key]['state'] = "更换标签";
  5171. } else if ($value['state'] == 8) {
  5172. $info_list[$key]['state'] = "其它";
  5173. } else if ($value['state'] == 9) {
  5174. $info_list[$key]['state'] = "预设";
  5175. }
  5176. }
  5177. $total = $this->whlabel->find_count($where);
  5178. $pagenum = ceil($total / $perpage);
  5179. $over = $total - ($start + $perpage);
  5180. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5181. echo json_encode($rows);
  5182. exit;
  5183. }
  5184. if (isset($post['rsku'])) {
  5185. $cz = $this->input->post('cz', true);
  5186. $label = $this->input->post('rsku', true);
  5187. $sl = $this->input->post('sl', true);
  5188. $warehouse = $this->input->post('warehouse', true);
  5189. if (!$sl) {
  5190. $sl = 1;
  5191. }
  5192. if (!$warehouse) {
  5193. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5194. exit;
  5195. }
  5196. $dblabel = $this->whlabellabel->get_label($label);
  5197. if ($dblabel) {
  5198. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5199. if (count($data) < 1) {
  5200. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5201. exit;
  5202. }
  5203. if ($sl > count($data)) {
  5204. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5205. exit;
  5206. }
  5207. $time = time();
  5208. for ($i = 0; $i < $sl; $i++) {
  5209. $this->whlabel->save(array('state' => 0, 'dbwarehouse' => $data[$i]['warehouse'], 'warehouse' => $warehouse, 'enter' => $time, 'time' => $time, 'dbcontent' => $data[$i]['dbcontent'] . $warehouse . '-' . $time . '|',), $data[$i]['id']);
  5210. }
  5211. echo json_encode(array('success' => true));
  5212. exit;
  5213. } else {
  5214. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5215. exit;
  5216. }
  5217. }
  5218. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5219. $this->_Template('whlabel_dbrk', $this->data);
  5220. }
  5221. public function _whlabelczdc()
  5222. {
  5223. if (isset($_GET['excel'])) {
  5224. //数据排序
  5225. $order_str = "id desc";
  5226. if (empty($page)) {
  5227. $start = 0;
  5228. $perpage = 1;
  5229. } else {
  5230. $start = ($page - 1) * $perpage;
  5231. }
  5232. $state = $this->input->get('state', true);
  5233. $sku = $this->input->get('sku', true);
  5234. $ctime = $this->input->get('ctime', true);
  5235. $category = $this->input->get('category', true);
  5236. $size = $this->input->get('size', true);
  5237. $grade = $this->input->get('grade', true);
  5238. $color = $this->input->get('color', true);
  5239. $lowe = $this->input->get('lowe', true);
  5240. $timetk = $this->input->get('timetkk', true);
  5241. $timetj = $this->input->get('timetjj', true);
  5242. $timetk = strtotime($timetk);
  5243. $timetj = strtotime($timetj);
  5244. $where = "dbtime > 0";
  5245. if ($timetk && $timetj) {
  5246. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5247. }
  5248. if ($category) {
  5249. $where .= " and features like '%-$category-%'";
  5250. }
  5251. if ($size) {
  5252. $where .= " and features like '%-$size-%'";
  5253. }
  5254. if ($grade) {
  5255. $where .= " and features like '%-$grade-%'";
  5256. }
  5257. if ($color) {
  5258. $where .= " and features like '%-$color-%'";
  5259. }
  5260. if ($lowe) {
  5261. $where .= " and features like '%-$lowe-%'";
  5262. }
  5263. //取得信息列表
  5264. $info_list = $this->whlabel->find_all($where, '*');
  5265. $rows = array();
  5266. $list = array();
  5267. foreach ($info_list as $key => $value) {
  5268. $rows[$value['sku']] = $value; //所有数据sku
  5269. }
  5270. foreach ($rows as $value) {
  5271. $warehouse = $this->warehouse->read($value['warehouse']);
  5272. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5273. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5274. if ($value['orderinfo'] == 0) {
  5275. $info_list[$key]['orderinfo'] = "";
  5276. }
  5277. if ($value['waybill'] == 0) {
  5278. $info_list[$key]['waybill'] = "";
  5279. }
  5280. if ($value['state'] == 0) {
  5281. $value['state'] = "在库";
  5282. } else if ($value['state'] == 3) {
  5283. $value['state'] = "调拨中";
  5284. }
  5285. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5286. }
  5287. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5288. $titlename = "<table border=1>
  5289. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5290. <tr align='center'>
  5291. <td>SKU</td>
  5292. <td>产品</td>
  5293. <td>调拨数量</td>
  5294. <td>入库数量</td>
  5295. </tr>
  5296. </table>";
  5297. $filename = $title . ".xls";
  5298. $tail = "";
  5299. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5300. }
  5301. }
  5302. public function _print($arg_array)
  5303. {
  5304. if (isset($_SESSION['api'])) {
  5305. $user = $this->user->get_api($_SESSION['api']);
  5306. $usp = $user;
  5307. $fgshop = "";
  5308. $sid = "";
  5309. $wid = "";
  5310. $wtype = "";
  5311. $usersp = explode('|', trim($user['shop'], '|'));
  5312. $userwh = explode('|', trim($user['warehouse'], '|'));
  5313. foreach ($usersp as $value) {
  5314. $fgshop .= " shop = " . $value . " or";
  5315. $sid .= " id = " . $value . " or";
  5316. }
  5317. foreach ($userwh as $value) {
  5318. $wid .= " id = " . $value . " or";
  5319. $wtype .= " type = " . $value . " or";
  5320. }
  5321. }
  5322. $post = $this->input->post(NULL, TRUE);
  5323. if (isset($post['tmsku'])) {
  5324. $tmsku = $this->input->post('tmsku', true);
  5325. if (is_numeric($tmsku)) {
  5326. $yyh = $this->whlabellabel->get_label($tmsku);
  5327. } else {
  5328. $yyh = $this->whlabellabel->get_sku($tmsku);
  5329. }
  5330. if ($yyh) {
  5331. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5332. exit;
  5333. } else {
  5334. echo json_encode(array('success' => false));
  5335. exit;
  5336. }
  5337. }
  5338. $classid = $this->classid->sku();
  5339. $pm = $classid;
  5340. $scsku = $classid;
  5341. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5342. if (isset($post['warehouse'])) {
  5343. if ($post['warehouse']) {
  5344. $list = array();
  5345. $num = "";
  5346. $title = "";
  5347. $features = "";
  5348. $order = 0;
  5349. $post['shop'] = '';
  5350. $brand = $this->input->post('brand', true);
  5351. if ($brand != '0,') {
  5352. $b = $this->brand->read(rtrim($brand, ','));
  5353. if ($b) {
  5354. $post['shop'] = str_replace('|', ',', $b['shop']);
  5355. }
  5356. }
  5357. $post['details'] = $this->input->post('details', true); //打印数量
  5358. $xbqnum = $this->input->post('xbqnum', true);
  5359. $post['purchase'] = $this->input->post('purchase', true);
  5360. $post['warehouse'] = $this->input->post('warehouse', true);
  5361. $post['purchase'] = $this->input->post('purchase', true);
  5362. $post['retreatwarehouse'] = $post['warehouse'];
  5363. $post['cpbz'] = $this->input->post('cpbz', true);
  5364. $post['state'] = 9;
  5365. $category = $this->input->post('category', true);
  5366. $list['category'] = $category;
  5367. $list['hairtype'] = $this->input->post('hairtype', true);
  5368. $list['grade'] = $this->input->post('grade', true);
  5369. $size = $this->input->post('size', true);
  5370. $list['size'] = rtrim($size, ',');
  5371. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5372. $list['extension'] = $this->input->post('extension', true);
  5373. if ($category == 1297) {
  5374. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5375. }
  5376. if ($category == 1702) {
  5377. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5378. $list['syother'] = $this->input->post('syother', true);
  5379. }
  5380. if ($category == 133) {
  5381. $list['fittype'] = $this->input->post('fittype', true);
  5382. $list['acother'] = $this->input->post('acother', true);
  5383. }
  5384. $list['color'] = $this->input->post('color', true);
  5385. $list['lowe'] = $this->input->post('lowe', true);
  5386. if ($category == 127) {
  5387. $list['type'] = $this->input->post('type', true);
  5388. $list['headroad'] = $this->input->post('headroad', true);
  5389. $list['density'] = $this->input->post('density', true);
  5390. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5391. $list['lacesize'] = $this->input->post('lacesize', true);
  5392. }
  5393. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5394. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5395. }
  5396. if ($category == 128) {
  5397. $list['lacetype'] = $this->input->post('lacetype', true);
  5398. $list['haircap'] = $this->input->post('haircap', true);
  5399. $list['density'] = $this->input->post('density', true);
  5400. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5401. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5402. $list['wigother'] = $this->input->post('wigother', true);
  5403. $list['wigother2'] = $this->input->post('wigother2', true);
  5404. }
  5405. if ($category == 129) {
  5406. $list['wide'] = $this->input->post('wide', true);
  5407. }
  5408. if ($category == 131) {
  5409. $list['gifttype'] = $this->input->post('gifttype', true);
  5410. $list['giftother'] = $this->input->post('giftother', true);
  5411. }
  5412. if ($category == 134) {
  5413. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5414. }
  5415. if ($category == 1297) {
  5416. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5417. $list['sywigother'] = $this->input->post('sywigother', true);
  5418. }
  5419. if ($category == 130 || $category == 133 || $category == 1702) {
  5420. $list['items'] = $this->input->post('items', true);
  5421. $list['weight'] = $this->input->post('weight', true);
  5422. }
  5423. if ($category == 1702) {
  5424. $list['syhairther'] = $this->input->post('syhairther', true);
  5425. }
  5426. foreach ($list as $k => $v) {
  5427. if ($v != 0) {
  5428. $num .= $v;
  5429. $features .= $v . '-';
  5430. $post[$k] = $v;
  5431. $typeclass = $this->typeclass->read($v);
  5432. if (isset($pm[$typeclass['classid']])) {
  5433. if (stripos($typeclass['zh'], '|') !== false) {
  5434. $exzh = explode('|', $typeclass['zh']);
  5435. $pm[$typeclass['classid']] = $exzh[0];
  5436. } else {
  5437. $pm[$typeclass['classid']] = $typeclass['zh'];
  5438. }
  5439. }
  5440. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5441. if ($k != 'size') {
  5442. $title .= $typeclass['title'] . " ";
  5443. }
  5444. }
  5445. }
  5446. $typeclass = $this->typeclass->read($list['size']);
  5447. $title .= $typeclass['title'];
  5448. $time = time();
  5449. $post['title'] = rtrim($title, ' ');
  5450. $post['number'] = $num;
  5451. $post['features'] = '-' . $features;
  5452. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5453. $featurespp = explode('-', trim($featurespp, '-'));
  5454. if (isset($featurespp[5])) {
  5455. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5456. } else {
  5457. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5458. }
  5459. $post['enter'] = $time;
  5460. $post['time'] = $time; //操作时间
  5461. $scsku = implode("-", $scsku);
  5462. $zh = implode(" ", $pm);
  5463. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5464. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5465. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5466. $post['sku'] = $bqsku;
  5467. $label = time() . rand(0, 9);
  5468. $post['label'] = $label;
  5469. $cpid = $this->whlabellabel->find_count();
  5470. $post['cpid'] = $cpid + 1;
  5471. $cpid = $post['cpid'];
  5472. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5473. //if($whlabelbarcode)
  5474. //{
  5475. //$post['label'] = $whlabelbarcode['label'];
  5476. //if(!$this->whlabellabel->insert($post))
  5477. //{
  5478. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5479. //}
  5480. //}
  5481. //else
  5482. //{
  5483. $this->db->trans_begin();
  5484. $this->whlabellabel->insert($post);
  5485. //$this->whlabelbarcode->insert($post);
  5486. if ($this->db->trans_status() === TRUE) {
  5487. $this->db->trans_commit();
  5488. } else {
  5489. $this->db->trans_rollback();
  5490. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5491. exit;
  5492. }
  5493. //}
  5494. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5495. $purchase = $this->purchase->read($post['purchase']);
  5496. echo json_encode(array('title' => $title, 'num' => $post['label'], 'bqsku' => $bqsku, 'xbqnum' => $xbqnum, 'zh' => str_replace('自然色 ', '', rtrim($zh, ' ')), 'details' => $details, 'purchase' => $purchase['title'], 'cpbz' => $post['cpbz'], 'usa' => 0, 'success' => true));
  5497. exit; //特殊仓目前不需要仓库选项
  5498. }
  5499. }
  5500. if (isset($_SESSION['api'])) {
  5501. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5502. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5503. $this->data['wlshop'] = $wlshop;
  5504. $this->data['warehouse'] = $warehouse;
  5505. }
  5506. $whlabelwz = $this->whlabelwz->find_all();
  5507. $this->data['whlabelwz'] = $whlabelwz;
  5508. $this->_Template('whlabel_print', $this->data);
  5509. }
  5510. public function _usaprint($arg_array)
  5511. {
  5512. if (isset($_SESSION['api'])) {
  5513. $user = $this->user->get_api($_SESSION['api']);
  5514. $usp = $user;
  5515. $fgshop = "";
  5516. $sid = "";
  5517. $wid = "";
  5518. $wtype = "";
  5519. $usersp = explode('|', trim($user['shop'], '|'));
  5520. $userwh = explode('|', trim($user['warehouse'], '|'));
  5521. foreach ($usersp as $value) {
  5522. $fgshop .= " shop = " . $value . " or";
  5523. $sid .= " id = " . $value . " or";
  5524. }
  5525. foreach ($userwh as $value) {
  5526. $wid .= " id = " . $value . " or";
  5527. $wtype .= " type = " . $value . " or";
  5528. }
  5529. }
  5530. $post = $this->input->post(NULL, TRUE);
  5531. if (isset($post['tmsku'])) {
  5532. $tmsku = $this->input->post('tmsku', true);
  5533. if (is_numeric($tmsku)) {
  5534. $yyh = $this->whlabellabel->get_label($tmsku);
  5535. } else {
  5536. $yyh = $this->whlabellabel->get_sku($tmsku);
  5537. }
  5538. if ($yyh) {
  5539. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5540. exit;
  5541. } else {
  5542. echo json_encode(array('success' => false));
  5543. exit;
  5544. }
  5545. }
  5546. $classid = $this->classid->sku();
  5547. $pm = $classid;
  5548. $scsku = $classid;
  5549. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5550. if (isset($post['warehouse'])) {
  5551. if ($post['warehouse']) {
  5552. $list = array();
  5553. $num = "";
  5554. $title = "";
  5555. $features = "";
  5556. $order = 0;
  5557. $post['shop'] = '';
  5558. $brand = $this->input->post('brand', true);
  5559. if ($brand != '0,') {
  5560. $b = $this->brand->read(rtrim($brand, ','));
  5561. if ($b) {
  5562. $post['shop'] = str_replace('|', ',', $b['shop']);
  5563. }
  5564. }
  5565. $post['details'] = $this->input->post('details', true); //打印数量
  5566. $xbqnum = $this->input->post('xbqnum', true);
  5567. $post['purchase'] = $this->input->post('purchase', true);
  5568. $post['warehouse'] = $this->input->post('warehouse', true);
  5569. $post['purchase'] = $this->input->post('purchase', true);
  5570. $post['retreatwarehouse'] = $post['warehouse'];
  5571. $post['cpbz'] = $this->input->post('cpbz', true);
  5572. $post['state'] = 9;
  5573. $category = $this->input->post('category', true);
  5574. $list['category'] = $category;
  5575. $list['hairtype'] = $this->input->post('hairtype', true);
  5576. $list['grade'] = $this->input->post('grade', true);
  5577. $size = $this->input->post('size', true);
  5578. $list['size'] = rtrim($size, ',');
  5579. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5580. $list['extension'] = $this->input->post('extension', true);
  5581. if ($category == 1297) {
  5582. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5583. }
  5584. if ($category == 1702) {
  5585. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5586. $list['syother'] = $this->input->post('syother', true);
  5587. }
  5588. if ($category == 133) {
  5589. $list['fittype'] = $this->input->post('fittype', true);
  5590. $list['acother'] = $this->input->post('acother', true);
  5591. }
  5592. $list['color'] = $this->input->post('color', true);
  5593. $list['lowe'] = $this->input->post('lowe', true);
  5594. if ($category == 127) {
  5595. $list['type'] = $this->input->post('type', true);
  5596. $list['headroad'] = $this->input->post('headroad', true);
  5597. $list['density'] = $this->input->post('density', true);
  5598. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5599. $list['lacesize'] = $this->input->post('lacesize', true);
  5600. }
  5601. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5602. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5603. }
  5604. if ($category == 128) {
  5605. $list['lacetype'] = $this->input->post('lacetype', true);
  5606. $list['haircap'] = $this->input->post('haircap', true);
  5607. $list['density'] = $this->input->post('density', true);
  5608. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5609. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5610. $list['wigother'] = $this->input->post('wigother', true);
  5611. $list['wigother2'] = $this->input->post('wigother2', true);
  5612. }
  5613. if ($category == 129) {
  5614. $list['wide'] = $this->input->post('wide', true);
  5615. }
  5616. if ($category == 131) {
  5617. $list['gifttype'] = $this->input->post('gifttype', true);
  5618. $list['giftother'] = $this->input->post('giftother', true);
  5619. }
  5620. if ($category == 134) {
  5621. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5622. }
  5623. if ($category == 1297) {
  5624. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5625. $list['sywigother'] = $this->input->post('sywigother', true);
  5626. }
  5627. if ($category == 130 || $category == 133 || $category == 1702) {
  5628. $list['items'] = $this->input->post('items', true);
  5629. $list['weight'] = $this->input->post('weight', true);
  5630. }
  5631. if ($category == 1702) {
  5632. $list['syhairther'] = $this->input->post('syhairther', true);
  5633. }
  5634. foreach ($list as $k => $v) {
  5635. if ($v != 0) {
  5636. $num .= $v;
  5637. $features .= $v . '-';
  5638. $post[$k] = $v;
  5639. $typeclass = $this->typeclass->read($v);
  5640. if (isset($pm[$typeclass['classid']])) {
  5641. if (stripos($typeclass['zh'], '|') !== false) {
  5642. $exzh = explode('|', $typeclass['zh']);
  5643. $pm[$typeclass['classid']] = $exzh[0];
  5644. } else {
  5645. $pm[$typeclass['classid']] = $typeclass['zh'];
  5646. }
  5647. }
  5648. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5649. if ($k != 'size') {
  5650. $title .= $typeclass['title'] . " ";
  5651. }
  5652. }
  5653. }
  5654. $typeclass = $this->typeclass->read($list['size']);
  5655. $title .= $typeclass['title'];
  5656. $time = time();
  5657. $post['title'] = rtrim($title, ' ');
  5658. $post['number'] = $num;
  5659. $post['features'] = '-' . $features;
  5660. $fp = $this->whlabel->get_features($post['features']);
  5661. if (!$fp) {
  5662. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5663. exit;
  5664. }
  5665. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5666. $featurespp = explode('-', trim($featurespp, '-'));
  5667. if (isset($featurespp[5])) {
  5668. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5669. } else {
  5670. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5671. }
  5672. $post['enter'] = $time;
  5673. $post['time'] = $time; //操作时间
  5674. $scsku = implode("-", $scsku);
  5675. $zh = implode(" ", $pm);
  5676. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5677. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5678. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5679. $post['sku'] = $fp['sku'];
  5680. $post['label'] = $fp['sku'];
  5681. $cpid = $this->whlabellabel->find_count();
  5682. $post['cpid'] = $cpid + 1;
  5683. $cpid = $post['cpid'];
  5684. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5685. //if($whlabelbarcode)
  5686. //{
  5687. //$post['label'] = $whlabelbarcode['label'];
  5688. //if(!$this->whlabellabel->insert($post))
  5689. //{
  5690. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5691. //}
  5692. //}
  5693. //else
  5694. //{
  5695. $this->db->trans_begin();
  5696. $this->whlabellabel->insert($post);
  5697. //$this->whlabelbarcode->insert($post);
  5698. if ($this->db->trans_status() === TRUE) {
  5699. $this->db->trans_commit();
  5700. } else {
  5701. $this->db->trans_rollback();
  5702. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5703. exit;
  5704. }
  5705. //}
  5706. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5707. $purchase = $this->purchase->read($post['purchase']);
  5708. echo json_encode(array('title' => $title, 'num' => $post['label'], 'bqsku' => $bqsku, 'xbqnum' => $xbqnum, 'zh' => str_replace('自然色 ', '', rtrim($zh, ' ')), 'details' => $details, 'purchase' => $purchase['title'], 'cpbz' => $post['cpbz'], 'usa' => 1, 'success' => true));
  5709. exit; //特殊仓目前不需要仓库选项
  5710. }
  5711. }
  5712. if (isset($_SESSION['api'])) {
  5713. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5714. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5715. $this->data['wlshop'] = $wlshop;
  5716. $this->data['warehouse'] = $warehouse;
  5717. }
  5718. $whlabelwz = $this->whlabelwz->find_all();
  5719. $this->data['whlabelwz'] = $whlabelwz;
  5720. $this->_Template('whlabel_usaprint', $this->data);
  5721. }
  5722. public function _printrk($arg_array)
  5723. {
  5724. $prc = array();
  5725. $purchase = $this->purchase->find_all();
  5726. foreach ($purchase as $k => $v) {
  5727. $prc[$v['id']] = $v['title'];
  5728. }
  5729. $post = $this->input->post(NULL, TRUE);
  5730. if (isset($post['page'])) {
  5731. $page = $this->input->post('page', true);
  5732. $perpage = $this->input->post('perpage', true);
  5733. $sku = $this->input->post('sku', true);
  5734. $bs = $this->input->post('bs', true);
  5735. $number = $this->input->post('number', true);
  5736. $warehouse = $this->input->post('warehouse', true);
  5737. $purchase = $this->input->post('purchase', true);
  5738. $orderinfo = $this->input->post('orderinfo', true);
  5739. $waybill = $this->input->post('waybill', true);
  5740. $category = $this->input->post('category', true);
  5741. $size = $this->input->post('size', true);
  5742. $grade = $this->input->post('grade', true);
  5743. $color = $this->input->post('color', true);
  5744. $lowe = $this->input->post('lowe', true);
  5745. $state = $this->input->post('state', true);
  5746. $label = $this->input->post('label', true);
  5747. $timetk = $this->input->post('ktime', true);
  5748. $timetj = $this->input->post('jtime', true);
  5749. $timetk = strtotime($timetk);
  5750. $timetj = strtotime($timetj);
  5751. $where = "1=1 ";
  5752. if ($timetk && $timetj) {
  5753. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5754. }
  5755. if ($sku) {
  5756. $where .= " and sku = '$sku'";
  5757. }
  5758. if ($bs != '') {
  5759. $where .= " and bs = '$bs'";
  5760. }
  5761. if ($number) {
  5762. $where .= " and number = '$number'";
  5763. }
  5764. if ($warehouse) {
  5765. $where .= " and warehouse = '$warehouse'";
  5766. }
  5767. if ($purchase) {
  5768. $where .= " and purchase = '$purchase'";
  5769. }
  5770. if ($orderinfo) {
  5771. $where .= " and orderinfo = '$orderinfo'";
  5772. }
  5773. if ($waybill) {
  5774. $where .= " and waybill = '$waybill'";
  5775. }
  5776. if ($category) {
  5777. $where .= " and features like '%-$category-%'";
  5778. }
  5779. if ($size) {
  5780. $where .= " and features like '%-$size-%'";
  5781. }
  5782. if ($grade) {
  5783. $where .= " and features like '%-$grade-%'";
  5784. }
  5785. if ($color) {
  5786. $where .= " and features like '%-$color-%'";
  5787. }
  5788. if ($lowe) {
  5789. $where .= " and features like '%-$lowe-%'";
  5790. }
  5791. if ($label) {
  5792. $where .= " and label = '$label'";
  5793. }
  5794. if ($state || $state == 0) {
  5795. $where .= " and state = '$state'";
  5796. }
  5797. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5798. //数据排序
  5799. $order_str = "enter desc";
  5800. if (empty($page)) {
  5801. $start = 0;
  5802. $perpage = 1;
  5803. } else {
  5804. $start = ($page - 1) * $perpage;
  5805. }
  5806. //取得信息列表
  5807. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5808. foreach ($info_list as $key => $value) {
  5809. $warehouse = $this->warehouse->read($value['warehouse']);
  5810. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5811. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5812. if ($value['state'] == 0) {
  5813. $info_list[$key]['state'] = "在库";
  5814. } else if ($value['state'] == 1) {
  5815. $info_list[$key]['state'] = "出库";
  5816. } else if ($value['state'] == 2) {
  5817. $info_list[$key]['state'] = "退库";
  5818. } else if ($value['state'] == 3) {
  5819. $info_list[$key]['state'] = "调拨中";
  5820. } else if ($value['state'] == 4) {
  5821. $info_list[$key]['state'] = "再加工";
  5822. } else if ($value['state'] == 5) {
  5823. $info_list[$key]['state'] = "维修中";
  5824. } else if ($value['state'] == 6) {
  5825. $info_list[$key]['state'] = "盘亏";
  5826. } else if ($value['state'] == 7) {
  5827. $info_list[$key]['state'] = "更换标签";
  5828. } else if ($value['state'] == 8) {
  5829. $info_list[$key]['state'] = "其它";
  5830. } else if ($value['state'] == 9) {
  5831. $info_list[$key]['state'] = "预设";
  5832. } else if ($value['state'] == 10) {
  5833. $info_list[$key]['state'] = "美店零售";
  5834. }
  5835. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5836. }
  5837. $total = $this->$ck->find_count($where);
  5838. $pagenum = ceil($total / $perpage);
  5839. $over = $total - ($start + $perpage);
  5840. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5841. echo json_encode($rows);
  5842. exit;
  5843. }
  5844. if (isset($post['tmsku'])) {
  5845. $time = time();
  5846. $tmsku = $this->input->post('tmsku', true);
  5847. //$post['shop'] = $this->input->post('shop',true);
  5848. $num = $this->input->post('num', true);
  5849. $rktype = $this->input->post('rktype', true);
  5850. if ($num > 200) {
  5851. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5852. exit;
  5853. }
  5854. if (!$rktype) {
  5855. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5856. }
  5857. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5858. /**
  5859. $wz = array();
  5860. foreach ($rk as $key=>$value)
  5861. {
  5862. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5863. }
  5864. if(count($wz) > 1)
  5865. {
  5866. $wz = array_values($wz);
  5867. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5868. }
  5869. **/
  5870. if (isset($rk[0]['purchase'])) {
  5871. $rk = $rk[0];
  5872. $j = 0;
  5873. $post['purchase'] = $rk['purchase'];
  5874. $post['warehouse'] = $rk['warehouse'];
  5875. $post['retreatwarehouse'] = $rk['warehouse'];
  5876. $post['sku'] = $rk['sku'];
  5877. $post['number'] = $rk['number'];
  5878. $post['features'] = $rk['features'];
  5879. $post['title'] = $rk['title'];
  5880. $post['enter'] = $time;
  5881. $post['time'] = $time;
  5882. $post['bs'] = 1;
  5883. $post['shop'] = $rk['shop'];
  5884. $post['details'] = $rk['details'];
  5885. $post['cpid'] = $rk['cpid'];
  5886. $post['cpbz'] = $rk['cpbz'];
  5887. //$post['rktype'] = $rktype;
  5888. $warehouse = $this->warehouse->read($rk['warehouse']);
  5889. if ($warehouse['bdck'] == '') {
  5890. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5891. exit;
  5892. } else {
  5893. $bdck = $warehouse['bdck'];
  5894. }
  5895. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5896. if (isset($pdwz['details'])) {
  5897. if ($pdwz['details'] != $post['details']) {
  5898. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5899. exit;
  5900. }
  5901. }
  5902. $post['featurespp'] = $rk['featurespp'];
  5903. if ($post['warehouse'] == '5') {
  5904. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5905. if ($yza) {
  5906. if ($post['features'] != $yza[0]['features']) {
  5907. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5908. exit;
  5909. }
  5910. }
  5911. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5912. if ($yzb) {
  5913. if ($post['sku'] != $yzb[0]['sku']) {
  5914. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5915. exit;
  5916. }
  5917. }
  5918. }
  5919. for ($i = 0; $i < $num; $i++) {
  5920. $post['label'] = time() . rand(100, 999) . $i;
  5921. if ($this->$bdck->insert($post)) {
  5922. $j++;
  5923. }
  5924. }
  5925. /**
  5926. if($post['warehouse'] != 12)
  5927. {
  5928. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5929. }
  5930. **/
  5931. if ($j == $num) {
  5932. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5933. exit;
  5934. } else {
  5935. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5936. exit;
  5937. }
  5938. } else {
  5939. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5940. exit;
  5941. }
  5942. }
  5943. $this->_Template('whlabel_printrk', $this->data);
  5944. }
  5945. public function _printxzrk($arg_array)
  5946. {
  5947. $post = $this->input->post(NULL, TRUE);
  5948. if (isset($post['wzid'])) {
  5949. $time = time();
  5950. $id = $this->input->post('wzid', true);
  5951. //$post['shop'] = $this->input->post('shop',true);
  5952. $num = 1;
  5953. $rk = $this->whlabellabel->read($id);
  5954. if (isset($rk['purchase'])) {
  5955. $x = 0;
  5956. $post['purchase'] = $rk['purchase'];
  5957. $post['warehouse'] = $rk['warehouse'];
  5958. $post['retreatwarehouse'] = $rk['warehouse'];
  5959. $post['sku'] = $rk['sku'];
  5960. $post['number'] = $rk['number'];
  5961. $post['features'] = $rk['features'];
  5962. $post['title'] = $rk['title'];
  5963. $post['enter'] = $time;
  5964. $post['time'] = $time;
  5965. $post['bs'] = 1;
  5966. $post['shop'] = $rk['shop'];
  5967. $post['details'] = $rk['details'];
  5968. $post['cpid'] = $rk['cpid'];
  5969. $post['cpbz'] = $rk['cpbz'];
  5970. $warehouse = $this->warehouse->read($rk['warehouse']);
  5971. if ($warehouse['bdck'] == '') {
  5972. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5973. exit;
  5974. } else {
  5975. $bdck = $warehouse['bdck'];
  5976. }
  5977. $post['featurespp'] = $rk['featurespp'];
  5978. $this->db->trans_begin();
  5979. for ($i = 0; $i < $num; $i++) {
  5980. $post['label'] = time() . rand(100, 999) . $i;
  5981. $this->$bdck->insert($post);
  5982. }
  5983. /**
  5984. if($post['warehouse'] != 12)
  5985. {
  5986. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5987. }
  5988. **/
  5989. if ($this->db->trans_status() === TRUE) {
  5990. $this->db->trans_commit();
  5991. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  5992. exit;
  5993. } else {
  5994. $this->db->trans_rollback();
  5995. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  5996. exit;
  5997. }
  5998. } else {
  5999. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6000. exit;
  6001. }
  6002. }
  6003. }
  6004. public function _printck($arg_array)
  6005. {
  6006. $prc = array();
  6007. $purchase = $this->purchase->find_all();
  6008. foreach ($purchase as $k => $v) {
  6009. $prc[$v['id']] = $v['title'];
  6010. }
  6011. $post = $this->input->post(NULL, TRUE);
  6012. if (isset($post['page'])) {
  6013. $page = $this->input->post('page', true);
  6014. $perpage = $this->input->post('perpage', true);
  6015. $sku = $this->input->post('sku', true);
  6016. $bs = $this->input->post('bs', true);
  6017. $number = $this->input->post('number', true);
  6018. $warehouse = $this->input->post('warehouse', true);
  6019. $purchase = $this->input->post('purchase', true);
  6020. $orderinfo = $this->input->post('orderinfo', true);
  6021. $waybill = $this->input->post('waybill', true);
  6022. $category = $this->input->post('category', true);
  6023. $size = $this->input->post('size', true);
  6024. $grade = $this->input->post('grade', true);
  6025. $color = $this->input->post('color', true);
  6026. $lowe = $this->input->post('lowe', true);
  6027. $state = $this->input->post('state', true);
  6028. $label = $this->input->post('label', true);
  6029. $timetk = $this->input->post('ktime', true);
  6030. $timetj = $this->input->post('jtime', true);
  6031. $timetk = strtotime($timetk);
  6032. $timetj = strtotime($timetj);
  6033. $where = "state=1 ";
  6034. if ($timetk && $timetj) {
  6035. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6036. }
  6037. if ($sku) {
  6038. $where .= " and sku = '$sku'";
  6039. }
  6040. if ($bs != '') {
  6041. $where .= " and bs = '$bs'";
  6042. }
  6043. if ($number) {
  6044. $where .= " and number = '$number'";
  6045. }
  6046. if ($warehouse) {
  6047. $where .= " and warehouse = '$warehouse'";
  6048. }
  6049. if ($purchase) {
  6050. $where .= " and purchase = '$purchase'";
  6051. }
  6052. if ($orderinfo) {
  6053. $where .= " and orderinfo = '$orderinfo'";
  6054. }
  6055. if ($waybill) {
  6056. $where .= " and waybill = '$waybill'";
  6057. }
  6058. if ($category) {
  6059. $where .= " and features like '%-$category-%'";
  6060. }
  6061. if ($size) {
  6062. $where .= " and features like '%-$size-%'";
  6063. }
  6064. if ($grade) {
  6065. $where .= " and features like '%-$grade-%'";
  6066. }
  6067. if ($color) {
  6068. $where .= " and features like '%-$color-%'";
  6069. }
  6070. if ($lowe) {
  6071. $where .= " and features like '%-$lowe-%'";
  6072. }
  6073. if ($label) {
  6074. $where .= " and label = '$label'";
  6075. }
  6076. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6077. //数据排序
  6078. $order_str = "outk desc";
  6079. if (empty($page)) {
  6080. $start = 0;
  6081. $perpage = 1;
  6082. } else {
  6083. $start = ($page - 1) * $perpage;
  6084. }
  6085. //取得信息列表
  6086. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6087. foreach ($info_list as $key => $value) {
  6088. $warehouse = $this->warehouse->read($value['warehouse']);
  6089. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6090. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6091. if ($value['state'] == 0) {
  6092. $info_list[$key]['state'] = "在库";
  6093. } else if ($value['state'] == 1) {
  6094. $info_list[$key]['state'] = "出库";
  6095. } else if ($value['state'] == 2) {
  6096. $info_list[$key]['state'] = "退库";
  6097. } else if ($value['state'] == 3) {
  6098. $info_list[$key]['state'] = "调拨中";
  6099. } else if ($value['state'] == 4) {
  6100. $info_list[$key]['state'] = "再加工";
  6101. } else if ($value['state'] == 5) {
  6102. $info_list[$key]['state'] = "维修中";
  6103. } else if ($value['state'] == 6) {
  6104. $info_list[$key]['state'] = "盘亏";
  6105. } else if ($value['state'] == 7) {
  6106. $info_list[$key]['state'] = "更换标签";
  6107. } else if ($value['state'] == 8) {
  6108. $info_list[$key]['state'] = "其它";
  6109. } else if ($value['state'] == 9) {
  6110. $info_list[$key]['state'] = "预设";
  6111. } else if ($value['state'] == 10) {
  6112. $info_list[$key]['state'] = "美店零售";
  6113. }
  6114. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6115. }
  6116. $total = $this->$ck->find_count($where);
  6117. $pagenum = ceil($total / $perpage);
  6118. $over = $total - ($start + $perpage);
  6119. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6120. echo json_encode($rows);
  6121. exit;
  6122. }
  6123. if (isset($post['tmsku'])) {
  6124. $time = time();
  6125. $tmsku = $this->input->post('tmsku', true);
  6126. //$post['shop'] = $this->input->post('shop',true);
  6127. $num = $this->input->post('num', true);
  6128. $cktype = $this->input->post('cktype', true);
  6129. $label = $this->whlabellabel->get_label($tmsku);
  6130. if (!$cktype) {
  6131. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6132. }
  6133. if (!isset($label['warehouse'])) {
  6134. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6135. exit;
  6136. }
  6137. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6138. if (stripos($label['features'], '-126-') !== false) {
  6139. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6140. } else {
  6141. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and purchase = '" . $label['purchase'] . "' and zd = ''");
  6142. }
  6143. $j = 0;
  6144. if (count($ck) >= $num) {
  6145. for ($i = 0; $i < $num; $i++) {
  6146. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6147. {
  6148. $j++;
  6149. }
  6150. }
  6151. if ($j == $num) {
  6152. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6153. exit;
  6154. } else {
  6155. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6156. exit;
  6157. }
  6158. } else {
  6159. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6160. exit;
  6161. }
  6162. }
  6163. $this->_Template('whlabel_printck', $this->data);
  6164. }
  6165. public function _printexcel()
  6166. {
  6167. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6168. $config['upload_path'] = '.' . $dir;
  6169. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6170. $config['allowed_types'] = 'xls|xlsx|csv';
  6171. $config['max_size'] = 10240;
  6172. $this->load->library('upload', $config);
  6173. $this->upload->initialize($config);
  6174. if ($this->upload->do_upload('userfile')) {
  6175. $full_path = $dir . $this->upload->data('file_name');
  6176. $fileName = '.' . $full_path;
  6177. if (!file_exists($fileName)) {
  6178. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6179. exit;
  6180. } else {
  6181. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6182. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6183. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6184. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6185. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6186. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6187. ++$column; //如果列数大于26行
  6188. $list = array();
  6189. for ($i = 2; $i <= $row; $i++) // 行数循环
  6190. {
  6191. $data = array();
  6192. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6193. {
  6194. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6195. }
  6196. $list[] = $data;
  6197. }
  6198. }
  6199. $ed = array();
  6200. $i = 0;
  6201. $j = 0;
  6202. $dcdata = array();
  6203. $yc = '';
  6204. $cmf_arr = array_column($list, '1');
  6205. array_multisort($cmf_arr, SORT_ASC, $list);
  6206. foreach ($list as $key => $value) {
  6207. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6208. if ($typeclass) {
  6209. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6210. } else {
  6211. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6212. $i++;
  6213. continue;
  6214. }
  6215. }
  6216. if ($i > 0) {
  6217. $yc = $i . '条异常';
  6218. }
  6219. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6220. exit;
  6221. }
  6222. }
  6223. public function _uck()
  6224. {
  6225. if (isset($_GET['excel'])) {
  6226. $tc = array();
  6227. $typeclass = $this->typeclass->find_all();
  6228. foreach ($typeclass as $v) {
  6229. $tc[$v['id']] = $v['zh'];
  6230. }
  6231. $data = array();
  6232. $t = array();
  6233. $rq = '';
  6234. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6235. $ts = $ts / (24 * 3600);
  6236. for ($i = 0; $i < $ts; $i++) {
  6237. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6238. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6239. }
  6240. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6241. foreach ($info_list as $k => $v) {
  6242. $features = explode('-', trim($v['features'], '-'));
  6243. if (!isset($features[3]) || !isset($features[4])) {
  6244. continue;
  6245. }
  6246. $data[$k][0] = $tc[$features[0]]; //类型
  6247. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6248. $data[$k][2] = $tc[$features[4]]; //曲度
  6249. $data[$k][3] = '';
  6250. if (isset($data[$k][1])) {
  6251. $data[$k][3] .= $data[$k][1];
  6252. }
  6253. if (isset($data[$k][2])) {
  6254. $data[$k][3] .= $data[$k][2];
  6255. }
  6256. if (isset($features[5])) {
  6257. $data[$k][3] .= $tc[$features[5]];
  6258. }
  6259. if (isset($features[2])) {
  6260. $data[$k][3] .= $tc[$features[2]];
  6261. }
  6262. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6263. $data[$k][4] = $v['sku'];
  6264. $data[$k][5] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and (state = 0 or (state = 1 and outk > ' . strtotime(date("Y-m", time())) . '))'); //月初库存
  6265. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6266. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6267. $ztrq = '';
  6268. $ztsl = '';
  6269. if (count($zt) > 0) {
  6270. foreach ($zt as $vv) {
  6271. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6272. $ztsl .= $vv['num'] . '<br>';
  6273. }
  6274. }
  6275. $data[$k][] = trim($ztsl, '<br>');
  6276. $data[$k][] = trim($ztrq, '<br>');
  6277. $byck = 0;
  6278. foreach ($t as $vv) {
  6279. $sl = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and state = 1 and outk > ' . strtotime($vv) . ' and outk < ' . (strtotime($vv) + 24 * 3600));
  6280. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6281. $byck += $sl;
  6282. }
  6283. $data[$k][] = ($byck > 0) ? $byck : '';
  6284. }
  6285. $title = "详情 " . date("Y-m-d", time());
  6286. $titlename = "<table border=1>
  6287. <tr align='center'>
  6288. <td>类别</td>
  6289. <td>颜色</td>
  6290. <td>曲度</td>
  6291. <td>名称</td>
  6292. <td>SKU</td>
  6293. <td>月初库存</td>
  6294. <td>剩余库存</td>
  6295. <td>在途数量</td>
  6296. <td>预达日期</td>" .
  6297. $rq
  6298. . "<td>本月出库</td></tr>
  6299. </table>";
  6300. $filename = $title . ".xls";
  6301. $tail = "";
  6302. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6303. }
  6304. }
  6305. public function _whlabelexcelzh()
  6306. {
  6307. if (isset($_GET['excel'])) {
  6308. $where = "sku != 'Preset'";
  6309. //数据排序
  6310. $order_str = "id desc";
  6311. if (empty($page)) {
  6312. $start = 0;
  6313. $perpage = 1;
  6314. } else {
  6315. $start = ($page - 1) * $perpage;
  6316. }
  6317. $category = $this->input->get('category', true);
  6318. $warehouse = $this->input->get('warehouse', true);
  6319. $excelid = $this->input->get('sid', true);
  6320. if ($category) {
  6321. $where .= " and features like '%-$category-%'";
  6322. }
  6323. if ($warehouse) {
  6324. $where .= " and warehouse = '$warehouse'";
  6325. }
  6326. $xzid = '';
  6327. if ($excelid) {
  6328. $excelid = explode(',', trim($excelid, ','));
  6329. foreach ($excelid as $key => $value) {
  6330. $xzid .= " id = " . $value . " or";
  6331. }
  6332. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6333. }
  6334. //取得信息列表
  6335. /**
  6336. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6337. $rows = array();$list = array();
  6338. foreach ($info_list as $key=>$value)
  6339. {
  6340. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6341. }
  6342. **/
  6343. $list = array();
  6344. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6345. foreach ($rows as $key => $value) {
  6346. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6347. $zh = '';
  6348. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6349. foreach ($zt as $v) {
  6350. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6351. }
  6352. $zt = array_sum(array_column($zt, 'num'));
  6353. $number = $value['number'];
  6354. $ftime = time() - 15 * 24 * 3600;
  6355. $warehouse = $this->warehouse->read($value['warehouse']);
  6356. $rows[$key]['warehouse'] = $warehouse['title'];
  6357. $rows[$key]['number'] = $c;
  6358. $rows[$key]['features'] = $zh;
  6359. $rows[$key]['hb'] = $c + $zt;
  6360. }
  6361. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6362. $titlename = "<table border=1>
  6363. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6364. <tr align='center'>
  6365. <td>仓库</td>
  6366. <td>SKU</td>
  6367. <td>产品</td>
  6368. <td>库存数量</td>
  6369. <td>在途数量及预达日期</td>
  6370. <td>在途+库存数量</td>
  6371. </tr>
  6372. </table>";
  6373. $filename = $title . ".xls";
  6374. $tail = "";
  6375. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6376. }
  6377. if (isset($_GET['excel'])) {
  6378. $warehouse = $this->input->get('warehouse', true);
  6379. $sku = $this->input->get('sku', true);
  6380. $cz = $this->input->get('cz', true);
  6381. $text = $this->input->post('text', true);
  6382. $xztime = $this->input->get('xztime', true);
  6383. $timetk = $this->input->get('timetk', true);
  6384. $timetj = $this->input->get('timetj', true);
  6385. $timetk = strtotime($timetk);
  6386. $timetj = strtotime($timetj);
  6387. $where = "time = '0' ";
  6388. if ($warehouse) {
  6389. $where .= " and warehouse = '$warehouse'";
  6390. }
  6391. if ($sku) {
  6392. $where .= " and sku = '$sku'";
  6393. }
  6394. if ($text) {
  6395. $where .= " and text like '%$text%'";
  6396. }
  6397. if ($cz != '') {
  6398. $where .= " and cz = '$cz'";
  6399. }
  6400. if ($timetk && $timetj) {
  6401. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6402. }
  6403. //数据排序
  6404. $order_str = $xztime . " desc";
  6405. //取得信息列表
  6406. $zh = array();
  6407. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6408. foreach ($info_list as $v) {
  6409. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6410. $warehouse = $this->warehouse->read($v['warehouse']);
  6411. $v['warehouse'] = $warehouse['title'];
  6412. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6413. $v['stime'] = date('Y-m-d', $v['stime']);
  6414. if (isset($zh[$v['features']])) {
  6415. $zh[$v['features']]['num'] += $v['num'];
  6416. } else {
  6417. $zh[$v['features']] = $v;
  6418. }
  6419. $zh[$v['features']]['features'] = $c;
  6420. }
  6421. $title = "在途数据" . date('Y-m-d', time());
  6422. $titlename = "<table border=1>
  6423. <tr align='center'>
  6424. <td>仓库</td>
  6425. <td>SKU</td>
  6426. <td>名称</td>
  6427. <td>在途数量</td>
  6428. <td>库存数量</td>
  6429. <td>添加在途日期</td>
  6430. <td>预达日期</td>
  6431. <td>备注</td>
  6432. </tr>
  6433. </table>";
  6434. $filename = $title . ".xls";
  6435. $tail = "";
  6436. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6437. }
  6438. }
  6439. public function _fc()
  6440. {
  6441. $vip = 0;
  6442. if (isset($_SESSION['api'])) {
  6443. $user = $this->user->get_api($_SESSION['api']);
  6444. if ($user['vip'] == 1) {
  6445. $vip = 1;
  6446. }
  6447. } else {
  6448. header('Location: /');
  6449. exit;
  6450. }
  6451. $post = $this->input->post(NULL, TRUE);
  6452. if (isset($post['page'])) {
  6453. $page = $this->input->post('page', true);
  6454. $perpage = $this->input->post('perpage', true);
  6455. $category = $this->input->post('category', true);
  6456. $size = $this->input->post('size', true);
  6457. $grade = $this->input->post('grade', true);
  6458. $color = $this->input->post('color', true);
  6459. $lowe = $this->input->post('lowe', true);
  6460. $sku = $this->input->post('sku');
  6461. $title = $this->input->post('title');
  6462. $warehouse = $this->input->post('warehouse', true);
  6463. $usa = $this->input->post('usa', true);
  6464. $purchase = $this->input->post('purchase', true);
  6465. $lacetype = $this->input->post('lacetype', true);
  6466. $haircap = $this->input->post('haircap', true);
  6467. $density = $this->input->post('density', true);
  6468. $details = $this->input->post('details', true);
  6469. $state = $this->input->post('state', true);
  6470. $ktime = $this->input->post('ktime', true);
  6471. $jtime = $this->input->post('jtime', true);
  6472. $ktime = strtotime($ktime);
  6473. $jtime = strtotime($jtime);
  6474. $where = "state = '11'";
  6475. $gj = "";
  6476. $ck = "";
  6477. if ($lacetype) {
  6478. $where .= " and features like '%-$lacetype-%'";
  6479. }
  6480. if ($category) {
  6481. $where .= " and features like '%-$category-%'";
  6482. }
  6483. if ($size) {
  6484. $where .= " and features like '%-$size-%'";
  6485. }
  6486. if ($grade) {
  6487. $where .= " and features like '%-$grade-%'";
  6488. }
  6489. if ($color) {
  6490. $where .= " and features like '%-$color-%'";
  6491. }
  6492. if ($lowe) {
  6493. $where .= " and features like '%-$lowe-%'";
  6494. }
  6495. if ($haircap) {
  6496. $where .= " and features like '%-$haircap-%'";
  6497. }
  6498. if ($density) {
  6499. $where .= " and features like '%-$density-%'";
  6500. }
  6501. if ($usa) {
  6502. if (!$warehouse) {
  6503. $where .= " and (warehouse = '5' or warehouse = '8')";
  6504. }
  6505. }
  6506. if ($warehouse) {
  6507. $where .= " and warehouse = '$warehouse'";
  6508. }
  6509. if ($details) {
  6510. $where .= " and details = '$details'";
  6511. }
  6512. if ($purchase) {
  6513. $where .= " and purchase = '$purchase'";
  6514. }
  6515. if ($state) {
  6516. $where .= " and state = '$state'";
  6517. }
  6518. if ($ktime && $jtime) {
  6519. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6520. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6521. }
  6522. //数据排序
  6523. $order_str = "id desc";
  6524. if (empty($page)) {
  6525. $start = 0;
  6526. $perpage = 1;
  6527. } else {
  6528. $start = ($page - 1) * $perpage;
  6529. }
  6530. if ($sku) {
  6531. $sku = trim($sku, ' ');
  6532. $sku = trim($sku, ' ');
  6533. $where .= " and sku like '%$sku%'";
  6534. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6535. } else if ($title) {
  6536. $title = trim($title, ' ');
  6537. $title = trim($title, ' ');
  6538. $where .= " and title like '%$title%'";
  6539. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6540. } else {
  6541. //$where .= " and time > '$ktime' and time < '$jtime'";
  6542. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6543. }
  6544. //取得信息列表
  6545. $rows = array();
  6546. $list = array();
  6547. foreach ($info_list as $key => $value) {
  6548. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  6549. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6550. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6551. $warehouse = $this->warehouse->read($value['warehouse']);
  6552. $info_list[$key]['warehouse'] = $warehouse['title'];
  6553. $info_list[$key]['number'] = $g;
  6554. $info_list[$key]['features'] = $x;
  6555. $info_list[$key]['x'] = $s;
  6556. }
  6557. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6558. $pagenum = ceil($total / $perpage);
  6559. $over = $total - ($start + $perpage);
  6560. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6561. echo json_encode($rows);
  6562. exit;
  6563. }
  6564. $this->data['vip'] = $vip;
  6565. $this->_Template('whlabel_fc', $this->data);
  6566. }
  6567. public function _fcmb()
  6568. {
  6569. $where = "sku != 'Preset'";
  6570. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6571. foreach ($rows as $k => $v) {
  6572. $warehouse = $this->warehouse->read($v['warehouse']);
  6573. $rows[$k]['warehouse'] = $warehouse['title'];
  6574. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6575. $rows[$k]['t'] = '';
  6576. $rows[$k]['n'] = '';
  6577. }
  6578. $title = "封货产品数据导入模板";
  6579. $titlename = "<table border=1>
  6580. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6581. <tr align='center'>
  6582. <td>仓库</td>
  6583. <td>SKU</td>
  6584. <td>产品</td>
  6585. <td>封存产品总数量</td>
  6586. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6587. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6588. </tr>
  6589. </table>";
  6590. $filename = $title . ".xls";
  6591. $tail = "";
  6592. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6593. }
  6594. public function _fcexcel()
  6595. {
  6596. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6597. $config['upload_path'] = '.' . $dir;
  6598. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6599. $config['allowed_types'] = 'xls|xlsx|csv';
  6600. $config['max_size'] = 10240;
  6601. $this->load->library('upload', $config);
  6602. $this->upload->initialize($config);
  6603. if ($this->upload->do_upload('userfile')) {
  6604. $full_path = $dir . $this->upload->data('file_name');
  6605. $fileName = '.' . $full_path;
  6606. if (!file_exists($fileName)) {
  6607. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6608. exit;
  6609. } else {
  6610. libxml_use_internal_errors(true);
  6611. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6612. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6613. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6614. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6615. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6616. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6617. ++$column; //如果列数大于26行
  6618. $list = array();
  6619. for ($i = 2; $i <= $row; $i++) // 行数循环
  6620. {
  6621. $data = array();
  6622. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6623. {
  6624. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6625. }
  6626. $list[] = $data;
  6627. }
  6628. }
  6629. $i = 0;
  6630. $j = 0;
  6631. $ed = array();
  6632. foreach ($list as $key => $value) {
  6633. $time = time();
  6634. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6635. continue;
  6636. }
  6637. $warehouse = $this->warehouse->get_title($value['0']);
  6638. $sku = $value['1'];
  6639. $type = $value['4']; //调整方式0扣减1删除
  6640. $num = $value['5']; //调整数量
  6641. //$text = $value['4'];//扣减说明
  6642. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6643. if (!$d) //如果没有这个SKU
  6644. {
  6645. $ed[] = array($sku . '-库存中不存在此SKU');
  6646. $j++;
  6647. continue;
  6648. }
  6649. if (!isset($warehouse['id'])) {
  6650. $ed[] = array($sku . '-仓库名错误!');
  6651. $j++;
  6652. continue;
  6653. }
  6654. if ($type == 1 || $type == 2) //扣减库存
  6655. {
  6656. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6657. if (count($data) < abs($num)) {
  6658. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6659. $j++;
  6660. continue;
  6661. }
  6662. if ($type == 1) //转入库存
  6663. {
  6664. for ($i = 0; $i < abs($num); $i++) {
  6665. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6666. }
  6667. } else if ($type == 2) //删除
  6668. {
  6669. for ($i = 0; $i < abs($num); $i++) {
  6670. $this->whlabel->remove($data[$i]['id']);
  6671. }
  6672. }
  6673. } else if ($type == 0) //增加库存
  6674. {
  6675. $post['sku'] = $d['sku'];
  6676. $post['shop'] = '';
  6677. $post['warehouse'] = $warehouse['id'];
  6678. $post['purchase'] = $d['purchase'];
  6679. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6680. $post['state'] = 11;
  6681. $post['title'] = $d['title'];
  6682. $post['number'] = $d['number'];
  6683. $post['features'] = $d['features'];
  6684. $post['enter'] = $time;
  6685. $post['time'] = $time; //操作时间
  6686. for ($i = 0; $i < $num; $i++) {
  6687. $post['label'] = time() . rand(100, 999) . $i;
  6688. $this->whlabel->insert($post);
  6689. }
  6690. }
  6691. sleep(1); //防止入库时间一样,需要延迟1秒
  6692. }
  6693. if ($j > 0) {
  6694. $tt = date('Ymd', time());
  6695. $title = '库存导入错误信息-' . $tt;
  6696. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6697. $tail = "\n";
  6698. $filename = $title . ".xls";
  6699. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6700. $dir = '/data/excel/' . $time . '/';
  6701. $file_name = 'error_' . $time . rand(1000, 9999);
  6702. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6703. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6704. fwrite($myfile, $ecl);
  6705. fclose($myfile);
  6706. $error = $dir . $file_name . '.xls';
  6707. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6708. exit;
  6709. } else {
  6710. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6711. exit;
  6712. }
  6713. }
  6714. }
  6715. public function _fcjxc($arg_array)
  6716. {
  6717. if (isset($_GET['excel'])) {
  6718. $category = $this->input->get('category', true);
  6719. $size = $this->input->get('size', true);
  6720. $grade = $this->input->get('grade', true);
  6721. $color = $this->input->get('color', true);
  6722. $lowe = $this->input->get('lowe', true);
  6723. $sku = $this->input->get('sku');
  6724. $title = $this->input->get('title');
  6725. $warehouse = $arg_array[0];
  6726. $usa = $this->input->get('usa', true);
  6727. $purchase = $this->input->get('purchase', true);
  6728. $lacetype = $this->input->get('lacetype', true);
  6729. $haircap = $this->input->get('haircap', true);
  6730. $density = $this->input->get('density', true);
  6731. $title = $this->input->get('title', true);
  6732. $state = $this->input->get('state', true);
  6733. $ktime = $this->input->get('ktime', true);
  6734. $jtime = $this->input->get('jtime', true);
  6735. $where = "state=11";
  6736. $gj = "";
  6737. $ck = "";
  6738. if ($lacetype) {
  6739. $where .= " and features like '%-$lacetype-%'";
  6740. }
  6741. if ($category) {
  6742. $where .= " and features like '%-$category-%'";
  6743. }
  6744. if ($size) {
  6745. $where .= " and features like '%-$size-%'";
  6746. }
  6747. if ($grade) {
  6748. $where .= " and features like '%-$grade-%'";
  6749. }
  6750. if ($color) {
  6751. $where .= " and features like '%-$color-%'";
  6752. }
  6753. if ($lowe) {
  6754. $where .= " and features like '%-$lowe-%'";
  6755. }
  6756. if ($haircap) {
  6757. $where .= " and features like '%-$haircap-%'";
  6758. }
  6759. if ($density) {
  6760. $where .= " and features like '%-$density-%'";
  6761. }
  6762. if ($usa) {
  6763. if (!$warehouse) {
  6764. $where .= " and (warehouse = '5' or warehouse = '8')";
  6765. }
  6766. }
  6767. if ($warehouse) {
  6768. $where .= " and warehouse = '$warehouse'";
  6769. }
  6770. if ($purchase) {
  6771. $where .= " and purchase = '$purchase'";
  6772. }
  6773. if ($state) {
  6774. $where .= " and state = '$state'";
  6775. }
  6776. $order_str = "id desc";
  6777. if ($sku) {
  6778. $sku = trim($sku, ' ');
  6779. $sku = trim($sku, ' ');
  6780. $where .= " and sku like '%$sku%'";
  6781. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6782. } else if ($title) {
  6783. $title = trim($title, ' ');
  6784. $title = trim($title, ' ');
  6785. $where .= " and title like '%$title%'";
  6786. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6787. } else {
  6788. //$where .= " and time > '$ktime' and time < '$jtime'";
  6789. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6790. }
  6791. //取得信息列表
  6792. $rows = array();
  6793. $list = array();
  6794. foreach ($info_list as $key => $value) {
  6795. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  6796. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6797. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6798. $rows[$key] = $value;
  6799. $warehouse = $this->warehouse->read($value['warehouse']);
  6800. $rows[$key]['warehouse'] = $warehouse['title'];
  6801. $rows[$key]['features'] = $g;
  6802. $rows[$key]['a'] = $x;
  6803. $rows[$key]['b'] = $s;
  6804. }
  6805. $title = "总统计表";
  6806. $titlename = "<table border=1>
  6807. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6808. <tr align='center'>
  6809. <td>仓库</td>
  6810. <td>SKU</td>
  6811. <td>产品名称</td>
  6812. <td>录入总量</td>
  6813. <td>取出总量</td>
  6814. <td>剩余总量</td>
  6815. </tr>
  6816. </table>";
  6817. $filename = $title . ".xls";
  6818. $tail = "";
  6819. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6820. }
  6821. $vip = 0;
  6822. if (isset($_SESSION['api'])) {
  6823. $user = $this->user->get_api($_SESSION['api']);
  6824. if ($user['vip'] == 1) {
  6825. $vip = 1;
  6826. }
  6827. } else {
  6828. header('Location: /');
  6829. exit;
  6830. }
  6831. $post = $this->input->post(NULL, TRUE);
  6832. if (isset($post['page'])) {
  6833. $page = $this->input->post('page', true);
  6834. $perpage = $this->input->post('perpage', true);
  6835. $category = $this->input->post('category', true);
  6836. $size = $this->input->post('size', true);
  6837. $grade = $this->input->post('grade', true);
  6838. $color = $this->input->post('color', true);
  6839. $lowe = $this->input->post('lowe', true);
  6840. $sku = $this->input->post('sku');
  6841. $title = $this->input->post('title');
  6842. $warehouse = $arg_array[0];
  6843. $usa = $this->input->post('usa', true);
  6844. $purchase = $this->input->post('purchase', true);
  6845. $lacetype = $this->input->post('lacetype', true);
  6846. $haircap = $this->input->post('haircap', true);
  6847. $density = $this->input->post('density', true);
  6848. $title = $this->input->post('title', true);
  6849. $state = $this->input->post('state', true);
  6850. $ktime = $this->input->post('ktime', true);
  6851. $jtime = $this->input->post('jtime', true);
  6852. $ktime = strtotime($ktime);
  6853. $jtime = strtotime($jtime);
  6854. $where = "state=11";
  6855. $gj = "";
  6856. $ck = "";
  6857. if ($lacetype) {
  6858. $where .= " and features like '%-$lacetype-%'";
  6859. }
  6860. if ($category) {
  6861. $where .= " and features like '%-$category-%'";
  6862. }
  6863. if ($size) {
  6864. $where .= " and features like '%-$size-%'";
  6865. }
  6866. if ($grade) {
  6867. $where .= " and features like '%-$grade-%'";
  6868. }
  6869. if ($color) {
  6870. $where .= " and features like '%-$color-%'";
  6871. }
  6872. if ($lowe) {
  6873. $where .= " and features like '%-$lowe-%'";
  6874. }
  6875. if ($haircap) {
  6876. $where .= " and features like '%-$haircap-%'";
  6877. }
  6878. if ($density) {
  6879. $where .= " and features like '%-$density-%'";
  6880. }
  6881. if ($usa) {
  6882. if (!$warehouse) {
  6883. $where .= " and (warehouse = '5' or warehouse = '8')";
  6884. }
  6885. }
  6886. if ($warehouse) {
  6887. $where .= " and warehouse = '$warehouse'";
  6888. }
  6889. if ($purchase) {
  6890. $where .= " and purchase = '$purchase'";
  6891. }
  6892. if ($state) {
  6893. $where .= " and state = '$state'";
  6894. }
  6895. if ($ktime && $jtime) {
  6896. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6897. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6898. }
  6899. //数据排序
  6900. $order_str = "id desc";
  6901. $xs = 0;
  6902. $rows = array();
  6903. $list = array();
  6904. if (empty($page)) {
  6905. $start = 0;
  6906. $perpage = 1;
  6907. } else {
  6908. $start = ($page - 1) * $perpage;
  6909. }
  6910. if ($sku || $title) {
  6911. if ($title) {
  6912. $title = trim($title, ' ');
  6913. $title = trim($title, ' ');
  6914. $where .= " and title like '%$title%'";
  6915. } else {
  6916. $sku = trim($sku, ' ');
  6917. $sku = trim($sku, ' ');
  6918. $where .= " and sku like '%$sku%'";
  6919. }
  6920. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6921. foreach ($info_list as $key => $value) {
  6922. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  6923. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6924. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6925. $rows[$key] = $value;
  6926. $warehouse = $this->warehouse->read($value['warehouse']);
  6927. $rows[$key]['warehouse'] = $warehouse['title'];
  6928. $rows[$key]['features'] = $g;
  6929. $rows[$key]['a'] = $x;
  6930. $rows[$key]['b'] = $s;
  6931. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6932. $xl = $this->whlabel->find_count($where . " and outk > '" . (time() - 30 * 24 * 3600) . "' and outk < '" . time() . "'" . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"'); //30天销量
  6933. $yj = $c / ($xl / 30);
  6934. if ($yj < 7) {
  6935. $rows[$key]['y'] = round($yj) . '天销量';
  6936. } else {
  6937. $rows[$key]['y'] = '正常';
  6938. }
  6939. }
  6940. } else {
  6941. //$where .= " and time > '$ktime' and time < '$jtime'";
  6942. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6943. foreach ($info_list as $key => $value) {
  6944. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  6945. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6946. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6947. $zs[$key] = $value;
  6948. $warehouse = $this->warehouse->read($value['warehouse']);
  6949. $zs[$key]['warehouse'] = $warehouse['title'];
  6950. $zs[$key]['features'] = $g;
  6951. $zs[$key]['a'] = $x;
  6952. $zs[$key]['b'] = $s;
  6953. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6954. $xl = $this->whlabel->find_count($where . " and outk > '" . (time() - 30 * 24 * 3600) . "' and outk < '" . time() . "'" . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"'); //30天销量
  6955. $yj = $c / ($xl / 30);
  6956. if ($yj < 7) {
  6957. $zs[$key]['y'] = round($yj) . '天销量';
  6958. $rows[$key] = $zs[$key];
  6959. }
  6960. }
  6961. }
  6962. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6963. $pagenum = ceil($total / $perpage);
  6964. $over = $total - ($start + $perpage);
  6965. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6966. echo json_encode($rows);
  6967. exit;
  6968. }
  6969. $this->data['arg_array'] = $arg_array[0];
  6970. $this->_Template('whlabel_fcjxc', $this->data);
  6971. }
  6972. public function _0kcdel()
  6973. {
  6974. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6975. $config['upload_path'] = '.' . $dir;
  6976. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6977. $config['allowed_types'] = 'xls|xlsx|csv';
  6978. $config['max_size'] = 10240;
  6979. $this->load->library('upload', $config);
  6980. $this->upload->initialize($config);
  6981. if ($this->upload->do_upload('userfile')) {
  6982. $full_path = $dir . $this->upload->data('file_name');
  6983. $fileName = '.' . $full_path;
  6984. if (!file_exists($fileName)) {
  6985. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6986. exit;
  6987. } else {
  6988. require_once "./data/excel/PHPExcel/IOFactory.php";
  6989. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6990. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6991. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6992. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6993. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6994. ++$column; //如果列数大于26行
  6995. $list = array();
  6996. for ($i = 2; $i <= $row; $i++) // 行数循环
  6997. {
  6998. $data = array();
  6999. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7000. {
  7001. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7002. }
  7003. $list[] = $data;
  7004. }
  7005. }
  7006. $i = 0;
  7007. $j = 0;
  7008. $ed = array();
  7009. foreach ($list as $key => $value) {
  7010. $time = time();
  7011. if ($value['0'] == "" || $value['1'] == "") {
  7012. continue;
  7013. }
  7014. $warehouse = $this->warehouse->get_title($value['0']);
  7015. $sku = $value['1'];
  7016. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7017. if (!$d) //如果没有这个SKU
  7018. {
  7019. $ed[] = array($sku . '-库存中不存在此SKU');
  7020. $j++;
  7021. continue;
  7022. }
  7023. if (!isset($warehouse['id'])) {
  7024. $ed[] = array($sku . '-仓库名错误!');
  7025. $j++;
  7026. continue;
  7027. }
  7028. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7029. if ($z < 1) {
  7030. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7031. foreach ($z as $v) {
  7032. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7033. if (count($zt) > 0) {
  7034. $ed[] = array($sku . '-有在途库存无法删除!');
  7035. $j++;
  7036. continue;
  7037. }
  7038. $this->whlabel->remove($v['id']);
  7039. }
  7040. } else {
  7041. $ed[] = array($sku . '-非0库存!');
  7042. $j++;
  7043. continue;
  7044. }
  7045. }
  7046. if ($j > 0) {
  7047. $tt = date('Ymd', time());
  7048. $title = '删除0库存错误信息-' . $tt;
  7049. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7050. $tail = "\n";
  7051. $filename = $title . ".xls";
  7052. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7053. $dir = '/data/excel/' . $time . '/';
  7054. $file_name = 'error_' . $time . rand(1000, 9999);
  7055. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7056. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7057. fwrite($myfile, $ecl);
  7058. fclose($myfile);
  7059. $error = $dir . $file_name . '.xls';
  7060. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7061. exit;
  7062. } else {
  7063. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7064. exit;
  7065. }
  7066. }
  7067. }
  7068. public function _gbhtype()
  7069. {
  7070. $post = $this->input->post(NULL, TRUE);
  7071. if (isset($post['s'])) {
  7072. $n = $this->input->post('n');
  7073. $d = $this->input->post('s');
  7074. if (!$d) {
  7075. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7076. exit;
  7077. }
  7078. $d = explode(',', trim($d, ','));
  7079. $t = $this->whlabel_type->read($n);
  7080. //循环删除记录
  7081. foreach ($d as $v) {
  7082. $u = $this->whlabel->read($v);
  7083. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7084. foreach ($data as $val) {
  7085. $this->whlabel->save(array('type' => $n), $val['id']);
  7086. }
  7087. }
  7088. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7089. }
  7090. }
  7091. //出库、退库导出
  7092. public function _dccrtype()
  7093. {
  7094. $classid = $this->classid->sku();
  7095. $pm = $classid;
  7096. $typeclass = array();
  7097. $tc = $this->typeclass->find_all();
  7098. foreach ($tc as $v) {
  7099. $typeclass[$v['id']] = $v;
  7100. }
  7101. $prc = array();
  7102. $purchase = $this->purchase->find_all();
  7103. foreach ($purchase as $k => $v) {
  7104. $prc[$v['id']] = $v['title'];
  7105. }
  7106. if (isset($_GET['sid'])) {
  7107. $wh = array();
  7108. $w = $this->warehouse->find_all('1=1', 'id,title');
  7109. foreach ($w as $v) {
  7110. $wh[$v['id']] = $v['title'];
  7111. }
  7112. $type = $this->input->get('excel', true);
  7113. $category = $this->input->get('category', true);
  7114. $size = $this->input->get('size', true);
  7115. $grade = $this->input->get('grade', true);
  7116. $color = $this->input->get('color', true);
  7117. $lowe = $this->input->get('lowe', true);
  7118. $sku = $this->input->get('sku', true);
  7119. $warehouse = $this->input->get('warehouse', true);
  7120. $lacetype = $this->input->get('lacetype', true);
  7121. $lacecolor = $this->input->get('lacecolor', true);
  7122. $density = $this->input->get('density', true);
  7123. $haircap = $this->input->get('haircap', true);
  7124. $purchase = $this->input->get('purchase', true);
  7125. $title = $this->input->get('title', true);
  7126. $state = $this->input->get('state', true);
  7127. $sid = $this->input->get('sid', true);
  7128. $ktime = $this->input->get('ktime', true);
  7129. $jtime = $this->input->get('jtime', true);
  7130. $ktime = strtotime($ktime);
  7131. $jtime = strtotime($jtime);
  7132. $where = "1=1";
  7133. $gj = "";
  7134. $ck = "";
  7135. if ($category) {
  7136. $where .= " and features like '%-$category-%'";
  7137. }
  7138. if ($size) {
  7139. $where .= " and features like '%-$size-%'";
  7140. }
  7141. if ($grade) {
  7142. $where .= " and features like '%-$grade-%'";
  7143. }
  7144. if ($color) {
  7145. $where .= " and features like '%-$color-%'";
  7146. }
  7147. if ($lowe) {
  7148. $where .= " and features like '%-$lowe-%'";
  7149. }
  7150. if ($warehouse) {
  7151. $where .= " and warehouse = '$warehouse'";
  7152. }
  7153. if ($purchase) {
  7154. $where .= " and purchase = '$purchase'";
  7155. }
  7156. if ($state) {
  7157. $where .= " and state = '$state'";
  7158. }
  7159. if ($lacetype) {
  7160. $where .= " and features like '%-$lacetype-%'";
  7161. }
  7162. if ($lacecolor) {
  7163. $where .= " and features like '%-$lacecolor-%'";
  7164. }
  7165. if ($density) {
  7166. $where .= " and features like '%-$density-%'";
  7167. }
  7168. if ($haircap) {
  7169. $where .= " and features like '%-$haircap-%'";
  7170. }
  7171. if ($title) {
  7172. $title = trim($title, ' ');
  7173. $title = trim($title, ' ');
  7174. $where .= " and title like '%$title%'";
  7175. }
  7176. if ($sku) {
  7177. $sku = trim($sku, ' ');
  7178. $sku = trim($sku, ' ');
  7179. $where .= " and sku like '%$sku%'";
  7180. }
  7181. if ($ktime && $jtime) {
  7182. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7183. }
  7184. $sidwhere = '';
  7185. if ($sid) {
  7186. $sd = "";
  7187. $s = explode(',', trim($sid, ','));
  7188. foreach ($s as $value) {
  7189. $sd .= " id = " . $value . " or";
  7190. }
  7191. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7192. }
  7193. //数据排序
  7194. $order_str = "time desc";
  7195. if (empty($page)) {
  7196. $start = 0;
  7197. $perpage = 1;
  7198. } else {
  7199. $start = ($page - 1) * $perpage;
  7200. }
  7201. $wh = array();
  7202. $w = $this->warehouse->find_all('1=1', 'id,title');
  7203. foreach ($w as $v) {
  7204. $wh[$v['id']] = $v['title'];
  7205. }
  7206. $wt = array();
  7207. $whlabel_type = $this->whlabel_type->find_all();
  7208. foreach ($whlabel_type as $v) {
  7209. $wt[$v['id']] = $v['title'];
  7210. }
  7211. $classid = $this->classid->sku();
  7212. $list = array();
  7213. $rows_r = $this->whlabel->find_pc($where . " and enter > '$ktime' and enter < '$jtime' " . $sidwhere, 'sku,features,warehouse,enter', 'warehouse,sku,title,zh,features,time,enter,rktype,number,text');
  7214. foreach ($rows_r as $key => $value) {
  7215. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7216. $pm = $classid;
  7217. $jm = $classid;
  7218. $rows_r[$key]['enter'] = '入库';
  7219. $rows_r[$key]['time'] = $value['enter'];
  7220. if ($value['rktype'] == 1) {
  7221. $rows_r[$key]['rktype'] = '采购入库';
  7222. } else if ($value['rktype'] == 2) {
  7223. $rows_r[$key]['rktype'] = '盘盈调整';
  7224. } else if ($value['rktype'] == 3) {
  7225. $rows_r[$key]['rktype'] = '其他调整入库';
  7226. } else if ($value['rktype'] == 4) {
  7227. $rows_r[$key]['rktype'] = '其他调整入库';
  7228. } else if ($value['rktype'] == 5) {
  7229. $rows_r[$key]['rktype'] = '退库入库';
  7230. } else if ($value['rktype'] == 6) {
  7231. $rows_r[$key]['rktype'] = '退货可用入库';
  7232. } else if ($value['rktype'] == 7) {
  7233. $rows_r[$key]['rktype'] = '形态转换入库';
  7234. } else {
  7235. $rows_r[$key]['rktype'] = '';
  7236. }
  7237. $features = explode('-', trim($value['features'], '-'));
  7238. foreach ($features as $v) {
  7239. if (isset($typeclass[$v])) {
  7240. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7241. $pm[$typeclass[$v]['classid']] = $zh[0];
  7242. }
  7243. if (isset($typeclass[$v])) {
  7244. if (isset($jm[$typeclass[$v]['classid']])) {
  7245. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7246. }
  7247. }
  7248. }
  7249. $zh = implode(" ", $pm);
  7250. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7251. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7252. $rows_r[$key]['zh'] = $zh;
  7253. $jm = array_filter($jm);
  7254. $rows_r[$key]['features'] = implode("-", $jm);
  7255. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7256. }
  7257. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7258. foreach ($rows_c as $key => $value) {
  7259. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7260. $pm = $classid;
  7261. $jm = $classid;
  7262. $rows_c[$key]['time'] = $value['outk'];
  7263. $rows_c[$key]['outk'] = '出库';
  7264. if ($value['cktype'] == 1) {
  7265. $rows_c[$key]['cktype'] = '销售出库';
  7266. } else if ($value['cktype'] == 2) {
  7267. $rows_c[$key]['cktype'] = '销售美国出库';
  7268. } else if ($value['cktype'] == 3) {
  7269. $rows_c[$key]['cktype'] = '盘亏调整';
  7270. } else if ($value['cktype'] == 4) {
  7271. $rows_c[$key]['cktype'] = '其他调整出库';
  7272. } else if ($value['cktype'] == 5) {
  7273. $rows_c[$key]['cktype'] = '形态转换出库';
  7274. } else {
  7275. $rows_c[$key]['cktype'] = '';
  7276. }
  7277. $features = explode('-', trim($value['features'], '-'));
  7278. foreach ($features as $v) {
  7279. if (isset($typeclass[$v])) {
  7280. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7281. $pm[$typeclass[$v]['classid']] = $zh[0];
  7282. }
  7283. if (isset($typeclass[$v])) {
  7284. if (isset($jm[$typeclass[$v]['classid']])) {
  7285. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7286. }
  7287. }
  7288. }
  7289. $zh = implode(" ", $pm);
  7290. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7291. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7292. $rows_c[$key]['zh'] = $zh;
  7293. $jm = array_filter($jm);
  7294. $rows_c[$key]['features'] = implode("-", $jm);
  7295. $rows_c[$key]['number'] = 1;
  7296. }
  7297. $merged = $rows_r;
  7298. foreach ($rows_c as $key => $value) {
  7299. if (isset($merged[$key])) {
  7300. $merged[] = $value;
  7301. } else {
  7302. $merged[$key] = $value;
  7303. }
  7304. }
  7305. usort($merged, function ($a, $b) {
  7306. return $a['time'] - $b['time'];
  7307. });
  7308. foreach ($merged as $key => $value) {
  7309. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7310. }
  7311. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7312. $titlename = "<table border=1>
  7313. <tr align='center'>
  7314. <td>仓库</td>
  7315. <td>SKU</td>
  7316. <td>商品名称</td>
  7317. <td>仓库品名</td>
  7318. <td>料号</td>
  7319. <td>时间</td>
  7320. <td>操作</td>
  7321. <td>类型</td>
  7322. <td>数量</td>
  7323. <td>备注</td>
  7324. </tr>
  7325. </table>";
  7326. $filename = $title . ".xlsx";
  7327. $tail = "";
  7328. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7329. }
  7330. }
  7331. }