Whlabel.php 259 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533
  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. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else {
  190. $this->_index();
  191. }
  192. }
  193. //管理
  194. public function _index()
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if (isset($post['page'])) {
  198. $page = $this->input->post('page', true);
  199. $perpage = $this->input->post('perpage', true);
  200. $sku = $this->input->post('sku', true);
  201. $number = $this->input->post('number', true);
  202. $warehouse = $this->input->post('warehouse', true);
  203. $purchase = $this->input->post('purchase', true);
  204. $orderinfo = $this->input->post('orderinfo', true);
  205. $waybill = $this->input->post('waybill', true);
  206. $category = $this->input->post('category', true);
  207. $size = $this->input->post('size', true);
  208. $grade = $this->input->post('grade', true);
  209. $color = $this->input->post('color', true);
  210. $lowe = $this->input->post('lowe', true);
  211. $state = $this->input->post('state', true);
  212. $label = $this->input->post('label', true);
  213. $timetk = $this->input->post('timetkk', true);
  214. $timetj = $this->input->post('timetjj', true);
  215. $timetk = strtotime($timetk);
  216. $timetj = strtotime($timetj);
  217. $where = "1=1 ";
  218. if ($timetk && $timetj) {
  219. $where .= " and time > '$timetk' and time < '$timetj'";
  220. }
  221. if ($sku) {
  222. $where .= " and sku = '$sku'";
  223. }
  224. if ($number) {
  225. $where .= " and number = '$number'";
  226. }
  227. if ($warehouse) {
  228. $where .= " and warehouse = '$warehouse'";
  229. }
  230. if ($purchase) {
  231. $where .= " and purchase = '$purchase'";
  232. }
  233. if ($orderinfo) {
  234. $where .= " and orderinfo = '$orderinfo'";
  235. }
  236. if ($waybill) {
  237. $where .= " and waybill = '$waybill'";
  238. }
  239. if ($category) {
  240. $where .= " and features like '%-$category-%'";
  241. }
  242. if ($size) {
  243. $where .= " and features like '%-$size-%'";
  244. }
  245. if ($grade) {
  246. $where .= " and features like '%-$grade-%'";
  247. }
  248. if ($color) {
  249. $where .= " and features like '%-$color-%'";
  250. }
  251. if ($lowe) {
  252. $where .= " and features like '%-$lowe-%'";
  253. }
  254. if ($label) {
  255. $where .= " and label = '$label'";
  256. }
  257. if ($state != '') {
  258. $where .= " and state = '$state'";
  259. }
  260. //数据排序
  261. $order_str = "time desc";
  262. if (empty($page)) {
  263. $start = 0;
  264. $perpage = 1;
  265. } else {
  266. $start = ($page - 1) * $perpage;
  267. }
  268. //取得信息列表
  269. $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);
  270. foreach ($info_list as $key => $value) {
  271. $warehouse = $this->warehouse->read($value['warehouse']);
  272. $info_list[$key]['warehouse'] = $warehouse['title'];
  273. $purchase = $this->purchase->read($value['purchase']);
  274. $info_list[$key]['purchase'] = $purchase['title'];
  275. if ($value['enter'] != 0) {
  276. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  277. } else {
  278. $info_list[$key]['enter'] = "";
  279. }
  280. if ($value['outk'] != 0) {
  281. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  282. } else {
  283. $info_list[$key]['outk'] = "";
  284. }
  285. if ($value['printing'] != 0) {
  286. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  287. } else {
  288. $info_list[$key]['printing'] = "";
  289. }
  290. if ($value['orderinfo'] == 0) {
  291. $info_list[$key]['orderinfo'] = "";
  292. }
  293. if ($value['waybill'] == 0) {
  294. $info_list[$key]['waybill'] = "";
  295. }
  296. if ($value['state'] == 0) {
  297. $info_list[$key]['state'] = "在库";
  298. } else if ($value['state'] == 1) {
  299. $info_list[$key]['state'] = "出库";
  300. } else if ($value['state'] == 2) {
  301. $info_list[$key]['state'] = "退库";
  302. } else if ($value['state'] == 3) {
  303. $info_list[$key]['state'] = "调拨中";
  304. } else if ($value['state'] == 4) {
  305. $info_list[$key]['state'] = "再加工";
  306. } else if ($value['state'] == 5) {
  307. $info_list[$key]['state'] = "维修中";
  308. } else if ($value['state'] == 6) {
  309. $info_list[$key]['state'] = "盘亏";
  310. } else if ($value['state'] == 7) {
  311. $info_list[$key]['state'] = "更换标签";
  312. } else if ($value['state'] == 8) {
  313. $info_list[$key]['state'] = "其它";
  314. } else if ($value['state'] == 9) {
  315. $info_list[$key]['state'] = "预设";
  316. } else if ($value['state'] == 10) {
  317. $info_list[$key]['state'] = "美店零售";
  318. }
  319. if ($value['text'] == "") {
  320. $info_list[$key]['text'] = "";
  321. }
  322. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  323. }
  324. $total = $this->whlabel->find_count($where);
  325. $pagenum = ceil($total / $perpage);
  326. $over = $total - ($start + $perpage);
  327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  328. echo json_encode($rows);
  329. exit;
  330. }
  331. if (isset($post['outsku'])) {
  332. $cz = $this->input->post('cz', true);
  333. if ($cz == '1') {
  334. $sku = $this->input->post('outsku', true);
  335. if ($sku) {
  336. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  337. if (count($data) < 1) {
  338. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  339. exit;
  340. }
  341. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  342. echo json_encode(array('success' => true));
  343. exit;
  344. }
  345. } else {
  346. $sku = $this->input->post('outsku', true);
  347. if ($sku) {
  348. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  349. if (count($data) < 1) {
  350. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  351. exit;
  352. }
  353. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  354. echo json_encode(array('success' => true));
  355. exit;
  356. }
  357. }
  358. }
  359. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  360. $this->_Template('whlabel', $this->data);
  361. }
  362. //在库标签
  363. public function _existence()
  364. {
  365. $post = $this->input->post(NULL, TRUE);
  366. if (isset($post['s'])) {
  367. $id_arr = $this->input->post('s');
  368. $id_arr = explode(',', $id_arr);
  369. if (!$id_arr) {
  370. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  371. exit;
  372. }
  373. //循环删除记录
  374. foreach ($id_arr as $v) {
  375. $sid = $this->whlabel->read($v);
  376. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  377. if ($count > 0) {
  378. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  379. exit;
  380. }
  381. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  382. if (count($zt) > 0) {
  383. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  384. exit;
  385. }
  386. $this->whlabel->remove($v);
  387. }
  388. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  389. exit;
  390. }
  391. if (isset($post['page'])) {
  392. $page = $this->input->post('page', true);
  393. $perpage = $this->input->post('perpage', true);
  394. $warehouse = $this->input->post('warehouse', true);
  395. $label = $this->input->post('label', true);
  396. $where = "1=1 and state = 0";
  397. if ($warehouse) {
  398. $where .= " and warehouse = '$warehouse'";
  399. }
  400. if ($label) {
  401. $where .= " and label = '$label'";
  402. }
  403. //数据排序
  404. $order_str = "time asc";
  405. if (empty($page)) {
  406. $start = 0;
  407. $perpage = 1;
  408. } else {
  409. $start = ($page - 1) * $perpage;
  410. }
  411. //取得信息列表
  412. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  413. foreach ($info_list as $key => $value) {
  414. if ($value['enter'] != 0) {
  415. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  416. } else {
  417. $info_list[$key]['enter'] = "";
  418. }
  419. if ($value['printing'] != 0) {
  420. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  421. } else {
  422. $info_list[$key]['printing'] = "";
  423. }
  424. }
  425. $total = $this->whlabel->find_count($where);
  426. $pagenum = ceil($total / $perpage);
  427. $over = $total - ($start + $perpage);
  428. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  429. echo json_encode($rows);
  430. exit;
  431. }
  432. $this->_Template('whlabel_existence', $this->data);
  433. }
  434. //进销存浏览
  435. public function _typedy($arg_array)
  436. {
  437. $prc = array();
  438. $purchase = $this->purchase->find_all();
  439. foreach ($purchase as $k => $v) {
  440. $prc[$v['id']] = $v['title'];
  441. }
  442. $post = $this->input->post(NULL, TRUE);
  443. if (isset($post['page'])) {
  444. $page = $this->input->post('page', true);
  445. $perpage = $this->input->post('perpage', true);
  446. $category = $this->input->post('category', true);
  447. $size = $this->input->post('size', true);
  448. $grade = $this->input->post('grade', true);
  449. $color = $this->input->post('color', true);
  450. $lowe = $this->input->post('lowe', true);
  451. $sku = $this->input->post('sku');
  452. $title = $this->input->post('title');
  453. $warehouse = $this->input->post('warehouse', true);
  454. $usa = $this->input->post('usa', true);
  455. $purchase = $this->input->post('purchase', true);
  456. $lacetype = $this->input->post('lacetype', true);
  457. $haircap = $this->input->post('haircap', true);
  458. $density = $this->input->post('density', true);
  459. $details = $this->input->post('details', true);
  460. $state = $this->input->post('state', true);
  461. $lacecolor = $this->input->post('lacecolor', true);
  462. $hairnumber = $this->input->post('hairnumber', true);
  463. $cklx = $this->input->post('cklx', true);
  464. $ktime = $this->input->post('ktime', true);
  465. $jtime = $this->input->post('jtime', true);
  466. $sm = $this->input->post('sm', true);
  467. $cpbz = $this->input->post('cpbz', true);
  468. $type = $this->input->post('type', true);
  469. $ktime = strtotime($ktime);
  470. $jtime = strtotime($jtime);
  471. $where = "1=1";
  472. $gj = "";
  473. $ck = "";
  474. if ($usa) {
  475. if (!$warehouse) {
  476. $where .= " and (warehouse = '5' or warehouse = '8')";
  477. }
  478. }
  479. if ($warehouse) {
  480. $where .= " and warehouse = '$warehouse'";
  481. }
  482. if ($details) {
  483. $where .= " and details = '$details'";
  484. }
  485. if ($purchase) {
  486. $where .= " and purchase = '$purchase'";
  487. }
  488. if ($state) {
  489. $where .= " and state = '$state'";
  490. }
  491. if ($lacetype) {
  492. $where .= " and features like '%-$lacetype-%'";
  493. }
  494. if ($category) {
  495. $where .= " and features like '%-$category-%'";
  496. }
  497. if ($size) {
  498. $where .= " and features like '%-$size-%'";
  499. }
  500. if ($grade) {
  501. $where .= " and features like '%-$grade-%'";
  502. }
  503. if ($color) {
  504. $where .= " and features like '%-$color-%'";
  505. }
  506. if ($lowe) {
  507. $where .= " and features like '%-$lowe-%'";
  508. }
  509. if ($haircap) {
  510. $where .= " and features like '%-$haircap-%'";
  511. }
  512. if ($density) {
  513. $where .= " and features like '%-$density-%'";
  514. }
  515. if ($lacecolor) {
  516. $where .= " and features like '%-$lacecolor-%'";
  517. }
  518. if($sm){
  519. $where .= " and sm like '%".$sm."%'";
  520. }
  521. if($cpbz){
  522. $where .= " and cpbz like '%".$cpbz."%'";
  523. }
  524. if($type){
  525. $where .= " and type = ".$type."";
  526. }
  527. if (!empty($hairnumber)) {
  528. $where .= " and features like '%-128-%' ";
  529. if ($hairnumber < 0) {
  530. $class_list = $this->typeclass->find_all('classid = 43');
  531. foreach ($class_list as $v) {
  532. $where .= " and features not like '%-" . $v['id'] . "-%'";
  533. }
  534. } else {
  535. $where .= " and features like '%-$hairnumber-%'";
  536. }
  537. }
  538. $where_add = '';
  539. if ($cklx) {
  540. $shop = $this->shop->read($cklx);
  541. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  542. }
  543. if ($ktime && $jtime) {
  544. $gj = " and enter > '$ktime' and enter < '$jtime'";
  545. $ck = " and outk > '$ktime' and outk < '$jtime'";
  546. }
  547. //数据排序
  548. $order_str = "id desc";
  549. if (empty($page)) {
  550. $start = 0;
  551. $perpage = 1;
  552. } else {
  553. $start = ($page - 1) * $perpage;
  554. }
  555. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  556. if ($sku) {
  557. $sku = trim($sku, ' ');
  558. $sku = trim($sku, ' ');
  559. $where .= " and sku like '%$sku%'";
  560. $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);
  561. } else if ($title) {
  562. $title = trim($title, ' ');
  563. $title = trim($title, ' ');
  564. $where .= " and title like '%$title%'";
  565. $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);
  566. } else {
  567. //$where .= " and time > '$ktime' and time < '$jtime'";
  568. $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);
  569. }
  570. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  571. foreach ($info_list as $k => $v) {
  572. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  573. unset($info_list[$k]['pm']);
  574. unset($info_list[$k]['jm']);
  575. unset($info_list[$k]['bm']);
  576. }
  577. //取得信息列表
  578. $rows = array();
  579. $list = array();
  580. foreach ($info_list as $key => $value) {
  581. $warehouse = $this->warehouse->read($value['warehouse']);
  582. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  583. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  584. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  585. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  586. $info_list[$key]['label'] = $value['sm'];
  587. $number = $value['number'];
  588. $ftime = time() - 15 * 24 * 3600;
  589. $info_list[$key]['warehouse'] = $warehouse['title'];
  590. $info_list[$key]['features'] = count($c);
  591. $z = count($z); //查看订单号
  592. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  593. $ztdata = '';
  594. if (count($zt) > 0) {
  595. foreach ($zt as $vv) {
  596. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  597. }
  598. }
  599. $info_list[$key]['number'] = $ztdata;
  600. $info_list[$key]['sm'] = $z;
  601. $details = array();
  602. $cpid = array();
  603. foreach ($c as $k => $v) {
  604. $details[$v['details']] = $v['details'];
  605. if ($v['cpid'] != 0) {
  606. $cpid[$v['cpid']] = $v['cpid'];
  607. }
  608. }
  609. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  610. if ($value['shop'] != '') {
  611. $shop = explode(',', trim($value['shop'], ','));
  612. $shop = $this->shop->read($shop[0]);
  613. $info_list[$key]['shop'] = $shop['shopname'];
  614. }
  615. }
  616. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  617. $pagenum = ceil($total / $perpage);
  618. $over = $total - ($start + $perpage);
  619. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  620. echo json_encode($rows);
  621. exit;
  622. }
  623. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  624. $this->_Template('whlabel_typedy', $this->data);
  625. }
  626. //进销存浏览
  627. public function _typedy_ck($arg_array)
  628. {
  629. $prc = array();
  630. $purchase = $this->purchase->find_all();
  631. foreach ($purchase as $k => $v) {
  632. $prc[$v['id']] = $v['title'];
  633. }
  634. $post = $this->input->post(NULL, TRUE);
  635. if (isset($post['page'])) {
  636. $page = $this->input->post('page', true);
  637. $perpage = $this->input->post('perpage', true);
  638. $category = $this->input->post('category', true);
  639. $size = $this->input->post('size', true);
  640. $grade = $this->input->post('grade', true);
  641. $color = $this->input->post('color', true);
  642. $lowe = $this->input->post('lowe', true);
  643. $sku = $this->input->post('sku');
  644. $title = $this->input->post('title');
  645. $warehouse = $this->input->post('warehouse', true);
  646. $usa = $this->input->post('usa', true);
  647. $purchase = $this->input->post('purchase', true);
  648. $lacetype = $this->input->post('lacetype', true);
  649. $haircap = $this->input->post('haircap', true);
  650. $density = $this->input->post('density', true);
  651. $details = $this->input->post('details', true);
  652. $state = $this->input->post('state', true);
  653. $lacecolor = $this->input->post('lacecolor', true);
  654. $cklx = $this->input->post('cklx', true);
  655. $ktime = $this->input->post('ktime', true);
  656. $jtime = $this->input->post('jtime', true);
  657. $ktime = strtotime($ktime);
  658. $jtime = strtotime($jtime);
  659. $where = "1=1";
  660. $gj = "";
  661. $ck = "";
  662. if ($lacetype) {
  663. $where .= " and features like '%-$lacetype-%'";
  664. }
  665. if ($category) {
  666. $where .= " and features like '%-$category-%'";
  667. }
  668. if ($size) {
  669. $where .= " and features like '%-$size-%'";
  670. }
  671. if ($grade) {
  672. $where .= " and features like '%-$grade-%'";
  673. }
  674. if ($color) {
  675. $where .= " and features like '%-$color-%'";
  676. }
  677. if ($lowe) {
  678. $where .= " and features like '%-$lowe-%'";
  679. }
  680. if ($haircap) {
  681. $where .= " and features like '%-$haircap-%'";
  682. }
  683. if ($density) {
  684. $where .= " and features like '%-$density-%'";
  685. }
  686. if ($lacecolor) {
  687. $where .= " and features like '%-$lacecolor-%'";
  688. }
  689. if ($usa) {
  690. if (!$warehouse) {
  691. $where .= " and (warehouse = '5' or warehouse = '8')";
  692. }
  693. }
  694. if ($warehouse) {
  695. $where .= " and warehouse = '$warehouse'";
  696. }
  697. if ($details) {
  698. $where .= " and details = '$details'";
  699. }
  700. if ($purchase) {
  701. $where .= " and purchase = '$purchase'";
  702. }
  703. if ($state) {
  704. $where .= " and state = '$state'";
  705. }
  706. $where_add = '';
  707. if ($cklx) {
  708. $shop = $this->shop->read($cklx);
  709. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  710. }
  711. if ($ktime && $jtime) {
  712. $gj = " and enter > '$ktime' and enter < '$jtime'";
  713. $ck = " and outk > '$ktime' and outk < '$jtime'";
  714. }
  715. //数据排序
  716. $order_str = "id desc";
  717. if (empty($page)) {
  718. $start = 0;
  719. $perpage = 1;
  720. } else {
  721. $start = ($page - 1) * $perpage;
  722. }
  723. if ($sku) {
  724. $sku = trim($sku, ' ');
  725. $sku = trim($sku, ' ');
  726. $where .= " and sku like '%$sku%'";
  727. $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);
  728. } else if ($title) {
  729. $title = trim($title, ' ');
  730. $title = trim($title, ' ');
  731. $where .= " and title like '%$title%'";
  732. $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);
  733. } else {
  734. //$where .= " and time > '$ktime' and time < '$jtime'";
  735. $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);
  736. }
  737. //取得信息列表
  738. $rows = array();
  739. $list = array();
  740. foreach ($info_list as $key => $value) {
  741. $warehouse = $this->warehouse->read($value['warehouse']);
  742. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  743. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  744. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  745. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  746. $ftime = time() - 15 * 24 * 3600;
  747. $info_list[$key]['warehouse'] = $warehouse['title'];
  748. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  749. //$z = count($z);//查看订单号
  750. //$info_list[$key]['zd'] = $z;
  751. $details = array();
  752. $cpid = array();
  753. foreach ($c as $k => $v) {
  754. $details[$v['details']] = $v['details'];
  755. if ($v['cpid'] != 0) {
  756. $cpid[$v['cpid']] = $v['cpid'];
  757. }
  758. }
  759. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  760. if ($value['shop'] != '') {
  761. $shop = explode(',', trim($value['shop'], ','));
  762. $shop = $this->shop->read($shop[0]);
  763. $info_list[$key]['shop'] = $shop['shopname'];
  764. }
  765. }
  766. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  767. $pagenum = ceil($total / $perpage);
  768. $over = $total - ($start + $perpage);
  769. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  770. echo json_encode($rows);
  771. exit;
  772. }
  773. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  774. $this->_Template('whlabel_typedy_ck', $this->data);
  775. }
  776. public function _typeck($arg_array)
  777. {
  778. $prc = array();
  779. $purchase = $this->purchase->find_all();
  780. foreach ($purchase as $k => $v) {
  781. $prc[$v['id']] = $v['title'];
  782. }
  783. $post = $this->input->post(NULL, TRUE);
  784. if (isset($post['page'])) {
  785. $page = $this->input->post('page', true);
  786. $perpage = $this->input->post('perpage', true);
  787. $category = $this->input->post('category', true);
  788. $size = $this->input->post('size', true);
  789. $grade = $this->input->post('grade', true);
  790. $color = $this->input->post('color', true);
  791. $lacecolor = $this->input->post('lacecolor', true);
  792. $lowe = $this->input->post('lowe', true);
  793. $sku = $this->input->post('sku');
  794. $title = $this->input->post('title');
  795. $warehouse = 13;
  796. $usa = $this->input->post('usa', true);
  797. $purchase = $this->input->post('purchase', true);
  798. $lacetype = $this->input->post('lacetype', true);
  799. $haircap = $this->input->post('haircap', true);
  800. $density = $this->input->post('density', true);
  801. $details = $this->input->post('details', true);
  802. $state = $this->input->post('state', true);
  803. $ktime = $this->input->post('ktime', true);
  804. $jtime = $this->input->post('jtime', true);
  805. $ktime = strtotime($ktime);
  806. $jtime = strtotime($jtime);
  807. $where = "1=1";
  808. $gj = "";
  809. $ck = "";
  810. if ($lacetype) {
  811. $where .= " and features like '%-$lacetype-%'";
  812. }
  813. if ($category) {
  814. $where .= " and features like '%-$category-%'";
  815. }
  816. if ($size) {
  817. $where .= " and features like '%-$size-%'";
  818. }
  819. if ($grade) {
  820. $where .= " and features like '%-$grade-%'";
  821. }
  822. if ($color) {
  823. $where .= " and features like '%-$color-%'";
  824. }
  825. if ($lacecolor) {
  826. $where .= " and features like '%-$lacecolor-%'";
  827. }
  828. if ($lowe) {
  829. $where .= " and features like '%-$lowe-%'";
  830. }
  831. if ($haircap) {
  832. $where .= " and features like '%-$haircap-%'";
  833. }
  834. if ($density) {
  835. $where .= " and features like '%-$density-%'";
  836. }
  837. if ($warehouse) {
  838. $where .= " and warehouse = '$warehouse'";
  839. }
  840. if ($details) {
  841. $where .= " and details = '$details'";
  842. }
  843. if ($purchase) {
  844. $where .= " and purchase = '$purchase'";
  845. }
  846. if ($state) {
  847. $where .= " and state = '$state'";
  848. }
  849. if ($ktime && $jtime) {
  850. $gj = " and enter > '$ktime' and enter < '$jtime'";
  851. $ck = " and outk > '$ktime' and outk < '$jtime'";
  852. }
  853. //数据排序
  854. $order_str = "id desc";
  855. if (empty($page)) {
  856. $start = 0;
  857. $perpage = 1;
  858. } else {
  859. $start = ($page - 1) * $perpage;
  860. }
  861. if ($sku) {
  862. $sku = trim($sku, ' ');
  863. $sku = trim($sku, ' ');
  864. $where .= " and sku like '%$sku%'";
  865. } else if ($title) {
  866. $title = trim($title, ' ');
  867. $title = trim($title, ' ');
  868. $where .= " and title like '%$title%'";
  869. }
  870. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  871. //取得信息列表
  872. $t = array();
  873. $typeclass = $this->typeclass->find_all();
  874. foreach ($typeclass as $v) {
  875. $t[$v['id']] = $v;
  876. }
  877. $rows = array();
  878. $list = array();
  879. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  880. foreach ($info_list as $key => $value) {
  881. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  882. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  883. $warehouse = $this->warehouse->read($value['warehouse']);
  884. $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');
  885. $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'] . '"');
  886. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  887. $number = $value['number'];
  888. $ftime = time() - 15 * 24 * 3600;
  889. $z = count($z); //查看订单号
  890. $info_list[$key]['warehouse'] = $warehouse['title'];
  891. $info_list[$key]['features'] = count($c);
  892. $info_list[$key]['number'] = $z;
  893. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  894. $details = array();
  895. $cpid = array();
  896. foreach ($c as $k => $v) {
  897. $details[$v['details']] = $v['details'];
  898. if ($v['cpid'] != 0) {
  899. $cpid[$v['cpid']] = $v['cpid'];
  900. }
  901. }
  902. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  903. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  904. unset($info_list[$key]['pm']);
  905. unset($info_list[$key]['jm']);
  906. unset($info_list[$key]['bm']);
  907. }
  908. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  909. $pagenum = ceil($total / $perpage);
  910. $over = $total - ($start + $perpage);
  911. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  912. echo json_encode($rows);
  913. exit;
  914. }
  915. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  916. $this->_Template('whlabel_typeck', $this->data);
  917. }
  918. //进销存导出
  919. public function _whlabeckdc()
  920. {
  921. $prc = array();
  922. $purchase = $this->purchase->find_all();
  923. foreach ($purchase as $k => $v) {
  924. $prc[$v['id']] = $v['title'];
  925. }
  926. if (isset($_GET['excel'])) {
  927. $where = "sku != 'Preset'";
  928. //数据排序
  929. $order_str = "id desc";
  930. if (empty($page)) {
  931. $start = 0;
  932. $perpage = 1;
  933. } else {
  934. $start = ($page - 1) * $perpage;
  935. }
  936. $category = $this->input->get('category', true);
  937. $color = $this->input->get('color', true);
  938. $lowe = $this->input->get('lowe', true);
  939. $lacetype = $this->input->get('lacetype', true);
  940. $size = $this->input->get('size', true);
  941. $density = $this->input->get('density', true);
  942. $haircap = $this->input->get('haircap', true);
  943. $sku = $this->input->get('sku', true);
  944. $details = $this->input->get('details', true);
  945. $warehouse = 13;
  946. $excelid = $this->input->get('sid', true);
  947. if ($category) {
  948. $where .= " and features like '%-$category-%'";
  949. }
  950. if ($color) {
  951. $where .= " and features like '%-$color-%'";
  952. }
  953. if ($lowe) {
  954. $where .= " and features like '%-$lowe-%'";
  955. }
  956. if ($lacetype) {
  957. $where .= " and features like '%-$lacetype-%'";
  958. }
  959. if ($size) {
  960. $where .= " and features like '%-$size-%'";
  961. }
  962. if ($density) {
  963. $where .= " and features like '%-$density-%'";
  964. }
  965. if ($haircap) {
  966. $where .= " and features like '%-$haircap-%'";
  967. }
  968. if ($warehouse) {
  969. $where .= " and warehouse = '$warehouse'";
  970. }
  971. if ($sku) {
  972. $where .= " and sku like '%$sku%'";
  973. }
  974. if ($details) {
  975. $where .= " and details = '$details'";
  976. }
  977. $xzid = '';
  978. if ($excelid) {
  979. $excelid = explode(',', trim($excelid, ','));
  980. foreach ($excelid as $key => $value) {
  981. $xzid .= " id = " . $value . " or";
  982. }
  983. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  984. }
  985. //取得信息列表
  986. /**
  987. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  988. $rows = array();$list = array();
  989. foreach ($info_list as $key=>$value)
  990. {
  991. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  992. }
  993. **/
  994. $wh = array();
  995. $w = $this->warehouse->find_all('1=1', 'id,title');
  996. foreach ($w as $v) {
  997. $wh[$v['id']] = $v['title'];
  998. }
  999. $tc = array();
  1000. $tcdata = array();
  1001. $list = array();
  1002. $classid = $this->classid->sku();
  1003. $tcall = $this->typeclass->find_all();
  1004. $typeclass = array();
  1005. foreach ($tcall as $v)
  1006. {
  1007. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1008. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1009. }
  1010. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1011. foreach ($rows as $key => $value) {
  1012. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1013. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1014. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1015. $rows[$key]['cpbz'] = $u9_info['bm'];
  1016. $rows[$key]['cs'] = $u9_info['jm'];
  1017. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1018. $details = array();
  1019. $cpid = array();
  1020. $cpbz = array();
  1021. $c = 0;
  1022. $g = 0;
  1023. $x = 0;
  1024. $t = 0;
  1025. $s = 0;
  1026. $q = 0;
  1027. foreach ($sd as $k => $v) {
  1028. if ($v['state'] == 0) {
  1029. $c++;
  1030. }
  1031. if ($v['state'] != 9) {
  1032. $g++;
  1033. }
  1034. if ($v['state'] == 1) {
  1035. $x++;
  1036. }
  1037. if ($v['state'] == 2) {
  1038. $t++;
  1039. }
  1040. if ($v['state'] == 8) {
  1041. $s++;
  1042. }
  1043. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1044. $q++;
  1045. }
  1046. $details[$v['details']] = $v['details'];
  1047. if ($v['cpid'] != 0) {
  1048. $cpid[$v['cpid']] = $v['cpid'];
  1049. }
  1050. if ($v['cpbz'] != '') {
  1051. $cpbz[$v['cpbz']] = $v['cpbz'];
  1052. }
  1053. }
  1054. $rows[$key]['details'] = implode("、", $details);
  1055. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1056. $number = $value['number'];
  1057. $ftime = time() - 15 * 24 * 3600;
  1058. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1059. $rows[$key]['number'] = $g;
  1060. $rows[$key]['features'] = $c;
  1061. $rows[$key]['x'] = $x;
  1062. $rows[$key]['t'] = $t;
  1063. $rows[$key]['s'] = $s;
  1064. $rows[$key]['q'] = $q;
  1065. $rows[$key]['wzsl'] = count($details);
  1066. }
  1067. $title = "进销存统计表" . date('Y-m-d', time());
  1068. $titlename = "<table border=1>
  1069. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1070. <tr align='center'>
  1071. <td>仓库</td>
  1072. <td>供应商</td>
  1073. <td>位置</td>
  1074. <td>库存编码</td>
  1075. <td>SKU</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. <td>位置数量</td>
  1087. </tr>
  1088. </table>";
  1089. $filename = $title . ".xls";
  1090. $tail = "";
  1091. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1092. }
  1093. }
  1094. public function _type()
  1095. {
  1096. $vip = 0;
  1097. if (isset($_SESSION['api'])) {
  1098. $user = $this->user->get_api($_SESSION['api']);
  1099. $fgshop = "";
  1100. $sid = "";
  1101. $usersp = explode('|', trim($user['shop'], '|'));
  1102. foreach ($usersp as $value) {
  1103. $fgshop .= " shop = " . $value . " or";
  1104. $sid .= " id = " . $value . " or";
  1105. }
  1106. if ($user['vip'] == 1) {
  1107. $vip = 1;
  1108. }
  1109. } else {
  1110. header('Location: /');
  1111. exit;
  1112. }
  1113. $prc = array();
  1114. $purchase = $this->purchase->find_all();
  1115. foreach ($purchase as $k => $v) {
  1116. $prc[$v['id']] = $v['title'];
  1117. }
  1118. $company = array();
  1119. $ct = $this->company->find_all();
  1120. foreach ($ct as $k => $v) {
  1121. $company[$v['id']] = $v['title'];
  1122. }
  1123. $sp = array();
  1124. $s = $this->shop->find_all('1=1', 'id,shopname');
  1125. foreach ($s as $v) {
  1126. $sp[$v['id']] = $v['shopname'];
  1127. }
  1128. $wh = array();
  1129. $w = $this->warehouse->find_all('1=1', 'id,title');
  1130. foreach ($w as $v) {
  1131. $wh[$v['id']] = $v['title'];
  1132. }
  1133. $post = $this->input->post(NULL, TRUE);
  1134. if (isset($post['page'])) {
  1135. $page = $this->input->post('page', true);
  1136. $perpage = $this->input->post('perpage', true);
  1137. $category = $this->input->post('category', true);
  1138. $size = $this->input->post('size', true);
  1139. $grade = $this->input->post('grade', true);
  1140. $color = $this->input->post('color', true);
  1141. $lowe = $this->input->post('lowe', true);
  1142. $sku = $this->input->post('sku');
  1143. $title = $this->input->post('title');
  1144. $warehouse = $this->input->post('warehouse', true);
  1145. $usa = $this->input->post('usa', true);
  1146. $purchase = $this->input->post('purchase', true);
  1147. $lacetype = $this->input->post('lacetype', true);
  1148. $haircap = $this->input->post('haircap', true);
  1149. $density = $this->input->post('density', true);
  1150. $details = $this->input->post('details', true);
  1151. $state = $this->input->post('state', true);
  1152. $shop = $this->input->post('shop', true);
  1153. $lacecolor = $this->input->post('lacecolor', true);
  1154. $hairnumber = $this->input->post('hairnumber', true);
  1155. $type = $this->input->post('type', true);
  1156. $ktime = $this->input->post('ktime', true);
  1157. $jtime = $this->input->post('jtime', true);
  1158. $ktime = strtotime($ktime);
  1159. $jtime = strtotime($jtime);
  1160. $cpbz = $this->input->post('cpbz', true);
  1161. $sm = $this->input->post('sm', true);
  1162. $where = "1=1";
  1163. $gj = "";
  1164. $ck = "";
  1165. if ($usa) {
  1166. if (!$warehouse) {
  1167. $where .= " and (warehouse = '5' or warehouse = '8')";
  1168. }
  1169. }
  1170. if ($warehouse) {
  1171. $where .= " and warehouse = '$warehouse'";
  1172. }
  1173. if ($details) {
  1174. $where .= " and details = '$details'";
  1175. }
  1176. if ($purchase) {
  1177. $where .= " and purchase = '$purchase'";
  1178. }
  1179. if ($state) {
  1180. $where .= " and state = '$state'";
  1181. }
  1182. if ($shop) {
  1183. $where .= " and shop like '%$shop%'";
  1184. }
  1185. if ($type) {
  1186. $where .= " and type = '$type'";
  1187. }
  1188. if ($ktime && $jtime) {
  1189. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1190. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1191. }
  1192. if ($cpbz) {
  1193. $where .= " and cpbz like '%$cpbz%' ";
  1194. }
  1195. if ($sm) {
  1196. $where .= " and sm like '%$sm%' ";
  1197. }
  1198. if ($lacecolor) {
  1199. $where .= " and features like '%-$lacecolor-%'";
  1200. }
  1201. if ($lacetype) {
  1202. $where .= " and features like '%-$lacetype-%'";
  1203. }
  1204. if ($category) {
  1205. $where .= " and features like '%-$category-%'";
  1206. }
  1207. if ($size) {
  1208. $where .= " and features like '%-$size-%'";
  1209. }
  1210. if ($grade) {
  1211. $where .= " and features like '%-$grade-%'";
  1212. }
  1213. if ($color) {
  1214. $where .= " and features like '%-$color-%'";
  1215. }
  1216. if ($lowe) {
  1217. $where .= " and features like '%-$lowe-%'";
  1218. }
  1219. if ($haircap) {
  1220. $where .= " and features like '%-$haircap-%'";
  1221. }
  1222. if ($density) {
  1223. $where .= " and features like '%-$density-%'";
  1224. }
  1225. if (!empty($hairnumber)) {
  1226. $where .= " and features like '%-128-%' ";
  1227. if ($hairnumber < 0) {
  1228. $class_list = $this->typeclass->find_all('classid = 43');
  1229. foreach ($class_list as $v) {
  1230. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1231. }
  1232. } else {
  1233. $where .= " and features like '%-$hairnumber-%'";
  1234. }
  1235. }
  1236. //数据排序
  1237. $order_str = "id desc";
  1238. if (empty($page)) {
  1239. $start = 0;
  1240. $perpage = 1;
  1241. } else {
  1242. $start = ($page - 1) * $perpage;
  1243. }
  1244. $fjnr = '';
  1245. if ($sku) {
  1246. $sku = trim($sku, ' ');
  1247. $sku = trim($sku, ' ');
  1248. $fjnr .= " and sku like '%$sku%'";
  1249. }
  1250. if ($title) {
  1251. $title = trim($title, ' ');
  1252. $title = trim($title, ' ');
  1253. $fjnr .= " and title like '%$title%'";
  1254. }
  1255. $wt = array();
  1256. $whlabel_type = $this->whlabel_type->find_all();
  1257. foreach ($whlabel_type as $v) {
  1258. $wt[$v['id']] = $v['title'];
  1259. }
  1260. $this->logic_ding->sendToDing("监听美仓BCA".$where);
  1261. //$where .= " and time > '$ktime' and time < '$jtime'";
  1262. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1263. //取得信息列表
  1264. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1265. $rows = array();
  1266. $list = array();
  1267. foreach ($info_list as $key => $value) {
  1268. if (isset($wt[$value['type']])) {
  1269. $info_list[$key]['type'] = $wt[$value['type']];
  1270. } else {
  1271. $info_list[$key]['type'] = '未设置';
  1272. }
  1273. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1274. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1275. $ztdata = '';
  1276. if (count($zt) > 0) {
  1277. foreach ($zt as $vv) {
  1278. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1279. }
  1280. }
  1281. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1282. $cdata = array_filter($qbdata, function ($item) {
  1283. return $item['state'] < 1;
  1284. });
  1285. $c = array_sum(array_column($cdata, 'jnum'));
  1286. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1287. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1288. });
  1289. $g = array_sum(array_column($gdata, 'jnum'));
  1290. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1291. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1292. });
  1293. $x = array_sum(array_column($xdata, 'jnum'));
  1294. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1295. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1296. });
  1297. $t = array_sum(array_column($tdata, 'jnum'));
  1298. $zdata = array_filter($qbdata, function ($item) {
  1299. return $item['zd'] != "" && $item['state'] < 1;
  1300. });
  1301. $z = array_sum(array_column($zdata, 'jnum'));
  1302. $zdata = array_filter($qbdata, function ($item) {
  1303. return $item['zd'] != "" && $item['state'] < 1;
  1304. });
  1305. $z = array_sum(array_column($zdata, 'jnum'));
  1306. //$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');
  1307. //$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'].'"');
  1308. //$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'].'"');
  1309. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1310. //$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'].'"');
  1311. $details = array();
  1312. $cpid = array();
  1313. $od = array();
  1314. $odid = '';
  1315. $companytitle = '';
  1316. $shop_list = [];
  1317. foreach ($qbdata as $v) {
  1318. if ($v['zd'] != "" && $v['state'] < 1) {
  1319. if (!isset($od[$v['zd']])) {
  1320. $od[$v['zd']] = 1; //所有数据sku
  1321. } else {
  1322. $od[$v['zd']] = $od[$v['zd']] + 1;
  1323. }
  1324. }
  1325. if ($v['state'] < 1) {
  1326. $details[$v['details']] = $v['details'];
  1327. if ($v['cpid'] != 0) {
  1328. $cpid[$v['cpid']] = $v['cpid'];
  1329. }
  1330. }
  1331. if($v['state'] == 0){
  1332. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1333. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1334. }
  1335. if ($v['shop'] != '') {
  1336. $shop = explode(',', trim($v['shop'], ','));
  1337. foreach ($shop as $vv) {
  1338. if (!in_array($vv, $shop_list)) {
  1339. $shop_list[] = $vv;
  1340. }
  1341. }
  1342. }
  1343. }
  1344. }
  1345. foreach ($od as $k => $vv) {
  1346. $odid .= $k . '数量' . $vv;
  1347. }
  1348. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1349. $info_list[$key]['label'] = $value['sm'];
  1350. $number = $value['number'];
  1351. $ftime = time() - 15 * 24 * 3600;
  1352. $z = $z . '(' . $odid . ')'; //查看订单号
  1353. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1354. $info_list[$key]['features'] = $c;
  1355. $info_list[$key]['number'] = $ztdata;
  1356. $info_list[$key]['sm'] = $g;
  1357. $info_list[$key]['x'] = $x;
  1358. $info_list[$key]['t'] = $t;
  1359. $info_list[$key]['z'] = $z;
  1360. /**
  1361. foreach ($cdata as $k=>$v)
  1362. {
  1363. $details[$v['details']] = $v['details'];
  1364. if($v['cpid'] != 0)
  1365. {
  1366. $cpid[$v['cpid']] = $v['cpid'];
  1367. }
  1368. }
  1369. **/
  1370. $info_list[$key]['shop'] = '';
  1371. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1372. // if ($value['shop'] != '') {
  1373. // $shop = explode(',', trim($value['shop'], ','));
  1374. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1375. // }
  1376. $shop_list = array_unique($shop_list);
  1377. $shop_str = '';
  1378. foreach ($shop_list as $v) {
  1379. if(isset($sp[$v])){
  1380. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1381. }
  1382. }
  1383. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1384. /**
  1385. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1386. if(isset($companytitle[0]))
  1387. {
  1388. foreach ($companytitle as $k=>$v)
  1389. {
  1390. if($v['companytitle'] != '')
  1391. {
  1392. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1393. }
  1394. }
  1395. }
  1396. **/
  1397. }
  1398. $final_all_list = [];
  1399. foreach ($info_list as $k => $v) {
  1400. $final_all_list[] = [
  1401. 'id' => $v['id'],
  1402. "warehouse" => $v["warehouse"],
  1403. "purchase" => $v["purchase"],
  1404. "sku" => $v["sku"],
  1405. "title" => $v["title"] . "<br/>" . $v["pm"],
  1406. "details" => $v["details"],
  1407. "shop" => $v["shop"],
  1408. "cpbz" => $v["cpbz"],
  1409. 'label' => $v['label'],
  1410. "type" => $v["type"],
  1411. "features" => $v["features"],
  1412. "number" => $v["number"],
  1413. "sm" => $v["sm"],
  1414. "x" => $v["x"],
  1415. "t" => $v["t"],
  1416. "z" => $v["z"]
  1417. ];
  1418. }
  1419. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1420. $pagenum = ceil($total / $perpage);
  1421. $over = $total - ($start + $perpage);
  1422. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1423. echo json_encode($rows);
  1424. exit;
  1425. }
  1426. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1427. $this->data['shop'] = $wlshop;
  1428. $this->data['vip'] = $vip;
  1429. $this->_Template('whlabel_type', $this->data);
  1430. }
  1431. //美仓进销存浏览
  1432. public function _usatype()
  1433. {
  1434. if (isset($_SESSION['api'])) {
  1435. $user = $this->user->get_api($_SESSION['api']);
  1436. $usp = $user;
  1437. $fgshop = "";
  1438. $sid = "";
  1439. $wid = "";
  1440. $wtype = "";
  1441. $userwh = explode('|', trim($user['warehouse'], '|'));
  1442. foreach ($userwh as $value) {
  1443. $wid .= " id = " . $value . " or";
  1444. $wtype .= " type = " . $value . " or";
  1445. }
  1446. }
  1447. $prc = array();
  1448. $purchase = $this->purchase->find_all();
  1449. foreach ($purchase as $k => $v) {
  1450. $prc[$v['id']] = $v['title'];
  1451. }
  1452. $post = $this->input->post(NULL, TRUE);
  1453. if (isset($post['page'])) {
  1454. $page = $this->input->post('page', true);
  1455. $perpage = $this->input->post('perpage', true);
  1456. $category = $this->input->post('category', true);
  1457. $size = $this->input->post('size', true);
  1458. $grade = $this->input->post('grade', true);
  1459. $color = $this->input->post('color', true);
  1460. $lowe = $this->input->post('lowe', true);
  1461. $sku = $this->input->post('sku');
  1462. $title = $this->input->post('title');
  1463. $warehouse = $this->input->post('warehouse', true);
  1464. $usa = $this->input->post('usa', true);
  1465. $purchase = $this->input->post('purchase', true);
  1466. $lacetype = $this->input->post('lacetype', true);
  1467. $haircap = $this->input->post('haircap', true);
  1468. $density = $this->input->post('density', true);
  1469. $details = $this->input->post('details', true);
  1470. $state = $this->input->post('state', true);
  1471. $lacecolor = $this->input->post('lacecolor', true);
  1472. $cklx = $this->input->post('cklx', true);
  1473. $ktime = $this->input->post('ktime', true);
  1474. $jtime = $this->input->post('jtime', true);
  1475. $ktime = strtotime($ktime);
  1476. $jtime = strtotime($jtime);
  1477. $where = "1=1";
  1478. $gj = "";
  1479. $ck = "";
  1480. if ($lacetype) {
  1481. $where .= " and features like '%-$lacetype-%'";
  1482. }
  1483. if ($category) {
  1484. $where .= " and features like '%-$category-%'";
  1485. }
  1486. if ($size) {
  1487. $where .= " and features like '%-$size-%'";
  1488. }
  1489. if ($grade) {
  1490. $where .= " and features like '%-$grade-%'";
  1491. }
  1492. if ($color) {
  1493. $where .= " and features like '%-$color-%'";
  1494. }
  1495. if ($lowe) {
  1496. $where .= " and features like '%-$lowe-%'";
  1497. }
  1498. if ($haircap) {
  1499. $where .= " and features like '%-$haircap-%'";
  1500. }
  1501. if ($density) {
  1502. $where .= " and features like '%-$density-%'";
  1503. }
  1504. if ($lacecolor) {
  1505. $where .= " and features like '%-$lacecolor-%'";
  1506. }
  1507. if ($usa) {
  1508. if (!$warehouse) {
  1509. $where .= " and (warehouse = '5' or warehouse = '8')";
  1510. }
  1511. }
  1512. if ($warehouse) {
  1513. $where .= " and warehouse = '$warehouse'";
  1514. }
  1515. if ($details) {
  1516. $where .= " and details = '$details'";
  1517. }
  1518. if ($purchase) {
  1519. $where .= " and purchase = '$purchase'";
  1520. }
  1521. if ($state) {
  1522. $where .= " and state = '$state'";
  1523. }
  1524. $where_add = '';
  1525. if ($cklx) {
  1526. $shop = $this->shop->read($cklx);
  1527. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1528. }
  1529. if ($ktime && $jtime) {
  1530. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1531. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1532. }
  1533. //数据排序
  1534. $order_str = "id desc";
  1535. if (empty($page)) {
  1536. $start = 0;
  1537. $perpage = 1;
  1538. } else {
  1539. $start = ($page - 1) * $perpage;
  1540. }
  1541. if ($sku) {
  1542. $sku = trim($sku, ' ');
  1543. $sku = trim($sku, ' ');
  1544. $where .= " and sku like '%$sku%'";
  1545. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1546. } else if ($title) {
  1547. $title = trim($title, ' ');
  1548. $title = trim($title, ' ');
  1549. $where .= " and title like '%$title%'";
  1550. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1551. } else {
  1552. //$where .= " and time > '$ktime' and time < '$jtime'";
  1553. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1554. }
  1555. //取得信息列表
  1556. $rows = array();
  1557. $list = array();
  1558. foreach ($info_list as $key => $value) {
  1559. $warehouse = $this->warehouse->read($value['warehouse']);
  1560. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1561. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1562. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1563. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1564. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1565. $od = array();
  1566. $odid = '';
  1567. foreach ($z as $v) {
  1568. if (!isset($od[$v['zd']])) {
  1569. $od[$v['zd']] = 1; //所有数据sku
  1570. } else {
  1571. $od[$v['zd']] = $od[$v['zd']] + 1;
  1572. }
  1573. }
  1574. foreach ($od as $k => $vv) {
  1575. $odid .= $k . '数量' . $vv . ' ';
  1576. }
  1577. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1578. $info_list[$key]['features'] = $c;
  1579. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1580. $ztdata = '';
  1581. if (count($zt) > 0) {
  1582. foreach ($zt as $vv) {
  1583. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1584. }
  1585. }
  1586. $info_list[$key]['warehouse'] = $ztdata;
  1587. $info_list[$key]['g'] = $g;
  1588. $info_list[$key]['x'] = $x;
  1589. $info_list[$key]['t'] = $t;
  1590. $info_list[$key]['z'] = $z;
  1591. }
  1592. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1593. $pagenum = ceil($total / $perpage);
  1594. $over = $total - ($start + $perpage);
  1595. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1596. echo json_encode($rows);
  1597. exit;
  1598. }
  1599. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1600. $this->data['warehouse'] = $warehouse;
  1601. $this->_Template('whlabel_typeusa', $this->data);
  1602. }
  1603. //美仓进销存浏览
  1604. public function _usatypeapp()
  1605. {
  1606. $post = $this->input->post(NULL, TRUE);
  1607. if (isset($post['page'])) {
  1608. $page = $this->input->post('page', true);
  1609. $perpage = $this->input->post('perpage', true);
  1610. $sku = $this->input->post('sku', true);
  1611. $warehouse = 5;
  1612. $title = $this->input->post('title', true);
  1613. $state = $this->input->post('state', true);
  1614. $ktime = $this->input->post('ktime', true);
  1615. $jtime = $this->input->post('jtime', true);
  1616. $ktime = strtotime($ktime);
  1617. $jtime = strtotime($jtime);
  1618. $where = "1=1";
  1619. $gj = "";
  1620. $ck = "";
  1621. if ($title) {
  1622. $st = explode(' ', trim($title, ' '));
  1623. foreach ($st as $v) {
  1624. $where .= " and title like '%$v%'";
  1625. }
  1626. }
  1627. if ($warehouse) {
  1628. $where .= " and warehouse = '$warehouse'";
  1629. }
  1630. if ($state) {
  1631. $where .= " and state = '$state'";
  1632. }
  1633. if ($sku) {
  1634. $where .= " and sku like '%$sku%'";
  1635. }
  1636. if ($ktime && $jtime) {
  1637. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1638. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1639. }
  1640. //数据排序
  1641. $order_str = "id desc";
  1642. if (empty($page)) {
  1643. $start = 0;
  1644. $perpage = 1;
  1645. } else {
  1646. $start = ($page - 1) * $perpage;
  1647. }
  1648. //取得信息列表
  1649. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1650. $rows = array();
  1651. $list = array();
  1652. foreach ($info_list as $key => $value) {
  1653. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1654. }
  1655. $rowsdq = array_slice($rows, $start, $perpage);
  1656. foreach ($rowsdq as $value) {
  1657. $warehouse = $this->warehouse->read($value['warehouse']);
  1658. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1659. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1660. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1661. $od = array();
  1662. $odid = '';
  1663. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1664. }
  1665. $total = count($rows);
  1666. $pagenum = ceil($total / $perpage);
  1667. $over = $total - ($start + $perpage);
  1668. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1669. echo json_encode($rows);
  1670. exit;
  1671. }
  1672. $this->_Template('phone/p_usatypeapp', $this->data);
  1673. }
  1674. //入库操作
  1675. public function _enteradd()
  1676. {
  1677. $dt = 0;
  1678. if (isset($_SESSION['api'])) {
  1679. $user = $this->user->get_api($_SESSION['api']);
  1680. $usp = $user;
  1681. $fgshop = "";
  1682. $sid = "";
  1683. $user = explode('|', trim($user['shop'], '|'));
  1684. foreach ($user as $value) {
  1685. $fgshop .= " shop = " . $value . " or";
  1686. $sid .= " id = " . $value . " or";
  1687. }
  1688. }
  1689. $tc = $this->typeclass->find_all();
  1690. $typeclass = array();
  1691. foreach ($tc as $v) {
  1692. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1693. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1694. }
  1695. $post = $this->input->post(NULL, TRUE);
  1696. if (isset($post['sku'])) {
  1697. $list = array();
  1698. $num = "";
  1699. $title = "";
  1700. $features = "";
  1701. $order = $this->input->post('order', true);
  1702. $shop = $this->input->post('shop', true);
  1703. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1704. $sku = $this->input->post('sku', true);
  1705. $post['sm'] = $this->input->post('sm', true);
  1706. $post['warehouse'] = $this->input->post('warehouse', true);
  1707. $post['purchase'] = $this->input->post('purchase', true);
  1708. $post['retreatwarehouse'] = $post['warehouse'];
  1709. $post['state'] = $this->input->post('state', true);
  1710. $post['rktype'] = $this->input->post('rktype', true);
  1711. $post['text'] = $this->input->post('text', true);
  1712. $category = $this->input->post('category', true);
  1713. $list['category'] = $category;
  1714. $list['hairtype'] = $this->input->post('hairtype', true);
  1715. $list['grade'] = $this->input->post('grade', true);
  1716. $size = $this->input->post('size', true);
  1717. $xzsku = $this->input->post('xzsku', true);
  1718. $list['size'] = rtrim($size, ',');
  1719. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1720. $list['extension'] = $this->input->post('extension', true);
  1721. if ($category == 1297) {
  1722. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1723. }
  1724. if ($category == 1702) {
  1725. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1726. $list['syother'] = $this->input->post('syother', true);
  1727. }
  1728. if ($category == 133) {
  1729. $list['fittype'] = $this->input->post('fittype', true);
  1730. $list['acother'] = $this->input->post('acother', true);
  1731. }
  1732. $list['color'] = $this->input->post('color', true);
  1733. $list['lowe'] = $this->input->post('lowe', true);
  1734. if (!$post['purchase']) {
  1735. $post['purchase'] = 1;
  1736. }
  1737. if ($category == 127) {
  1738. $list['type'] = $this->input->post('type', true);
  1739. $list['headroad'] = $this->input->post('headroad', true);
  1740. $list['density'] = $this->input->post('density', true);
  1741. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1742. $list['lacesize'] = $this->input->post('lacesize', true);
  1743. }
  1744. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1745. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1746. }
  1747. if ($category == 128) {
  1748. $list['lacetype'] = $this->input->post('lacetype', true);
  1749. $list['haircap'] = $this->input->post('haircap', true);
  1750. $list['density'] = $this->input->post('density', true);
  1751. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1752. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1753. $list['wigother'] = $this->input->post('wigother', true);
  1754. $list['wigother1'] = $this->input->post('wigother1', true);
  1755. $list['wigother2'] = $this->input->post('wigother2', true);
  1756. }
  1757. if ($category == 129) {
  1758. $list['wide'] = $this->input->post('wide', true);
  1759. }
  1760. if ($category == 131) {
  1761. $list['gifttype'] = $this->input->post('gifttype', true);
  1762. $list['giftother'] = $this->input->post('giftother', true);
  1763. }
  1764. if ($category == 134) {
  1765. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1766. }
  1767. if ($category == 1297) {
  1768. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1769. $list['sywigother'] = $this->input->post('sywigother', true);
  1770. }
  1771. if ($category == 130 || $category == 133 || $category == 1702) {
  1772. $list['items'] = $this->input->post('items', true);
  1773. $list['weight'] = $this->input->post('weight', true);
  1774. }
  1775. if ($category == 1702) {
  1776. $list['syhairther'] = $this->input->post('syhairther', true);
  1777. }
  1778. $classid = $this->classid->sku();
  1779. $scsku = $classid;
  1780. $pm = $classid;
  1781. foreach ($list as $k => $v) {
  1782. if ($v != 0) {
  1783. $num .= $v;
  1784. $features .= $v . '-';
  1785. $post[$k] = $v;
  1786. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1787. if ($k != 'size') {
  1788. $title .= $typeclass[$v]['title'] . " ";
  1789. }
  1790. if (isset($pm[$typeclass[$v]['classid']])) {
  1791. if ($typeclass[$v]['title'] == '9A') {
  1792. $pm[$typeclass[$v]['classid']] = '9A';
  1793. } else if ($typeclass[$v]['title'] == '10A') {
  1794. $pm[$typeclass[$v]['classid']] = '10A';
  1795. } else {
  1796. $clzh = $typeclass[$v]['zh'];
  1797. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1798. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1799. $clzh = $clzh[0];
  1800. }
  1801. $pm[$typeclass[$v]['classid']] = $clzh;
  1802. }
  1803. }
  1804. }
  1805. }
  1806. $zh = implode(" ", $pm);
  1807. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1808. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1809. if ($list['size']) {
  1810. $typeclass = $this->typeclass->read($list['size']);
  1811. $title .= $typeclass['title'];
  1812. }
  1813. $time = time();
  1814. if ($xzsku) {
  1815. $scsku = implode("-", $scsku);
  1816. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1817. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1818. $post['sku'] = trim($scsku, ' ');
  1819. } else {
  1820. $post['sku'] = $sku;
  1821. }
  1822. //$post['sku'] = trim($sku,' ');
  1823. $post['title'] = rtrim($title, ' ');
  1824. $post['number'] = $num;
  1825. $post['features'] = '-' . $features;
  1826. $post['enter'] = $time;
  1827. $post['time'] = $time; //操作时间
  1828. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1829. if ($yza) {
  1830. if ($post['features'] != $yza[0]['features']) {
  1831. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1832. exit;
  1833. }
  1834. }
  1835. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1836. if ($yzb) {
  1837. if ($post['sku'] != $yzb[0]['sku']) {
  1838. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1839. exit;
  1840. }
  1841. }
  1842. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1843. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1844. exit;
  1845. }
  1846. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1847. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1848. exit;
  1849. }
  1850. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1851. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1852. exit;
  1853. }
  1854. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1855. if (isset($yz[0]['type'])) {
  1856. $post['type'] = $yz[0]['type'];
  1857. }
  1858. if ($post['state'] == 9) //如果选择预设库存
  1859. {
  1860. $this->whlabel->insert($post);
  1861. } else {
  1862. /**
  1863. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1864. if($ljg == 1)
  1865. {
  1866. for($i=0;$i<$order;$i++)
  1867. {
  1868. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1869. $this->whlabel->insert($post);
  1870. }
  1871. }
  1872. **/
  1873. //if($post['warehouse'] == '5')
  1874. //{
  1875. //}
  1876. $yydata = $post;
  1877. $yydata['zh'] = $zh;
  1878. /**
  1879. $wl = $this->apiyy->get_cjlp($yydata);
  1880. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1881. {
  1882. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1883. }
  1884. if($wl['Data'][0]['m_isSucess'] != 1)
  1885. {
  1886. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1887. }
  1888. **/
  1889. for ($i = 0; $i < $order; $i++) {
  1890. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1891. $this->whlabel->insert($post);
  1892. }
  1893. }
  1894. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1895. exit;
  1896. }
  1897. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1898. $this->data['wlshop'] = $wlshop;
  1899. $this->_Template('whlabel_enteradd', $this->data);
  1900. }
  1901. //修改产品
  1902. public function _enteredit($arg_array)
  1903. {
  1904. $dt = 0;
  1905. if (isset($_SESSION['api'])) {
  1906. $user = $this->user->get_api($_SESSION['api']);
  1907. $usp = $user;
  1908. $fgshop = "";
  1909. $sid = "";
  1910. $user = explode('|', trim($user['shop'], '|'));
  1911. foreach ($user as $value) {
  1912. $fgshop .= " shop = " . $value . " or";
  1913. $sid .= " id = " . $value . " or";
  1914. }
  1915. }
  1916. $post = $this->input->post(NULL, TRUE);
  1917. if (isset($post['sku'])) {
  1918. $list = array();
  1919. $num = "";
  1920. $title = "";
  1921. $features = "";
  1922. $id = $this->input->post('id', true);
  1923. $order = $this->input->post('order', true);
  1924. $shop = $this->input->post('shop', true);
  1925. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1926. $post['sku'] = $this->input->post('sku', true);
  1927. $post['sm'] = $this->input->post('sm', true);
  1928. $post['warehouse'] = $this->input->post('warehouse', true);
  1929. $post['purchase'] = $this->input->post('purchase', true);
  1930. $post['retreatwarehouse'] = $post['warehouse'];
  1931. $category = $this->input->post('category', true);
  1932. $list['category'] = $category;
  1933. $list['hairtype'] = $this->input->post('hairtype', true);
  1934. $list['grade'] = $this->input->post('grade', true);
  1935. $size = $this->input->post('size', true);
  1936. $list['size'] = rtrim($size, ',');
  1937. $post['rktype'] = $this->input->post('rktype', true);
  1938. $post['text'] = $this->input->post('text', true);
  1939. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1940. $list['extension'] = $this->input->post('extension', true);
  1941. if ($category == 1297) {
  1942. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1943. }
  1944. if ($category == 1702) {
  1945. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1946. $list['syother'] = $this->input->post('syother', true);
  1947. }
  1948. if ($category == 133) {
  1949. $list['fittype'] = $this->input->post('fittype', true);
  1950. $list['acother'] = $this->input->post('acother', true);
  1951. }
  1952. $list['color'] = $this->input->post('color', true);
  1953. $list['lowe'] = $this->input->post('lowe', true);
  1954. if (!$post['purchase']) {
  1955. $post['purchase'] = 1;
  1956. }
  1957. if ($category == 127) {
  1958. $list['type'] = $this->input->post('type', true);
  1959. $list['headroad'] = $this->input->post('headroad', true);
  1960. $list['density'] = $this->input->post('density', true);
  1961. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1962. $list['lacesize'] = $this->input->post('lacesize', true);
  1963. }
  1964. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1965. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1966. }
  1967. if ($category == 128) {
  1968. $list['lacetype'] = $this->input->post('lacetype', true);
  1969. $list['haircap'] = $this->input->post('haircap', true);
  1970. $list['density'] = $this->input->post('density', true);
  1971. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1972. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1973. $list['wigother'] = $this->input->post('wigother', true);
  1974. $list['wigother1'] = $this->input->post('wigother1', true);
  1975. $list['wigother2'] = $this->input->post('wigother2', true);
  1976. }
  1977. if ($category == 129) {
  1978. $list['wide'] = $this->input->post('wide', true);
  1979. }
  1980. if ($category == 131) {
  1981. $list['gifttype'] = $this->input->post('gifttype', true);
  1982. $list['giftother'] = $this->input->post('giftother', true);
  1983. }
  1984. if ($category == 134) {
  1985. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1986. }
  1987. if ($category == 1297) {
  1988. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1989. $list['sywigother'] = $this->input->post('sywigother', true);
  1990. }
  1991. if ($category == 130 || $category == 133 || $category == 1702) {
  1992. $list['items'] = $this->input->post('items', true);
  1993. $list['weight'] = $this->input->post('weight', true);
  1994. }
  1995. if ($category == 1702) {
  1996. $list['syhairther'] = $this->input->post('syhairther', true);
  1997. }
  1998. foreach ($list as $k => $v) {
  1999. if ($v != 0) {
  2000. $num .= $v;
  2001. $features .= $v . '-';
  2002. $typeclass = $this->typeclass->read($v);
  2003. if ($k != 'size') {
  2004. $title .= $typeclass['title'] . " ";
  2005. }
  2006. }
  2007. }
  2008. $typeclass = $this->typeclass->read($list['size']);
  2009. $title .= $typeclass['title'];
  2010. $time = time();
  2011. $post['title'] = rtrim($title, ' ');
  2012. $post['number'] = $num;
  2013. $post['features'] = '-' . $features;
  2014. $post['time'] = $time; //操作时间
  2015. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2016. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2017. exit;
  2018. }
  2019. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2020. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2021. exit;
  2022. }
  2023. $uid = $this->whlabel->read($id);
  2024. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2025. if ($datanum > 0) {
  2026. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2027. exit;
  2028. }
  2029. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2030. {
  2031. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2032. if ($yza) {
  2033. if ($post['features'] != $yza[0]['features']) {
  2034. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2035. exit;
  2036. }
  2037. }
  2038. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2039. if ($yzb) {
  2040. if ($post['sku'] != $yzb[0]['sku']) {
  2041. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2042. exit;
  2043. }
  2044. }
  2045. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2046. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2047. exit;
  2048. }
  2049. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2050. foreach ($data as $v) {
  2051. $post['id'] = $v['id'];
  2052. $this->whlabel->save($post, $v['id']);
  2053. }
  2054. } else {
  2055. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2056. if ($data > 0) {
  2057. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2058. exit;
  2059. } else {
  2060. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2061. foreach ($data as $v) {
  2062. $post['id'] = $v['id'];
  2063. $this->whlabel->save($post, $v['id']);
  2064. }
  2065. }
  2066. }
  2067. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2068. exit;
  2069. }
  2070. $uid = $this->whlabel->read($arg_array[0]);
  2071. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2072. $this->data['enter'] = $uid;
  2073. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2074. $this->data['wlshop'] = $wlshop;
  2075. $this->_Template('whlabel_enteredit', $this->data);
  2076. }
  2077. //入库浏览
  2078. public function _enter()
  2079. {
  2080. $post = $this->input->post(NULL, TRUE);
  2081. if (isset($post['s'])) {
  2082. $id_arr = $this->input->post('s');
  2083. $id_arr = explode(',', $id_arr);
  2084. if (!$id_arr) {
  2085. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2086. exit;
  2087. }
  2088. //循环删除记录
  2089. foreach ($id_arr as $v) {
  2090. $sid = $this->whlabel->read($v);
  2091. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2092. if ($count > 0) {
  2093. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2094. exit;
  2095. }
  2096. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2097. foreach ($info_list as $va) {
  2098. $this->whlabel->remove($va['id']);
  2099. }
  2100. }
  2101. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2102. exit;
  2103. }
  2104. $sp = array();
  2105. $s = $this->shop->find_all('1=1', 'id,shopname');
  2106. foreach ($s as $v) {
  2107. $sp[$v['id']] = $v['shopname'];
  2108. }
  2109. $wh = array();
  2110. $w = $this->warehouse->find_all('1=1', 'id,title');
  2111. foreach ($w as $v) {
  2112. $wh[$v['id']] = $v['title'];
  2113. }
  2114. if (isset($post['page'])) {
  2115. $page = $this->input->post('page', true);
  2116. $perpage = $this->input->post('perpage', true);
  2117. $category = $this->input->post('category', true);
  2118. $size = $this->input->post('size', true);
  2119. $grade = $this->input->post('grade', true);
  2120. $color = $this->input->post('color', true);
  2121. $lowe = $this->input->post('lowe', true);
  2122. $sku = $this->input->post('sku', true);
  2123. $warehouse = $this->input->post('warehouse', true);
  2124. $purchase = $this->input->post('purchase', true);
  2125. $ktime = $this->input->post('ktime', true);
  2126. $jtime = $this->input->post('jtime', true);
  2127. $ktime = strtotime($ktime);
  2128. $jtime = strtotime($jtime);
  2129. $where = "1=1";
  2130. $gj = "";
  2131. $ck = "";
  2132. if ($category) {
  2133. $where .= " and features like '%-$category-%'";
  2134. }
  2135. if ($size) {
  2136. $where .= " and features like '%-$size-%'";
  2137. }
  2138. if ($grade) {
  2139. $where .= " and features like '%-$grade-%'";
  2140. }
  2141. if ($color) {
  2142. $where .= " and features like '%-$color-%'";
  2143. }
  2144. if ($lowe) {
  2145. $where .= " and features like '%-$lowe-%'";
  2146. }
  2147. if ($warehouse) {
  2148. $where .= " and warehouse = '$warehouse'";
  2149. }
  2150. if ($purchase) {
  2151. $where .= " and purchase = '$purchase'";
  2152. }
  2153. if ($sku) {
  2154. $where .= " and sku like '%$sku%'";
  2155. }
  2156. if ($ktime && $jtime) {
  2157. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2158. }
  2159. //数据排序
  2160. $order_str = "enter desc";
  2161. if (empty($page)) {
  2162. $start = 0;
  2163. $perpage = 1;
  2164. } else {
  2165. $start = ($page - 1) * $perpage;
  2166. }
  2167. //取得信息列表
  2168. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2169. foreach ($info_list as $k => $v) {
  2170. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2171. if ($v['shop'] == '') {
  2172. $s = '通用';
  2173. } else {
  2174. $info_list[$k]['shop'] = '';
  2175. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2176. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2177. }
  2178. }
  2179. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2180. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2181. $info_list[$k]['g'] = $g;
  2182. }
  2183. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2184. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2185. $pagenum = ceil($total / $perpage);
  2186. $over = $total - ($start + $perpage);
  2187. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2188. echo json_encode($rows);
  2189. exit;
  2190. }
  2191. $this->_Template('whlabel_enter', $this->data);
  2192. }
  2193. //出库浏览
  2194. public function _out()
  2195. {
  2196. $post = $this->input->post(NULL, TRUE);
  2197. if (isset($post['page'])) {
  2198. $page = $this->input->post('page', true);
  2199. $perpage = $this->input->post('perpage', true);
  2200. $category = $this->input->post('category', true);
  2201. $size = $this->input->post('size', true);
  2202. $grade = $this->input->post('grade', true);
  2203. $color = $this->input->post('color', true);
  2204. $lowe = $this->input->post('lowe', true);
  2205. $sku = $this->input->post('sku', true);
  2206. $warehouse = $this->input->post('warehouse', true);
  2207. $purchase = $this->input->post('purchase', true);
  2208. $state = $this->input->post('state', true);
  2209. $ktime = $this->input->post('ktime', true);
  2210. $jtime = $this->input->post('jtime', true);
  2211. $ktime = strtotime($ktime);
  2212. $jtime = strtotime($jtime);
  2213. $where = "state=3";
  2214. $gj = "";
  2215. $ck = "";
  2216. if ($category) {
  2217. $where .= " and features like '%-$category-%'";
  2218. }
  2219. if ($size) {
  2220. $where .= " and features like '%-$size-%'";
  2221. }
  2222. if ($grade) {
  2223. $where .= " and features like '%-$grade-%'";
  2224. }
  2225. if ($color) {
  2226. $where .= " and features like '%-$color-%'";
  2227. }
  2228. if ($lowe) {
  2229. $where .= " and features like '%-$lowe-%'";
  2230. }
  2231. if ($state) {
  2232. $where .= " and state = '$state'";
  2233. }
  2234. if ($warehouse) {
  2235. $where .= " and warehouse = '$warehouse'";
  2236. }
  2237. if ($purchase) {
  2238. $where .= " and purchase = '$purchase'";
  2239. }
  2240. if ($sku) {
  2241. $where .= " and sku = '$sku'";
  2242. }
  2243. if ($ktime && $jtime) {
  2244. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2245. }
  2246. //数据排序
  2247. $order_str = "id desc";
  2248. if (empty($page)) {
  2249. $start = 0;
  2250. $perpage = 1;
  2251. } else {
  2252. $start = ($page - 1) * $perpage;
  2253. }
  2254. //取得信息列表
  2255. $info_list = $this->whlabel->find_all($where, 'sku');
  2256. $rows = array();
  2257. $list = array();
  2258. foreach ($info_list as $key => $value) {
  2259. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2260. }
  2261. $rows = array_unique($rows); //删除重复记录
  2262. foreach ($rows as $key => $value) {
  2263. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2264. $ck = $this->warehouse->read($data['warehouse']);
  2265. $warehouse = $ck['title'];
  2266. $gy = $this->purchase->read($data['purchase']);
  2267. $purchase = $gy['purchase'];
  2268. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2269. $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);
  2270. }
  2271. $total = count($list);
  2272. $pagenum = ceil($total / $perpage);
  2273. $over = $total - ($start + $perpage);
  2274. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2275. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2276. echo json_encode($rows);
  2277. exit;
  2278. }
  2279. $this->_Template('whlabel_out', $this->data);
  2280. }
  2281. //出库标签浏览
  2282. public function _label()
  2283. {
  2284. $post = $this->input->post(NULL, TRUE);
  2285. if (isset($post['page'])) {
  2286. $page = $this->input->post('page', true);
  2287. $perpage = $this->input->post('perpage', true);
  2288. $sku = $this->input->post('sku', true);
  2289. $warehouse = $this->input->post('warehouse', true);
  2290. $purchase = $this->input->post('purchase', true);
  2291. $orderinfo = $this->input->post('orderinfo', true);
  2292. $waybill = $this->input->post('waybill', true);
  2293. $category = $this->input->post('category', true);
  2294. $size = $this->input->post('size', true);
  2295. $grade = $this->input->post('grade', true);
  2296. $color = $this->input->post('color', true);
  2297. $lowe = $this->input->post('lowe', true);
  2298. $where = "state=1";
  2299. if ($sku) {
  2300. $where .= " and sku = '$sku'";
  2301. }
  2302. if ($warehouse) {
  2303. $where .= " and warehouse = '$warehouse'";
  2304. }
  2305. if ($purchase) {
  2306. $where .= " and purchase = '$purchase'";
  2307. }
  2308. if ($orderinfo) {
  2309. $where .= " and orderinfo = '$orderinfo'";
  2310. }
  2311. if ($waybill) {
  2312. $where .= " and waybill = '$waybill'";
  2313. }
  2314. if ($category) {
  2315. $where .= " and features like '%-$category-%'";
  2316. }
  2317. if ($size) {
  2318. $where .= " and features like '%-$size-%'";
  2319. }
  2320. if ($grade) {
  2321. $where .= " and features like '%-$grade-%'";
  2322. }
  2323. if ($color) {
  2324. $where .= " and features like '%-$color-%'";
  2325. }
  2326. if ($lowe) {
  2327. $where .= " and features like '%-$lowe-%'";
  2328. }
  2329. //数据排序
  2330. $order_str = "outk desc";
  2331. if (empty($page)) {
  2332. $start = 0;
  2333. $perpage = 1;
  2334. } else {
  2335. $start = ($page - 1) * $perpage;
  2336. }
  2337. //取得信息列表
  2338. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2339. foreach ($info_list as $key => $value) {
  2340. $warehouse = $this->warehouse->read($value['warehouse']);
  2341. $info_list[$key]['warehouse'] = $warehouse['title'];
  2342. $purchase = $this->purchase->read($value['purchase']);
  2343. $info_list[$key]['purchase'] = $purchase['title'];
  2344. if ($value['outk'] != 0) {
  2345. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2346. } else {
  2347. $info_list[$key]['outk'] = "";
  2348. }
  2349. if ($value['orderinfo'] == 0) {
  2350. $info_list[$key]['orderinfo'] = "";
  2351. }
  2352. if ($value['waybill'] == 0) {
  2353. $info_list[$key]['waybill'] = "";
  2354. }
  2355. }
  2356. $total = $this->whlabel->find_count($where);
  2357. $pagenum = ceil($total / $perpage);
  2358. $over = $total - ($start + $perpage);
  2359. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2360. echo json_encode($rows);
  2361. exit;
  2362. }
  2363. $this->_Template('whlabel_label', $this->data);
  2364. }
  2365. //独立站出库订单
  2366. public function _outorder()
  2367. {
  2368. if (isset($_SESSION['api'])) {
  2369. $user = $this->user->get_api($_SESSION['api']);
  2370. $usp = $user;
  2371. $fgshop = "";
  2372. $sid = "";
  2373. $user = explode('|', trim($user['shop'], '|'));
  2374. foreach ($user as $value) {
  2375. $fgshop .= " shop = " . $value . " or";
  2376. $sid .= " id = " . $value . " or";
  2377. }
  2378. } else {
  2379. echo "请重新登录";
  2380. }
  2381. $post = $this->input->post(NULL, TRUE);
  2382. if (isset($post['page'])) {
  2383. $page = $this->input->post('page', true);
  2384. $perpage = $this->input->post('perpage', true);
  2385. $warehouse = $this->input->post('warehouse', true);
  2386. $xztime = $this->input->post('xztime', true);
  2387. $timetk = $this->input->post('timetkk', true);
  2388. $timetj = $this->input->post('timetjj', true);
  2389. $shop = $this->input->post('shop', true);
  2390. $source = $this->input->post('source', true);
  2391. $orderinfo = $this->input->post('orderinfo', true);
  2392. $number = $this->input->post('number', true);
  2393. $sfxh = $this->input->post('sfxh', true);
  2394. $express = $this->input->post('express', true);
  2395. $waybill = $this->input->post('waybill', true);
  2396. $library = $this->input->post('library', true);
  2397. $country = $this->input->post('country', true);
  2398. $so = $this->input->post('so', true);
  2399. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2400. $print = $this->input->post('print', true);
  2401. $state = $this->input->post('state', true);
  2402. $orderurl = $this->input->post('orderurl', true);
  2403. $timetk = strtotime($timetk);
  2404. $timetj = strtotime($timetj);
  2405. /**
  2406. $sj = $this->input->post('sj',true);
  2407. if($sj)
  2408. {
  2409. $sj = $this->input->post('sj',true);
  2410. }
  2411. else
  2412. {
  2413. $sj = "fullorder";
  2414. }
  2415. **/
  2416. $sj = "fullorder";
  2417. $where = "1=1";
  2418. if ($warehouse) {
  2419. $where .= " and type = '$warehouse'";
  2420. }
  2421. if ($timetk && $timetj) {
  2422. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2423. }
  2424. if ($orderinfo) {
  2425. $where .= " and orderinfo = '$orderinfo'";
  2426. }
  2427. if ($number) {
  2428. $where .= " and number = '$number'";
  2429. }
  2430. if ($express) {
  2431. $where .= " and express = '$express'";
  2432. }
  2433. if ($waybill) {
  2434. $where .= " and waybill = '$waybill'";
  2435. }
  2436. if ($library) {
  2437. $where .= " and library = '$library'";
  2438. }
  2439. if ($print) {
  2440. $where .= " and print = '$print'";
  2441. }
  2442. if ($libraryconfirm) {
  2443. $where .= " and libraryconfirm = '$libraryconfirm'";
  2444. }
  2445. if ($state) {
  2446. $where .= " and state = '$state'";
  2447. }
  2448. if ($shop) {
  2449. $where .= " and shop = '$shop'";
  2450. }
  2451. if ($country) {
  2452. $where .= " and country = '$country'";
  2453. }
  2454. if ($sfxh != '') {
  2455. $where .= " and sfxh = '$sfxh'";
  2456. }
  2457. if ($so) {
  2458. $where .= " and shipremarks like '%$so%'";
  2459. }
  2460. if ($source) {
  2461. if ($source == '2d') {
  2462. $where .= " and source >= '2'";
  2463. } else {
  2464. $where .= " and source = '$source'";
  2465. }
  2466. }
  2467. if (isset($_SESSION['api'])) {
  2468. foreach ($user as $value) {
  2469. $fgshop .= " shop = " . $value . " or";
  2470. }
  2471. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2472. }
  2473. if ($orderurl) {
  2474. $url = $this->orderurl->read($orderurl);
  2475. $where .= " and link like '%" . $url['url'] . "%'";
  2476. }
  2477. //数据排序
  2478. $order_str = "librarytime desc";
  2479. if (empty($page)) {
  2480. $start = 0;
  2481. $perpage = 1;
  2482. } else {
  2483. $start = ($page - 1) * $perpage;
  2484. }
  2485. //取得信息列表
  2486. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2487. //格式化数据
  2488. foreach ($info_list as $key => $value) {
  2489. $shop = $this->shop->read($value['shop']);
  2490. $info_list[$key]['shop'] = $shop['shopname'];
  2491. $express = $this->express->read($value['express']);
  2492. $info_list[$key]['express'] = $express['servicename'];
  2493. $warehouse = $this->warehouse->read($value['type']);
  2494. $info_list[$key]['type'] = $warehouse['title'];
  2495. if ($value['librarytime'] == '0') {
  2496. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2497. } else {
  2498. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2499. }
  2500. }
  2501. $total = $this->$sj->find_count($where);
  2502. $pagenum = ceil($total / $perpage);
  2503. $over = $total - ($start + $perpage);
  2504. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2505. echo json_encode($rows);
  2506. exit;
  2507. }
  2508. $this->data['express'] = $this->express->find_all();
  2509. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2510. $this->data['wlshop'] = $wlshop;
  2511. $user = $this->user->get_api($_SESSION['api']);
  2512. $powerid = $this->power->read($user['power']);
  2513. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2514. $pid = '';
  2515. foreach ($powertext as $v) {
  2516. $pid .= " id = " . $v . " or";
  2517. }
  2518. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2519. $this->data['fullorderexcel'] = $fullorderexcel;
  2520. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2521. $this->data['orderurl'] = $orderurl;
  2522. $this->_Template('whlabel_outorder', $this->data);
  2523. }
  2524. //tt出库
  2525. public function _toutorder()
  2526. {
  2527. if (isset($_SESSION['api'])) {
  2528. $user = $this->user->get_api($_SESSION['api']);
  2529. $usp = $user;
  2530. $fgshop = "";
  2531. $sid = "";
  2532. $user = explode('|', trim($user['shop'], '|'));
  2533. foreach ($user as $value) {
  2534. $fgshop .= " shop = " . $value . " or";
  2535. $sid .= " id = " . $value . " or";
  2536. }
  2537. } else {
  2538. echo "请重新登录";
  2539. }
  2540. $post = $this->input->post(NULL, TRUE);
  2541. if (isset($post['page'])) {
  2542. $page = $this->input->post('page', true);
  2543. $perpage = $this->input->post('perpage', true);
  2544. $warehouse = $this->input->post('warehouse', true);
  2545. $xztime = $this->input->post('xztime', true);
  2546. $timetk = $this->input->post('timetkk', true);
  2547. $timetj = $this->input->post('timetjj', true);
  2548. $shop = $this->input->post('shop', true);
  2549. $source = $this->input->post('source', true);
  2550. $orderinfo = $this->input->post('orderinfo', true);
  2551. $number = $this->input->post('number', true);
  2552. $sfxh = $this->input->post('sfxh', true);
  2553. $express = $this->input->post('express', true);
  2554. $waybill = $this->input->post('waybill', true);
  2555. $library = $this->input->post('library', true);
  2556. $country = $this->input->post('country', true);
  2557. $so = $this->input->post('so', true);
  2558. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2559. $print = $this->input->post('print', true);
  2560. $state = $this->input->post('state', true);
  2561. $orderurl = $this->input->post('orderurl', true);
  2562. $timetk = strtotime($timetk);
  2563. $timetj = strtotime($timetj);
  2564. /**
  2565. $sj = $this->input->post('sj',true);
  2566. if($sj)
  2567. {
  2568. $sj = $this->input->post('sj',true);
  2569. }
  2570. else
  2571. {
  2572. $sj = "fullorder";
  2573. }
  2574. **/
  2575. $sj = "fullordertt";
  2576. $where = "1=1";
  2577. if ($warehouse) {
  2578. $where .= " and type = '$warehouse'";
  2579. }
  2580. if ($timetk && $timetj) {
  2581. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2582. }
  2583. if ($orderinfo) {
  2584. $where .= " and orderinfo = '$orderinfo'";
  2585. }
  2586. if ($number) {
  2587. $where .= " and number = '$number'";
  2588. }
  2589. if ($express) {
  2590. $where .= " and express = '$express'";
  2591. }
  2592. if ($waybill) {
  2593. $where .= " and waybill = '$waybill'";
  2594. }
  2595. if ($library) {
  2596. $where .= " and library = '$library'";
  2597. }
  2598. if ($print) {
  2599. $where .= " and print = '$print'";
  2600. }
  2601. if ($libraryconfirm) {
  2602. $where .= " and libraryconfirm = '$libraryconfirm'";
  2603. }
  2604. if ($state) {
  2605. $where .= " and state = '$state'";
  2606. }
  2607. if ($shop) {
  2608. $where .= " and shop = '$shop'";
  2609. }
  2610. if ($country) {
  2611. $where .= " and country = '$country'";
  2612. }
  2613. if ($sfxh != '') {
  2614. $where .= " and sfxh = '$sfxh'";
  2615. }
  2616. if ($so) {
  2617. $where .= " and shipremarks like '%$so%'";
  2618. }
  2619. if ($source) {
  2620. if ($source == '2d') {
  2621. $where .= " and source >= '2'";
  2622. } else {
  2623. $where .= " and source = '$source'";
  2624. }
  2625. }
  2626. if (isset($_SESSION['api'])) {
  2627. foreach ($user as $value) {
  2628. $fgshop .= " shop = " . $value . " or";
  2629. }
  2630. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2631. }
  2632. if ($orderurl) {
  2633. $url = $this->orderurl->read($orderurl);
  2634. $where .= " and link like '%" . $url['url'] . "%'";
  2635. }
  2636. //数据排序
  2637. $order_str = "librarytime desc";
  2638. if (empty($page)) {
  2639. $start = 0;
  2640. $perpage = 1;
  2641. } else {
  2642. $start = ($page - 1) * $perpage;
  2643. }
  2644. //取得信息列表
  2645. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2646. //格式化数据
  2647. foreach ($info_list as $key => $value) {
  2648. $shop = $this->shop->read($value['shop']);
  2649. $info_list[$key]['shop'] = $shop['shopname'];
  2650. $express = $this->express->read($value['express']);
  2651. $info_list[$key]['express'] = $express['servicename'];
  2652. $warehouse = $this->warehouse->read($value['type']);
  2653. $info_list[$key]['type'] = $warehouse['title'];
  2654. if ($value['librarytime'] == '0') {
  2655. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2656. } else {
  2657. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2658. }
  2659. }
  2660. $total = $this->$sj->find_count($where);
  2661. $pagenum = ceil($total / $perpage);
  2662. $over = $total - ($start + $perpage);
  2663. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2664. echo json_encode($rows);
  2665. exit;
  2666. }
  2667. $this->data['express'] = $this->express->find_all();
  2668. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2669. $this->data['wlshop'] = $wlshop;
  2670. $user = $this->user->get_api($_SESSION['api']);
  2671. $powerid = $this->power->read($user['power']);
  2672. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2673. $pid = '';
  2674. foreach ($powertext as $v) {
  2675. $pid .= " id = " . $v . " or";
  2676. }
  2677. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2678. $this->data['fullorderexcel'] = $fullorderexcel;
  2679. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2680. $this->data['orderurl'] = $orderurl;
  2681. $this->_Template('whlabel_toutorder', $this->data);
  2682. }
  2683. //tt出库
  2684. public function _aoutorder()
  2685. {
  2686. if (isset($_SESSION['api'])) {
  2687. $user = $this->user->get_api($_SESSION['api']);
  2688. $usp = $user;
  2689. $fgshop = "";
  2690. $sid = "";
  2691. $user = explode('|', trim($user['shop'], '|'));
  2692. foreach ($user as $value) {
  2693. $fgshop .= " shop = " . $value . " or";
  2694. $sid .= " id = " . $value . " or";
  2695. }
  2696. } else {
  2697. echo "请重新登录";
  2698. }
  2699. $post = $this->input->post(NULL, TRUE);
  2700. if (isset($post['page'])) {
  2701. $page = $this->input->post('page', true);
  2702. $perpage = $this->input->post('perpage', true);
  2703. $warehouse = $this->input->post('warehouse', true);
  2704. $xztime = $this->input->post('xztime', true);
  2705. $timetk = $this->input->post('timetkk', true);
  2706. $timetj = $this->input->post('timetjj', true);
  2707. $shop = $this->input->post('shop', true);
  2708. $source = $this->input->post('source', true);
  2709. $orderinfo = $this->input->post('orderinfo', true);
  2710. $number = $this->input->post('number', true);
  2711. $sfxh = $this->input->post('sfxh', true);
  2712. $express = $this->input->post('express', true);
  2713. $waybill = $this->input->post('waybill', true);
  2714. $library = $this->input->post('library', true);
  2715. $country = $this->input->post('country', true);
  2716. $so = $this->input->post('so', true);
  2717. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2718. $print = $this->input->post('print', true);
  2719. $state = $this->input->post('state', true);
  2720. $orderurl = $this->input->post('orderurl', true);
  2721. $timetk = strtotime($timetk);
  2722. $timetj = strtotime($timetj);
  2723. /**
  2724. $sj = $this->input->post('sj',true);
  2725. if($sj)
  2726. {
  2727. $sj = $this->input->post('sj',true);
  2728. }
  2729. else
  2730. {
  2731. $sj = "fullorder";
  2732. }
  2733. **/
  2734. $sj = "fullorderamz";
  2735. $where = "1=1";
  2736. if ($warehouse) {
  2737. $where .= " and type = '$warehouse'";
  2738. }
  2739. if ($timetk && $timetj) {
  2740. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2741. }
  2742. if ($orderinfo) {
  2743. $where .= " and orderinfo = '$orderinfo'";
  2744. }
  2745. if ($number) {
  2746. $where .= " and number = '$number'";
  2747. }
  2748. if ($express) {
  2749. $where .= " and express = '$express'";
  2750. }
  2751. if ($waybill) {
  2752. $where .= " and waybill = '$waybill'";
  2753. }
  2754. if ($library) {
  2755. $where .= " and library = '$library'";
  2756. }
  2757. if ($print) {
  2758. $where .= " and print = '$print'";
  2759. }
  2760. if ($libraryconfirm) {
  2761. $where .= " and libraryconfirm = '$libraryconfirm'";
  2762. }
  2763. if ($state) {
  2764. $where .= " and state = '$state'";
  2765. }
  2766. if ($shop) {
  2767. $where .= " and shop = '$shop'";
  2768. }
  2769. if ($country) {
  2770. $where .= " and country = '$country'";
  2771. }
  2772. if ($sfxh != '') {
  2773. $where .= " and sfxh = '$sfxh'";
  2774. }
  2775. if ($so) {
  2776. $where .= " and shipremarks like '%$so%'";
  2777. }
  2778. if ($source) {
  2779. if ($source == '2d') {
  2780. $where .= " and source >= '2'";
  2781. } else {
  2782. $where .= " and source = '$source'";
  2783. }
  2784. }
  2785. if (isset($_SESSION['api'])) {
  2786. foreach ($user as $value) {
  2787. $fgshop .= " shop = " . $value . " or";
  2788. }
  2789. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2790. }
  2791. if ($orderurl) {
  2792. $url = $this->orderurl->read($orderurl);
  2793. $where .= " and link like '%" . $url['url'] . "%'";
  2794. }
  2795. //数据排序
  2796. $order_str = "librarytime desc";
  2797. if (empty($page)) {
  2798. $start = 0;
  2799. $perpage = 1;
  2800. } else {
  2801. $start = ($page - 1) * $perpage;
  2802. }
  2803. //取得信息列表
  2804. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2805. //格式化数据
  2806. foreach ($info_list as $key => $value) {
  2807. $shop = $this->shop->read($value['shop']);
  2808. $info_list[$key]['shop'] = $shop['shopname'];
  2809. $express = $this->express->read($value['express']);
  2810. $info_list[$key]['express'] = $express['servicename'];
  2811. $warehouse = $this->warehouse->read($value['type']);
  2812. $info_list[$key]['type'] = $warehouse['title'];
  2813. if ($value['librarytime'] == '0') {
  2814. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2815. } else {
  2816. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2817. }
  2818. }
  2819. $total = $this->$sj->find_count($where);
  2820. $pagenum = ceil($total / $perpage);
  2821. $over = $total - ($start + $perpage);
  2822. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2823. echo json_encode($rows);
  2824. exit;
  2825. }
  2826. $this->data['express'] = $this->express->find_all();
  2827. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2828. $this->data['wlshop'] = $wlshop;
  2829. $user = $this->user->get_api($_SESSION['api']);
  2830. $powerid = $this->power->read($user['power']);
  2831. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2832. $pid = '';
  2833. foreach ($powertext as $v) {
  2834. $pid .= " id = " . $v . " or";
  2835. }
  2836. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2837. $this->data['fullorderexcel'] = $fullorderexcel;
  2838. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2839. $this->data['orderurl'] = $orderurl;
  2840. $this->_Template('whlabel_aoutorder', $this->data);
  2841. }
  2842. //速卖通出库订单
  2843. public function _soutorder()
  2844. {
  2845. if (isset($_SESSION['api'])) {
  2846. $user = $this->user->get_api($_SESSION['api']);
  2847. $usp = $user;
  2848. $fgshop = "";
  2849. $sid = "";
  2850. $user = explode('|', trim($user['shop'], '|'));
  2851. foreach ($user as $value) {
  2852. $sid .= " id = " . $value . " or";
  2853. }
  2854. }
  2855. $post = $this->input->post(NULL, TRUE);
  2856. if (isset($post['page'])) {
  2857. $page = $this->input->post('page', true);
  2858. $perpage = $this->input->post('perpage', true);
  2859. $warehouse = $this->input->post('warehouse', true);
  2860. $xztime = $this->input->post('xztime', true);
  2861. $timetk = $this->input->post('timetkk', true);
  2862. $timetj = $this->input->post('timetjj', true);
  2863. $shop = $this->input->post('shop', true);
  2864. $source = $this->input->post('source', true);
  2865. $orderinfo = $this->input->post('orderinfo', true);
  2866. $number = $this->input->post('number', true);
  2867. $express = $this->input->post('express', true);
  2868. $waybill = $this->input->post('waybill', true);
  2869. $library = $this->input->post('library', true);
  2870. $country = $this->input->post('country', true);
  2871. $sfxh = $this->input->post('sfxh', true);
  2872. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2873. $print = $this->input->post('print', true);
  2874. $state = $this->input->post('state', true);
  2875. $so = $this->input->post('so', true);
  2876. $timetk = strtotime($timetk);
  2877. $timetj = strtotime($timetj);
  2878. /**
  2879. $sj = $this->input->post('sj',true);
  2880. if($sj)
  2881. {
  2882. $sj = $this->input->post('sj',true);
  2883. }
  2884. else
  2885. {
  2886. $sj = "fullorder";
  2887. }
  2888. **/
  2889. $sj = "fullordersmt";
  2890. $where = "1=1";
  2891. if ($warehouse) {
  2892. $where .= " and type = '$warehouse'";
  2893. }
  2894. if ($timetk && $timetj) {
  2895. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2896. }
  2897. if ($orderinfo) {
  2898. $where .= " and orderinfo = '$orderinfo'";
  2899. }
  2900. if ($number) {
  2901. $where .= " and number = '$number'";
  2902. }
  2903. if ($express) {
  2904. $where .= " and express = '$express'";
  2905. }
  2906. if ($waybill) {
  2907. $where .= " and waybill = '$waybill'";
  2908. }
  2909. if ($library) {
  2910. $where .= " and library = '$library'";
  2911. }
  2912. if ($print) {
  2913. $where .= " and print = '$print'";
  2914. }
  2915. if ($libraryconfirm) {
  2916. $where .= " and libraryconfirm = '$libraryconfirm'";
  2917. }
  2918. if ($state) {
  2919. $where .= " and state = '$state'";
  2920. }
  2921. if ($shop) {
  2922. $where .= " and shop = '$shop'";
  2923. }
  2924. if ($sfxh != '') {
  2925. $where .= " and sfxh = '$sfxh'";
  2926. }
  2927. if ($so) {
  2928. $where .= " and shipremarks like '%$so%'";
  2929. }
  2930. if ($source) {
  2931. $where .= " and source = '$source'";
  2932. }
  2933. if ($country) {
  2934. $where .= " and country = '$country'";
  2935. } else {
  2936. if (isset($_SESSION['api'])) {
  2937. foreach ($user as $value) {
  2938. $fgshop .= " shop = " . $value . " or";
  2939. }
  2940. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2941. }
  2942. }
  2943. //数据排序
  2944. $order_str = "librarytime desc";
  2945. if (empty($page)) {
  2946. $start = 0;
  2947. $perpage = 1;
  2948. } else {
  2949. $start = ($page - 1) * $perpage;
  2950. }
  2951. //取得信息列表
  2952. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2953. //格式化数据
  2954. foreach ($info_list as $key => $value) {
  2955. $shop = $this->shop->read($value['shop']);
  2956. $info_list[$key]['shop'] = $shop['shopname'];
  2957. $express = $this->express->read($value['express']);
  2958. $info_list[$key]['express'] = $express['servicename'];
  2959. $warehouse = $this->warehouse->read($value['type']);
  2960. $info_list[$key]['type'] = $warehouse['title'];
  2961. if ($value['librarytime'] == '0') {
  2962. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2963. } else {
  2964. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2965. }
  2966. }
  2967. $total = $this->$sj->find_count($where);
  2968. $pagenum = ceil($total / $perpage);
  2969. $over = $total - ($start + $perpage);
  2970. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2971. echo json_encode($rows);
  2972. exit;
  2973. }
  2974. $this->data['express'] = $this->express->find_all();
  2975. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2976. $this->data['wlshop'] = $wlshop;
  2977. $user = $this->user->get_api($_SESSION['api']);
  2978. $powerid = $this->power->read($user['power']);
  2979. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2980. $pid = '';
  2981. foreach ($powertext as $v) {
  2982. $pid .= " id = " . $v . " or";
  2983. }
  2984. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2985. $this->data['fullorderexcel'] = $fullorderexcel;
  2986. $this->_Template('whlabel_soutorder', $this->data);
  2987. }
  2988. //订单退库
  2989. public function _retreat()
  2990. {
  2991. $post = $this->input->post(NULL, TRUE);
  2992. if (isset($post['page'])) {
  2993. $page = $this->input->post('page', true);
  2994. $perpage = $this->input->post('perpage', true);
  2995. $warehouse = $this->input->post('warehouse', true);
  2996. $timetk = $this->input->post('timetk', true);
  2997. $timetj = $this->input->post('timetj', true);
  2998. $shop = $this->input->post('shop', true);
  2999. $source = $this->input->post('source', true);
  3000. $state = $this->input->post('state', true);
  3001. $review = $this->input->post('review', true);
  3002. $state = $this->input->post('state', true);
  3003. $express = $this->input->post('express', true);
  3004. $orderinfo = $this->input->post('orderinfo', true);
  3005. $user = $this->input->post('user', true);
  3006. $name = $this->input->post('name', true);
  3007. $waybill = $this->input->post('waybill', true);
  3008. $timetk = strtotime($timetk);
  3009. $timetj = strtotime($timetj);
  3010. $where = "(state=206 or state=210) and mergeid = 0";
  3011. if ($warehouse) {
  3012. $where .= " and state = '$warehouse'";
  3013. }
  3014. if ($timetk && $timetj) {
  3015. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3016. }
  3017. if ($shop) {
  3018. $where .= " and shop = '$shop'";
  3019. }
  3020. if ($source) {
  3021. $where .= " and source = '$source'";
  3022. }
  3023. if ($state) {
  3024. $where .= " and state = '$state'";
  3025. }
  3026. if ($review) {
  3027. $where .= " and review = '$review'";
  3028. }
  3029. if ($state) {
  3030. $where .= " and state = '$state'";
  3031. }
  3032. if ($express) {
  3033. $where .= " and express = '$express'";
  3034. }
  3035. if ($orderinfo) {
  3036. $where .= " and orderinfo = '$orderinfo'";
  3037. }
  3038. if ($user) {
  3039. $where .= " and user = '$user'";
  3040. }
  3041. if ($name) {
  3042. $where .= " and name = '$name'";
  3043. }
  3044. if ($waybill) {
  3045. $where .= " and waybill = '$waybill'";
  3046. }
  3047. //数据排序
  3048. $order_str = "id desc";
  3049. if (empty($page)) {
  3050. $start = 0;
  3051. $perpage = 1;
  3052. } else {
  3053. $start = ($page - 1) * $perpage;
  3054. }
  3055. //取得信息列表
  3056. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3057. //格式化数据
  3058. foreach ($info_list as $key => $value) {
  3059. $shop = $this->shop->read($value['shop']);
  3060. $info_list[$key]['shop'] = $shop['shopname'];
  3061. $warehouse = $this->warehouse->read($value['warehouse']);
  3062. $info_list[$key]['warehouse'] = $warehouse['title'];
  3063. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3064. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3065. if ($value['waybill'] == 0) {
  3066. $info_list[$key]['waybill'] = "";
  3067. }
  3068. $express = $this->express->read($value['express']);
  3069. $info_list[$key]['express'] = $express['title'];
  3070. $typeclass = $this->typeclass->read($value['state']);
  3071. $info_list[$key]['state'] = $typeclass['title'];
  3072. }
  3073. $total = $this->fullorder->find_count($where);
  3074. $pagenum = ceil($total / $perpage);
  3075. $over = $total - ($start + $perpage);
  3076. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3077. echo json_encode($rows);
  3078. exit;
  3079. }
  3080. $this->data['express'] = $this->express->find_all();
  3081. $this->_Template('whlabel_retreat', $this->data);
  3082. }
  3083. //退库标签浏览
  3084. public function _retreatlk()
  3085. {
  3086. $post = $this->input->post(NULL, TRUE);
  3087. if (isset($post['page'])) {
  3088. $page = $this->input->post('page', true);
  3089. $perpage = $this->input->post('perpage', true);
  3090. $timetk = $this->input->post('timetk', true);
  3091. $timetj = $this->input->post('timetj', true);
  3092. $sku = $this->input->post('sku', true);
  3093. $warehouse = $this->input->post('warehouse', true);
  3094. $purchase = $this->input->post('purchase', true);
  3095. $orderinfo = $this->input->post('orderinfo', true);
  3096. $waybill = $this->input->post('waybill', true);
  3097. $category = $this->input->post('category', true);
  3098. $size = $this->input->post('size', true);
  3099. $grade = $this->input->post('grade', true);
  3100. $color = $this->input->post('color', true);
  3101. $lowe = $this->input->post('lowe', true);
  3102. $state = $this->input->post('state', true);
  3103. $timetk = strtotime($timetk);
  3104. $timetj = strtotime($timetj);
  3105. $where = "state=2";
  3106. if ($timetk && $timetj) {
  3107. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3108. }
  3109. if ($sku) {
  3110. $where .= " and sku = '$sku'";
  3111. }
  3112. if ($warehouse) {
  3113. $where .= " and warehouse = '$warehouse'";
  3114. }
  3115. if ($purchase) {
  3116. $where .= " and purchase = '$purchase'";
  3117. }
  3118. if ($orderinfo) {
  3119. $where .= " and orderinfo = '$orderinfo'";
  3120. }
  3121. if ($waybill) {
  3122. $where .= " and waybill = '$waybill'";
  3123. }
  3124. if ($category) {
  3125. $where .= " and features like '%-$category-%'";
  3126. }
  3127. if ($size) {
  3128. $where .= " and features like '%-$size-%'";
  3129. }
  3130. if ($grade) {
  3131. $where .= " and features like '%-$grade-%'";
  3132. }
  3133. if ($color) {
  3134. $where .= " and features like '%-$color-%'";
  3135. }
  3136. if ($lowe) {
  3137. $where .= " and features like '%-$lowe-%'";
  3138. }
  3139. //数据排序
  3140. $order_str = "time desc";
  3141. if (empty($page)) {
  3142. $start = 0;
  3143. $perpage = 1;
  3144. } else {
  3145. $start = ($page - 1) * $perpage;
  3146. }
  3147. //取得信息列表
  3148. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3149. foreach ($info_list as $key => $value) {
  3150. $warehouse = $this->warehouse->read($value['warehouse']);
  3151. $info_list[$key]['warehouse'] = $warehouse['title'];
  3152. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3153. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3154. $purchase = $this->purchase->read($value['purchase']);
  3155. $info_list[$key]['purchase'] = $purchase['title'];
  3156. if ($value['outk'] != 0) {
  3157. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3158. } else {
  3159. $info_list[$key]['outk'] = "";
  3160. }
  3161. if ($value['retreat'] != 0) {
  3162. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3163. } else {
  3164. $info_list[$key]['retreat'] = "";
  3165. }
  3166. if ($value['orderinfo'] == 0) {
  3167. $info_list[$key]['orderinfo'] = "";
  3168. }
  3169. if ($value['waybill'] == 0) {
  3170. $info_list[$key]['waybill'] = "";
  3171. }
  3172. }
  3173. $total = $this->whlabel->find_count($where);
  3174. $pagenum = ceil($total / $perpage);
  3175. $over = $total - ($start + $perpage);
  3176. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3177. echo json_encode($rows);
  3178. exit;
  3179. }
  3180. $this->_Template('whlabel_retreatlk', $this->data);
  3181. }
  3182. //更换标签及浏览
  3183. public function _change()
  3184. {
  3185. $post = $this->input->post(NULL, TRUE);
  3186. if (isset($post['page'])) {
  3187. $page = $this->input->post('page', true);
  3188. $perpage = $this->input->post('perpage', true);
  3189. $timetk = $this->input->post('timetk', true);
  3190. $timetj = $this->input->post('timetj', true);
  3191. $label = $this->input->post('label', true);
  3192. $oldlabel = $this->input->post('oldlabel', true);
  3193. $timetk = strtotime($timetk);
  3194. $timetj = strtotime($timetj);
  3195. $where = "state=10 ";
  3196. if ($timetk && $timetj) {
  3197. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3198. }
  3199. if ($label) {
  3200. $where .= " and label = '$label'";
  3201. }
  3202. if ($oldlabel) {
  3203. $where .= " and oldlabel = '$oldlabel'";
  3204. }
  3205. //数据排序
  3206. $order_str = "time asc";
  3207. if (empty($page)) {
  3208. $start = 0;
  3209. $perpage = 1;
  3210. } else {
  3211. $start = ($page - 1) * $perpage;
  3212. }
  3213. //取得信息列表
  3214. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3215. foreach ($info_list as $key => $value) {
  3216. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3217. }
  3218. $total = $this->whlabel->find_count($where);
  3219. $pagenum = ceil($total / $perpage);
  3220. $over = $total - ($start + $perpage);
  3221. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3222. echo json_encode($rows);
  3223. exit;
  3224. }
  3225. $this->_Template('whlabel_change', $this->data);
  3226. }
  3227. //产品标签
  3228. public function _cpbqdc()
  3229. {
  3230. if (isset($_GET['excel'])) {
  3231. $where = "1=1";
  3232. //数据排序
  3233. $order_str = "id desc";
  3234. if (empty($page)) {
  3235. $start = 0;
  3236. $perpage = 1;
  3237. } else {
  3238. $start = ($page - 1) * $perpage;
  3239. }
  3240. $warehouse = $this->input->get('warehouse', true);
  3241. $state = $this->input->get('state', true);
  3242. $timetk = $this->input->get('timetkk', true);
  3243. $timetj = $this->input->get('timetjj', true);
  3244. $timetk = strtotime($timetk);
  3245. $timetj = strtotime($timetj);
  3246. if ($warehouse) {
  3247. $where .= " and warehouse = '$warehouse'";
  3248. }
  3249. if ($state || $state == 0) {
  3250. $where .= " and state = '$state'";
  3251. }
  3252. if ($timetk && $timetj) {
  3253. $where .= " and time > '$timetk' and time < '$timetj'";
  3254. }
  3255. //取得信息列表
  3256. $info_list = $this->whlabel->find_all($where, '*');
  3257. $rows = array();
  3258. $list = array();
  3259. foreach ($info_list as $key => $value) {
  3260. $rows[$value['time']] = $value; //所有数据sku
  3261. }
  3262. foreach ($rows as $value) {
  3263. $warehouse = $this->warehouse->read($value['warehouse']);
  3264. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3265. $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);
  3266. }
  3267. $title = "产品标签统计表";
  3268. $titlename = "<table border=1>
  3269. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3270. <tr align='center'>
  3271. <td>仓库</td>
  3272. <td>SKU</td>
  3273. <td>产品</td>
  3274. <td>入库时间</td>
  3275. <td>操作时间</td>
  3276. <td>备注</td>
  3277. <td>数量</td>
  3278. </tr>
  3279. </table>";
  3280. $filename = $title . ".xls";
  3281. $tail = "";
  3282. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3283. }
  3284. }
  3285. //进销存导出
  3286. public function _exceljxc()
  3287. {
  3288. $classid = $this->classid->sku();
  3289. $pm = $classid;
  3290. $typeclass = array();
  3291. $tc = $this->typeclass->find_all();
  3292. foreach ($tc as $v) {
  3293. $typeclass[$v['id']] = $v;
  3294. }
  3295. $prc = array();
  3296. $purchase = $this->purchase->find_all();
  3297. foreach ($purchase as $k => $v) {
  3298. $prc[$v['id']] = $v['title'];
  3299. }
  3300. if (isset($_GET['excel'])) {
  3301. $where = "sku != 'Preset'";
  3302. //数据排序
  3303. $order_str = "id desc";
  3304. if (empty($page)) {
  3305. $start = 0;
  3306. $perpage = 1;
  3307. } else {
  3308. $start = ($page - 1) * $perpage;
  3309. }
  3310. $category = $this->input->get('category', true);
  3311. $warehouse = $this->input->get('warehouse', true);
  3312. $excelid = $this->input->get('sid', true);
  3313. if ($category) {
  3314. $where .= " and features like '%-$category-%'";
  3315. }
  3316. if ($warehouse) {
  3317. $where .= " and warehouse = '$warehouse'";
  3318. }
  3319. $xzid = '';
  3320. if ($excelid) {
  3321. $excelid = explode(',', trim($excelid, ','));
  3322. foreach ($excelid as $key => $value) {
  3323. $xzid .= " id = " . $value . " or";
  3324. }
  3325. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3326. }
  3327. //取得信息列表
  3328. /**
  3329. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3330. $rows = array();$list = array();
  3331. foreach ($info_list as $key=>$value)
  3332. {
  3333. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3334. }
  3335. **/
  3336. $wt = array();
  3337. $whlabel_type = $this->whlabel_type->find_all();
  3338. foreach ($whlabel_type as $v) {
  3339. $wt[$v['id']] = $v['title'];
  3340. }
  3341. $wh = array();
  3342. $w = $this->warehouse->find_all('1=1', 'id,title');
  3343. foreach ($w as $v) {
  3344. $wh[$v['id']] = $v['title'];
  3345. }
  3346. $list = array();
  3347. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3348. foreach ($rows as $key => $value) {
  3349. if (isset($wt[$value['type']])) {
  3350. $rows[$key]['type'] = $wt[$value['type']];
  3351. } else {
  3352. $rows[$key]['type'] = '未设置';
  3353. }
  3354. $bm = '03';
  3355. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3356. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3357. $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');
  3358. $details = array();
  3359. $cpid = array();
  3360. $cpbz = array();
  3361. $c = 0;
  3362. $g = 0;
  3363. $x = 0;
  3364. $t = 0;
  3365. $s = 0;
  3366. $q = 0;
  3367. foreach ($sd as $k => $v) {
  3368. if ($v['state'] == 0) {
  3369. $c++;
  3370. if ($v['cpid'] != 0) {
  3371. $cpid[$v['cpid']] = $v['cpid'];
  3372. }
  3373. if ($v['cpbz'] != '') {
  3374. $cpbz[$v['cpbz']] = $v['cpbz'];
  3375. }
  3376. }
  3377. if ($v['state'] != 9) {
  3378. $g++;
  3379. }
  3380. if ($v['state'] == 1) {
  3381. $x++;
  3382. }
  3383. if ($v['state'] == 2) {
  3384. $t++;
  3385. }
  3386. if ($v['state'] == 8) {
  3387. $s++;
  3388. }
  3389. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3390. $q++;
  3391. }
  3392. $details[$v['details']] = $v['details'];
  3393. }
  3394. $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'] . '"');
  3395. $rows[$key]['details'] = implode("、", $details);
  3396. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3397. $number = $value['number'];
  3398. $ftime = time() - 15 * 24 * 3600;
  3399. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3400. $rows[$key]['number'] = $g;
  3401. $rows[$key]['c'] = $c;
  3402. $rows[$key]['x'] = $x;
  3403. $rows[$key]['t'] = $t;
  3404. $rows[$key]['s'] = $s;
  3405. $rows[$key]['q'] = $q;
  3406. $rows[$key]['z'] = $z;
  3407. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3408. $features = explode('-', trim($features, '-'));
  3409. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3410. // $pm = $classid;
  3411. // $jm = $classid;
  3412. // foreach($features as $k=>$v)
  3413. // {
  3414. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3415. // {
  3416. // if($typeclass[$v]['bm'] != '')
  3417. // {
  3418. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3419. // }
  3420. // }
  3421. // if($v != 0)
  3422. // {
  3423. // if(!isset($typeclass[$v]))
  3424. // {
  3425. // continue;
  3426. // }
  3427. // if(isset($pm[$typeclass[$v]['classid']]))
  3428. // {
  3429. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3430. // {
  3431. // $tz = explode('|',$typeclass[$v]['zh']);
  3432. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3433. // }
  3434. // else
  3435. // {
  3436. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3437. // }
  3438. // }
  3439. // if(isset($jm[$typeclass[$v]['classid']]))
  3440. // {
  3441. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3442. // }
  3443. // }
  3444. // }
  3445. // $jm = array_filter($jm);
  3446. // $rows[$key]['bs'] = implode("-",$jm);
  3447. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3448. // $zh = implode(" ",$pm);
  3449. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3450. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3451. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3452. // $rows[$key]['features'] = $zh;
  3453. }
  3454. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3455. $final_list = [];
  3456. foreach ($list as $k => $v) {
  3457. if (empty($v['sku'])) {
  3458. continue;
  3459. }
  3460. $final_list[] = [
  3461. "warehouse" => $v["warehouse"],
  3462. "purchase" => $v["purchase"],
  3463. "details" => $v["details"],
  3464. "cpid" => $v["cpid"],
  3465. "dbcontent" => $v["dbcontent"],
  3466. "sku" => $v["sku"],
  3467. "cs" => $v["bm"],
  3468. "bs" => $v["jm"],
  3469. "title" => $v["title"],
  3470. "features" => $v["pm"],
  3471. "cpbz" => $v["cpbz"],
  3472. "sm" => $v["sm"],
  3473. "type" => $v["type"],
  3474. "number" => $v["number"],
  3475. "c" => $v["c"],
  3476. "x" => $v["x"],
  3477. "t" => $v["t"],
  3478. "s" => $v["s"],
  3479. "q" => $v["q"],
  3480. "z" => $v["z"],
  3481. "weight" => $v['weight'],
  3482. ];
  3483. }
  3484. $title = "总进销存统计表";
  3485. $titlename = "<table border=1>
  3486. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3487. <tr align='center'>
  3488. <td>仓库</td>
  3489. <td>供应商</td>
  3490. <td>位置</td>
  3491. <td>库存编码</td>
  3492. <td>类目</td>
  3493. <td>SKU</td>
  3494. <td>用友编码</td>
  3495. <td>用友料号</td>
  3496. <td>商品名称</td>
  3497. <td>商品中文</td>
  3498. <td>产品备注</td>
  3499. <td>说明</td>
  3500. <td>类型</td>
  3501. <td>入库总量</td>
  3502. <td>库存数量</td>
  3503. <td>销售数量</td>
  3504. <td>退货数量</td>
  3505. <td>删除数量</td>
  3506. <td>其它操作</td>
  3507. <td>占单数量</td>
  3508. <td>重量(g)</td>
  3509. </tr>
  3510. </table>";
  3511. $filename = $title . ".xls";
  3512. $tail = "";
  3513. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3514. }
  3515. }
  3516. //入库导出
  3517. public function _excelr()
  3518. {
  3519. if (isset($_GET['excel'])) {
  3520. $category = $this->input->get('category', true);
  3521. $size = $this->input->get('size', true);
  3522. $grade = $this->input->get('grade', true);
  3523. $color = $this->input->get('color', true);
  3524. $lowe = $this->input->get('lowe', true);
  3525. $sku = $this->input->get('sku', true);
  3526. $warehouse = $this->input->get('warehouse', true);
  3527. $purchase = $this->input->get('purchase', true);
  3528. $ktime = $this->input->get('ktime', true);
  3529. $jtime = $this->input->get('jtime', true);
  3530. $ktime = strtotime($ktime);
  3531. $jtime = strtotime($jtime);
  3532. $where = "1=1";
  3533. $gj = "";
  3534. $ck = "";
  3535. if ($category) {
  3536. $where .= " and features like '%-$category-%'";
  3537. }
  3538. if ($size) {
  3539. $where .= " and features like '%-$size-%'";
  3540. }
  3541. if ($grade) {
  3542. $where .= " and features like '%-$grade-%'";
  3543. }
  3544. if ($color) {
  3545. $where .= " and features like '%-$color-%'";
  3546. }
  3547. if ($lowe) {
  3548. $where .= " and features like '%-$lowe-%'";
  3549. }
  3550. if ($warehouse) {
  3551. $where .= " and warehouse = '$warehouse'";
  3552. }
  3553. if ($purchase) {
  3554. $where .= " and purchase = '$purchase'";
  3555. }
  3556. if ($sku) {
  3557. $where .= " and sku = '$sku'";
  3558. }
  3559. if ($ktime && $jtime) {
  3560. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3561. }
  3562. //数据排序
  3563. $order_str = "id desc";
  3564. if (empty($page)) {
  3565. $start = 0;
  3566. $perpage = 1;
  3567. } else {
  3568. $start = ($page - 1) * $perpage;
  3569. }
  3570. $list = array();
  3571. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3572. foreach ($rows as $value) {
  3573. $ck = $this->warehouse->read($value['warehouse']);
  3574. $warehouse = $ck['title'];
  3575. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3576. $retreatwarehouse = $tkck['title'];
  3577. $gy = $this->purchase->read($value['purchase']);
  3578. $purchase = $gy['title'];
  3579. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3580. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3581. }
  3582. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3583. $titlename = "<table border=1>
  3584. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3585. <tr align='center'>
  3586. <td>仓库</td>
  3587. <td>SKU</td>
  3588. <td>产品</td>
  3589. <td>时间</td>
  3590. <td>数量</td>
  3591. </tr>
  3592. </table>";
  3593. $filename = $title . ".xls";
  3594. $tail = "";
  3595. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3596. }
  3597. }
  3598. //出库、退库导出
  3599. public function _excelct()
  3600. {
  3601. $classid = $this->classid->sku();
  3602. $pm = $classid;
  3603. $typeclass = array();
  3604. $tc = $this->typeclass->find_all();
  3605. foreach ($tc as $v) {
  3606. $typeclass[$v['id']] = $v;
  3607. }
  3608. $prc = array();
  3609. $purchase = $this->purchase->find_all();
  3610. foreach ($purchase as $k => $v) {
  3611. $prc[$v['id']] = $v['title'];
  3612. }
  3613. if (isset($_GET['excel'])) {
  3614. $wh = array();
  3615. $w = $this->warehouse->find_all('1=1', 'id,title');
  3616. foreach ($w as $v) {
  3617. $wh[$v['id']] = $v['title'];
  3618. }
  3619. $type = $this->input->get('excel', true);
  3620. $category = $this->input->get('category', true);
  3621. $size = $this->input->get('size', true);
  3622. $grade = $this->input->get('grade', true);
  3623. $color = $this->input->get('color', true);
  3624. $lowe = $this->input->get('lowe', true);
  3625. $sku = $this->input->get('sku', true);
  3626. $warehouse = $this->input->get('warehouse', true);
  3627. $lacetype = $this->input->get('lacetype', true);
  3628. $lacecolor = $this->input->get('lacecolor', true);
  3629. $density = $this->input->get('density', true);
  3630. $haircap = $this->input->get('haircap', true);
  3631. $purchase = $this->input->get('purchase', true);
  3632. $title = $this->input->get('title', true);
  3633. $state = $this->input->get('state', true);
  3634. $sid = $this->input->get('sid', true);
  3635. $ktime = $this->input->get('ktime', true);
  3636. $jtime = $this->input->get('jtime', true);
  3637. $ktime = strtotime($ktime);
  3638. $jtime = strtotime($jtime);
  3639. $where = "1=1";
  3640. $gj = "";
  3641. $ck = "";
  3642. if ($category) {
  3643. $where .= " and features like '%-$category-%'";
  3644. }
  3645. if ($size) {
  3646. $where .= " and features like '%-$size-%'";
  3647. }
  3648. if ($grade) {
  3649. $where .= " and features like '%-$grade-%'";
  3650. }
  3651. if ($color) {
  3652. $where .= " and features like '%-$color-%'";
  3653. }
  3654. if ($lowe) {
  3655. $where .= " and features like '%-$lowe-%'";
  3656. }
  3657. if ($warehouse) {
  3658. $where .= " and warehouse = '$warehouse'";
  3659. }
  3660. if ($purchase) {
  3661. $where .= " and purchase = '$purchase'";
  3662. }
  3663. if ($state) {
  3664. $where .= " and state = '$state'";
  3665. }
  3666. if ($lacetype) {
  3667. $where .= " and features like '%-$lacetype-%'";
  3668. }
  3669. if ($lacecolor) {
  3670. $where .= " and features like '%-$lacecolor-%'";
  3671. }
  3672. if ($density) {
  3673. $where .= " and features like '%-$density-%'";
  3674. }
  3675. if ($haircap) {
  3676. $where .= " and features like '%-$haircap-%'";
  3677. }
  3678. if ($title) {
  3679. $title = trim($title, ' ');
  3680. $title = trim($title, ' ');
  3681. $where .= " and title like '%$title%'";
  3682. }
  3683. if ($sku) {
  3684. $sku = trim($sku, ' ');
  3685. $sku = trim($sku, ' ');
  3686. $where .= " and sku like '%$sku%'";
  3687. }
  3688. if ($ktime && $jtime) {
  3689. if ($type == 1) {
  3690. $tl = '出库';
  3691. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3692. } else if ($type == 2) {
  3693. $tl = '退库';
  3694. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3695. } else if ($type == 3) {
  3696. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3697. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3698. } else if ($type == 4) {
  3699. $tl = '出库+零售';
  3700. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3701. } else if ($type == 5) {
  3702. $tl = '零售';
  3703. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3704. }
  3705. }
  3706. $sidwhere = '';
  3707. if ($sid) {
  3708. $sd = "";
  3709. $s = explode(',', trim($sid, ','));
  3710. foreach ($s as $value) {
  3711. $sd .= " id = " . $value . " or";
  3712. }
  3713. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3714. }
  3715. //数据排序
  3716. $order_str = "time desc";
  3717. if (empty($page)) {
  3718. $start = 0;
  3719. $perpage = 1;
  3720. } else {
  3721. $start = ($page - 1) * $perpage;
  3722. }
  3723. //$this->logic_ding->sendToDing("导出出入库分类数据".$where);
  3724. //取得信息列表
  3725. if ($type != 3 && $type != 5) {
  3726. if ($type == 1 || $type == 4) {
  3727. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3728. foreach ($info_list as $key => $value) {
  3729. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3730. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3731. $warehouse = $this->warehouse->read($value['warehouse']);
  3732. $info_list[$key]['warehouse'] = $warehouse['title'];
  3733. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3734. $features = explode('-', trim($features, '-'));
  3735. $pm = $classid;
  3736. foreach ($features as $k => $v) {
  3737. if ($v != 0) {
  3738. if (!isset($typeclass[$v])) {
  3739. continue;
  3740. }
  3741. if (isset($pm[$typeclass[$v]['classid']])) {
  3742. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3743. $tz = explode('|', $typeclass[$v]['zh']);
  3744. $pm[$typeclass[$v]['classid']] = $tz[0];
  3745. } else {
  3746. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3747. }
  3748. }
  3749. }
  3750. }
  3751. $zh = implode(" ", $pm);
  3752. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3753. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3754. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3755. $info_list[$key]['features'] = $zh;
  3756. }
  3757. $final_list = [];
  3758. foreach($info_list as $k=>$v){
  3759. $number = "";
  3760. if(!empty($v['orderinfo'])){
  3761. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3762. if(!empty($tmp_info['number'])){
  3763. $number = $tmp_info['number'];
  3764. }
  3765. }
  3766. $final_list[] = [
  3767. 'warehouse'=>$v['warehouse'],
  3768. 'purchase'=>$v['purchase'],
  3769. 'sku'=>$v['sku'],
  3770. 'title'=>$v['title'],
  3771. 'features'=>$v['features'],
  3772. 'label'=>$v['label'],
  3773. 'orderinfo'=>$v['orderinfo'],
  3774. 'number'=>$number,
  3775. 'waybill'=>$v['waybill'],
  3776. 'outk'=>$v['outk'],
  3777. ];
  3778. }
  3779. } else {
  3780. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3781. foreach ($info_list as $key => $value) {
  3782. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3783. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3784. $warehouse = $this->warehouse->read($value['warehouse']);
  3785. $info_list[$key]['warehouse'] = $warehouse['title'];
  3786. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3787. $features = explode('-', trim($features, '-'));
  3788. $pm = $classid;
  3789. foreach ($features as $k => $v) {
  3790. if ($v != 0) {
  3791. if (!isset($typeclass[$v])) {
  3792. continue;
  3793. }
  3794. if (isset($pm[$typeclass[$v]['classid']])) {
  3795. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3796. $tz = explode('|', $typeclass[$v]['zh']);
  3797. $pm[$typeclass[$v]['classid']] = $tz[0];
  3798. } else {
  3799. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3800. }
  3801. }
  3802. }
  3803. }
  3804. $zh = implode(" ", $pm);
  3805. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3806. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3807. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3808. $info_list[$key]['features'] = $zh;
  3809. }
  3810. $final_list = [];
  3811. foreach($info_list as $k=>$v){
  3812. $number = "";
  3813. if(!empty($v['orderinfo'])){
  3814. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3815. if(!empty($tmp_info['number'])){
  3816. $number = $tmp_info['number'];
  3817. }
  3818. }
  3819. $final_list[] = [
  3820. 'warehouse'=>$v['warehouse'],
  3821. 'purchase'=>$v['purchase'],
  3822. 'sku'=>$v['sku'],
  3823. 'title'=>$v['title'],
  3824. 'features'=>$v['features'],
  3825. 'label'=>$v['label'],
  3826. 'orderinfo'=>$v['orderinfo'],
  3827. 'number'=>$number,
  3828. 'waybill'=>$v['waybill'],
  3829. 'retreat'=>$v['retreat'],
  3830. ];
  3831. }
  3832. }
  3833. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3834. $titlename = "<table border=1>
  3835. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3836. <tr align='center'>
  3837. <td>仓库</td>
  3838. <td>供应商</td>
  3839. <td>SKU</td>
  3840. <td>商品名称</td>
  3841. <td>商品中文</td>
  3842. <td>标签</td>
  3843. <td>订单号</td>
  3844. <td>订单编码</td>
  3845. <td>运单号</td>
  3846. <td>" . $tl . "时间(中国时间)</td>
  3847. </tr>
  3848. </table>";
  3849. $filename = $title . ".xls";
  3850. $tail = "";
  3851. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3852. } else if ($type == 5) {
  3853. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3854. //$this->logic_ding->sendToDing("导出出入库分类数据".json_encode($info_list));
  3855. foreach ($info_list as $key => $value) {
  3856. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3857. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3858. $warehouse = $this->warehouse->read($value['warehouse']);
  3859. $info_list[$key]['warehouse'] = $warehouse['title'];
  3860. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3861. $features = explode('-', trim($features, '-'));
  3862. $pm = $classid;
  3863. foreach ($features as $k => $v) {
  3864. if ($v != 0) {
  3865. if (!isset($typeclass[$v])) {
  3866. continue;
  3867. }
  3868. if (isset($pm[$typeclass[$v]['classid']])) {
  3869. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3870. $tz = explode('|', $typeclass[$v]['zh']);
  3871. $pm[$typeclass[$v]['classid']] = $tz[0];
  3872. } else {
  3873. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3874. }
  3875. }
  3876. }
  3877. }
  3878. $zh = implode(" ", $pm);
  3879. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3880. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3881. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3882. $info_list[$key]['features'] = $zh;
  3883. }
  3884. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3885. $titlename = "<table border=1>
  3886. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3887. <tr align='center'>
  3888. <td>仓库</td>
  3889. <td>供应商</td>
  3890. <td>SKU</td>
  3891. <td>商品名称</td>
  3892. <td>商品中文</td>
  3893. <td>标签</td>
  3894. <td>" . $tl . "时间(中国时间)</td>
  3895. </tr>
  3896. </table>";
  3897. $filename = $title . ".xls";
  3898. $tail = "";
  3899. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3900. } else {
  3901. /**
  3902. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3903. $rows = array();$list = array();
  3904. foreach ($info_list as $key=>$value)
  3905. {
  3906. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3907. }
  3908. **/
  3909. $wh = array();
  3910. $w = $this->warehouse->find_all('1=1', 'id,title');
  3911. foreach ($w as $v) {
  3912. $wh[$v['id']] = $v['title'];
  3913. }
  3914. $wt = array();
  3915. $whlabel_type = $this->whlabel_type->find_all();
  3916. foreach ($whlabel_type as $v) {
  3917. $wt[$v['id']] = $v['title'];
  3918. }
  3919. $classid = $this->classid->sku();
  3920. $list = array();
  3921. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3922. foreach ($rows as $key => $value) {
  3923. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3924. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3925. $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');
  3926. $details = array();
  3927. $cpid = array();
  3928. $cpbz = array();
  3929. $c = 0;
  3930. $g = 0;
  3931. $x = 0;
  3932. $t = 0;
  3933. $s = 0;
  3934. $q = 0;
  3935. foreach ($sd as $k => $v) {
  3936. if ($v['state'] == 0) {
  3937. $c++;
  3938. }
  3939. if ($v['state'] != 9) {
  3940. $g++;
  3941. }
  3942. if ($v['outk'] > 1) {
  3943. $x++;
  3944. }
  3945. if ($v['retreat'] > 0) {
  3946. $t++;
  3947. }
  3948. if ($v['state'] == 8) {
  3949. $s++;
  3950. }
  3951. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3952. $q++;
  3953. }
  3954. $details[$v['details']] = $v['details'];
  3955. if ($v['cpid'] != 0) {
  3956. $cpid[$v['cpid']] = $v['cpid'];
  3957. }
  3958. if ($v['cpbz'] != '') {
  3959. $cpbz[$v['cpbz']] = $v['cpbz'];
  3960. }
  3961. }
  3962. if (isset($wt[$value['type']])) {
  3963. $rows[$key]['type'] = $wt[$value['type']];
  3964. } else {
  3965. $rows[$key]['type'] = '未设置';
  3966. }
  3967. $rows[$key]['details'] = implode("、", $details);
  3968. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3969. $ftime = time() - 15 * 24 * 3600;
  3970. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3971. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3972. $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);
  3973. $rows[$key]['c'] = $c;
  3974. $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);
  3975. $rows[$key]['t'] = $t;
  3976. $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'] . '"');
  3977. $rows[$key]['z'] = $z;
  3978. // $jm = $classid;
  3979. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3980. $features = explode('-', trim($features, '-'));
  3981. // $pm = $classid;
  3982. // foreach ($features as $k => $v) {
  3983. // if ($v != 0) {
  3984. // if (!isset($typeclass[$v])) {
  3985. // continue;
  3986. // }
  3987. // if (isset($pm[$typeclass[$v]['classid']])) {
  3988. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3989. // $tz = explode('|', $typeclass[$v]['zh']);
  3990. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3991. // } else {
  3992. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3993. // }
  3994. // if (isset($jm[$typeclass[$v]['classid']])) {
  3995. // if ($typeclass[$v]['jm']) {
  3996. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3997. // }
  3998. // }
  3999. // }
  4000. // }
  4001. // }
  4002. // $zh = implode(" ", $pm);
  4003. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4004. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4005. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4006. // $rows[$key]['features'] = $zh;
  4007. // $jm = array_filter($jm); //去除空值
  4008. // $jm = implode("-", $jm);
  4009. // $rows[$key]['jm'] = $jm;
  4010. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4011. }
  4012. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4013. // echo "<pre>";
  4014. // print_r($tmp_list);
  4015. // die;
  4016. $final_list =[];
  4017. foreach($tmp_list as $k=>$v){
  4018. $final_list[] = [
  4019. "warehouse"=>$v['warehouse'],
  4020. "purchase"=>$v['purchase'],
  4021. "details"=>$v['details'],
  4022. "cpid"=>$v['cpid'],
  4023. "sku"=>$v['sku'],
  4024. "title"=>$v['title'],
  4025. "features"=>$v['pm'],
  4026. "cpbz"=>$v['cpbz'],
  4027. "sm"=>$v['sm'],
  4028. "type"=>$v['type'],
  4029. "g"=>$v["g"],
  4030. "c"=>$v["c"],
  4031. "x"=>$v["x"],
  4032. "t"=>$v["t"],
  4033. "z"=>$v["z"],
  4034. "jm"=>$v["jm"],
  4035. "weight"=>$v["weight"],
  4036. "asd"=>$v["asd"],
  4037. ];
  4038. }
  4039. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4040. $titlename = "<table border=1>
  4041. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4042. <tr align='center'>
  4043. <td>仓库</td>
  4044. <td>供应商</td>
  4045. <td>位置</td>
  4046. <td>库存编码</td>
  4047. <td>SKU</td>
  4048. <td>商品名称</td>
  4049. <td>商品中文</td>
  4050. <td>产品备注</td>
  4051. <td>说明</td>
  4052. <td>类型</td>
  4053. <td>入库总量</td>
  4054. <td>库存数量</td>
  4055. <td>销售数量</td>
  4056. <td>退货数量</td>
  4057. <td>占单数量</td>
  4058. <td>料号</td>
  4059. <td>重量</td>
  4060. <td>类目</td>
  4061. </tr>
  4062. </table>";
  4063. $filename = $title . ".xls";
  4064. $tail = "";
  4065. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4066. }
  4067. }
  4068. }
  4069. //出库+入库数据整合
  4070. public function _excelcr()
  4071. {
  4072. if (isset($_GET['excel'])) {
  4073. $type = $this->input->get('excel', true);
  4074. $category = $this->input->get('category', true);
  4075. $size = $this->input->get('size', true);
  4076. $grade = $this->input->get('grade', true);
  4077. $color = $this->input->get('color', true);
  4078. $lowe = $this->input->get('lowe', true);
  4079. $sku = $this->input->get('sku', true);
  4080. $warehouse = $this->input->get('warehouse', true);
  4081. $purchase = $this->input->get('purchase', true);
  4082. $state = $this->input->get('state', true);
  4083. $sid = $this->input->get('sid', true);
  4084. $ktime = $this->input->get('ktime', true);
  4085. $jtime = $this->input->get('jtime', true);
  4086. $ktime = strtotime($ktime);
  4087. $jtime = strtotime($jtime);
  4088. $where = "1=1";
  4089. $gj = "";
  4090. $ck = "";
  4091. if ($category) {
  4092. $where .= " and features like '%-$category-%'";
  4093. }
  4094. if ($size) {
  4095. $where .= " and features like '%-$size-%'";
  4096. }
  4097. if ($grade) {
  4098. $where .= " and features like '%-$grade-%'";
  4099. }
  4100. if ($color) {
  4101. $where .= " and features like '%-$color-%'";
  4102. }
  4103. if ($lowe) {
  4104. $where .= " and features like '%-$lowe-%'";
  4105. }
  4106. if ($warehouse) {
  4107. $where .= " and warehouse = '$warehouse'";
  4108. }
  4109. if ($purchase) {
  4110. $where .= " and purchase = '$purchase'";
  4111. }
  4112. if ($state) {
  4113. $where .= " and state = '$state'";
  4114. }
  4115. if ($sku) {
  4116. $where .= " and sku like '%$sku%'";
  4117. }
  4118. if ($ktime && $jtime) {
  4119. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4120. }
  4121. $sidwhere = '';
  4122. if ($sid) {
  4123. $sd = "";
  4124. $s = explode(',', trim($sid, ','));
  4125. foreach ($s as $value) {
  4126. $sd .= " id = " . $value . " or";
  4127. }
  4128. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4129. }
  4130. //取得信息列表
  4131. $timeread = $ktime;
  4132. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4133. $timelist = array();
  4134. for ($i = 0; $i < $timenum; $i++) {
  4135. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4136. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4137. }
  4138. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4139. //echo "<pre>";
  4140. //print_r($info_list);
  4141. //exit();
  4142. $rows = array();
  4143. $list = array();
  4144. foreach ($info_list as $key => $value) {
  4145. $thistime = $timelist;
  4146. if (isset($rows[strtolower($value['sku'])])) {
  4147. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4148. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4149. }
  4150. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4151. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4152. }
  4153. } else {
  4154. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4155. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4156. }
  4157. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4158. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4159. }
  4160. $rows[strtolower($value['sku'])] = $thistime;
  4161. }
  4162. }
  4163. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4164. <head>
  4165. <!--[if gte mso 9]><xml>
  4166. <x:ExcelWorkbook>
  4167. <x:ExcelWorksheets>
  4168. <x:ExcelWorksheet>
  4169. <x:Name>EXCEL</x:Name>
  4170. <x:WorksheetOptions>
  4171. <x:Print>
  4172. <x:ValidPrinterInfo />
  4173. </x:Print>
  4174. </x:WorksheetOptions>
  4175. </x:ExcelWorksheet>
  4176. </x:ExcelWorksheets>
  4177. </x:ExcelWorkbook>
  4178. </xml>
  4179. <![endif]-->
  4180. </head><body>";
  4181. $str .= "<table border=1><tr><td>SKU</td>";
  4182. foreach ($timelist as $k => $v) {
  4183. $str .= "<td>" . $k . "出库</td>";
  4184. $str .= "<td>" . $k . "入库</td>";
  4185. }
  4186. $str .= "</tr></table>";
  4187. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4188. foreach ($rows as $key => $val) {
  4189. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4190. foreach ($val as $k => $v) {
  4191. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4192. if ($val[$k]['r'] > 0) {
  4193. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4194. } else {
  4195. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4196. }
  4197. }
  4198. $str .= "</tr>";
  4199. }
  4200. $str .= "</table>";
  4201. $str .= "</body></html>";
  4202. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4203. header("Content-type: application/octet-stream");
  4204. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4205. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4206. header("Pragma: no-cache");
  4207. header("Expires: 0");
  4208. exit($str);
  4209. }
  4210. }
  4211. //数量调整模板导出
  4212. public function _presetout()
  4213. {
  4214. if (isset($_GET['excel'])) {
  4215. $where = "sku != 'Preset' and purchase != 0";
  4216. //数据排序
  4217. $order_str = "id desc";
  4218. if (empty($page)) {
  4219. $start = 0;
  4220. $perpage = 1;
  4221. } else {
  4222. $start = ($page - 1) * $perpage;
  4223. }
  4224. //取得信息列表
  4225. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4226. $rows = array();
  4227. $list = array();
  4228. foreach ($info_list as $value) {
  4229. $warehouse = $this->warehouse->read($value['warehouse']);
  4230. $number = $value['number'];
  4231. $ftime = time() - 15 * 24 * 3600;
  4232. $purchase = $this->purchase->read($value['purchase']);
  4233. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4234. }
  4235. $title = "库存模板";
  4236. $titlename = "<table border=1>
  4237. <tr align='center'>
  4238. <td>仓库</td>
  4239. <td>供应商编码</td>
  4240. <td>SKU</td>
  4241. <td>增减数量(正数或负数)</td>
  4242. <td>增减备注</td>
  4243. <td>扣减方式:0减少库存1删除库存</td>
  4244. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4245. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4246. </tr>
  4247. </table>";
  4248. $filename = $title . ".xls";
  4249. $tail = "";
  4250. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4251. }
  4252. }
  4253. //数量调整模板导入
  4254. public function _presetedit()
  4255. {
  4256. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4257. $config['upload_path'] = '.' . $dir;
  4258. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4259. $config['allowed_types'] = 'xls|xlsx|csv';
  4260. $config['max_size'] = 10240;
  4261. $this->load->library('upload', $config);
  4262. $this->upload->initialize($config);
  4263. if ($this->upload->do_upload('userfile')) {
  4264. $full_path = $dir . $this->upload->data('file_name');
  4265. $fileName = '.' . $full_path;
  4266. if (!file_exists($fileName)) {
  4267. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4268. exit;
  4269. } else {
  4270. require_once "./data/excel/PHPExcel/IOFactory.php";
  4271. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4272. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4273. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4274. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4275. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4276. ++$column; //如果列数大于26行
  4277. $list = array();
  4278. for ($i = 2; $i <= $row; $i++) // 行数循环
  4279. {
  4280. $data = array();
  4281. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4282. {
  4283. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4284. }
  4285. $list[] = $data;
  4286. }
  4287. }
  4288. $i = 0;
  4289. $j = 0;
  4290. $ed = array();
  4291. foreach ($list as $key => $value) {
  4292. $time = time();
  4293. if ($value['0'] == "") {
  4294. continue;
  4295. }
  4296. $warehouse = $this->warehouse->get_title($value['0']);
  4297. $purchase = $this->purchase->get_bm($value['1']);
  4298. $sku = $value['2'];
  4299. $num = $value['3']; //调整数量
  4300. $text = $value['4']; //扣减说明
  4301. $type = $value['5']; //调整方式0扣减1删除
  4302. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4303. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4304. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4305. if (!$purchase) //如果没有这个SKU
  4306. {
  4307. $ed[] = array($purchase . '-不存在此供应商编码');
  4308. $j++;
  4309. continue;
  4310. }
  4311. if (!$d) //如果没有这个SKU
  4312. {
  4313. $ed[] = array($sku . '-库存中不存在此SKU');
  4314. $j++;
  4315. continue;
  4316. }
  4317. if (!isset($warehouse['id'])) {
  4318. $ed[] = array($sku . '-仓库名错误!');
  4319. $j++;
  4320. continue;
  4321. }
  4322. if ($type != '0' && $type != '1') {
  4323. $ed[] = array($sku . '-扣减方式填写错误!');
  4324. $j++;
  4325. continue;
  4326. }
  4327. if ($num < 0) //扣减库存
  4328. {
  4329. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4330. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4331. $j++;
  4332. continue;
  4333. }
  4334. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4335. if (count($data) < abs($num)) {
  4336. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4337. $j++;
  4338. continue;
  4339. }
  4340. if ($type == 0) //如果扣减方式为 扣减库存
  4341. {
  4342. for ($i = 0; $i < abs($num); $i++) {
  4343. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4344. }
  4345. } else if ($type == 1) {
  4346. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4347. if (count($zt) > 0) {
  4348. $ed[] = array($sku . '-有在途库存无法删除!');
  4349. $j++;
  4350. continue;
  4351. }
  4352. for ($i = 0; $i < abs($num); $i++) {
  4353. $this->whlabel->remove($data[$i]['id']);
  4354. }
  4355. }
  4356. } else if ($num > 0) //增加库存
  4357. {
  4358. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4359. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4360. $j++;
  4361. continue;
  4362. }
  4363. $post['sku'] = $d['sku'];
  4364. $post['shop'] = $d['shop'];
  4365. $post['warehouse'] = $warehouse['id'];
  4366. $post['purchase'] = $purchase['id'];
  4367. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4368. $post['state'] = 0;
  4369. $post['title'] = $d['title'];
  4370. $post['number'] = $d['number'];
  4371. $post['features'] = $d['features'];
  4372. $post['enter'] = $time;
  4373. $post['time'] = $time; //操作时间
  4374. $post['rktype'] = $rktype;
  4375. for ($i = 0; $i < $num; $i++) {
  4376. $post['label'] = time() . rand(100, 999) . $i;
  4377. $this->whlabel->insert($post);
  4378. }
  4379. }
  4380. sleep(1); //防止入库时间一样,需要延迟1秒
  4381. }
  4382. if ($j > 0) {
  4383. $tt = date('Ymd', time());
  4384. $title = '库存导入错误信息-' . $tt;
  4385. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4386. $tail = "\n";
  4387. $filename = $title . ".xls";
  4388. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4389. $dir = '/data/excel/' . $time . '/';
  4390. $file_name = 'error_' . $time . rand(1000, 9999);
  4391. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4392. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4393. fwrite($myfile, $ecl);
  4394. fclose($myfile);
  4395. $error = $dir . $file_name . '.xls';
  4396. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4397. exit;
  4398. } else {
  4399. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4400. exit;
  4401. }
  4402. }
  4403. }
  4404. //笛卡儿积
  4405. function cp($ps, $sets, $list)
  4406. {
  4407. $result = array();
  4408. $j = 0;
  4409. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4410. if ($i == 0) {
  4411. $result = $sets[$i];
  4412. }
  4413. $tmp = array();
  4414. foreach ($result as $res) {
  4415. foreach ($sets[$i + 1] as $set) {
  4416. $tmp[] = $res . ',' . $set;
  4417. }
  4418. }
  4419. $result = $tmp;
  4420. }
  4421. $this->db->trans_begin();
  4422. foreach ($result as $v) {
  4423. $post = array();
  4424. $title = "";
  4425. $num = "";
  4426. $data = explode(',', $v);
  4427. for ($i = 0; $i < count($list); $i++) {
  4428. $post[$list[$i]] = $data[$i];
  4429. $typeclass = $this->typeclass->read($data[$i]);
  4430. $title = $title . $typeclass['title'] . " ";
  4431. if ($data[$i] != 0) {
  4432. $num .= $data[$i]; //所有数据ID拼接
  4433. }
  4434. }
  4435. foreach ($ps as $kp => $vp) {
  4436. $post[$kp] = $vp;
  4437. }
  4438. $post['number'] = $num;
  4439. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4440. if ($info_list) {
  4441. $j++;
  4442. } else {
  4443. $skunum = $this->whlabel->find_count();
  4444. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4445. $post['title'] = rtrim($title, ' ');
  4446. $this->whlabel->insert($post);
  4447. }
  4448. }
  4449. if ($this->db->trans_status() === FALSE) {
  4450. $this->db->trans_commit();
  4451. return NULL;
  4452. } else {
  4453. $this->db->trans_commit();
  4454. return $j;
  4455. }
  4456. }
  4457. public function _kj($arg_array)
  4458. {
  4459. if (isset($_POST['sku'])) {
  4460. $time = time();
  4461. $sku = $this->input->post('sku', true);
  4462. $warehouse = $this->input->post('warehouse', true);
  4463. $num = $this->input->post('num', true);
  4464. $text = $this->input->post('text', true);
  4465. $purchase = $this->input->post('purchase', true);
  4466. $cktype = $this->input->post('cktype', true);
  4467. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4468. if ($cktype != 1 && $text == '') {
  4469. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4470. exit;
  4471. }
  4472. if ($num > count($order)) {
  4473. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4474. exit;
  4475. } else {
  4476. for ($i = 0; $i < $num; $i++) {
  4477. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4478. }
  4479. }
  4480. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4481. exit;
  4482. }
  4483. $uid = $this->whlabel->read($arg_array[0]);
  4484. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4485. $this->data['data'] = $uid;
  4486. $this->_Template('whlabel_kj', $this->data);
  4487. }
  4488. public function _summary($arg_array)
  4489. {
  4490. $prc = array();
  4491. $purchase = $this->purchase->find_all();
  4492. foreach ($purchase as $k => $v) {
  4493. $prc[$v['id']] = $v['title'];
  4494. }
  4495. if (isset($_GET['excel'])) {
  4496. $ktime = $this->input->get('ktime', true);
  4497. $jtime = $this->input->get('jtime', true);
  4498. $ktime = strtotime($ktime);
  4499. $jtime = strtotime($jtime);
  4500. $where = "1=1";
  4501. if ($ktime && $jtime) {
  4502. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4503. }
  4504. //数据排序
  4505. $order_str = "time desc";
  4506. if (empty($page)) {
  4507. $start = 0;
  4508. $perpage = 1;
  4509. } else {
  4510. $start = ($page - 1) * $perpage;
  4511. }
  4512. //取得信息列表
  4513. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4514. foreach ($info_list as $key => $value) {
  4515. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4516. $warehouse = $this->warehouse->read($value['warehouse']);
  4517. $info_list[$key]['warehouse'] = $warehouse['title'];
  4518. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4519. $details = array();
  4520. $cpid = array();
  4521. foreach ($x as $k => $v) {
  4522. if ($v['details'] != '') {
  4523. $details[$v['details']] = $v['details'];
  4524. }
  4525. if ($v['cpid'] != 0) {
  4526. $cpid[$v['cpid']] = $v['cpid'];
  4527. }
  4528. }
  4529. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4530. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4531. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4532. $info_list[$key]['s'] = $s;
  4533. $info_list[$key]['x'] = count($x);
  4534. }
  4535. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4536. $titlename = "<table border=1>
  4537. <tr align='center'>
  4538. <td>仓库</td>
  4539. <td>供应商</td>
  4540. <td>出库位置</td>
  4541. <td>出库编码</td>
  4542. <td>SKU</td>
  4543. <td>产品名</td>
  4544. <td>总剩余库存</td>
  4545. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4546. </tr>
  4547. </table>";
  4548. $filename = $title . ".xls";
  4549. $tail = "";
  4550. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4551. }
  4552. }
  4553. //usps发货清单
  4554. public function _manifest()
  4555. {
  4556. if (isset($_POST['manifest'])) {
  4557. $wltext = $this->input->post('wltext', true);
  4558. $time = time() - 16 * 3600;
  4559. $ptime = strtotime(date('Y-m-d', $time));
  4560. $waybill = array();
  4561. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4562. foreach ($fullorder as $v) {
  4563. $waybill[$v['waybill']] = $v['waybill'];
  4564. }
  4565. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4566. foreach ($fullordersmt as $v) {
  4567. $waybill[$v['waybill']] = $v['waybill'];
  4568. }
  4569. $wltext = explode(';', $wltext);
  4570. foreach ($wltext as $v) {
  4571. if (isset($waybill[$v])) {
  4572. unset($waybill[$v]);
  4573. }
  4574. }
  4575. $data = $this->usps->get_manifest($waybill);
  4576. if (isset($data['Description'])) {
  4577. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4578. exit;
  4579. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4580. $bctime = date('Ymd', time());
  4581. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4582. echo json_encode(array('msg' => $pdf, 'success' => true));
  4583. exit;
  4584. } else {
  4585. echo json_encode(array('msg' => $data, 'success' => false));
  4586. exit;
  4587. }
  4588. }
  4589. }
  4590. public function _pdf($pdf, $title, $bctime)
  4591. {
  4592. $pdf_path = './data/pdf/' . $bctime . '/';
  4593. $file_base64 = $pdf;
  4594. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4595. $file_base64 = base64_decode($file_base64);
  4596. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4597. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4598. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4599. }
  4600. /**
  4601. *
  4602. *
  4603. *
  4604. 进销存占单异常索引
  4605. *
  4606. *
  4607. *
  4608. **/
  4609. public function _abnormal()
  4610. {
  4611. $post = $this->input->post(NULL, TRUE);
  4612. if (isset($post['page'])) {
  4613. $page = $this->input->post('page', true);
  4614. $perpage = $this->input->post('perpage', true);
  4615. $sku = $this->input->post('sku', true);
  4616. $where = "1=1";
  4617. //数据排序
  4618. $order_str = "id desc";
  4619. if (empty($page)) {
  4620. $start = 0;
  4621. $perpage = 1;
  4622. } else {
  4623. $start = ($page - 1) * $perpage;
  4624. }
  4625. //取得信息列表
  4626. $info_list = $this->whlabel->find_all($where, '*');
  4627. $rows = array();
  4628. $list = array();
  4629. foreach ($info_list as $key => $value) {
  4630. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4631. }
  4632. foreach ($rows as $value) {
  4633. $warehouse = $this->warehouse->read($value['warehouse']);
  4634. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4635. $number = $value['number'];
  4636. $ftime = time() - 15 * 24 * 3600;
  4637. if ($value['shop'] != '') {
  4638. $shop = $value['shop'];
  4639. $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');
  4640. $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');
  4641. $order = array_merge($orderdlz, $ordersmt);
  4642. $od = 0;
  4643. $a = '';
  4644. $orid = '';
  4645. foreach ($order as $v) {
  4646. $or = explode('|', ltrim($v['whlabel'], '|'));
  4647. for ($i = 0; $i < count($or); $i++) {
  4648. $orod = explode('-', $or[$i]);
  4649. if ($orod[0] == $number) {
  4650. $od += $orod[1];
  4651. }
  4652. }
  4653. $orid .= $v['number'] . '-';
  4654. }
  4655. } else {
  4656. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4657. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4658. $order = array_merge($orderdlz, $ordersmt);
  4659. $od = 0;
  4660. $a = '';
  4661. $orid = '';
  4662. $qt = array();
  4663. foreach ($order as $v) {
  4664. $or = explode('|', ltrim($v['whlabel'], '|'));
  4665. for ($i = 0; $i < count($or); $i++) {
  4666. $orod = explode('-', $or[$i]);
  4667. if ($orod[0] == $number) {
  4668. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4669. if ($czzs > 0) {
  4670. if (isset($qt[$v['shop']])) {
  4671. if ($qt[$v['shop']] < $orod[1]) {
  4672. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4673. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4674. } else {
  4675. $qt[$v['shop']] -= $orod[1];
  4676. }
  4677. } else {
  4678. $qt[$v['shop']] = $czzs;
  4679. }
  4680. } else {
  4681. $od += $orod[1];
  4682. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4683. }
  4684. }
  4685. }
  4686. }
  4687. }
  4688. $z = $od . '(' . $orid . ')'; //查看订单号
  4689. //$z = $od;
  4690. if ($od > $c) {
  4691. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4692. }
  4693. }
  4694. $listdata = array_slice($list, $start, $perpage);
  4695. $total = count($list);
  4696. $pagenum = ceil($total / $perpage);
  4697. $over = $total - ($start + $perpage);
  4698. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4699. echo json_encode($rows);
  4700. exit;
  4701. }
  4702. $this->_Template('whlabel_abnormal', $this->data);
  4703. }
  4704. /**
  4705. *
  4706. *
  4707. *
  4708. 进销存占单异常索引
  4709. *
  4710. *
  4711. *
  4712. **/
  4713. public function _error()
  4714. {
  4715. $post = $this->input->post(NULL, TRUE);
  4716. if (isset($post['page'])) {
  4717. $page = $this->input->post('page', true);
  4718. $perpage = $this->input->post('perpage', true);
  4719. $sku = $this->input->post('sku', true);
  4720. $warehouse = $this->input->post('warehouse', true);
  4721. $ktime = $this->input->post('ktime', true);
  4722. $jtime = $this->input->post('jtime', true);
  4723. $ktime = strtotime($ktime);
  4724. $jtime = strtotime($jtime);
  4725. $where = "sku != 'Preset'";
  4726. $gj = '';
  4727. if ($sku) {
  4728. $where .= " and sku like '%$sku%'";
  4729. } else {
  4730. if ($ktime && $jtime) {
  4731. $gj = " and time > '$ktime' and time < '$jtime'";
  4732. }
  4733. }
  4734. if ($warehouse) {
  4735. $where .= " and warehouse = '$warehouse'";
  4736. }
  4737. //数据排序
  4738. $order_str = "id desc";
  4739. if (empty($page)) {
  4740. $start = 0;
  4741. $perpage = 1;
  4742. } else {
  4743. $start = ($page - 1) * $perpage;
  4744. }
  4745. //取得信息列表
  4746. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4747. $rows = array();
  4748. $list = array();
  4749. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4750. // foreach ($info_list as $value)
  4751. // {
  4752. // $warehouse = $this->warehouse->read($value['warehouse']);
  4753. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4754. // $number = $value['number'];$ftime = time()-15*24*3600;
  4755. // if($c < 1)
  4756. // {
  4757. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4758. // }
  4759. // }
  4760. $warehouse_list = $this->warehouse->find_all();
  4761. $warehouse_list = array_column($warehouse_list, null, 'id');
  4762. foreach ($info_list as $value) {
  4763. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4764. 'title' => "",
  4765. ];
  4766. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4767. $number = $value['number'];
  4768. $ftime = time() - 15 * 24 * 3600;
  4769. if ($c < 1) {
  4770. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4771. }
  4772. }
  4773. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4774. // $query = $this->db->query($sql);
  4775. // $info_list = $query->result_array();
  4776. // $sql_two = "select title,id from crowd_warehouse";
  4777. // $query_two = $this->db->query($sql_two);
  4778. // $warehouse_list = $query_two->result_array();
  4779. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4780. // foreach ($info_list as $value)
  4781. // {
  4782. // if(isset($warehouse_arr[$value['warehouse']])){
  4783. // $warehouse = $warehouse_arr[$value['warehouse']];
  4784. // }else{
  4785. // $warehouse = [
  4786. // 'id'=>0,
  4787. // 'title'=>"异常",
  4788. // ];
  4789. // }
  4790. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4791. // $number = $value['number'];$ftime = time()-15*24*3600;
  4792. // if($c < 1)
  4793. // {
  4794. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4795. // }
  4796. // }
  4797. $listdata = array_slice($list, $start, $perpage);
  4798. $total = count($list);
  4799. $pagenum = ceil($total / $perpage);
  4800. $over = $total - ($start + $perpage);
  4801. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4802. echo json_encode($rows);
  4803. exit;
  4804. }
  4805. if (isset($post['s'])) {
  4806. $id_arr = $this->input->post('s');
  4807. $id_arr = explode(',', trim($id_arr, ','));
  4808. if (!$id_arr) {
  4809. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4810. exit;
  4811. }
  4812. //循环删除记录
  4813. foreach ($id_arr as $v) {
  4814. $dd = $this->whlabel->read($v);
  4815. if (!isset($dd['id'])) {
  4816. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4817. exit;
  4818. }
  4819. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4820. if (isset($zt[0])) {
  4821. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4822. exit;
  4823. }
  4824. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4825. foreach ($deldd as $vv) {
  4826. $this->whlabel->remove($vv['id']);
  4827. }
  4828. }
  4829. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4830. exit;
  4831. }
  4832. $this->_Template('whlabel_error', $this->data);
  4833. }
  4834. public function _errorexcel()
  4835. {
  4836. $post = $this->input->post(NULL, TRUE);
  4837. if (isset($_GET['page'])) {
  4838. $page = $this->input->get('page', true);
  4839. $perpage = $this->input->get('perpage', true);
  4840. $sku = $this->input->get('sku', true);
  4841. $warehouse = $this->input->get('warehouse', true);
  4842. $ktime = $this->input->get('ktime', true);
  4843. $jtime = $this->input->get('jtime', true);
  4844. $ktime = strtotime($ktime);
  4845. $jtime = strtotime($jtime);
  4846. $where = "sku != 'Preset'";
  4847. $gj = '';
  4848. if ($sku) {
  4849. $where .= " and sku like '%$sku%'";
  4850. } else {
  4851. if ($ktime && $jtime) {
  4852. $gj = " and time > '$ktime' and time < '$jtime'";
  4853. }
  4854. }
  4855. if ($warehouse) {
  4856. $where .= " and warehouse = '$warehouse'";
  4857. }
  4858. //数据排序
  4859. $order_str = "id desc";
  4860. if (empty($page)) {
  4861. $start = 0;
  4862. $perpage = 1;
  4863. } else {
  4864. $start = ($page - 1) * $perpage;
  4865. }
  4866. //取得信息列表
  4867. $rows = array();
  4868. $list = array();
  4869. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4870. foreach ($info_list as $value) {
  4871. $warehouse = $this->warehouse->read($value['warehouse']);
  4872. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4873. $number = $value['number'];
  4874. $ftime = time() - 15 * 24 * 3600;
  4875. if ($c < 1) {
  4876. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4877. }
  4878. }
  4879. $title = "0库存汇总";
  4880. $titlename = "<table border=1>
  4881. <tr align='center'>
  4882. <td>仓库</td>
  4883. <td>SKU</td>
  4884. <td>产品</td>
  4885. <td>当前库存</td>
  4886. </tr>
  4887. </table>";
  4888. $filename = $title . ".xls";
  4889. $tail = "";
  4890. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4891. }
  4892. }
  4893. /**
  4894. *
  4895. *
  4896. * 占单
  4897. *
  4898. *
  4899. **/
  4900. public function _kcyz()
  4901. {
  4902. $post = $this->input->post(NULL, TRUE);
  4903. if (isset($post['warehouse'])) {
  4904. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4905. exit; //不再使用
  4906. $warehouse = $this->input->post('warehouse', true);
  4907. $whlabel = $this->input->post('whlabel', true);
  4908. $id = $this->input->post('id', true);
  4909. $shop = $this->input->post('shop', true);
  4910. $number = $this->input->post('number', true);
  4911. if (!$whlabel || $whlabel == '|') {
  4912. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4913. exit;
  4914. }
  4915. $pp = explode('|', trim($whlabel, '|'));
  4916. $x = 0;
  4917. $save = array();
  4918. foreach ($pp as $va) {
  4919. $num = explode('-', $va);
  4920. if ($number) {
  4921. $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 = '')"); //通用
  4922. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4923. } else {
  4924. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4925. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4926. }
  4927. $x++;
  4928. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4929. $save[] = $x - 1;
  4930. continue; //提前先加X不然出错,所以要减1
  4931. }
  4932. }
  4933. if (isset($save[0])) {
  4934. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4935. exit;
  4936. } else {
  4937. echo json_encode(array('success' => true));
  4938. exit;
  4939. }
  4940. }
  4941. }
  4942. public function _db()
  4943. {
  4944. $post = $this->input->post(NULL, TRUE);
  4945. if (isset($post['page'])) {
  4946. $page = $this->input->post('page', true);
  4947. $perpage = $this->input->post('perpage', true);
  4948. $sku = $this->input->post('sku', true);
  4949. $number = $this->input->post('number', true);
  4950. $warehouse = $this->input->post('warehouse', true);
  4951. $purchase = $this->input->post('purchase', true);
  4952. $orderinfo = $this->input->post('orderinfo', true);
  4953. $waybill = $this->input->post('waybill', true);
  4954. $category = $this->input->post('category', true);
  4955. $size = $this->input->post('size', true);
  4956. $grade = $this->input->post('grade', true);
  4957. $color = $this->input->post('color', true);
  4958. $lowe = $this->input->post('lowe', true);
  4959. $state = $this->input->post('state', true);
  4960. $label = $this->input->post('label', true);
  4961. $timetk = $this->input->post('timetkk', true);
  4962. $timetj = $this->input->post('timetjj', true);
  4963. $timetk = strtotime($timetk);
  4964. $timetj = strtotime($timetj);
  4965. $where = "dbtime > 0";
  4966. if ($timetk && $timetj) {
  4967. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4968. }
  4969. if ($sku) {
  4970. $where .= " and sku = '$sku'";
  4971. }
  4972. if ($warehouse) {
  4973. $where .= " and warehouse = '$warehouse'";
  4974. if ($warehouse == 12) {
  4975. $w = 'specialstock';
  4976. } else {
  4977. $w = 'whlabel';
  4978. }
  4979. }
  4980. if ($purchase) {
  4981. $where .= " and purchase = '$purchase'";
  4982. }
  4983. if ($category) {
  4984. $where .= " and features like '%-$category-%'";
  4985. }
  4986. if ($size) {
  4987. $where .= " and features like '%-$size-%'";
  4988. }
  4989. if ($grade) {
  4990. $where .= " and features like '%-$grade-%'";
  4991. }
  4992. if ($color) {
  4993. $where .= " and features like '%-$color-%'";
  4994. }
  4995. if ($lowe) {
  4996. $where .= " and features like '%-$lowe-%'";
  4997. }
  4998. if ($state != '') {
  4999. $where .= " and state = '$state'";
  5000. }
  5001. //数据排序
  5002. $order_str = "dbtime desc";
  5003. if (empty($page)) {
  5004. $start = 0;
  5005. $perpage = 1;
  5006. } else {
  5007. $start = ($page - 1) * $perpage;
  5008. }
  5009. //取得信息列表
  5010. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5011. foreach ($info_list as $key => $value) {
  5012. $warehouse = $this->$w->read($value['warehouse']);
  5013. $info_list[$key]['warehouse'] = $warehouse['title'];
  5014. $purchase = $this->purchase->read($value['purchase']);
  5015. $info_list[$key]['purchase'] = $purchase['title'];
  5016. if ($value['enter'] != 0) {
  5017. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5018. } else {
  5019. $info_list[$key]['enter'] = "";
  5020. }
  5021. if ($value['dbtime'] != 0) {
  5022. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5023. } else {
  5024. $info_list[$key]['dbtime'] = "";
  5025. }
  5026. if ($value['state'] == 0) {
  5027. $info_list[$key]['state'] = "在库";
  5028. } else if ($value['state'] == 1) {
  5029. $info_list[$key]['state'] = "出库";
  5030. } else if ($value['state'] == 2) {
  5031. $info_list[$key]['state'] = "退库";
  5032. } else if ($value['state'] == 3) {
  5033. $info_list[$key]['state'] = "调拨中";
  5034. } else if ($value['state'] == 4) {
  5035. $info_list[$key]['state'] = "再加工";
  5036. } else if ($value['state'] == 5) {
  5037. $info_list[$key]['state'] = "维修中";
  5038. } else if ($value['state'] == 6) {
  5039. $info_list[$key]['state'] = "盘亏";
  5040. } else if ($value['state'] == 7) {
  5041. $info_list[$key]['state'] = "更换标签";
  5042. } else if ($value['state'] == 8) {
  5043. $info_list[$key]['state'] = "其它";
  5044. } else if ($value['state'] == 9) {
  5045. $info_list[$key]['state'] = "预设";
  5046. }
  5047. }
  5048. $total = $this->whlabel->find_count($where);
  5049. $pagenum = ceil($total / $perpage);
  5050. $over = $total - ($start + $perpage);
  5051. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5052. echo json_encode($rows);
  5053. exit;
  5054. }
  5055. if (isset($post['outsku'])) {
  5056. $time = time();
  5057. $cz = $this->input->post('cz', true);
  5058. $label = $this->input->post('outsku', true);
  5059. $sl = $this->input->post('sl', true);
  5060. $num = $this->input->post('num', true);
  5061. //$warehouse = $this->input->post('warehouse',true);
  5062. if (!$sl) {
  5063. $sl = 1;
  5064. }
  5065. if (!$warehouse) {
  5066. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5067. exit;
  5068. }
  5069. $dblabel = $this->whlabellabel->get_label($label);
  5070. if ($dblabel) {
  5071. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5072. if (count($data) < 1) {
  5073. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5074. exit;
  5075. }
  5076. if (count($data) < $num) {
  5077. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5078. exit;
  5079. }
  5080. for ($i = 0; $i < $sl; $i++) {
  5081. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5082. }
  5083. echo json_encode(array('success' => true));
  5084. exit;
  5085. } else {
  5086. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5087. exit;
  5088. }
  5089. }
  5090. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5091. $this->_Template('whlabel_db', $this->data);
  5092. }
  5093. public function _dbrk()
  5094. {
  5095. $post = $this->input->post(NULL, TRUE);
  5096. if (isset($post['page'])) {
  5097. $page = $this->input->post('page', true);
  5098. $perpage = $this->input->post('perpage', true);
  5099. $sku = $this->input->post('sku', true);
  5100. $number = $this->input->post('number', true);
  5101. $warehouse = $this->input->post('warehouse', true);
  5102. $purchase = $this->input->post('purchase', true);
  5103. $orderinfo = $this->input->post('orderinfo', true);
  5104. $waybill = $this->input->post('waybill', true);
  5105. $category = $this->input->post('category', true);
  5106. $size = $this->input->post('size', true);
  5107. $grade = $this->input->post('grade', true);
  5108. $color = $this->input->post('color', true);
  5109. $lowe = $this->input->post('lowe', true);
  5110. $state = $this->input->post('state', true);
  5111. $label = $this->input->post('label', true);
  5112. $ctime = $this->input->post('ctime', true);
  5113. $timetk = $this->input->post('timetkk', true);
  5114. $timetj = $this->input->post('timetjj', true);
  5115. $timetk = strtotime($timetk);
  5116. $timetj = strtotime($timetj);
  5117. $where = "dbtime > 0";
  5118. if ($timetk && $timetj) {
  5119. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5120. }
  5121. if ($sku) {
  5122. $where .= " and sku = '$sku'";
  5123. }
  5124. if ($warehouse) {
  5125. $where .= " and warehouse = '$warehouse'";
  5126. }
  5127. if ($purchase) {
  5128. $where .= " and purchase = '$purchase'";
  5129. }
  5130. if ($category) {
  5131. $where .= " and features like '%-$category-%'";
  5132. }
  5133. if ($size) {
  5134. $where .= " and features like '%-$size-%'";
  5135. }
  5136. if ($grade) {
  5137. $where .= " and features like '%-$grade-%'";
  5138. }
  5139. if ($color) {
  5140. $where .= " and features like '%-$color-%'";
  5141. }
  5142. if ($lowe) {
  5143. $where .= " and features like '%-$lowe-%'";
  5144. }
  5145. if ($state != '') {
  5146. $where .= " and state = '$state'";
  5147. }
  5148. //数据排序
  5149. $order_str = "dbtime desc";
  5150. if (empty($page)) {
  5151. $start = 0;
  5152. $perpage = 1;
  5153. } else {
  5154. $start = ($page - 1) * $perpage;
  5155. }
  5156. //取得信息列表
  5157. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5158. foreach ($info_list as $key => $value) {
  5159. $warehouse = $this->warehouse->read($value['warehouse']);
  5160. $info_list[$key]['warehouse'] = $warehouse['title'];
  5161. $purchase = $this->purchase->read($value['purchase']);
  5162. $info_list[$key]['purchase'] = $purchase['title'];
  5163. if ($value['enter'] != 0) {
  5164. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5165. } else {
  5166. $info_list[$key]['enter'] = "";
  5167. }
  5168. if ($value['dbtime'] != 0) {
  5169. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5170. } else {
  5171. $info_list[$key]['dbtime'] = "";
  5172. }
  5173. if ($value['state'] == 0) {
  5174. $info_list[$key]['state'] = "在库";
  5175. } else if ($value['state'] == 1) {
  5176. $info_list[$key]['state'] = "出库";
  5177. } else if ($value['state'] == 2) {
  5178. $info_list[$key]['state'] = "退库";
  5179. } else if ($value['state'] == 3) {
  5180. $info_list[$key]['state'] = "调拨中";
  5181. } else if ($value['state'] == 4) {
  5182. $info_list[$key]['state'] = "再加工";
  5183. } else if ($value['state'] == 5) {
  5184. $info_list[$key]['state'] = "维修中";
  5185. } else if ($value['state'] == 6) {
  5186. $info_list[$key]['state'] = "盘亏";
  5187. } else if ($value['state'] == 7) {
  5188. $info_list[$key]['state'] = "更换标签";
  5189. } else if ($value['state'] == 8) {
  5190. $info_list[$key]['state'] = "其它";
  5191. } else if ($value['state'] == 9) {
  5192. $info_list[$key]['state'] = "预设";
  5193. }
  5194. }
  5195. $total = $this->whlabel->find_count($where);
  5196. $pagenum = ceil($total / $perpage);
  5197. $over = $total - ($start + $perpage);
  5198. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5199. echo json_encode($rows);
  5200. exit;
  5201. }
  5202. if (isset($post['rsku'])) {
  5203. $cz = $this->input->post('cz', true);
  5204. $label = $this->input->post('rsku', true);
  5205. $sl = $this->input->post('sl', true);
  5206. $warehouse = $this->input->post('warehouse', true);
  5207. if (!$sl) {
  5208. $sl = 1;
  5209. }
  5210. if (!$warehouse) {
  5211. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5212. exit;
  5213. }
  5214. $dblabel = $this->whlabellabel->get_label($label);
  5215. if ($dblabel) {
  5216. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5217. if (count($data) < 1) {
  5218. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5219. exit;
  5220. }
  5221. if ($sl > count($data)) {
  5222. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5223. exit;
  5224. }
  5225. $time = time();
  5226. for ($i = 0; $i < $sl; $i++) {
  5227. $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']);
  5228. }
  5229. echo json_encode(array('success' => true));
  5230. exit;
  5231. } else {
  5232. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5233. exit;
  5234. }
  5235. }
  5236. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5237. $this->_Template('whlabel_dbrk', $this->data);
  5238. }
  5239. public function _whlabelczdc()
  5240. {
  5241. if (isset($_GET['excel'])) {
  5242. //数据排序
  5243. $order_str = "id desc";
  5244. if (empty($page)) {
  5245. $start = 0;
  5246. $perpage = 1;
  5247. } else {
  5248. $start = ($page - 1) * $perpage;
  5249. }
  5250. $state = $this->input->get('state', true);
  5251. $sku = $this->input->get('sku', true);
  5252. $ctime = $this->input->get('ctime', true);
  5253. $category = $this->input->get('category', true);
  5254. $size = $this->input->get('size', true);
  5255. $grade = $this->input->get('grade', true);
  5256. $color = $this->input->get('color', true);
  5257. $lowe = $this->input->get('lowe', true);
  5258. $timetk = $this->input->get('timetkk', true);
  5259. $timetj = $this->input->get('timetjj', true);
  5260. $timetk = strtotime($timetk);
  5261. $timetj = strtotime($timetj);
  5262. $where = "dbtime > 0";
  5263. if ($timetk && $timetj) {
  5264. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5265. }
  5266. if ($category) {
  5267. $where .= " and features like '%-$category-%'";
  5268. }
  5269. if ($size) {
  5270. $where .= " and features like '%-$size-%'";
  5271. }
  5272. if ($grade) {
  5273. $where .= " and features like '%-$grade-%'";
  5274. }
  5275. if ($color) {
  5276. $where .= " and features like '%-$color-%'";
  5277. }
  5278. if ($lowe) {
  5279. $where .= " and features like '%-$lowe-%'";
  5280. }
  5281. //取得信息列表
  5282. $info_list = $this->whlabel->find_all($where, '*');
  5283. $rows = array();
  5284. $list = array();
  5285. foreach ($info_list as $key => $value) {
  5286. $rows[$value['sku']] = $value; //所有数据sku
  5287. }
  5288. foreach ($rows as $value) {
  5289. $warehouse = $this->warehouse->read($value['warehouse']);
  5290. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5291. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5292. if ($value['orderinfo'] == 0) {
  5293. $info_list[$key]['orderinfo'] = "";
  5294. }
  5295. if ($value['waybill'] == 0) {
  5296. $info_list[$key]['waybill'] = "";
  5297. }
  5298. if ($value['state'] == 0) {
  5299. $value['state'] = "在库";
  5300. } else if ($value['state'] == 3) {
  5301. $value['state'] = "调拨中";
  5302. }
  5303. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5304. }
  5305. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5306. $titlename = "<table border=1>
  5307. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5308. <tr align='center'>
  5309. <td>SKU</td>
  5310. <td>产品</td>
  5311. <td>调拨数量</td>
  5312. <td>入库数量</td>
  5313. </tr>
  5314. </table>";
  5315. $filename = $title . ".xls";
  5316. $tail = "";
  5317. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5318. }
  5319. }
  5320. public function _print($arg_array)
  5321. {
  5322. if (isset($_SESSION['api'])) {
  5323. $user = $this->user->get_api($_SESSION['api']);
  5324. $usp = $user;
  5325. $fgshop = "";
  5326. $sid = "";
  5327. $wid = "";
  5328. $wtype = "";
  5329. $usersp = explode('|', trim($user['shop'], '|'));
  5330. $userwh = explode('|', trim($user['warehouse'], '|'));
  5331. foreach ($usersp as $value) {
  5332. $fgshop .= " shop = " . $value . " or";
  5333. $sid .= " id = " . $value . " or";
  5334. }
  5335. foreach ($userwh as $value) {
  5336. $wid .= " id = " . $value . " or";
  5337. $wtype .= " type = " . $value . " or";
  5338. }
  5339. }
  5340. $post = $this->input->post(NULL, TRUE);
  5341. if (isset($post['tmsku'])) {
  5342. $tmsku = $this->input->post('tmsku', true);
  5343. if (is_numeric($tmsku)) {
  5344. $yyh = $this->whlabellabel->get_label($tmsku);
  5345. } else {
  5346. $yyh = $this->whlabellabel->get_sku($tmsku);
  5347. }
  5348. if ($yyh) {
  5349. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5350. exit;
  5351. } else {
  5352. echo json_encode(array('success' => false));
  5353. exit;
  5354. }
  5355. }
  5356. $classid = $this->classid->sku();
  5357. $pm = $classid;
  5358. $scsku = $classid;
  5359. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5360. if (isset($post['warehouse'])) {
  5361. if ($post['warehouse']) {
  5362. $list = array();
  5363. $num = "";
  5364. $title = "";
  5365. $features = "";
  5366. $order = 0;
  5367. $post['shop'] = '';
  5368. $brand = $this->input->post('brand', true);
  5369. if ($brand != '0,') {
  5370. $b = $this->brand->read(rtrim($brand, ','));
  5371. if ($b) {
  5372. $post['shop'] = str_replace('|', ',', $b['shop']);
  5373. }
  5374. }
  5375. $post['details'] = $this->input->post('details', true); //打印数量
  5376. $xbqnum = $this->input->post('xbqnum', true);
  5377. $post['purchase'] = $this->input->post('purchase', true);
  5378. $post['warehouse'] = $this->input->post('warehouse', true);
  5379. $post['purchase'] = $this->input->post('purchase', true);
  5380. $post['retreatwarehouse'] = $post['warehouse'];
  5381. $post['cpbz'] = $this->input->post('cpbz', true);
  5382. $post['state'] = 9;
  5383. $category = $this->input->post('category', true);
  5384. $list['category'] = $category;
  5385. $list['hairtype'] = $this->input->post('hairtype', true);
  5386. $list['grade'] = $this->input->post('grade', true);
  5387. $size = $this->input->post('size', true);
  5388. $list['size'] = rtrim($size, ',');
  5389. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5390. $list['extension'] = $this->input->post('extension', true);
  5391. if ($category == 1297) {
  5392. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5393. }
  5394. if ($category == 1702) {
  5395. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5396. $list['syother'] = $this->input->post('syother', true);
  5397. }
  5398. if ($category == 133) {
  5399. $list['fittype'] = $this->input->post('fittype', true);
  5400. $list['acother'] = $this->input->post('acother', true);
  5401. }
  5402. $list['color'] = $this->input->post('color', true);
  5403. $list['lowe'] = $this->input->post('lowe', true);
  5404. if ($category == 127) {
  5405. $list['type'] = $this->input->post('type', true);
  5406. $list['headroad'] = $this->input->post('headroad', true);
  5407. $list['density'] = $this->input->post('density', true);
  5408. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5409. $list['lacesize'] = $this->input->post('lacesize', true);
  5410. }
  5411. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5412. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5413. }
  5414. if ($category == 128) {
  5415. $list['lacetype'] = $this->input->post('lacetype', true);
  5416. $list['haircap'] = $this->input->post('haircap', true);
  5417. $list['density'] = $this->input->post('density', true);
  5418. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5419. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5420. $list['wigother'] = $this->input->post('wigother', true);
  5421. $list['wigother1'] = $this->input->post('wigother1', true);
  5422. $list['wigother2'] = $this->input->post('wigother2', true);
  5423. }
  5424. if ($category == 129) {
  5425. $list['wide'] = $this->input->post('wide', true);
  5426. }
  5427. if ($category == 131) {
  5428. $list['gifttype'] = $this->input->post('gifttype', true);
  5429. $list['giftother'] = $this->input->post('giftother', true);
  5430. }
  5431. if ($category == 134) {
  5432. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5433. }
  5434. if ($category == 1297) {
  5435. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5436. $list['sywigother'] = $this->input->post('sywigother', true);
  5437. }
  5438. if ($category == 130 || $category == 133 || $category == 1702) {
  5439. $list['items'] = $this->input->post('items', true);
  5440. $list['weight'] = $this->input->post('weight', true);
  5441. }
  5442. if ($category == 1702) {
  5443. $list['syhairther'] = $this->input->post('syhairther', true);
  5444. }
  5445. foreach ($list as $k => $v) {
  5446. if ($v != 0) {
  5447. $num .= $v;
  5448. $features .= $v . '-';
  5449. $post[$k] = $v;
  5450. $typeclass = $this->typeclass->read($v);
  5451. if (isset($pm[$typeclass['classid']])) {
  5452. if (stripos($typeclass['zh'], '|') !== false) {
  5453. $exzh = explode('|', $typeclass['zh']);
  5454. $pm[$typeclass['classid']] = $exzh[0];
  5455. } else {
  5456. $pm[$typeclass['classid']] = $typeclass['zh'];
  5457. }
  5458. }
  5459. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5460. if ($k != 'size') {
  5461. $title .= $typeclass['title'] . " ";
  5462. }
  5463. }
  5464. }
  5465. $typeclass = $this->typeclass->read($list['size']);
  5466. $title .= $typeclass['title'];
  5467. $time = time();
  5468. $post['title'] = rtrim($title, ' ');
  5469. $post['number'] = $num;
  5470. $post['features'] = '-' . $features;
  5471. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5472. $featurespp = explode('-', trim($featurespp, '-'));
  5473. if (isset($featurespp[5])) {
  5474. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5475. } else {
  5476. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5477. }
  5478. $post['enter'] = $time;
  5479. $post['time'] = $time; //操作时间
  5480. $scsku = implode("-", $scsku);
  5481. $zh = implode(" ", $pm);
  5482. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5483. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5484. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5485. $post['sku'] = $bqsku;
  5486. $label = time() . rand(0, 9);
  5487. $post['label'] = $label;
  5488. $cpid = $this->whlabellabel->find_count();
  5489. $post['cpid'] = $cpid + 1;
  5490. $cpid = $post['cpid'];
  5491. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5492. //if($whlabelbarcode)
  5493. //{
  5494. //$post['label'] = $whlabelbarcode['label'];
  5495. //if(!$this->whlabellabel->insert($post))
  5496. //{
  5497. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5498. //}
  5499. //}
  5500. //else
  5501. //{
  5502. $this->db->trans_begin();
  5503. $this->whlabellabel->insert($post);
  5504. //$this->whlabelbarcode->insert($post);
  5505. if ($this->db->trans_status() === TRUE) {
  5506. $this->db->trans_commit();
  5507. } else {
  5508. $this->db->trans_rollback();
  5509. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5510. exit;
  5511. }
  5512. //}
  5513. $warehouse_name = "";
  5514. $warehouse = $post['warehouse'];
  5515. if($warehouse == 12){
  5516. $warehouse_name = "特殊库存库";
  5517. }
  5518. // if($warehouse == 13){
  5519. // $warehouse_name = "许昌仓";
  5520. // }
  5521. // if($warehouse == 5){
  5522. // $warehouse_name = "美国店";
  5523. // }
  5524. // if($warehouse == 16){
  5525. // $warehouse_name = "定制头套仓";
  5526. // }
  5527. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5528. if(!empty($warehouse_name)){
  5529. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5530. }
  5531. $purchase = $this->purchase->read($post['purchase']);
  5532. 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));
  5533. exit; //特殊仓目前不需要仓库选项
  5534. }
  5535. }
  5536. if (isset($_SESSION['api'])) {
  5537. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5538. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5539. $this->data['wlshop'] = $wlshop;
  5540. $this->data['warehouse'] = $warehouse;
  5541. }
  5542. $whlabelwz = $this->whlabelwz->find_all();
  5543. $this->data['whlabelwz'] = $whlabelwz;
  5544. $this->_Template('whlabel_print', $this->data);
  5545. }
  5546. public function _usaprint($arg_array)
  5547. {
  5548. if (isset($_SESSION['api'])) {
  5549. $user = $this->user->get_api($_SESSION['api']);
  5550. $usp = $user;
  5551. $fgshop = "";
  5552. $sid = "";
  5553. $wid = "";
  5554. $wtype = "";
  5555. $usersp = explode('|', trim($user['shop'], '|'));
  5556. $userwh = explode('|', trim($user['warehouse'], '|'));
  5557. foreach ($usersp as $value) {
  5558. $fgshop .= " shop = " . $value . " or";
  5559. $sid .= " id = " . $value . " or";
  5560. }
  5561. foreach ($userwh as $value) {
  5562. $wid .= " id = " . $value . " or";
  5563. $wtype .= " type = " . $value . " or";
  5564. }
  5565. }
  5566. $post = $this->input->post(NULL, TRUE);
  5567. if (isset($post['tmsku'])) {
  5568. $tmsku = $this->input->post('tmsku', true);
  5569. if (is_numeric($tmsku)) {
  5570. $yyh = $this->whlabellabel->get_label($tmsku);
  5571. } else {
  5572. $yyh = $this->whlabellabel->get_sku($tmsku);
  5573. }
  5574. if ($yyh) {
  5575. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5576. exit;
  5577. } else {
  5578. echo json_encode(array('success' => false));
  5579. exit;
  5580. }
  5581. }
  5582. $classid = $this->classid->sku();
  5583. $pm = $classid;
  5584. $scsku = $classid;
  5585. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5586. if (isset($post['warehouse'])) {
  5587. if ($post['warehouse']) {
  5588. $list = array();
  5589. $num = "";
  5590. $title = "";
  5591. $features = "";
  5592. $order = 0;
  5593. $post['shop'] = '';
  5594. $brand = $this->input->post('brand', true);
  5595. if ($brand != '0,') {
  5596. $b = $this->brand->read(rtrim($brand, ','));
  5597. if ($b) {
  5598. $post['shop'] = str_replace('|', ',', $b['shop']);
  5599. }
  5600. }
  5601. $post['details'] = $this->input->post('details', true); //打印数量
  5602. $xbqnum = $this->input->post('xbqnum', true);
  5603. $post['purchase'] = $this->input->post('purchase', true);
  5604. $post['warehouse'] = $this->input->post('warehouse', true);
  5605. $post['purchase'] = $this->input->post('purchase', true);
  5606. $post['retreatwarehouse'] = $post['warehouse'];
  5607. $post['cpbz'] = $this->input->post('cpbz', true);
  5608. $post['state'] = 9;
  5609. $category = $this->input->post('category', true);
  5610. $list['category'] = $category;
  5611. $list['hairtype'] = $this->input->post('hairtype', true);
  5612. $list['grade'] = $this->input->post('grade', true);
  5613. $size = $this->input->post('size', true);
  5614. $list['size'] = rtrim($size, ',');
  5615. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5616. $list['extension'] = $this->input->post('extension', true);
  5617. if ($category == 1297) {
  5618. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5619. }
  5620. if ($category == 1702) {
  5621. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5622. $list['syother'] = $this->input->post('syother', true);
  5623. }
  5624. if ($category == 133) {
  5625. $list['fittype'] = $this->input->post('fittype', true);
  5626. $list['acother'] = $this->input->post('acother', true);
  5627. }
  5628. $list['color'] = $this->input->post('color', true);
  5629. $list['lowe'] = $this->input->post('lowe', true);
  5630. if ($category == 127) {
  5631. $list['type'] = $this->input->post('type', true);
  5632. $list['headroad'] = $this->input->post('headroad', true);
  5633. $list['density'] = $this->input->post('density', true);
  5634. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5635. $list['lacesize'] = $this->input->post('lacesize', true);
  5636. }
  5637. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5638. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5639. }
  5640. if ($category == 128) {
  5641. $list['lacetype'] = $this->input->post('lacetype', true);
  5642. $list['haircap'] = $this->input->post('haircap', true);
  5643. $list['density'] = $this->input->post('density', true);
  5644. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5645. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5646. $list['wigother'] = $this->input->post('wigother', true);
  5647. $list['wigother1'] = $this->input->post('wigother1', true);
  5648. $list['wigother2'] = $this->input->post('wigother2', true);
  5649. }
  5650. if ($category == 129) {
  5651. $list['wide'] = $this->input->post('wide', true);
  5652. }
  5653. if ($category == 131) {
  5654. $list['gifttype'] = $this->input->post('gifttype', true);
  5655. $list['giftother'] = $this->input->post('giftother', true);
  5656. }
  5657. if ($category == 134) {
  5658. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5659. }
  5660. if ($category == 1297) {
  5661. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5662. $list['sywigother'] = $this->input->post('sywigother', true);
  5663. }
  5664. if ($category == 130 || $category == 133 || $category == 1702) {
  5665. $list['items'] = $this->input->post('items', true);
  5666. $list['weight'] = $this->input->post('weight', true);
  5667. }
  5668. if ($category == 1702) {
  5669. $list['syhairther'] = $this->input->post('syhairther', true);
  5670. }
  5671. foreach ($list as $k => $v) {
  5672. if ($v != 0) {
  5673. $num .= $v;
  5674. $features .= $v . '-';
  5675. $post[$k] = $v;
  5676. $typeclass = $this->typeclass->read($v);
  5677. if (isset($pm[$typeclass['classid']])) {
  5678. if (stripos($typeclass['zh'], '|') !== false) {
  5679. $exzh = explode('|', $typeclass['zh']);
  5680. $pm[$typeclass['classid']] = $exzh[0];
  5681. } else {
  5682. $pm[$typeclass['classid']] = $typeclass['zh'];
  5683. }
  5684. }
  5685. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5686. if ($k != 'size') {
  5687. $title .= $typeclass['title'] . " ";
  5688. }
  5689. }
  5690. }
  5691. $typeclass = $this->typeclass->read($list['size']);
  5692. $title .= $typeclass['title'];
  5693. $time = time();
  5694. $post['title'] = rtrim($title, ' ');
  5695. $post['number'] = $num;
  5696. $post['features'] = '-' . $features;
  5697. $fp = $this->whlabel->get_features($post['features']);
  5698. if (!$fp) {
  5699. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5700. exit;
  5701. }
  5702. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5703. $featurespp = explode('-', trim($featurespp, '-'));
  5704. if (isset($featurespp[5])) {
  5705. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5706. } else {
  5707. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5708. }
  5709. $post['enter'] = $time;
  5710. $post['time'] = $time; //操作时间
  5711. $scsku = implode("-", $scsku);
  5712. $zh = implode(" ", $pm);
  5713. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5714. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5715. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5716. $post['sku'] = $fp['sku'];
  5717. $post['label'] = $fp['sku'];
  5718. $cpid = $this->whlabellabel->find_count();
  5719. $post['cpid'] = $cpid + 1;
  5720. $cpid = $post['cpid'];
  5721. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5722. //if($whlabelbarcode)
  5723. //{
  5724. //$post['label'] = $whlabelbarcode['label'];
  5725. //if(!$this->whlabellabel->insert($post))
  5726. //{
  5727. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5728. //}
  5729. //}
  5730. //else
  5731. //{
  5732. $this->db->trans_begin();
  5733. $this->whlabellabel->insert($post);
  5734. //$this->whlabelbarcode->insert($post);
  5735. if ($this->db->trans_status() === TRUE) {
  5736. $this->db->trans_commit();
  5737. } else {
  5738. $this->db->trans_rollback();
  5739. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5740. exit;
  5741. }
  5742. //}
  5743. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5744. $purchase = $this->purchase->read($post['purchase']);
  5745. 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));
  5746. exit; //特殊仓目前不需要仓库选项
  5747. }
  5748. }
  5749. if (isset($_SESSION['api'])) {
  5750. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5751. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5752. $this->data['wlshop'] = $wlshop;
  5753. $this->data['warehouse'] = $warehouse;
  5754. }
  5755. $whlabelwz = $this->whlabelwz->find_all();
  5756. $this->data['whlabelwz'] = $whlabelwz;
  5757. $this->_Template('whlabel_usaprint', $this->data);
  5758. }
  5759. public function _printrk($arg_array)
  5760. {
  5761. $prc = array();
  5762. $purchase = $this->purchase->find_all();
  5763. foreach ($purchase as $k => $v) {
  5764. $prc[$v['id']] = $v['title'];
  5765. }
  5766. $post = $this->input->post(NULL, TRUE);
  5767. if (isset($post['page'])) {
  5768. $page = $this->input->post('page', true);
  5769. $perpage = $this->input->post('perpage', true);
  5770. $sku = $this->input->post('sku', true);
  5771. $bs = $this->input->post('bs', true);
  5772. $number = $this->input->post('number', true);
  5773. $warehouse = $this->input->post('warehouse', true);
  5774. $purchase = $this->input->post('purchase', true);
  5775. $orderinfo = $this->input->post('orderinfo', true);
  5776. $waybill = $this->input->post('waybill', true);
  5777. $category = $this->input->post('category', true);
  5778. $size = $this->input->post('size', true);
  5779. $grade = $this->input->post('grade', true);
  5780. $color = $this->input->post('color', true);
  5781. $lowe = $this->input->post('lowe', true);
  5782. $state = $this->input->post('state', true);
  5783. $label = $this->input->post('label', true);
  5784. $timetk = $this->input->post('ktime', true);
  5785. $timetj = $this->input->post('jtime', true);
  5786. $timetk = strtotime($timetk);
  5787. $timetj = strtotime($timetj);
  5788. $where = "1=1 ";
  5789. if ($timetk && $timetj) {
  5790. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5791. }
  5792. if ($sku) {
  5793. $where .= " and sku = '$sku'";
  5794. }
  5795. if ($bs != '') {
  5796. $where .= " and bs = '$bs'";
  5797. }
  5798. if ($number) {
  5799. $where .= " and number = '$number'";
  5800. }
  5801. if ($warehouse) {
  5802. $where .= " and warehouse = '$warehouse'";
  5803. }
  5804. if ($purchase) {
  5805. $where .= " and purchase = '$purchase'";
  5806. }
  5807. if ($orderinfo) {
  5808. $where .= " and orderinfo = '$orderinfo'";
  5809. }
  5810. if ($waybill) {
  5811. $where .= " and waybill = '$waybill'";
  5812. }
  5813. if ($category) {
  5814. $where .= " and features like '%-$category-%'";
  5815. }
  5816. if ($size) {
  5817. $where .= " and features like '%-$size-%'";
  5818. }
  5819. if ($grade) {
  5820. $where .= " and features like '%-$grade-%'";
  5821. }
  5822. if ($color) {
  5823. $where .= " and features like '%-$color-%'";
  5824. }
  5825. if ($lowe) {
  5826. $where .= " and features like '%-$lowe-%'";
  5827. }
  5828. if ($label) {
  5829. $where .= " and label = '$label'";
  5830. }
  5831. if ($state || $state == 0) {
  5832. $where .= " and state = '$state'";
  5833. }
  5834. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5835. //数据排序
  5836. $order_str = "enter desc";
  5837. if (empty($page)) {
  5838. $start = 0;
  5839. $perpage = 1;
  5840. } else {
  5841. $start = ($page - 1) * $perpage;
  5842. }
  5843. //取得信息列表
  5844. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5845. foreach ($info_list as $key => $value) {
  5846. $warehouse = $this->warehouse->read($value['warehouse']);
  5847. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5848. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5849. if ($value['state'] == 0) {
  5850. $info_list[$key]['state'] = "在库";
  5851. } else if ($value['state'] == 1) {
  5852. $info_list[$key]['state'] = "出库";
  5853. } else if ($value['state'] == 2) {
  5854. $info_list[$key]['state'] = "退库";
  5855. } else if ($value['state'] == 3) {
  5856. $info_list[$key]['state'] = "调拨中";
  5857. } else if ($value['state'] == 4) {
  5858. $info_list[$key]['state'] = "再加工";
  5859. } else if ($value['state'] == 5) {
  5860. $info_list[$key]['state'] = "维修中";
  5861. } else if ($value['state'] == 6) {
  5862. $info_list[$key]['state'] = "盘亏";
  5863. } else if ($value['state'] == 7) {
  5864. $info_list[$key]['state'] = "更换标签";
  5865. } else if ($value['state'] == 8) {
  5866. $info_list[$key]['state'] = "其它";
  5867. } else if ($value['state'] == 9) {
  5868. $info_list[$key]['state'] = "预设";
  5869. } else if ($value['state'] == 10) {
  5870. $info_list[$key]['state'] = "美店零售";
  5871. }
  5872. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5873. }
  5874. $total = $this->$ck->find_count($where);
  5875. $pagenum = ceil($total / $perpage);
  5876. $over = $total - ($start + $perpage);
  5877. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5878. echo json_encode($rows);
  5879. exit;
  5880. }
  5881. if (isset($post['tmsku'])) {
  5882. $time = time();
  5883. $tmsku = $this->input->post('tmsku', true);
  5884. //$post['shop'] = $this->input->post('shop',true);
  5885. $num = $this->input->post('num', true);
  5886. $rktype = $this->input->post('rktype', true);
  5887. if ($num > 200) {
  5888. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5889. exit;
  5890. }
  5891. if (!$rktype) {
  5892. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5893. }
  5894. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5895. /**
  5896. $wz = array();
  5897. foreach ($rk as $key=>$value)
  5898. {
  5899. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5900. }
  5901. if(count($wz) > 1)
  5902. {
  5903. $wz = array_values($wz);
  5904. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5905. }
  5906. **/
  5907. if (isset($rk[0]['purchase'])) {
  5908. $rk = $rk[0];
  5909. $j = 0;
  5910. $post['purchase'] = $rk['purchase'];
  5911. $post['warehouse'] = $rk['warehouse'];
  5912. $post['retreatwarehouse'] = $rk['warehouse'];
  5913. $post['sku'] = $rk['sku'];
  5914. $post['number'] = $rk['number'];
  5915. $post['features'] = $rk['features'];
  5916. $post['title'] = $rk['title'];
  5917. $post['enter'] = $time;
  5918. $post['time'] = $time;
  5919. $post['bs'] = 1;
  5920. $post['shop'] = $rk['shop'];
  5921. $post['details'] = $rk['details'];
  5922. $post['cpid'] = $rk['cpid'];
  5923. $post['cpbz'] = $rk['cpbz'];
  5924. //$post['rktype'] = $rktype;
  5925. $warehouse = $this->warehouse->read($rk['warehouse']);
  5926. if ($warehouse['bdck'] == '') {
  5927. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5928. exit;
  5929. } else {
  5930. $bdck = $warehouse['bdck'];
  5931. }
  5932. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5933. if (isset($pdwz['details'])) {
  5934. if ($pdwz['details'] != $post['details']) {
  5935. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5936. exit;
  5937. }
  5938. }
  5939. $post['featurespp'] = $rk['featurespp'];
  5940. if ($post['warehouse'] == '5') {
  5941. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5942. if ($yza) {
  5943. if ($post['features'] != $yza[0]['features']) {
  5944. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5945. exit;
  5946. }
  5947. }
  5948. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5949. if ($yzb) {
  5950. if ($post['sku'] != $yzb[0]['sku']) {
  5951. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5952. exit;
  5953. }
  5954. }
  5955. }
  5956. for ($i = 0; $i < $num; $i++) {
  5957. $post['label'] = time() . rand(100, 999) . $i;
  5958. if ($this->$bdck->insert($post)) {
  5959. $j++;
  5960. }
  5961. }
  5962. /**
  5963. if($post['warehouse'] != 12)
  5964. {
  5965. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5966. }
  5967. **/
  5968. if ($j == $num) {
  5969. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5970. exit;
  5971. } else {
  5972. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5973. exit;
  5974. }
  5975. } else {
  5976. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5977. exit;
  5978. }
  5979. }
  5980. $this->_Template('whlabel_printrk', $this->data);
  5981. }
  5982. public function _printxzrk($arg_array)
  5983. {
  5984. $post = $this->input->post(NULL, TRUE);
  5985. if (isset($post['wzid'])) {
  5986. $time = time();
  5987. $id = $this->input->post('wzid', true);
  5988. //$post['shop'] = $this->input->post('shop',true);
  5989. $num = 1;
  5990. $rk = $this->whlabellabel->read($id);
  5991. if (isset($rk['purchase'])) {
  5992. $x = 0;
  5993. $post['purchase'] = $rk['purchase'];
  5994. $post['warehouse'] = $rk['warehouse'];
  5995. $post['retreatwarehouse'] = $rk['warehouse'];
  5996. $post['sku'] = $rk['sku'];
  5997. $post['number'] = $rk['number'];
  5998. $post['features'] = $rk['features'];
  5999. $post['title'] = $rk['title'];
  6000. $post['enter'] = $time;
  6001. $post['time'] = $time;
  6002. $post['bs'] = 1;
  6003. $post['shop'] = $rk['shop'];
  6004. $post['details'] = $rk['details'];
  6005. $post['cpid'] = $rk['cpid'];
  6006. $post['cpbz'] = $rk['cpbz'];
  6007. $warehouse = $this->warehouse->read($rk['warehouse']);
  6008. if ($warehouse['bdck'] == '') {
  6009. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6010. exit;
  6011. } else {
  6012. $bdck = $warehouse['bdck'];
  6013. }
  6014. $post['featurespp'] = $rk['featurespp'];
  6015. $this->db->trans_begin();
  6016. for ($i = 0; $i < $num; $i++) {
  6017. $post['label'] = time() . rand(100, 999) . $i;
  6018. $this->$bdck->insert($post);
  6019. }
  6020. /**
  6021. if($post['warehouse'] != 12)
  6022. {
  6023. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6024. }
  6025. **/
  6026. if ($this->db->trans_status() === TRUE) {
  6027. $this->db->trans_commit();
  6028. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6029. exit;
  6030. } else {
  6031. $this->db->trans_rollback();
  6032. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6033. exit;
  6034. }
  6035. } else {
  6036. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6037. exit;
  6038. }
  6039. }
  6040. }
  6041. public function _printck($arg_array)
  6042. {
  6043. $prc = array();
  6044. $purchase = $this->purchase->find_all();
  6045. foreach ($purchase as $k => $v) {
  6046. $prc[$v['id']] = $v['title'];
  6047. }
  6048. $post = $this->input->post(NULL, TRUE);
  6049. if (isset($post['page'])) {
  6050. $page = $this->input->post('page', true);
  6051. $perpage = $this->input->post('perpage', true);
  6052. $sku = $this->input->post('sku', true);
  6053. $bs = $this->input->post('bs', true);
  6054. $number = $this->input->post('number', true);
  6055. $warehouse = $this->input->post('warehouse', true);
  6056. $purchase = $this->input->post('purchase', true);
  6057. $orderinfo = $this->input->post('orderinfo', true);
  6058. $waybill = $this->input->post('waybill', true);
  6059. $category = $this->input->post('category', true);
  6060. $size = $this->input->post('size', true);
  6061. $grade = $this->input->post('grade', true);
  6062. $color = $this->input->post('color', true);
  6063. $lowe = $this->input->post('lowe', true);
  6064. $state = $this->input->post('state', true);
  6065. $label = $this->input->post('label', true);
  6066. $timetk = $this->input->post('ktime', true);
  6067. $timetj = $this->input->post('jtime', true);
  6068. $timetk = strtotime($timetk);
  6069. $timetj = strtotime($timetj);
  6070. $where = "state=1 ";
  6071. if ($timetk && $timetj) {
  6072. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6073. }
  6074. if ($sku) {
  6075. $where .= " and sku = '$sku'";
  6076. }
  6077. if ($bs != '') {
  6078. $where .= " and bs = '$bs'";
  6079. }
  6080. if ($number) {
  6081. $where .= " and number = '$number'";
  6082. }
  6083. if ($warehouse) {
  6084. $where .= " and warehouse = '$warehouse'";
  6085. }
  6086. if ($purchase) {
  6087. $where .= " and purchase = '$purchase'";
  6088. }
  6089. if ($orderinfo) {
  6090. $where .= " and orderinfo = '$orderinfo'";
  6091. }
  6092. if ($waybill) {
  6093. $where .= " and waybill = '$waybill'";
  6094. }
  6095. if ($category) {
  6096. $where .= " and features like '%-$category-%'";
  6097. }
  6098. if ($size) {
  6099. $where .= " and features like '%-$size-%'";
  6100. }
  6101. if ($grade) {
  6102. $where .= " and features like '%-$grade-%'";
  6103. }
  6104. if ($color) {
  6105. $where .= " and features like '%-$color-%'";
  6106. }
  6107. if ($lowe) {
  6108. $where .= " and features like '%-$lowe-%'";
  6109. }
  6110. if ($label) {
  6111. $where .= " and label = '$label'";
  6112. }
  6113. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6114. //数据排序
  6115. $order_str = "outk desc";
  6116. if (empty($page)) {
  6117. $start = 0;
  6118. $perpage = 1;
  6119. } else {
  6120. $start = ($page - 1) * $perpage;
  6121. }
  6122. //取得信息列表
  6123. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6124. foreach ($info_list as $key => $value) {
  6125. $warehouse = $this->warehouse->read($value['warehouse']);
  6126. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6127. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6128. if ($value['state'] == 0) {
  6129. $info_list[$key]['state'] = "在库";
  6130. } else if ($value['state'] == 1) {
  6131. $info_list[$key]['state'] = "出库";
  6132. } else if ($value['state'] == 2) {
  6133. $info_list[$key]['state'] = "退库";
  6134. } else if ($value['state'] == 3) {
  6135. $info_list[$key]['state'] = "调拨中";
  6136. } else if ($value['state'] == 4) {
  6137. $info_list[$key]['state'] = "再加工";
  6138. } else if ($value['state'] == 5) {
  6139. $info_list[$key]['state'] = "维修中";
  6140. } else if ($value['state'] == 6) {
  6141. $info_list[$key]['state'] = "盘亏";
  6142. } else if ($value['state'] == 7) {
  6143. $info_list[$key]['state'] = "更换标签";
  6144. } else if ($value['state'] == 8) {
  6145. $info_list[$key]['state'] = "其它";
  6146. } else if ($value['state'] == 9) {
  6147. $info_list[$key]['state'] = "预设";
  6148. } else if ($value['state'] == 10) {
  6149. $info_list[$key]['state'] = "美店零售";
  6150. }
  6151. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6152. }
  6153. $total = $this->$ck->find_count($where);
  6154. $pagenum = ceil($total / $perpage);
  6155. $over = $total - ($start + $perpage);
  6156. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6157. echo json_encode($rows);
  6158. exit;
  6159. }
  6160. if (isset($post['tmsku'])) {
  6161. $time = time();
  6162. $tmsku = $this->input->post('tmsku', true);
  6163. //$post['shop'] = $this->input->post('shop',true);
  6164. $num = $this->input->post('num', true);
  6165. $cktype = $this->input->post('cktype', true);
  6166. $label = $this->whlabellabel->get_label($tmsku);
  6167. if (!$cktype) {
  6168. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6169. }
  6170. if (!isset($label['warehouse'])) {
  6171. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6172. exit;
  6173. }
  6174. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6175. if (stripos($label['features'], '-126-') !== false) {
  6176. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6177. } else {
  6178. $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 = ''");
  6179. }
  6180. $j = 0;
  6181. if (count($ck) >= $num) {
  6182. for ($i = 0; $i < $num; $i++) {
  6183. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6184. {
  6185. $j++;
  6186. }
  6187. }
  6188. if ($j == $num) {
  6189. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6190. exit;
  6191. } else {
  6192. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6193. exit;
  6194. }
  6195. } else {
  6196. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6197. exit;
  6198. }
  6199. }
  6200. if(isset($_SESSION['api']))
  6201. {
  6202. $user = $this->user->get_api($_SESSION['api']);
  6203. if(in_array($user['power'],[1,27])){
  6204. $vip = 1;
  6205. }
  6206. }
  6207. else
  6208. {
  6209. $vip = 0;
  6210. header('Location: /');exit;
  6211. }
  6212. $this->data['vip'] = $vip;
  6213. $this->_Template('whlabel_printck', $this->data);
  6214. }
  6215. public function _printexcel()
  6216. {
  6217. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6218. $config['upload_path'] = '.' . $dir;
  6219. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6220. $config['allowed_types'] = 'xls|xlsx|csv';
  6221. $config['max_size'] = 10240;
  6222. $this->load->library('upload', $config);
  6223. $this->upload->initialize($config);
  6224. if ($this->upload->do_upload('userfile')) {
  6225. $full_path = $dir . $this->upload->data('file_name');
  6226. $fileName = '.' . $full_path;
  6227. if (!file_exists($fileName)) {
  6228. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6229. exit;
  6230. } else {
  6231. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6232. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6233. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6234. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6235. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6236. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6237. ++$column; //如果列数大于26行
  6238. $list = array();
  6239. for ($i = 2; $i <= $row; $i++) // 行数循环
  6240. {
  6241. $data = array();
  6242. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6243. {
  6244. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6245. }
  6246. $list[] = $data;
  6247. }
  6248. }
  6249. $ed = array();
  6250. $i = 0;
  6251. $j = 0;
  6252. $dcdata = array();
  6253. $yc = '';
  6254. $cmf_arr = array_column($list, '1');
  6255. array_multisort($cmf_arr, SORT_ASC, $list);
  6256. foreach ($list as $key => $value) {
  6257. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6258. if ($typeclass) {
  6259. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6260. } else {
  6261. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6262. $i++;
  6263. continue;
  6264. }
  6265. }
  6266. if ($i > 0) {
  6267. $yc = $i . '条异常';
  6268. }
  6269. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6270. exit;
  6271. }
  6272. }
  6273. public function _uck()
  6274. {
  6275. if (isset($_GET['excel'])) {
  6276. $tc = array();
  6277. $typeclass = $this->typeclass->find_all();
  6278. foreach ($typeclass as $v) {
  6279. $tc[$v['id']] = $v['zh'];
  6280. }
  6281. $data = array();
  6282. $t = array();
  6283. $rq = '';
  6284. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6285. $ts = $ts / (24 * 3600);
  6286. for ($i = 0; $i < $ts; $i++) {
  6287. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6288. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6289. }
  6290. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6291. foreach ($info_list as $k => $v) {
  6292. $features = explode('-', trim($v['features'], '-'));
  6293. if (!isset($features[3]) || !isset($features[4])) {
  6294. continue;
  6295. }
  6296. $data[$k][0] = $tc[$features[0]]; //类型
  6297. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6298. $data[$k][2] = $tc[$features[4]]; //曲度
  6299. $data[$k][3] = '';
  6300. if (isset($data[$k][1])) {
  6301. $data[$k][3] .= $data[$k][1];
  6302. }
  6303. if (isset($data[$k][2])) {
  6304. $data[$k][3] .= $data[$k][2];
  6305. }
  6306. if (isset($features[5])) {
  6307. $data[$k][3] .= $tc[$features[5]];
  6308. }
  6309. if (isset($features[2])) {
  6310. $data[$k][3] .= $tc[$features[2]];
  6311. }
  6312. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6313. $data[$k][4] = $v['sku'];
  6314. $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())) . '))'); //月初库存
  6315. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6316. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6317. $ztrq = '';
  6318. $ztsl = '';
  6319. if (count($zt) > 0) {
  6320. foreach ($zt as $vv) {
  6321. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6322. $ztsl .= $vv['num'] . '<br>';
  6323. }
  6324. }
  6325. $data[$k][] = trim($ztsl, '<br>');
  6326. $data[$k][] = trim($ztrq, '<br>');
  6327. $byck = 0;
  6328. foreach ($t as $vv) {
  6329. $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));
  6330. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6331. $byck += $sl;
  6332. }
  6333. $data[$k][] = ($byck > 0) ? $byck : '';
  6334. }
  6335. $title = "详情 " . date("Y-m-d", time());
  6336. $titlename = "<table border=1>
  6337. <tr align='center'>
  6338. <td>类别</td>
  6339. <td>颜色</td>
  6340. <td>曲度</td>
  6341. <td>名称</td>
  6342. <td>SKU</td>
  6343. <td>月初库存</td>
  6344. <td>剩余库存</td>
  6345. <td>在途数量</td>
  6346. <td>预达日期</td>" .
  6347. $rq
  6348. . "<td>本月出库</td></tr>
  6349. </table>";
  6350. $filename = $title . ".xls";
  6351. $tail = "";
  6352. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6353. }
  6354. }
  6355. public function _whlabelexcelzh()
  6356. {
  6357. if (isset($_GET['excel'])) {
  6358. $where = "sku != 'Preset'";
  6359. //数据排序
  6360. $order_str = "id desc";
  6361. if (empty($page)) {
  6362. $start = 0;
  6363. $perpage = 1;
  6364. } else {
  6365. $start = ($page - 1) * $perpage;
  6366. }
  6367. $category = $this->input->get('category', true);
  6368. $warehouse = $this->input->get('warehouse', true);
  6369. $excelid = $this->input->get('sid', true);
  6370. if ($category) {
  6371. $where .= " and features like '%-$category-%'";
  6372. }
  6373. if ($warehouse) {
  6374. $where .= " and warehouse = '$warehouse'";
  6375. }
  6376. $xzid = '';
  6377. if ($excelid) {
  6378. $excelid = explode(',', trim($excelid, ','));
  6379. foreach ($excelid as $key => $value) {
  6380. $xzid .= " id = " . $value . " or";
  6381. }
  6382. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6383. }
  6384. //取得信息列表
  6385. /**
  6386. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6387. $rows = array();$list = array();
  6388. foreach ($info_list as $key=>$value)
  6389. {
  6390. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6391. }
  6392. **/
  6393. $list = array();
  6394. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6395. foreach ($rows as $key => $value) {
  6396. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6397. $zh = '';
  6398. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6399. foreach ($zt as $v) {
  6400. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6401. }
  6402. $zt = array_sum(array_column($zt, 'num'));
  6403. $number = $value['number'];
  6404. $ftime = time() - 15 * 24 * 3600;
  6405. $warehouse = $this->warehouse->read($value['warehouse']);
  6406. $rows[$key]['warehouse'] = $warehouse['title'];
  6407. $rows[$key]['number'] = $c;
  6408. $rows[$key]['features'] = $zh;
  6409. $rows[$key]['hb'] = $c + $zt;
  6410. }
  6411. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6412. $titlename = "<table border=1>
  6413. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6414. <tr align='center'>
  6415. <td>仓库</td>
  6416. <td>SKU</td>
  6417. <td>产品</td>
  6418. <td>库存数量</td>
  6419. <td>在途数量及预达日期</td>
  6420. <td>在途+库存数量</td>
  6421. </tr>
  6422. </table>";
  6423. $filename = $title . ".xls";
  6424. $tail = "";
  6425. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6426. }
  6427. if (isset($_GET['excel'])) {
  6428. $warehouse = $this->input->get('warehouse', true);
  6429. $sku = $this->input->get('sku', true);
  6430. $cz = $this->input->get('cz', true);
  6431. $text = $this->input->post('text', true);
  6432. $xztime = $this->input->get('xztime', true);
  6433. $timetk = $this->input->get('timetk', true);
  6434. $timetj = $this->input->get('timetj', true);
  6435. $timetk = strtotime($timetk);
  6436. $timetj = strtotime($timetj);
  6437. $where = "time = '0' ";
  6438. if ($warehouse) {
  6439. $where .= " and warehouse = '$warehouse'";
  6440. }
  6441. if ($sku) {
  6442. $where .= " and sku = '$sku'";
  6443. }
  6444. if ($text) {
  6445. $where .= " and text like '%$text%'";
  6446. }
  6447. if ($cz != '') {
  6448. $where .= " and cz = '$cz'";
  6449. }
  6450. if ($timetk && $timetj) {
  6451. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6452. }
  6453. //数据排序
  6454. $order_str = $xztime . " desc";
  6455. //取得信息列表
  6456. $zh = array();
  6457. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6458. foreach ($info_list as $v) {
  6459. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6460. $warehouse = $this->warehouse->read($v['warehouse']);
  6461. $v['warehouse'] = $warehouse['title'];
  6462. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6463. $v['stime'] = date('Y-m-d', $v['stime']);
  6464. if (isset($zh[$v['features']])) {
  6465. $zh[$v['features']]['num'] += $v['num'];
  6466. } else {
  6467. $zh[$v['features']] = $v;
  6468. }
  6469. $zh[$v['features']]['features'] = $c;
  6470. }
  6471. $title = "在途数据" . date('Y-m-d', time());
  6472. $titlename = "<table border=1>
  6473. <tr align='center'>
  6474. <td>仓库</td>
  6475. <td>SKU</td>
  6476. <td>名称</td>
  6477. <td>在途数量</td>
  6478. <td>库存数量</td>
  6479. <td>添加在途日期</td>
  6480. <td>预达日期</td>
  6481. <td>备注</td>
  6482. </tr>
  6483. </table>";
  6484. $filename = $title . ".xls";
  6485. $tail = "";
  6486. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6487. }
  6488. }
  6489. public function _fc()
  6490. {
  6491. $vip = 0;
  6492. if (isset($_SESSION['api'])) {
  6493. $user = $this->user->get_api($_SESSION['api']);
  6494. if ($user['vip'] == 1) {
  6495. $vip = 1;
  6496. }
  6497. } else {
  6498. header('Location: /');
  6499. exit;
  6500. }
  6501. $post = $this->input->post(NULL, TRUE);
  6502. if (isset($post['page'])) {
  6503. $page = $this->input->post('page', true);
  6504. $perpage = $this->input->post('perpage', true);
  6505. $category = $this->input->post('category', true);
  6506. $size = $this->input->post('size', true);
  6507. $grade = $this->input->post('grade', true);
  6508. $color = $this->input->post('color', true);
  6509. $lowe = $this->input->post('lowe', true);
  6510. $sku = $this->input->post('sku');
  6511. $title = $this->input->post('title');
  6512. $warehouse = $this->input->post('warehouse', true);
  6513. $usa = $this->input->post('usa', true);
  6514. $purchase = $this->input->post('purchase', true);
  6515. $lacetype = $this->input->post('lacetype', true);
  6516. $haircap = $this->input->post('haircap', true);
  6517. $density = $this->input->post('density', true);
  6518. $details = $this->input->post('details', true);
  6519. $state = $this->input->post('state', true);
  6520. $ktime = $this->input->post('ktime', true);
  6521. $jtime = $this->input->post('jtime', true);
  6522. $ktime = strtotime($ktime);
  6523. $jtime = strtotime($jtime);
  6524. $where = "state = '11'";
  6525. $gj = "";
  6526. $ck = "";
  6527. if ($lacetype) {
  6528. $where .= " and features like '%-$lacetype-%'";
  6529. }
  6530. if ($category) {
  6531. $where .= " and features like '%-$category-%'";
  6532. }
  6533. if ($size) {
  6534. $where .= " and features like '%-$size-%'";
  6535. }
  6536. if ($grade) {
  6537. $where .= " and features like '%-$grade-%'";
  6538. }
  6539. if ($color) {
  6540. $where .= " and features like '%-$color-%'";
  6541. }
  6542. if ($lowe) {
  6543. $where .= " and features like '%-$lowe-%'";
  6544. }
  6545. if ($haircap) {
  6546. $where .= " and features like '%-$haircap-%'";
  6547. }
  6548. if ($density) {
  6549. $where .= " and features like '%-$density-%'";
  6550. }
  6551. if ($usa) {
  6552. if (!$warehouse) {
  6553. $where .= " and (warehouse = '5' or warehouse = '8')";
  6554. }
  6555. }
  6556. if ($warehouse) {
  6557. $where .= " and warehouse = '$warehouse'";
  6558. }
  6559. if ($details) {
  6560. $where .= " and details = '$details'";
  6561. }
  6562. if ($purchase) {
  6563. $where .= " and purchase = '$purchase'";
  6564. }
  6565. if ($state) {
  6566. $where .= " and state = '$state'";
  6567. }
  6568. if ($ktime && $jtime) {
  6569. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6570. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6571. }
  6572. //数据排序
  6573. $order_str = "id desc";
  6574. if (empty($page)) {
  6575. $start = 0;
  6576. $perpage = 1;
  6577. } else {
  6578. $start = ($page - 1) * $perpage;
  6579. }
  6580. if ($sku) {
  6581. $sku = trim($sku, ' ');
  6582. $sku = trim($sku, ' ');
  6583. $where .= " and sku like '%$sku%'";
  6584. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6585. } else if ($title) {
  6586. $title = trim($title, ' ');
  6587. $title = trim($title, ' ');
  6588. $where .= " and title like '%$title%'";
  6589. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6590. } else {
  6591. //$where .= " and time > '$ktime' and time < '$jtime'";
  6592. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6593. }
  6594. //取得信息列表
  6595. $rows = array();
  6596. $list = array();
  6597. foreach ($info_list as $key => $value) {
  6598. $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'] . '"');
  6599. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6600. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6601. $warehouse = $this->warehouse->read($value['warehouse']);
  6602. $info_list[$key]['warehouse'] = $warehouse['title'];
  6603. $info_list[$key]['number'] = $g;
  6604. $info_list[$key]['features'] = $x;
  6605. $info_list[$key]['x'] = $s;
  6606. }
  6607. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6608. $pagenum = ceil($total / $perpage);
  6609. $over = $total - ($start + $perpage);
  6610. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6611. echo json_encode($rows);
  6612. exit;
  6613. }
  6614. $this->data['vip'] = $vip;
  6615. $this->_Template('whlabel_fc', $this->data);
  6616. }
  6617. public function _fcmb()
  6618. {
  6619. $where = "sku != 'Preset'";
  6620. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6621. foreach ($rows as $k => $v) {
  6622. $warehouse = $this->warehouse->read($v['warehouse']);
  6623. $rows[$k]['warehouse'] = $warehouse['title'];
  6624. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6625. $rows[$k]['t'] = '';
  6626. $rows[$k]['n'] = '';
  6627. }
  6628. $title = "封货产品数据导入模板";
  6629. $titlename = "<table border=1>
  6630. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6631. <tr align='center'>
  6632. <td>仓库</td>
  6633. <td>SKU</td>
  6634. <td>产品</td>
  6635. <td>封存产品总数量</td>
  6636. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6637. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6638. </tr>
  6639. </table>";
  6640. $filename = $title . ".xls";
  6641. $tail = "";
  6642. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6643. }
  6644. public function _fcexcel()
  6645. {
  6646. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6647. $config['upload_path'] = '.' . $dir;
  6648. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6649. $config['allowed_types'] = 'xls|xlsx|csv';
  6650. $config['max_size'] = 10240;
  6651. $this->load->library('upload', $config);
  6652. $this->upload->initialize($config);
  6653. if ($this->upload->do_upload('userfile')) {
  6654. $full_path = $dir . $this->upload->data('file_name');
  6655. $fileName = '.' . $full_path;
  6656. if (!file_exists($fileName)) {
  6657. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6658. exit;
  6659. } else {
  6660. libxml_use_internal_errors(true);
  6661. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6662. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6663. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6664. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6665. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6666. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6667. ++$column; //如果列数大于26行
  6668. $list = array();
  6669. for ($i = 2; $i <= $row; $i++) // 行数循环
  6670. {
  6671. $data = array();
  6672. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6673. {
  6674. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6675. }
  6676. $list[] = $data;
  6677. }
  6678. }
  6679. $i = 0;
  6680. $j = 0;
  6681. $ed = array();
  6682. foreach ($list as $key => $value) {
  6683. $time = time();
  6684. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6685. continue;
  6686. }
  6687. $warehouse = $this->warehouse->get_title($value['0']);
  6688. $sku = $value['1'];
  6689. $type = $value['4']; //调整方式0扣减1删除
  6690. $num = $value['5']; //调整数量
  6691. //$text = $value['4'];//扣减说明
  6692. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6693. if (!$d) //如果没有这个SKU
  6694. {
  6695. $ed[] = array($sku . '-库存中不存在此SKU');
  6696. $j++;
  6697. continue;
  6698. }
  6699. if (!isset($warehouse['id'])) {
  6700. $ed[] = array($sku . '-仓库名错误!');
  6701. $j++;
  6702. continue;
  6703. }
  6704. if ($type == 1 || $type == 2) //扣减库存
  6705. {
  6706. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6707. if (count($data) < abs($num)) {
  6708. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6709. $j++;
  6710. continue;
  6711. }
  6712. if ($type == 1) //转入库存
  6713. {
  6714. for ($i = 0; $i < abs($num); $i++) {
  6715. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6716. }
  6717. } else if ($type == 2) //删除
  6718. {
  6719. for ($i = 0; $i < abs($num); $i++) {
  6720. $this->whlabel->remove($data[$i]['id']);
  6721. }
  6722. }
  6723. } else if ($type == 0) //增加库存
  6724. {
  6725. $post['sku'] = $d['sku'];
  6726. $post['shop'] = '';
  6727. $post['warehouse'] = $warehouse['id'];
  6728. $post['purchase'] = $d['purchase'];
  6729. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6730. $post['state'] = 11;
  6731. $post['title'] = $d['title'];
  6732. $post['number'] = $d['number'];
  6733. $post['features'] = $d['features'];
  6734. $post['enter'] = $time;
  6735. $post['time'] = $time; //操作时间
  6736. for ($i = 0; $i < $num; $i++) {
  6737. $post['label'] = time() . rand(100, 999) . $i;
  6738. $this->whlabel->insert($post);
  6739. }
  6740. }
  6741. sleep(1); //防止入库时间一样,需要延迟1秒
  6742. }
  6743. if ($j > 0) {
  6744. $tt = date('Ymd', time());
  6745. $title = '库存导入错误信息-' . $tt;
  6746. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6747. $tail = "\n";
  6748. $filename = $title . ".xls";
  6749. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6750. $dir = '/data/excel/' . $time . '/';
  6751. $file_name = 'error_' . $time . rand(1000, 9999);
  6752. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6753. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6754. fwrite($myfile, $ecl);
  6755. fclose($myfile);
  6756. $error = $dir . $file_name . '.xls';
  6757. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6758. exit;
  6759. } else {
  6760. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6761. exit;
  6762. }
  6763. }
  6764. }
  6765. public function _fcjxc($arg_array)
  6766. {
  6767. if (isset($_GET['excel'])) {
  6768. $category = $this->input->get('category', true);
  6769. $size = $this->input->get('size', true);
  6770. $grade = $this->input->get('grade', true);
  6771. $color = $this->input->get('color', true);
  6772. $lowe = $this->input->get('lowe', true);
  6773. $sku = $this->input->get('sku');
  6774. $title = $this->input->get('title');
  6775. $warehouse = $arg_array[0];
  6776. $usa = $this->input->get('usa', true);
  6777. $purchase = $this->input->get('purchase', true);
  6778. $lacetype = $this->input->get('lacetype', true);
  6779. $haircap = $this->input->get('haircap', true);
  6780. $density = $this->input->get('density', true);
  6781. $title = $this->input->get('title', true);
  6782. $state = $this->input->get('state', true);
  6783. $ktime = $this->input->get('ktime', true);
  6784. $jtime = $this->input->get('jtime', true);
  6785. $where = "state=11";
  6786. $gj = "";
  6787. $ck = "";
  6788. if ($lacetype) {
  6789. $where .= " and features like '%-$lacetype-%'";
  6790. }
  6791. if ($category) {
  6792. $where .= " and features like '%-$category-%'";
  6793. }
  6794. if ($size) {
  6795. $where .= " and features like '%-$size-%'";
  6796. }
  6797. if ($grade) {
  6798. $where .= " and features like '%-$grade-%'";
  6799. }
  6800. if ($color) {
  6801. $where .= " and features like '%-$color-%'";
  6802. }
  6803. if ($lowe) {
  6804. $where .= " and features like '%-$lowe-%'";
  6805. }
  6806. if ($haircap) {
  6807. $where .= " and features like '%-$haircap-%'";
  6808. }
  6809. if ($density) {
  6810. $where .= " and features like '%-$density-%'";
  6811. }
  6812. if ($usa) {
  6813. if (!$warehouse) {
  6814. $where .= " and (warehouse = '5' or warehouse = '8')";
  6815. }
  6816. }
  6817. if ($warehouse) {
  6818. $where .= " and warehouse = '$warehouse'";
  6819. }
  6820. if ($purchase) {
  6821. $where .= " and purchase = '$purchase'";
  6822. }
  6823. if ($state) {
  6824. $where .= " and state = '$state'";
  6825. }
  6826. $order_str = "id desc";
  6827. if ($sku) {
  6828. $sku = trim($sku, ' ');
  6829. $sku = trim($sku, ' ');
  6830. $where .= " and sku like '%$sku%'";
  6831. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6832. } else if ($title) {
  6833. $title = trim($title, ' ');
  6834. $title = trim($title, ' ');
  6835. $where .= " and title like '%$title%'";
  6836. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6837. } else {
  6838. //$where .= " and time > '$ktime' and time < '$jtime'";
  6839. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6840. }
  6841. //取得信息列表
  6842. $rows = array();
  6843. $list = array();
  6844. foreach ($info_list as $key => $value) {
  6845. $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'] . '"');
  6846. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6847. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6848. $rows[$key] = $value;
  6849. $warehouse = $this->warehouse->read($value['warehouse']);
  6850. $rows[$key]['warehouse'] = $warehouse['title'];
  6851. $rows[$key]['features'] = $g;
  6852. $rows[$key]['a'] = $x;
  6853. $rows[$key]['b'] = $s;
  6854. }
  6855. $title = "总统计表";
  6856. $titlename = "<table border=1>
  6857. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6858. <tr align='center'>
  6859. <td>仓库</td>
  6860. <td>SKU</td>
  6861. <td>产品名称</td>
  6862. <td>录入总量</td>
  6863. <td>取出总量</td>
  6864. <td>剩余总量</td>
  6865. </tr>
  6866. </table>";
  6867. $filename = $title . ".xls";
  6868. $tail = "";
  6869. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6870. }
  6871. $vip = 0;
  6872. if (isset($_SESSION['api'])) {
  6873. $user = $this->user->get_api($_SESSION['api']);
  6874. if ($user['vip'] == 1) {
  6875. $vip = 1;
  6876. }
  6877. } else {
  6878. header('Location: /');
  6879. exit;
  6880. }
  6881. $post = $this->input->post(NULL, TRUE);
  6882. if (isset($post['page'])) {
  6883. $page = $this->input->post('page', true);
  6884. $perpage = $this->input->post('perpage', true);
  6885. $category = $this->input->post('category', true);
  6886. $size = $this->input->post('size', true);
  6887. $grade = $this->input->post('grade', true);
  6888. $color = $this->input->post('color', true);
  6889. $lowe = $this->input->post('lowe', true);
  6890. $sku = $this->input->post('sku');
  6891. $title = $this->input->post('title');
  6892. $warehouse = $arg_array[0];
  6893. $usa = $this->input->post('usa', true);
  6894. $purchase = $this->input->post('purchase', true);
  6895. $lacetype = $this->input->post('lacetype', true);
  6896. $haircap = $this->input->post('haircap', true);
  6897. $density = $this->input->post('density', true);
  6898. $title = $this->input->post('title', true);
  6899. $state = $this->input->post('state', true);
  6900. $ktime = $this->input->post('ktime', true);
  6901. $jtime = $this->input->post('jtime', true);
  6902. $ktime = strtotime($ktime);
  6903. $jtime = strtotime($jtime);
  6904. $where = "state=11";
  6905. $gj = "";
  6906. $ck = "";
  6907. if ($lacetype) {
  6908. $where .= " and features like '%-$lacetype-%'";
  6909. }
  6910. if ($category) {
  6911. $where .= " and features like '%-$category-%'";
  6912. }
  6913. if ($size) {
  6914. $where .= " and features like '%-$size-%'";
  6915. }
  6916. if ($grade) {
  6917. $where .= " and features like '%-$grade-%'";
  6918. }
  6919. if ($color) {
  6920. $where .= " and features like '%-$color-%'";
  6921. }
  6922. if ($lowe) {
  6923. $where .= " and features like '%-$lowe-%'";
  6924. }
  6925. if ($haircap) {
  6926. $where .= " and features like '%-$haircap-%'";
  6927. }
  6928. if ($density) {
  6929. $where .= " and features like '%-$density-%'";
  6930. }
  6931. if ($usa) {
  6932. if (!$warehouse) {
  6933. $where .= " and (warehouse = '5' or warehouse = '8')";
  6934. }
  6935. }
  6936. if ($warehouse) {
  6937. $where .= " and warehouse = '$warehouse'";
  6938. }
  6939. if ($purchase) {
  6940. $where .= " and purchase = '$purchase'";
  6941. }
  6942. if ($state) {
  6943. $where .= " and state = '$state'";
  6944. }
  6945. if ($ktime && $jtime) {
  6946. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6947. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6948. }
  6949. //数据排序
  6950. $order_str = "id desc";
  6951. $xs = 0;
  6952. $rows = array();
  6953. $list = array();
  6954. if (empty($page)) {
  6955. $start = 0;
  6956. $perpage = 1;
  6957. } else {
  6958. $start = ($page - 1) * $perpage;
  6959. }
  6960. if ($sku || $title) {
  6961. if ($title) {
  6962. $title = trim($title, ' ');
  6963. $title = trim($title, ' ');
  6964. $where .= " and title like '%$title%'";
  6965. } else {
  6966. $sku = trim($sku, ' ');
  6967. $sku = trim($sku, ' ');
  6968. $where .= " and sku like '%$sku%'";
  6969. }
  6970. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6971. foreach ($info_list as $key => $value) {
  6972. $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'] . '"');
  6973. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6974. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6975. $rows[$key] = $value;
  6976. $warehouse = $this->warehouse->read($value['warehouse']);
  6977. $rows[$key]['warehouse'] = $warehouse['title'];
  6978. $rows[$key]['features'] = $g;
  6979. $rows[$key]['a'] = $x;
  6980. $rows[$key]['b'] = $s;
  6981. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6982. $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天销量
  6983. $yj = $c / ($xl / 30);
  6984. if ($yj < 7) {
  6985. $rows[$key]['y'] = round($yj) . '天销量';
  6986. } else {
  6987. $rows[$key]['y'] = '正常';
  6988. }
  6989. }
  6990. } else {
  6991. //$where .= " and time > '$ktime' and time < '$jtime'";
  6992. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6993. foreach ($info_list as $key => $value) {
  6994. $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'] . '"');
  6995. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6996. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6997. $zs[$key] = $value;
  6998. $warehouse = $this->warehouse->read($value['warehouse']);
  6999. $zs[$key]['warehouse'] = $warehouse['title'];
  7000. $zs[$key]['features'] = $g;
  7001. $zs[$key]['a'] = $x;
  7002. $zs[$key]['b'] = $s;
  7003. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7004. $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天销量
  7005. $yj = $c / ($xl / 30);
  7006. if ($yj < 7) {
  7007. $zs[$key]['y'] = round($yj) . '天销量';
  7008. $rows[$key] = $zs[$key];
  7009. }
  7010. }
  7011. }
  7012. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7013. $pagenum = ceil($total / $perpage);
  7014. $over = $total - ($start + $perpage);
  7015. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7016. echo json_encode($rows);
  7017. exit;
  7018. }
  7019. $this->data['arg_array'] = $arg_array[0];
  7020. $this->_Template('whlabel_fcjxc', $this->data);
  7021. }
  7022. public function _0kcdel()
  7023. {
  7024. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7025. $config['upload_path'] = '.' . $dir;
  7026. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7027. $config['allowed_types'] = 'xls|xlsx|csv';
  7028. $config['max_size'] = 10240;
  7029. $this->load->library('upload', $config);
  7030. $this->upload->initialize($config);
  7031. if ($this->upload->do_upload('userfile')) {
  7032. $full_path = $dir . $this->upload->data('file_name');
  7033. $fileName = '.' . $full_path;
  7034. if (!file_exists($fileName)) {
  7035. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7036. exit;
  7037. } else {
  7038. require_once "./data/excel/PHPExcel/IOFactory.php";
  7039. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7040. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7041. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7042. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7043. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7044. ++$column; //如果列数大于26行
  7045. $list = array();
  7046. for ($i = 2; $i <= $row; $i++) // 行数循环
  7047. {
  7048. $data = array();
  7049. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7050. {
  7051. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7052. }
  7053. $list[] = $data;
  7054. }
  7055. }
  7056. $i = 0;
  7057. $j = 0;
  7058. $ed = array();
  7059. foreach ($list as $key => $value) {
  7060. $time = time();
  7061. if ($value['0'] == "" || $value['1'] == "") {
  7062. continue;
  7063. }
  7064. $warehouse = $this->warehouse->get_title($value['0']);
  7065. $sku = $value['1'];
  7066. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7067. if (!$d) //如果没有这个SKU
  7068. {
  7069. $ed[] = array($sku . '-库存中不存在此SKU');
  7070. $j++;
  7071. continue;
  7072. }
  7073. if (!isset($warehouse['id'])) {
  7074. $ed[] = array($sku . '-仓库名错误!');
  7075. $j++;
  7076. continue;
  7077. }
  7078. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7079. if ($z < 1) {
  7080. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7081. foreach ($z as $v) {
  7082. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7083. if (count($zt) > 0) {
  7084. $ed[] = array($sku . '-有在途库存无法删除!');
  7085. $j++;
  7086. continue;
  7087. }
  7088. $this->whlabel->remove($v['id']);
  7089. }
  7090. } else {
  7091. $ed[] = array($sku . '-非0库存!');
  7092. $j++;
  7093. continue;
  7094. }
  7095. }
  7096. if ($j > 0) {
  7097. $tt = date('Ymd', time());
  7098. $title = '删除0库存错误信息-' . $tt;
  7099. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7100. $tail = "\n";
  7101. $filename = $title . ".xls";
  7102. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7103. $dir = '/data/excel/' . $time . '/';
  7104. $file_name = 'error_' . $time . rand(1000, 9999);
  7105. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7106. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7107. fwrite($myfile, $ecl);
  7108. fclose($myfile);
  7109. $error = $dir . $file_name . '.xls';
  7110. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7111. exit;
  7112. } else {
  7113. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7114. exit;
  7115. }
  7116. }
  7117. }
  7118. public function _gbhtype()
  7119. {
  7120. $post = $this->input->post(NULL, TRUE);
  7121. if (isset($post['s'])) {
  7122. $n = $this->input->post('n');
  7123. $d = $this->input->post('s');
  7124. if (!$d) {
  7125. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7126. exit;
  7127. }
  7128. $d = explode(',', trim($d, ','));
  7129. $t = $this->whlabel_type->read($n);
  7130. //循环删除记录
  7131. foreach ($d as $v) {
  7132. $u = $this->whlabel->read($v);
  7133. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7134. foreach ($data as $val) {
  7135. $this->whlabel->save(array('type' => $n), $val['id']);
  7136. }
  7137. }
  7138. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7139. }
  7140. }
  7141. //出库、退库导出
  7142. public function _dccrtype()
  7143. {
  7144. $classid = $this->classid->sku();
  7145. $pm = $classid;
  7146. $typeclass = array();
  7147. $tc = $this->typeclass->find_all();
  7148. foreach ($tc as $v) {
  7149. $typeclass[$v['id']] = $v;
  7150. }
  7151. $prc = array();
  7152. $purchase = $this->purchase->find_all();
  7153. foreach ($purchase as $k => $v) {
  7154. $prc[$v['id']] = $v['title'];
  7155. }
  7156. if (isset($_GET['sid'])) {
  7157. $wh = array();
  7158. $w = $this->warehouse->find_all('1=1', 'id,title');
  7159. foreach ($w as $v) {
  7160. $wh[$v['id']] = $v['title'];
  7161. }
  7162. $type = $this->input->get('excel', true);
  7163. $category = $this->input->get('category', true);
  7164. $size = $this->input->get('size', true);
  7165. $grade = $this->input->get('grade', true);
  7166. $color = $this->input->get('color', true);
  7167. $lowe = $this->input->get('lowe', true);
  7168. $sku = $this->input->get('sku', true);
  7169. $warehouse = $this->input->get('warehouse', true);
  7170. $lacetype = $this->input->get('lacetype', true);
  7171. $lacecolor = $this->input->get('lacecolor', true);
  7172. $density = $this->input->get('density', true);
  7173. $haircap = $this->input->get('haircap', true);
  7174. $purchase = $this->input->get('purchase', true);
  7175. $title = $this->input->get('title', true);
  7176. $state = $this->input->get('state', true);
  7177. $sid = $this->input->get('sid', true);
  7178. $ktime = $this->input->get('ktime', true);
  7179. $jtime = $this->input->get('jtime', true);
  7180. $ktime = strtotime($ktime);
  7181. $jtime = strtotime($jtime);
  7182. $where = "1=1";
  7183. $gj = "";
  7184. $ck = "";
  7185. if ($category) {
  7186. $where .= " and features like '%-$category-%'";
  7187. }
  7188. if ($size) {
  7189. $where .= " and features like '%-$size-%'";
  7190. }
  7191. if ($grade) {
  7192. $where .= " and features like '%-$grade-%'";
  7193. }
  7194. if ($color) {
  7195. $where .= " and features like '%-$color-%'";
  7196. }
  7197. if ($lowe) {
  7198. $where .= " and features like '%-$lowe-%'";
  7199. }
  7200. if ($warehouse) {
  7201. $where .= " and warehouse = '$warehouse'";
  7202. }
  7203. if ($purchase) {
  7204. $where .= " and purchase = '$purchase'";
  7205. }
  7206. if ($state) {
  7207. $where .= " and state = '$state'";
  7208. }
  7209. if ($lacetype) {
  7210. $where .= " and features like '%-$lacetype-%'";
  7211. }
  7212. if ($lacecolor) {
  7213. $where .= " and features like '%-$lacecolor-%'";
  7214. }
  7215. if ($density) {
  7216. $where .= " and features like '%-$density-%'";
  7217. }
  7218. if ($haircap) {
  7219. $where .= " and features like '%-$haircap-%'";
  7220. }
  7221. if ($title) {
  7222. $title = trim($title, ' ');
  7223. $title = trim($title, ' ');
  7224. $where .= " and title like '%$title%'";
  7225. }
  7226. if ($sku) {
  7227. $sku = trim($sku, ' ');
  7228. $sku = trim($sku, ' ');
  7229. $where .= " and sku like '%$sku%'";
  7230. }
  7231. if ($ktime && $jtime) {
  7232. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7233. }
  7234. $sidwhere = '';
  7235. if ($sid) {
  7236. $sd = "";
  7237. $s = explode(',', trim($sid, ','));
  7238. foreach ($s as $value) {
  7239. $sd .= " id = " . $value . " or";
  7240. }
  7241. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7242. }
  7243. //数据排序
  7244. $order_str = "time desc";
  7245. if (empty($page)) {
  7246. $start = 0;
  7247. $perpage = 1;
  7248. } else {
  7249. $start = ($page - 1) * $perpage;
  7250. }
  7251. $wh = array();
  7252. $w = $this->warehouse->find_all('1=1', 'id,title');
  7253. foreach ($w as $v) {
  7254. $wh[$v['id']] = $v['title'];
  7255. }
  7256. $wt = array();
  7257. $whlabel_type = $this->whlabel_type->find_all();
  7258. foreach ($whlabel_type as $v) {
  7259. $wt[$v['id']] = $v['title'];
  7260. }
  7261. $classid = $this->classid->sku();
  7262. $list = array();
  7263. $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');
  7264. foreach ($rows_r as $key => $value) {
  7265. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7266. $pm = $classid;
  7267. $jm = $classid;
  7268. $rows_r[$key]['enter'] = '入库';
  7269. $rows_r[$key]['time'] = $value['enter'];
  7270. if ($value['rktype'] == 1) {
  7271. $rows_r[$key]['rktype'] = '采购入库';
  7272. } else if ($value['rktype'] == 2) {
  7273. $rows_r[$key]['rktype'] = '盘盈调整';
  7274. } else if ($value['rktype'] == 3) {
  7275. $rows_r[$key]['rktype'] = '其他调整入库';
  7276. } else if ($value['rktype'] == 4) {
  7277. $rows_r[$key]['rktype'] = '其他调整入库';
  7278. } else if ($value['rktype'] == 5) {
  7279. $rows_r[$key]['rktype'] = '退库入库';
  7280. } else if ($value['rktype'] == 6) {
  7281. $rows_r[$key]['rktype'] = '退货可用入库';
  7282. } else if ($value['rktype'] == 7) {
  7283. $rows_r[$key]['rktype'] = '形态转换入库';
  7284. } else {
  7285. $rows_r[$key]['rktype'] = '';
  7286. }
  7287. $features = explode('-', trim($value['features'], '-'));
  7288. foreach ($features as $v) {
  7289. if (isset($typeclass[$v])) {
  7290. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7291. $pm[$typeclass[$v]['classid']] = $zh[0];
  7292. }
  7293. if (isset($typeclass[$v])) {
  7294. if (isset($jm[$typeclass[$v]['classid']])) {
  7295. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7296. }
  7297. }
  7298. }
  7299. $zh = implode(" ", $pm);
  7300. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7301. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7302. $rows_r[$key]['zh'] = $zh;
  7303. $jm = array_filter($jm);
  7304. $rows_r[$key]['features'] = implode("-", $jm);
  7305. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7306. }
  7307. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7308. foreach ($rows_c as $key => $value) {
  7309. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7310. $pm = $classid;
  7311. $jm = $classid;
  7312. $rows_c[$key]['time'] = $value['outk'];
  7313. $rows_c[$key]['outk'] = '出库';
  7314. if ($value['cktype'] == 1) {
  7315. $rows_c[$key]['cktype'] = '销售出库';
  7316. } else if ($value['cktype'] == 2) {
  7317. $rows_c[$key]['cktype'] = '销售美国出库';
  7318. } else if ($value['cktype'] == 3) {
  7319. $rows_c[$key]['cktype'] = '盘亏调整';
  7320. } else if ($value['cktype'] == 4) {
  7321. $rows_c[$key]['cktype'] = '其他调整出库';
  7322. } else if ($value['cktype'] == 5) {
  7323. $rows_c[$key]['cktype'] = '形态转换出库';
  7324. } else {
  7325. $rows_c[$key]['cktype'] = '';
  7326. }
  7327. $features = explode('-', trim($value['features'], '-'));
  7328. foreach ($features as $v) {
  7329. if (isset($typeclass[$v])) {
  7330. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7331. $pm[$typeclass[$v]['classid']] = $zh[0];
  7332. }
  7333. if (isset($typeclass[$v])) {
  7334. if (isset($jm[$typeclass[$v]['classid']])) {
  7335. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7336. }
  7337. }
  7338. }
  7339. $zh = implode(" ", $pm);
  7340. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7341. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7342. $rows_c[$key]['zh'] = $zh;
  7343. $jm = array_filter($jm);
  7344. $rows_c[$key]['features'] = implode("-", $jm);
  7345. $rows_c[$key]['number'] = 1;
  7346. }
  7347. $merged = $rows_r;
  7348. foreach ($rows_c as $key => $value) {
  7349. if (isset($merged[$key])) {
  7350. $merged[] = $value;
  7351. } else {
  7352. $merged[$key] = $value;
  7353. }
  7354. }
  7355. usort($merged, function ($a, $b) {
  7356. return $a['time'] - $b['time'];
  7357. });
  7358. foreach ($merged as $key => $value) {
  7359. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7360. }
  7361. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7362. $titlename = "<table border=1>
  7363. <tr align='center'>
  7364. <td>仓库</td>
  7365. <td>SKU</td>
  7366. <td>商品名称</td>
  7367. <td>仓库品名</td>
  7368. <td>料号</td>
  7369. <td>时间</td>
  7370. <td>操作</td>
  7371. <td>类型</td>
  7372. <td>数量</td>
  7373. <td>备注</td>
  7374. </tr>
  7375. </table>";
  7376. $filename = $title . ".xlsx";
  7377. $tail = "";
  7378. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7379. }
  7380. }
  7381. }