123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Specialstock extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_specialstock','specialstock');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_purchase','purchase');
- $this->load->_model('Model_excel','excel');
- $this->load->_model('Model_fullorder','fullorder');
- $this->load->_model('Model_fullordertt','fullordertt');
- $this->load->_model('Model_fullorder_smt','fullorder_smt');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- $this->load->_model('Model_express','express');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_typeclass','typeclass');
- $this->load->_model('Model_country','country');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_kdniao','kdniao');
- $this->load->_model('Model_notice','notice');
- $this->load->_model('Model_dhl','dhl');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_fullorderexcel','fullorderexcel');
- $this->load->_model('Model_ljg','ljg');
- $this->load->_model('Model_usps','usps');
- $this->load->_model('Model_whlabelwz','whlabelwz');
- $this->load->_model('Model_classid','classid');
- $this->load->_model("Model_logic_u9tools","logic_u9tools");
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'existence')//在库标签
- {
- $this->_existence();
- }
- else if($arg == 'cpbqdc')//在库标签
- {
- $this->_cpbqdc();
- }
- else if($arg == 'type')//进销存浏览
- {
- $this->_type($arg_array);
- }
- else if($arg == 'xhctype')//现货仓进销存浏览
- {
- $this->_xhctype($arg_array);
- }
- else if($arg == 'typedy')//进销存浏览店员浏览
- {
- $this->_typedy();
- }
- else if($arg == 'xhctypedy')//现货仓进销存浏览店员浏览
- {
- $this->_xhctypedy();
- }
- else if($arg == 'usatype')//美仓进销存浏览
- {
- $this->_usatype();
- }
- else if($arg == 'usatypeapp')//美仓APP进销存浏览
- {
- $this->_usatypeapp();
- }
- else if($arg == 'enteradd')//入库操作
- {
- $this->_enteradd();
- }
- else if($arg == 'enteredit')//修改
- {
- $this->_enteredit($arg_array);
- }
- else if($arg == 'enter')//入库浏览
- {
- $this->_enter();
- }
- else if($arg == 'xhcenter')//入库浏览
- {
- $this->_xhcenter();
- }
- else if($arg == 'out')//出库浏览
- {
- $this->_out();
- }
- else if($arg == 'label')//出库标签浏览
- {
- $this->_label();
- }
- else if($arg == 'outorder')//独立站出库订单
- {
- $this->_outorder();
- }
- else if($arg == 'soutorder')//速卖通出库订单
- {
- $this->_soutorder();
- }
- else if($arg == 'retreat')//退库订单
- {
- $this->_retreat();
- }
- else if($arg == 'retreatlk')//退库订单
- {
- $this->_retreatlk();
- }
- else if($arg == 'change')//更换标签
- {
- $this->_change();
- }
- else if($arg == 'del')//删除
- {
- $this->_del($arg_array);
- }
- else if($arg == 'exceljxc')//进销存信息导出
- {
- $this->_exceljxc();
- }
- else if($arg == 'excelr')//入库信息导出
- {
- $this->_excelr();
- }
- else if($arg == 'excelct')//出库、退库信息导出
- {
- $this->_excelct();
- }
- else if($arg == 'kcyz')//库存验证
- {
- $this->_kcyz();
- }
- else if($arg == 'kj')//库存扣减
- {
- $this->_kj($arg_array);
- }
- else if($arg == 'presetout')//预设库存导入
- {
- $this->_presetout($arg_array);
- }
- else if($arg == 'presetedit')//预设库存导入
- {
- $this->_presetedit($arg_array);
- }
- else if($arg == 'summary')//汇总导出
- {
- $this->_summary($arg_array);
- }
- else if($arg == 'manifest')//usps发货清单
- {
- $this->_manifest();
- }
- else if($arg == 'abnormal')//占单异常
- {
- $this->_abnormal();
- }
- else if($arg == 'error')
- {
- $this->_error();
- }
- else if($arg == 'ppkc')
- {
- $this->_ppkc();
- }
- else if($arg == 'list')
- {
- $this->_list($arg_array);
- }
- else if($arg == 'hwwz')
- {
- $this->_hwwz();
- }
- else if($arg == 'order')
- {
- $this->_order();
- }
- else if($arg == 'placeorder')
- {
- $this->_placeorder();
- }
- else
- {
- $this->_index();
- }
- }
-
- public function _del($id_arr)
- {
- if($id_arr)
- {
- $id_arr = explode(',',$id_arr);
- //循环删除记录
- foreach ($id_arr as $value)
- {
- $data = $this->specialstock->read($value);
- $z = $this->specialstock->find_all('sku = "'.$data['sku'].'" and number = "'.$data['number'].'" and zd = "" and state = 0 and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
- foreach ($z as $v)
- {
- $this->specialstock->remove($v['id']);
- }
- }
- return json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
- }
- else
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- }
-
- public function _list($arg_array)
- {
- $ppid = array();
- $number = (isset($arg_array[1]))?$arg_array[1]:'no';
- if(!isset($arg_array[2]))
- {
- echo "特殊产品信息错误!清除浏览器缓存后再试";exit;
- }
- $hz = '';
- $bdck = $this->warehouse->get_bdck('specialstock');
- if($bdck)
- {
- if($bdck['hz'] != '' && stripos($arg_array[2],$bdck['hz']) !== false)
- {
- $hz = $bdck['hz'];
- }
- }
- if(stripos($arg_array[2],'-') !== false)
- {
- $dcp = explode('-',$arg_array[2]);
- foreach ($dcp as $v)
- {
- if($hz != '')
- {
- $ppid[] = trim($v,$hz);
- }
- else
- {
- $ppid[] = 0;
- }
- }
- if($hz != '')
- {
- $xzid = trim($dcp[0],$hz);
- }
- else
- {
- $xzid = 0;
- }
- }
- else
- {
- if($arg_array[2] != 0 && $hz != '')
- {
- $xzid = trim($arg_array[2],$hz);//已选择产品用
- $ppid[] = $xzid;
- }
- else
- {
- $xzid = $arg_array[0];//未选择产品用
- $ppid[] = 0;
- }
- }
- $thisdata = $this->specialstock->read($xzid);
- $data = array();$dataw = array();
- //本单已占用的,无论是否已出库
- if(stripos($thisdata['featurespp'],'-149') !== false)//如果是360头套 那么也可以匹配370头套
- {
- $tjd = explode('-',$thisdata['featurespp']);
- $dataally = $this->specialstock->find_all("(featurespp = '".$thisdata['featurespp']."' or featurespp = '".$tjd[0]."-".$tjd[1]."-".$tjd[2]."-329"."') and zd = '".$number."'");
- }
- else
- {
- $dataally = $this->specialstock->find_all("featurespp = '".$thisdata['featurespp']."' and zd = '".$number."'");
- }
- foreach ($dataally as $v)
- {
- $sm = '';
- $zd = ($number == $v['zd'])?1:0;
- $cpid = ($v['cpid']>0)?' - 编码:'.$v['cpid']:'';
- $cpbz = ($v['cpbz']!='')?'<p style="color:#f00">货物说明:'.$v['cpbz'].'</p>':'';
- $features = '-';$c = '';
- $td = explode('-',trim($v['features'],'-'));
- foreach ($td as $va)
- {
- $s = $this->typeclass->read($va);
- if($s['classid'] == '14')
- {
- $c = $va;
- }
- else
- {
- $features .= $va.'-';
- }
- }
-
- foreach ($ppid as $va)
- {
- if($va == $v['id'])
- {
- $sm = '<p style="color:#F00">当前选择的产品</p>';
- }
- else if(stripos($sm,'当前选择的产品') === false)
- {
- $sm = '<p style="color:#F00">本单已占用</p>';
- }
- }
- $tp = $this->typeclass->read($c);
- $data[] = array('id'=>$v['id'],'z'=>$zd,'title'=>$v['title'].$sm,'features'=>$c.','.$features,'cc'=>$tp['spare'],'num'=>1,'details'=>'位置:'.$v['details'].$cpid.$cpbz,'sm'=>$sm);
- }
- //未占用的库存
- if(stripos($thisdata['featurespp'],'-149') !== false)//如果是360头套 那么也可以匹配370头套
- {
- $tjd = explode('-',$thisdata['featurespp']);
- $dataallw = $this->specialstock->find_all("(featurespp = '".$thisdata['featurespp']."' or featurespp = '".$tjd[0]."-".$tjd[1]."-".$tjd[2]."-329"."') and zd = '' and state = '0'");
- }
- else
- {
- $dataallw = $this->specialstock->find_all("featurespp = '".$thisdata['featurespp']."' and zd = '' and state = '0'");
- }
- foreach ($dataallw as $v)
- {
- $zd = ($number == $v['zd'])?1:0;
- $cpid = ($v['cpid']>0)?' - 编码:'.$v['cpid']:'';
- $cpbz = ($v['cpbz']!='')?'<p style="color:#f00">货物说明:'.$v['cpbz'].'</p>':'';
- $features = '-';$c = '';
- $td = explode('-',trim($v['features'],'-'));
- foreach ($td as $va)
- {
- $sm = '';
- $s = $this->typeclass->read($va);
- if($s['classid'] == '14')
- {
- $c = $va;
- }
- else
- {
- $features .= $va.'-';
- }
- foreach ($ppid as $va)
- {
- if($va == $v['id'])
- {
- $sm = '<p style="color:#F00">当前选择的产品,需提交后占单</p>';
- }
- }
- }
- $tp = $this->typeclass->read($c);
- $dataw[] = array('id'=>$v['id'],'z'=>$zd,'title'=>$v['title'].$sm,'ct'=>$v['title'],'features'=>$c.','.$features,'cc'=>$tp['spare'],'num'=>1,'details'=>'位置:'.$v['details'].$cpid.$cpbz);
- }
- $this->data['data'] = $data;
- $this->data['dataw'] = $dataw;
- $this->data['id'] = $arg_array[0];
- $this->data['ppid'] = $ppid;
- $this->_Template('specialstock_list',$this->data);
-
- }
-
-
- //检查是否匹配特殊库存
- public function _ppkc()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['data']))
- {
- $data = $this->input->post('data',true);
- $number = $this->input->post('number',true);
- $whlabel = $this->input->post('whlabel',true);
- $data = explode('|',rtrim($data,'|'));
- $whlabel = explode('|',trim($whlabel,'|'));
- $i = 0;$list = array();$a=array();
- //更具要求特殊仓库存不在有限匹配
- // foreach ($data as $v)
- // {
- // $v = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
- // $vfl = explode('-',trim($v,'-'));
- // $num = explode('-',trim($whlabel[$i],'-'));
- // if(isset($vfl[4]))
- // {
- // if($vfl[4] == 149)//如果是360头套 那么也可以匹配370头套
- // {
- // $pp = $this->specialstock->find_all("featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' and zd = '' and state = '0'");
- // if(!$pp)
- // {
- // $pp = $this->specialstock->find_all("(featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' or featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3]."-329') and zd = '' and state = '0'");
- // }
- // }
- // else
- // {
- // $pp = $this->specialstock->find_all("featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' and zd = '' and state = '0'");
- // }
- // $yzd='';
- // if(isset($num[2]))
- // {
- // preg_match_all('/\d+/',$num[2],$n);
- // $n = join('',$n[0]);
- // $yzd = $this->specialstock->find_all("id = '$n' and zd = '$number'");
- // }
- // if(count($pp) >= $num[1] && !$yzd)
- // {
- // $w = '特殊';//有现货仓的设置后面特殊更改为现货
- // $list[] = array($i,$pp[0]['id'],$w);
- // }
- // else if($yzd)
- // {
- // foreach ($yzd as $val)
- // {
- // if($num[2] == $val['id'].'z')
- // {
- // $w = '特殊';//有现货仓的设置后面特殊更改为现货
- // $list[] = array($i,$yzd[0]['id'],$w);
- // }
- // }
- // }
- // }
- // $i++;
- // }
- if($list)
- {
- echo json_encode(array('list'=>$list,'success'=>true));exit;
- }
- }
-
- }
-
-
- //管理
- public function _index()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $number = $this->input->post('number',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $label = $this->input->post('label',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "1=1 ";
- if($timetk && $timetj)
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- if($state || $state == 0)
- {
- $where .= " and state = '$state'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['outk'] != 0)
- {
- $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
- }
- else
- {
- $info_list[$key]['outk'] = "";
- }
- if($value['printing'] != 0)
- {
- $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
- }
- else
- {
- $info_list[$key]['printing'] = "";
- }
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- if($value['state'] == 0)
- {
- $info_list[$key]['state'] = "在库";
- }
- else if($value['state'] == 1)
- {
- $info_list[$key]['state'] = "出库";
- }
- else if($value['state'] == 2)
- {
- $info_list[$key]['state'] = "退库";
- }
- else if($value['state'] == 3)
- {
- $info_list[$key]['state'] = "调拨中";
- }
- else if($value['state'] == 4)
- {
- $info_list[$key]['state'] = "再加工";
- }
- else if($value['state'] == 5)
- {
- $info_list[$key]['state'] = "维修中";
- }
- else if($value['state'] == 6)
- {
- $info_list[$key]['state'] = "盘亏";
- }
- else if($value['state'] == 7)
- {
- $info_list[$key]['state'] = "更换标签";
- }
- else if($value['state'] == 8)
- {
- $info_list[$key]['state'] = "其它";
- }
- else if($value['state'] == 9)
- {
- $info_list[$key]['state'] = "预设";
- }
- if($value['text'] == "")
- {
- $info_list[$key]['text'] = "";
- }
- $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
- }
- $total = $this->specialstock->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- if(isset($post['outsku']))
- {
- $cz = $this->input->post('cz',true);
- if($cz == '1')
- {
- $sku = $this->input->post('outsku',true);
- if($sku)
- {
- $data = $this->specialstock->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
- }
- $this->specialstock->save(array('state'=>10,'outk'=>time(),'time'=>time()),$data[0]['id']);
- echo json_encode(array('success'=>true));exit;
- }
- }
- else
- {
- $sku = $this->input->post('outsku',true);
- if($sku)
- {
- $data = $this->specialstock->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
- if(count($data) < 1)
- {
- echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
- }
- $this->specialstock->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
- echo json_encode(array('success'=>true));exit;
- }
- }
- }
- $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
- $this->_Template('specialstock',$this->data);
- }
- //在库标签
- public function _existence()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $this->specialstock->remove($v);
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $label = $this->input->post('label',true);
-
- $where = "1=1 and state = 0";
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- //数据排序
- $order_str = "time asc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- if($value['enter'] != 0)
- {
- $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
- }
- else
- {
- $info_list[$key]['enter'] = "";
- }
- if($value['printing'] != 0)
- {
- $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
- }
- else
- {
- $info_list[$key]['printing'] = "";
- }
-
- }
- $total = $this->specialstock->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_existence',$this->data);
- }
-
- public function _typedy()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $wid = $this->specialstock->read($value['id']);
- $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
- $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- $z = count($z);//查看订单号
- $info_list[$key]['features'] = count($c);
- $info_list[$key]['number'] = $z;
- $details = array();
- $cpid = array();
- foreach ($c as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
-
- }
- $total = count($this->specialstock->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_typedy',$this->data);
- }
- //进销存浏览
- public function _type($arg_array)
- {
- $vip = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- if($user['vip'] == 1)
- {
- $vip = 1;
- }
- }
- else
- {
- header('Location: /');exit;
- }
- if(isset($arg_array[0]))
- {
- if($arg_array[0] == 'del')
- {
- $s = $this->input->post('s',true);
- $del = $this->_0kcdel($s);
- echo $del;exit;
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku');
- $title = $this->input->post('title');
- $warehouse = $this->input->post('warehouse',true);
- $usa = $this->input->post('usa',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $haircap = $this->input->post('haircap',true);
- $density = $this->input->post('density',true);
- $details = $this->input->post('details',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $hairnumber = $this->input->post('hairnumber',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($haircap)
- {
- $where .= " and features like '%-$haircap-%'";
- }
- if (!empty($hairnumber)) {
- $where .= " and features like '%-128-%' ";
- if ($hairnumber < 0) {
- $class_list = $this->typeclass->find_all('classid = 43');
- foreach ($class_list as $v) {
- $where .= " and features not like '%-" . $v['id'] . "-%'";
- }
- } else {
- $where .= " and features like '%-$hairnumber-%'";
- }
- }
- if($density)
- {
- $where .= " and features like '%-$density-%'";
- }
- if($usa)
- {
- if(!$warehouse)
- {
- $where .= " and (warehouse = '5' or warehouse = '8')";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- if($state >-1){
- $where .= " and state = '$state'";
- }
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- if($sku)
- {
- $sku = trim($sku,' ');
- $sku = trim($sku,' ');
- $where .= " and sku like '%$sku%'";
- $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
- }
- else if($title)
- {
- $title = trim($title,' ');
- $title = trim($title,' ');
- $where .= " and title like '%$title%'";
- $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
- }
- else
- {
- //$where .= " and time > '$ktime' and time < '$jtime'";
- $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
- }
- //取得信息列表
-
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $wid = $this->specialstock->read($value['id']);
- $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
- $g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
- $x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
- $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$wid['warehouse'].'"');
- $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
- $od = array();$odid = '';
- foreach ($z as $v)
- {
- if(!isset($od[$v['zd']]))
- {
- $od[$v['zd']] = 1;//所有数据sku
- }
- else
- {
- $od[$v['zd']] = $od[$v['zd']]+1;
- }
- }
- foreach ($od as $k=>$vv)
- {
- $odid .= $k.'数量'.$vv;
- }
- $ftime = time()-15*24*3600;
- $z = count($z).'('.$odid.')';//查看订单号
- $info_list[$key]['features'] = count($c);
- $info_list[$key]['g'] = $g;
- $info_list[$key]['x'] = $x;
- $info_list[$key]['t'] = $t;
- $info_list[$key]['z'] = $z;
- $details = array();
- $cpid = array();
- foreach ($c as $k=>$v)
- {
- $details[$v['details']] = $v['details'];
- if($v['cpid'] != 0)
- {
- $cpid[$v['cpid']] = $v['cpid'];
- }
- }
- $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
- }
- $total = count($this->specialstock->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features'));
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['vip'] = $vip;
- $this->_Template('specialstock_type',$this->data);
- }
-
-
-
- public function _xhctypedy()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku',true);
- $details = $this->input->post('details',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "warehouse != '12'";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($details)
- {
- $where .= " and details like '%$details%'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['number'].$value['details'].$value['warehouse']] = $value;//所有数据sku
- }
- foreach ($rows as $k=>$value)
- {
- $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- if($c < 1)
- {
- unset($rows[$k]);
- }
- }
- $rowsdq = array_slice($rows,$start,$perpage);
- foreach ($rowsdq as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
-
- $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- $z = count($z);//查看订单号
- //$z = $od;
- $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'wz'=>$value['details'],'bz'=>$value['cpbz'],'c'=>$c,'z'=>$z);
- }
- $total = count($rows);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_xhctypedy',$this->data);
- }
- //进销存浏览
- public function _xhctype($arg_array)
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($arg_array[0]))
- {
- if($arg_array[0] == 'del')
- {
- $s = $this->input->post('s',true);
- $del = $this->_del($s);
- echo $del;exit;
- }
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku',true);
- $details = $this->input->post('details',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "warehouse != '12'";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($details)
- {
- $where .= " and details like '%$details%'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['number'].$value['details'].$value['warehouse']] = $value;//所有数据sku
- }
- $rowsdq = array_slice($rows,$start,$perpage);
- foreach ($rowsdq as $k=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
- $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $od = array();$odid = '';
- foreach ($z as $v)
- {
- if(!isset($od[$v['zd']]))
- {
- $od[$v['zd']] = 1;//所有数据sku
- }
- else
- {
- $od[$v['zd']] = $od[$v['zd']]+1;
- }
- }
- foreach ($od as $k=>$vv)
- {
- $odid .= $k.'数量'.$vv;
- }
- $number = $value['number'];$ftime = time()-15*24*3600;
- /**
- if($value['shop'] != '')
- {
- $shop = $value['shop'];
- $orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
- $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
- $order = array_merge($orderdlz,$ordersmt);
- $od = 0;$a = '';$orid = '';
- foreach ($order as $v)
- {
- $or = explode('|',ltrim($v['specialstock'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $number)
- {
- $od += $orod[1];
- }
- }
- $orid .= $v['number'].'-';
- }
- }
- else
- {
- $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
- $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '".$value['warehouse']."' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
- $order = array_merge($orderdlz,$ordersmt);
- $od = 0;$a = '';$orid = '';$qt = array();
- foreach ($order as $v)
- {
- $or = explode('|',ltrim($v['specialstock'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $number)
- {
- $czzs = $this->specialstock->find_count("number = '$number' and warehouse = '".$value['warehouse']."' and shop = '".$v['shop']."' and state = 0");
- if($czzs > 0)
- {
- if(isset($qt[$v['shop']]))
- {
- if($qt[$v['shop']] < $orod[1])
- {
- $od += $orod[1];//专属小于单量不计算剩余直接归入通用
- $orid .= $v['number'].'+数量'.$orod[1].'-';
- }
- else
- {
- $qt[$v['shop']] -= $orod[1];
- }
- }
- else
- {
- $qt[$v['shop']] = $czzs;
- }
- }
- else
- {
- $od += $orod[1];
- $orid .= $v['number'].'+数量'.$orod[1].'-';
- }
- }
- }
- }
- }
- **/
- $z = count($z).'('.$odid.')';//查看订单号
- //$z = $od;
- $wz = ($value['cpid'] > 0)?$value['details'].'-'.$value['cpid']:$value['details'];
- $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'wz'=>$wz,'bz'=>$value['cpbz'],'c'=>$c,'g'=>$g,'x'=>$x,'t'=>$t,'z'=>$z);
- }
- $total = count($rows);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_xhctype',$this->data);
- }
-
-
-
- //美仓进销存浏览
- public function _usatype()
- {
- $this->_Template('specialstock_typeusa',$this->data);
- }
- //美仓进销存浏览
- public function _usatypeapp()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $warehouse = '5';
- $title = $this->input->post('title',true);
- $state = $this->input->post('state',true);
-
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($title)
- {
- $st = explode(' ',trim($title,' '));
- foreach ($st as $v)
- {
- $where .= " and title like '%$v%'";
- }
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['sku'].'warehouse'.$value['warehouse']] = $value;//所有数据sku
- }
- $rowsdq = array_slice($rows,$start,$perpage);
- foreach ($rowsdq as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
- $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
- $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
- $od = array();$odid = '';
- $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
- }
- $total = count($rows);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('phone/p_usatypeapp',$this->data);
- }
- //入库操作
- public function _enteradd()
- {
- $dt = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['details']))
- {
- $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
- $order = $this->input->post('order',true);
- $post['details'] = $this->input->post('details',true);
- $post['sku'] = $this->input->post('sku',true);
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother1'] = $this->input->post('wigother1',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- else if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $post[$k] = $v;
- $typeclass = $this->typeclass->read($v);
- if($k != 'size')
- {
- $title .= $typeclass['title']." ";
- }
- }
- }
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- $time = time();
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
- $featurespp = explode('-',trim($featurespp,'-'));
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- for($i=0;$i<$order;$i++)
- {
- $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
- $this->specialstock->insert($post);
- }
- echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('specialstock_enteradd',$this->data);
- }
- //修改产品
- public function _enteredit($arg_array)
- {
- $dt = 0;
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['details']))
- {
- $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
- $id = $this->input->post('id',true);
- $order = $this->input->post('order',true);
- $post['details'] = $this->input->post('details',true);
- $post['sku'] = $this->input->post('sku',true);
- $category = $this->input->post('category',true);
- $list['category'] = $category;
- $list['hairtype'] = $this->input->post('hairtype',true);
- $list['grade'] = $this->input->post('grade',true);
- $size = $this->input->post('size',true);
- $list['size'] = rtrim($size,',');
- $list['hairnumber'] = $this->input->post('hairnumber',true);
- $list['extension'] = $this->input->post('extension',true);
- if($category == 1297)
- {
- $list['sywignumber'] = $this->input->post('sywignumber',true);
- }
- if($category == 1702)
- {
- $list['syhairnumber'] = $this->input->post('syhairnumber',true);
- $list['syother'] = $this->input->post('syother',true);
- }
- if($category == 133)
- {
- $list['fittype'] = $this->input->post('fittype',true);
- $list['acother'] = $this->input->post('acother',true);
- }
- $list['color'] = $this->input->post('color',true);
- $list['lowe'] = $this->input->post('lowe',true);
- $post['warehouse'] = $this->input->post('warehouse',true);
- if($category == 127)
- {
- $list['type'] = $this->input->post('type',true);
- $list['headroad'] = $this->input->post('headroad',true);
- $list['density'] = $this->input->post('density',true);
- if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
- {
- $list['lacesize'] = $this->input->post('lacesize',true);
- }
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- }
- if($category == 128)
- {
- $list['lacetype'] = $this->input->post('lacetype',true);
- $list['haircap'] = $this->input->post('haircap',true);
- $list['density'] = $this->input->post('density',true);
- $list['lacecolor'] = $this->input->post('lacecolor',true);
- $list['lacetypes'] = $this->input->post('lacetypes',true);
- $list['wigother'] = $this->input->post('wigother',true);
- $list['wigother1'] = $this->input->post('wigother1',true);
- $list['wigother2'] = $this->input->post('wigother2',true);
- }
- if($category == 129)
- {
- $list['wide'] = $this->input->post('wide',true);
- }
-
- if($category == 131)
- {
- $list['gifttype'] = $this->input->post('gifttype',true);
- $list['giftother'] = $this->input->post('giftother',true);
- }
-
- if($category == 134)
- {
- $list['pieceweight'] = $this->input->post('pieceweight',true);
- }
- if($category == 1297)
- {
- $list['synthetictype'] = $this->input->post('synthetictype',true);
- $list['sywigother'] = $this->input->post('sywigother',true);
- }
- if($category == 130 || $category == 133 || $category == 1702)
- {
- $list['items'] = $this->input->post('items',true);
- $list['weight'] = $this->input->post('weight',true);
- }
- else if($category == 1702)
- {
- $list['syhairther'] = $this->input->post('syhairther',true);
- }
- foreach($list as $k=>$v)
- {
- if($v != 0)
- {
- $num .=$v;
- $features .=$v.'-';
- $typeclass = $this->typeclass->read($v);
- if($k != 'size')
- {
- $title .= $typeclass['title']." ";
- }
- }
- }
- $typeclass = $this->typeclass->read($list['size']);
- $title .= $typeclass['title'];
- $time = time();
- $post['title'] = rtrim($title,' ');
- $post['number'] = $num;
- $post['features'] = '-'.$features;
- $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
- $featurespp = explode('-',trim($featurespp,'-'));
- $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
- $post['time'] = $time;//操作时间
- $uid = $this->specialstock->read($id);
- $datanum = $this->specialstock->find_count("state = 0 and number = '".$uid['number']."' and zd != ''");
- if($datanum > 0)
- {
- echo json_encode(array('msg'=>'此库存有占单,请解除占单后再修改!','success'=>false));exit;
- }
- $data = $this->specialstock->find_all("number = '".$uid['number']."' and enter = '".$uid['enter']."'");// and enter = '".$uid['enter']."'
- foreach ($data as $v)
- {
- $post['id'] = $v['id'];
- $this->specialstock->save($post,$v['id']);
- }
- echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
- }
- $uid = $this->specialstock->read($arg_array[0]);
- $uid['order'] = $this->specialstock->find_count('enter = '.$uid['enter']);
- $this->data['enter'] = $uid ;
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $whlabelwz = $this->whlabelwz->find_all();
- $this->data['whlabelwz'] = $whlabelwz;
- $this->_Template('specialstock_enteredit',$this->data);
- }
- //入库浏览
- public function _enter()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $sid = $this->specialstock->read($v);
- $info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
- foreach ($info_list as $va)
- {
- $this->specialstock->remove($va['id']);
- }
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $details = $this->input->post('details',true);
- $sku = $this->input->post('sku',true);
- $warehouse = '';//12
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($details)
- {
- $where .= " and details like '%$details%'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($ktime && $jtime)
- {
- $where .= " and enter > '$ktime' and enter < '$jtime'";
- }
- //数据排序
- $order_str = "enter desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*',$order_str);
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['enter'].$value['number']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9');
- $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'details'=>$value['details'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
- }
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list),'abc'=>($where));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_enter',$this->data);
- }
-
- //入库浏览
- public function _xhcenter()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $sid = $this->specialstock->read($v);
- $info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
- foreach ($info_list as $va)
- {
- $this->specialstock->remove($va['id']);
- }
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $details = $this->input->post('details',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "warehouse != '12'";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($details)
- {
- $where .= " and details like '%$details%'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($ktime && $jtime)
- {
- $where .= " and enter > '$ktime' and enter < '$jtime'";
- }
- //数据排序
- $order_str = "enter desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*',$order_str);
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['enter'].$value['number']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9');
- $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'details'=>$value['details'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
- }
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_xhcenter',$this->data);
- }
- //出库浏览
- public function _out()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "state=3";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($ktime && $jtime)
- {
- $where .= " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'sku');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
- }
- $rows = array_unique($rows);//删除重复记录
- foreach ($rows as $key=>$value)
- {
- $data = $this->specialstock->get_sku($value);//获取目前sku的所有数据
- $ck = $this->warehouse->read($data['warehouse']);
- $warehouse = $ck['title'];
- $gy = $this->purchase->read($data['purchase']);
- $purchase = $gy['purchase'];
- $g = $this->specialstock->find_count($where.' and sku = "'.$value.'" and state = 3');
- $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);
- }
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_out',$this->data);
- }
-
- //出库标签浏览
- public function _label()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
-
- $where = "state=1";
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- //数据排序
- $order_str = "outk desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['outk'] != 0)
- {
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
- }
- else
- {
- $info_list[$key]['outk'] = "";
- }
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- }
- $total = $this->specialstock->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_label',$this->data);
- }
- //独立站出库订单
- public function _outorder()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $xztime = $this->input->post('xztime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $express = $this->input->post('express',true);
- $waybill = $this->input->post('waybill',true);
- $library = $this->input->post('library',true);
- $country = $this->input->post('country',true);
- $so = $this->input->post('so',true);
- $libraryconfirm = $this->input->post('libraryconfirm',true);
- $print = $this->input->post('print',true);
- $state = $this->input->post('state',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- /**
- $sj = $this->input->post('sj',true);
- if($sj)
- {
- $sj = $this->input->post('sj',true);
- }
- else
- {
- $sj = "fullorder";
- }
- **/
- $sj = "fullorder";
- $where = "mergeid = 0";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($libraryconfirm)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- else
- {
- if(isset($_SESSION['api']))
- {
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- }
- $where .= " and (".rtrim($fgshop,'or').")";
- }
- }
- //数据排序
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->$sj->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=2','*','idorder desc');//导出模板
- $this->_Template('specialstock_outorder',$this->data);
- }
-
- //速卖通出库订单
- public function _soutorder()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $xztime = $this->input->post('xztime',true);
- $timetk = $this->input->post('timetkk',true);
- $timetj = $this->input->post('timetjj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $express = $this->input->post('express',true);
- $waybill = $this->input->post('waybill',true);
- $library = $this->input->post('library',true);
- $country = $this->input->post('country',true);
- $libraryconfirm = $this->input->post('libraryconfirm',true);
- $print = $this->input->post('print',true);
- $state = $this->input->post('state',true);
- $so = $this->input->post('so',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- /**
- $sj = $this->input->post('sj',true);
- if($sj)
- {
- $sj = $this->input->post('sj',true);
- }
- else
- {
- $sj = "fullorder";
- }
- **/
- $sj = "fullordersmt";
- $where = "mergeid = 0";
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($print)
- {
- $where .= " and print = '$print'";
- }
- if($libraryconfirm)
- {
- $where .= " and libraryconfirm = '$libraryconfirm'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($so)
- {
- $where .= " and shipremarks like '%$so%'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- else
- {
- if(isset($_SESSION['api']))
- {
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- }
- $where .= " and (".rtrim($fgshop,'or').")";
- }
- }
- //数据排序
- $order_str = "librarytime desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- if($value['librarytime'] == '0')
- {
- $info_list[$key]['librarytime'] = '<em class="t"></em>';
- }
- else
- {
- $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
- }
- }
- $total = $this->$sj->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=5','*','idorder desc');//导出模板
- $this->_Template('specialstock_soutorder',$this->data);
- }
-
- //订单退库
- public function _retreat()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $warehouse = $this->input->post('warehouse',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $state = $this->input->post('state',true);
- $review = $this->input->post('review',true);
- $state = $this->input->post('state',true);
- $express = $this->input->post('express',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $user = $this->input->post('user',true);
- $name = $this->input->post('name',true);
- $waybill = $this->input->post('waybill',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "(state=206 or state=210) and mergeid = 0";
- if($warehouse)
- {
- $where .= " and state = '$warehouse'";
- }
- if($timetk && $timetj)
- {
- $where .= " and buytime > '$timetk' and buytime < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($review)
- {
- $where .= " and review = '$review'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($express)
- {
- $where .= " and express = '$express'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($name)
- {
- $where .= " and name = '$name'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
- $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['title'];
- $typeclass = $this->typeclass->read($value['state']);
- $info_list[$key]['state'] = $typeclass['title'];
- }
- $total = $this->fullorder->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->data['express'] = $this->express->find_all();
- $this->_Template('specialstock_retreat',$this->data);
- }
- //退库标签浏览
- public function _retreatlk()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $waybill = $this->input->post('waybill',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $state = $this->input->post('state',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
-
- $where = "state=2";
- if($timetk && $timetj)
- {
- $where .= " and retreat > '$timetk' and retreat < '$timetj'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($waybill)
- {
- $where .= " and waybill = '$waybill'";
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
- $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
- $purchase = $this->purchase->read($value['purchase']);
- $info_list[$key]['purchase'] = $purchase['title'];
- if($value['outk'] != 0)
- {
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
- }
- else
- {
- $info_list[$key]['outk'] = "";
- }
- if($value['retreat'] != 0)
- {
- $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
- }
- else
- {
- $info_list[$key]['retreat'] = "";
- }
- if($value['orderinfo'] == 0)
- {
- $info_list[$key]['orderinfo'] = "";
- }
- if($value['waybill'] == 0)
- {
- $info_list[$key]['waybill'] = "";
- }
- }
- $total = $this->specialstock->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_retreatlk',$this->data);
- }
- //更换标签及浏览
- public function _change()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $label = $this->input->post('label',true);
- $oldlabel = $this->input->post('oldlabel',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "state=10 ";
- if($timetk && $timetj)
- {
- $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
- }
- if($label)
- {
- $where .= " and label = '$label'";
- }
- if($oldlabel)
- {
- $where .= " and oldlabel = '$oldlabel'";
- }
- //数据排序
- $order_str = "time asc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
- }
- $total = $this->specialstock->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_change',$this->data);
- }
-
- //产品标签
- public function _cpbqdc()
- {
- if(isset($_GET['excel']))
- {
- $where = "1=1";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $warehouse = $this->input->get('warehouse',true);
- $state = $this->input->get('state',true);
- $timetk = $this->input->get('timetkk',true);
- $timetj = $this->input->get('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($state || $state == 0)
- {
- $where .= " and state = '$state'";
- }
- if($timetk && $timetj)
- {
- $where .= " and time > '$timetk' and time < '$timetj'";
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['time']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $s = $this->specialstock->find_count($where.' and time = "'.$value['time'].'"');
- $list[] = array($warehouse['title'],$value['sku'],$value['title'],date('Y-m-d H:i:s',$value['enter']),date('Y-m-d H:i:s',$value['time']),$value['details'],$s);
- }
- $title = "产品标签统计表";
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>仓库</td>
- <td>SKU</td>
- <td>产品</td>
- <td>入库时间</td>
- <td>操作时间</td>
- <td>备注</td>
- <td>数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- //进销存导出
- public function _exceljxc()
- {
- if(isset($_GET['excel']))
- {
- $where = "1=1";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $category = $this->input->get('category',true);
- $warehouse = $this->input->get('warehouse',true);
- $pc = $this->input->get('pc',true);
- if($pc)
- {
- $pc = trim($pc,'x');
- $pc = explode('x',$pc);
- foreach ($pc as $v)
- {
- $where .= " and warehouse != '".$v."'";
- }
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- //取得信息列表
- $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,features,sku,details,warehouse,number,title,cpbz');
- $list = array();
- // foreach ($info_list as $value)
- // {
- // $classid = $this->classid->sku();
- // $pm = $classid;
- // //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
- // $features = explode('-',trim($value['features'],'-'));
- // foreach ($features as $v)
- // {
- // $typeclass = $this->typeclass->read($v);
- // $pm[$typeclass['classid']] = $typeclass['zh'];
- // //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
- // }
- // $typeclass = $this->typeclass->read($v);
- // //$scsku = implode("-",$scsku);
- // $zh = implode(" ",$pm);
- // $zh = str_replace('自然色 ','',rtrim($zh,' '));
- // //$scsku = str_replace('- ','-',trim($scsku,'-'));
- // //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- // $cpid = '';
- // $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"','cpid');
- // foreach ($c as $v)
- // {
- // if($v['cpid'] != 0)
- // {
- // $cpid .= $v['cpid'].' ';
- // }
- // }
- // $g = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
- // $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- // $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "2" and features = "'.$value['features'].'"');
- // $number = $value['number'];$ftime = time()-15*24*3600;
- // $warehouse = $this->warehouse->read($value['warehouse']);
- // $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$u9_code,$g,count($c),$x,$t,$value['cpbz']);
- // }
- $classid = $this->classid->sku();
- $tcall = $this->typeclass->find_all();
- foreach ($tcall as $v)
- {
- //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
- $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
- }
- foreach ($info_list as $value)
- {
-
- $tmp_r = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
- $zh = $tmp_r['zh'];
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- $u9_code = $tmp_r['jm'];
- $cpid = '';
- $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"','cpid');
- foreach ($c as $v)
- {
- if($v['cpid'] != 0)
- {
- $cpid .= $v['cpid'].' ';
- }
- }
- $g = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
- $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
- $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "2" and features = "'.$value['features'].'"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$u9_code,$g,count($c),$x,$t,$value['cpbz']);
- }
- $title = "总进销存统计表";
- $titlename = "<table border=1>
- <tr><th colspan='10' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>位置</td>
- <td>库存编码</td>
- <td>产品</td>
- <td>SKU</td>
- <td>中文</td>
- <td>u9料号</td>
- <td>入库总量</td>
- <td>库存数量</td>
- <td>销售数量</td>
- <td>退货数量</td>
- <td>备注</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
-
- //入库导出
- public function _excelr()
- {
- if(isset($_GET['excel']))
- {
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $purchase = $this->input->get('purchase',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- $pc = $this->input->get('pc',true);
- if($pc)
- {
- $pc = trim($pc,'x');
- $pc = explode('x',$pc);
- foreach ($pc as $v)
- {
- $where .= " and warehouse != '".$v."'";
- }
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($ktime && $jtime)
- {
- $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_pc($where,'enter','*',$order_str);
- $list = array();
- foreach ($info_list as $value)
- {
- $ck = $this->warehouse->read($value['warehouse']);
- $warehouse = $ck['title'];
- $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
- $retreatwarehouse = $tkck['title'];
- $gy = $this->purchase->read($value['purchase']);
- $purchase = $gy['title'];
- $cpid = '';
- $g = $this->specialstock->find_all($where.' and enter = "'.$value['enter'].'"','cpid');
- foreach ($g as $v)
- {
- if($v['cpid'] != 0)
- {
- $cpid .= $v['cpid'].' ';
- }
- }
- $list[] = array('details'=>$value['details'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>count($g),'cpid'=>$cpid);
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
- $titlename = "<table border=1>
- <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>备注</td>
- <td>产品</td>
- <td>时间</td>
- <td>数量</td>
- <td>编码</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
-
- //出库、退库导出
- public function _excelct()
- {
- if(isset($_GET['excel']))
- {
- $type = $this->input->get('excel',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $lacetype = $this->input->get('lacetype',true);
- $details = $this->input->get('details',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $purchase = $this->input->get('purchase',true);
- $state = $this->input->get('state',true);
- $sid = $this->input->get('sid',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";$gj = "";$ck = "";
- $pc = $this->input->get('pc',true);
- if($pc)
- {
- $pc = trim($pc,'x');
- $pc = explode('x',$pc);
- foreach ($pc as $v)
- {
- $where .= " and warehouse != '".$v."'";
- }
- }
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($details)
- {
- $where .= " and details like '%$details%'";
- }
- if($ktime && $jtime)
- {
- if($type == 1)
- {
- $tl = '出库';
- $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
- }
- else if($type == 2)
- {
- $tl = '退库';
- $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
- }
- else if($type == 3)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- else if($type == 4)
- {
- $tl = '出库+零售';
- $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
- }
- else if($type == 5)
- {
- $tl = '零售';
- $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
- }
- }
- if($sid)
- {
- $sd = "";
- $s = explode(',',trim($sid,','));
- foreach ($s as $value)
- {
- $sd .= " id = ".$value." or";
- }
- $sidwhere .= " and (".rtrim($sd,'or').")";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- if($type != 3 && $type != 5)
- {
- if($type == 1 || $type == 4)
- {
- $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,outk,cpbz',$order_str);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
- }
- }
- else
- {
- $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,retreat,cpbz',$order_str);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
- }
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
- $titlename = "<table border=1>
- <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>位置</td>
- <td>产品编码</td>
- <td>产品</td>
- <td>标签</td>
- <td>订单号</td>
- <td>运单号</td>
- <td>".$tl."时间(中国时间)</td>
- <td>备注</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
- }
- else if($type == 5)
- {
- $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,outk,cpbz',$order_str);
- foreach ($info_list as $key=>$value)
- {
- $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
- $warehouse = $this->warehouse->read($value['warehouse']);
- $info_list[$key]['warehouse'] = $warehouse['title'];
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
- $titlename = "<table border=1>
- <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>位置</td>
- <td>产品编码</td>
- <td>产品</td>
- <td>标签</td>
- <td>".$tl."时间(中国时间)</td>
- <td>备注</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
- }
- else
- {
- $info_list = $this->specialstock->find_pc($where.$sidwhere,'sku,warehouse,features','*');
- $list = array();
- foreach ($info_list as $value)
- {
- $classid = $this->classid->sku();
- $pm = $classid;
- //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
- $features = explode('-',trim($value['features'],'-'));
- foreach ($features as $v)
- {
- $typeclass = $this->typeclass->read($v);
- $pm[$typeclass['classid']] = $typeclass['zh'];
- //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
- }
- $typeclass = $this->typeclass->read($v);
- //$scsku = implode("-",$scsku);
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- //$scsku = str_replace('- ','-',trim($scsku,'-'));
- //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $cpid = '';
- $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"','cpid');
- foreach ($c as $v)
- {
- if($v['cpid'] != 0)
- {
- $cpid .= $v['cpid'].' ';
- }
- }
- $g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state != "9"');
- $x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "1"');
- $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "2"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$g,count($c),$x,$t,$value['cpbz']);
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
- $titlename = "<table border=1>
- <tr><th colspan='9' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>位置</td>
- <td>库存编码</td>
- <td>产品</td>
- <td>SKU</td>
- <td>中文</td>
- <td>入库总量</td>
- <td>库存数量</td>
- <td>销售数量</td>
- <td>退货数量</td>
- <td>备注</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- }
-
- //数量调整模板导出
- public function _presetout()
- {
- if(isset($_GET['excel']))
- {
- $where = "1=1";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $pc = $this->input->get('pc',true);
- if($pc)
- {
- $pc = trim($pc,'x');
- $pc = explode('x',$pc);
- foreach ($pc as $v)
- {
- $where .= " and warehouse != '".$v."'";
- }
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['number']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $number = $value['number'];$ftime = time()-15*24*3600;
- $list[] = array($value['features'],$value['sku'],'0','','0',$warehouse['title']);
- }
- $title = "库存模板";
- $titlename = "<table border=1>
- <tr align='center'>
- <td>编码号</td>
- <td>SKU</td>
- <td>增减数量(正数或负数)</td>
- <td>扣减备注</td>
- <td>扣减方式:0减少库存1删除库存</td>
- <td>所属仓库</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- //数量调整模板导入
- public function _presetedit()
- {
- $dir = '/data/excel/'.date('Ymd',time()).'/';
- $config['upload_path'] = '.'.$dir ;
- $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
- $config['allowed_types'] = 'xls|xlsx|csv';
- $config['max_size'] = 10240;
- $this->load->library('upload', $config);
- $this->upload->initialize($config);
- if ($this->upload->do_upload('userfile'))
- {
- $full_path = $dir.$this->upload->data('file_name');
- $fileName = '.' . $full_path;
- if (!file_exists($fileName))
- {
- echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
- }
- else
- {
- libxml_use_internal_errors(true);
- require_once "./data/excel/PHPExcel/IOFactory.php";
- $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
- $phpExcel->setActiveSheetIndex(0);// 设置为默认表
- $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
- $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
- $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
- ++$column;//如果列数大于26行
- $list = array();
- for ($i = 2; $i <= $row; $i++) // 行数循环
- {
- $data = array();
- for ($c = 'A'; $c != $column; $c++) // 列数循环
- {
- $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
- }
- $list[] = $data;
- }
- }
- $i = 0;$j = 0;$ed = array();
- foreach ($list as $key=>$value)
- {
- $time = time();
- if($value['0'] == "")
- {
- continue;
- }
- $features = $value['0'];
- $num = $value['2'];//调整数量
- $text = $value['3'];//扣减说明
- $type = $value['4'];//调整方式0扣减1删除
- $d = $this->specialstock->get_features($features);
- if(!$d)//如果没有这个SKU
- {
- $ed[] = array($title.'-库存中不存在此编码');
- $j++;
- continue;
- }
- if($num < 0)//扣减库存
- {
- $data = $this->specialstock->find_all('warehouse = "'.$warehouse['id'].'" and features = "'.$features.'" and zd = "" and state = 0');
- if(count($data) < abs($num))
- {
- $ed[] = array($title.'-扣减数量大于库存剩余数量!');
- $j++;
- continue;
- }
- if($type == 0)//如果扣减方式为 扣减库存
- {
- for($i=0;$i<abs($num);$i++)
- {
- $this->specialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$data[$i]['id']);
- }
- }
- else
- {
- for($i=0;$i<abs($num);$i++)
- {
- $this->specialstock->remove($data[$i]['id']);
- }
- }
- }
- else if($num > 0)//增加库存
- {
- $post['shop'] = $d['shop'];
- $post['purchase'] = $d['purchase'];
- $post['retreatwarehouse'] = $d['retreatwarehouse'];
- $post['state'] = 0;
- $post['title'] = $d['title'];
- $post['number'] = $d['number'];
- $post['features'] = $d['features'];
- $post['enter'] = $time;
- $post['time'] = $time;//操作时间
- for($i=0;$i<$num;$i++)
- {
- $post['label'] = time().rand(100,999).$i;
- $this->specialstock->insert($post);
- }
- }
- sleep(1);//防止入库时间一样,需要延迟1秒
- }
- if($j > 0)
- {
- $tt = date('Ymd',time());
- $title = '库存导入错误信息-'.$tt;
- $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
- $tail = "\n";
- $filename = $title.".xls";
- $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
- $dir = '/data/excel/'.$time.'/';
- $file_name = 'error_'.$time.rand(1000,9999);
- if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
- $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
- fwrite($myfile,$ecl);
- fclose($myfile);
- $error = $dir.$file_name.'.xls';
- echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
- }
- }
- }
- //笛卡儿积
- function cp($ps,$sets,$list)
- {
- $result = array();$j=0;
- for($i=0,$count=count($sets); $i<$count-1; $i++)
- {
- if($i==0)
- {
- $result = $sets[$i];
- }
- $tmp = array();
- foreach($result as $res)
- {
- foreach($sets[$i+1] as $set)
- {
- $tmp[] = $res.','.$set;
- }
- }
- $result = $tmp;
- }
- $this->db->trans_begin();
- foreach ($result as $v)
- {
- $post = array();$title = "";$num="";
- $data = explode(',',$v);
- for($i=0;$i<count($list); $i++)
- {
- $post[$list[$i]] = $data[$i];
- $typeclass = $this->typeclass->read($data[$i]);
- $title = $title.$typeclass['title']." ";
- if($data[$i] != 0)
- {
- $num .=$data[$i];//所有数据ID拼接
- }
- }
- foreach ($ps as $kp=>$vp)
- {
- $post[$kp] = $vp;
- }
- $post['number'] = $num;
- $info_list = $this->specialstock->get_number($num);//查询specialstock是否存在此拼接的数据ID
- if($info_list)
- {
- $j++;
- }
- else
- {
- $skunum = $this->specialstock->find_count();
- $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
- $post['title'] = rtrim($title,' ');
- $this->specialstock->insert($post);
- }
-
- }
- if ($this->db->trans_status() === FALSE)
- {
- $this->db->trans_commit();
- return NULL;
- }
- else
- {
- $this->db->trans_commit();
- return $j;
- }
- }
- public function _kj($arg_array)
- {
- if(isset($_POST['number']))
- {
- $time = time();
- $number = $this->input->post('number',true);
- $num = $this->input->post('num',true);
- $text = $this->input->post('text',true);
- $order = $this->specialstock->find_all("number = '$number' and zd = '' and state = 0");
- if($num > count($order))
- {
- echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
- }
- else
- {
- for($i=0;$i<$num;$i++)
- {
- $this->specialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$order[$i]['id']);
- }
- }
- echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
- }
- $uid = $this->specialstock->read($arg_array[0]);
- $uid['num'] = $this->specialstock->find_count('number = "'.$uid['number']. '" and zd = "" and state = 0');
- $this->data['data'] = $uid ;
- $this->_Template('specialstock_kj',$this->data);
- }
- public function _summary($arg_array)
- {
- if(isset($_GET['excel']))
- {
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1";
- if($ktime && $jtime)
- {
- $where .= " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "time desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $pc = $this->input->get('pc',true);
- if($pc)
- {
- $pc = trim($pc,'x');
- $pc = explode('x',$pc);
- foreach ($pc as $v)
- {
- $where .= " and warehouse != '".$v."'";
- }
- }
- //取得信息列表
- $info_list = $this->specialstock->find_pc($where,'number','*');
- foreach ($info_list as $value)
- {
- $xcpid = '';$scpid = '';
- $x = $this->specialstock->find_all($where.' and number = "'.$value['number'].'"');
- foreach ($x as $v)
- {
- if($v['cpid'] != 0)
- {
- $xcpid .= $v['cpid'].' ';
- }
- }
- $s = $this->specialstock->find_all('state = 0 and number = "'.$value['number'].'"');
- foreach ($s as $v)
- {
- if($v['cpid'] != 0)
- {
- $scpid .= $v['cpid'].' ';
- }
- }
- $list[] = array('details'=>$value['details'],'title'=>$value['title'],'s'=>count($s),'x'=>count($x),'scpid'=>$scpid,'xcpid'=>$xcpid,'outk'=>date('Y-m-d H:i:s',$value['outk']));
- }
- $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
- $titlename = "<table border=1>
- <tr align='center'>
- <td>仓库备注</td>
- <td>产品名</td>
- <td>总剩余库存</td>
- <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
- <td>剩余产品编码</td>
- <td>销售产品编码</td>
- <td>出库时间</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
- }
- //usps发货清单
- public function _manifest()
- {
- if(isset($_POST['manifest']))
- {
- $wltext = $this->input->post('wltext',true);
- $time = time()-16*3600;
- $ptime = strtotime(date('Y-m-d',$time));
- $waybill = array();
- $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
- foreach ($fullorder as $v)
- {
- $waybill[$v['waybill']] = $v['waybill'];
- }
- $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
- foreach ($fullordersmt as $v)
- {
- $waybill[$v['waybill']] = $v['waybill'];
- }
- $wltext = explode(';',$wltext);
- foreach ($wltext as $v)
- {
- if(isset($waybill[$v]))
- {
- unset($waybill[$v]);
- }
- }
- $data = $this->usps->get_manifest($waybill);
- if(isset($data['Description']))
- {
- echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
- }
- else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
- {
- $bctime = date('Ymd',time());
- $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
- echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>$data,'success'=>false));exit;
- }
- }
- }
- public function _pdf($pdf,$title,$bctime)
- {
- $pdf_path = './data/pdf/'.$bctime.'/';
- $file_base64 = $pdf;
- $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
- $file_base64 = base64_decode($file_base64);
- if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
- file_put_contents($pdf_path.$title.'.pdf',$file_base64);
- return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
- }
-
-
-
-
- /**
- *
- *
- *
- 进销存占单异常索引
- *
- *
- *
- **/
-
- public function _abnormal()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $where = "1=1";
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['sku']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- if($value['shop'] != '')
- {
- $shop = $value['shop'];
- $orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
- $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
- $order = array_merge($orderdlz,$ordersmt);
- $od = 0;$a = '';$orid = '';
- foreach ($order as $v)
- {
- $or = explode('|',ltrim($v['specialstock'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $number)
- {
- $od += $orod[1];
- }
- }
- $orid .= $v['number'].'-';
- }
- }
- else
- {
- $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
- $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
- $order = array_merge($orderdlz,$ordersmt);
- $od = 0;$a = '';$orid = '';$qt = array();
- foreach ($order as $v)
- {
- $or = explode('|',ltrim($v['specialstock'],'|'));
- for($i=0;$i<count($or);$i++)
- {
- $orod = explode('-',$or[$i]);
- if($orod[0] == $number)
- {
- $czzs = $this->specialstock->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
- if($czzs > 0)
- {
- if(isset($qt[$v['shop']]))
- {
- if($qt[$v['shop']] < $orod[1])
- {
- $od += $orod[1];//专属小于单量不计算剩余直接归入通用
- $orid .= $v['number'].'+数量'.$orod[1].'-';
- }
- else
- {
- $qt[$v['shop']] -= $orod[1];
- }
- }
- else
- {
- $qt[$v['shop']] = $czzs;
- }
- }
- else
- {
- $od += $orod[1];
- $orid .= $v['number'].'+数量'.$orod[1].'-';
- }
- }
- }
- }
- }
- $z = $od.'('.$orid.')';//查看订单号
- //$z = $od;
- if($od > $c)
- {
- $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
- }
- }
- $listdata = array_slice($list,$start,$perpage);
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_abnormal',$this->data);
- }
- /**
- *
- *
- *
- 进销存占单异常索引
- *
- *
- *
- **/
-
- public function _error()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $sku = $this->input->post('sku',true);
- $warehouse = $this->input->post('warehouse',true);
- $where = "1=1";
- if($sku)
- {
- $where .= " and sku = '$sku'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- if($value['sku'] != '')
- {
- $rows[$value['sku']] = $value;//所有数据sku
- }
- }
- foreach ($rows as $value)
- {
- $warehouse = $this->warehouse->read($value['warehouse']);
- $c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- if($c < 1)
- {
- $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
- }
- }
- $listdata = array_slice($list,$start,$perpage);
- $total = count($list);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
- echo json_encode($rows);exit;
- }
- if(isset($post['s']))
- {
- $id_arr = $this->input->post('s');
- $id_arr = explode(',',$id_arr);
- if(!$id_arr)
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- //循环删除记录
- foreach ($id_arr as $v)
- {
- $dd = $this->specialstock->read($v);
- $deldd = $this->specialstock->find_all("sku = '".$dd['sku']."'");
- foreach ($deldd as $vv)
- {
- $this->specialstock->remove($vv['id']);
- }
- }
- echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
- }
- $this->_Template('specialstock_error',$this->data);
- }
- /**
- *
- *
- * 占单
- *
- *
- **/
- public function _kcyz()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['warehouse']))
- {
- $warehouse = $this->input->post('warehouse',true);
- $specialstock = $this->input->post('specialstock',true);
- $id = $this->input->post('id',true);
- $shop = $this->input->post('shop',true);
- $number = $this->input->post('number',true);
- if(!$specialstock || $specialstock == '|')
- {
- return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
- }
- $pp = explode('|',trim($specialstock,'|'));
- $x = 0;$save = array();
- foreach ($pp as $va)
- {
- $num = explode('-',$va);
- if($number)
- {
- $specialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')");//通用
- $shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
- }
- else
- {
- $specialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
- $shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
- }
- $x++;
- if(count($specialstock)+count($shopspecialstock) < $num[1])
- {
- $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
- }
- }
- if(isset($save[0]))
- {
- echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
- }
- else
- {
- echo json_encode(array('success'=>true));exit;
- }
- }
- }
-
-
- public function _hwwz()//货物位置
- {
- if(isset($_GET['id']))
- {
- $id = $this->input->get('id',true);
- $sku = $this->input->get('sku',true);
- $bs = $this->input->get('bs',true);
- $number = $this->input->get('number',true);
- $warehouse = $this->input->get('warehouse',true);
- $purchase = $this->input->get('purchase',true);
- $orderinfo = $this->input->get('orderinfo',true);
- $waybill = $this->input->get('waybill',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $state = $this->input->get('state',true);
- $label = $this->input->get('label',true);
- $px = $this->input->get('px',true);
- $details = $this->input->get('details',true);
- $timetk = $this->input->get('timetkk',true);
- $timetj = $this->input->get('timetjj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "state='0'";
- //数据排序
- $order_str = $px." desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $category = $this->input->get('category',true);
- $warehouse = $this->input->get('warehouse',true);
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($details)
- {
- $where .= " and details = '$details'";
- }
- if($id != '')
- {
- $sid = "";
- $usersp = explode(',',trim($id,','));
- foreach ($usersp as $value)
- {
- $sid .= " id = ".$value." or";
- }
- $info_list = $this->specialstock->find_all($where." and (".rtrim($sid,'or').")",'*','details desc');
- }
- else
- {
- $info_list = $this->specialstock->find_all($where,'*','details desc');
- }
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['sku'].$value['warehouse'].$value['details']] = $value;//所有数据sku
- }
- foreach ($rows as $value)
- {
- $classid = $this->classid->sku();
- $pm = $classid;
- //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
- $features = explode('-',trim($value['features'],'-'));
- foreach ($features as $v)
- {
- $typeclass = $this->typeclass->read($v);
- $pm[$typeclass['classid']] = $typeclass['zh'];
- //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
- }
- $typeclass = $this->typeclass->read($v);
- //$scsku = implode("-",$scsku);
- $zh = implode(" ",$pm);
- $zh = str_replace('自然色 ','',rtrim($zh,' '));
- //$scsku = str_replace('- ','-',trim($scsku,'-'));
- //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
- $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"');
- $number = $value['number'];$ftime = time()-15*24*3600;
- $warehouse = $this->warehouse->read($value['warehouse']);
- $list[] = array($value['id'],$value['details'],$zh,$c);
- }
- $title = "库存表";
- $titlename = "";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($list,$titlename,$filename,$tail);
- }
-
- }
-
- public function _order()
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($arg_array[0]))
- {
- if($arg_array[0] == 'del')
- {
- $s = $this->input->post('s',true);
- $del = $this->_del($s);
- echo $del;exit;
- }
- }
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $category = $this->input->post('category',true);
- $size = $this->input->post('size',true);
- $grade = $this->input->post('grade',true);
- $color = $this->input->post('color',true);
- $lowe = $this->input->post('lowe',true);
- $sku = $this->input->post('sku',true);
- $details = $this->input->post('details',true);
- $warehouse = $this->input->post('warehouse',true);
- $purchase = $this->input->post('purchase',true);
- $lacetype = $this->input->post('lacetype',true);
- $state = $this->input->post('state',true);
- $ktime = $this->input->post('ktime',true);
- $jtime = $this->input->post('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "zd =''";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and features like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and features like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and features like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and features like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and features like '%-$lowe-%'";
- }
- if($lacetype)
- {
- $where .= " and features like '%-$lacetype-%'";
- }
- if($warehouse)
- {
- $where .= " and warehouse = '$warehouse'";
- }
- if($purchase)
- {
- $where .= " and purchase = '$purchase'";
- }
- if($state)
- {
- $where .= " and state = '$state'";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($details)
- {
- $where .= " and details like '%$details%'";
- }
- if($ktime && $jtime)
- {
- $gj = " and enter > '$ktime' and enter < '$jtime'";
- $ck = " and outk > '$ktime' and outk < '$jtime'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->specialstock->find_all($where,'*');
- $rows = array();$list = array();
- foreach ($info_list as $key=>$value)
- {
- $rows[$value['number'].$value['warehouse']] = $value;//所有数据sku
- }
- $rowsdq = array_slice($rows,$start,$perpage);
- $inch = '';$zh = '';
- $classid = $this->classid->sku();
- $pm = $classid;
- foreach ($rowsdq as $value)
- {
- $features = '-';
- $td = explode('-',trim($value['features'],'-'));
- foreach ($td as $va)
- {
- $s = $this->typeclass->read($va);
- if($s['classid'] == '14')
- {
- $c = $va;
- $inch = $s['spare'];
- if(isset($pm[$s['classid']]))
- {
- $pm[$s['classid']] = $s['zh'];
- }
- }
- else
- {
- $features .= $va.'-';
- if(isset($pm[$s['classid']]))
- {
- $pm[$s['classid']] = $s['zh'];
- }
-
- }
- }
- $features = $c.','.$features;
-
- $warehouse = $this->warehouse->read($value['warehouse']);
- $cpid = ($value['cpid']>0)?' - 编码:'.$value['cpid']:'';
- $nr = implode(" ",$pm);
- $nr = preg_replace(array('/(\s+)/','/分\s/u'),array(' ','分'),$nr);
- $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
- $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'tj'=>"<span data-f='".$features."' data-t='".$value['title']."' data-i='".$inch."' data-n='".$c."' data-id='".$value['id']."' data-id='".$value['id']."' data-wz='".$nr.' - 位置:'.$value['details'].$cpid.";'>添加</span>");
- }
- $total = count($rows);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
- echo json_encode($rows);exit;
- }
- $this->_Template('specialstock_order',$this->data);
- }
-
- public function _0kcdel($id_arr)
- {
- if($id_arr)
- {
- $id_arr = explode(',',$id_arr);
- $j = count($id_arr);
- $i = 0;
- //循环删除记录
- foreach ($id_arr as $value)
- {
- $data = $this->specialstock->read($value);
- $z = $this->specialstock->find_count('sku = "'.$data['sku'].'" and zd = "" and state = 0 and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
- if($z < 1)
- {
- $z = $this->specialstock->find_all('sku = "'.$data['sku'].'" and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
- foreach ($z as $v)
- {
- $this->specialstock->remove($v['id']);
- }
- $i++;
- }
- }
- if($i != $j && $i != 0)
- {
- return json_encode(array('del'=>$id_arr,'msg'=>'有非0库存数据,0库存删除成功!','success'=>true));
- }
- else if($i != $j && $i == 0)
- {
- return json_encode(array('del'=>$id_arr,'msg'=>'库存非0不允许删除!','success'=>false));
- }
- else
- {
- return json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
- }
- }
- else
- {
- echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
- }
- }
- }
|