Whlabel.php 258 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497
  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. $sm = $this->input->post('sm', true);
  466. $cpbz = $this->input->post('cpbz', true);
  467. $type = $this->input->post('type', true);
  468. $ktime = strtotime($ktime);
  469. $jtime = strtotime($jtime);
  470. $where = "1=1";
  471. $gj = "";
  472. $ck = "";
  473. if ($usa) {
  474. if (!$warehouse) {
  475. $where .= " and (warehouse = '5' or warehouse = '8')";
  476. }
  477. }
  478. if ($warehouse) {
  479. $where .= " and warehouse = '$warehouse'";
  480. }
  481. if ($details) {
  482. $where .= " and details = '$details'";
  483. }
  484. if ($purchase) {
  485. $where .= " and purchase = '$purchase'";
  486. }
  487. if ($state) {
  488. $where .= " and state = '$state'";
  489. }
  490. if ($lacetype) {
  491. $where .= " and features like '%-$lacetype-%'";
  492. }
  493. if ($category) {
  494. $where .= " and features like '%-$category-%'";
  495. }
  496. if ($size) {
  497. $where .= " and features like '%-$size-%'";
  498. }
  499. if ($grade) {
  500. $where .= " and features like '%-$grade-%'";
  501. }
  502. if ($color) {
  503. $where .= " and features like '%-$color-%'";
  504. }
  505. if ($lowe) {
  506. $where .= " and features like '%-$lowe-%'";
  507. }
  508. if ($haircap) {
  509. $where .= " and features like '%-$haircap-%'";
  510. }
  511. if ($density) {
  512. $where .= " and features like '%-$density-%'";
  513. }
  514. if ($lacecolor) {
  515. $where .= " and features like '%-$lacecolor-%'";
  516. }
  517. if($sm){
  518. $where .= " and sm like '%".$sm."%'";
  519. }
  520. if($cpbz){
  521. $where .= " and cpbz like '%".$cpbz."%'";
  522. }
  523. if($type){
  524. $where .= " and type = ".$type."";
  525. }
  526. if (!empty($hairnumber)) {
  527. $where .= " and features like '%-128-%' ";
  528. if ($hairnumber < 0) {
  529. $class_list = $this->typeclass->find_all('classid = 43');
  530. foreach ($class_list as $v) {
  531. $where .= " and features not like '%-" . $v['id'] . "-%'";
  532. }
  533. } else {
  534. $where .= " and features like '%-$hairnumber-%'";
  535. }
  536. }
  537. $where_add = '';
  538. if ($cklx) {
  539. $shop = $this->shop->read($cklx);
  540. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  541. }
  542. if ($ktime && $jtime) {
  543. $gj = " and enter > '$ktime' and enter < '$jtime'";
  544. $ck = " and outk > '$ktime' and outk < '$jtime'";
  545. }
  546. //数据排序
  547. $order_str = "id desc";
  548. if (empty($page)) {
  549. $start = 0;
  550. $perpage = 1;
  551. } else {
  552. $start = ($page - 1) * $perpage;
  553. }
  554. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  555. if ($sku) {
  556. $sku = trim($sku, ' ');
  557. $sku = trim($sku, ' ');
  558. $where .= " and sku like '%$sku%'";
  559. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  560. } else if ($title) {
  561. $title = trim($title, ' ');
  562. $title = trim($title, ' ');
  563. $where .= " and title like '%$title%'";
  564. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  565. } else {
  566. //$where .= " and time > '$ktime' and time < '$jtime'";
  567. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  568. }
  569. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  570. foreach ($info_list as $k => $v) {
  571. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  572. unset($info_list[$k]['pm']);
  573. unset($info_list[$k]['jm']);
  574. unset($info_list[$k]['bm']);
  575. }
  576. //取得信息列表
  577. $rows = array();
  578. $list = array();
  579. foreach ($info_list as $key => $value) {
  580. $warehouse = $this->warehouse->read($value['warehouse']);
  581. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  582. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  583. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  584. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  585. $info_list[$key]['label'] = $value['sm'];
  586. $number = $value['number'];
  587. $ftime = time() - 15 * 24 * 3600;
  588. $info_list[$key]['warehouse'] = $warehouse['title'];
  589. $info_list[$key]['features'] = count($c);
  590. $z = count($z); //查看订单号
  591. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  592. $ztdata = '';
  593. if (count($zt) > 0) {
  594. foreach ($zt as $vv) {
  595. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  596. }
  597. }
  598. $info_list[$key]['number'] = $ztdata;
  599. $info_list[$key]['sm'] = $z;
  600. $details = array();
  601. $cpid = array();
  602. foreach ($c as $k => $v) {
  603. $details[$v['details']] = $v['details'];
  604. if ($v['cpid'] != 0) {
  605. $cpid[$v['cpid']] = $v['cpid'];
  606. }
  607. }
  608. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  609. if ($value['shop'] != '') {
  610. $shop = explode(',', trim($value['shop'], ','));
  611. $shop = $this->shop->read($shop[0]);
  612. $info_list[$key]['shop'] = $shop['shopname'];
  613. }
  614. }
  615. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  616. $pagenum = ceil($total / $perpage);
  617. $over = $total - ($start + $perpage);
  618. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  619. echo json_encode($rows);
  620. exit;
  621. }
  622. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  623. $this->_Template('whlabel_typedy', $this->data);
  624. }
  625. //进销存浏览
  626. public function _typedy_ck($arg_array)
  627. {
  628. $prc = array();
  629. $purchase = $this->purchase->find_all();
  630. foreach ($purchase as $k => $v) {
  631. $prc[$v['id']] = $v['title'];
  632. }
  633. $post = $this->input->post(NULL, TRUE);
  634. if (isset($post['page'])) {
  635. $page = $this->input->post('page', true);
  636. $perpage = $this->input->post('perpage', true);
  637. $category = $this->input->post('category', true);
  638. $size = $this->input->post('size', true);
  639. $grade = $this->input->post('grade', true);
  640. $color = $this->input->post('color', true);
  641. $lowe = $this->input->post('lowe', true);
  642. $sku = $this->input->post('sku');
  643. $title = $this->input->post('title');
  644. $warehouse = $this->input->post('warehouse', true);
  645. $usa = $this->input->post('usa', true);
  646. $purchase = $this->input->post('purchase', true);
  647. $lacetype = $this->input->post('lacetype', true);
  648. $haircap = $this->input->post('haircap', true);
  649. $density = $this->input->post('density', true);
  650. $details = $this->input->post('details', true);
  651. $state = $this->input->post('state', true);
  652. $lacecolor = $this->input->post('lacecolor', true);
  653. $cklx = $this->input->post('cklx', true);
  654. $ktime = $this->input->post('ktime', true);
  655. $jtime = $this->input->post('jtime', true);
  656. $ktime = strtotime($ktime);
  657. $jtime = strtotime($jtime);
  658. $where = "1=1";
  659. $gj = "";
  660. $ck = "";
  661. if ($lacetype) {
  662. $where .= " and features like '%-$lacetype-%'";
  663. }
  664. if ($category) {
  665. $where .= " and features like '%-$category-%'";
  666. }
  667. if ($size) {
  668. $where .= " and features like '%-$size-%'";
  669. }
  670. if ($grade) {
  671. $where .= " and features like '%-$grade-%'";
  672. }
  673. if ($color) {
  674. $where .= " and features like '%-$color-%'";
  675. }
  676. if ($lowe) {
  677. $where .= " and features like '%-$lowe-%'";
  678. }
  679. if ($haircap) {
  680. $where .= " and features like '%-$haircap-%'";
  681. }
  682. if ($density) {
  683. $where .= " and features like '%-$density-%'";
  684. }
  685. if ($lacecolor) {
  686. $where .= " and features like '%-$lacecolor-%'";
  687. }
  688. if ($usa) {
  689. if (!$warehouse) {
  690. $where .= " and (warehouse = '5' or warehouse = '8')";
  691. }
  692. }
  693. if ($warehouse) {
  694. $where .= " and warehouse = '$warehouse'";
  695. }
  696. if ($details) {
  697. $where .= " and details = '$details'";
  698. }
  699. if ($purchase) {
  700. $where .= " and purchase = '$purchase'";
  701. }
  702. if ($state) {
  703. $where .= " and state = '$state'";
  704. }
  705. $where_add = '';
  706. if ($cklx) {
  707. $shop = $this->shop->read($cklx);
  708. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  709. }
  710. if ($ktime && $jtime) {
  711. $gj = " and enter > '$ktime' and enter < '$jtime'";
  712. $ck = " and outk > '$ktime' and outk < '$jtime'";
  713. }
  714. //数据排序
  715. $order_str = "id desc";
  716. if (empty($page)) {
  717. $start = 0;
  718. $perpage = 1;
  719. } else {
  720. $start = ($page - 1) * $perpage;
  721. }
  722. if ($sku) {
  723. $sku = trim($sku, ' ');
  724. $sku = trim($sku, ' ');
  725. $where .= " and sku like '%$sku%'";
  726. $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);
  727. } else if ($title) {
  728. $title = trim($title, ' ');
  729. $title = trim($title, ' ');
  730. $where .= " and title like '%$title%'";
  731. $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);
  732. } else {
  733. //$where .= " and time > '$ktime' and time < '$jtime'";
  734. $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);
  735. }
  736. //取得信息列表
  737. $rows = array();
  738. $list = array();
  739. foreach ($info_list as $key => $value) {
  740. $warehouse = $this->warehouse->read($value['warehouse']);
  741. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  742. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  743. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  744. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  745. $ftime = time() - 15 * 24 * 3600;
  746. $info_list[$key]['warehouse'] = $warehouse['title'];
  747. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  748. //$z = count($z);//查看订单号
  749. //$info_list[$key]['zd'] = $z;
  750. $details = array();
  751. $cpid = array();
  752. foreach ($c as $k => $v) {
  753. $details[$v['details']] = $v['details'];
  754. if ($v['cpid'] != 0) {
  755. $cpid[$v['cpid']] = $v['cpid'];
  756. }
  757. }
  758. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  759. if ($value['shop'] != '') {
  760. $shop = explode(',', trim($value['shop'], ','));
  761. $shop = $this->shop->read($shop[0]);
  762. $info_list[$key]['shop'] = $shop['shopname'];
  763. }
  764. }
  765. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  766. $pagenum = ceil($total / $perpage);
  767. $over = $total - ($start + $perpage);
  768. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  769. echo json_encode($rows);
  770. exit;
  771. }
  772. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  773. $this->_Template('whlabel_typedy_ck', $this->data);
  774. }
  775. public function _typeck($arg_array)
  776. {
  777. $prc = array();
  778. $purchase = $this->purchase->find_all();
  779. foreach ($purchase as $k => $v) {
  780. $prc[$v['id']] = $v['title'];
  781. }
  782. $post = $this->input->post(NULL, TRUE);
  783. if (isset($post['page'])) {
  784. $page = $this->input->post('page', true);
  785. $perpage = $this->input->post('perpage', true);
  786. $category = $this->input->post('category', true);
  787. $size = $this->input->post('size', true);
  788. $grade = $this->input->post('grade', true);
  789. $color = $this->input->post('color', true);
  790. $lacecolor = $this->input->post('lacecolor', true);
  791. $lowe = $this->input->post('lowe', true);
  792. $sku = $this->input->post('sku');
  793. $title = $this->input->post('title');
  794. $warehouse = 13;
  795. $usa = $this->input->post('usa', true);
  796. $purchase = $this->input->post('purchase', true);
  797. $lacetype = $this->input->post('lacetype', true);
  798. $haircap = $this->input->post('haircap', true);
  799. $density = $this->input->post('density', true);
  800. $details = $this->input->post('details', true);
  801. $state = $this->input->post('state', true);
  802. $ktime = $this->input->post('ktime', true);
  803. $jtime = $this->input->post('jtime', true);
  804. $ktime = strtotime($ktime);
  805. $jtime = strtotime($jtime);
  806. $where = "1=1";
  807. $gj = "";
  808. $ck = "";
  809. if ($lacetype) {
  810. $where .= " and features like '%-$lacetype-%'";
  811. }
  812. if ($category) {
  813. $where .= " and features like '%-$category-%'";
  814. }
  815. if ($size) {
  816. $where .= " and features like '%-$size-%'";
  817. }
  818. if ($grade) {
  819. $where .= " and features like '%-$grade-%'";
  820. }
  821. if ($color) {
  822. $where .= " and features like '%-$color-%'";
  823. }
  824. if ($lacecolor) {
  825. $where .= " and features like '%-$lacecolor-%'";
  826. }
  827. if ($lowe) {
  828. $where .= " and features like '%-$lowe-%'";
  829. }
  830. if ($haircap) {
  831. $where .= " and features like '%-$haircap-%'";
  832. }
  833. if ($density) {
  834. $where .= " and features like '%-$density-%'";
  835. }
  836. if ($warehouse) {
  837. $where .= " and warehouse = '$warehouse'";
  838. }
  839. if ($details) {
  840. $where .= " and details = '$details'";
  841. }
  842. if ($purchase) {
  843. $where .= " and purchase = '$purchase'";
  844. }
  845. if ($state) {
  846. $where .= " and state = '$state'";
  847. }
  848. if ($ktime && $jtime) {
  849. $gj = " and enter > '$ktime' and enter < '$jtime'";
  850. $ck = " and outk > '$ktime' and outk < '$jtime'";
  851. }
  852. //数据排序
  853. $order_str = "id desc";
  854. if (empty($page)) {
  855. $start = 0;
  856. $perpage = 1;
  857. } else {
  858. $start = ($page - 1) * $perpage;
  859. }
  860. if ($sku) {
  861. $sku = trim($sku, ' ');
  862. $sku = trim($sku, ' ');
  863. $where .= " and sku like '%$sku%'";
  864. } else if ($title) {
  865. $title = trim($title, ' ');
  866. $title = trim($title, ' ');
  867. $where .= " and title like '%$title%'";
  868. }
  869. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  870. //取得信息列表
  871. $t = array();
  872. $typeclass = $this->typeclass->find_all();
  873. foreach ($typeclass as $v) {
  874. $t[$v['id']] = $v;
  875. }
  876. $rows = array();
  877. $list = array();
  878. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  879. foreach ($info_list as $key => $value) {
  880. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  881. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  882. $warehouse = $this->warehouse->read($value['warehouse']);
  883. $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');
  884. $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'] . '"');
  885. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  886. $number = $value['number'];
  887. $ftime = time() - 15 * 24 * 3600;
  888. $z = count($z); //查看订单号
  889. $info_list[$key]['warehouse'] = $warehouse['title'];
  890. $info_list[$key]['features'] = count($c);
  891. $info_list[$key]['number'] = $z;
  892. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  893. $details = array();
  894. $cpid = array();
  895. foreach ($c as $k => $v) {
  896. $details[$v['details']] = $v['details'];
  897. if ($v['cpid'] != 0) {
  898. $cpid[$v['cpid']] = $v['cpid'];
  899. }
  900. }
  901. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  902. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  903. unset($info_list[$key]['pm']);
  904. unset($info_list[$key]['jm']);
  905. unset($info_list[$key]['bm']);
  906. }
  907. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  908. $pagenum = ceil($total / $perpage);
  909. $over = $total - ($start + $perpage);
  910. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  911. echo json_encode($rows);
  912. exit;
  913. }
  914. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  915. $this->_Template('whlabel_typeck', $this->data);
  916. }
  917. //进销存导出
  918. public function _whlabeckdc()
  919. {
  920. $prc = array();
  921. $purchase = $this->purchase->find_all();
  922. foreach ($purchase as $k => $v) {
  923. $prc[$v['id']] = $v['title'];
  924. }
  925. if (isset($_GET['excel'])) {
  926. $where = "sku != 'Preset'";
  927. //数据排序
  928. $order_str = "id desc";
  929. if (empty($page)) {
  930. $start = 0;
  931. $perpage = 1;
  932. } else {
  933. $start = ($page - 1) * $perpage;
  934. }
  935. $category = $this->input->get('category', true);
  936. $color = $this->input->get('color', true);
  937. $lowe = $this->input->get('lowe', true);
  938. $lacetype = $this->input->get('lacetype', true);
  939. $size = $this->input->get('size', true);
  940. $density = $this->input->get('density', true);
  941. $haircap = $this->input->get('haircap', true);
  942. $sku = $this->input->get('sku', true);
  943. $details = $this->input->get('details', true);
  944. $warehouse = 13;
  945. $excelid = $this->input->get('sid', true);
  946. if ($category) {
  947. $where .= " and features like '%-$category-%'";
  948. }
  949. if ($color) {
  950. $where .= " and features like '%-$color-%'";
  951. }
  952. if ($lowe) {
  953. $where .= " and features like '%-$lowe-%'";
  954. }
  955. if ($lacetype) {
  956. $where .= " and features like '%-$lacetype-%'";
  957. }
  958. if ($size) {
  959. $where .= " and features like '%-$size-%'";
  960. }
  961. if ($density) {
  962. $where .= " and features like '%-$density-%'";
  963. }
  964. if ($haircap) {
  965. $where .= " and features like '%-$haircap-%'";
  966. }
  967. if ($warehouse) {
  968. $where .= " and warehouse = '$warehouse'";
  969. }
  970. if ($sku) {
  971. $where .= " and sku like '%$sku%'";
  972. }
  973. if ($details) {
  974. $where .= " and details = '$details'";
  975. }
  976. $xzid = '';
  977. if ($excelid) {
  978. $excelid = explode(',', trim($excelid, ','));
  979. foreach ($excelid as $key => $value) {
  980. $xzid .= " id = " . $value . " or";
  981. }
  982. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  983. }
  984. //取得信息列表
  985. /**
  986. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  987. $rows = array();$list = array();
  988. foreach ($info_list as $key=>$value)
  989. {
  990. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  991. }
  992. **/
  993. $wh = array();
  994. $w = $this->warehouse->find_all('1=1', 'id,title');
  995. foreach ($w as $v) {
  996. $wh[$v['id']] = $v['title'];
  997. }
  998. $tc = array();
  999. $tcdata = array();
  1000. $list = array();
  1001. $classid = $this->classid->sku();
  1002. $tcall = $this->typeclass->find_all();
  1003. $typeclass = array();
  1004. foreach ($tcall as $v)
  1005. {
  1006. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1007. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1008. }
  1009. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1010. foreach ($rows as $key => $value) {
  1011. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1012. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1013. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1014. $rows[$key]['cpbz'] = $u9_info['bm'];
  1015. $rows[$key]['cs'] = $u9_info['jm'];
  1016. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1017. $details = array();
  1018. $cpid = array();
  1019. $cpbz = array();
  1020. $c = 0;
  1021. $g = 0;
  1022. $x = 0;
  1023. $t = 0;
  1024. $s = 0;
  1025. $q = 0;
  1026. foreach ($sd as $k => $v) {
  1027. if ($v['state'] == 0) {
  1028. $c++;
  1029. }
  1030. if ($v['state'] != 9) {
  1031. $g++;
  1032. }
  1033. if ($v['state'] == 1) {
  1034. $x++;
  1035. }
  1036. if ($v['state'] == 2) {
  1037. $t++;
  1038. }
  1039. if ($v['state'] == 8) {
  1040. $s++;
  1041. }
  1042. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1043. $q++;
  1044. }
  1045. $details[$v['details']] = $v['details'];
  1046. if ($v['cpid'] != 0) {
  1047. $cpid[$v['cpid']] = $v['cpid'];
  1048. }
  1049. if ($v['cpbz'] != '') {
  1050. $cpbz[$v['cpbz']] = $v['cpbz'];
  1051. }
  1052. }
  1053. $rows[$key]['details'] = implode("、", $details);
  1054. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1055. $number = $value['number'];
  1056. $ftime = time() - 15 * 24 * 3600;
  1057. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1058. $rows[$key]['number'] = $g;
  1059. $rows[$key]['features'] = $c;
  1060. $rows[$key]['x'] = $x;
  1061. $rows[$key]['t'] = $t;
  1062. $rows[$key]['s'] = $s;
  1063. $rows[$key]['q'] = $q;
  1064. $rows[$key]['wzsl'] = count($details);
  1065. }
  1066. $title = "进销存统计表" . date('Y-m-d', time());
  1067. $titlename = "<table border=1>
  1068. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1069. <tr align='center'>
  1070. <td>仓库</td>
  1071. <td>供应商</td>
  1072. <td>位置</td>
  1073. <td>库存编码</td>
  1074. <td>SKU</td>
  1075. <td>用友编码</td>
  1076. <td>用友料号</td>
  1077. <td>产品英文名</td>
  1078. <td>产品中文名</td>
  1079. <td>入库总量</td>
  1080. <td>库存数量</td>
  1081. <td>销售数量</td>
  1082. <td>退货数量</td>
  1083. <td>删除数量</td>
  1084. <td>其它操作</td>
  1085. <td>位置数量</td>
  1086. </tr>
  1087. </table>";
  1088. $filename = $title . ".xls";
  1089. $tail = "";
  1090. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1091. }
  1092. }
  1093. public function _type()
  1094. {
  1095. $vip = 0;
  1096. if (isset($_SESSION['api'])) {
  1097. $user = $this->user->get_api($_SESSION['api']);
  1098. $fgshop = "";
  1099. $sid = "";
  1100. $usersp = explode('|', trim($user['shop'], '|'));
  1101. foreach ($usersp as $value) {
  1102. $fgshop .= " shop = " . $value . " or";
  1103. $sid .= " id = " . $value . " or";
  1104. }
  1105. if ($user['vip'] == 1) {
  1106. $vip = 1;
  1107. }
  1108. } else {
  1109. header('Location: /');
  1110. exit;
  1111. }
  1112. $prc = array();
  1113. $purchase = $this->purchase->find_all();
  1114. foreach ($purchase as $k => $v) {
  1115. $prc[$v['id']] = $v['title'];
  1116. }
  1117. $company = array();
  1118. $ct = $this->company->find_all();
  1119. foreach ($ct as $k => $v) {
  1120. $company[$v['id']] = $v['title'];
  1121. }
  1122. $sp = array();
  1123. $s = $this->shop->find_all('1=1', 'id,shopname');
  1124. foreach ($s as $v) {
  1125. $sp[$v['id']] = $v['shopname'];
  1126. }
  1127. $wh = array();
  1128. $w = $this->warehouse->find_all('1=1', 'id,title');
  1129. foreach ($w as $v) {
  1130. $wh[$v['id']] = $v['title'];
  1131. }
  1132. $post = $this->input->post(NULL, TRUE);
  1133. if (isset($post['page'])) {
  1134. $page = $this->input->post('page', true);
  1135. $perpage = $this->input->post('perpage', true);
  1136. $category = $this->input->post('category', true);
  1137. $size = $this->input->post('size', true);
  1138. $grade = $this->input->post('grade', true);
  1139. $color = $this->input->post('color', true);
  1140. $lowe = $this->input->post('lowe', true);
  1141. $sku = $this->input->post('sku');
  1142. $title = $this->input->post('title');
  1143. $warehouse = $this->input->post('warehouse', true);
  1144. $usa = $this->input->post('usa', true);
  1145. $purchase = $this->input->post('purchase', true);
  1146. $lacetype = $this->input->post('lacetype', true);
  1147. $haircap = $this->input->post('haircap', true);
  1148. $density = $this->input->post('density', true);
  1149. $details = $this->input->post('details', true);
  1150. $state = $this->input->post('state', true);
  1151. $shop = $this->input->post('shop', true);
  1152. $lacecolor = $this->input->post('lacecolor', true);
  1153. $hairnumber = $this->input->post('hairnumber', true);
  1154. $type = $this->input->post('type', true);
  1155. $ktime = $this->input->post('ktime', true);
  1156. $jtime = $this->input->post('jtime', true);
  1157. $ktime = strtotime($ktime);
  1158. $jtime = strtotime($jtime);
  1159. $cpbz = $this->input->post('cpbz', true);
  1160. $where = "1=1";
  1161. $gj = "";
  1162. $ck = "";
  1163. if ($usa) {
  1164. if (!$warehouse) {
  1165. $where .= " and (warehouse = '5' or warehouse = '8')";
  1166. }
  1167. }
  1168. if ($warehouse) {
  1169. $where .= " and warehouse = '$warehouse'";
  1170. }
  1171. if ($details) {
  1172. $where .= " and details = '$details'";
  1173. }
  1174. if ($purchase) {
  1175. $where .= " and purchase = '$purchase'";
  1176. }
  1177. if ($state) {
  1178. $where .= " and state = '$state'";
  1179. }
  1180. if ($shop) {
  1181. $where .= " and shop like '%$shop%'";
  1182. }
  1183. if ($type) {
  1184. $where .= " and type = '$type'";
  1185. }
  1186. if ($ktime && $jtime) {
  1187. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1188. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1189. }
  1190. if ($cpbz) {
  1191. $where .= " and cpbz like '%$cpbz%' ";
  1192. }
  1193. if ($lacecolor) {
  1194. $where .= " and features like '%-$lacecolor-%'";
  1195. }
  1196. if ($lacetype) {
  1197. $where .= " and features like '%-$lacetype-%'";
  1198. }
  1199. if ($category) {
  1200. $where .= " and features like '%-$category-%'";
  1201. }
  1202. if ($size) {
  1203. $where .= " and features like '%-$size-%'";
  1204. }
  1205. if ($grade) {
  1206. $where .= " and features like '%-$grade-%'";
  1207. }
  1208. if ($color) {
  1209. $where .= " and features like '%-$color-%'";
  1210. }
  1211. if ($lowe) {
  1212. $where .= " and features like '%-$lowe-%'";
  1213. }
  1214. if ($haircap) {
  1215. $where .= " and features like '%-$haircap-%'";
  1216. }
  1217. if ($density) {
  1218. $where .= " and features like '%-$density-%'";
  1219. }
  1220. if (!empty($hairnumber)) {
  1221. $where .= " and features like '%-128-%' ";
  1222. if ($hairnumber < 0) {
  1223. $class_list = $this->typeclass->find_all('classid = 43');
  1224. foreach ($class_list as $v) {
  1225. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1226. }
  1227. } else {
  1228. $where .= " and features like '%-$hairnumber-%'";
  1229. }
  1230. }
  1231. //数据排序
  1232. $order_str = "id desc";
  1233. if (empty($page)) {
  1234. $start = 0;
  1235. $perpage = 1;
  1236. } else {
  1237. $start = ($page - 1) * $perpage;
  1238. }
  1239. $fjnr = '';
  1240. if ($sku) {
  1241. $sku = trim($sku, ' ');
  1242. $sku = trim($sku, ' ');
  1243. $fjnr .= " and sku like '%$sku%'";
  1244. }
  1245. if ($title) {
  1246. $title = trim($title, ' ');
  1247. $title = trim($title, ' ');
  1248. $fjnr .= " and title like '%$title%'";
  1249. }
  1250. $wt = array();
  1251. $whlabel_type = $this->whlabel_type->find_all();
  1252. foreach ($whlabel_type as $v) {
  1253. $wt[$v['id']] = $v['title'];
  1254. }
  1255. //$where .= " and time > '$ktime' and time < '$jtime'";
  1256. $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
  1257. //取得信息列表
  1258. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1259. $rows = array();
  1260. $list = array();
  1261. foreach ($info_list as $key => $value) {
  1262. if (isset($wt[$value['type']])) {
  1263. $info_list[$key]['type'] = $wt[$value['type']];
  1264. } else {
  1265. $info_list[$key]['type'] = '未设置';
  1266. }
  1267. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1268. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1269. $ztdata = '';
  1270. if (count($zt) > 0) {
  1271. foreach ($zt as $vv) {
  1272. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1273. }
  1274. }
  1275. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1276. $cdata = array_filter($qbdata, function ($item) {
  1277. return $item['state'] < 1;
  1278. });
  1279. $c = array_sum(array_column($cdata, 'jnum'));
  1280. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1281. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1282. });
  1283. $g = array_sum(array_column($gdata, 'jnum'));
  1284. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1285. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1286. });
  1287. $x = array_sum(array_column($xdata, 'jnum'));
  1288. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1289. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1290. });
  1291. $t = array_sum(array_column($tdata, 'jnum'));
  1292. $zdata = array_filter($qbdata, function ($item) {
  1293. return $item['zd'] != "" && $item['state'] < 1;
  1294. });
  1295. $z = array_sum(array_column($zdata, 'jnum'));
  1296. $zdata = array_filter($qbdata, function ($item) {
  1297. return $item['zd'] != "" && $item['state'] < 1;
  1298. });
  1299. $z = array_sum(array_column($zdata, 'jnum'));
  1300. //$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');
  1301. //$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'].'"');
  1302. //$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'].'"');
  1303. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1304. //$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'].'"');
  1305. $details = array();
  1306. $cpid = array();
  1307. $od = array();
  1308. $odid = '';
  1309. $companytitle = '';
  1310. foreach ($qbdata as $v) {
  1311. if ($v['zd'] != "" && $v['state'] < 1) {
  1312. if (!isset($od[$v['zd']])) {
  1313. $od[$v['zd']] = 1; //所有数据sku
  1314. } else {
  1315. $od[$v['zd']] = $od[$v['zd']] + 1;
  1316. }
  1317. }
  1318. if ($v['state'] < 1) {
  1319. $details[$v['details']] = $v['details'];
  1320. if ($v['cpid'] != 0) {
  1321. $cpid[$v['cpid']] = $v['cpid'];
  1322. }
  1323. }
  1324. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1325. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1326. }
  1327. }
  1328. foreach ($od as $k => $vv) {
  1329. $odid .= $k . '数量' . $vv;
  1330. }
  1331. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  1332. $number = $value['number'];
  1333. $ftime = time() - 15 * 24 * 3600;
  1334. $z = $z . '(' . $odid . ')'; //查看订单号
  1335. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1336. $info_list[$key]['features'] = $c;
  1337. $info_list[$key]['number'] = $ztdata;
  1338. $info_list[$key]['sm'] = $g;
  1339. $info_list[$key]['x'] = $x;
  1340. $info_list[$key]['t'] = $t;
  1341. $info_list[$key]['z'] = $z;
  1342. /**
  1343. foreach ($cdata as $k=>$v)
  1344. {
  1345. $details[$v['details']] = $v['details'];
  1346. if($v['cpid'] != 0)
  1347. {
  1348. $cpid[$v['cpid']] = $v['cpid'];
  1349. }
  1350. }
  1351. **/
  1352. $info_list[$key]['shop'] = '';
  1353. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1354. if ($value['shop'] != '') {
  1355. $shop = explode(',', trim($value['shop'], ','));
  1356. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1357. }
  1358. $info_list[$key]['shop'] .= $companytitle;
  1359. /**
  1360. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1361. if(isset($companytitle[0]))
  1362. {
  1363. foreach ($companytitle as $k=>$v)
  1364. {
  1365. if($v['companytitle'] != '')
  1366. {
  1367. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1368. }
  1369. }
  1370. }
  1371. **/
  1372. }
  1373. $final_all_list = [];
  1374. foreach ($info_list as $k => $v) {
  1375. $final_all_list[] = [
  1376. 'id' => $v['id'],
  1377. "warehouse" => $v["warehouse"],
  1378. "purchase" => $v["purchase"],
  1379. "sku" => $v["sku"],
  1380. "title" => $v["title"] . "<br/>" . $v["pm"],
  1381. "details" => $v["details"],
  1382. "shop" => $v["shop"],
  1383. "cpbz" => $v["cpbz"],
  1384. "type" => $v["type"],
  1385. "features" => $v["features"],
  1386. "number" => $v["number"],
  1387. "sm" => $v["sm"],
  1388. "x" => $v["x"],
  1389. "t" => $v["t"],
  1390. "z" => $v["z"]
  1391. ];
  1392. }
  1393. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1394. $pagenum = ceil($total / $perpage);
  1395. $over = $total - ($start + $perpage);
  1396. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1397. echo json_encode($rows);
  1398. exit;
  1399. }
  1400. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1401. $this->data['shop'] = $wlshop;
  1402. $this->data['vip'] = $vip;
  1403. $this->_Template('whlabel_type', $this->data);
  1404. }
  1405. //美仓进销存浏览
  1406. public function _usatype()
  1407. {
  1408. if (isset($_SESSION['api'])) {
  1409. $user = $this->user->get_api($_SESSION['api']);
  1410. $usp = $user;
  1411. $fgshop = "";
  1412. $sid = "";
  1413. $wid = "";
  1414. $wtype = "";
  1415. $userwh = explode('|', trim($user['warehouse'], '|'));
  1416. foreach ($userwh as $value) {
  1417. $wid .= " id = " . $value . " or";
  1418. $wtype .= " type = " . $value . " or";
  1419. }
  1420. }
  1421. $prc = array();
  1422. $purchase = $this->purchase->find_all();
  1423. foreach ($purchase as $k => $v) {
  1424. $prc[$v['id']] = $v['title'];
  1425. }
  1426. $post = $this->input->post(NULL, TRUE);
  1427. if (isset($post['page'])) {
  1428. $page = $this->input->post('page', true);
  1429. $perpage = $this->input->post('perpage', true);
  1430. $category = $this->input->post('category', true);
  1431. $size = $this->input->post('size', true);
  1432. $grade = $this->input->post('grade', true);
  1433. $color = $this->input->post('color', true);
  1434. $lowe = $this->input->post('lowe', true);
  1435. $sku = $this->input->post('sku');
  1436. $title = $this->input->post('title');
  1437. $warehouse = $this->input->post('warehouse', true);
  1438. $usa = $this->input->post('usa', true);
  1439. $purchase = $this->input->post('purchase', true);
  1440. $lacetype = $this->input->post('lacetype', true);
  1441. $haircap = $this->input->post('haircap', true);
  1442. $density = $this->input->post('density', true);
  1443. $details = $this->input->post('details', true);
  1444. $state = $this->input->post('state', true);
  1445. $lacecolor = $this->input->post('lacecolor', true);
  1446. $cklx = $this->input->post('cklx', true);
  1447. $ktime = $this->input->post('ktime', true);
  1448. $jtime = $this->input->post('jtime', true);
  1449. $ktime = strtotime($ktime);
  1450. $jtime = strtotime($jtime);
  1451. $where = "1=1";
  1452. $gj = "";
  1453. $ck = "";
  1454. if ($lacetype) {
  1455. $where .= " and features like '%-$lacetype-%'";
  1456. }
  1457. if ($category) {
  1458. $where .= " and features like '%-$category-%'";
  1459. }
  1460. if ($size) {
  1461. $where .= " and features like '%-$size-%'";
  1462. }
  1463. if ($grade) {
  1464. $where .= " and features like '%-$grade-%'";
  1465. }
  1466. if ($color) {
  1467. $where .= " and features like '%-$color-%'";
  1468. }
  1469. if ($lowe) {
  1470. $where .= " and features like '%-$lowe-%'";
  1471. }
  1472. if ($haircap) {
  1473. $where .= " and features like '%-$haircap-%'";
  1474. }
  1475. if ($density) {
  1476. $where .= " and features like '%-$density-%'";
  1477. }
  1478. if ($lacecolor) {
  1479. $where .= " and features like '%-$lacecolor-%'";
  1480. }
  1481. if ($usa) {
  1482. if (!$warehouse) {
  1483. $where .= " and (warehouse = '5' or warehouse = '8')";
  1484. }
  1485. }
  1486. if ($warehouse) {
  1487. $where .= " and warehouse = '$warehouse'";
  1488. }
  1489. if ($details) {
  1490. $where .= " and details = '$details'";
  1491. }
  1492. if ($purchase) {
  1493. $where .= " and purchase = '$purchase'";
  1494. }
  1495. if ($state) {
  1496. $where .= " and state = '$state'";
  1497. }
  1498. $where_add = '';
  1499. if ($cklx) {
  1500. $shop = $this->shop->read($cklx);
  1501. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1502. }
  1503. if ($ktime && $jtime) {
  1504. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1505. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1506. }
  1507. //数据排序
  1508. $order_str = "id desc";
  1509. if (empty($page)) {
  1510. $start = 0;
  1511. $perpage = 1;
  1512. } else {
  1513. $start = ($page - 1) * $perpage;
  1514. }
  1515. if ($sku) {
  1516. $sku = trim($sku, ' ');
  1517. $sku = trim($sku, ' ');
  1518. $where .= " and sku like '%$sku%'";
  1519. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1520. } else if ($title) {
  1521. $title = trim($title, ' ');
  1522. $title = trim($title, ' ');
  1523. $where .= " and title like '%$title%'";
  1524. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1525. } else {
  1526. //$where .= " and time > '$ktime' and time < '$jtime'";
  1527. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1528. }
  1529. //取得信息列表
  1530. $rows = array();
  1531. $list = array();
  1532. foreach ($info_list as $key => $value) {
  1533. $warehouse = $this->warehouse->read($value['warehouse']);
  1534. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1535. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1536. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1537. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1538. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1539. $od = array();
  1540. $odid = '';
  1541. foreach ($z as $v) {
  1542. if (!isset($od[$v['zd']])) {
  1543. $od[$v['zd']] = 1; //所有数据sku
  1544. } else {
  1545. $od[$v['zd']] = $od[$v['zd']] + 1;
  1546. }
  1547. }
  1548. foreach ($od as $k => $vv) {
  1549. $odid .= $k . '数量' . $vv . ' ';
  1550. }
  1551. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1552. $info_list[$key]['features'] = $c;
  1553. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1554. $ztdata = '';
  1555. if (count($zt) > 0) {
  1556. foreach ($zt as $vv) {
  1557. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1558. }
  1559. }
  1560. $info_list[$key]['warehouse'] = $ztdata;
  1561. $info_list[$key]['g'] = $g;
  1562. $info_list[$key]['x'] = $x;
  1563. $info_list[$key]['t'] = $t;
  1564. $info_list[$key]['z'] = $z;
  1565. }
  1566. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1567. $pagenum = ceil($total / $perpage);
  1568. $over = $total - ($start + $perpage);
  1569. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1570. echo json_encode($rows);
  1571. exit;
  1572. }
  1573. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1574. $this->data['warehouse'] = $warehouse;
  1575. $this->_Template('whlabel_typeusa', $this->data);
  1576. }
  1577. //美仓进销存浏览
  1578. public function _usatypeapp()
  1579. {
  1580. $post = $this->input->post(NULL, TRUE);
  1581. if (isset($post['page'])) {
  1582. $page = $this->input->post('page', true);
  1583. $perpage = $this->input->post('perpage', true);
  1584. $sku = $this->input->post('sku', true);
  1585. $warehouse = 5;
  1586. $title = $this->input->post('title', true);
  1587. $state = $this->input->post('state', true);
  1588. $ktime = $this->input->post('ktime', true);
  1589. $jtime = $this->input->post('jtime', true);
  1590. $ktime = strtotime($ktime);
  1591. $jtime = strtotime($jtime);
  1592. $where = "1=1";
  1593. $gj = "";
  1594. $ck = "";
  1595. if ($title) {
  1596. $st = explode(' ', trim($title, ' '));
  1597. foreach ($st as $v) {
  1598. $where .= " and title like '%$v%'";
  1599. }
  1600. }
  1601. if ($warehouse) {
  1602. $where .= " and warehouse = '$warehouse'";
  1603. }
  1604. if ($state) {
  1605. $where .= " and state = '$state'";
  1606. }
  1607. if ($sku) {
  1608. $where .= " and sku like '%$sku%'";
  1609. }
  1610. if ($ktime && $jtime) {
  1611. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1612. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1613. }
  1614. //数据排序
  1615. $order_str = "id desc";
  1616. if (empty($page)) {
  1617. $start = 0;
  1618. $perpage = 1;
  1619. } else {
  1620. $start = ($page - 1) * $perpage;
  1621. }
  1622. //取得信息列表
  1623. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1624. $rows = array();
  1625. $list = array();
  1626. foreach ($info_list as $key => $value) {
  1627. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1628. }
  1629. $rowsdq = array_slice($rows, $start, $perpage);
  1630. foreach ($rowsdq as $value) {
  1631. $warehouse = $this->warehouse->read($value['warehouse']);
  1632. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1633. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1634. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1635. $od = array();
  1636. $odid = '';
  1637. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1638. }
  1639. $total = count($rows);
  1640. $pagenum = ceil($total / $perpage);
  1641. $over = $total - ($start + $perpage);
  1642. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1643. echo json_encode($rows);
  1644. exit;
  1645. }
  1646. $this->_Template('phone/p_usatypeapp', $this->data);
  1647. }
  1648. //入库操作
  1649. public function _enteradd()
  1650. {
  1651. $dt = 0;
  1652. if (isset($_SESSION['api'])) {
  1653. $user = $this->user->get_api($_SESSION['api']);
  1654. $usp = $user;
  1655. $fgshop = "";
  1656. $sid = "";
  1657. $user = explode('|', trim($user['shop'], '|'));
  1658. foreach ($user as $value) {
  1659. $fgshop .= " shop = " . $value . " or";
  1660. $sid .= " id = " . $value . " or";
  1661. }
  1662. }
  1663. $tc = $this->typeclass->find_all();
  1664. $typeclass = array();
  1665. foreach ($tc as $v) {
  1666. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1667. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1668. }
  1669. $post = $this->input->post(NULL, TRUE);
  1670. if (isset($post['sku'])) {
  1671. $list = array();
  1672. $num = "";
  1673. $title = "";
  1674. $features = "";
  1675. $order = $this->input->post('order', true);
  1676. $shop = $this->input->post('shop', true);
  1677. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1678. $sku = $this->input->post('sku', true);
  1679. $post['sm'] = $this->input->post('sm', true);
  1680. $post['warehouse'] = $this->input->post('warehouse', true);
  1681. $post['purchase'] = $this->input->post('purchase', true);
  1682. $post['retreatwarehouse'] = $post['warehouse'];
  1683. $post['state'] = $this->input->post('state', true);
  1684. $post['rktype'] = $this->input->post('rktype', true);
  1685. $post['text'] = $this->input->post('text', true);
  1686. $category = $this->input->post('category', true);
  1687. $list['category'] = $category;
  1688. $list['hairtype'] = $this->input->post('hairtype', true);
  1689. $list['grade'] = $this->input->post('grade', true);
  1690. $size = $this->input->post('size', true);
  1691. $xzsku = $this->input->post('xzsku', true);
  1692. $list['size'] = rtrim($size, ',');
  1693. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1694. $list['extension'] = $this->input->post('extension', true);
  1695. if ($category == 1297) {
  1696. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1697. }
  1698. if ($category == 1702) {
  1699. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1700. $list['syother'] = $this->input->post('syother', true);
  1701. }
  1702. if ($category == 133) {
  1703. $list['fittype'] = $this->input->post('fittype', true);
  1704. $list['acother'] = $this->input->post('acother', true);
  1705. }
  1706. $list['color'] = $this->input->post('color', true);
  1707. $list['lowe'] = $this->input->post('lowe', true);
  1708. if (!$post['purchase']) {
  1709. $post['purchase'] = 1;
  1710. }
  1711. if ($category == 127) {
  1712. $list['type'] = $this->input->post('type', true);
  1713. $list['headroad'] = $this->input->post('headroad', true);
  1714. $list['density'] = $this->input->post('density', true);
  1715. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1716. $list['lacesize'] = $this->input->post('lacesize', true);
  1717. }
  1718. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1719. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1720. }
  1721. if ($category == 128) {
  1722. $list['lacetype'] = $this->input->post('lacetype', true);
  1723. $list['haircap'] = $this->input->post('haircap', true);
  1724. $list['density'] = $this->input->post('density', true);
  1725. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1726. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1727. $list['wigother'] = $this->input->post('wigother', true);
  1728. $list['wigother1'] = $this->input->post('wigother1', true);
  1729. $list['wigother2'] = $this->input->post('wigother2', true);
  1730. }
  1731. if ($category == 129) {
  1732. $list['wide'] = $this->input->post('wide', true);
  1733. }
  1734. if ($category == 131) {
  1735. $list['gifttype'] = $this->input->post('gifttype', true);
  1736. $list['giftother'] = $this->input->post('giftother', true);
  1737. }
  1738. if ($category == 134) {
  1739. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1740. }
  1741. if ($category == 1297) {
  1742. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1743. $list['sywigother'] = $this->input->post('sywigother', true);
  1744. }
  1745. if ($category == 130 || $category == 133 || $category == 1702) {
  1746. $list['items'] = $this->input->post('items', true);
  1747. $list['weight'] = $this->input->post('weight', true);
  1748. }
  1749. if ($category == 1702) {
  1750. $list['syhairther'] = $this->input->post('syhairther', true);
  1751. }
  1752. $classid = $this->classid->sku();
  1753. $scsku = $classid;
  1754. $pm = $classid;
  1755. foreach ($list as $k => $v) {
  1756. if ($v != 0) {
  1757. $num .= $v;
  1758. $features .= $v . '-';
  1759. $post[$k] = $v;
  1760. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1761. if ($k != 'size') {
  1762. $title .= $typeclass[$v]['title'] . " ";
  1763. }
  1764. if (isset($pm[$typeclass[$v]['classid']])) {
  1765. if ($typeclass[$v]['title'] == '9A') {
  1766. $pm[$typeclass[$v]['classid']] = '9A';
  1767. } else if ($typeclass[$v]['title'] == '10A') {
  1768. $pm[$typeclass[$v]['classid']] = '10A';
  1769. } else {
  1770. $clzh = $typeclass[$v]['zh'];
  1771. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1772. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1773. $clzh = $clzh[0];
  1774. }
  1775. $pm[$typeclass[$v]['classid']] = $clzh;
  1776. }
  1777. }
  1778. }
  1779. }
  1780. $zh = implode(" ", $pm);
  1781. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1782. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1783. if ($list['size']) {
  1784. $typeclass = $this->typeclass->read($list['size']);
  1785. $title .= $typeclass['title'];
  1786. }
  1787. $time = time();
  1788. if ($xzsku) {
  1789. $scsku = implode("-", $scsku);
  1790. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1791. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1792. $post['sku'] = trim($scsku, ' ');
  1793. } else {
  1794. $post['sku'] = $sku;
  1795. }
  1796. //$post['sku'] = trim($sku,' ');
  1797. $post['title'] = rtrim($title, ' ');
  1798. $post['number'] = $num;
  1799. $post['features'] = '-' . $features;
  1800. $post['enter'] = $time;
  1801. $post['time'] = $time; //操作时间
  1802. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1803. if ($yza) {
  1804. if ($post['features'] != $yza[0]['features']) {
  1805. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1806. exit;
  1807. }
  1808. }
  1809. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1810. if ($yzb) {
  1811. if ($post['sku'] != $yzb[0]['sku']) {
  1812. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1813. exit;
  1814. }
  1815. }
  1816. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1817. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1818. exit;
  1819. }
  1820. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1821. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1822. exit;
  1823. }
  1824. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1825. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1826. exit;
  1827. }
  1828. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1829. if (isset($yz[0]['type'])) {
  1830. $post['type'] = $yz[0]['type'];
  1831. }
  1832. if ($post['state'] == 9) //如果选择预设库存
  1833. {
  1834. $this->whlabel->insert($post);
  1835. } else {
  1836. /**
  1837. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1838. if($ljg == 1)
  1839. {
  1840. for($i=0;$i<$order;$i++)
  1841. {
  1842. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1843. $this->whlabel->insert($post);
  1844. }
  1845. }
  1846. **/
  1847. //if($post['warehouse'] == '5')
  1848. //{
  1849. //}
  1850. $yydata = $post;
  1851. $yydata['zh'] = $zh;
  1852. /**
  1853. $wl = $this->apiyy->get_cjlp($yydata);
  1854. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1855. {
  1856. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1857. }
  1858. if($wl['Data'][0]['m_isSucess'] != 1)
  1859. {
  1860. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1861. }
  1862. **/
  1863. for ($i = 0; $i < $order; $i++) {
  1864. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1865. $this->whlabel->insert($post);
  1866. }
  1867. }
  1868. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1869. exit;
  1870. }
  1871. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1872. $this->data['wlshop'] = $wlshop;
  1873. $this->_Template('whlabel_enteradd', $this->data);
  1874. }
  1875. //修改产品
  1876. public function _enteredit($arg_array)
  1877. {
  1878. $dt = 0;
  1879. if (isset($_SESSION['api'])) {
  1880. $user = $this->user->get_api($_SESSION['api']);
  1881. $usp = $user;
  1882. $fgshop = "";
  1883. $sid = "";
  1884. $user = explode('|', trim($user['shop'], '|'));
  1885. foreach ($user as $value) {
  1886. $fgshop .= " shop = " . $value . " or";
  1887. $sid .= " id = " . $value . " or";
  1888. }
  1889. }
  1890. $post = $this->input->post(NULL, TRUE);
  1891. if (isset($post['sku'])) {
  1892. $list = array();
  1893. $num = "";
  1894. $title = "";
  1895. $features = "";
  1896. $id = $this->input->post('id', true);
  1897. $order = $this->input->post('order', true);
  1898. $shop = $this->input->post('shop', true);
  1899. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1900. $post['sku'] = $this->input->post('sku', true);
  1901. $post['sm'] = $this->input->post('sm', true);
  1902. $post['warehouse'] = $this->input->post('warehouse', true);
  1903. $post['purchase'] = $this->input->post('purchase', true);
  1904. $post['retreatwarehouse'] = $post['warehouse'];
  1905. $category = $this->input->post('category', true);
  1906. $list['category'] = $category;
  1907. $list['hairtype'] = $this->input->post('hairtype', true);
  1908. $list['grade'] = $this->input->post('grade', true);
  1909. $size = $this->input->post('size', true);
  1910. $list['size'] = rtrim($size, ',');
  1911. $post['rktype'] = $this->input->post('rktype', true);
  1912. $post['text'] = $this->input->post('text', true);
  1913. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1914. $list['extension'] = $this->input->post('extension', true);
  1915. if ($category == 1297) {
  1916. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1917. }
  1918. if ($category == 1702) {
  1919. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1920. $list['syother'] = $this->input->post('syother', true);
  1921. }
  1922. if ($category == 133) {
  1923. $list['fittype'] = $this->input->post('fittype', true);
  1924. $list['acother'] = $this->input->post('acother', true);
  1925. }
  1926. $list['color'] = $this->input->post('color', true);
  1927. $list['lowe'] = $this->input->post('lowe', true);
  1928. if (!$post['purchase']) {
  1929. $post['purchase'] = 1;
  1930. }
  1931. if ($category == 127) {
  1932. $list['type'] = $this->input->post('type', true);
  1933. $list['headroad'] = $this->input->post('headroad', true);
  1934. $list['density'] = $this->input->post('density', true);
  1935. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1936. $list['lacesize'] = $this->input->post('lacesize', true);
  1937. }
  1938. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1939. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1940. }
  1941. if ($category == 128) {
  1942. $list['lacetype'] = $this->input->post('lacetype', true);
  1943. $list['haircap'] = $this->input->post('haircap', true);
  1944. $list['density'] = $this->input->post('density', true);
  1945. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1946. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1947. $list['wigother'] = $this->input->post('wigother', true);
  1948. $list['wigother1'] = $this->input->post('wigother1', true);
  1949. $list['wigother2'] = $this->input->post('wigother2', true);
  1950. }
  1951. if ($category == 129) {
  1952. $list['wide'] = $this->input->post('wide', true);
  1953. }
  1954. if ($category == 131) {
  1955. $list['gifttype'] = $this->input->post('gifttype', true);
  1956. $list['giftother'] = $this->input->post('giftother', true);
  1957. }
  1958. if ($category == 134) {
  1959. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1960. }
  1961. if ($category == 1297) {
  1962. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1963. $list['sywigother'] = $this->input->post('sywigother', true);
  1964. }
  1965. if ($category == 130 || $category == 133 || $category == 1702) {
  1966. $list['items'] = $this->input->post('items', true);
  1967. $list['weight'] = $this->input->post('weight', true);
  1968. }
  1969. if ($category == 1702) {
  1970. $list['syhairther'] = $this->input->post('syhairther', true);
  1971. }
  1972. foreach ($list as $k => $v) {
  1973. if ($v != 0) {
  1974. $num .= $v;
  1975. $features .= $v . '-';
  1976. $typeclass = $this->typeclass->read($v);
  1977. if ($k != 'size') {
  1978. $title .= $typeclass['title'] . " ";
  1979. }
  1980. }
  1981. }
  1982. $typeclass = $this->typeclass->read($list['size']);
  1983. $title .= $typeclass['title'];
  1984. $time = time();
  1985. $post['title'] = rtrim($title, ' ');
  1986. $post['number'] = $num;
  1987. $post['features'] = '-' . $features;
  1988. $post['time'] = $time; //操作时间
  1989. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1990. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1991. exit;
  1992. }
  1993. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1994. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1995. exit;
  1996. }
  1997. $uid = $this->whlabel->read($id);
  1998. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  1999. if ($datanum > 0) {
  2000. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2001. exit;
  2002. }
  2003. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2004. {
  2005. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2006. if ($yza) {
  2007. if ($post['features'] != $yza[0]['features']) {
  2008. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2009. exit;
  2010. }
  2011. }
  2012. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2013. if ($yzb) {
  2014. if ($post['sku'] != $yzb[0]['sku']) {
  2015. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2016. exit;
  2017. }
  2018. }
  2019. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2020. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2021. exit;
  2022. }
  2023. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2024. foreach ($data as $v) {
  2025. $post['id'] = $v['id'];
  2026. $this->whlabel->save($post, $v['id']);
  2027. }
  2028. } else {
  2029. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2030. if ($data > 0) {
  2031. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2032. exit;
  2033. } else {
  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. }
  2040. }
  2041. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2042. exit;
  2043. }
  2044. $uid = $this->whlabel->read($arg_array[0]);
  2045. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2046. $this->data['enter'] = $uid;
  2047. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2048. $this->data['wlshop'] = $wlshop;
  2049. $this->_Template('whlabel_enteredit', $this->data);
  2050. }
  2051. //入库浏览
  2052. public function _enter()
  2053. {
  2054. $post = $this->input->post(NULL, TRUE);
  2055. if (isset($post['s'])) {
  2056. $id_arr = $this->input->post('s');
  2057. $id_arr = explode(',', $id_arr);
  2058. if (!$id_arr) {
  2059. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2060. exit;
  2061. }
  2062. //循环删除记录
  2063. foreach ($id_arr as $v) {
  2064. $sid = $this->whlabel->read($v);
  2065. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2066. if ($count > 0) {
  2067. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2068. exit;
  2069. }
  2070. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2071. foreach ($info_list as $va) {
  2072. $this->whlabel->remove($va['id']);
  2073. }
  2074. }
  2075. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2076. exit;
  2077. }
  2078. $sp = array();
  2079. $s = $this->shop->find_all('1=1', 'id,shopname');
  2080. foreach ($s as $v) {
  2081. $sp[$v['id']] = $v['shopname'];
  2082. }
  2083. $wh = array();
  2084. $w = $this->warehouse->find_all('1=1', 'id,title');
  2085. foreach ($w as $v) {
  2086. $wh[$v['id']] = $v['title'];
  2087. }
  2088. if (isset($post['page'])) {
  2089. $page = $this->input->post('page', true);
  2090. $perpage = $this->input->post('perpage', true);
  2091. $category = $this->input->post('category', true);
  2092. $size = $this->input->post('size', true);
  2093. $grade = $this->input->post('grade', true);
  2094. $color = $this->input->post('color', true);
  2095. $lowe = $this->input->post('lowe', true);
  2096. $sku = $this->input->post('sku', true);
  2097. $warehouse = $this->input->post('warehouse', true);
  2098. $purchase = $this->input->post('purchase', true);
  2099. $ktime = $this->input->post('ktime', true);
  2100. $jtime = $this->input->post('jtime', true);
  2101. $ktime = strtotime($ktime);
  2102. $jtime = strtotime($jtime);
  2103. $where = "1=1";
  2104. $gj = "";
  2105. $ck = "";
  2106. if ($category) {
  2107. $where .= " and features like '%-$category-%'";
  2108. }
  2109. if ($size) {
  2110. $where .= " and features like '%-$size-%'";
  2111. }
  2112. if ($grade) {
  2113. $where .= " and features like '%-$grade-%'";
  2114. }
  2115. if ($color) {
  2116. $where .= " and features like '%-$color-%'";
  2117. }
  2118. if ($lowe) {
  2119. $where .= " and features like '%-$lowe-%'";
  2120. }
  2121. if ($warehouse) {
  2122. $where .= " and warehouse = '$warehouse'";
  2123. }
  2124. if ($purchase) {
  2125. $where .= " and purchase = '$purchase'";
  2126. }
  2127. if ($sku) {
  2128. $where .= " and sku like '%$sku%'";
  2129. }
  2130. if ($ktime && $jtime) {
  2131. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2132. }
  2133. //数据排序
  2134. $order_str = "enter desc";
  2135. if (empty($page)) {
  2136. $start = 0;
  2137. $perpage = 1;
  2138. } else {
  2139. $start = ($page - 1) * $perpage;
  2140. }
  2141. //取得信息列表
  2142. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2143. foreach ($info_list as $k => $v) {
  2144. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2145. if ($v['shop'] == '') {
  2146. $s = '通用';
  2147. } else {
  2148. $info_list[$k]['shop'] = '';
  2149. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2150. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2151. }
  2152. }
  2153. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2154. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2155. $info_list[$k]['g'] = $g;
  2156. }
  2157. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2158. $pagenum = ceil($total / $perpage);
  2159. $over = $total - ($start + $perpage);
  2160. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2161. echo json_encode($rows);
  2162. exit;
  2163. }
  2164. $this->_Template('whlabel_enter', $this->data);
  2165. }
  2166. //出库浏览
  2167. public function _out()
  2168. {
  2169. $post = $this->input->post(NULL, TRUE);
  2170. if (isset($post['page'])) {
  2171. $page = $this->input->post('page', true);
  2172. $perpage = $this->input->post('perpage', true);
  2173. $category = $this->input->post('category', true);
  2174. $size = $this->input->post('size', true);
  2175. $grade = $this->input->post('grade', true);
  2176. $color = $this->input->post('color', true);
  2177. $lowe = $this->input->post('lowe', true);
  2178. $sku = $this->input->post('sku', true);
  2179. $warehouse = $this->input->post('warehouse', true);
  2180. $purchase = $this->input->post('purchase', true);
  2181. $state = $this->input->post('state', true);
  2182. $ktime = $this->input->post('ktime', true);
  2183. $jtime = $this->input->post('jtime', true);
  2184. $ktime = strtotime($ktime);
  2185. $jtime = strtotime($jtime);
  2186. $where = "state=3";
  2187. $gj = "";
  2188. $ck = "";
  2189. if ($category) {
  2190. $where .= " and features like '%-$category-%'";
  2191. }
  2192. if ($size) {
  2193. $where .= " and features like '%-$size-%'";
  2194. }
  2195. if ($grade) {
  2196. $where .= " and features like '%-$grade-%'";
  2197. }
  2198. if ($color) {
  2199. $where .= " and features like '%-$color-%'";
  2200. }
  2201. if ($lowe) {
  2202. $where .= " and features like '%-$lowe-%'";
  2203. }
  2204. if ($state) {
  2205. $where .= " and state = '$state'";
  2206. }
  2207. if ($warehouse) {
  2208. $where .= " and warehouse = '$warehouse'";
  2209. }
  2210. if ($purchase) {
  2211. $where .= " and purchase = '$purchase'";
  2212. }
  2213. if ($sku) {
  2214. $where .= " and sku = '$sku'";
  2215. }
  2216. if ($ktime && $jtime) {
  2217. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2218. }
  2219. //数据排序
  2220. $order_str = "id desc";
  2221. if (empty($page)) {
  2222. $start = 0;
  2223. $perpage = 1;
  2224. } else {
  2225. $start = ($page - 1) * $perpage;
  2226. }
  2227. //取得信息列表
  2228. $info_list = $this->whlabel->find_all($where, 'sku');
  2229. $rows = array();
  2230. $list = array();
  2231. foreach ($info_list as $key => $value) {
  2232. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2233. }
  2234. $rows = array_unique($rows); //删除重复记录
  2235. foreach ($rows as $key => $value) {
  2236. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2237. $ck = $this->warehouse->read($data['warehouse']);
  2238. $warehouse = $ck['title'];
  2239. $gy = $this->purchase->read($data['purchase']);
  2240. $purchase = $gy['purchase'];
  2241. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2242. $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);
  2243. }
  2244. $total = count($list);
  2245. $pagenum = ceil($total / $perpage);
  2246. $over = $total - ($start + $perpage);
  2247. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2248. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2249. echo json_encode($rows);
  2250. exit;
  2251. }
  2252. $this->_Template('whlabel_out', $this->data);
  2253. }
  2254. //出库标签浏览
  2255. public function _label()
  2256. {
  2257. $post = $this->input->post(NULL, TRUE);
  2258. if (isset($post['page'])) {
  2259. $page = $this->input->post('page', true);
  2260. $perpage = $this->input->post('perpage', true);
  2261. $sku = $this->input->post('sku', true);
  2262. $warehouse = $this->input->post('warehouse', true);
  2263. $purchase = $this->input->post('purchase', true);
  2264. $orderinfo = $this->input->post('orderinfo', true);
  2265. $waybill = $this->input->post('waybill', true);
  2266. $category = $this->input->post('category', true);
  2267. $size = $this->input->post('size', true);
  2268. $grade = $this->input->post('grade', true);
  2269. $color = $this->input->post('color', true);
  2270. $lowe = $this->input->post('lowe', true);
  2271. $where = "state=1";
  2272. if ($sku) {
  2273. $where .= " and sku = '$sku'";
  2274. }
  2275. if ($warehouse) {
  2276. $where .= " and warehouse = '$warehouse'";
  2277. }
  2278. if ($purchase) {
  2279. $where .= " and purchase = '$purchase'";
  2280. }
  2281. if ($orderinfo) {
  2282. $where .= " and orderinfo = '$orderinfo'";
  2283. }
  2284. if ($waybill) {
  2285. $where .= " and waybill = '$waybill'";
  2286. }
  2287. if ($category) {
  2288. $where .= " and features like '%-$category-%'";
  2289. }
  2290. if ($size) {
  2291. $where .= " and features like '%-$size-%'";
  2292. }
  2293. if ($grade) {
  2294. $where .= " and features like '%-$grade-%'";
  2295. }
  2296. if ($color) {
  2297. $where .= " and features like '%-$color-%'";
  2298. }
  2299. if ($lowe) {
  2300. $where .= " and features like '%-$lowe-%'";
  2301. }
  2302. //数据排序
  2303. $order_str = "outk desc";
  2304. if (empty($page)) {
  2305. $start = 0;
  2306. $perpage = 1;
  2307. } else {
  2308. $start = ($page - 1) * $perpage;
  2309. }
  2310. //取得信息列表
  2311. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2312. foreach ($info_list as $key => $value) {
  2313. $warehouse = $this->warehouse->read($value['warehouse']);
  2314. $info_list[$key]['warehouse'] = $warehouse['title'];
  2315. $purchase = $this->purchase->read($value['purchase']);
  2316. $info_list[$key]['purchase'] = $purchase['title'];
  2317. if ($value['outk'] != 0) {
  2318. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2319. } else {
  2320. $info_list[$key]['outk'] = "";
  2321. }
  2322. if ($value['orderinfo'] == 0) {
  2323. $info_list[$key]['orderinfo'] = "";
  2324. }
  2325. if ($value['waybill'] == 0) {
  2326. $info_list[$key]['waybill'] = "";
  2327. }
  2328. }
  2329. $total = $this->whlabel->find_count($where);
  2330. $pagenum = ceil($total / $perpage);
  2331. $over = $total - ($start + $perpage);
  2332. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2333. echo json_encode($rows);
  2334. exit;
  2335. }
  2336. $this->_Template('whlabel_label', $this->data);
  2337. }
  2338. //独立站出库订单
  2339. public function _outorder()
  2340. {
  2341. if (isset($_SESSION['api'])) {
  2342. $user = $this->user->get_api($_SESSION['api']);
  2343. $usp = $user;
  2344. $fgshop = "";
  2345. $sid = "";
  2346. $user = explode('|', trim($user['shop'], '|'));
  2347. foreach ($user as $value) {
  2348. $fgshop .= " shop = " . $value . " or";
  2349. $sid .= " id = " . $value . " or";
  2350. }
  2351. } else {
  2352. echo "请重新登录";
  2353. }
  2354. $post = $this->input->post(NULL, TRUE);
  2355. if (isset($post['page'])) {
  2356. $page = $this->input->post('page', true);
  2357. $perpage = $this->input->post('perpage', true);
  2358. $warehouse = $this->input->post('warehouse', true);
  2359. $xztime = $this->input->post('xztime', true);
  2360. $timetk = $this->input->post('timetkk', true);
  2361. $timetj = $this->input->post('timetjj', true);
  2362. $shop = $this->input->post('shop', true);
  2363. $source = $this->input->post('source', true);
  2364. $orderinfo = $this->input->post('orderinfo', true);
  2365. $number = $this->input->post('number', true);
  2366. $sfxh = $this->input->post('sfxh', true);
  2367. $express = $this->input->post('express', true);
  2368. $waybill = $this->input->post('waybill', true);
  2369. $library = $this->input->post('library', true);
  2370. $country = $this->input->post('country', true);
  2371. $so = $this->input->post('so', true);
  2372. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2373. $print = $this->input->post('print', true);
  2374. $state = $this->input->post('state', true);
  2375. $orderurl = $this->input->post('orderurl', true);
  2376. $timetk = strtotime($timetk);
  2377. $timetj = strtotime($timetj);
  2378. /**
  2379. $sj = $this->input->post('sj',true);
  2380. if($sj)
  2381. {
  2382. $sj = $this->input->post('sj',true);
  2383. }
  2384. else
  2385. {
  2386. $sj = "fullorder";
  2387. }
  2388. **/
  2389. $sj = "fullorder";
  2390. $where = "1=1";
  2391. if ($warehouse) {
  2392. $where .= " and type = '$warehouse'";
  2393. }
  2394. if ($timetk && $timetj) {
  2395. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2396. }
  2397. if ($orderinfo) {
  2398. $where .= " and orderinfo = '$orderinfo'";
  2399. }
  2400. if ($number) {
  2401. $where .= " and number = '$number'";
  2402. }
  2403. if ($express) {
  2404. $where .= " and express = '$express'";
  2405. }
  2406. if ($waybill) {
  2407. $where .= " and waybill = '$waybill'";
  2408. }
  2409. if ($library) {
  2410. $where .= " and library = '$library'";
  2411. }
  2412. if ($print) {
  2413. $where .= " and print = '$print'";
  2414. }
  2415. if ($libraryconfirm) {
  2416. $where .= " and libraryconfirm = '$libraryconfirm'";
  2417. }
  2418. if ($state) {
  2419. $where .= " and state = '$state'";
  2420. }
  2421. if ($shop) {
  2422. $where .= " and shop = '$shop'";
  2423. }
  2424. if ($country) {
  2425. $where .= " and country = '$country'";
  2426. }
  2427. if ($sfxh != '') {
  2428. $where .= " and sfxh = '$sfxh'";
  2429. }
  2430. if ($so) {
  2431. $where .= " and shipremarks like '%$so%'";
  2432. }
  2433. if ($source) {
  2434. if ($source == '2d') {
  2435. $where .= " and source >= '2'";
  2436. } else {
  2437. $where .= " and source = '$source'";
  2438. }
  2439. }
  2440. if (isset($_SESSION['api'])) {
  2441. foreach ($user as $value) {
  2442. $fgshop .= " shop = " . $value . " or";
  2443. }
  2444. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2445. }
  2446. if ($orderurl) {
  2447. $url = $this->orderurl->read($orderurl);
  2448. $where .= " and link like '%" . $url['url'] . "%'";
  2449. }
  2450. //数据排序
  2451. $order_str = "librarytime desc";
  2452. if (empty($page)) {
  2453. $start = 0;
  2454. $perpage = 1;
  2455. } else {
  2456. $start = ($page - 1) * $perpage;
  2457. }
  2458. //取得信息列表
  2459. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2460. //格式化数据
  2461. foreach ($info_list as $key => $value) {
  2462. $shop = $this->shop->read($value['shop']);
  2463. $info_list[$key]['shop'] = $shop['shopname'];
  2464. $express = $this->express->read($value['express']);
  2465. $info_list[$key]['express'] = $express['servicename'];
  2466. $warehouse = $this->warehouse->read($value['type']);
  2467. $info_list[$key]['type'] = $warehouse['title'];
  2468. if ($value['librarytime'] == '0') {
  2469. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2470. } else {
  2471. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2472. }
  2473. }
  2474. $total = $this->$sj->find_count($where);
  2475. $pagenum = ceil($total / $perpage);
  2476. $over = $total - ($start + $perpage);
  2477. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2478. echo json_encode($rows);
  2479. exit;
  2480. }
  2481. $this->data['express'] = $this->express->find_all();
  2482. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2483. $this->data['wlshop'] = $wlshop;
  2484. $user = $this->user->get_api($_SESSION['api']);
  2485. $powerid = $this->power->read($user['power']);
  2486. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2487. $pid = '';
  2488. foreach ($powertext as $v) {
  2489. $pid .= " id = " . $v . " or";
  2490. }
  2491. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2492. $this->data['fullorderexcel'] = $fullorderexcel;
  2493. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2494. $this->data['orderurl'] = $orderurl;
  2495. $this->_Template('whlabel_outorder', $this->data);
  2496. }
  2497. //tt出库
  2498. public function _toutorder()
  2499. {
  2500. if (isset($_SESSION['api'])) {
  2501. $user = $this->user->get_api($_SESSION['api']);
  2502. $usp = $user;
  2503. $fgshop = "";
  2504. $sid = "";
  2505. $user = explode('|', trim($user['shop'], '|'));
  2506. foreach ($user as $value) {
  2507. $fgshop .= " shop = " . $value . " or";
  2508. $sid .= " id = " . $value . " or";
  2509. }
  2510. } else {
  2511. echo "请重新登录";
  2512. }
  2513. $post = $this->input->post(NULL, TRUE);
  2514. if (isset($post['page'])) {
  2515. $page = $this->input->post('page', true);
  2516. $perpage = $this->input->post('perpage', true);
  2517. $warehouse = $this->input->post('warehouse', true);
  2518. $xztime = $this->input->post('xztime', true);
  2519. $timetk = $this->input->post('timetkk', true);
  2520. $timetj = $this->input->post('timetjj', true);
  2521. $shop = $this->input->post('shop', true);
  2522. $source = $this->input->post('source', true);
  2523. $orderinfo = $this->input->post('orderinfo', true);
  2524. $number = $this->input->post('number', true);
  2525. $sfxh = $this->input->post('sfxh', true);
  2526. $express = $this->input->post('express', true);
  2527. $waybill = $this->input->post('waybill', true);
  2528. $library = $this->input->post('library', true);
  2529. $country = $this->input->post('country', true);
  2530. $so = $this->input->post('so', true);
  2531. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2532. $print = $this->input->post('print', true);
  2533. $state = $this->input->post('state', true);
  2534. $orderurl = $this->input->post('orderurl', true);
  2535. $timetk = strtotime($timetk);
  2536. $timetj = strtotime($timetj);
  2537. /**
  2538. $sj = $this->input->post('sj',true);
  2539. if($sj)
  2540. {
  2541. $sj = $this->input->post('sj',true);
  2542. }
  2543. else
  2544. {
  2545. $sj = "fullorder";
  2546. }
  2547. **/
  2548. $sj = "fullordertt";
  2549. $where = "1=1";
  2550. if ($warehouse) {
  2551. $where .= " and type = '$warehouse'";
  2552. }
  2553. if ($timetk && $timetj) {
  2554. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2555. }
  2556. if ($orderinfo) {
  2557. $where .= " and orderinfo = '$orderinfo'";
  2558. }
  2559. if ($number) {
  2560. $where .= " and number = '$number'";
  2561. }
  2562. if ($express) {
  2563. $where .= " and express = '$express'";
  2564. }
  2565. if ($waybill) {
  2566. $where .= " and waybill = '$waybill'";
  2567. }
  2568. if ($library) {
  2569. $where .= " and library = '$library'";
  2570. }
  2571. if ($print) {
  2572. $where .= " and print = '$print'";
  2573. }
  2574. if ($libraryconfirm) {
  2575. $where .= " and libraryconfirm = '$libraryconfirm'";
  2576. }
  2577. if ($state) {
  2578. $where .= " and state = '$state'";
  2579. }
  2580. if ($shop) {
  2581. $where .= " and shop = '$shop'";
  2582. }
  2583. if ($country) {
  2584. $where .= " and country = '$country'";
  2585. }
  2586. if ($sfxh != '') {
  2587. $where .= " and sfxh = '$sfxh'";
  2588. }
  2589. if ($so) {
  2590. $where .= " and shipremarks like '%$so%'";
  2591. }
  2592. if ($source) {
  2593. if ($source == '2d') {
  2594. $where .= " and source >= '2'";
  2595. } else {
  2596. $where .= " and source = '$source'";
  2597. }
  2598. }
  2599. if (isset($_SESSION['api'])) {
  2600. foreach ($user as $value) {
  2601. $fgshop .= " shop = " . $value . " or";
  2602. }
  2603. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2604. }
  2605. if ($orderurl) {
  2606. $url = $this->orderurl->read($orderurl);
  2607. $where .= " and link like '%" . $url['url'] . "%'";
  2608. }
  2609. //数据排序
  2610. $order_str = "librarytime desc";
  2611. if (empty($page)) {
  2612. $start = 0;
  2613. $perpage = 1;
  2614. } else {
  2615. $start = ($page - 1) * $perpage;
  2616. }
  2617. //取得信息列表
  2618. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2619. //格式化数据
  2620. foreach ($info_list as $key => $value) {
  2621. $shop = $this->shop->read($value['shop']);
  2622. $info_list[$key]['shop'] = $shop['shopname'];
  2623. $express = $this->express->read($value['express']);
  2624. $info_list[$key]['express'] = $express['servicename'];
  2625. $warehouse = $this->warehouse->read($value['type']);
  2626. $info_list[$key]['type'] = $warehouse['title'];
  2627. if ($value['librarytime'] == '0') {
  2628. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2629. } else {
  2630. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2631. }
  2632. }
  2633. $total = $this->$sj->find_count($where);
  2634. $pagenum = ceil($total / $perpage);
  2635. $over = $total - ($start + $perpage);
  2636. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2637. echo json_encode($rows);
  2638. exit;
  2639. }
  2640. $this->data['express'] = $this->express->find_all();
  2641. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2642. $this->data['wlshop'] = $wlshop;
  2643. $user = $this->user->get_api($_SESSION['api']);
  2644. $powerid = $this->power->read($user['power']);
  2645. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2646. $pid = '';
  2647. foreach ($powertext as $v) {
  2648. $pid .= " id = " . $v . " or";
  2649. }
  2650. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2651. $this->data['fullorderexcel'] = $fullorderexcel;
  2652. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2653. $this->data['orderurl'] = $orderurl;
  2654. $this->_Template('whlabel_toutorder', $this->data);
  2655. }
  2656. //tt出库
  2657. public function _aoutorder()
  2658. {
  2659. if (isset($_SESSION['api'])) {
  2660. $user = $this->user->get_api($_SESSION['api']);
  2661. $usp = $user;
  2662. $fgshop = "";
  2663. $sid = "";
  2664. $user = explode('|', trim($user['shop'], '|'));
  2665. foreach ($user as $value) {
  2666. $fgshop .= " shop = " . $value . " or";
  2667. $sid .= " id = " . $value . " or";
  2668. }
  2669. } else {
  2670. echo "请重新登录";
  2671. }
  2672. $post = $this->input->post(NULL, TRUE);
  2673. if (isset($post['page'])) {
  2674. $page = $this->input->post('page', true);
  2675. $perpage = $this->input->post('perpage', true);
  2676. $warehouse = $this->input->post('warehouse', true);
  2677. $xztime = $this->input->post('xztime', true);
  2678. $timetk = $this->input->post('timetkk', true);
  2679. $timetj = $this->input->post('timetjj', true);
  2680. $shop = $this->input->post('shop', true);
  2681. $source = $this->input->post('source', true);
  2682. $orderinfo = $this->input->post('orderinfo', true);
  2683. $number = $this->input->post('number', true);
  2684. $sfxh = $this->input->post('sfxh', true);
  2685. $express = $this->input->post('express', true);
  2686. $waybill = $this->input->post('waybill', true);
  2687. $library = $this->input->post('library', true);
  2688. $country = $this->input->post('country', true);
  2689. $so = $this->input->post('so', true);
  2690. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2691. $print = $this->input->post('print', true);
  2692. $state = $this->input->post('state', true);
  2693. $orderurl = $this->input->post('orderurl', true);
  2694. $timetk = strtotime($timetk);
  2695. $timetj = strtotime($timetj);
  2696. /**
  2697. $sj = $this->input->post('sj',true);
  2698. if($sj)
  2699. {
  2700. $sj = $this->input->post('sj',true);
  2701. }
  2702. else
  2703. {
  2704. $sj = "fullorder";
  2705. }
  2706. **/
  2707. $sj = "fullorderamz";
  2708. $where = "1=1";
  2709. if ($warehouse) {
  2710. $where .= " and type = '$warehouse'";
  2711. }
  2712. if ($timetk && $timetj) {
  2713. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2714. }
  2715. if ($orderinfo) {
  2716. $where .= " and orderinfo = '$orderinfo'";
  2717. }
  2718. if ($number) {
  2719. $where .= " and number = '$number'";
  2720. }
  2721. if ($express) {
  2722. $where .= " and express = '$express'";
  2723. }
  2724. if ($waybill) {
  2725. $where .= " and waybill = '$waybill'";
  2726. }
  2727. if ($library) {
  2728. $where .= " and library = '$library'";
  2729. }
  2730. if ($print) {
  2731. $where .= " and print = '$print'";
  2732. }
  2733. if ($libraryconfirm) {
  2734. $where .= " and libraryconfirm = '$libraryconfirm'";
  2735. }
  2736. if ($state) {
  2737. $where .= " and state = '$state'";
  2738. }
  2739. if ($shop) {
  2740. $where .= " and shop = '$shop'";
  2741. }
  2742. if ($country) {
  2743. $where .= " and country = '$country'";
  2744. }
  2745. if ($sfxh != '') {
  2746. $where .= " and sfxh = '$sfxh'";
  2747. }
  2748. if ($so) {
  2749. $where .= " and shipremarks like '%$so%'";
  2750. }
  2751. if ($source) {
  2752. if ($source == '2d') {
  2753. $where .= " and source >= '2'";
  2754. } else {
  2755. $where .= " and source = '$source'";
  2756. }
  2757. }
  2758. if (isset($_SESSION['api'])) {
  2759. foreach ($user as $value) {
  2760. $fgshop .= " shop = " . $value . " or";
  2761. }
  2762. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2763. }
  2764. if ($orderurl) {
  2765. $url = $this->orderurl->read($orderurl);
  2766. $where .= " and link like '%" . $url['url'] . "%'";
  2767. }
  2768. //数据排序
  2769. $order_str = "librarytime desc";
  2770. if (empty($page)) {
  2771. $start = 0;
  2772. $perpage = 1;
  2773. } else {
  2774. $start = ($page - 1) * $perpage;
  2775. }
  2776. //取得信息列表
  2777. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2778. //格式化数据
  2779. foreach ($info_list as $key => $value) {
  2780. $shop = $this->shop->read($value['shop']);
  2781. $info_list[$key]['shop'] = $shop['shopname'];
  2782. $express = $this->express->read($value['express']);
  2783. $info_list[$key]['express'] = $express['servicename'];
  2784. $warehouse = $this->warehouse->read($value['type']);
  2785. $info_list[$key]['type'] = $warehouse['title'];
  2786. if ($value['librarytime'] == '0') {
  2787. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2788. } else {
  2789. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2790. }
  2791. }
  2792. $total = $this->$sj->find_count($where);
  2793. $pagenum = ceil($total / $perpage);
  2794. $over = $total - ($start + $perpage);
  2795. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2796. echo json_encode($rows);
  2797. exit;
  2798. }
  2799. $this->data['express'] = $this->express->find_all();
  2800. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2801. $this->data['wlshop'] = $wlshop;
  2802. $user = $this->user->get_api($_SESSION['api']);
  2803. $powerid = $this->power->read($user['power']);
  2804. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2805. $pid = '';
  2806. foreach ($powertext as $v) {
  2807. $pid .= " id = " . $v . " or";
  2808. }
  2809. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2810. $this->data['fullorderexcel'] = $fullorderexcel;
  2811. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2812. $this->data['orderurl'] = $orderurl;
  2813. $this->_Template('whlabel_aoutorder', $this->data);
  2814. }
  2815. //速卖通出库订单
  2816. public function _soutorder()
  2817. {
  2818. if (isset($_SESSION['api'])) {
  2819. $user = $this->user->get_api($_SESSION['api']);
  2820. $usp = $user;
  2821. $fgshop = "";
  2822. $sid = "";
  2823. $user = explode('|', trim($user['shop'], '|'));
  2824. foreach ($user as $value) {
  2825. $sid .= " id = " . $value . " or";
  2826. }
  2827. }
  2828. $post = $this->input->post(NULL, TRUE);
  2829. if (isset($post['page'])) {
  2830. $page = $this->input->post('page', true);
  2831. $perpage = $this->input->post('perpage', true);
  2832. $warehouse = $this->input->post('warehouse', true);
  2833. $xztime = $this->input->post('xztime', true);
  2834. $timetk = $this->input->post('timetkk', true);
  2835. $timetj = $this->input->post('timetjj', true);
  2836. $shop = $this->input->post('shop', true);
  2837. $source = $this->input->post('source', true);
  2838. $orderinfo = $this->input->post('orderinfo', true);
  2839. $number = $this->input->post('number', true);
  2840. $express = $this->input->post('express', true);
  2841. $waybill = $this->input->post('waybill', true);
  2842. $library = $this->input->post('library', true);
  2843. $country = $this->input->post('country', true);
  2844. $sfxh = $this->input->post('sfxh', true);
  2845. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2846. $print = $this->input->post('print', true);
  2847. $state = $this->input->post('state', true);
  2848. $so = $this->input->post('so', true);
  2849. $timetk = strtotime($timetk);
  2850. $timetj = strtotime($timetj);
  2851. /**
  2852. $sj = $this->input->post('sj',true);
  2853. if($sj)
  2854. {
  2855. $sj = $this->input->post('sj',true);
  2856. }
  2857. else
  2858. {
  2859. $sj = "fullorder";
  2860. }
  2861. **/
  2862. $sj = "fullordersmt";
  2863. $where = "1=1";
  2864. if ($warehouse) {
  2865. $where .= " and type = '$warehouse'";
  2866. }
  2867. if ($timetk && $timetj) {
  2868. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2869. }
  2870. if ($orderinfo) {
  2871. $where .= " and orderinfo = '$orderinfo'";
  2872. }
  2873. if ($number) {
  2874. $where .= " and number = '$number'";
  2875. }
  2876. if ($express) {
  2877. $where .= " and express = '$express'";
  2878. }
  2879. if ($waybill) {
  2880. $where .= " and waybill = '$waybill'";
  2881. }
  2882. if ($library) {
  2883. $where .= " and library = '$library'";
  2884. }
  2885. if ($print) {
  2886. $where .= " and print = '$print'";
  2887. }
  2888. if ($libraryconfirm) {
  2889. $where .= " and libraryconfirm = '$libraryconfirm'";
  2890. }
  2891. if ($state) {
  2892. $where .= " and state = '$state'";
  2893. }
  2894. if ($shop) {
  2895. $where .= " and shop = '$shop'";
  2896. }
  2897. if ($sfxh != '') {
  2898. $where .= " and sfxh = '$sfxh'";
  2899. }
  2900. if ($so) {
  2901. $where .= " and shipremarks like '%$so%'";
  2902. }
  2903. if ($source) {
  2904. $where .= " and source = '$source'";
  2905. }
  2906. if ($country) {
  2907. $where .= " and country = '$country'";
  2908. } else {
  2909. if (isset($_SESSION['api'])) {
  2910. foreach ($user as $value) {
  2911. $fgshop .= " shop = " . $value . " or";
  2912. }
  2913. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2914. }
  2915. }
  2916. //数据排序
  2917. $order_str = "librarytime desc";
  2918. if (empty($page)) {
  2919. $start = 0;
  2920. $perpage = 1;
  2921. } else {
  2922. $start = ($page - 1) * $perpage;
  2923. }
  2924. //取得信息列表
  2925. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2926. //格式化数据
  2927. foreach ($info_list as $key => $value) {
  2928. $shop = $this->shop->read($value['shop']);
  2929. $info_list[$key]['shop'] = $shop['shopname'];
  2930. $express = $this->express->read($value['express']);
  2931. $info_list[$key]['express'] = $express['servicename'];
  2932. $warehouse = $this->warehouse->read($value['type']);
  2933. $info_list[$key]['type'] = $warehouse['title'];
  2934. if ($value['librarytime'] == '0') {
  2935. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2936. } else {
  2937. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2938. }
  2939. }
  2940. $total = $this->$sj->find_count($where);
  2941. $pagenum = ceil($total / $perpage);
  2942. $over = $total - ($start + $perpage);
  2943. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2944. echo json_encode($rows);
  2945. exit;
  2946. }
  2947. $this->data['express'] = $this->express->find_all();
  2948. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2949. $this->data['wlshop'] = $wlshop;
  2950. $user = $this->user->get_api($_SESSION['api']);
  2951. $powerid = $this->power->read($user['power']);
  2952. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2953. $pid = '';
  2954. foreach ($powertext as $v) {
  2955. $pid .= " id = " . $v . " or";
  2956. }
  2957. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2958. $this->data['fullorderexcel'] = $fullorderexcel;
  2959. $this->_Template('whlabel_soutorder', $this->data);
  2960. }
  2961. //订单退库
  2962. public function _retreat()
  2963. {
  2964. $post = $this->input->post(NULL, TRUE);
  2965. if (isset($post['page'])) {
  2966. $page = $this->input->post('page', true);
  2967. $perpage = $this->input->post('perpage', true);
  2968. $warehouse = $this->input->post('warehouse', true);
  2969. $timetk = $this->input->post('timetk', true);
  2970. $timetj = $this->input->post('timetj', true);
  2971. $shop = $this->input->post('shop', true);
  2972. $source = $this->input->post('source', true);
  2973. $state = $this->input->post('state', true);
  2974. $review = $this->input->post('review', true);
  2975. $state = $this->input->post('state', true);
  2976. $express = $this->input->post('express', true);
  2977. $orderinfo = $this->input->post('orderinfo', true);
  2978. $user = $this->input->post('user', true);
  2979. $name = $this->input->post('name', true);
  2980. $waybill = $this->input->post('waybill', true);
  2981. $timetk = strtotime($timetk);
  2982. $timetj = strtotime($timetj);
  2983. $where = "(state=206 or state=210) and mergeid = 0";
  2984. if ($warehouse) {
  2985. $where .= " and state = '$warehouse'";
  2986. }
  2987. if ($timetk && $timetj) {
  2988. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2989. }
  2990. if ($shop) {
  2991. $where .= " and shop = '$shop'";
  2992. }
  2993. if ($source) {
  2994. $where .= " and source = '$source'";
  2995. }
  2996. if ($state) {
  2997. $where .= " and state = '$state'";
  2998. }
  2999. if ($review) {
  3000. $where .= " and review = '$review'";
  3001. }
  3002. if ($state) {
  3003. $where .= " and state = '$state'";
  3004. }
  3005. if ($express) {
  3006. $where .= " and express = '$express'";
  3007. }
  3008. if ($orderinfo) {
  3009. $where .= " and orderinfo = '$orderinfo'";
  3010. }
  3011. if ($user) {
  3012. $where .= " and user = '$user'";
  3013. }
  3014. if ($name) {
  3015. $where .= " and name = '$name'";
  3016. }
  3017. if ($waybill) {
  3018. $where .= " and waybill = '$waybill'";
  3019. }
  3020. //数据排序
  3021. $order_str = "id desc";
  3022. if (empty($page)) {
  3023. $start = 0;
  3024. $perpage = 1;
  3025. } else {
  3026. $start = ($page - 1) * $perpage;
  3027. }
  3028. //取得信息列表
  3029. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3030. //格式化数据
  3031. foreach ($info_list as $key => $value) {
  3032. $shop = $this->shop->read($value['shop']);
  3033. $info_list[$key]['shop'] = $shop['shopname'];
  3034. $warehouse = $this->warehouse->read($value['warehouse']);
  3035. $info_list[$key]['warehouse'] = $warehouse['title'];
  3036. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3037. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3038. if ($value['waybill'] == 0) {
  3039. $info_list[$key]['waybill'] = "";
  3040. }
  3041. $express = $this->express->read($value['express']);
  3042. $info_list[$key]['express'] = $express['title'];
  3043. $typeclass = $this->typeclass->read($value['state']);
  3044. $info_list[$key]['state'] = $typeclass['title'];
  3045. }
  3046. $total = $this->fullorder->find_count($where);
  3047. $pagenum = ceil($total / $perpage);
  3048. $over = $total - ($start + $perpage);
  3049. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3050. echo json_encode($rows);
  3051. exit;
  3052. }
  3053. $this->data['express'] = $this->express->find_all();
  3054. $this->_Template('whlabel_retreat', $this->data);
  3055. }
  3056. //退库标签浏览
  3057. public function _retreatlk()
  3058. {
  3059. $post = $this->input->post(NULL, TRUE);
  3060. if (isset($post['page'])) {
  3061. $page = $this->input->post('page', true);
  3062. $perpage = $this->input->post('perpage', true);
  3063. $timetk = $this->input->post('timetk', true);
  3064. $timetj = $this->input->post('timetj', true);
  3065. $sku = $this->input->post('sku', true);
  3066. $warehouse = $this->input->post('warehouse', true);
  3067. $purchase = $this->input->post('purchase', true);
  3068. $orderinfo = $this->input->post('orderinfo', true);
  3069. $waybill = $this->input->post('waybill', true);
  3070. $category = $this->input->post('category', true);
  3071. $size = $this->input->post('size', true);
  3072. $grade = $this->input->post('grade', true);
  3073. $color = $this->input->post('color', true);
  3074. $lowe = $this->input->post('lowe', true);
  3075. $state = $this->input->post('state', true);
  3076. $timetk = strtotime($timetk);
  3077. $timetj = strtotime($timetj);
  3078. $where = "state=2";
  3079. if ($timetk && $timetj) {
  3080. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3081. }
  3082. if ($sku) {
  3083. $where .= " and sku = '$sku'";
  3084. }
  3085. if ($warehouse) {
  3086. $where .= " and warehouse = '$warehouse'";
  3087. }
  3088. if ($purchase) {
  3089. $where .= " and purchase = '$purchase'";
  3090. }
  3091. if ($orderinfo) {
  3092. $where .= " and orderinfo = '$orderinfo'";
  3093. }
  3094. if ($waybill) {
  3095. $where .= " and waybill = '$waybill'";
  3096. }
  3097. if ($category) {
  3098. $where .= " and features like '%-$category-%'";
  3099. }
  3100. if ($size) {
  3101. $where .= " and features like '%-$size-%'";
  3102. }
  3103. if ($grade) {
  3104. $where .= " and features like '%-$grade-%'";
  3105. }
  3106. if ($color) {
  3107. $where .= " and features like '%-$color-%'";
  3108. }
  3109. if ($lowe) {
  3110. $where .= " and features like '%-$lowe-%'";
  3111. }
  3112. //数据排序
  3113. $order_str = "time desc";
  3114. if (empty($page)) {
  3115. $start = 0;
  3116. $perpage = 1;
  3117. } else {
  3118. $start = ($page - 1) * $perpage;
  3119. }
  3120. //取得信息列表
  3121. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3122. foreach ($info_list as $key => $value) {
  3123. $warehouse = $this->warehouse->read($value['warehouse']);
  3124. $info_list[$key]['warehouse'] = $warehouse['title'];
  3125. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3126. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3127. $purchase = $this->purchase->read($value['purchase']);
  3128. $info_list[$key]['purchase'] = $purchase['title'];
  3129. if ($value['outk'] != 0) {
  3130. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3131. } else {
  3132. $info_list[$key]['outk'] = "";
  3133. }
  3134. if ($value['retreat'] != 0) {
  3135. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3136. } else {
  3137. $info_list[$key]['retreat'] = "";
  3138. }
  3139. if ($value['orderinfo'] == 0) {
  3140. $info_list[$key]['orderinfo'] = "";
  3141. }
  3142. if ($value['waybill'] == 0) {
  3143. $info_list[$key]['waybill'] = "";
  3144. }
  3145. }
  3146. $total = $this->whlabel->find_count($where);
  3147. $pagenum = ceil($total / $perpage);
  3148. $over = $total - ($start + $perpage);
  3149. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3150. echo json_encode($rows);
  3151. exit;
  3152. }
  3153. $this->_Template('whlabel_retreatlk', $this->data);
  3154. }
  3155. //更换标签及浏览
  3156. public function _change()
  3157. {
  3158. $post = $this->input->post(NULL, TRUE);
  3159. if (isset($post['page'])) {
  3160. $page = $this->input->post('page', true);
  3161. $perpage = $this->input->post('perpage', true);
  3162. $timetk = $this->input->post('timetk', true);
  3163. $timetj = $this->input->post('timetj', true);
  3164. $label = $this->input->post('label', true);
  3165. $oldlabel = $this->input->post('oldlabel', true);
  3166. $timetk = strtotime($timetk);
  3167. $timetj = strtotime($timetj);
  3168. $where = "state=10 ";
  3169. if ($timetk && $timetj) {
  3170. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3171. }
  3172. if ($label) {
  3173. $where .= " and label = '$label'";
  3174. }
  3175. if ($oldlabel) {
  3176. $where .= " and oldlabel = '$oldlabel'";
  3177. }
  3178. //数据排序
  3179. $order_str = "time asc";
  3180. if (empty($page)) {
  3181. $start = 0;
  3182. $perpage = 1;
  3183. } else {
  3184. $start = ($page - 1) * $perpage;
  3185. }
  3186. //取得信息列表
  3187. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3188. foreach ($info_list as $key => $value) {
  3189. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3190. }
  3191. $total = $this->whlabel->find_count($where);
  3192. $pagenum = ceil($total / $perpage);
  3193. $over = $total - ($start + $perpage);
  3194. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3195. echo json_encode($rows);
  3196. exit;
  3197. }
  3198. $this->_Template('whlabel_change', $this->data);
  3199. }
  3200. //产品标签
  3201. public function _cpbqdc()
  3202. {
  3203. if (isset($_GET['excel'])) {
  3204. $where = "1=1";
  3205. //数据排序
  3206. $order_str = "id desc";
  3207. if (empty($page)) {
  3208. $start = 0;
  3209. $perpage = 1;
  3210. } else {
  3211. $start = ($page - 1) * $perpage;
  3212. }
  3213. $warehouse = $this->input->get('warehouse', true);
  3214. $state = $this->input->get('state', true);
  3215. $timetk = $this->input->get('timetkk', true);
  3216. $timetj = $this->input->get('timetjj', true);
  3217. $timetk = strtotime($timetk);
  3218. $timetj = strtotime($timetj);
  3219. if ($warehouse) {
  3220. $where .= " and warehouse = '$warehouse'";
  3221. }
  3222. if ($state || $state == 0) {
  3223. $where .= " and state = '$state'";
  3224. }
  3225. if ($timetk && $timetj) {
  3226. $where .= " and time > '$timetk' and time < '$timetj'";
  3227. }
  3228. //取得信息列表
  3229. $info_list = $this->whlabel->find_all($where, '*');
  3230. $rows = array();
  3231. $list = array();
  3232. foreach ($info_list as $key => $value) {
  3233. $rows[$value['time']] = $value; //所有数据sku
  3234. }
  3235. foreach ($rows as $value) {
  3236. $warehouse = $this->warehouse->read($value['warehouse']);
  3237. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3238. $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);
  3239. }
  3240. $title = "产品标签统计表";
  3241. $titlename = "<table border=1>
  3242. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3243. <tr align='center'>
  3244. <td>仓库</td>
  3245. <td>SKU</td>
  3246. <td>产品</td>
  3247. <td>入库时间</td>
  3248. <td>操作时间</td>
  3249. <td>备注</td>
  3250. <td>数量</td>
  3251. </tr>
  3252. </table>";
  3253. $filename = $title . ".xls";
  3254. $tail = "";
  3255. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3256. }
  3257. }
  3258. //进销存导出
  3259. public function _exceljxc()
  3260. {
  3261. $classid = $this->classid->sku();
  3262. $pm = $classid;
  3263. $typeclass = array();
  3264. $tc = $this->typeclass->find_all();
  3265. foreach ($tc as $v) {
  3266. $typeclass[$v['id']] = $v;
  3267. }
  3268. $prc = array();
  3269. $purchase = $this->purchase->find_all();
  3270. foreach ($purchase as $k => $v) {
  3271. $prc[$v['id']] = $v['title'];
  3272. }
  3273. if (isset($_GET['excel'])) {
  3274. $where = "sku != 'Preset'";
  3275. //数据排序
  3276. $order_str = "id desc";
  3277. if (empty($page)) {
  3278. $start = 0;
  3279. $perpage = 1;
  3280. } else {
  3281. $start = ($page - 1) * $perpage;
  3282. }
  3283. $category = $this->input->get('category', true);
  3284. $warehouse = $this->input->get('warehouse', true);
  3285. $excelid = $this->input->get('sid', true);
  3286. if ($category) {
  3287. $where .= " and features like '%-$category-%'";
  3288. }
  3289. if ($warehouse) {
  3290. $where .= " and warehouse = '$warehouse'";
  3291. }
  3292. $xzid = '';
  3293. if ($excelid) {
  3294. $excelid = explode(',', trim($excelid, ','));
  3295. foreach ($excelid as $key => $value) {
  3296. $xzid .= " id = " . $value . " or";
  3297. }
  3298. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3299. }
  3300. //取得信息列表
  3301. /**
  3302. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3303. $rows = array();$list = array();
  3304. foreach ($info_list as $key=>$value)
  3305. {
  3306. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3307. }
  3308. **/
  3309. $wt = array();
  3310. $whlabel_type = $this->whlabel_type->find_all();
  3311. foreach ($whlabel_type as $v) {
  3312. $wt[$v['id']] = $v['title'];
  3313. }
  3314. $wh = array();
  3315. $w = $this->warehouse->find_all('1=1', 'id,title');
  3316. foreach ($w as $v) {
  3317. $wh[$v['id']] = $v['title'];
  3318. }
  3319. $list = array();
  3320. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3321. foreach ($rows as $key => $value) {
  3322. if (isset($wt[$value['type']])) {
  3323. $rows[$key]['type'] = $wt[$value['type']];
  3324. } else {
  3325. $rows[$key]['type'] = '未设置';
  3326. }
  3327. $bm = '03';
  3328. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3329. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3330. $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');
  3331. $details = array();
  3332. $cpid = array();
  3333. $cpbz = array();
  3334. $c = 0;
  3335. $g = 0;
  3336. $x = 0;
  3337. $t = 0;
  3338. $s = 0;
  3339. $q = 0;
  3340. foreach ($sd as $k => $v) {
  3341. if ($v['state'] == 0) {
  3342. $c++;
  3343. if ($v['cpid'] != 0) {
  3344. $cpid[$v['cpid']] = $v['cpid'];
  3345. }
  3346. if ($v['cpbz'] != '') {
  3347. $cpbz[$v['cpbz']] = $v['cpbz'];
  3348. }
  3349. }
  3350. if ($v['state'] != 9) {
  3351. $g++;
  3352. }
  3353. if ($v['state'] == 1) {
  3354. $x++;
  3355. }
  3356. if ($v['state'] == 2) {
  3357. $t++;
  3358. }
  3359. if ($v['state'] == 8) {
  3360. $s++;
  3361. }
  3362. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3363. $q++;
  3364. }
  3365. $details[$v['details']] = $v['details'];
  3366. }
  3367. $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'] . '"');
  3368. $rows[$key]['details'] = implode("、", $details);
  3369. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3370. $number = $value['number'];
  3371. $ftime = time() - 15 * 24 * 3600;
  3372. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3373. $rows[$key]['number'] = $g;
  3374. $rows[$key]['c'] = $c;
  3375. $rows[$key]['x'] = $x;
  3376. $rows[$key]['t'] = $t;
  3377. $rows[$key]['s'] = $s;
  3378. $rows[$key]['q'] = $q;
  3379. $rows[$key]['z'] = $z;
  3380. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3381. $features = explode('-', trim($features, '-'));
  3382. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3383. // $pm = $classid;
  3384. // $jm = $classid;
  3385. // foreach($features as $k=>$v)
  3386. // {
  3387. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3388. // {
  3389. // if($typeclass[$v]['bm'] != '')
  3390. // {
  3391. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3392. // }
  3393. // }
  3394. // if($v != 0)
  3395. // {
  3396. // if(!isset($typeclass[$v]))
  3397. // {
  3398. // continue;
  3399. // }
  3400. // if(isset($pm[$typeclass[$v]['classid']]))
  3401. // {
  3402. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3403. // {
  3404. // $tz = explode('|',$typeclass[$v]['zh']);
  3405. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3406. // }
  3407. // else
  3408. // {
  3409. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3410. // }
  3411. // }
  3412. // if(isset($jm[$typeclass[$v]['classid']]))
  3413. // {
  3414. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3415. // }
  3416. // }
  3417. // }
  3418. // $jm = array_filter($jm);
  3419. // $rows[$key]['bs'] = implode("-",$jm);
  3420. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3421. // $zh = implode(" ",$pm);
  3422. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3423. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3424. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3425. // $rows[$key]['features'] = $zh;
  3426. }
  3427. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3428. $final_list = [];
  3429. foreach ($list as $k => $v) {
  3430. if (empty($v['sku'])) {
  3431. continue;
  3432. }
  3433. $final_list[] = [
  3434. "warehouse" => $v["warehouse"],
  3435. "purchase" => $v["purchase"],
  3436. "details" => $v["details"],
  3437. "cpid" => $v["cpid"],
  3438. "dbcontent" => $v["dbcontent"],
  3439. "sku" => $v["sku"],
  3440. "cs" => $v["bm"],
  3441. "bs" => $v["jm"],
  3442. "title" => $v["title"],
  3443. "features" => $v["pm"],
  3444. "cpbz" => $v["cpbz"],
  3445. "sm" => $v["sm"],
  3446. "type" => $v["type"],
  3447. "number" => $v["number"],
  3448. "c" => $v["c"],
  3449. "x" => $v["x"],
  3450. "t" => $v["t"],
  3451. "s" => $v["s"],
  3452. "q" => $v["q"],
  3453. "z" => $v["z"],
  3454. "weight" => $v['weight'],
  3455. ];
  3456. }
  3457. $title = "总进销存统计表";
  3458. $titlename = "<table border=1>
  3459. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3460. <tr align='center'>
  3461. <td>仓库</td>
  3462. <td>供应商</td>
  3463. <td>位置</td>
  3464. <td>库存编码</td>
  3465. <td>类目</td>
  3466. <td>SKU</td>
  3467. <td>用友编码</td>
  3468. <td>用友料号</td>
  3469. <td>商品名称</td>
  3470. <td>商品中文</td>
  3471. <td>产品备注</td>
  3472. <td>说明</td>
  3473. <td>类型</td>
  3474. <td>入库总量</td>
  3475. <td>库存数量</td>
  3476. <td>销售数量</td>
  3477. <td>退货数量</td>
  3478. <td>删除数量</td>
  3479. <td>其它操作</td>
  3480. <td>占单数量</td>
  3481. <td>重量(g)</td>
  3482. </tr>
  3483. </table>";
  3484. $filename = $title . ".xls";
  3485. $tail = "";
  3486. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3487. }
  3488. }
  3489. //入库导出
  3490. public function _excelr()
  3491. {
  3492. if (isset($_GET['excel'])) {
  3493. $category = $this->input->get('category', true);
  3494. $size = $this->input->get('size', true);
  3495. $grade = $this->input->get('grade', true);
  3496. $color = $this->input->get('color', true);
  3497. $lowe = $this->input->get('lowe', true);
  3498. $sku = $this->input->get('sku', true);
  3499. $warehouse = $this->input->get('warehouse', true);
  3500. $purchase = $this->input->get('purchase', true);
  3501. $ktime = $this->input->get('ktime', true);
  3502. $jtime = $this->input->get('jtime', true);
  3503. $ktime = strtotime($ktime);
  3504. $jtime = strtotime($jtime);
  3505. $where = "1=1";
  3506. $gj = "";
  3507. $ck = "";
  3508. if ($category) {
  3509. $where .= " and features like '%-$category-%'";
  3510. }
  3511. if ($size) {
  3512. $where .= " and features like '%-$size-%'";
  3513. }
  3514. if ($grade) {
  3515. $where .= " and features like '%-$grade-%'";
  3516. }
  3517. if ($color) {
  3518. $where .= " and features like '%-$color-%'";
  3519. }
  3520. if ($lowe) {
  3521. $where .= " and features like '%-$lowe-%'";
  3522. }
  3523. if ($warehouse) {
  3524. $where .= " and warehouse = '$warehouse'";
  3525. }
  3526. if ($purchase) {
  3527. $where .= " and purchase = '$purchase'";
  3528. }
  3529. if ($sku) {
  3530. $where .= " and sku = '$sku'";
  3531. }
  3532. if ($ktime && $jtime) {
  3533. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3534. }
  3535. //数据排序
  3536. $order_str = "id desc";
  3537. if (empty($page)) {
  3538. $start = 0;
  3539. $perpage = 1;
  3540. } else {
  3541. $start = ($page - 1) * $perpage;
  3542. }
  3543. $list = array();
  3544. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3545. foreach ($rows as $value) {
  3546. $ck = $this->warehouse->read($value['warehouse']);
  3547. $warehouse = $ck['title'];
  3548. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3549. $retreatwarehouse = $tkck['title'];
  3550. $gy = $this->purchase->read($value['purchase']);
  3551. $purchase = $gy['title'];
  3552. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3553. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3554. }
  3555. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3556. $titlename = "<table border=1>
  3557. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3558. <tr align='center'>
  3559. <td>仓库</td>
  3560. <td>SKU</td>
  3561. <td>产品</td>
  3562. <td>时间</td>
  3563. <td>数量</td>
  3564. </tr>
  3565. </table>";
  3566. $filename = $title . ".xls";
  3567. $tail = "";
  3568. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3569. }
  3570. }
  3571. //出库、退库导出
  3572. public function _excelct()
  3573. {
  3574. $classid = $this->classid->sku();
  3575. $pm = $classid;
  3576. $typeclass = array();
  3577. $tc = $this->typeclass->find_all();
  3578. foreach ($tc as $v) {
  3579. $typeclass[$v['id']] = $v;
  3580. }
  3581. $prc = array();
  3582. $purchase = $this->purchase->find_all();
  3583. foreach ($purchase as $k => $v) {
  3584. $prc[$v['id']] = $v['title'];
  3585. }
  3586. if (isset($_GET['excel'])) {
  3587. $wh = array();
  3588. $w = $this->warehouse->find_all('1=1', 'id,title');
  3589. foreach ($w as $v) {
  3590. $wh[$v['id']] = $v['title'];
  3591. }
  3592. $type = $this->input->get('excel', true);
  3593. $category = $this->input->get('category', true);
  3594. $size = $this->input->get('size', true);
  3595. $grade = $this->input->get('grade', true);
  3596. $color = $this->input->get('color', true);
  3597. $lowe = $this->input->get('lowe', true);
  3598. $sku = $this->input->get('sku', true);
  3599. $warehouse = $this->input->get('warehouse', true);
  3600. $lacetype = $this->input->get('lacetype', true);
  3601. $lacecolor = $this->input->get('lacecolor', true);
  3602. $density = $this->input->get('density', true);
  3603. $haircap = $this->input->get('haircap', true);
  3604. $purchase = $this->input->get('purchase', true);
  3605. $title = $this->input->get('title', true);
  3606. $state = $this->input->get('state', true);
  3607. $sid = $this->input->get('sid', true);
  3608. $ktime = $this->input->get('ktime', true);
  3609. $jtime = $this->input->get('jtime', true);
  3610. $ktime = strtotime($ktime);
  3611. $jtime = strtotime($jtime);
  3612. $where = "1=1";
  3613. $gj = "";
  3614. $ck = "";
  3615. if ($category) {
  3616. $where .= " and features like '%-$category-%'";
  3617. }
  3618. if ($size) {
  3619. $where .= " and features like '%-$size-%'";
  3620. }
  3621. if ($grade) {
  3622. $where .= " and features like '%-$grade-%'";
  3623. }
  3624. if ($color) {
  3625. $where .= " and features like '%-$color-%'";
  3626. }
  3627. if ($lowe) {
  3628. $where .= " and features like '%-$lowe-%'";
  3629. }
  3630. if ($warehouse) {
  3631. $where .= " and warehouse = '$warehouse'";
  3632. }
  3633. if ($purchase) {
  3634. $where .= " and purchase = '$purchase'";
  3635. }
  3636. if ($state) {
  3637. $where .= " and state = '$state'";
  3638. }
  3639. if ($lacetype) {
  3640. $where .= " and features like '%-$lacetype-%'";
  3641. }
  3642. if ($lacecolor) {
  3643. $where .= " and features like '%-$lacecolor-%'";
  3644. }
  3645. if ($density) {
  3646. $where .= " and features like '%-$density-%'";
  3647. }
  3648. if ($haircap) {
  3649. $where .= " and features like '%-$haircap-%'";
  3650. }
  3651. if ($title) {
  3652. $title = trim($title, ' ');
  3653. $title = trim($title, ' ');
  3654. $where .= " and title like '%$title%'";
  3655. }
  3656. if ($sku) {
  3657. $sku = trim($sku, ' ');
  3658. $sku = trim($sku, ' ');
  3659. $where .= " and sku like '%$sku%'";
  3660. }
  3661. if ($ktime && $jtime) {
  3662. if ($type == 1) {
  3663. $tl = '出库';
  3664. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3665. } else if ($type == 2) {
  3666. $tl = '退库';
  3667. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3668. } else if ($type == 3) {
  3669. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3670. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3671. } else if ($type == 4) {
  3672. $tl = '出库+零售';
  3673. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3674. } else if ($type == 5) {
  3675. $tl = '零售';
  3676. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3677. }
  3678. }
  3679. $sidwhere = '';
  3680. if ($sid) {
  3681. $sd = "";
  3682. $s = explode(',', trim($sid, ','));
  3683. foreach ($s as $value) {
  3684. $sd .= " id = " . $value . " or";
  3685. }
  3686. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3687. }
  3688. //数据排序
  3689. $order_str = "time desc";
  3690. if (empty($page)) {
  3691. $start = 0;
  3692. $perpage = 1;
  3693. } else {
  3694. $start = ($page - 1) * $perpage;
  3695. }
  3696. //取得信息列表
  3697. if ($type != 3 && $type != 5) {
  3698. if ($type == 1 || $type == 4) {
  3699. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3700. foreach ($info_list as $key => $value) {
  3701. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3702. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3703. $warehouse = $this->warehouse->read($value['warehouse']);
  3704. $info_list[$key]['warehouse'] = $warehouse['title'];
  3705. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3706. $features = explode('-', trim($features, '-'));
  3707. $pm = $classid;
  3708. foreach ($features as $k => $v) {
  3709. if ($v != 0) {
  3710. if (!isset($typeclass[$v])) {
  3711. continue;
  3712. }
  3713. if (isset($pm[$typeclass[$v]['classid']])) {
  3714. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3715. $tz = explode('|', $typeclass[$v]['zh']);
  3716. $pm[$typeclass[$v]['classid']] = $tz[0];
  3717. } else {
  3718. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3719. }
  3720. }
  3721. }
  3722. }
  3723. $zh = implode(" ", $pm);
  3724. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3725. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3726. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3727. $info_list[$key]['features'] = $zh;
  3728. }
  3729. $final_list = [];
  3730. foreach($info_list as $k=>$v){
  3731. $number = "";
  3732. if(!empty($v['orderinfo'])){
  3733. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3734. if(!empty($tmp_info['number'])){
  3735. $number = $tmp_info['number'];
  3736. }
  3737. }
  3738. $final_list[] = [
  3739. 'warehouse'=>$v['warehouse'],
  3740. 'purchase'=>$v['purchase'],
  3741. 'sku'=>$v['sku'],
  3742. 'title'=>$v['title'],
  3743. 'features'=>$v['features'],
  3744. 'label'=>$v['label'],
  3745. 'orderinfo'=>$v['orderinfo'],
  3746. 'number'=>$number,
  3747. 'waybill'=>$v['waybill'],
  3748. 'outk'=>$v['outk'],
  3749. ];
  3750. }
  3751. } else {
  3752. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3753. foreach ($info_list as $key => $value) {
  3754. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3755. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3756. $warehouse = $this->warehouse->read($value['warehouse']);
  3757. $info_list[$key]['warehouse'] = $warehouse['title'];
  3758. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3759. $features = explode('-', trim($features, '-'));
  3760. $pm = $classid;
  3761. foreach ($features as $k => $v) {
  3762. if ($v != 0) {
  3763. if (!isset($typeclass[$v])) {
  3764. continue;
  3765. }
  3766. if (isset($pm[$typeclass[$v]['classid']])) {
  3767. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3768. $tz = explode('|', $typeclass[$v]['zh']);
  3769. $pm[$typeclass[$v]['classid']] = $tz[0];
  3770. } else {
  3771. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3772. }
  3773. }
  3774. }
  3775. }
  3776. $zh = implode(" ", $pm);
  3777. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3778. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3779. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3780. $info_list[$key]['features'] = $zh;
  3781. }
  3782. $final_list = [];
  3783. foreach($info_list as $k=>$v){
  3784. $number = "";
  3785. if(!empty($v['orderinfo'])){
  3786. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3787. if(!empty($tmp_info['number'])){
  3788. $number = $tmp_info['number'];
  3789. }
  3790. }
  3791. $final_list[] = [
  3792. 'warehouse'=>$v['warehouse'],
  3793. 'purchase'=>$v['purchase'],
  3794. 'sku'=>$v['sku'],
  3795. 'title'=>$v['title'],
  3796. 'features'=>$v['features'],
  3797. 'label'=>$v['label'],
  3798. 'orderinfo'=>$v['orderinfo'],
  3799. 'number'=>$number,
  3800. 'waybill'=>$v['waybill'],
  3801. 'retreat'=>$v['retreat'],
  3802. ];
  3803. }
  3804. }
  3805. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3806. $titlename = "<table border=1>
  3807. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3808. <tr align='center'>
  3809. <td>仓库</td>
  3810. <td>供应商</td>
  3811. <td>SKU</td>
  3812. <td>商品名称</td>
  3813. <td>商品中文</td>
  3814. <td>标签</td>
  3815. <td>订单号</td>
  3816. <td>订单编码</td>
  3817. <td>运单号</td>
  3818. <td>" . $tl . "时间(中国时间)</td>
  3819. </tr>
  3820. </table>";
  3821. $filename = $title . ".xls";
  3822. $tail = "";
  3823. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3824. } else if ($type == 5) {
  3825. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3826. foreach ($info_list as $key => $value) {
  3827. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3828. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3829. $warehouse = $this->warehouse->read($value['warehouse']);
  3830. $info_list[$key]['warehouse'] = $warehouse['title'];
  3831. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3832. $features = explode('-', trim($features, '-'));
  3833. $pm = $classid;
  3834. foreach ($features as $k => $v) {
  3835. if ($v != 0) {
  3836. if (!isset($typeclass[$v])) {
  3837. continue;
  3838. }
  3839. if (isset($pm[$typeclass[$v]['classid']])) {
  3840. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3841. $tz = explode('|', $typeclass[$v]['zh']);
  3842. $pm[$typeclass[$v]['classid']] = $tz[0];
  3843. } else {
  3844. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3845. }
  3846. }
  3847. }
  3848. }
  3849. $zh = implode(" ", $pm);
  3850. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3851. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3852. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3853. $info_list[$key]['features'] = $zh;
  3854. }
  3855. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3856. $titlename = "<table border=1>
  3857. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3858. <tr align='center'>
  3859. <td>仓库</td>
  3860. <td>供应商</td>
  3861. <td>SKU</td>
  3862. <td>商品名称</td>
  3863. <td>商品中文</td>
  3864. <td>标签</td>
  3865. <td>" . $tl . "时间(中国时间)</td>
  3866. </tr>
  3867. </table>";
  3868. $filename = $title . ".xls";
  3869. $tail = "";
  3870. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3871. } else {
  3872. /**
  3873. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3874. $rows = array();$list = array();
  3875. foreach ($info_list as $key=>$value)
  3876. {
  3877. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3878. }
  3879. **/
  3880. $wh = array();
  3881. $w = $this->warehouse->find_all('1=1', 'id,title');
  3882. foreach ($w as $v) {
  3883. $wh[$v['id']] = $v['title'];
  3884. }
  3885. $wt = array();
  3886. $whlabel_type = $this->whlabel_type->find_all();
  3887. foreach ($whlabel_type as $v) {
  3888. $wt[$v['id']] = $v['title'];
  3889. }
  3890. $classid = $this->classid->sku();
  3891. $list = array();
  3892. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3893. foreach ($rows as $key => $value) {
  3894. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3895. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3896. $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');
  3897. $details = array();
  3898. $cpid = array();
  3899. $cpbz = array();
  3900. $c = 0;
  3901. $g = 0;
  3902. $x = 0;
  3903. $t = 0;
  3904. $s = 0;
  3905. $q = 0;
  3906. foreach ($sd as $k => $v) {
  3907. if ($v['state'] == 0) {
  3908. $c++;
  3909. }
  3910. if ($v['state'] != 9) {
  3911. $g++;
  3912. }
  3913. if ($v['outk'] > 1) {
  3914. $x++;
  3915. }
  3916. if ($v['retreat'] > 0) {
  3917. $t++;
  3918. }
  3919. if ($v['state'] == 8) {
  3920. $s++;
  3921. }
  3922. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3923. $q++;
  3924. }
  3925. $details[$v['details']] = $v['details'];
  3926. if ($v['cpid'] != 0) {
  3927. $cpid[$v['cpid']] = $v['cpid'];
  3928. }
  3929. if ($v['cpbz'] != '') {
  3930. $cpbz[$v['cpbz']] = $v['cpbz'];
  3931. }
  3932. }
  3933. if (isset($wt[$value['type']])) {
  3934. $rows[$key]['type'] = $wt[$value['type']];
  3935. } else {
  3936. $rows[$key]['type'] = '未设置';
  3937. }
  3938. $rows[$key]['details'] = implode("、", $details);
  3939. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3940. $ftime = time() - 15 * 24 * 3600;
  3941. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3942. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3943. $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);
  3944. $rows[$key]['c'] = $c;
  3945. $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);
  3946. $rows[$key]['t'] = $t;
  3947. $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'] . '"');
  3948. $rows[$key]['z'] = $z;
  3949. // $jm = $classid;
  3950. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3951. $features = explode('-', trim($features, '-'));
  3952. // $pm = $classid;
  3953. // foreach ($features as $k => $v) {
  3954. // if ($v != 0) {
  3955. // if (!isset($typeclass[$v])) {
  3956. // continue;
  3957. // }
  3958. // if (isset($pm[$typeclass[$v]['classid']])) {
  3959. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3960. // $tz = explode('|', $typeclass[$v]['zh']);
  3961. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3962. // } else {
  3963. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3964. // }
  3965. // if (isset($jm[$typeclass[$v]['classid']])) {
  3966. // if ($typeclass[$v]['jm']) {
  3967. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3968. // }
  3969. // }
  3970. // }
  3971. // }
  3972. // }
  3973. // $zh = implode(" ", $pm);
  3974. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3975. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3976. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3977. // $rows[$key]['features'] = $zh;
  3978. // $jm = array_filter($jm); //去除空值
  3979. // $jm = implode("-", $jm);
  3980. // $rows[$key]['jm'] = $jm;
  3981. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3982. }
  3983. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3984. // echo "<pre>";
  3985. // print_r($tmp_list);
  3986. // die;
  3987. $final_list =[];
  3988. foreach($tmp_list as $k=>$v){
  3989. $final_list[] = [
  3990. "warehouse"=>$v['warehouse'],
  3991. "purchase"=>$v['purchase'],
  3992. "details"=>$v['details'],
  3993. "cpid"=>$v['cpid'],
  3994. "sku"=>$v['sku'],
  3995. "title"=>$v['title'],
  3996. "features"=>$v['pm'],
  3997. "cpbz"=>$v['cpbz'],
  3998. "sm"=>$v['sm'],
  3999. "type"=>$v['type'],
  4000. "g"=>$v["g"],
  4001. "c"=>$v["c"],
  4002. "x"=>$v["x"],
  4003. "t"=>$v["t"],
  4004. "z"=>$v["z"],
  4005. "jm"=>$v["jm"],
  4006. "weight"=>$v["weight"],
  4007. "asd"=>$v["asd"],
  4008. ];
  4009. }
  4010. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4011. $titlename = "<table border=1>
  4012. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4013. <tr align='center'>
  4014. <td>仓库</td>
  4015. <td>供应商</td>
  4016. <td>位置</td>
  4017. <td>库存编码</td>
  4018. <td>SKU</td>
  4019. <td>商品名称</td>
  4020. <td>商品中文</td>
  4021. <td>产品备注</td>
  4022. <td>说明</td>
  4023. <td>类型</td>
  4024. <td>入库总量</td>
  4025. <td>库存数量</td>
  4026. <td>销售数量</td>
  4027. <td>退货数量</td>
  4028. <td>占单数量</td>
  4029. <td>料号</td>
  4030. <td>重量</td>
  4031. <td>类目</td>
  4032. </tr>
  4033. </table>";
  4034. $filename = $title . ".xls";
  4035. $tail = "";
  4036. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4037. }
  4038. }
  4039. }
  4040. //出库+入库数据整合
  4041. public function _excelcr()
  4042. {
  4043. if (isset($_GET['excel'])) {
  4044. $type = $this->input->get('excel', true);
  4045. $category = $this->input->get('category', true);
  4046. $size = $this->input->get('size', true);
  4047. $grade = $this->input->get('grade', true);
  4048. $color = $this->input->get('color', true);
  4049. $lowe = $this->input->get('lowe', true);
  4050. $sku = $this->input->get('sku', true);
  4051. $warehouse = $this->input->get('warehouse', true);
  4052. $purchase = $this->input->get('purchase', true);
  4053. $state = $this->input->get('state', true);
  4054. $sid = $this->input->get('sid', true);
  4055. $ktime = $this->input->get('ktime', true);
  4056. $jtime = $this->input->get('jtime', true);
  4057. $ktime = strtotime($ktime);
  4058. $jtime = strtotime($jtime);
  4059. $where = "1=1";
  4060. $gj = "";
  4061. $ck = "";
  4062. if ($category) {
  4063. $where .= " and features like '%-$category-%'";
  4064. }
  4065. if ($size) {
  4066. $where .= " and features like '%-$size-%'";
  4067. }
  4068. if ($grade) {
  4069. $where .= " and features like '%-$grade-%'";
  4070. }
  4071. if ($color) {
  4072. $where .= " and features like '%-$color-%'";
  4073. }
  4074. if ($lowe) {
  4075. $where .= " and features like '%-$lowe-%'";
  4076. }
  4077. if ($warehouse) {
  4078. $where .= " and warehouse = '$warehouse'";
  4079. }
  4080. if ($purchase) {
  4081. $where .= " and purchase = '$purchase'";
  4082. }
  4083. if ($state) {
  4084. $where .= " and state = '$state'";
  4085. }
  4086. if ($sku) {
  4087. $where .= " and sku like '%$sku%'";
  4088. }
  4089. if ($ktime && $jtime) {
  4090. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4091. }
  4092. $sidwhere = '';
  4093. if ($sid) {
  4094. $sd = "";
  4095. $s = explode(',', trim($sid, ','));
  4096. foreach ($s as $value) {
  4097. $sd .= " id = " . $value . " or";
  4098. }
  4099. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4100. }
  4101. //取得信息列表
  4102. $timeread = $ktime;
  4103. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4104. $timelist = array();
  4105. for ($i = 0; $i < $timenum; $i++) {
  4106. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4107. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4108. }
  4109. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4110. //echo "<pre>";
  4111. //print_r($info_list);
  4112. //exit();
  4113. $rows = array();
  4114. $list = array();
  4115. foreach ($info_list as $key => $value) {
  4116. $thistime = $timelist;
  4117. if (isset($rows[strtolower($value['sku'])])) {
  4118. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4119. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4120. }
  4121. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4122. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4123. }
  4124. } else {
  4125. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4126. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4127. }
  4128. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4129. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4130. }
  4131. $rows[strtolower($value['sku'])] = $thistime;
  4132. }
  4133. }
  4134. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4135. <head>
  4136. <!--[if gte mso 9]><xml>
  4137. <x:ExcelWorkbook>
  4138. <x:ExcelWorksheets>
  4139. <x:ExcelWorksheet>
  4140. <x:Name>EXCEL</x:Name>
  4141. <x:WorksheetOptions>
  4142. <x:Print>
  4143. <x:ValidPrinterInfo />
  4144. </x:Print>
  4145. </x:WorksheetOptions>
  4146. </x:ExcelWorksheet>
  4147. </x:ExcelWorksheets>
  4148. </x:ExcelWorkbook>
  4149. </xml>
  4150. <![endif]-->
  4151. </head><body>";
  4152. $str .= "<table border=1><tr><td>SKU</td>";
  4153. foreach ($timelist as $k => $v) {
  4154. $str .= "<td>" . $k . "出库</td>";
  4155. $str .= "<td>" . $k . "入库</td>";
  4156. }
  4157. $str .= "</tr></table>";
  4158. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4159. foreach ($rows as $key => $val) {
  4160. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4161. foreach ($val as $k => $v) {
  4162. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4163. if ($val[$k]['r'] > 0) {
  4164. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4165. } else {
  4166. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4167. }
  4168. }
  4169. $str .= "</tr>";
  4170. }
  4171. $str .= "</table>";
  4172. $str .= "</body></html>";
  4173. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4174. header("Content-type: application/octet-stream");
  4175. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4176. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4177. header("Pragma: no-cache");
  4178. header("Expires: 0");
  4179. exit($str);
  4180. }
  4181. }
  4182. //数量调整模板导出
  4183. public function _presetout()
  4184. {
  4185. if (isset($_GET['excel'])) {
  4186. $where = "sku != 'Preset' and purchase != 0";
  4187. //数据排序
  4188. $order_str = "id desc";
  4189. if (empty($page)) {
  4190. $start = 0;
  4191. $perpage = 1;
  4192. } else {
  4193. $start = ($page - 1) * $perpage;
  4194. }
  4195. //取得信息列表
  4196. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4197. $rows = array();
  4198. $list = array();
  4199. foreach ($info_list as $value) {
  4200. $warehouse = $this->warehouse->read($value['warehouse']);
  4201. $number = $value['number'];
  4202. $ftime = time() - 15 * 24 * 3600;
  4203. $purchase = $this->purchase->read($value['purchase']);
  4204. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4205. }
  4206. $title = "库存模板";
  4207. $titlename = "<table border=1>
  4208. <tr align='center'>
  4209. <td>仓库</td>
  4210. <td>供应商编码</td>
  4211. <td>SKU</td>
  4212. <td>增减数量(正数或负数)</td>
  4213. <td>增减备注</td>
  4214. <td>扣减方式:0减少库存1删除库存</td>
  4215. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4216. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4217. </tr>
  4218. </table>";
  4219. $filename = $title . ".xls";
  4220. $tail = "";
  4221. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4222. }
  4223. }
  4224. //数量调整模板导入
  4225. public function _presetedit()
  4226. {
  4227. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4228. $config['upload_path'] = '.' . $dir;
  4229. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4230. $config['allowed_types'] = 'xls|xlsx|csv';
  4231. $config['max_size'] = 10240;
  4232. $this->load->library('upload', $config);
  4233. $this->upload->initialize($config);
  4234. if ($this->upload->do_upload('userfile')) {
  4235. $full_path = $dir . $this->upload->data('file_name');
  4236. $fileName = '.' . $full_path;
  4237. if (!file_exists($fileName)) {
  4238. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4239. exit;
  4240. } else {
  4241. require_once "./data/excel/PHPExcel/IOFactory.php";
  4242. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4243. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4244. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4245. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4246. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4247. ++$column; //如果列数大于26行
  4248. $list = array();
  4249. for ($i = 2; $i <= $row; $i++) // 行数循环
  4250. {
  4251. $data = array();
  4252. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4253. {
  4254. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4255. }
  4256. $list[] = $data;
  4257. }
  4258. }
  4259. $i = 0;
  4260. $j = 0;
  4261. $ed = array();
  4262. foreach ($list as $key => $value) {
  4263. $time = time();
  4264. if ($value['0'] == "") {
  4265. continue;
  4266. }
  4267. $warehouse = $this->warehouse->get_title($value['0']);
  4268. $purchase = $this->purchase->get_bm($value['1']);
  4269. $sku = $value['2'];
  4270. $num = $value['3']; //调整数量
  4271. $text = $value['4']; //扣减说明
  4272. $type = $value['5']; //调整方式0扣减1删除
  4273. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4274. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4275. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4276. if (!$purchase) //如果没有这个SKU
  4277. {
  4278. $ed[] = array($purchase . '-不存在此供应商编码');
  4279. $j++;
  4280. continue;
  4281. }
  4282. if (!$d) //如果没有这个SKU
  4283. {
  4284. $ed[] = array($sku . '-库存中不存在此SKU');
  4285. $j++;
  4286. continue;
  4287. }
  4288. if (!isset($warehouse['id'])) {
  4289. $ed[] = array($sku . '-仓库名错误!');
  4290. $j++;
  4291. continue;
  4292. }
  4293. if ($type != '0' && $type != '1') {
  4294. $ed[] = array($sku . '-扣减方式填写错误!');
  4295. $j++;
  4296. continue;
  4297. }
  4298. if ($num < 0) //扣减库存
  4299. {
  4300. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4301. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4302. $j++;
  4303. continue;
  4304. }
  4305. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4306. if (count($data) < abs($num)) {
  4307. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4308. $j++;
  4309. continue;
  4310. }
  4311. if ($type == 0) //如果扣减方式为 扣减库存
  4312. {
  4313. for ($i = 0; $i < abs($num); $i++) {
  4314. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4315. }
  4316. } else if ($type == 1) {
  4317. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4318. if (count($zt) > 0) {
  4319. $ed[] = array($sku . '-有在途库存无法删除!');
  4320. $j++;
  4321. continue;
  4322. }
  4323. for ($i = 0; $i < abs($num); $i++) {
  4324. $this->whlabel->remove($data[$i]['id']);
  4325. }
  4326. }
  4327. } else if ($num > 0) //增加库存
  4328. {
  4329. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4330. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4331. $j++;
  4332. continue;
  4333. }
  4334. $post['sku'] = $d['sku'];
  4335. $post['shop'] = $d['shop'];
  4336. $post['warehouse'] = $warehouse['id'];
  4337. $post['purchase'] = $purchase['id'];
  4338. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4339. $post['state'] = 0;
  4340. $post['title'] = $d['title'];
  4341. $post['number'] = $d['number'];
  4342. $post['features'] = $d['features'];
  4343. $post['enter'] = $time;
  4344. $post['time'] = $time; //操作时间
  4345. $post['rktype'] = $rktype;
  4346. for ($i = 0; $i < $num; $i++) {
  4347. $post['label'] = time() . rand(100, 999) . $i;
  4348. $this->whlabel->insert($post);
  4349. }
  4350. }
  4351. sleep(1); //防止入库时间一样,需要延迟1秒
  4352. }
  4353. if ($j > 0) {
  4354. $tt = date('Ymd', time());
  4355. $title = '库存导入错误信息-' . $tt;
  4356. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4357. $tail = "\n";
  4358. $filename = $title . ".xls";
  4359. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4360. $dir = '/data/excel/' . $time . '/';
  4361. $file_name = 'error_' . $time . rand(1000, 9999);
  4362. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4363. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4364. fwrite($myfile, $ecl);
  4365. fclose($myfile);
  4366. $error = $dir . $file_name . '.xls';
  4367. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4368. exit;
  4369. } else {
  4370. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4371. exit;
  4372. }
  4373. }
  4374. }
  4375. //笛卡儿积
  4376. function cp($ps, $sets, $list)
  4377. {
  4378. $result = array();
  4379. $j = 0;
  4380. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4381. if ($i == 0) {
  4382. $result = $sets[$i];
  4383. }
  4384. $tmp = array();
  4385. foreach ($result as $res) {
  4386. foreach ($sets[$i + 1] as $set) {
  4387. $tmp[] = $res . ',' . $set;
  4388. }
  4389. }
  4390. $result = $tmp;
  4391. }
  4392. $this->db->trans_begin();
  4393. foreach ($result as $v) {
  4394. $post = array();
  4395. $title = "";
  4396. $num = "";
  4397. $data = explode(',', $v);
  4398. for ($i = 0; $i < count($list); $i++) {
  4399. $post[$list[$i]] = $data[$i];
  4400. $typeclass = $this->typeclass->read($data[$i]);
  4401. $title = $title . $typeclass['title'] . " ";
  4402. if ($data[$i] != 0) {
  4403. $num .= $data[$i]; //所有数据ID拼接
  4404. }
  4405. }
  4406. foreach ($ps as $kp => $vp) {
  4407. $post[$kp] = $vp;
  4408. }
  4409. $post['number'] = $num;
  4410. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4411. if ($info_list) {
  4412. $j++;
  4413. } else {
  4414. $skunum = $this->whlabel->find_count();
  4415. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4416. $post['title'] = rtrim($title, ' ');
  4417. $this->whlabel->insert($post);
  4418. }
  4419. }
  4420. if ($this->db->trans_status() === FALSE) {
  4421. $this->db->trans_commit();
  4422. return NULL;
  4423. } else {
  4424. $this->db->trans_commit();
  4425. return $j;
  4426. }
  4427. }
  4428. public function _kj($arg_array)
  4429. {
  4430. if (isset($_POST['sku'])) {
  4431. $time = time();
  4432. $sku = $this->input->post('sku', true);
  4433. $warehouse = $this->input->post('warehouse', true);
  4434. $num = $this->input->post('num', true);
  4435. $text = $this->input->post('text', true);
  4436. $purchase = $this->input->post('purchase', true);
  4437. $cktype = $this->input->post('cktype', true);
  4438. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4439. if ($cktype != 1 && $text == '') {
  4440. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4441. exit;
  4442. }
  4443. if ($num > count($order)) {
  4444. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4445. exit;
  4446. } else {
  4447. for ($i = 0; $i < $num; $i++) {
  4448. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4449. }
  4450. }
  4451. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4452. exit;
  4453. }
  4454. $uid = $this->whlabel->read($arg_array[0]);
  4455. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4456. $this->data['data'] = $uid;
  4457. $this->_Template('whlabel_kj', $this->data);
  4458. }
  4459. public function _summary($arg_array)
  4460. {
  4461. $prc = array();
  4462. $purchase = $this->purchase->find_all();
  4463. foreach ($purchase as $k => $v) {
  4464. $prc[$v['id']] = $v['title'];
  4465. }
  4466. if (isset($_GET['excel'])) {
  4467. $ktime = $this->input->get('ktime', true);
  4468. $jtime = $this->input->get('jtime', true);
  4469. $ktime = strtotime($ktime);
  4470. $jtime = strtotime($jtime);
  4471. $where = "1=1";
  4472. if ($ktime && $jtime) {
  4473. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4474. }
  4475. //数据排序
  4476. $order_str = "time desc";
  4477. if (empty($page)) {
  4478. $start = 0;
  4479. $perpage = 1;
  4480. } else {
  4481. $start = ($page - 1) * $perpage;
  4482. }
  4483. //取得信息列表
  4484. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4485. foreach ($info_list as $key => $value) {
  4486. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4487. $warehouse = $this->warehouse->read($value['warehouse']);
  4488. $info_list[$key]['warehouse'] = $warehouse['title'];
  4489. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4490. $details = array();
  4491. $cpid = array();
  4492. foreach ($x as $k => $v) {
  4493. if ($v['details'] != '') {
  4494. $details[$v['details']] = $v['details'];
  4495. }
  4496. if ($v['cpid'] != 0) {
  4497. $cpid[$v['cpid']] = $v['cpid'];
  4498. }
  4499. }
  4500. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4501. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4502. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4503. $info_list[$key]['s'] = $s;
  4504. $info_list[$key]['x'] = count($x);
  4505. }
  4506. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4507. $titlename = "<table border=1>
  4508. <tr align='center'>
  4509. <td>仓库</td>
  4510. <td>供应商</td>
  4511. <td>出库位置</td>
  4512. <td>出库编码</td>
  4513. <td>SKU</td>
  4514. <td>产品名</td>
  4515. <td>总剩余库存</td>
  4516. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4517. </tr>
  4518. </table>";
  4519. $filename = $title . ".xls";
  4520. $tail = "";
  4521. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4522. }
  4523. }
  4524. //usps发货清单
  4525. public function _manifest()
  4526. {
  4527. if (isset($_POST['manifest'])) {
  4528. $wltext = $this->input->post('wltext', true);
  4529. $time = time() - 16 * 3600;
  4530. $ptime = strtotime(date('Y-m-d', $time));
  4531. $waybill = array();
  4532. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4533. foreach ($fullorder as $v) {
  4534. $waybill[$v['waybill']] = $v['waybill'];
  4535. }
  4536. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4537. foreach ($fullordersmt as $v) {
  4538. $waybill[$v['waybill']] = $v['waybill'];
  4539. }
  4540. $wltext = explode(';', $wltext);
  4541. foreach ($wltext as $v) {
  4542. if (isset($waybill[$v])) {
  4543. unset($waybill[$v]);
  4544. }
  4545. }
  4546. $data = $this->usps->get_manifest($waybill);
  4547. if (isset($data['Description'])) {
  4548. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4549. exit;
  4550. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4551. $bctime = date('Ymd', time());
  4552. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4553. echo json_encode(array('msg' => $pdf, 'success' => true));
  4554. exit;
  4555. } else {
  4556. echo json_encode(array('msg' => $data, 'success' => false));
  4557. exit;
  4558. }
  4559. }
  4560. }
  4561. public function _pdf($pdf, $title, $bctime)
  4562. {
  4563. $pdf_path = './data/pdf/' . $bctime . '/';
  4564. $file_base64 = $pdf;
  4565. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4566. $file_base64 = base64_decode($file_base64);
  4567. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4568. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4569. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4570. }
  4571. /**
  4572. *
  4573. *
  4574. *
  4575. 进销存占单异常索引
  4576. *
  4577. *
  4578. *
  4579. **/
  4580. public function _abnormal()
  4581. {
  4582. $post = $this->input->post(NULL, TRUE);
  4583. if (isset($post['page'])) {
  4584. $page = $this->input->post('page', true);
  4585. $perpage = $this->input->post('perpage', true);
  4586. $sku = $this->input->post('sku', true);
  4587. $where = "1=1";
  4588. //数据排序
  4589. $order_str = "id desc";
  4590. if (empty($page)) {
  4591. $start = 0;
  4592. $perpage = 1;
  4593. } else {
  4594. $start = ($page - 1) * $perpage;
  4595. }
  4596. //取得信息列表
  4597. $info_list = $this->whlabel->find_all($where, '*');
  4598. $rows = array();
  4599. $list = array();
  4600. foreach ($info_list as $key => $value) {
  4601. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4602. }
  4603. foreach ($rows as $value) {
  4604. $warehouse = $this->warehouse->read($value['warehouse']);
  4605. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4606. $number = $value['number'];
  4607. $ftime = time() - 15 * 24 * 3600;
  4608. if ($value['shop'] != '') {
  4609. $shop = $value['shop'];
  4610. $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');
  4611. $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');
  4612. $order = array_merge($orderdlz, $ordersmt);
  4613. $od = 0;
  4614. $a = '';
  4615. $orid = '';
  4616. foreach ($order as $v) {
  4617. $or = explode('|', ltrim($v['whlabel'], '|'));
  4618. for ($i = 0; $i < count($or); $i++) {
  4619. $orod = explode('-', $or[$i]);
  4620. if ($orod[0] == $number) {
  4621. $od += $orod[1];
  4622. }
  4623. }
  4624. $orid .= $v['number'] . '-';
  4625. }
  4626. } else {
  4627. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4628. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4629. $order = array_merge($orderdlz, $ordersmt);
  4630. $od = 0;
  4631. $a = '';
  4632. $orid = '';
  4633. $qt = array();
  4634. foreach ($order as $v) {
  4635. $or = explode('|', ltrim($v['whlabel'], '|'));
  4636. for ($i = 0; $i < count($or); $i++) {
  4637. $orod = explode('-', $or[$i]);
  4638. if ($orod[0] == $number) {
  4639. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4640. if ($czzs > 0) {
  4641. if (isset($qt[$v['shop']])) {
  4642. if ($qt[$v['shop']] < $orod[1]) {
  4643. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4644. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4645. } else {
  4646. $qt[$v['shop']] -= $orod[1];
  4647. }
  4648. } else {
  4649. $qt[$v['shop']] = $czzs;
  4650. }
  4651. } else {
  4652. $od += $orod[1];
  4653. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4654. }
  4655. }
  4656. }
  4657. }
  4658. }
  4659. $z = $od . '(' . $orid . ')'; //查看订单号
  4660. //$z = $od;
  4661. if ($od > $c) {
  4662. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4663. }
  4664. }
  4665. $listdata = array_slice($list, $start, $perpage);
  4666. $total = count($list);
  4667. $pagenum = ceil($total / $perpage);
  4668. $over = $total - ($start + $perpage);
  4669. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4670. echo json_encode($rows);
  4671. exit;
  4672. }
  4673. $this->_Template('whlabel_abnormal', $this->data);
  4674. }
  4675. /**
  4676. *
  4677. *
  4678. *
  4679. 进销存占单异常索引
  4680. *
  4681. *
  4682. *
  4683. **/
  4684. public function _error()
  4685. {
  4686. $post = $this->input->post(NULL, TRUE);
  4687. if (isset($post['page'])) {
  4688. $page = $this->input->post('page', true);
  4689. $perpage = $this->input->post('perpage', true);
  4690. $sku = $this->input->post('sku', true);
  4691. $warehouse = $this->input->post('warehouse', true);
  4692. $ktime = $this->input->post('ktime', true);
  4693. $jtime = $this->input->post('jtime', true);
  4694. $ktime = strtotime($ktime);
  4695. $jtime = strtotime($jtime);
  4696. $where = "sku != 'Preset'";
  4697. $gj = '';
  4698. if ($sku) {
  4699. $where .= " and sku like '%$sku%'";
  4700. } else {
  4701. if ($ktime && $jtime) {
  4702. $gj = " and time > '$ktime' and time < '$jtime'";
  4703. }
  4704. }
  4705. if ($warehouse) {
  4706. $where .= " and warehouse = '$warehouse'";
  4707. }
  4708. //数据排序
  4709. $order_str = "id desc";
  4710. if (empty($page)) {
  4711. $start = 0;
  4712. $perpage = 1;
  4713. } else {
  4714. $start = ($page - 1) * $perpage;
  4715. }
  4716. //取得信息列表
  4717. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4718. $rows = array();
  4719. $list = array();
  4720. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4721. // foreach ($info_list as $value)
  4722. // {
  4723. // $warehouse = $this->warehouse->read($value['warehouse']);
  4724. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4725. // $number = $value['number'];$ftime = time()-15*24*3600;
  4726. // if($c < 1)
  4727. // {
  4728. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4729. // }
  4730. // }
  4731. $warehouse_list = $this->warehouse->find_all();
  4732. $warehouse_list = array_column($warehouse_list, null, 'id');
  4733. foreach ($info_list as $value) {
  4734. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4735. 'title' => "",
  4736. ];
  4737. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4738. $number = $value['number'];
  4739. $ftime = time() - 15 * 24 * 3600;
  4740. if ($c < 1) {
  4741. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4742. }
  4743. }
  4744. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4745. // $query = $this->db->query($sql);
  4746. // $info_list = $query->result_array();
  4747. // $sql_two = "select title,id from crowd_warehouse";
  4748. // $query_two = $this->db->query($sql_two);
  4749. // $warehouse_list = $query_two->result_array();
  4750. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4751. // foreach ($info_list as $value)
  4752. // {
  4753. // if(isset($warehouse_arr[$value['warehouse']])){
  4754. // $warehouse = $warehouse_arr[$value['warehouse']];
  4755. // }else{
  4756. // $warehouse = [
  4757. // 'id'=>0,
  4758. // 'title'=>"异常",
  4759. // ];
  4760. // }
  4761. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4762. // $number = $value['number'];$ftime = time()-15*24*3600;
  4763. // if($c < 1)
  4764. // {
  4765. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4766. // }
  4767. // }
  4768. $listdata = array_slice($list, $start, $perpage);
  4769. $total = count($list);
  4770. $pagenum = ceil($total / $perpage);
  4771. $over = $total - ($start + $perpage);
  4772. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4773. echo json_encode($rows);
  4774. exit;
  4775. }
  4776. if (isset($post['s'])) {
  4777. $id_arr = $this->input->post('s');
  4778. $id_arr = explode(',', trim($id_arr, ','));
  4779. if (!$id_arr) {
  4780. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4781. exit;
  4782. }
  4783. //循环删除记录
  4784. foreach ($id_arr as $v) {
  4785. $dd = $this->whlabel->read($v);
  4786. if (!isset($dd['id'])) {
  4787. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4788. exit;
  4789. }
  4790. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4791. if (isset($zt[0])) {
  4792. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4793. exit;
  4794. }
  4795. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4796. foreach ($deldd as $vv) {
  4797. $this->whlabel->remove($vv['id']);
  4798. }
  4799. }
  4800. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4801. exit;
  4802. }
  4803. $this->_Template('whlabel_error', $this->data);
  4804. }
  4805. public function _errorexcel()
  4806. {
  4807. $post = $this->input->post(NULL, TRUE);
  4808. if (isset($_GET['page'])) {
  4809. $page = $this->input->get('page', true);
  4810. $perpage = $this->input->get('perpage', true);
  4811. $sku = $this->input->get('sku', true);
  4812. $warehouse = $this->input->get('warehouse', true);
  4813. $ktime = $this->input->get('ktime', true);
  4814. $jtime = $this->input->get('jtime', true);
  4815. $ktime = strtotime($ktime);
  4816. $jtime = strtotime($jtime);
  4817. $where = "sku != 'Preset'";
  4818. $gj = '';
  4819. if ($sku) {
  4820. $where .= " and sku like '%$sku%'";
  4821. } else {
  4822. if ($ktime && $jtime) {
  4823. $gj = " and time > '$ktime' and time < '$jtime'";
  4824. }
  4825. }
  4826. if ($warehouse) {
  4827. $where .= " and warehouse = '$warehouse'";
  4828. }
  4829. //数据排序
  4830. $order_str = "id desc";
  4831. if (empty($page)) {
  4832. $start = 0;
  4833. $perpage = 1;
  4834. } else {
  4835. $start = ($page - 1) * $perpage;
  4836. }
  4837. //取得信息列表
  4838. $rows = array();
  4839. $list = array();
  4840. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4841. foreach ($info_list as $value) {
  4842. $warehouse = $this->warehouse->read($value['warehouse']);
  4843. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4844. $number = $value['number'];
  4845. $ftime = time() - 15 * 24 * 3600;
  4846. if ($c < 1) {
  4847. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4848. }
  4849. }
  4850. $title = "0库存汇总";
  4851. $titlename = "<table border=1>
  4852. <tr align='center'>
  4853. <td>仓库</td>
  4854. <td>SKU</td>
  4855. <td>产品</td>
  4856. <td>当前库存</td>
  4857. </tr>
  4858. </table>";
  4859. $filename = $title . ".xls";
  4860. $tail = "";
  4861. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4862. }
  4863. }
  4864. /**
  4865. *
  4866. *
  4867. * 占单
  4868. *
  4869. *
  4870. **/
  4871. public function _kcyz()
  4872. {
  4873. $post = $this->input->post(NULL, TRUE);
  4874. if (isset($post['warehouse'])) {
  4875. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4876. exit; //不再使用
  4877. $warehouse = $this->input->post('warehouse', true);
  4878. $whlabel = $this->input->post('whlabel', true);
  4879. $id = $this->input->post('id', true);
  4880. $shop = $this->input->post('shop', true);
  4881. $number = $this->input->post('number', true);
  4882. if (!$whlabel || $whlabel == '|') {
  4883. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4884. exit;
  4885. }
  4886. $pp = explode('|', trim($whlabel, '|'));
  4887. $x = 0;
  4888. $save = array();
  4889. foreach ($pp as $va) {
  4890. $num = explode('-', $va);
  4891. if ($number) {
  4892. $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 = '')"); //通用
  4893. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4894. } else {
  4895. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4896. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4897. }
  4898. $x++;
  4899. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4900. $save[] = $x - 1;
  4901. continue; //提前先加X不然出错,所以要减1
  4902. }
  4903. }
  4904. if (isset($save[0])) {
  4905. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4906. exit;
  4907. } else {
  4908. echo json_encode(array('success' => true));
  4909. exit;
  4910. }
  4911. }
  4912. }
  4913. public function _db()
  4914. {
  4915. $post = $this->input->post(NULL, TRUE);
  4916. if (isset($post['page'])) {
  4917. $page = $this->input->post('page', true);
  4918. $perpage = $this->input->post('perpage', true);
  4919. $sku = $this->input->post('sku', true);
  4920. $number = $this->input->post('number', true);
  4921. $warehouse = $this->input->post('warehouse', true);
  4922. $purchase = $this->input->post('purchase', true);
  4923. $orderinfo = $this->input->post('orderinfo', true);
  4924. $waybill = $this->input->post('waybill', true);
  4925. $category = $this->input->post('category', true);
  4926. $size = $this->input->post('size', true);
  4927. $grade = $this->input->post('grade', true);
  4928. $color = $this->input->post('color', true);
  4929. $lowe = $this->input->post('lowe', true);
  4930. $state = $this->input->post('state', true);
  4931. $label = $this->input->post('label', true);
  4932. $timetk = $this->input->post('timetkk', true);
  4933. $timetj = $this->input->post('timetjj', true);
  4934. $timetk = strtotime($timetk);
  4935. $timetj = strtotime($timetj);
  4936. $where = "dbtime > 0";
  4937. if ($timetk && $timetj) {
  4938. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4939. }
  4940. if ($sku) {
  4941. $where .= " and sku = '$sku'";
  4942. }
  4943. if ($warehouse) {
  4944. $where .= " and warehouse = '$warehouse'";
  4945. if ($warehouse == 12) {
  4946. $w = 'specialstock';
  4947. } else {
  4948. $w = 'whlabel';
  4949. }
  4950. }
  4951. if ($purchase) {
  4952. $where .= " and purchase = '$purchase'";
  4953. }
  4954. if ($category) {
  4955. $where .= " and features like '%-$category-%'";
  4956. }
  4957. if ($size) {
  4958. $where .= " and features like '%-$size-%'";
  4959. }
  4960. if ($grade) {
  4961. $where .= " and features like '%-$grade-%'";
  4962. }
  4963. if ($color) {
  4964. $where .= " and features like '%-$color-%'";
  4965. }
  4966. if ($lowe) {
  4967. $where .= " and features like '%-$lowe-%'";
  4968. }
  4969. if ($state != '') {
  4970. $where .= " and state = '$state'";
  4971. }
  4972. //数据排序
  4973. $order_str = "dbtime desc";
  4974. if (empty($page)) {
  4975. $start = 0;
  4976. $perpage = 1;
  4977. } else {
  4978. $start = ($page - 1) * $perpage;
  4979. }
  4980. //取得信息列表
  4981. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4982. foreach ($info_list as $key => $value) {
  4983. $warehouse = $this->$w->read($value['warehouse']);
  4984. $info_list[$key]['warehouse'] = $warehouse['title'];
  4985. $purchase = $this->purchase->read($value['purchase']);
  4986. $info_list[$key]['purchase'] = $purchase['title'];
  4987. if ($value['enter'] != 0) {
  4988. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  4989. } else {
  4990. $info_list[$key]['enter'] = "";
  4991. }
  4992. if ($value['dbtime'] != 0) {
  4993. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  4994. } else {
  4995. $info_list[$key]['dbtime'] = "";
  4996. }
  4997. if ($value['state'] == 0) {
  4998. $info_list[$key]['state'] = "在库";
  4999. } else if ($value['state'] == 1) {
  5000. $info_list[$key]['state'] = "出库";
  5001. } else if ($value['state'] == 2) {
  5002. $info_list[$key]['state'] = "退库";
  5003. } else if ($value['state'] == 3) {
  5004. $info_list[$key]['state'] = "调拨中";
  5005. } else if ($value['state'] == 4) {
  5006. $info_list[$key]['state'] = "再加工";
  5007. } else if ($value['state'] == 5) {
  5008. $info_list[$key]['state'] = "维修中";
  5009. } else if ($value['state'] == 6) {
  5010. $info_list[$key]['state'] = "盘亏";
  5011. } else if ($value['state'] == 7) {
  5012. $info_list[$key]['state'] = "更换标签";
  5013. } else if ($value['state'] == 8) {
  5014. $info_list[$key]['state'] = "其它";
  5015. } else if ($value['state'] == 9) {
  5016. $info_list[$key]['state'] = "预设";
  5017. }
  5018. }
  5019. $total = $this->whlabel->find_count($where);
  5020. $pagenum = ceil($total / $perpage);
  5021. $over = $total - ($start + $perpage);
  5022. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5023. echo json_encode($rows);
  5024. exit;
  5025. }
  5026. if (isset($post['outsku'])) {
  5027. $time = time();
  5028. $cz = $this->input->post('cz', true);
  5029. $label = $this->input->post('outsku', true);
  5030. $sl = $this->input->post('sl', true);
  5031. $num = $this->input->post('num', true);
  5032. //$warehouse = $this->input->post('warehouse',true);
  5033. if (!$sl) {
  5034. $sl = 1;
  5035. }
  5036. if (!$warehouse) {
  5037. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5038. exit;
  5039. }
  5040. $dblabel = $this->whlabellabel->get_label($label);
  5041. if ($dblabel) {
  5042. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5043. if (count($data) < 1) {
  5044. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5045. exit;
  5046. }
  5047. if (count($data) < $num) {
  5048. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5049. exit;
  5050. }
  5051. for ($i = 0; $i < $sl; $i++) {
  5052. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5053. }
  5054. echo json_encode(array('success' => true));
  5055. exit;
  5056. } else {
  5057. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5058. exit;
  5059. }
  5060. }
  5061. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5062. $this->_Template('whlabel_db', $this->data);
  5063. }
  5064. public function _dbrk()
  5065. {
  5066. $post = $this->input->post(NULL, TRUE);
  5067. if (isset($post['page'])) {
  5068. $page = $this->input->post('page', true);
  5069. $perpage = $this->input->post('perpage', true);
  5070. $sku = $this->input->post('sku', true);
  5071. $number = $this->input->post('number', true);
  5072. $warehouse = $this->input->post('warehouse', true);
  5073. $purchase = $this->input->post('purchase', true);
  5074. $orderinfo = $this->input->post('orderinfo', true);
  5075. $waybill = $this->input->post('waybill', true);
  5076. $category = $this->input->post('category', true);
  5077. $size = $this->input->post('size', true);
  5078. $grade = $this->input->post('grade', true);
  5079. $color = $this->input->post('color', true);
  5080. $lowe = $this->input->post('lowe', true);
  5081. $state = $this->input->post('state', true);
  5082. $label = $this->input->post('label', true);
  5083. $ctime = $this->input->post('ctime', true);
  5084. $timetk = $this->input->post('timetkk', true);
  5085. $timetj = $this->input->post('timetjj', true);
  5086. $timetk = strtotime($timetk);
  5087. $timetj = strtotime($timetj);
  5088. $where = "dbtime > 0";
  5089. if ($timetk && $timetj) {
  5090. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5091. }
  5092. if ($sku) {
  5093. $where .= " and sku = '$sku'";
  5094. }
  5095. if ($warehouse) {
  5096. $where .= " and warehouse = '$warehouse'";
  5097. }
  5098. if ($purchase) {
  5099. $where .= " and purchase = '$purchase'";
  5100. }
  5101. if ($category) {
  5102. $where .= " and features like '%-$category-%'";
  5103. }
  5104. if ($size) {
  5105. $where .= " and features like '%-$size-%'";
  5106. }
  5107. if ($grade) {
  5108. $where .= " and features like '%-$grade-%'";
  5109. }
  5110. if ($color) {
  5111. $where .= " and features like '%-$color-%'";
  5112. }
  5113. if ($lowe) {
  5114. $where .= " and features like '%-$lowe-%'";
  5115. }
  5116. if ($state != '') {
  5117. $where .= " and state = '$state'";
  5118. }
  5119. //数据排序
  5120. $order_str = "dbtime desc";
  5121. if (empty($page)) {
  5122. $start = 0;
  5123. $perpage = 1;
  5124. } else {
  5125. $start = ($page - 1) * $perpage;
  5126. }
  5127. //取得信息列表
  5128. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5129. foreach ($info_list as $key => $value) {
  5130. $warehouse = $this->warehouse->read($value['warehouse']);
  5131. $info_list[$key]['warehouse'] = $warehouse['title'];
  5132. $purchase = $this->purchase->read($value['purchase']);
  5133. $info_list[$key]['purchase'] = $purchase['title'];
  5134. if ($value['enter'] != 0) {
  5135. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5136. } else {
  5137. $info_list[$key]['enter'] = "";
  5138. }
  5139. if ($value['dbtime'] != 0) {
  5140. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5141. } else {
  5142. $info_list[$key]['dbtime'] = "";
  5143. }
  5144. if ($value['state'] == 0) {
  5145. $info_list[$key]['state'] = "在库";
  5146. } else if ($value['state'] == 1) {
  5147. $info_list[$key]['state'] = "出库";
  5148. } else if ($value['state'] == 2) {
  5149. $info_list[$key]['state'] = "退库";
  5150. } else if ($value['state'] == 3) {
  5151. $info_list[$key]['state'] = "调拨中";
  5152. } else if ($value['state'] == 4) {
  5153. $info_list[$key]['state'] = "再加工";
  5154. } else if ($value['state'] == 5) {
  5155. $info_list[$key]['state'] = "维修中";
  5156. } else if ($value['state'] == 6) {
  5157. $info_list[$key]['state'] = "盘亏";
  5158. } else if ($value['state'] == 7) {
  5159. $info_list[$key]['state'] = "更换标签";
  5160. } else if ($value['state'] == 8) {
  5161. $info_list[$key]['state'] = "其它";
  5162. } else if ($value['state'] == 9) {
  5163. $info_list[$key]['state'] = "预设";
  5164. }
  5165. }
  5166. $total = $this->whlabel->find_count($where);
  5167. $pagenum = ceil($total / $perpage);
  5168. $over = $total - ($start + $perpage);
  5169. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5170. echo json_encode($rows);
  5171. exit;
  5172. }
  5173. if (isset($post['rsku'])) {
  5174. $cz = $this->input->post('cz', true);
  5175. $label = $this->input->post('rsku', true);
  5176. $sl = $this->input->post('sl', true);
  5177. $warehouse = $this->input->post('warehouse', true);
  5178. if (!$sl) {
  5179. $sl = 1;
  5180. }
  5181. if (!$warehouse) {
  5182. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5183. exit;
  5184. }
  5185. $dblabel = $this->whlabellabel->get_label($label);
  5186. if ($dblabel) {
  5187. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5188. if (count($data) < 1) {
  5189. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5190. exit;
  5191. }
  5192. if ($sl > count($data)) {
  5193. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5194. exit;
  5195. }
  5196. $time = time();
  5197. for ($i = 0; $i < $sl; $i++) {
  5198. $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']);
  5199. }
  5200. echo json_encode(array('success' => true));
  5201. exit;
  5202. } else {
  5203. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5204. exit;
  5205. }
  5206. }
  5207. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5208. $this->_Template('whlabel_dbrk', $this->data);
  5209. }
  5210. public function _whlabelczdc()
  5211. {
  5212. if (isset($_GET['excel'])) {
  5213. //数据排序
  5214. $order_str = "id desc";
  5215. if (empty($page)) {
  5216. $start = 0;
  5217. $perpage = 1;
  5218. } else {
  5219. $start = ($page - 1) * $perpage;
  5220. }
  5221. $state = $this->input->get('state', true);
  5222. $sku = $this->input->get('sku', true);
  5223. $ctime = $this->input->get('ctime', true);
  5224. $category = $this->input->get('category', true);
  5225. $size = $this->input->get('size', true);
  5226. $grade = $this->input->get('grade', true);
  5227. $color = $this->input->get('color', true);
  5228. $lowe = $this->input->get('lowe', true);
  5229. $timetk = $this->input->get('timetkk', true);
  5230. $timetj = $this->input->get('timetjj', true);
  5231. $timetk = strtotime($timetk);
  5232. $timetj = strtotime($timetj);
  5233. $where = "dbtime > 0";
  5234. if ($timetk && $timetj) {
  5235. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5236. }
  5237. if ($category) {
  5238. $where .= " and features like '%-$category-%'";
  5239. }
  5240. if ($size) {
  5241. $where .= " and features like '%-$size-%'";
  5242. }
  5243. if ($grade) {
  5244. $where .= " and features like '%-$grade-%'";
  5245. }
  5246. if ($color) {
  5247. $where .= " and features like '%-$color-%'";
  5248. }
  5249. if ($lowe) {
  5250. $where .= " and features like '%-$lowe-%'";
  5251. }
  5252. //取得信息列表
  5253. $info_list = $this->whlabel->find_all($where, '*');
  5254. $rows = array();
  5255. $list = array();
  5256. foreach ($info_list as $key => $value) {
  5257. $rows[$value['sku']] = $value; //所有数据sku
  5258. }
  5259. foreach ($rows as $value) {
  5260. $warehouse = $this->warehouse->read($value['warehouse']);
  5261. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5262. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5263. if ($value['orderinfo'] == 0) {
  5264. $info_list[$key]['orderinfo'] = "";
  5265. }
  5266. if ($value['waybill'] == 0) {
  5267. $info_list[$key]['waybill'] = "";
  5268. }
  5269. if ($value['state'] == 0) {
  5270. $value['state'] = "在库";
  5271. } else if ($value['state'] == 3) {
  5272. $value['state'] = "调拨中";
  5273. }
  5274. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5275. }
  5276. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5277. $titlename = "<table border=1>
  5278. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5279. <tr align='center'>
  5280. <td>SKU</td>
  5281. <td>产品</td>
  5282. <td>调拨数量</td>
  5283. <td>入库数量</td>
  5284. </tr>
  5285. </table>";
  5286. $filename = $title . ".xls";
  5287. $tail = "";
  5288. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5289. }
  5290. }
  5291. public function _print($arg_array)
  5292. {
  5293. if (isset($_SESSION['api'])) {
  5294. $user = $this->user->get_api($_SESSION['api']);
  5295. $usp = $user;
  5296. $fgshop = "";
  5297. $sid = "";
  5298. $wid = "";
  5299. $wtype = "";
  5300. $usersp = explode('|', trim($user['shop'], '|'));
  5301. $userwh = explode('|', trim($user['warehouse'], '|'));
  5302. foreach ($usersp as $value) {
  5303. $fgshop .= " shop = " . $value . " or";
  5304. $sid .= " id = " . $value . " or";
  5305. }
  5306. foreach ($userwh as $value) {
  5307. $wid .= " id = " . $value . " or";
  5308. $wtype .= " type = " . $value . " or";
  5309. }
  5310. }
  5311. $post = $this->input->post(NULL, TRUE);
  5312. if (isset($post['tmsku'])) {
  5313. $tmsku = $this->input->post('tmsku', true);
  5314. if (is_numeric($tmsku)) {
  5315. $yyh = $this->whlabellabel->get_label($tmsku);
  5316. } else {
  5317. $yyh = $this->whlabellabel->get_sku($tmsku);
  5318. }
  5319. if ($yyh) {
  5320. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5321. exit;
  5322. } else {
  5323. echo json_encode(array('success' => false));
  5324. exit;
  5325. }
  5326. }
  5327. $classid = $this->classid->sku();
  5328. $pm = $classid;
  5329. $scsku = $classid;
  5330. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5331. if (isset($post['warehouse'])) {
  5332. if ($post['warehouse']) {
  5333. $list = array();
  5334. $num = "";
  5335. $title = "";
  5336. $features = "";
  5337. $order = 0;
  5338. $post['shop'] = '';
  5339. $brand = $this->input->post('brand', true);
  5340. if ($brand != '0,') {
  5341. $b = $this->brand->read(rtrim($brand, ','));
  5342. if ($b) {
  5343. $post['shop'] = str_replace('|', ',', $b['shop']);
  5344. }
  5345. }
  5346. $post['details'] = $this->input->post('details', true); //打印数量
  5347. $xbqnum = $this->input->post('xbqnum', true);
  5348. $post['purchase'] = $this->input->post('purchase', true);
  5349. $post['warehouse'] = $this->input->post('warehouse', true);
  5350. $post['purchase'] = $this->input->post('purchase', true);
  5351. $post['retreatwarehouse'] = $post['warehouse'];
  5352. $post['cpbz'] = $this->input->post('cpbz', true);
  5353. $post['state'] = 9;
  5354. $category = $this->input->post('category', true);
  5355. $list['category'] = $category;
  5356. $list['hairtype'] = $this->input->post('hairtype', true);
  5357. $list['grade'] = $this->input->post('grade', true);
  5358. $size = $this->input->post('size', true);
  5359. $list['size'] = rtrim($size, ',');
  5360. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5361. $list['extension'] = $this->input->post('extension', true);
  5362. if ($category == 1297) {
  5363. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5364. }
  5365. if ($category == 1702) {
  5366. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5367. $list['syother'] = $this->input->post('syother', true);
  5368. }
  5369. if ($category == 133) {
  5370. $list['fittype'] = $this->input->post('fittype', true);
  5371. $list['acother'] = $this->input->post('acother', true);
  5372. }
  5373. $list['color'] = $this->input->post('color', true);
  5374. $list['lowe'] = $this->input->post('lowe', true);
  5375. if ($category == 127) {
  5376. $list['type'] = $this->input->post('type', true);
  5377. $list['headroad'] = $this->input->post('headroad', true);
  5378. $list['density'] = $this->input->post('density', true);
  5379. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5380. $list['lacesize'] = $this->input->post('lacesize', true);
  5381. }
  5382. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5383. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5384. }
  5385. if ($category == 128) {
  5386. $list['lacetype'] = $this->input->post('lacetype', true);
  5387. $list['haircap'] = $this->input->post('haircap', true);
  5388. $list['density'] = $this->input->post('density', true);
  5389. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5390. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5391. $list['wigother'] = $this->input->post('wigother', true);
  5392. $list['wigother1'] = $this->input->post('wigother1', true);
  5393. $list['wigother2'] = $this->input->post('wigother2', true);
  5394. }
  5395. if ($category == 129) {
  5396. $list['wide'] = $this->input->post('wide', true);
  5397. }
  5398. if ($category == 131) {
  5399. $list['gifttype'] = $this->input->post('gifttype', true);
  5400. $list['giftother'] = $this->input->post('giftother', true);
  5401. }
  5402. if ($category == 134) {
  5403. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5404. }
  5405. if ($category == 1297) {
  5406. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5407. $list['sywigother'] = $this->input->post('sywigother', true);
  5408. }
  5409. if ($category == 130 || $category == 133 || $category == 1702) {
  5410. $list['items'] = $this->input->post('items', true);
  5411. $list['weight'] = $this->input->post('weight', true);
  5412. }
  5413. if ($category == 1702) {
  5414. $list['syhairther'] = $this->input->post('syhairther', true);
  5415. }
  5416. foreach ($list as $k => $v) {
  5417. if ($v != 0) {
  5418. $num .= $v;
  5419. $features .= $v . '-';
  5420. $post[$k] = $v;
  5421. $typeclass = $this->typeclass->read($v);
  5422. if (isset($pm[$typeclass['classid']])) {
  5423. if (stripos($typeclass['zh'], '|') !== false) {
  5424. $exzh = explode('|', $typeclass['zh']);
  5425. $pm[$typeclass['classid']] = $exzh[0];
  5426. } else {
  5427. $pm[$typeclass['classid']] = $typeclass['zh'];
  5428. }
  5429. }
  5430. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5431. if ($k != 'size') {
  5432. $title .= $typeclass['title'] . " ";
  5433. }
  5434. }
  5435. }
  5436. $typeclass = $this->typeclass->read($list['size']);
  5437. $title .= $typeclass['title'];
  5438. $time = time();
  5439. $post['title'] = rtrim($title, ' ');
  5440. $post['number'] = $num;
  5441. $post['features'] = '-' . $features;
  5442. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5443. $featurespp = explode('-', trim($featurespp, '-'));
  5444. if (isset($featurespp[5])) {
  5445. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5446. } else {
  5447. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5448. }
  5449. $post['enter'] = $time;
  5450. $post['time'] = $time; //操作时间
  5451. $scsku = implode("-", $scsku);
  5452. $zh = implode(" ", $pm);
  5453. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5454. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5455. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5456. $post['sku'] = $bqsku;
  5457. $label = time() . rand(0, 9);
  5458. $post['label'] = $label;
  5459. $cpid = $this->whlabellabel->find_count();
  5460. $post['cpid'] = $cpid + 1;
  5461. $cpid = $post['cpid'];
  5462. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5463. //if($whlabelbarcode)
  5464. //{
  5465. //$post['label'] = $whlabelbarcode['label'];
  5466. //if(!$this->whlabellabel->insert($post))
  5467. //{
  5468. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5469. //}
  5470. //}
  5471. //else
  5472. //{
  5473. $this->db->trans_begin();
  5474. $this->whlabellabel->insert($post);
  5475. //$this->whlabelbarcode->insert($post);
  5476. if ($this->db->trans_status() === TRUE) {
  5477. $this->db->trans_commit();
  5478. } else {
  5479. $this->db->trans_rollback();
  5480. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5481. exit;
  5482. }
  5483. //}
  5484. $warehouse_name = "";
  5485. $warehouse = $post['warehouse'];
  5486. if($warehouse == 12){
  5487. $warehouse_name = "特殊库存库";
  5488. }
  5489. // if($warehouse == 13){
  5490. // $warehouse_name = "许昌仓";
  5491. // }
  5492. // if($warehouse == 5){
  5493. // $warehouse_name = "美国店";
  5494. // }
  5495. // if($warehouse == 16){
  5496. // $warehouse_name = "定制头套仓";
  5497. // }
  5498. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5499. if(!empty($warehouse_name)){
  5500. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5501. }
  5502. $purchase = $this->purchase->read($post['purchase']);
  5503. 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));
  5504. exit; //特殊仓目前不需要仓库选项
  5505. }
  5506. }
  5507. if (isset($_SESSION['api'])) {
  5508. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5509. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5510. $this->data['wlshop'] = $wlshop;
  5511. $this->data['warehouse'] = $warehouse;
  5512. }
  5513. $whlabelwz = $this->whlabelwz->find_all();
  5514. $this->data['whlabelwz'] = $whlabelwz;
  5515. $this->_Template('whlabel_print', $this->data);
  5516. }
  5517. public function _usaprint($arg_array)
  5518. {
  5519. if (isset($_SESSION['api'])) {
  5520. $user = $this->user->get_api($_SESSION['api']);
  5521. $usp = $user;
  5522. $fgshop = "";
  5523. $sid = "";
  5524. $wid = "";
  5525. $wtype = "";
  5526. $usersp = explode('|', trim($user['shop'], '|'));
  5527. $userwh = explode('|', trim($user['warehouse'], '|'));
  5528. foreach ($usersp as $value) {
  5529. $fgshop .= " shop = " . $value . " or";
  5530. $sid .= " id = " . $value . " or";
  5531. }
  5532. foreach ($userwh as $value) {
  5533. $wid .= " id = " . $value . " or";
  5534. $wtype .= " type = " . $value . " or";
  5535. }
  5536. }
  5537. $post = $this->input->post(NULL, TRUE);
  5538. if (isset($post['tmsku'])) {
  5539. $tmsku = $this->input->post('tmsku', true);
  5540. if (is_numeric($tmsku)) {
  5541. $yyh = $this->whlabellabel->get_label($tmsku);
  5542. } else {
  5543. $yyh = $this->whlabellabel->get_sku($tmsku);
  5544. }
  5545. if ($yyh) {
  5546. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5547. exit;
  5548. } else {
  5549. echo json_encode(array('success' => false));
  5550. exit;
  5551. }
  5552. }
  5553. $classid = $this->classid->sku();
  5554. $pm = $classid;
  5555. $scsku = $classid;
  5556. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5557. if (isset($post['warehouse'])) {
  5558. if ($post['warehouse']) {
  5559. $list = array();
  5560. $num = "";
  5561. $title = "";
  5562. $features = "";
  5563. $order = 0;
  5564. $post['shop'] = '';
  5565. $brand = $this->input->post('brand', true);
  5566. if ($brand != '0,') {
  5567. $b = $this->brand->read(rtrim($brand, ','));
  5568. if ($b) {
  5569. $post['shop'] = str_replace('|', ',', $b['shop']);
  5570. }
  5571. }
  5572. $post['details'] = $this->input->post('details', true); //打印数量
  5573. $xbqnum = $this->input->post('xbqnum', true);
  5574. $post['purchase'] = $this->input->post('purchase', true);
  5575. $post['warehouse'] = $this->input->post('warehouse', true);
  5576. $post['purchase'] = $this->input->post('purchase', true);
  5577. $post['retreatwarehouse'] = $post['warehouse'];
  5578. $post['cpbz'] = $this->input->post('cpbz', true);
  5579. $post['state'] = 9;
  5580. $category = $this->input->post('category', true);
  5581. $list['category'] = $category;
  5582. $list['hairtype'] = $this->input->post('hairtype', true);
  5583. $list['grade'] = $this->input->post('grade', true);
  5584. $size = $this->input->post('size', true);
  5585. $list['size'] = rtrim($size, ',');
  5586. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5587. $list['extension'] = $this->input->post('extension', true);
  5588. if ($category == 1297) {
  5589. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5590. }
  5591. if ($category == 1702) {
  5592. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5593. $list['syother'] = $this->input->post('syother', true);
  5594. }
  5595. if ($category == 133) {
  5596. $list['fittype'] = $this->input->post('fittype', true);
  5597. $list['acother'] = $this->input->post('acother', true);
  5598. }
  5599. $list['color'] = $this->input->post('color', true);
  5600. $list['lowe'] = $this->input->post('lowe', true);
  5601. if ($category == 127) {
  5602. $list['type'] = $this->input->post('type', true);
  5603. $list['headroad'] = $this->input->post('headroad', true);
  5604. $list['density'] = $this->input->post('density', true);
  5605. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5606. $list['lacesize'] = $this->input->post('lacesize', true);
  5607. }
  5608. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5609. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5610. }
  5611. if ($category == 128) {
  5612. $list['lacetype'] = $this->input->post('lacetype', true);
  5613. $list['haircap'] = $this->input->post('haircap', true);
  5614. $list['density'] = $this->input->post('density', true);
  5615. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5616. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5617. $list['wigother'] = $this->input->post('wigother', true);
  5618. $list['wigother1'] = $this->input->post('wigother1', true);
  5619. $list['wigother2'] = $this->input->post('wigother2', true);
  5620. }
  5621. if ($category == 129) {
  5622. $list['wide'] = $this->input->post('wide', true);
  5623. }
  5624. if ($category == 131) {
  5625. $list['gifttype'] = $this->input->post('gifttype', true);
  5626. $list['giftother'] = $this->input->post('giftother', true);
  5627. }
  5628. if ($category == 134) {
  5629. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5630. }
  5631. if ($category == 1297) {
  5632. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5633. $list['sywigother'] = $this->input->post('sywigother', true);
  5634. }
  5635. if ($category == 130 || $category == 133 || $category == 1702) {
  5636. $list['items'] = $this->input->post('items', true);
  5637. $list['weight'] = $this->input->post('weight', true);
  5638. }
  5639. if ($category == 1702) {
  5640. $list['syhairther'] = $this->input->post('syhairther', true);
  5641. }
  5642. foreach ($list as $k => $v) {
  5643. if ($v != 0) {
  5644. $num .= $v;
  5645. $features .= $v . '-';
  5646. $post[$k] = $v;
  5647. $typeclass = $this->typeclass->read($v);
  5648. if (isset($pm[$typeclass['classid']])) {
  5649. if (stripos($typeclass['zh'], '|') !== false) {
  5650. $exzh = explode('|', $typeclass['zh']);
  5651. $pm[$typeclass['classid']] = $exzh[0];
  5652. } else {
  5653. $pm[$typeclass['classid']] = $typeclass['zh'];
  5654. }
  5655. }
  5656. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5657. if ($k != 'size') {
  5658. $title .= $typeclass['title'] . " ";
  5659. }
  5660. }
  5661. }
  5662. $typeclass = $this->typeclass->read($list['size']);
  5663. $title .= $typeclass['title'];
  5664. $time = time();
  5665. $post['title'] = rtrim($title, ' ');
  5666. $post['number'] = $num;
  5667. $post['features'] = '-' . $features;
  5668. $fp = $this->whlabel->get_features($post['features']);
  5669. if (!$fp) {
  5670. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5671. exit;
  5672. }
  5673. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5674. $featurespp = explode('-', trim($featurespp, '-'));
  5675. if (isset($featurespp[5])) {
  5676. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5677. } else {
  5678. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5679. }
  5680. $post['enter'] = $time;
  5681. $post['time'] = $time; //操作时间
  5682. $scsku = implode("-", $scsku);
  5683. $zh = implode(" ", $pm);
  5684. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5685. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5686. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5687. $post['sku'] = $fp['sku'];
  5688. $post['label'] = $fp['sku'];
  5689. $cpid = $this->whlabellabel->find_count();
  5690. $post['cpid'] = $cpid + 1;
  5691. $cpid = $post['cpid'];
  5692. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5693. //if($whlabelbarcode)
  5694. //{
  5695. //$post['label'] = $whlabelbarcode['label'];
  5696. //if(!$this->whlabellabel->insert($post))
  5697. //{
  5698. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5699. //}
  5700. //}
  5701. //else
  5702. //{
  5703. $this->db->trans_begin();
  5704. $this->whlabellabel->insert($post);
  5705. //$this->whlabelbarcode->insert($post);
  5706. if ($this->db->trans_status() === TRUE) {
  5707. $this->db->trans_commit();
  5708. } else {
  5709. $this->db->trans_rollback();
  5710. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5711. exit;
  5712. }
  5713. //}
  5714. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5715. $purchase = $this->purchase->read($post['purchase']);
  5716. 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));
  5717. exit; //特殊仓目前不需要仓库选项
  5718. }
  5719. }
  5720. if (isset($_SESSION['api'])) {
  5721. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5722. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5723. $this->data['wlshop'] = $wlshop;
  5724. $this->data['warehouse'] = $warehouse;
  5725. }
  5726. $whlabelwz = $this->whlabelwz->find_all();
  5727. $this->data['whlabelwz'] = $whlabelwz;
  5728. $this->_Template('whlabel_usaprint', $this->data);
  5729. }
  5730. public function _printrk($arg_array)
  5731. {
  5732. $prc = array();
  5733. $purchase = $this->purchase->find_all();
  5734. foreach ($purchase as $k => $v) {
  5735. $prc[$v['id']] = $v['title'];
  5736. }
  5737. $post = $this->input->post(NULL, TRUE);
  5738. if (isset($post['page'])) {
  5739. $page = $this->input->post('page', true);
  5740. $perpage = $this->input->post('perpage', true);
  5741. $sku = $this->input->post('sku', true);
  5742. $bs = $this->input->post('bs', true);
  5743. $number = $this->input->post('number', true);
  5744. $warehouse = $this->input->post('warehouse', true);
  5745. $purchase = $this->input->post('purchase', true);
  5746. $orderinfo = $this->input->post('orderinfo', true);
  5747. $waybill = $this->input->post('waybill', true);
  5748. $category = $this->input->post('category', true);
  5749. $size = $this->input->post('size', true);
  5750. $grade = $this->input->post('grade', true);
  5751. $color = $this->input->post('color', true);
  5752. $lowe = $this->input->post('lowe', true);
  5753. $state = $this->input->post('state', true);
  5754. $label = $this->input->post('label', true);
  5755. $timetk = $this->input->post('ktime', true);
  5756. $timetj = $this->input->post('jtime', true);
  5757. $timetk = strtotime($timetk);
  5758. $timetj = strtotime($timetj);
  5759. $where = "1=1 ";
  5760. if ($timetk && $timetj) {
  5761. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5762. }
  5763. if ($sku) {
  5764. $where .= " and sku = '$sku'";
  5765. }
  5766. if ($bs != '') {
  5767. $where .= " and bs = '$bs'";
  5768. }
  5769. if ($number) {
  5770. $where .= " and number = '$number'";
  5771. }
  5772. if ($warehouse) {
  5773. $where .= " and warehouse = '$warehouse'";
  5774. }
  5775. if ($purchase) {
  5776. $where .= " and purchase = '$purchase'";
  5777. }
  5778. if ($orderinfo) {
  5779. $where .= " and orderinfo = '$orderinfo'";
  5780. }
  5781. if ($waybill) {
  5782. $where .= " and waybill = '$waybill'";
  5783. }
  5784. if ($category) {
  5785. $where .= " and features like '%-$category-%'";
  5786. }
  5787. if ($size) {
  5788. $where .= " and features like '%-$size-%'";
  5789. }
  5790. if ($grade) {
  5791. $where .= " and features like '%-$grade-%'";
  5792. }
  5793. if ($color) {
  5794. $where .= " and features like '%-$color-%'";
  5795. }
  5796. if ($lowe) {
  5797. $where .= " and features like '%-$lowe-%'";
  5798. }
  5799. if ($label) {
  5800. $where .= " and label = '$label'";
  5801. }
  5802. if ($state || $state == 0) {
  5803. $where .= " and state = '$state'";
  5804. }
  5805. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5806. //数据排序
  5807. $order_str = "enter desc";
  5808. if (empty($page)) {
  5809. $start = 0;
  5810. $perpage = 1;
  5811. } else {
  5812. $start = ($page - 1) * $perpage;
  5813. }
  5814. //取得信息列表
  5815. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5816. foreach ($info_list as $key => $value) {
  5817. $warehouse = $this->warehouse->read($value['warehouse']);
  5818. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5819. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5820. if ($value['state'] == 0) {
  5821. $info_list[$key]['state'] = "在库";
  5822. } else if ($value['state'] == 1) {
  5823. $info_list[$key]['state'] = "出库";
  5824. } else if ($value['state'] == 2) {
  5825. $info_list[$key]['state'] = "退库";
  5826. } else if ($value['state'] == 3) {
  5827. $info_list[$key]['state'] = "调拨中";
  5828. } else if ($value['state'] == 4) {
  5829. $info_list[$key]['state'] = "再加工";
  5830. } else if ($value['state'] == 5) {
  5831. $info_list[$key]['state'] = "维修中";
  5832. } else if ($value['state'] == 6) {
  5833. $info_list[$key]['state'] = "盘亏";
  5834. } else if ($value['state'] == 7) {
  5835. $info_list[$key]['state'] = "更换标签";
  5836. } else if ($value['state'] == 8) {
  5837. $info_list[$key]['state'] = "其它";
  5838. } else if ($value['state'] == 9) {
  5839. $info_list[$key]['state'] = "预设";
  5840. } else if ($value['state'] == 10) {
  5841. $info_list[$key]['state'] = "美店零售";
  5842. }
  5843. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5844. }
  5845. $total = $this->$ck->find_count($where);
  5846. $pagenum = ceil($total / $perpage);
  5847. $over = $total - ($start + $perpage);
  5848. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5849. echo json_encode($rows);
  5850. exit;
  5851. }
  5852. if (isset($post['tmsku'])) {
  5853. $time = time();
  5854. $tmsku = $this->input->post('tmsku', true);
  5855. //$post['shop'] = $this->input->post('shop',true);
  5856. $num = $this->input->post('num', true);
  5857. $rktype = $this->input->post('rktype', true);
  5858. if ($num > 200) {
  5859. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5860. exit;
  5861. }
  5862. if (!$rktype) {
  5863. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5864. }
  5865. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5866. /**
  5867. $wz = array();
  5868. foreach ($rk as $key=>$value)
  5869. {
  5870. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5871. }
  5872. if(count($wz) > 1)
  5873. {
  5874. $wz = array_values($wz);
  5875. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5876. }
  5877. **/
  5878. if (isset($rk[0]['purchase'])) {
  5879. $rk = $rk[0];
  5880. $j = 0;
  5881. $post['purchase'] = $rk['purchase'];
  5882. $post['warehouse'] = $rk['warehouse'];
  5883. $post['retreatwarehouse'] = $rk['warehouse'];
  5884. $post['sku'] = $rk['sku'];
  5885. $post['number'] = $rk['number'];
  5886. $post['features'] = $rk['features'];
  5887. $post['title'] = $rk['title'];
  5888. $post['enter'] = $time;
  5889. $post['time'] = $time;
  5890. $post['bs'] = 1;
  5891. $post['shop'] = $rk['shop'];
  5892. $post['details'] = $rk['details'];
  5893. $post['cpid'] = $rk['cpid'];
  5894. $post['cpbz'] = $rk['cpbz'];
  5895. //$post['rktype'] = $rktype;
  5896. $warehouse = $this->warehouse->read($rk['warehouse']);
  5897. if ($warehouse['bdck'] == '') {
  5898. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5899. exit;
  5900. } else {
  5901. $bdck = $warehouse['bdck'];
  5902. }
  5903. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5904. if (isset($pdwz['details'])) {
  5905. if ($pdwz['details'] != $post['details']) {
  5906. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5907. exit;
  5908. }
  5909. }
  5910. $post['featurespp'] = $rk['featurespp'];
  5911. if ($post['warehouse'] == '5') {
  5912. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5913. if ($yza) {
  5914. if ($post['features'] != $yza[0]['features']) {
  5915. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5916. exit;
  5917. }
  5918. }
  5919. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5920. if ($yzb) {
  5921. if ($post['sku'] != $yzb[0]['sku']) {
  5922. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5923. exit;
  5924. }
  5925. }
  5926. }
  5927. for ($i = 0; $i < $num; $i++) {
  5928. $post['label'] = time() . rand(100, 999) . $i;
  5929. if ($this->$bdck->insert($post)) {
  5930. $j++;
  5931. }
  5932. }
  5933. /**
  5934. if($post['warehouse'] != 12)
  5935. {
  5936. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5937. }
  5938. **/
  5939. if ($j == $num) {
  5940. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5941. exit;
  5942. } else {
  5943. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5944. exit;
  5945. }
  5946. } else {
  5947. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5948. exit;
  5949. }
  5950. }
  5951. $this->_Template('whlabel_printrk', $this->data);
  5952. }
  5953. public function _printxzrk($arg_array)
  5954. {
  5955. $post = $this->input->post(NULL, TRUE);
  5956. if (isset($post['wzid'])) {
  5957. $time = time();
  5958. $id = $this->input->post('wzid', true);
  5959. //$post['shop'] = $this->input->post('shop',true);
  5960. $num = 1;
  5961. $rk = $this->whlabellabel->read($id);
  5962. if (isset($rk['purchase'])) {
  5963. $x = 0;
  5964. $post['purchase'] = $rk['purchase'];
  5965. $post['warehouse'] = $rk['warehouse'];
  5966. $post['retreatwarehouse'] = $rk['warehouse'];
  5967. $post['sku'] = $rk['sku'];
  5968. $post['number'] = $rk['number'];
  5969. $post['features'] = $rk['features'];
  5970. $post['title'] = $rk['title'];
  5971. $post['enter'] = $time;
  5972. $post['time'] = $time;
  5973. $post['bs'] = 1;
  5974. $post['shop'] = $rk['shop'];
  5975. $post['details'] = $rk['details'];
  5976. $post['cpid'] = $rk['cpid'];
  5977. $post['cpbz'] = $rk['cpbz'];
  5978. $warehouse = $this->warehouse->read($rk['warehouse']);
  5979. if ($warehouse['bdck'] == '') {
  5980. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5981. exit;
  5982. } else {
  5983. $bdck = $warehouse['bdck'];
  5984. }
  5985. $post['featurespp'] = $rk['featurespp'];
  5986. $this->db->trans_begin();
  5987. for ($i = 0; $i < $num; $i++) {
  5988. $post['label'] = time() . rand(100, 999) . $i;
  5989. $this->$bdck->insert($post);
  5990. }
  5991. /**
  5992. if($post['warehouse'] != 12)
  5993. {
  5994. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5995. }
  5996. **/
  5997. if ($this->db->trans_status() === TRUE) {
  5998. $this->db->trans_commit();
  5999. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6000. exit;
  6001. } else {
  6002. $this->db->trans_rollback();
  6003. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6004. exit;
  6005. }
  6006. } else {
  6007. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6008. exit;
  6009. }
  6010. }
  6011. }
  6012. public function _printck($arg_array)
  6013. {
  6014. $prc = array();
  6015. $purchase = $this->purchase->find_all();
  6016. foreach ($purchase as $k => $v) {
  6017. $prc[$v['id']] = $v['title'];
  6018. }
  6019. $post = $this->input->post(NULL, TRUE);
  6020. if (isset($post['page'])) {
  6021. $page = $this->input->post('page', true);
  6022. $perpage = $this->input->post('perpage', true);
  6023. $sku = $this->input->post('sku', true);
  6024. $bs = $this->input->post('bs', true);
  6025. $number = $this->input->post('number', true);
  6026. $warehouse = $this->input->post('warehouse', true);
  6027. $purchase = $this->input->post('purchase', true);
  6028. $orderinfo = $this->input->post('orderinfo', true);
  6029. $waybill = $this->input->post('waybill', true);
  6030. $category = $this->input->post('category', true);
  6031. $size = $this->input->post('size', true);
  6032. $grade = $this->input->post('grade', true);
  6033. $color = $this->input->post('color', true);
  6034. $lowe = $this->input->post('lowe', true);
  6035. $state = $this->input->post('state', true);
  6036. $label = $this->input->post('label', true);
  6037. $timetk = $this->input->post('ktime', true);
  6038. $timetj = $this->input->post('jtime', true);
  6039. $timetk = strtotime($timetk);
  6040. $timetj = strtotime($timetj);
  6041. $where = "state=1 ";
  6042. if ($timetk && $timetj) {
  6043. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6044. }
  6045. if ($sku) {
  6046. $where .= " and sku = '$sku'";
  6047. }
  6048. if ($bs != '') {
  6049. $where .= " and bs = '$bs'";
  6050. }
  6051. if ($number) {
  6052. $where .= " and number = '$number'";
  6053. }
  6054. if ($warehouse) {
  6055. $where .= " and warehouse = '$warehouse'";
  6056. }
  6057. if ($purchase) {
  6058. $where .= " and purchase = '$purchase'";
  6059. }
  6060. if ($orderinfo) {
  6061. $where .= " and orderinfo = '$orderinfo'";
  6062. }
  6063. if ($waybill) {
  6064. $where .= " and waybill = '$waybill'";
  6065. }
  6066. if ($category) {
  6067. $where .= " and features like '%-$category-%'";
  6068. }
  6069. if ($size) {
  6070. $where .= " and features like '%-$size-%'";
  6071. }
  6072. if ($grade) {
  6073. $where .= " and features like '%-$grade-%'";
  6074. }
  6075. if ($color) {
  6076. $where .= " and features like '%-$color-%'";
  6077. }
  6078. if ($lowe) {
  6079. $where .= " and features like '%-$lowe-%'";
  6080. }
  6081. if ($label) {
  6082. $where .= " and label = '$label'";
  6083. }
  6084. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6085. //数据排序
  6086. $order_str = "outk desc";
  6087. if (empty($page)) {
  6088. $start = 0;
  6089. $perpage = 1;
  6090. } else {
  6091. $start = ($page - 1) * $perpage;
  6092. }
  6093. //取得信息列表
  6094. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6095. foreach ($info_list as $key => $value) {
  6096. $warehouse = $this->warehouse->read($value['warehouse']);
  6097. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6098. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6099. if ($value['state'] == 0) {
  6100. $info_list[$key]['state'] = "在库";
  6101. } else if ($value['state'] == 1) {
  6102. $info_list[$key]['state'] = "出库";
  6103. } else if ($value['state'] == 2) {
  6104. $info_list[$key]['state'] = "退库";
  6105. } else if ($value['state'] == 3) {
  6106. $info_list[$key]['state'] = "调拨中";
  6107. } else if ($value['state'] == 4) {
  6108. $info_list[$key]['state'] = "再加工";
  6109. } else if ($value['state'] == 5) {
  6110. $info_list[$key]['state'] = "维修中";
  6111. } else if ($value['state'] == 6) {
  6112. $info_list[$key]['state'] = "盘亏";
  6113. } else if ($value['state'] == 7) {
  6114. $info_list[$key]['state'] = "更换标签";
  6115. } else if ($value['state'] == 8) {
  6116. $info_list[$key]['state'] = "其它";
  6117. } else if ($value['state'] == 9) {
  6118. $info_list[$key]['state'] = "预设";
  6119. } else if ($value['state'] == 10) {
  6120. $info_list[$key]['state'] = "美店零售";
  6121. }
  6122. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6123. }
  6124. $total = $this->$ck->find_count($where);
  6125. $pagenum = ceil($total / $perpage);
  6126. $over = $total - ($start + $perpage);
  6127. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6128. echo json_encode($rows);
  6129. exit;
  6130. }
  6131. if (isset($post['tmsku'])) {
  6132. $time = time();
  6133. $tmsku = $this->input->post('tmsku', true);
  6134. //$post['shop'] = $this->input->post('shop',true);
  6135. $num = $this->input->post('num', true);
  6136. $cktype = $this->input->post('cktype', true);
  6137. $label = $this->whlabellabel->get_label($tmsku);
  6138. if (!$cktype) {
  6139. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6140. }
  6141. if (!isset($label['warehouse'])) {
  6142. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6143. exit;
  6144. }
  6145. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6146. if (stripos($label['features'], '-126-') !== false) {
  6147. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6148. } else {
  6149. $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 = ''");
  6150. }
  6151. $j = 0;
  6152. if (count($ck) >= $num) {
  6153. for ($i = 0; $i < $num; $i++) {
  6154. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6155. {
  6156. $j++;
  6157. }
  6158. }
  6159. if ($j == $num) {
  6160. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6161. exit;
  6162. } else {
  6163. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6164. exit;
  6165. }
  6166. } else {
  6167. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6168. exit;
  6169. }
  6170. }
  6171. if(isset($_SESSION['api']))
  6172. {
  6173. $user = $this->user->get_api($_SESSION['api']);
  6174. if(in_array($user['power'],[1,27])){
  6175. $vip = 1;
  6176. }
  6177. }
  6178. else
  6179. {
  6180. $vip = 0;
  6181. header('Location: /');exit;
  6182. }
  6183. $this->data['vip'] = $vip;
  6184. $this->_Template('whlabel_printck', $this->data);
  6185. }
  6186. public function _printexcel()
  6187. {
  6188. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6189. $config['upload_path'] = '.' . $dir;
  6190. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6191. $config['allowed_types'] = 'xls|xlsx|csv';
  6192. $config['max_size'] = 10240;
  6193. $this->load->library('upload', $config);
  6194. $this->upload->initialize($config);
  6195. if ($this->upload->do_upload('userfile')) {
  6196. $full_path = $dir . $this->upload->data('file_name');
  6197. $fileName = '.' . $full_path;
  6198. if (!file_exists($fileName)) {
  6199. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6200. exit;
  6201. } else {
  6202. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6203. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6204. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6205. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6206. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6207. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6208. ++$column; //如果列数大于26行
  6209. $list = array();
  6210. for ($i = 2; $i <= $row; $i++) // 行数循环
  6211. {
  6212. $data = array();
  6213. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6214. {
  6215. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6216. }
  6217. $list[] = $data;
  6218. }
  6219. }
  6220. $ed = array();
  6221. $i = 0;
  6222. $j = 0;
  6223. $dcdata = array();
  6224. $yc = '';
  6225. $cmf_arr = array_column($list, '1');
  6226. array_multisort($cmf_arr, SORT_ASC, $list);
  6227. foreach ($list as $key => $value) {
  6228. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6229. if ($typeclass) {
  6230. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6231. } else {
  6232. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6233. $i++;
  6234. continue;
  6235. }
  6236. }
  6237. if ($i > 0) {
  6238. $yc = $i . '条异常';
  6239. }
  6240. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6241. exit;
  6242. }
  6243. }
  6244. public function _uck()
  6245. {
  6246. if (isset($_GET['excel'])) {
  6247. $tc = array();
  6248. $typeclass = $this->typeclass->find_all();
  6249. foreach ($typeclass as $v) {
  6250. $tc[$v['id']] = $v['zh'];
  6251. }
  6252. $data = array();
  6253. $t = array();
  6254. $rq = '';
  6255. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6256. $ts = $ts / (24 * 3600);
  6257. for ($i = 0; $i < $ts; $i++) {
  6258. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6259. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6260. }
  6261. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6262. foreach ($info_list as $k => $v) {
  6263. $features = explode('-', trim($v['features'], '-'));
  6264. if (!isset($features[3]) || !isset($features[4])) {
  6265. continue;
  6266. }
  6267. $data[$k][0] = $tc[$features[0]]; //类型
  6268. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6269. $data[$k][2] = $tc[$features[4]]; //曲度
  6270. $data[$k][3] = '';
  6271. if (isset($data[$k][1])) {
  6272. $data[$k][3] .= $data[$k][1];
  6273. }
  6274. if (isset($data[$k][2])) {
  6275. $data[$k][3] .= $data[$k][2];
  6276. }
  6277. if (isset($features[5])) {
  6278. $data[$k][3] .= $tc[$features[5]];
  6279. }
  6280. if (isset($features[2])) {
  6281. $data[$k][3] .= $tc[$features[2]];
  6282. }
  6283. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6284. $data[$k][4] = $v['sku'];
  6285. $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())) . '))'); //月初库存
  6286. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6287. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6288. $ztrq = '';
  6289. $ztsl = '';
  6290. if (count($zt) > 0) {
  6291. foreach ($zt as $vv) {
  6292. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6293. $ztsl .= $vv['num'] . '<br>';
  6294. }
  6295. }
  6296. $data[$k][] = trim($ztsl, '<br>');
  6297. $data[$k][] = trim($ztrq, '<br>');
  6298. $byck = 0;
  6299. foreach ($t as $vv) {
  6300. $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));
  6301. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6302. $byck += $sl;
  6303. }
  6304. $data[$k][] = ($byck > 0) ? $byck : '';
  6305. }
  6306. $title = "详情 " . date("Y-m-d", time());
  6307. $titlename = "<table border=1>
  6308. <tr align='center'>
  6309. <td>类别</td>
  6310. <td>颜色</td>
  6311. <td>曲度</td>
  6312. <td>名称</td>
  6313. <td>SKU</td>
  6314. <td>月初库存</td>
  6315. <td>剩余库存</td>
  6316. <td>在途数量</td>
  6317. <td>预达日期</td>" .
  6318. $rq
  6319. . "<td>本月出库</td></tr>
  6320. </table>";
  6321. $filename = $title . ".xls";
  6322. $tail = "";
  6323. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6324. }
  6325. }
  6326. public function _whlabelexcelzh()
  6327. {
  6328. if (isset($_GET['excel'])) {
  6329. $where = "sku != 'Preset'";
  6330. //数据排序
  6331. $order_str = "id desc";
  6332. if (empty($page)) {
  6333. $start = 0;
  6334. $perpage = 1;
  6335. } else {
  6336. $start = ($page - 1) * $perpage;
  6337. }
  6338. $category = $this->input->get('category', true);
  6339. $warehouse = $this->input->get('warehouse', true);
  6340. $excelid = $this->input->get('sid', true);
  6341. if ($category) {
  6342. $where .= " and features like '%-$category-%'";
  6343. }
  6344. if ($warehouse) {
  6345. $where .= " and warehouse = '$warehouse'";
  6346. }
  6347. $xzid = '';
  6348. if ($excelid) {
  6349. $excelid = explode(',', trim($excelid, ','));
  6350. foreach ($excelid as $key => $value) {
  6351. $xzid .= " id = " . $value . " or";
  6352. }
  6353. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6354. }
  6355. //取得信息列表
  6356. /**
  6357. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6358. $rows = array();$list = array();
  6359. foreach ($info_list as $key=>$value)
  6360. {
  6361. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6362. }
  6363. **/
  6364. $list = array();
  6365. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6366. foreach ($rows as $key => $value) {
  6367. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6368. $zh = '';
  6369. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6370. foreach ($zt as $v) {
  6371. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6372. }
  6373. $zt = array_sum(array_column($zt, 'num'));
  6374. $number = $value['number'];
  6375. $ftime = time() - 15 * 24 * 3600;
  6376. $warehouse = $this->warehouse->read($value['warehouse']);
  6377. $rows[$key]['warehouse'] = $warehouse['title'];
  6378. $rows[$key]['number'] = $c;
  6379. $rows[$key]['features'] = $zh;
  6380. $rows[$key]['hb'] = $c + $zt;
  6381. }
  6382. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6383. $titlename = "<table border=1>
  6384. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6385. <tr align='center'>
  6386. <td>仓库</td>
  6387. <td>SKU</td>
  6388. <td>产品</td>
  6389. <td>库存数量</td>
  6390. <td>在途数量及预达日期</td>
  6391. <td>在途+库存数量</td>
  6392. </tr>
  6393. </table>";
  6394. $filename = $title . ".xls";
  6395. $tail = "";
  6396. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6397. }
  6398. if (isset($_GET['excel'])) {
  6399. $warehouse = $this->input->get('warehouse', true);
  6400. $sku = $this->input->get('sku', true);
  6401. $cz = $this->input->get('cz', true);
  6402. $text = $this->input->post('text', true);
  6403. $xztime = $this->input->get('xztime', true);
  6404. $timetk = $this->input->get('timetk', true);
  6405. $timetj = $this->input->get('timetj', true);
  6406. $timetk = strtotime($timetk);
  6407. $timetj = strtotime($timetj);
  6408. $where = "time = '0' ";
  6409. if ($warehouse) {
  6410. $where .= " and warehouse = '$warehouse'";
  6411. }
  6412. if ($sku) {
  6413. $where .= " and sku = '$sku'";
  6414. }
  6415. if ($text) {
  6416. $where .= " and text like '%$text%'";
  6417. }
  6418. if ($cz != '') {
  6419. $where .= " and cz = '$cz'";
  6420. }
  6421. if ($timetk && $timetj) {
  6422. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6423. }
  6424. //数据排序
  6425. $order_str = $xztime . " desc";
  6426. //取得信息列表
  6427. $zh = array();
  6428. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6429. foreach ($info_list as $v) {
  6430. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6431. $warehouse = $this->warehouse->read($v['warehouse']);
  6432. $v['warehouse'] = $warehouse['title'];
  6433. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6434. $v['stime'] = date('Y-m-d', $v['stime']);
  6435. if (isset($zh[$v['features']])) {
  6436. $zh[$v['features']]['num'] += $v['num'];
  6437. } else {
  6438. $zh[$v['features']] = $v;
  6439. }
  6440. $zh[$v['features']]['features'] = $c;
  6441. }
  6442. $title = "在途数据" . date('Y-m-d', time());
  6443. $titlename = "<table border=1>
  6444. <tr align='center'>
  6445. <td>仓库</td>
  6446. <td>SKU</td>
  6447. <td>名称</td>
  6448. <td>在途数量</td>
  6449. <td>库存数量</td>
  6450. <td>添加在途日期</td>
  6451. <td>预达日期</td>
  6452. <td>备注</td>
  6453. </tr>
  6454. </table>";
  6455. $filename = $title . ".xls";
  6456. $tail = "";
  6457. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6458. }
  6459. }
  6460. public function _fc()
  6461. {
  6462. $vip = 0;
  6463. if (isset($_SESSION['api'])) {
  6464. $user = $this->user->get_api($_SESSION['api']);
  6465. if ($user['vip'] == 1) {
  6466. $vip = 1;
  6467. }
  6468. } else {
  6469. header('Location: /');
  6470. exit;
  6471. }
  6472. $post = $this->input->post(NULL, TRUE);
  6473. if (isset($post['page'])) {
  6474. $page = $this->input->post('page', true);
  6475. $perpage = $this->input->post('perpage', true);
  6476. $category = $this->input->post('category', true);
  6477. $size = $this->input->post('size', true);
  6478. $grade = $this->input->post('grade', true);
  6479. $color = $this->input->post('color', true);
  6480. $lowe = $this->input->post('lowe', true);
  6481. $sku = $this->input->post('sku');
  6482. $title = $this->input->post('title');
  6483. $warehouse = $this->input->post('warehouse', true);
  6484. $usa = $this->input->post('usa', true);
  6485. $purchase = $this->input->post('purchase', true);
  6486. $lacetype = $this->input->post('lacetype', true);
  6487. $haircap = $this->input->post('haircap', true);
  6488. $density = $this->input->post('density', true);
  6489. $details = $this->input->post('details', true);
  6490. $state = $this->input->post('state', true);
  6491. $ktime = $this->input->post('ktime', true);
  6492. $jtime = $this->input->post('jtime', true);
  6493. $ktime = strtotime($ktime);
  6494. $jtime = strtotime($jtime);
  6495. $where = "state = '11'";
  6496. $gj = "";
  6497. $ck = "";
  6498. if ($lacetype) {
  6499. $where .= " and features like '%-$lacetype-%'";
  6500. }
  6501. if ($category) {
  6502. $where .= " and features like '%-$category-%'";
  6503. }
  6504. if ($size) {
  6505. $where .= " and features like '%-$size-%'";
  6506. }
  6507. if ($grade) {
  6508. $where .= " and features like '%-$grade-%'";
  6509. }
  6510. if ($color) {
  6511. $where .= " and features like '%-$color-%'";
  6512. }
  6513. if ($lowe) {
  6514. $where .= " and features like '%-$lowe-%'";
  6515. }
  6516. if ($haircap) {
  6517. $where .= " and features like '%-$haircap-%'";
  6518. }
  6519. if ($density) {
  6520. $where .= " and features like '%-$density-%'";
  6521. }
  6522. if ($usa) {
  6523. if (!$warehouse) {
  6524. $where .= " and (warehouse = '5' or warehouse = '8')";
  6525. }
  6526. }
  6527. if ($warehouse) {
  6528. $where .= " and warehouse = '$warehouse'";
  6529. }
  6530. if ($details) {
  6531. $where .= " and details = '$details'";
  6532. }
  6533. if ($purchase) {
  6534. $where .= " and purchase = '$purchase'";
  6535. }
  6536. if ($state) {
  6537. $where .= " and state = '$state'";
  6538. }
  6539. if ($ktime && $jtime) {
  6540. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6541. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6542. }
  6543. //数据排序
  6544. $order_str = "id desc";
  6545. if (empty($page)) {
  6546. $start = 0;
  6547. $perpage = 1;
  6548. } else {
  6549. $start = ($page - 1) * $perpage;
  6550. }
  6551. if ($sku) {
  6552. $sku = trim($sku, ' ');
  6553. $sku = trim($sku, ' ');
  6554. $where .= " and sku like '%$sku%'";
  6555. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6556. } else if ($title) {
  6557. $title = trim($title, ' ');
  6558. $title = trim($title, ' ');
  6559. $where .= " and title like '%$title%'";
  6560. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6561. } else {
  6562. //$where .= " and time > '$ktime' and time < '$jtime'";
  6563. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6564. }
  6565. //取得信息列表
  6566. $rows = array();
  6567. $list = array();
  6568. foreach ($info_list as $key => $value) {
  6569. $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'] . '"');
  6570. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6571. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6572. $warehouse = $this->warehouse->read($value['warehouse']);
  6573. $info_list[$key]['warehouse'] = $warehouse['title'];
  6574. $info_list[$key]['number'] = $g;
  6575. $info_list[$key]['features'] = $x;
  6576. $info_list[$key]['x'] = $s;
  6577. }
  6578. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6579. $pagenum = ceil($total / $perpage);
  6580. $over = $total - ($start + $perpage);
  6581. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6582. echo json_encode($rows);
  6583. exit;
  6584. }
  6585. $this->data['vip'] = $vip;
  6586. $this->_Template('whlabel_fc', $this->data);
  6587. }
  6588. public function _fcmb()
  6589. {
  6590. $where = "sku != 'Preset'";
  6591. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6592. foreach ($rows as $k => $v) {
  6593. $warehouse = $this->warehouse->read($v['warehouse']);
  6594. $rows[$k]['warehouse'] = $warehouse['title'];
  6595. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6596. $rows[$k]['t'] = '';
  6597. $rows[$k]['n'] = '';
  6598. }
  6599. $title = "封货产品数据导入模板";
  6600. $titlename = "<table border=1>
  6601. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6602. <tr align='center'>
  6603. <td>仓库</td>
  6604. <td>SKU</td>
  6605. <td>产品</td>
  6606. <td>封存产品总数量</td>
  6607. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6608. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6609. </tr>
  6610. </table>";
  6611. $filename = $title . ".xls";
  6612. $tail = "";
  6613. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6614. }
  6615. public function _fcexcel()
  6616. {
  6617. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6618. $config['upload_path'] = '.' . $dir;
  6619. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6620. $config['allowed_types'] = 'xls|xlsx|csv';
  6621. $config['max_size'] = 10240;
  6622. $this->load->library('upload', $config);
  6623. $this->upload->initialize($config);
  6624. if ($this->upload->do_upload('userfile')) {
  6625. $full_path = $dir . $this->upload->data('file_name');
  6626. $fileName = '.' . $full_path;
  6627. if (!file_exists($fileName)) {
  6628. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6629. exit;
  6630. } else {
  6631. libxml_use_internal_errors(true);
  6632. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6633. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6634. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6635. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6636. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6637. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6638. ++$column; //如果列数大于26行
  6639. $list = array();
  6640. for ($i = 2; $i <= $row; $i++) // 行数循环
  6641. {
  6642. $data = array();
  6643. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6644. {
  6645. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6646. }
  6647. $list[] = $data;
  6648. }
  6649. }
  6650. $i = 0;
  6651. $j = 0;
  6652. $ed = array();
  6653. foreach ($list as $key => $value) {
  6654. $time = time();
  6655. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6656. continue;
  6657. }
  6658. $warehouse = $this->warehouse->get_title($value['0']);
  6659. $sku = $value['1'];
  6660. $type = $value['4']; //调整方式0扣减1删除
  6661. $num = $value['5']; //调整数量
  6662. //$text = $value['4'];//扣减说明
  6663. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6664. if (!$d) //如果没有这个SKU
  6665. {
  6666. $ed[] = array($sku . '-库存中不存在此SKU');
  6667. $j++;
  6668. continue;
  6669. }
  6670. if (!isset($warehouse['id'])) {
  6671. $ed[] = array($sku . '-仓库名错误!');
  6672. $j++;
  6673. continue;
  6674. }
  6675. if ($type == 1 || $type == 2) //扣减库存
  6676. {
  6677. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6678. if (count($data) < abs($num)) {
  6679. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6680. $j++;
  6681. continue;
  6682. }
  6683. if ($type == 1) //转入库存
  6684. {
  6685. for ($i = 0; $i < abs($num); $i++) {
  6686. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6687. }
  6688. } else if ($type == 2) //删除
  6689. {
  6690. for ($i = 0; $i < abs($num); $i++) {
  6691. $this->whlabel->remove($data[$i]['id']);
  6692. }
  6693. }
  6694. } else if ($type == 0) //增加库存
  6695. {
  6696. $post['sku'] = $d['sku'];
  6697. $post['shop'] = '';
  6698. $post['warehouse'] = $warehouse['id'];
  6699. $post['purchase'] = $d['purchase'];
  6700. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6701. $post['state'] = 11;
  6702. $post['title'] = $d['title'];
  6703. $post['number'] = $d['number'];
  6704. $post['features'] = $d['features'];
  6705. $post['enter'] = $time;
  6706. $post['time'] = $time; //操作时间
  6707. for ($i = 0; $i < $num; $i++) {
  6708. $post['label'] = time() . rand(100, 999) . $i;
  6709. $this->whlabel->insert($post);
  6710. }
  6711. }
  6712. sleep(1); //防止入库时间一样,需要延迟1秒
  6713. }
  6714. if ($j > 0) {
  6715. $tt = date('Ymd', time());
  6716. $title = '库存导入错误信息-' . $tt;
  6717. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6718. $tail = "\n";
  6719. $filename = $title . ".xls";
  6720. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6721. $dir = '/data/excel/' . $time . '/';
  6722. $file_name = 'error_' . $time . rand(1000, 9999);
  6723. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6724. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6725. fwrite($myfile, $ecl);
  6726. fclose($myfile);
  6727. $error = $dir . $file_name . '.xls';
  6728. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6729. exit;
  6730. } else {
  6731. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6732. exit;
  6733. }
  6734. }
  6735. }
  6736. public function _fcjxc($arg_array)
  6737. {
  6738. if (isset($_GET['excel'])) {
  6739. $category = $this->input->get('category', true);
  6740. $size = $this->input->get('size', true);
  6741. $grade = $this->input->get('grade', true);
  6742. $color = $this->input->get('color', true);
  6743. $lowe = $this->input->get('lowe', true);
  6744. $sku = $this->input->get('sku');
  6745. $title = $this->input->get('title');
  6746. $warehouse = $arg_array[0];
  6747. $usa = $this->input->get('usa', true);
  6748. $purchase = $this->input->get('purchase', true);
  6749. $lacetype = $this->input->get('lacetype', true);
  6750. $haircap = $this->input->get('haircap', true);
  6751. $density = $this->input->get('density', true);
  6752. $title = $this->input->get('title', true);
  6753. $state = $this->input->get('state', true);
  6754. $ktime = $this->input->get('ktime', true);
  6755. $jtime = $this->input->get('jtime', true);
  6756. $where = "state=11";
  6757. $gj = "";
  6758. $ck = "";
  6759. if ($lacetype) {
  6760. $where .= " and features like '%-$lacetype-%'";
  6761. }
  6762. if ($category) {
  6763. $where .= " and features like '%-$category-%'";
  6764. }
  6765. if ($size) {
  6766. $where .= " and features like '%-$size-%'";
  6767. }
  6768. if ($grade) {
  6769. $where .= " and features like '%-$grade-%'";
  6770. }
  6771. if ($color) {
  6772. $where .= " and features like '%-$color-%'";
  6773. }
  6774. if ($lowe) {
  6775. $where .= " and features like '%-$lowe-%'";
  6776. }
  6777. if ($haircap) {
  6778. $where .= " and features like '%-$haircap-%'";
  6779. }
  6780. if ($density) {
  6781. $where .= " and features like '%-$density-%'";
  6782. }
  6783. if ($usa) {
  6784. if (!$warehouse) {
  6785. $where .= " and (warehouse = '5' or warehouse = '8')";
  6786. }
  6787. }
  6788. if ($warehouse) {
  6789. $where .= " and warehouse = '$warehouse'";
  6790. }
  6791. if ($purchase) {
  6792. $where .= " and purchase = '$purchase'";
  6793. }
  6794. if ($state) {
  6795. $where .= " and state = '$state'";
  6796. }
  6797. $order_str = "id desc";
  6798. if ($sku) {
  6799. $sku = trim($sku, ' ');
  6800. $sku = trim($sku, ' ');
  6801. $where .= " and sku like '%$sku%'";
  6802. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6803. } else if ($title) {
  6804. $title = trim($title, ' ');
  6805. $title = trim($title, ' ');
  6806. $where .= " and title like '%$title%'";
  6807. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6808. } else {
  6809. //$where .= " and time > '$ktime' and time < '$jtime'";
  6810. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6811. }
  6812. //取得信息列表
  6813. $rows = array();
  6814. $list = array();
  6815. foreach ($info_list as $key => $value) {
  6816. $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'] . '"');
  6817. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6818. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6819. $rows[$key] = $value;
  6820. $warehouse = $this->warehouse->read($value['warehouse']);
  6821. $rows[$key]['warehouse'] = $warehouse['title'];
  6822. $rows[$key]['features'] = $g;
  6823. $rows[$key]['a'] = $x;
  6824. $rows[$key]['b'] = $s;
  6825. }
  6826. $title = "总统计表";
  6827. $titlename = "<table border=1>
  6828. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6829. <tr align='center'>
  6830. <td>仓库</td>
  6831. <td>SKU</td>
  6832. <td>产品名称</td>
  6833. <td>录入总量</td>
  6834. <td>取出总量</td>
  6835. <td>剩余总量</td>
  6836. </tr>
  6837. </table>";
  6838. $filename = $title . ".xls";
  6839. $tail = "";
  6840. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6841. }
  6842. $vip = 0;
  6843. if (isset($_SESSION['api'])) {
  6844. $user = $this->user->get_api($_SESSION['api']);
  6845. if ($user['vip'] == 1) {
  6846. $vip = 1;
  6847. }
  6848. } else {
  6849. header('Location: /');
  6850. exit;
  6851. }
  6852. $post = $this->input->post(NULL, TRUE);
  6853. if (isset($post['page'])) {
  6854. $page = $this->input->post('page', true);
  6855. $perpage = $this->input->post('perpage', true);
  6856. $category = $this->input->post('category', true);
  6857. $size = $this->input->post('size', true);
  6858. $grade = $this->input->post('grade', true);
  6859. $color = $this->input->post('color', true);
  6860. $lowe = $this->input->post('lowe', true);
  6861. $sku = $this->input->post('sku');
  6862. $title = $this->input->post('title');
  6863. $warehouse = $arg_array[0];
  6864. $usa = $this->input->post('usa', true);
  6865. $purchase = $this->input->post('purchase', true);
  6866. $lacetype = $this->input->post('lacetype', true);
  6867. $haircap = $this->input->post('haircap', true);
  6868. $density = $this->input->post('density', true);
  6869. $title = $this->input->post('title', true);
  6870. $state = $this->input->post('state', true);
  6871. $ktime = $this->input->post('ktime', true);
  6872. $jtime = $this->input->post('jtime', true);
  6873. $ktime = strtotime($ktime);
  6874. $jtime = strtotime($jtime);
  6875. $where = "state=11";
  6876. $gj = "";
  6877. $ck = "";
  6878. if ($lacetype) {
  6879. $where .= " and features like '%-$lacetype-%'";
  6880. }
  6881. if ($category) {
  6882. $where .= " and features like '%-$category-%'";
  6883. }
  6884. if ($size) {
  6885. $where .= " and features like '%-$size-%'";
  6886. }
  6887. if ($grade) {
  6888. $where .= " and features like '%-$grade-%'";
  6889. }
  6890. if ($color) {
  6891. $where .= " and features like '%-$color-%'";
  6892. }
  6893. if ($lowe) {
  6894. $where .= " and features like '%-$lowe-%'";
  6895. }
  6896. if ($haircap) {
  6897. $where .= " and features like '%-$haircap-%'";
  6898. }
  6899. if ($density) {
  6900. $where .= " and features like '%-$density-%'";
  6901. }
  6902. if ($usa) {
  6903. if (!$warehouse) {
  6904. $where .= " and (warehouse = '5' or warehouse = '8')";
  6905. }
  6906. }
  6907. if ($warehouse) {
  6908. $where .= " and warehouse = '$warehouse'";
  6909. }
  6910. if ($purchase) {
  6911. $where .= " and purchase = '$purchase'";
  6912. }
  6913. if ($state) {
  6914. $where .= " and state = '$state'";
  6915. }
  6916. if ($ktime && $jtime) {
  6917. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6918. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6919. }
  6920. //数据排序
  6921. $order_str = "id desc";
  6922. $xs = 0;
  6923. $rows = array();
  6924. $list = array();
  6925. if (empty($page)) {
  6926. $start = 0;
  6927. $perpage = 1;
  6928. } else {
  6929. $start = ($page - 1) * $perpage;
  6930. }
  6931. if ($sku || $title) {
  6932. if ($title) {
  6933. $title = trim($title, ' ');
  6934. $title = trim($title, ' ');
  6935. $where .= " and title like '%$title%'";
  6936. } else {
  6937. $sku = trim($sku, ' ');
  6938. $sku = trim($sku, ' ');
  6939. $where .= " and sku like '%$sku%'";
  6940. }
  6941. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6942. foreach ($info_list as $key => $value) {
  6943. $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'] . '"');
  6944. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6945. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6946. $rows[$key] = $value;
  6947. $warehouse = $this->warehouse->read($value['warehouse']);
  6948. $rows[$key]['warehouse'] = $warehouse['title'];
  6949. $rows[$key]['features'] = $g;
  6950. $rows[$key]['a'] = $x;
  6951. $rows[$key]['b'] = $s;
  6952. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6953. $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天销量
  6954. $yj = $c / ($xl / 30);
  6955. if ($yj < 7) {
  6956. $rows[$key]['y'] = round($yj) . '天销量';
  6957. } else {
  6958. $rows[$key]['y'] = '正常';
  6959. }
  6960. }
  6961. } else {
  6962. //$where .= " and time > '$ktime' and time < '$jtime'";
  6963. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6964. foreach ($info_list as $key => $value) {
  6965. $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'] . '"');
  6966. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6967. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6968. $zs[$key] = $value;
  6969. $warehouse = $this->warehouse->read($value['warehouse']);
  6970. $zs[$key]['warehouse'] = $warehouse['title'];
  6971. $zs[$key]['features'] = $g;
  6972. $zs[$key]['a'] = $x;
  6973. $zs[$key]['b'] = $s;
  6974. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6975. $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天销量
  6976. $yj = $c / ($xl / 30);
  6977. if ($yj < 7) {
  6978. $zs[$key]['y'] = round($yj) . '天销量';
  6979. $rows[$key] = $zs[$key];
  6980. }
  6981. }
  6982. }
  6983. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6984. $pagenum = ceil($total / $perpage);
  6985. $over = $total - ($start + $perpage);
  6986. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6987. echo json_encode($rows);
  6988. exit;
  6989. }
  6990. $this->data['arg_array'] = $arg_array[0];
  6991. $this->_Template('whlabel_fcjxc', $this->data);
  6992. }
  6993. public function _0kcdel()
  6994. {
  6995. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6996. $config['upload_path'] = '.' . $dir;
  6997. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6998. $config['allowed_types'] = 'xls|xlsx|csv';
  6999. $config['max_size'] = 10240;
  7000. $this->load->library('upload', $config);
  7001. $this->upload->initialize($config);
  7002. if ($this->upload->do_upload('userfile')) {
  7003. $full_path = $dir . $this->upload->data('file_name');
  7004. $fileName = '.' . $full_path;
  7005. if (!file_exists($fileName)) {
  7006. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7007. exit;
  7008. } else {
  7009. require_once "./data/excel/PHPExcel/IOFactory.php";
  7010. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7011. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7012. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7013. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7014. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7015. ++$column; //如果列数大于26行
  7016. $list = array();
  7017. for ($i = 2; $i <= $row; $i++) // 行数循环
  7018. {
  7019. $data = array();
  7020. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7021. {
  7022. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7023. }
  7024. $list[] = $data;
  7025. }
  7026. }
  7027. $i = 0;
  7028. $j = 0;
  7029. $ed = array();
  7030. foreach ($list as $key => $value) {
  7031. $time = time();
  7032. if ($value['0'] == "" || $value['1'] == "") {
  7033. continue;
  7034. }
  7035. $warehouse = $this->warehouse->get_title($value['0']);
  7036. $sku = $value['1'];
  7037. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7038. if (!$d) //如果没有这个SKU
  7039. {
  7040. $ed[] = array($sku . '-库存中不存在此SKU');
  7041. $j++;
  7042. continue;
  7043. }
  7044. if (!isset($warehouse['id'])) {
  7045. $ed[] = array($sku . '-仓库名错误!');
  7046. $j++;
  7047. continue;
  7048. }
  7049. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7050. if ($z < 1) {
  7051. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7052. foreach ($z as $v) {
  7053. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7054. if (count($zt) > 0) {
  7055. $ed[] = array($sku . '-有在途库存无法删除!');
  7056. $j++;
  7057. continue;
  7058. }
  7059. $this->whlabel->remove($v['id']);
  7060. }
  7061. } else {
  7062. $ed[] = array($sku . '-非0库存!');
  7063. $j++;
  7064. continue;
  7065. }
  7066. }
  7067. if ($j > 0) {
  7068. $tt = date('Ymd', time());
  7069. $title = '删除0库存错误信息-' . $tt;
  7070. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7071. $tail = "\n";
  7072. $filename = $title . ".xls";
  7073. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7074. $dir = '/data/excel/' . $time . '/';
  7075. $file_name = 'error_' . $time . rand(1000, 9999);
  7076. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7077. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7078. fwrite($myfile, $ecl);
  7079. fclose($myfile);
  7080. $error = $dir . $file_name . '.xls';
  7081. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7082. exit;
  7083. } else {
  7084. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7085. exit;
  7086. }
  7087. }
  7088. }
  7089. public function _gbhtype()
  7090. {
  7091. $post = $this->input->post(NULL, TRUE);
  7092. if (isset($post['s'])) {
  7093. $n = $this->input->post('n');
  7094. $d = $this->input->post('s');
  7095. if (!$d) {
  7096. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7097. exit;
  7098. }
  7099. $d = explode(',', trim($d, ','));
  7100. $t = $this->whlabel_type->read($n);
  7101. //循环删除记录
  7102. foreach ($d as $v) {
  7103. $u = $this->whlabel->read($v);
  7104. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7105. foreach ($data as $val) {
  7106. $this->whlabel->save(array('type' => $n), $val['id']);
  7107. }
  7108. }
  7109. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7110. }
  7111. }
  7112. //出库、退库导出
  7113. public function _dccrtype()
  7114. {
  7115. $classid = $this->classid->sku();
  7116. $pm = $classid;
  7117. $typeclass = array();
  7118. $tc = $this->typeclass->find_all();
  7119. foreach ($tc as $v) {
  7120. $typeclass[$v['id']] = $v;
  7121. }
  7122. $prc = array();
  7123. $purchase = $this->purchase->find_all();
  7124. foreach ($purchase as $k => $v) {
  7125. $prc[$v['id']] = $v['title'];
  7126. }
  7127. if (isset($_GET['sid'])) {
  7128. $wh = array();
  7129. $w = $this->warehouse->find_all('1=1', 'id,title');
  7130. foreach ($w as $v) {
  7131. $wh[$v['id']] = $v['title'];
  7132. }
  7133. $type = $this->input->get('excel', true);
  7134. $category = $this->input->get('category', true);
  7135. $size = $this->input->get('size', true);
  7136. $grade = $this->input->get('grade', true);
  7137. $color = $this->input->get('color', true);
  7138. $lowe = $this->input->get('lowe', true);
  7139. $sku = $this->input->get('sku', true);
  7140. $warehouse = $this->input->get('warehouse', true);
  7141. $lacetype = $this->input->get('lacetype', true);
  7142. $lacecolor = $this->input->get('lacecolor', true);
  7143. $density = $this->input->get('density', true);
  7144. $haircap = $this->input->get('haircap', true);
  7145. $purchase = $this->input->get('purchase', true);
  7146. $title = $this->input->get('title', true);
  7147. $state = $this->input->get('state', true);
  7148. $sid = $this->input->get('sid', true);
  7149. $ktime = $this->input->get('ktime', true);
  7150. $jtime = $this->input->get('jtime', true);
  7151. $ktime = strtotime($ktime);
  7152. $jtime = strtotime($jtime);
  7153. $where = "1=1";
  7154. $gj = "";
  7155. $ck = "";
  7156. if ($category) {
  7157. $where .= " and features like '%-$category-%'";
  7158. }
  7159. if ($size) {
  7160. $where .= " and features like '%-$size-%'";
  7161. }
  7162. if ($grade) {
  7163. $where .= " and features like '%-$grade-%'";
  7164. }
  7165. if ($color) {
  7166. $where .= " and features like '%-$color-%'";
  7167. }
  7168. if ($lowe) {
  7169. $where .= " and features like '%-$lowe-%'";
  7170. }
  7171. if ($warehouse) {
  7172. $where .= " and warehouse = '$warehouse'";
  7173. }
  7174. if ($purchase) {
  7175. $where .= " and purchase = '$purchase'";
  7176. }
  7177. if ($state) {
  7178. $where .= " and state = '$state'";
  7179. }
  7180. if ($lacetype) {
  7181. $where .= " and features like '%-$lacetype-%'";
  7182. }
  7183. if ($lacecolor) {
  7184. $where .= " and features like '%-$lacecolor-%'";
  7185. }
  7186. if ($density) {
  7187. $where .= " and features like '%-$density-%'";
  7188. }
  7189. if ($haircap) {
  7190. $where .= " and features like '%-$haircap-%'";
  7191. }
  7192. if ($title) {
  7193. $title = trim($title, ' ');
  7194. $title = trim($title, ' ');
  7195. $where .= " and title like '%$title%'";
  7196. }
  7197. if ($sku) {
  7198. $sku = trim($sku, ' ');
  7199. $sku = trim($sku, ' ');
  7200. $where .= " and sku like '%$sku%'";
  7201. }
  7202. if ($ktime && $jtime) {
  7203. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7204. }
  7205. $sidwhere = '';
  7206. if ($sid) {
  7207. $sd = "";
  7208. $s = explode(',', trim($sid, ','));
  7209. foreach ($s as $value) {
  7210. $sd .= " id = " . $value . " or";
  7211. }
  7212. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7213. }
  7214. //数据排序
  7215. $order_str = "time desc";
  7216. if (empty($page)) {
  7217. $start = 0;
  7218. $perpage = 1;
  7219. } else {
  7220. $start = ($page - 1) * $perpage;
  7221. }
  7222. $wh = array();
  7223. $w = $this->warehouse->find_all('1=1', 'id,title');
  7224. foreach ($w as $v) {
  7225. $wh[$v['id']] = $v['title'];
  7226. }
  7227. $wt = array();
  7228. $whlabel_type = $this->whlabel_type->find_all();
  7229. foreach ($whlabel_type as $v) {
  7230. $wt[$v['id']] = $v['title'];
  7231. }
  7232. $classid = $this->classid->sku();
  7233. $list = array();
  7234. $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');
  7235. foreach ($rows_r as $key => $value) {
  7236. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7237. $pm = $classid;
  7238. $jm = $classid;
  7239. $rows_r[$key]['enter'] = '入库';
  7240. $rows_r[$key]['time'] = $value['enter'];
  7241. if ($value['rktype'] == 1) {
  7242. $rows_r[$key]['rktype'] = '采购入库';
  7243. } else if ($value['rktype'] == 2) {
  7244. $rows_r[$key]['rktype'] = '盘盈调整';
  7245. } else if ($value['rktype'] == 3) {
  7246. $rows_r[$key]['rktype'] = '其他调整入库';
  7247. } else if ($value['rktype'] == 4) {
  7248. $rows_r[$key]['rktype'] = '其他调整入库';
  7249. } else if ($value['rktype'] == 5) {
  7250. $rows_r[$key]['rktype'] = '退库入库';
  7251. } else if ($value['rktype'] == 6) {
  7252. $rows_r[$key]['rktype'] = '退货可用入库';
  7253. } else if ($value['rktype'] == 7) {
  7254. $rows_r[$key]['rktype'] = '形态转换入库';
  7255. } else {
  7256. $rows_r[$key]['rktype'] = '';
  7257. }
  7258. $features = explode('-', trim($value['features'], '-'));
  7259. foreach ($features as $v) {
  7260. if (isset($typeclass[$v])) {
  7261. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7262. $pm[$typeclass[$v]['classid']] = $zh[0];
  7263. }
  7264. if (isset($typeclass[$v])) {
  7265. if (isset($jm[$typeclass[$v]['classid']])) {
  7266. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7267. }
  7268. }
  7269. }
  7270. $zh = implode(" ", $pm);
  7271. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7272. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7273. $rows_r[$key]['zh'] = $zh;
  7274. $jm = array_filter($jm);
  7275. $rows_r[$key]['features'] = implode("-", $jm);
  7276. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7277. }
  7278. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7279. foreach ($rows_c as $key => $value) {
  7280. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7281. $pm = $classid;
  7282. $jm = $classid;
  7283. $rows_c[$key]['time'] = $value['outk'];
  7284. $rows_c[$key]['outk'] = '出库';
  7285. if ($value['cktype'] == 1) {
  7286. $rows_c[$key]['cktype'] = '销售出库';
  7287. } else if ($value['cktype'] == 2) {
  7288. $rows_c[$key]['cktype'] = '销售美国出库';
  7289. } else if ($value['cktype'] == 3) {
  7290. $rows_c[$key]['cktype'] = '盘亏调整';
  7291. } else if ($value['cktype'] == 4) {
  7292. $rows_c[$key]['cktype'] = '其他调整出库';
  7293. } else if ($value['cktype'] == 5) {
  7294. $rows_c[$key]['cktype'] = '形态转换出库';
  7295. } else {
  7296. $rows_c[$key]['cktype'] = '';
  7297. }
  7298. $features = explode('-', trim($value['features'], '-'));
  7299. foreach ($features as $v) {
  7300. if (isset($typeclass[$v])) {
  7301. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7302. $pm[$typeclass[$v]['classid']] = $zh[0];
  7303. }
  7304. if (isset($typeclass[$v])) {
  7305. if (isset($jm[$typeclass[$v]['classid']])) {
  7306. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7307. }
  7308. }
  7309. }
  7310. $zh = implode(" ", $pm);
  7311. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7312. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7313. $rows_c[$key]['zh'] = $zh;
  7314. $jm = array_filter($jm);
  7315. $rows_c[$key]['features'] = implode("-", $jm);
  7316. $rows_c[$key]['number'] = 1;
  7317. }
  7318. $merged = $rows_r;
  7319. foreach ($rows_c as $key => $value) {
  7320. if (isset($merged[$key])) {
  7321. $merged[] = $value;
  7322. } else {
  7323. $merged[$key] = $value;
  7324. }
  7325. }
  7326. usort($merged, function ($a, $b) {
  7327. return $a['time'] - $b['time'];
  7328. });
  7329. foreach ($merged as $key => $value) {
  7330. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7331. }
  7332. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7333. $titlename = "<table border=1>
  7334. <tr align='center'>
  7335. <td>仓库</td>
  7336. <td>SKU</td>
  7337. <td>商品名称</td>
  7338. <td>仓库品名</td>
  7339. <td>料号</td>
  7340. <td>时间</td>
  7341. <td>操作</td>
  7342. <td>类型</td>
  7343. <td>数量</td>
  7344. <td>备注</td>
  7345. </tr>
  7346. </table>";
  7347. $filename = $title . ".xlsx";
  7348. $tail = "";
  7349. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7350. }
  7351. }
  7352. }