| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303 | 
							- <?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);
 
- 			$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',$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;
 
- 		}
 
-     }
 
- }
 
 
  |