Specialstock.php 144 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Specialstock extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_specialstock','specialstock');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_whlabelwz','whlabelwz');
  27. $this->load->_model('Model_classid','classid');
  28. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  29. }
  30. //定义方法的调用规则 获取URI第二段值
  31. public function _remap($arg,$arg_array)
  32. {
  33. if($arg == 'existence')//在库标签
  34. {
  35. $this->_existence();
  36. }
  37. else if($arg == 'cpbqdc')//在库标签
  38. {
  39. $this->_cpbqdc();
  40. }
  41. else if($arg == 'type')//进销存浏览
  42. {
  43. $this->_type($arg_array);
  44. }
  45. else if($arg == 'xhctype')//现货仓进销存浏览
  46. {
  47. $this->_xhctype($arg_array);
  48. }
  49. else if($arg == 'typedy')//进销存浏览店员浏览
  50. {
  51. $this->_typedy();
  52. }
  53. else if($arg == 'xhctypedy')//现货仓进销存浏览店员浏览
  54. {
  55. $this->_xhctypedy();
  56. }
  57. else if($arg == 'usatype')//美仓进销存浏览
  58. {
  59. $this->_usatype();
  60. }
  61. else if($arg == 'usatypeapp')//美仓APP进销存浏览
  62. {
  63. $this->_usatypeapp();
  64. }
  65. else if($arg == 'enteradd')//入库操作
  66. {
  67. $this->_enteradd();
  68. }
  69. else if($arg == 'enteredit')//修改
  70. {
  71. $this->_enteredit($arg_array);
  72. }
  73. else if($arg == 'enter')//入库浏览
  74. {
  75. $this->_enter();
  76. }
  77. else if($arg == 'xhcenter')//入库浏览
  78. {
  79. $this->_xhcenter();
  80. }
  81. else if($arg == 'out')//出库浏览
  82. {
  83. $this->_out();
  84. }
  85. else if($arg == 'label')//出库标签浏览
  86. {
  87. $this->_label();
  88. }
  89. else if($arg == 'outorder')//独立站出库订单
  90. {
  91. $this->_outorder();
  92. }
  93. else if($arg == 'soutorder')//速卖通出库订单
  94. {
  95. $this->_soutorder();
  96. }
  97. else if($arg == 'retreat')//退库订单
  98. {
  99. $this->_retreat();
  100. }
  101. else if($arg == 'retreatlk')//退库订单
  102. {
  103. $this->_retreatlk();
  104. }
  105. else if($arg == 'change')//更换标签
  106. {
  107. $this->_change();
  108. }
  109. else if($arg == 'del')//删除
  110. {
  111. $this->_del($arg_array);
  112. }
  113. else if($arg == 'exceljxc')//进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. }
  117. else if($arg == 'excelr')//入库信息导出
  118. {
  119. $this->_excelr();
  120. }
  121. else if($arg == 'excelct')//出库、退库信息导出
  122. {
  123. $this->_excelct();
  124. }
  125. else if($arg == 'kcyz')//库存验证
  126. {
  127. $this->_kcyz();
  128. }
  129. else if($arg == 'kj')//库存扣减
  130. {
  131. $this->_kj($arg_array);
  132. }
  133. else if($arg == 'presetout')//预设库存导入
  134. {
  135. $this->_presetout($arg_array);
  136. }
  137. else if($arg == 'presetedit')//预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. }
  141. else if($arg == 'summary')//汇总导出
  142. {
  143. $this->_summary($arg_array);
  144. }
  145. else if($arg == 'manifest')//usps发货清单
  146. {
  147. $this->_manifest();
  148. }
  149. else if($arg == 'abnormal')//占单异常
  150. {
  151. $this->_abnormal();
  152. }
  153. else if($arg == 'error')
  154. {
  155. $this->_error();
  156. }
  157. else if($arg == 'ppkc')
  158. {
  159. $this->_ppkc();
  160. }
  161. else if($arg == 'list')
  162. {
  163. $this->_list($arg_array);
  164. }
  165. else if($arg == 'hwwz')
  166. {
  167. $this->_hwwz();
  168. }
  169. else if($arg == 'order')
  170. {
  171. $this->_order();
  172. }
  173. else if($arg == 'placeorder')
  174. {
  175. $this->_placeorder();
  176. }
  177. else
  178. {
  179. $this->_index();
  180. }
  181. }
  182. public function _del($id_arr)
  183. {
  184. if($id_arr)
  185. {
  186. $id_arr = explode(',',$id_arr);
  187. //循环删除记录
  188. foreach ($id_arr as $value)
  189. {
  190. $data = $this->specialstock->read($value);
  191. $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'].'"');
  192. foreach ($z as $v)
  193. {
  194. $this->specialstock->remove($v['id']);
  195. }
  196. }
  197. return json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  198. }
  199. else
  200. {
  201. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  202. }
  203. }
  204. public function _list($arg_array)
  205. {
  206. $ppid = array();
  207. $number = (isset($arg_array[1]))?$arg_array[1]:'no';
  208. if(!isset($arg_array[2]))
  209. {
  210. echo "特殊产品信息错误!清除浏览器缓存后再试";exit;
  211. }
  212. $hz = '';
  213. $bdck = $this->warehouse->get_bdck('specialstock');
  214. if($bdck)
  215. {
  216. if($bdck['hz'] != '' && stripos($arg_array[2],$bdck['hz']) !== false)
  217. {
  218. $hz = $bdck['hz'];
  219. }
  220. }
  221. if(stripos($arg_array[2],'-') !== false)
  222. {
  223. $dcp = explode('-',$arg_array[2]);
  224. foreach ($dcp as $v)
  225. {
  226. if($hz != '')
  227. {
  228. $ppid[] = trim($v,$hz);
  229. }
  230. else
  231. {
  232. $ppid[] = 0;
  233. }
  234. }
  235. if($hz != '')
  236. {
  237. $xzid = trim($dcp[0],$hz);
  238. }
  239. else
  240. {
  241. $xzid = 0;
  242. }
  243. }
  244. else
  245. {
  246. if($arg_array[2] != 0 && $hz != '')
  247. {
  248. $xzid = trim($arg_array[2],$hz);//已选择产品用
  249. $ppid[] = $xzid;
  250. }
  251. else
  252. {
  253. $xzid = $arg_array[0];//未选择产品用
  254. $ppid[] = 0;
  255. }
  256. }
  257. $thisdata = $this->specialstock->read($xzid);
  258. $data = array();$dataw = array();
  259. //本单已占用的,无论是否已出库
  260. if(stripos($thisdata['featurespp'],'-149') !== false)//如果是360头套 那么也可以匹配370头套
  261. {
  262. $tjd = explode('-',$thisdata['featurespp']);
  263. $dataally = $this->specialstock->find_all("(featurespp = '".$thisdata['featurespp']."' or featurespp = '".$tjd[0]."-".$tjd[1]."-".$tjd[2]."-329"."') and zd = '".$number."'");
  264. }
  265. else
  266. {
  267. $dataally = $this->specialstock->find_all("featurespp = '".$thisdata['featurespp']."' and zd = '".$number."'");
  268. }
  269. foreach ($dataally as $v)
  270. {
  271. $sm = '';
  272. $zd = ($number == $v['zd'])?1:0;
  273. $cpid = ($v['cpid']>0)?' - 编码:'.$v['cpid']:'';
  274. $cpbz = ($v['cpbz']!='')?'<p style="color:#f00">货物说明:'.$v['cpbz'].'</p>':'';
  275. $features = '-';$c = '';
  276. $td = explode('-',trim($v['features'],'-'));
  277. foreach ($td as $va)
  278. {
  279. $s = $this->typeclass->read($va);
  280. if($s['classid'] == '14')
  281. {
  282. $c = $va;
  283. }
  284. else
  285. {
  286. $features .= $va.'-';
  287. }
  288. }
  289. foreach ($ppid as $va)
  290. {
  291. if($va == $v['id'])
  292. {
  293. $sm = '<p style="color:#F00">当前选择的产品</p>';
  294. }
  295. else if(stripos($sm,'当前选择的产品') === false)
  296. {
  297. $sm = '<p style="color:#F00">本单已占用</p>';
  298. }
  299. }
  300. $tp = $this->typeclass->read($c);
  301. $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);
  302. }
  303. //未占用的库存
  304. if(stripos($thisdata['featurespp'],'-149') !== false)//如果是360头套 那么也可以匹配370头套
  305. {
  306. $tjd = explode('-',$thisdata['featurespp']);
  307. $dataallw = $this->specialstock->find_all("(featurespp = '".$thisdata['featurespp']."' or featurespp = '".$tjd[0]."-".$tjd[1]."-".$tjd[2]."-329"."') and zd = '' and state = '0'");
  308. }
  309. else
  310. {
  311. $dataallw = $this->specialstock->find_all("featurespp = '".$thisdata['featurespp']."' and zd = '' and state = '0'");
  312. }
  313. foreach ($dataallw as $v)
  314. {
  315. $zd = ($number == $v['zd'])?1:0;
  316. $cpid = ($v['cpid']>0)?' - 编码:'.$v['cpid']:'';
  317. $cpbz = ($v['cpbz']!='')?'<p style="color:#f00">货物说明:'.$v['cpbz'].'</p>':'';
  318. $features = '-';$c = '';
  319. $td = explode('-',trim($v['features'],'-'));
  320. foreach ($td as $va)
  321. {
  322. $sm = '';
  323. $s = $this->typeclass->read($va);
  324. if($s['classid'] == '14')
  325. {
  326. $c = $va;
  327. }
  328. else
  329. {
  330. $features .= $va.'-';
  331. }
  332. foreach ($ppid as $va)
  333. {
  334. if($va == $v['id'])
  335. {
  336. $sm = '<p style="color:#F00">当前选择的产品,需提交后占单</p>';
  337. }
  338. }
  339. }
  340. $tp = $this->typeclass->read($c);
  341. $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);
  342. }
  343. $this->data['data'] = $data;
  344. $this->data['dataw'] = $dataw;
  345. $this->data['id'] = $arg_array[0];
  346. $this->data['ppid'] = $ppid;
  347. $this->_Template('specialstock_list',$this->data);
  348. }
  349. //检查是否匹配特殊库存
  350. public function _ppkc()
  351. {
  352. $post = $this->input->post(NULL, TRUE);
  353. if(isset($post['data']))
  354. {
  355. $data = $this->input->post('data',true);
  356. $number = $this->input->post('number',true);
  357. $whlabel = $this->input->post('whlabel',true);
  358. $data = explode('|',rtrim($data,'|'));
  359. $whlabel = explode('|',trim($whlabel,'|'));
  360. $i = 0;$list = array();$a=array();
  361. //更具要求特殊仓库存不在有限匹配
  362. foreach ($data as $v)
  363. {
  364. $v = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
  365. $vfl = explode('-',trim($v,'-'));
  366. $num = explode('-',trim($whlabel[$i],'-'));
  367. if(isset($vfl[4]))
  368. {
  369. if($vfl[4] == 149)//如果是360头套 那么也可以匹配370头套
  370. {
  371. $pp = $this->specialstock->find_all("featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' and zd = '' and state = '0'");
  372. if(!$pp)
  373. {
  374. $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'");
  375. }
  376. }
  377. else
  378. {
  379. $pp = $this->specialstock->find_all("featurespp = '".$vfl[0].'-'.$vfl[2].'-'.$vfl[3].'-'.$vfl[4]."' and zd = '' and state = '0'");
  380. }
  381. $yzd='';
  382. if(isset($num[2]))
  383. {
  384. preg_match_all('/\d+/',$num[2],$n);
  385. $n = join('',$n[0]);
  386. $yzd = $this->specialstock->find_all("id = '$n' and zd = '$number'");
  387. }
  388. if(count($pp) >= $num[1] && !$yzd)
  389. {
  390. $w = '特殊';//有现货仓的设置后面特殊更改为现货
  391. $list[] = array($i,$pp[0]['id'],$w);
  392. }
  393. else if($yzd)
  394. {
  395. foreach ($yzd as $val)
  396. {
  397. if($num[2] == $val['id'].'z')
  398. {
  399. $w = '特殊';//有现货仓的设置后面特殊更改为现货
  400. $list[] = array($i,$yzd[0]['id'],$w);
  401. }
  402. }
  403. }
  404. }
  405. $i++;
  406. }
  407. if($list)
  408. {
  409. echo json_encode(array('list'=>$list,'success'=>true));exit;
  410. }
  411. }
  412. }
  413. //管理
  414. public function _index()
  415. {
  416. $post = $this->input->post(NULL, TRUE);
  417. if(isset($post['page']))
  418. {
  419. $page = $this->input->post('page',true);
  420. $perpage = $this->input->post('perpage',true);
  421. $sku = $this->input->post('sku',true);
  422. $number = $this->input->post('number',true);
  423. $warehouse = $this->input->post('warehouse',true);
  424. $purchase = $this->input->post('purchase',true);
  425. $orderinfo = $this->input->post('orderinfo',true);
  426. $waybill = $this->input->post('waybill',true);
  427. $category = $this->input->post('category',true);
  428. $size = $this->input->post('size',true);
  429. $grade = $this->input->post('grade',true);
  430. $color = $this->input->post('color',true);
  431. $lowe = $this->input->post('lowe',true);
  432. $state = $this->input->post('state',true);
  433. $label = $this->input->post('label',true);
  434. $timetk = $this->input->post('timetkk',true);
  435. $timetj = $this->input->post('timetjj',true);
  436. $timetk = strtotime($timetk);
  437. $timetj = strtotime($timetj);
  438. $where = "1=1 ";
  439. if($timetk && $timetj)
  440. {
  441. $where .= " and time > '$timetk' and time < '$timetj'";
  442. }
  443. if($sku)
  444. {
  445. $where .= " and sku = '$sku'";
  446. }
  447. if($number)
  448. {
  449. $where .= " and number = '$number'";
  450. }
  451. if($warehouse)
  452. {
  453. $where .= " and warehouse = '$warehouse'";
  454. }
  455. if($purchase)
  456. {
  457. $where .= " and purchase = '$purchase'";
  458. }
  459. if($orderinfo)
  460. {
  461. $where .= " and orderinfo = '$orderinfo'";
  462. }
  463. if($waybill)
  464. {
  465. $where .= " and waybill = '$waybill'";
  466. }
  467. if($category)
  468. {
  469. $where .= " and features like '%-$category-%'";
  470. }
  471. if($size)
  472. {
  473. $where .= " and features like '%-$size-%'";
  474. }
  475. if($grade)
  476. {
  477. $where .= " and features like '%-$grade-%'";
  478. }
  479. if($color)
  480. {
  481. $where .= " and features like '%-$color-%'";
  482. }
  483. if($lowe)
  484. {
  485. $where .= " and features like '%-$lowe-%'";
  486. }
  487. if($label)
  488. {
  489. $where .= " and label = '$label'";
  490. }
  491. if($state || $state == 0)
  492. {
  493. $where .= " and state = '$state'";
  494. }
  495. //数据排序
  496. $order_str = "time desc";
  497. if(empty($page))
  498. {
  499. $start = 0;
  500. $perpage = 1;
  501. }
  502. else
  503. {
  504. $start = ($page - 1)*$perpage;
  505. }
  506. //取得信息列表
  507. $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);
  508. foreach ($info_list as $key=>$value)
  509. {
  510. $warehouse = $this->warehouse->read($value['warehouse']);
  511. $info_list[$key]['warehouse'] = $warehouse['title'];
  512. $purchase = $this->purchase->read($value['purchase']);
  513. $info_list[$key]['purchase'] = $purchase['title'];
  514. if($value['enter'] != 0)
  515. {
  516. $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
  517. }
  518. else
  519. {
  520. $info_list[$key]['enter'] = "";
  521. }
  522. if($value['outk'] != 0)
  523. {
  524. $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
  525. }
  526. else
  527. {
  528. $info_list[$key]['outk'] = "";
  529. }
  530. if($value['printing'] != 0)
  531. {
  532. $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
  533. }
  534. else
  535. {
  536. $info_list[$key]['printing'] = "";
  537. }
  538. if($value['orderinfo'] == 0)
  539. {
  540. $info_list[$key]['orderinfo'] = "";
  541. }
  542. if($value['waybill'] == 0)
  543. {
  544. $info_list[$key]['waybill'] = "";
  545. }
  546. if($value['state'] == 0)
  547. {
  548. $info_list[$key]['state'] = "在库";
  549. }
  550. else if($value['state'] == 1)
  551. {
  552. $info_list[$key]['state'] = "出库";
  553. }
  554. else if($value['state'] == 2)
  555. {
  556. $info_list[$key]['state'] = "退库";
  557. }
  558. else if($value['state'] == 3)
  559. {
  560. $info_list[$key]['state'] = "调拨中";
  561. }
  562. else if($value['state'] == 4)
  563. {
  564. $info_list[$key]['state'] = "再加工";
  565. }
  566. else if($value['state'] == 5)
  567. {
  568. $info_list[$key]['state'] = "维修中";
  569. }
  570. else if($value['state'] == 6)
  571. {
  572. $info_list[$key]['state'] = "盘亏";
  573. }
  574. else if($value['state'] == 7)
  575. {
  576. $info_list[$key]['state'] = "更换标签";
  577. }
  578. else if($value['state'] == 8)
  579. {
  580. $info_list[$key]['state'] = "其它";
  581. }
  582. else if($value['state'] == 9)
  583. {
  584. $info_list[$key]['state'] = "预设";
  585. }
  586. if($value['text'] == "")
  587. {
  588. $info_list[$key]['text'] = "";
  589. }
  590. $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
  591. }
  592. $total = $this->specialstock->find_count($where);
  593. $pagenum = ceil($total/$perpage);
  594. $over = $total-($start+$perpage);
  595. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  596. echo json_encode($rows);exit;
  597. }
  598. if(isset($post['outsku']))
  599. {
  600. $cz = $this->input->post('cz',true);
  601. if($cz == '1')
  602. {
  603. $sku = $this->input->post('outsku',true);
  604. if($sku)
  605. {
  606. $data = $this->specialstock->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  607. if(count($data) < 1)
  608. {
  609. echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
  610. }
  611. $this->specialstock->save(array('state'=>10,'outk'=>time(),'time'=>time()),$data[0]['id']);
  612. echo json_encode(array('success'=>true));exit;
  613. }
  614. }
  615. else
  616. {
  617. $sku = $this->input->post('outsku',true);
  618. if($sku)
  619. {
  620. $data = $this->specialstock->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  621. if(count($data) < 1)
  622. {
  623. echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
  624. }
  625. $this->specialstock->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
  626. echo json_encode(array('success'=>true));exit;
  627. }
  628. }
  629. }
  630. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  631. $this->_Template('specialstock',$this->data);
  632. }
  633. //在库标签
  634. public function _existence()
  635. {
  636. $post = $this->input->post(NULL, TRUE);
  637. if(isset($post['s']))
  638. {
  639. $id_arr = $this->input->post('s');
  640. $id_arr = explode(',',$id_arr);
  641. if(!$id_arr)
  642. {
  643. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  644. }
  645. //循环删除记录
  646. foreach ($id_arr as $v)
  647. {
  648. $this->specialstock->remove($v);
  649. }
  650. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  651. }
  652. if(isset($post['page']))
  653. {
  654. $page = $this->input->post('page',true);
  655. $perpage = $this->input->post('perpage',true);
  656. $warehouse = $this->input->post('warehouse',true);
  657. $label = $this->input->post('label',true);
  658. $where = "1=1 and state = 0";
  659. if($warehouse)
  660. {
  661. $where .= " and warehouse = '$warehouse'";
  662. }
  663. if($label)
  664. {
  665. $where .= " and label = '$label'";
  666. }
  667. //数据排序
  668. $order_str = "time asc";
  669. if(empty($page))
  670. {
  671. $start = 0;
  672. $perpage = 1;
  673. }
  674. else
  675. {
  676. $start = ($page - 1)*$perpage;
  677. }
  678. //取得信息列表
  679. $info_list = $this->specialstock->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
  680. foreach ($info_list as $key=>$value)
  681. {
  682. if($value['enter'] != 0)
  683. {
  684. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  685. }
  686. else
  687. {
  688. $info_list[$key]['enter'] = "";
  689. }
  690. if($value['printing'] != 0)
  691. {
  692. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  693. }
  694. else
  695. {
  696. $info_list[$key]['printing'] = "";
  697. }
  698. }
  699. $total = $this->specialstock->find_count($where);
  700. $pagenum = ceil($total/$perpage);
  701. $over = $total-($start+$perpage);
  702. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  703. echo json_encode($rows);exit;
  704. }
  705. $this->_Template('specialstock_existence',$this->data);
  706. }
  707. public function _typedy()
  708. {
  709. $post = $this->input->post(NULL, TRUE);
  710. if(isset($post['page']))
  711. {
  712. $page = $this->input->post('page',true);
  713. $perpage = $this->input->post('perpage',true);
  714. $category = $this->input->post('category',true);
  715. $size = $this->input->post('size',true);
  716. $grade = $this->input->post('grade',true);
  717. $color = $this->input->post('color',true);
  718. $lowe = $this->input->post('lowe',true);
  719. $sku = $this->input->post('sku');
  720. $title = $this->input->post('title');
  721. $warehouse = $this->input->post('warehouse',true);
  722. $hairnumber = $this->input->post('hairnumber',true);
  723. $usa = $this->input->post('usa',true);
  724. $purchase = $this->input->post('purchase',true);
  725. $lacetype = $this->input->post('lacetype',true);
  726. $haircap = $this->input->post('haircap',true);
  727. $density = $this->input->post('density',true);
  728. $details = $this->input->post('details',true);
  729. $state = $this->input->post('state',true);
  730. $ktime = $this->input->post('ktime',true);
  731. $jtime = $this->input->post('jtime',true);
  732. $ktime = strtotime($ktime);
  733. $jtime = strtotime($jtime);
  734. $where = "1=1";$gj = "";$ck = "";
  735. if($lacetype)
  736. {
  737. $where .= " and features like '%-$lacetype-%'";
  738. }
  739. if($category)
  740. {
  741. $where .= " and features like '%-$category-%'";
  742. }
  743. if($size)
  744. {
  745. $where .= " and features like '%-$size-%'";
  746. }
  747. if($grade)
  748. {
  749. $where .= " and features like '%-$grade-%'";
  750. }
  751. if($color)
  752. {
  753. $where .= " and features like '%-$color-%'";
  754. }
  755. if($lowe)
  756. {
  757. $where .= " and features like '%-$lowe-%'";
  758. }
  759. if($haircap)
  760. {
  761. $where .= " and features like '%-$haircap-%'";
  762. }
  763. if($density)
  764. {
  765. $where .= " and features like '%-$density-%'";
  766. }
  767. if($usa)
  768. {
  769. if(!$warehouse)
  770. {
  771. $where .= " and (warehouse = '5' or warehouse = '8')";
  772. }
  773. }
  774. if($warehouse)
  775. {
  776. $where .= " and warehouse = '$warehouse'";
  777. }
  778. if($details)
  779. {
  780. $where .= " and details = '$details'";
  781. }
  782. if($purchase)
  783. {
  784. $where .= " and purchase = '$purchase'";
  785. }
  786. if(isset($state))
  787. {
  788. if($state >-1){
  789. $where .= " and state = '$state'";
  790. }
  791. }
  792. if (!empty($hairnumber)) {
  793. $where .= " and features like '%-128-%' ";
  794. if ($hairnumber < 0) {
  795. $class_list = $this->typeclass->find_all('classid = 43');
  796. foreach ($class_list as $v) {
  797. $where .= " and features not like '%-" . $v['id'] . "-%'";
  798. }
  799. } else {
  800. $where .= " and features like '%-$hairnumber-%'";
  801. }
  802. }
  803. if($ktime && $jtime)
  804. {
  805. $gj = " and enter > '$ktime' and enter < '$jtime'";
  806. $ck = " and outk > '$ktime' and outk < '$jtime'";
  807. }
  808. //数据排序
  809. $order_str = "id desc";
  810. if(empty($page))
  811. {
  812. $start = 0;
  813. $perpage = 1;
  814. }
  815. else
  816. {
  817. $start = ($page - 1)*$perpage;
  818. }
  819. if($sku)
  820. {
  821. $sku = trim($sku,' ');
  822. $sku = trim($sku,' ');
  823. $where .= " and sku like '%$sku%'";
  824. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
  825. }
  826. else if($title)
  827. {
  828. $title = trim($title,' ');
  829. $title = trim($title,' ');
  830. $where .= " and title like '%$title%'";
  831. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
  832. }
  833. else
  834. {
  835. //$where .= " and time > '$ktime' and time < '$jtime'";
  836. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
  837. }
  838. //取得信息列表
  839. $rows = array();$list = array();
  840. foreach ($info_list as $key=>$value)
  841. {
  842. $wid = $this->specialstock->read($value['id']);
  843. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  844. $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
  845. $number = $value['number'];$ftime = time()-15*24*3600;
  846. $z = count($z);//查看订单号
  847. $info_list[$key]['features'] = count($c);
  848. $info_list[$key]['number'] = $z;
  849. $details = array();
  850. $cpid = array();
  851. foreach ($c as $k=>$v)
  852. {
  853. $details[$v['details']] = $v['details'];
  854. if($v['cpid'] != 0)
  855. {
  856. $cpid[$v['cpid']] = $v['cpid'];
  857. }
  858. }
  859. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  860. }
  861. $total = count($this->specialstock->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  862. $pagenum = ceil($total/$perpage);
  863. $over = $total-($start+$perpage);
  864. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  865. echo json_encode($rows);exit;
  866. }
  867. $this->_Template('specialstock_typedy',$this->data);
  868. }
  869. //进销存浏览
  870. public function _type($arg_array)
  871. {
  872. $vip = 0;
  873. if(isset($_SESSION['api']))
  874. {
  875. $user = $this->user->get_api($_SESSION['api']);
  876. if($user['vip'] == 1)
  877. {
  878. $vip = 1;
  879. }
  880. }
  881. else
  882. {
  883. header('Location: /');exit;
  884. }
  885. if(isset($arg_array[0]))
  886. {
  887. if($arg_array[0] == 'del')
  888. {
  889. $s = $this->input->post('s',true);
  890. $del = $this->_0kcdel($s);
  891. echo $del;exit;
  892. }
  893. }
  894. $post = $this->input->post(NULL, TRUE);
  895. if(isset($post['page']))
  896. {
  897. $page = $this->input->post('page',true);
  898. $perpage = $this->input->post('perpage',true);
  899. $category = $this->input->post('category',true);
  900. $size = $this->input->post('size',true);
  901. $grade = $this->input->post('grade',true);
  902. $color = $this->input->post('color',true);
  903. $lowe = $this->input->post('lowe',true);
  904. $sku = $this->input->post('sku');
  905. $title = $this->input->post('title');
  906. $warehouse = $this->input->post('warehouse',true);
  907. $usa = $this->input->post('usa',true);
  908. $purchase = $this->input->post('purchase',true);
  909. $lacetype = $this->input->post('lacetype',true);
  910. $haircap = $this->input->post('haircap',true);
  911. $density = $this->input->post('density',true);
  912. $details = $this->input->post('details',true);
  913. $state = $this->input->post('state',true);
  914. $ktime = $this->input->post('ktime',true);
  915. $jtime = $this->input->post('jtime',true);
  916. $hairnumber = $this->input->post('hairnumber',true);
  917. $ktime = strtotime($ktime);
  918. $jtime = strtotime($jtime);
  919. $where = "1=1";$gj = "";$ck = "";
  920. if($lacetype)
  921. {
  922. $where .= " and features like '%-$lacetype-%'";
  923. }
  924. if($category)
  925. {
  926. $where .= " and features like '%-$category-%'";
  927. }
  928. if($size)
  929. {
  930. $where .= " and features like '%-$size-%'";
  931. }
  932. if($grade)
  933. {
  934. $where .= " and features like '%-$grade-%'";
  935. }
  936. if($color)
  937. {
  938. $where .= " and features like '%-$color-%'";
  939. }
  940. if($lowe)
  941. {
  942. $where .= " and features like '%-$lowe-%'";
  943. }
  944. if($haircap)
  945. {
  946. $where .= " and features like '%-$haircap-%'";
  947. }
  948. if (!empty($hairnumber)) {
  949. $where .= " and features like '%-128-%' ";
  950. if ($hairnumber < 0) {
  951. $class_list = $this->typeclass->find_all('classid = 43');
  952. foreach ($class_list as $v) {
  953. $where .= " and features not like '%-" . $v['id'] . "-%'";
  954. }
  955. } else {
  956. $where .= " and features like '%-$hairnumber-%'";
  957. }
  958. }
  959. if($density)
  960. {
  961. $where .= " and features like '%-$density-%'";
  962. }
  963. if($usa)
  964. {
  965. if(!$warehouse)
  966. {
  967. $where .= " and (warehouse = '5' or warehouse = '8')";
  968. }
  969. }
  970. if($warehouse)
  971. {
  972. $where .= " and warehouse = '$warehouse'";
  973. }
  974. if($details)
  975. {
  976. $where .= " and details = '$details'";
  977. }
  978. if($purchase)
  979. {
  980. $where .= " and purchase = '$purchase'";
  981. }
  982. if($state)
  983. {
  984. $where .= " and state = '$state'";
  985. }
  986. if($ktime && $jtime)
  987. {
  988. $gj = " and enter > '$ktime' and enter < '$jtime'";
  989. $ck = " and outk > '$ktime' and outk < '$jtime'";
  990. }
  991. //数据排序
  992. $order_str = "id desc";
  993. if(empty($page))
  994. {
  995. $start = 0;
  996. $perpage = 1;
  997. }
  998. else
  999. {
  1000. $start = ($page - 1)*$perpage;
  1001. }
  1002. if($sku)
  1003. {
  1004. $sku = trim($sku,' ');
  1005. $sku = trim($sku,' ');
  1006. $where .= " and sku like '%$sku%'";
  1007. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
  1008. }
  1009. else if($title)
  1010. {
  1011. $title = trim($title,' ');
  1012. $title = trim($title,' ');
  1013. $where .= " and title like '%$title%'";
  1014. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
  1015. }
  1016. else
  1017. {
  1018. //$where .= " and time > '$ktime' and time < '$jtime'";
  1019. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,sku,title,details,cpbz,features',$order_str,$start,$perpage);
  1020. }
  1021. //取得信息列表
  1022. $rows = array();$list = array();
  1023. foreach ($info_list as $key=>$value)
  1024. {
  1025. $wid = $this->specialstock->read($value['id']);
  1026. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1027. $g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
  1028. $x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
  1029. $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$wid['warehouse'].'"');
  1030. $z = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$wid['warehouse'].'" and features = "'.$value['features'].'"');
  1031. $od = array();$odid = '';
  1032. foreach ($z as $v)
  1033. {
  1034. if(!isset($od[$v['zd']]))
  1035. {
  1036. $od[$v['zd']] = 1;//所有数据sku
  1037. }
  1038. else
  1039. {
  1040. $od[$v['zd']] = $od[$v['zd']]+1;
  1041. }
  1042. }
  1043. foreach ($od as $k=>$vv)
  1044. {
  1045. $odid .= $k.'数量'.$vv;
  1046. }
  1047. $ftime = time()-15*24*3600;
  1048. $z = count($z).'('.$odid.')';//查看订单号
  1049. $info_list[$key]['features'] = count($c);
  1050. $info_list[$key]['g'] = $g;
  1051. $info_list[$key]['x'] = $x;
  1052. $info_list[$key]['t'] = $t;
  1053. $info_list[$key]['z'] = $z;
  1054. $details = array();
  1055. $cpid = array();
  1056. foreach ($c as $k=>$v)
  1057. {
  1058. $details[$v['details']] = $v['details'];
  1059. if($v['cpid'] != 0)
  1060. {
  1061. $cpid[$v['cpid']] = $v['cpid'];
  1062. }
  1063. }
  1064. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1065. }
  1066. $total = count($this->specialstock->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features'));
  1067. $pagenum = ceil($total/$perpage);
  1068. $over = $total-($start+$perpage);
  1069. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1070. echo json_encode($rows);exit;
  1071. }
  1072. $this->data['vip'] = $vip;
  1073. $this->_Template('specialstock_type',$this->data);
  1074. }
  1075. public function _xhctypedy()
  1076. {
  1077. $post = $this->input->post(NULL, TRUE);
  1078. if(isset($post['page']))
  1079. {
  1080. $page = $this->input->post('page',true);
  1081. $perpage = $this->input->post('perpage',true);
  1082. $category = $this->input->post('category',true);
  1083. $size = $this->input->post('size',true);
  1084. $grade = $this->input->post('grade',true);
  1085. $color = $this->input->post('color',true);
  1086. $lowe = $this->input->post('lowe',true);
  1087. $sku = $this->input->post('sku',true);
  1088. $details = $this->input->post('details',true);
  1089. $warehouse = $this->input->post('warehouse',true);
  1090. $purchase = $this->input->post('purchase',true);
  1091. $lacetype = $this->input->post('lacetype',true);
  1092. $state = $this->input->post('state',true);
  1093. $ktime = $this->input->post('ktime',true);
  1094. $jtime = $this->input->post('jtime',true);
  1095. $ktime = strtotime($ktime);
  1096. $jtime = strtotime($jtime);
  1097. $where = "warehouse != '12'";$gj = "";$ck = "";
  1098. if($category)
  1099. {
  1100. $where .= " and features like '%-$category-%'";
  1101. }
  1102. if($size)
  1103. {
  1104. $where .= " and features like '%-$size-%'";
  1105. }
  1106. if($grade)
  1107. {
  1108. $where .= " and features like '%-$grade-%'";
  1109. }
  1110. if($color)
  1111. {
  1112. $where .= " and features like '%-$color-%'";
  1113. }
  1114. if($lowe)
  1115. {
  1116. $where .= " and features like '%-$lowe-%'";
  1117. }
  1118. if($lacetype)
  1119. {
  1120. $where .= " and features like '%-$lacetype-%'";
  1121. }
  1122. if($warehouse)
  1123. {
  1124. $where .= " and warehouse = '$warehouse'";
  1125. }
  1126. if($purchase)
  1127. {
  1128. $where .= " and purchase = '$purchase'";
  1129. }
  1130. if($state)
  1131. {
  1132. $where .= " and state = '$state'";
  1133. }
  1134. if($sku)
  1135. {
  1136. $where .= " and sku like '%$sku%'";
  1137. }
  1138. if($details)
  1139. {
  1140. $where .= " and details like '%$details%'";
  1141. }
  1142. if($ktime && $jtime)
  1143. {
  1144. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1145. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1146. }
  1147. //数据排序
  1148. $order_str = "id desc";
  1149. if(empty($page))
  1150. {
  1151. $start = 0;
  1152. $perpage = 1;
  1153. }
  1154. else
  1155. {
  1156. $start = ($page - 1)*$perpage;
  1157. }
  1158. //取得信息列表
  1159. $info_list = $this->specialstock->find_all($where,'*');
  1160. $rows = array();$list = array();
  1161. foreach ($info_list as $key=>$value)
  1162. {
  1163. $rows[$value['number'].$value['details'].$value['warehouse']] = $value;//所有数据sku
  1164. }
  1165. foreach ($rows as $k=>$value)
  1166. {
  1167. $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'].'"');
  1168. if($c < 1)
  1169. {
  1170. unset($rows[$k]);
  1171. }
  1172. }
  1173. $rowsdq = array_slice($rows,$start,$perpage);
  1174. foreach ($rowsdq as $value)
  1175. {
  1176. $warehouse = $this->warehouse->read($value['warehouse']);
  1177. $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'].'"');
  1178. $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'].'"');
  1179. $number = $value['number'];$ftime = time()-15*24*3600;
  1180. $z = count($z);//查看订单号
  1181. //$z = $od;
  1182. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'wz'=>$value['details'],'bz'=>$value['cpbz'],'c'=>$c,'z'=>$z);
  1183. }
  1184. $total = count($rows);
  1185. $pagenum = ceil($total/$perpage);
  1186. $over = $total-($start+$perpage);
  1187. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1188. echo json_encode($rows);exit;
  1189. }
  1190. $this->_Template('specialstock_xhctypedy',$this->data);
  1191. }
  1192. //进销存浏览
  1193. public function _xhctype($arg_array)
  1194. {
  1195. $post = $this->input->post(NULL, TRUE);
  1196. if(isset($arg_array[0]))
  1197. {
  1198. if($arg_array[0] == 'del')
  1199. {
  1200. $s = $this->input->post('s',true);
  1201. $del = $this->_del($s);
  1202. echo $del;exit;
  1203. }
  1204. }
  1205. if(isset($post['page']))
  1206. {
  1207. $page = $this->input->post('page',true);
  1208. $perpage = $this->input->post('perpage',true);
  1209. $category = $this->input->post('category',true);
  1210. $size = $this->input->post('size',true);
  1211. $grade = $this->input->post('grade',true);
  1212. $color = $this->input->post('color',true);
  1213. $lowe = $this->input->post('lowe',true);
  1214. $sku = $this->input->post('sku',true);
  1215. $details = $this->input->post('details',true);
  1216. $warehouse = $this->input->post('warehouse',true);
  1217. $purchase = $this->input->post('purchase',true);
  1218. $lacetype = $this->input->post('lacetype',true);
  1219. $state = $this->input->post('state',true);
  1220. $ktime = $this->input->post('ktime',true);
  1221. $jtime = $this->input->post('jtime',true);
  1222. $ktime = strtotime($ktime);
  1223. $jtime = strtotime($jtime);
  1224. $where = "warehouse != '12'";$gj = "";$ck = "";
  1225. if($category)
  1226. {
  1227. $where .= " and features like '%-$category-%'";
  1228. }
  1229. if($size)
  1230. {
  1231. $where .= " and features like '%-$size-%'";
  1232. }
  1233. if($grade)
  1234. {
  1235. $where .= " and features like '%-$grade-%'";
  1236. }
  1237. if($color)
  1238. {
  1239. $where .= " and features like '%-$color-%'";
  1240. }
  1241. if($lowe)
  1242. {
  1243. $where .= " and features like '%-$lowe-%'";
  1244. }
  1245. if($lacetype)
  1246. {
  1247. $where .= " and features like '%-$lacetype-%'";
  1248. }
  1249. if($warehouse)
  1250. {
  1251. $where .= " and warehouse = '$warehouse'";
  1252. }
  1253. if($purchase)
  1254. {
  1255. $where .= " and purchase = '$purchase'";
  1256. }
  1257. if($state)
  1258. {
  1259. $where .= " and state = '$state'";
  1260. }
  1261. if($sku)
  1262. {
  1263. $where .= " and sku like '%$sku%'";
  1264. }
  1265. if($details)
  1266. {
  1267. $where .= " and details like '%$details%'";
  1268. }
  1269. if($ktime && $jtime)
  1270. {
  1271. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1272. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1273. }
  1274. //数据排序
  1275. $order_str = "id desc";
  1276. if(empty($page))
  1277. {
  1278. $start = 0;
  1279. $perpage = 1;
  1280. }
  1281. else
  1282. {
  1283. $start = ($page - 1)*$perpage;
  1284. }
  1285. //取得信息列表
  1286. $info_list = $this->specialstock->find_all($where,'*');
  1287. $rows = array();$list = array();
  1288. foreach ($info_list as $key=>$value)
  1289. {
  1290. $rows[$value['number'].$value['details'].$value['warehouse']] = $value;//所有数据sku
  1291. }
  1292. $rowsdq = array_slice($rows,$start,$perpage);
  1293. foreach ($rowsdq as $k=>$value)
  1294. {
  1295. $warehouse = $this->warehouse->read($value['warehouse']);
  1296. $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'].'"');
  1297. $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'].'"');
  1298. $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'].'"');
  1299. $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1300. $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'].'"');
  1301. $od = array();$odid = '';
  1302. foreach ($z as $v)
  1303. {
  1304. if(!isset($od[$v['zd']]))
  1305. {
  1306. $od[$v['zd']] = 1;//所有数据sku
  1307. }
  1308. else
  1309. {
  1310. $od[$v['zd']] = $od[$v['zd']]+1;
  1311. }
  1312. }
  1313. foreach ($od as $k=>$vv)
  1314. {
  1315. $odid .= $k.'数量'.$vv;
  1316. }
  1317. $number = $value['number'];$ftime = time()-15*24*3600;
  1318. /**
  1319. if($value['shop'] != '')
  1320. {
  1321. $shop = $value['shop'];
  1322. $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');
  1323. $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');
  1324. $order = array_merge($orderdlz,$ordersmt);
  1325. $od = 0;$a = '';$orid = '';
  1326. foreach ($order as $v)
  1327. {
  1328. $or = explode('|',ltrim($v['specialstock'],'|'));
  1329. for($i=0;$i<count($or);$i++)
  1330. {
  1331. $orod = explode('-',$or[$i]);
  1332. if($orod[0] == $number)
  1333. {
  1334. $od += $orod[1];
  1335. }
  1336. }
  1337. $orid .= $v['number'].'-';
  1338. }
  1339. }
  1340. else
  1341. {
  1342. $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');
  1343. $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');
  1344. $order = array_merge($orderdlz,$ordersmt);
  1345. $od = 0;$a = '';$orid = '';$qt = array();
  1346. foreach ($order as $v)
  1347. {
  1348. $or = explode('|',ltrim($v['specialstock'],'|'));
  1349. for($i=0;$i<count($or);$i++)
  1350. {
  1351. $orod = explode('-',$or[$i]);
  1352. if($orod[0] == $number)
  1353. {
  1354. $czzs = $this->specialstock->find_count("number = '$number' and warehouse = '".$value['warehouse']."' and shop = '".$v['shop']."' and state = 0");
  1355. if($czzs > 0)
  1356. {
  1357. if(isset($qt[$v['shop']]))
  1358. {
  1359. if($qt[$v['shop']] < $orod[1])
  1360. {
  1361. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  1362. $orid .= $v['number'].'+数量'.$orod[1].'-';
  1363. }
  1364. else
  1365. {
  1366. $qt[$v['shop']] -= $orod[1];
  1367. }
  1368. }
  1369. else
  1370. {
  1371. $qt[$v['shop']] = $czzs;
  1372. }
  1373. }
  1374. else
  1375. {
  1376. $od += $orod[1];
  1377. $orid .= $v['number'].'+数量'.$orod[1].'-';
  1378. }
  1379. }
  1380. }
  1381. }
  1382. }
  1383. **/
  1384. $z = count($z).'('.$odid.')';//查看订单号
  1385. //$z = $od;
  1386. $wz = ($value['cpid'] > 0)?$value['details'].'-'.$value['cpid']:$value['details'];
  1387. $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);
  1388. }
  1389. $total = count($rows);
  1390. $pagenum = ceil($total/$perpage);
  1391. $over = $total-($start+$perpage);
  1392. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1393. echo json_encode($rows);exit;
  1394. }
  1395. $this->_Template('specialstock_xhctype',$this->data);
  1396. }
  1397. //美仓进销存浏览
  1398. public function _usatype()
  1399. {
  1400. $this->_Template('specialstock_typeusa',$this->data);
  1401. }
  1402. //美仓进销存浏览
  1403. public function _usatypeapp()
  1404. {
  1405. $post = $this->input->post(NULL, TRUE);
  1406. if(isset($post['page']))
  1407. {
  1408. $page = $this->input->post('page',true);
  1409. $perpage = $this->input->post('perpage',true);
  1410. $sku = $this->input->post('sku',true);
  1411. $warehouse = '5';
  1412. $title = $this->input->post('title',true);
  1413. $state = $this->input->post('state',true);
  1414. $ktime = $this->input->post('ktime',true);
  1415. $jtime = $this->input->post('jtime',true);
  1416. $ktime = strtotime($ktime);
  1417. $jtime = strtotime($jtime);
  1418. $where = "1=1";$gj = "";$ck = "";
  1419. if($title)
  1420. {
  1421. $st = explode(' ',trim($title,' '));
  1422. foreach ($st as $v)
  1423. {
  1424. $where .= " and title like '%$v%'";
  1425. }
  1426. }
  1427. if($warehouse)
  1428. {
  1429. $where .= " and warehouse = '$warehouse'";
  1430. }
  1431. if($state)
  1432. {
  1433. $where .= " and state = '$state'";
  1434. }
  1435. if($sku)
  1436. {
  1437. $where .= " and sku like '%$sku%'";
  1438. }
  1439. if($ktime && $jtime)
  1440. {
  1441. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1442. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1443. }
  1444. //数据排序
  1445. $order_str = "id desc";
  1446. if(empty($page))
  1447. {
  1448. $start = 0;
  1449. $perpage = 1;
  1450. }
  1451. else
  1452. {
  1453. $start = ($page - 1)*$perpage;
  1454. }
  1455. //取得信息列表
  1456. $info_list = $this->specialstock->find_all($where,'*');
  1457. $rows = array();$list = array();
  1458. foreach ($info_list as $key=>$value)
  1459. {
  1460. $rows[$value['sku'].'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1461. }
  1462. $rowsdq = array_slice($rows,$start,$perpage);
  1463. foreach ($rowsdq as $value)
  1464. {
  1465. $warehouse = $this->warehouse->read($value['warehouse']);
  1466. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1467. $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1468. $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1469. $od = array();$odid = '';
  1470. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1471. }
  1472. $total = count($rows);
  1473. $pagenum = ceil($total/$perpage);
  1474. $over = $total-($start+$perpage);
  1475. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1476. echo json_encode($rows);exit;
  1477. }
  1478. $this->_Template('phone/p_usatypeapp',$this->data);
  1479. }
  1480. //入库操作
  1481. public function _enteradd()
  1482. {
  1483. $dt = 0;
  1484. if(isset($_SESSION['api']))
  1485. {
  1486. $user = $this->user->get_api($_SESSION['api']);
  1487. $usp = $user;
  1488. $fgshop = "";$sid = "";
  1489. $user = explode('|',trim($user['shop'],'|'));
  1490. foreach ($user as $value)
  1491. {
  1492. $fgshop .= " shop = ".$value." or";
  1493. $sid .= " id = ".$value." or";
  1494. }
  1495. }
  1496. $post = $this->input->post(NULL, TRUE);
  1497. if(isset($post['details']))
  1498. {
  1499. $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
  1500. $order = $this->input->post('order',true);
  1501. $post['details'] = $this->input->post('details',true);
  1502. $post['sku'] = $this->input->post('sku',true);
  1503. $category = $this->input->post('category',true);
  1504. $list['category'] = $category;
  1505. $list['hairtype'] = $this->input->post('hairtype',true);
  1506. $list['grade'] = $this->input->post('grade',true);
  1507. $size = $this->input->post('size',true);
  1508. $list['size'] = rtrim($size,',');
  1509. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1510. $list['extension'] = $this->input->post('extension',true);
  1511. if($category == 1297)
  1512. {
  1513. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1514. }
  1515. if($category == 1702)
  1516. {
  1517. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1518. $list['syother'] = $this->input->post('syother',true);
  1519. }
  1520. if($category == 133)
  1521. {
  1522. $list['fittype'] = $this->input->post('fittype',true);
  1523. $list['acother'] = $this->input->post('acother',true);
  1524. }
  1525. $list['color'] = $this->input->post('color',true);
  1526. $list['lowe'] = $this->input->post('lowe',true);
  1527. $post['warehouse'] = $this->input->post('warehouse',true);
  1528. if($category == 127)
  1529. {
  1530. $list['type'] = $this->input->post('type',true);
  1531. $list['headroad'] = $this->input->post('headroad',true);
  1532. $list['density'] = $this->input->post('density',true);
  1533. $list['lacesize'] = $this->input->post('lacesize',true);
  1534. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1535. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1536. $list['lacetypestwo'] = $this->input->post('lacetypestwo',true);
  1537. }
  1538. if($category == 128)
  1539. {
  1540. $list['lacetype'] = $this->input->post('lacetype',true);
  1541. $list['haircap'] = $this->input->post('haircap',true);
  1542. $list['density'] = $this->input->post('density',true);
  1543. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1544. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1545. $list['wigother'] = $this->input->post('wigother',true);
  1546. $list['wigother1'] = $this->input->post('wigother1',true);
  1547. $list['wigother2'] = $this->input->post('wigother2',true);
  1548. $list['product_related'] = $this->input->post('product_related', true);
  1549. }
  1550. if($category == 129)
  1551. {
  1552. $list['wide'] = $this->input->post('wide',true);
  1553. }
  1554. if($category == 131)
  1555. {
  1556. $list['gifttype'] = $this->input->post('gifttype',true);
  1557. $list['giftother'] = $this->input->post('giftother',true);
  1558. }
  1559. if($category == 134)
  1560. {
  1561. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1562. }
  1563. if($category == 1297)
  1564. {
  1565. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1566. $list['sywigother'] = $this->input->post('sywigother',true);
  1567. }
  1568. if($category == 130 || $category == 133 || $category == 1702)
  1569. {
  1570. $list['items'] = $this->input->post('items',true);
  1571. $list['weight'] = $this->input->post('weight',true);
  1572. }
  1573. else if($category == 1702)
  1574. {
  1575. $list['syhairther'] = $this->input->post('syhairther',true);
  1576. }
  1577. if($category == 130){
  1578. $list['jfother'] = $this->input->post('jfother', true);
  1579. }
  1580. foreach($list as $k=>$v)
  1581. {
  1582. if($v != 0)
  1583. {
  1584. $num .=$v;
  1585. $features .=$v.'-';
  1586. $post[$k] = $v;
  1587. $typeclass = $this->typeclass->read($v);
  1588. if($k != 'size')
  1589. {
  1590. $title .= $typeclass['title']." ";
  1591. }
  1592. }
  1593. }
  1594. $typeclass = $this->typeclass->read($list['size']);
  1595. $title .= $typeclass['title'];
  1596. $time = time();
  1597. $post['title'] = rtrim($title,' ');
  1598. $post['number'] = $num;
  1599. $post['features'] = '-'.$features;
  1600. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  1601. $featurespp = explode('-',trim($featurespp,'-'));
  1602. if (isset($featurespp[5])) {
  1603. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  1604. } else {
  1605. if(isset($featurespp[4])){
  1606. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  1607. }else{
  1608. $post['featurespp'] = trim($features,'-');
  1609. }
  1610. }
  1611. $post['enter'] = $time;
  1612. $post['time'] = $time;//操作时间
  1613. for($i=0;$i<$order;$i++)
  1614. {
  1615. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1616. $this->specialstock->insert($post);
  1617. }
  1618. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  1619. }
  1620. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1621. $this->data['wlshop'] = $wlshop;
  1622. $this->_Template('specialstock_enteradd',$this->data);
  1623. }
  1624. //修改产品
  1625. public function _enteredit($arg_array)
  1626. {
  1627. $dt = 0;
  1628. if(isset($_SESSION['api']))
  1629. {
  1630. $user = $this->user->get_api($_SESSION['api']);
  1631. $usp = $user;
  1632. $fgshop = "";$sid = "";
  1633. $user = explode('|',trim($user['shop'],'|'));
  1634. foreach ($user as $value)
  1635. {
  1636. $fgshop .= " shop = ".$value." or";
  1637. $sid .= " id = ".$value." or";
  1638. }
  1639. }
  1640. $post = $this->input->post(NULL, TRUE);
  1641. if(isset($post['details']))
  1642. {
  1643. $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
  1644. $id = $this->input->post('id',true);
  1645. $order = $this->input->post('order',true);
  1646. $post['details'] = $this->input->post('details',true);
  1647. $post['sku'] = $this->input->post('sku',true);
  1648. $category = $this->input->post('category',true);
  1649. $list['category'] = $category;
  1650. $list['hairtype'] = $this->input->post('hairtype',true);
  1651. $list['grade'] = $this->input->post('grade',true);
  1652. $size = $this->input->post('size',true);
  1653. $list['size'] = rtrim($size,',');
  1654. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1655. $list['extension'] = $this->input->post('extension',true);
  1656. if($category == 1297)
  1657. {
  1658. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1659. }
  1660. if($category == 1702)
  1661. {
  1662. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1663. $list['syother'] = $this->input->post('syother',true);
  1664. }
  1665. if($category == 133)
  1666. {
  1667. $list['fittype'] = $this->input->post('fittype',true);
  1668. $list['acother'] = $this->input->post('acother',true);
  1669. }
  1670. $list['color'] = $this->input->post('color',true);
  1671. $list['lowe'] = $this->input->post('lowe',true);
  1672. $post['warehouse'] = $this->input->post('warehouse',true);
  1673. if($category == 127)
  1674. {
  1675. $list['type'] = $this->input->post('type',true);
  1676. $list['headroad'] = $this->input->post('headroad',true);
  1677. $list['density'] = $this->input->post('density',true);
  1678. $list['lacesize'] = $this->input->post('lacesize',true);
  1679. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1680. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1681. $list['lacetypestwo'] = $this->input->post('lacetypestwo',true);
  1682. }
  1683. if($category == 128 || $category == 2465)
  1684. {
  1685. $list['lacetype'] = $this->input->post('lacetype',true);
  1686. $list['haircap'] = $this->input->post('haircap',true);
  1687. $list['density'] = $this->input->post('density',true);
  1688. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1689. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1690. $list['wigother'] = $this->input->post('wigother',true);
  1691. $list['wigother1'] = $this->input->post('wigother1',true);
  1692. $list['wigother2'] = $this->input->post('wigother2',true);
  1693. $list['product_related'] = $this->input->post('product_related', true);
  1694. }
  1695. if($category == 129)
  1696. {
  1697. $list['wide'] = $this->input->post('wide',true);
  1698. }
  1699. if($category == 131)
  1700. {
  1701. $list['gifttype'] = $this->input->post('gifttype',true);
  1702. $list['giftother'] = $this->input->post('giftother',true);
  1703. }
  1704. if($category == 134)
  1705. {
  1706. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1707. }
  1708. if($category == 1297)
  1709. {
  1710. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1711. $list['sywigother'] = $this->input->post('sywigother',true);
  1712. }
  1713. if($category == 130 || $category == 133 || $category == 1702)
  1714. {
  1715. $list['items'] = $this->input->post('items',true);
  1716. $list['weight'] = $this->input->post('weight',true);
  1717. }
  1718. else if($category == 1702)
  1719. {
  1720. $list['syhairther'] = $this->input->post('syhairther',true);
  1721. }
  1722. if($category == 130){
  1723. $list['jfother'] = $this->input->post('jfother', true);
  1724. }
  1725. foreach($list as $k=>$v)
  1726. {
  1727. if($v != 0)
  1728. {
  1729. $num .=$v;
  1730. $features .=$v.'-';
  1731. $typeclass = $this->typeclass->read($v);
  1732. if($k != 'size')
  1733. {
  1734. $title .= $typeclass['title']." ";
  1735. }
  1736. }
  1737. }
  1738. $typeclass = $this->typeclass->read($list['size']);
  1739. $title .= $typeclass['title'];
  1740. $time = time();
  1741. $post['title'] = rtrim($title,' ');
  1742. $post['number'] = $num;
  1743. $post['features'] = '-'.$features;
  1744. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  1745. $featurespp = explode('-',trim($featurespp,'-'));
  1746. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  1747. $post['time'] = $time;//操作时间
  1748. $uid = $this->specialstock->read($id);
  1749. $datanum = $this->specialstock->find_count("state = 0 and number = '".$uid['number']."' and zd != ''");
  1750. if($datanum > 0)
  1751. {
  1752. echo json_encode(array('msg'=>'此库存有占单,请解除占单后再修改!','success'=>false));exit;
  1753. }
  1754. $data = $this->specialstock->find_all("number = '".$uid['number']."' and enter = '".$uid['enter']."'");// and enter = '".$uid['enter']."'
  1755. foreach ($data as $v)
  1756. {
  1757. $post['id'] = $v['id'];
  1758. $this->specialstock->save($post,$v['id']);
  1759. }
  1760. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  1761. }
  1762. $uid = $this->specialstock->read($arg_array[0]);
  1763. $uid['order'] = $this->specialstock->find_count('enter = '.$uid['enter']);
  1764. $this->data['enter'] = $uid ;
  1765. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1766. $this->data['wlshop'] = $wlshop;
  1767. $whlabelwz = $this->whlabelwz->find_all();
  1768. $this->data['whlabelwz'] = $whlabelwz;
  1769. $this->_Template('specialstock_enteredit',$this->data);
  1770. }
  1771. //入库浏览
  1772. public function _enter()
  1773. {
  1774. $post = $this->input->post(NULL, TRUE);
  1775. if(isset($post['s']))
  1776. {
  1777. $id_arr = $this->input->post('s');
  1778. $id_arr = explode(',',$id_arr);
  1779. if(!$id_arr)
  1780. {
  1781. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1782. }
  1783. //循环删除记录
  1784. foreach ($id_arr as $v)
  1785. {
  1786. $sid = $this->specialstock->read($v);
  1787. $info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
  1788. foreach ($info_list as $va)
  1789. {
  1790. $this->specialstock->remove($va['id']);
  1791. }
  1792. }
  1793. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  1794. }
  1795. if(isset($post['page']))
  1796. {
  1797. $page = $this->input->post('page',true);
  1798. $perpage = $this->input->post('perpage',true);
  1799. $category = $this->input->post('category',true);
  1800. $size = $this->input->post('size',true);
  1801. $grade = $this->input->post('grade',true);
  1802. $color = $this->input->post('color',true);
  1803. $details = $this->input->post('details',true);
  1804. $sku = $this->input->post('sku',true);
  1805. $warehouse = '';//12
  1806. $ktime = $this->input->post('ktime',true);
  1807. $jtime = $this->input->post('jtime',true);
  1808. $ktime = strtotime($ktime);
  1809. $jtime = strtotime($jtime);
  1810. $where = "1=1";$gj = "";$ck = "";
  1811. if($category)
  1812. {
  1813. $where .= " and features like '%-$category-%'";
  1814. }
  1815. if($size)
  1816. {
  1817. $where .= " and features like '%-$size-%'";
  1818. }
  1819. if($grade)
  1820. {
  1821. $where .= " and features like '%-$grade-%'";
  1822. }
  1823. if($color)
  1824. {
  1825. $where .= " and features like '%-$color-%'";
  1826. }
  1827. if($details)
  1828. {
  1829. $where .= " and details like '%$details%'";
  1830. }
  1831. if($sku)
  1832. {
  1833. $where .= " and sku like '%$sku%'";
  1834. }
  1835. if($warehouse)
  1836. {
  1837. $where .= " and warehouse = '$warehouse'";
  1838. }
  1839. if($ktime && $jtime)
  1840. {
  1841. $where .= " and enter > '$ktime' and enter < '$jtime'";
  1842. }
  1843. //数据排序
  1844. $order_str = "enter desc";
  1845. if(empty($page))
  1846. {
  1847. $start = 0;
  1848. $perpage = 1;
  1849. }
  1850. else
  1851. {
  1852. $start = ($page - 1)*$perpage;
  1853. }
  1854. //取得信息列表
  1855. $info_list = $this->specialstock->find_all($where,'*',$order_str);
  1856. $rows = array();$list = array();
  1857. foreach ($info_list as $key=>$value)
  1858. {
  1859. $rows[$value['enter'].$value['number']] = $value;//所有数据sku
  1860. }
  1861. foreach ($rows as $value)
  1862. {
  1863. $g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9'." and sku = '".$value['sku']."' ");
  1864. $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);
  1865. }
  1866. $total = count($list);
  1867. $pagenum = ceil($total/$perpage);
  1868. $over = $total-($start+$perpage);
  1869. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  1870. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list),'abc'=>($where));
  1871. echo json_encode($rows);exit;
  1872. }
  1873. $this->_Template('specialstock_enter',$this->data);
  1874. }
  1875. //入库浏览
  1876. public function _xhcenter()
  1877. {
  1878. $post = $this->input->post(NULL, TRUE);
  1879. if(isset($post['s']))
  1880. {
  1881. $id_arr = $this->input->post('s');
  1882. $id_arr = explode(',',$id_arr);
  1883. if(!$id_arr)
  1884. {
  1885. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1886. }
  1887. //循环删除记录
  1888. foreach ($id_arr as $v)
  1889. {
  1890. $sid = $this->specialstock->read($v);
  1891. $info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
  1892. foreach ($info_list as $va)
  1893. {
  1894. $this->specialstock->remove($va['id']);
  1895. }
  1896. }
  1897. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  1898. }
  1899. if(isset($post['page']))
  1900. {
  1901. $page = $this->input->post('page',true);
  1902. $perpage = $this->input->post('perpage',true);
  1903. $category = $this->input->post('category',true);
  1904. $size = $this->input->post('size',true);
  1905. $grade = $this->input->post('grade',true);
  1906. $color = $this->input->post('color',true);
  1907. $details = $this->input->post('details',true);
  1908. $sku = $this->input->post('sku',true);
  1909. $warehouse = $this->input->post('warehouse',true);
  1910. $ktime = $this->input->post('ktime',true);
  1911. $jtime = $this->input->post('jtime',true);
  1912. $ktime = strtotime($ktime);
  1913. $jtime = strtotime($jtime);
  1914. $where = "warehouse != '12'";$gj = "";$ck = "";
  1915. if($category)
  1916. {
  1917. $where .= " and features like '%-$category-%'";
  1918. }
  1919. if($size)
  1920. {
  1921. $where .= " and features like '%-$size-%'";
  1922. }
  1923. if($grade)
  1924. {
  1925. $where .= " and features like '%-$grade-%'";
  1926. }
  1927. if($color)
  1928. {
  1929. $where .= " and features like '%-$color-%'";
  1930. }
  1931. if($details)
  1932. {
  1933. $where .= " and details like '%$details%'";
  1934. }
  1935. if($sku)
  1936. {
  1937. $where .= " and sku like '%$sku%'";
  1938. }
  1939. if($warehouse)
  1940. {
  1941. $where .= " and warehouse = '$warehouse'";
  1942. }
  1943. if($ktime && $jtime)
  1944. {
  1945. $where .= " and enter > '$ktime' and enter < '$jtime'";
  1946. }
  1947. //数据排序
  1948. $order_str = "enter desc";
  1949. if(empty($page))
  1950. {
  1951. $start = 0;
  1952. $perpage = 1;
  1953. }
  1954. else
  1955. {
  1956. $start = ($page - 1)*$perpage;
  1957. }
  1958. //取得信息列表
  1959. $info_list = $this->specialstock->find_all($where,'*',$order_str);
  1960. $rows = array();$list = array();
  1961. foreach ($info_list as $key=>$value)
  1962. {
  1963. $rows[$value['enter'].$value['number']] = $value;//所有数据sku
  1964. }
  1965. foreach ($rows as $value)
  1966. {
  1967. $g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9');
  1968. $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);
  1969. }
  1970. $total = count($list);
  1971. $pagenum = ceil($total/$perpage);
  1972. $over = $total-($start+$perpage);
  1973. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  1974. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1975. echo json_encode($rows);exit;
  1976. }
  1977. $this->_Template('specialstock_xhcenter',$this->data);
  1978. }
  1979. //出库浏览
  1980. public function _out()
  1981. {
  1982. $post = $this->input->post(NULL, TRUE);
  1983. if(isset($post['page']))
  1984. {
  1985. $page = $this->input->post('page',true);
  1986. $perpage = $this->input->post('perpage',true);
  1987. $category = $this->input->post('category',true);
  1988. $size = $this->input->post('size',true);
  1989. $grade = $this->input->post('grade',true);
  1990. $color = $this->input->post('color',true);
  1991. $lowe = $this->input->post('lowe',true);
  1992. $sku = $this->input->post('sku',true);
  1993. $warehouse = $this->input->post('warehouse',true);
  1994. $purchase = $this->input->post('purchase',true);
  1995. $ktime = $this->input->post('ktime',true);
  1996. $jtime = $this->input->post('jtime',true);
  1997. $ktime = strtotime($ktime);
  1998. $jtime = strtotime($jtime);
  1999. $where = "state=3";$gj = "";$ck = "";
  2000. if($category)
  2001. {
  2002. $where .= " and features like '%-$category-%'";
  2003. }
  2004. if($size)
  2005. {
  2006. $where .= " and features like '%-$size-%'";
  2007. }
  2008. if($grade)
  2009. {
  2010. $where .= " and features like '%-$grade-%'";
  2011. }
  2012. if($color)
  2013. {
  2014. $where .= " and features like '%-$color-%'";
  2015. }
  2016. if($lowe)
  2017. {
  2018. $where .= " and features like '%-$lowe-%'";
  2019. }
  2020. if($state)
  2021. {
  2022. $where .= " and state = '$state'";
  2023. }
  2024. if($warehouse)
  2025. {
  2026. $where .= " and warehouse = '$warehouse'";
  2027. }
  2028. if($purchase)
  2029. {
  2030. $where .= " and purchase = '$purchase'";
  2031. }
  2032. if($sku)
  2033. {
  2034. $where .= " and sku = '$sku'";
  2035. }
  2036. if($ktime && $jtime)
  2037. {
  2038. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2039. }
  2040. //数据排序
  2041. $order_str = "id desc";
  2042. if(empty($page))
  2043. {
  2044. $start = 0;
  2045. $perpage = 1;
  2046. }
  2047. else
  2048. {
  2049. $start = ($page - 1)*$perpage;
  2050. }
  2051. //取得信息列表
  2052. $info_list = $this->specialstock->find_all($where,'sku');
  2053. $rows = array();$list = array();
  2054. foreach ($info_list as $key=>$value)
  2055. {
  2056. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2057. }
  2058. $rows = array_unique($rows);//删除重复记录
  2059. foreach ($rows as $key=>$value)
  2060. {
  2061. $data = $this->specialstock->get_sku($value);//获取目前sku的所有数据
  2062. $ck = $this->warehouse->read($data['warehouse']);
  2063. $warehouse = $ck['title'];
  2064. $gy = $this->purchase->read($data['purchase']);
  2065. $purchase = $gy['purchase'];
  2066. $g = $this->specialstock->find_count($where.' and sku = "'.$value.'" and state = 3');
  2067. $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);
  2068. }
  2069. $total = count($list);
  2070. $pagenum = ceil($total/$perpage);
  2071. $over = $total-($start+$perpage);
  2072. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2073. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2074. echo json_encode($rows);exit;
  2075. }
  2076. $this->_Template('specialstock_out',$this->data);
  2077. }
  2078. //出库标签浏览
  2079. public function _label()
  2080. {
  2081. $post = $this->input->post(NULL, TRUE);
  2082. if(isset($post['page']))
  2083. {
  2084. $page = $this->input->post('page',true);
  2085. $perpage = $this->input->post('perpage',true);
  2086. $sku = $this->input->post('sku',true);
  2087. $warehouse = $this->input->post('warehouse',true);
  2088. $purchase = $this->input->post('purchase',true);
  2089. $orderinfo = $this->input->post('orderinfo',true);
  2090. $waybill = $this->input->post('waybill',true);
  2091. $category = $this->input->post('category',true);
  2092. $size = $this->input->post('size',true);
  2093. $grade = $this->input->post('grade',true);
  2094. $color = $this->input->post('color',true);
  2095. $lowe = $this->input->post('lowe',true);
  2096. $where = "state=1";
  2097. if($sku)
  2098. {
  2099. $where .= " and sku = '$sku'";
  2100. }
  2101. if($warehouse)
  2102. {
  2103. $where .= " and warehouse = '$warehouse'";
  2104. }
  2105. if($purchase)
  2106. {
  2107. $where .= " and purchase = '$purchase'";
  2108. }
  2109. if($orderinfo)
  2110. {
  2111. $where .= " and orderinfo = '$orderinfo'";
  2112. }
  2113. if($waybill)
  2114. {
  2115. $where .= " and waybill = '$waybill'";
  2116. }
  2117. if($category)
  2118. {
  2119. $where .= " and features like '%-$category-%'";
  2120. }
  2121. if($size)
  2122. {
  2123. $where .= " and features like '%-$size-%'";
  2124. }
  2125. if($grade)
  2126. {
  2127. $where .= " and features like '%-$grade-%'";
  2128. }
  2129. if($color)
  2130. {
  2131. $where .= " and features like '%-$color-%'";
  2132. }
  2133. if($lowe)
  2134. {
  2135. $where .= " and features like '%-$lowe-%'";
  2136. }
  2137. //数据排序
  2138. $order_str = "outk desc";
  2139. if(empty($page))
  2140. {
  2141. $start = 0;
  2142. $perpage = 1;
  2143. }
  2144. else
  2145. {
  2146. $start = ($page - 1)*$perpage;
  2147. }
  2148. //取得信息列表
  2149. $info_list = $this->specialstock->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2150. foreach ($info_list as $key=>$value)
  2151. {
  2152. $warehouse = $this->warehouse->read($value['warehouse']);
  2153. $info_list[$key]['warehouse'] = $warehouse['title'];
  2154. $purchase = $this->purchase->read($value['purchase']);
  2155. $info_list[$key]['purchase'] = $purchase['title'];
  2156. if($value['outk'] != 0)
  2157. {
  2158. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2159. }
  2160. else
  2161. {
  2162. $info_list[$key]['outk'] = "";
  2163. }
  2164. if($value['orderinfo'] == 0)
  2165. {
  2166. $info_list[$key]['orderinfo'] = "";
  2167. }
  2168. if($value['waybill'] == 0)
  2169. {
  2170. $info_list[$key]['waybill'] = "";
  2171. }
  2172. }
  2173. $total = $this->specialstock->find_count($where);
  2174. $pagenum = ceil($total/$perpage);
  2175. $over = $total-($start+$perpage);
  2176. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2177. echo json_encode($rows);exit;
  2178. }
  2179. $this->_Template('specialstock_label',$this->data);
  2180. }
  2181. //独立站出库订单
  2182. public function _outorder()
  2183. {
  2184. if(isset($_SESSION['api']))
  2185. {
  2186. $user = $this->user->get_api($_SESSION['api']);
  2187. $usp = $user;
  2188. $fgshop = "";$sid = "";
  2189. $user = explode('|',trim($user['shop'],'|'));
  2190. foreach ($user as $value)
  2191. {
  2192. $sid .= " id = ".$value." or";
  2193. }
  2194. }
  2195. $post = $this->input->post(NULL, TRUE);
  2196. if(isset($post['page']))
  2197. {
  2198. $page = $this->input->post('page',true);
  2199. $perpage = $this->input->post('perpage',true);
  2200. $warehouse = $this->input->post('warehouse',true);
  2201. $xztime = $this->input->post('xztime',true);
  2202. $timetk = $this->input->post('timetkk',true);
  2203. $timetj = $this->input->post('timetjj',true);
  2204. $shop = $this->input->post('shop',true);
  2205. $source = $this->input->post('source',true);
  2206. $orderinfo = $this->input->post('orderinfo',true);
  2207. $number = $this->input->post('number',true);
  2208. $express = $this->input->post('express',true);
  2209. $waybill = $this->input->post('waybill',true);
  2210. $library = $this->input->post('library',true);
  2211. $country = $this->input->post('country',true);
  2212. $so = $this->input->post('so',true);
  2213. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2214. $print = $this->input->post('print',true);
  2215. $state = $this->input->post('state',true);
  2216. $timetk = strtotime($timetk);
  2217. $timetj = strtotime($timetj);
  2218. /**
  2219. $sj = $this->input->post('sj',true);
  2220. if($sj)
  2221. {
  2222. $sj = $this->input->post('sj',true);
  2223. }
  2224. else
  2225. {
  2226. $sj = "fullorder";
  2227. }
  2228. **/
  2229. $sj = "fullorder";
  2230. $where = "mergeid = 0";
  2231. if($warehouse)
  2232. {
  2233. $where .= " and type = '$warehouse'";
  2234. }
  2235. if($timetk && $timetj)
  2236. {
  2237. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2238. }
  2239. if($orderinfo)
  2240. {
  2241. $where .= " and orderinfo = '$orderinfo'";
  2242. }
  2243. if($number)
  2244. {
  2245. $where .= " and number = '$number'";
  2246. }
  2247. if($express)
  2248. {
  2249. $where .= " and express = '$express'";
  2250. }
  2251. if($waybill)
  2252. {
  2253. $where .= " and waybill = '$waybill'";
  2254. }
  2255. if($library)
  2256. {
  2257. $where .= " and library = '$library'";
  2258. }
  2259. if($print)
  2260. {
  2261. $where .= " and print = '$print'";
  2262. }
  2263. if($libraryconfirm)
  2264. {
  2265. $where .= " and libraryconfirm = '$libraryconfirm'";
  2266. }
  2267. if($state)
  2268. {
  2269. $where .= " and state = '$state'";
  2270. }
  2271. if($shop)
  2272. {
  2273. $where .= " and shop = '$shop'";
  2274. }
  2275. if($country)
  2276. {
  2277. $where .= " and country = '$country'";
  2278. }
  2279. if($so)
  2280. {
  2281. $where .= " and shipremarks like '%$so%'";
  2282. }
  2283. if($source)
  2284. {
  2285. $where .= " and source = '$source'";
  2286. }
  2287. else
  2288. {
  2289. if(isset($_SESSION['api']))
  2290. {
  2291. foreach ($user as $value)
  2292. {
  2293. $fgshop .= " shop = ".$value." or";
  2294. }
  2295. $where .= " and (".rtrim($fgshop,'or').")";
  2296. }
  2297. }
  2298. //数据排序
  2299. $order_str = "librarytime desc";
  2300. if(empty($page))
  2301. {
  2302. $start = 0;
  2303. $perpage = 1;
  2304. }
  2305. else
  2306. {
  2307. $start = ($page - 1)*$perpage;
  2308. }
  2309. //取得信息列表
  2310. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2311. //格式化数据
  2312. foreach ($info_list as $key=>$value)
  2313. {
  2314. $shop = $this->shop->read($value['shop']);
  2315. $info_list[$key]['shop'] = $shop['shopname'];
  2316. $express = $this->express->read($value['express']);
  2317. $info_list[$key]['express'] = $express['servicename'];
  2318. $warehouse = $this->warehouse->read($value['type']);
  2319. $info_list[$key]['type'] = $warehouse['title'];
  2320. if($value['librarytime'] == '0')
  2321. {
  2322. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2323. }
  2324. else
  2325. {
  2326. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2327. }
  2328. }
  2329. $total = $this->$sj->find_count($where);
  2330. $pagenum = ceil($total/$perpage);
  2331. $over = $total-($start+$perpage);
  2332. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2333. echo json_encode($rows);exit;
  2334. }
  2335. $this->data['express'] = $this->express->find_all();
  2336. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2337. $this->data['wlshop'] = $wlshop;
  2338. $this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=2','*','idorder desc');//导出模板
  2339. $this->_Template('specialstock_outorder',$this->data);
  2340. }
  2341. //速卖通出库订单
  2342. public function _soutorder()
  2343. {
  2344. if(isset($_SESSION['api']))
  2345. {
  2346. $user = $this->user->get_api($_SESSION['api']);
  2347. $usp = $user;
  2348. $fgshop = "";$sid = "";
  2349. $user = explode('|',trim($user['shop'],'|'));
  2350. foreach ($user as $value)
  2351. {
  2352. $sid .= " id = ".$value." or";
  2353. }
  2354. }
  2355. $post = $this->input->post(NULL, TRUE);
  2356. if(isset($post['page']))
  2357. {
  2358. $page = $this->input->post('page',true);
  2359. $perpage = $this->input->post('perpage',true);
  2360. $warehouse = $this->input->post('warehouse',true);
  2361. $xztime = $this->input->post('xztime',true);
  2362. $timetk = $this->input->post('timetkk',true);
  2363. $timetj = $this->input->post('timetjj',true);
  2364. $shop = $this->input->post('shop',true);
  2365. $source = $this->input->post('source',true);
  2366. $orderinfo = $this->input->post('orderinfo',true);
  2367. $number = $this->input->post('number',true);
  2368. $express = $this->input->post('express',true);
  2369. $waybill = $this->input->post('waybill',true);
  2370. $library = $this->input->post('library',true);
  2371. $country = $this->input->post('country',true);
  2372. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2373. $print = $this->input->post('print',true);
  2374. $state = $this->input->post('state',true);
  2375. $so = $this->input->post('so',true);
  2376. $timetk = strtotime($timetk);
  2377. $timetj = strtotime($timetj);
  2378. /**
  2379. $sj = $this->input->post('sj',true);
  2380. if($sj)
  2381. {
  2382. $sj = $this->input->post('sj',true);
  2383. }
  2384. else
  2385. {
  2386. $sj = "fullorder";
  2387. }
  2388. **/
  2389. $sj = "fullordersmt";
  2390. $where = "mergeid = 0";
  2391. if($warehouse)
  2392. {
  2393. $where .= " and type = '$warehouse'";
  2394. }
  2395. if($timetk && $timetj)
  2396. {
  2397. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2398. }
  2399. if($orderinfo)
  2400. {
  2401. $where .= " and orderinfo = '$orderinfo'";
  2402. }
  2403. if($number)
  2404. {
  2405. $where .= " and number = '$number'";
  2406. }
  2407. if($express)
  2408. {
  2409. $where .= " and express = '$express'";
  2410. }
  2411. if($waybill)
  2412. {
  2413. $where .= " and waybill = '$waybill'";
  2414. }
  2415. if($library)
  2416. {
  2417. $where .= " and library = '$library'";
  2418. }
  2419. if($print)
  2420. {
  2421. $where .= " and print = '$print'";
  2422. }
  2423. if($libraryconfirm)
  2424. {
  2425. $where .= " and libraryconfirm = '$libraryconfirm'";
  2426. }
  2427. if($state)
  2428. {
  2429. $where .= " and state = '$state'";
  2430. }
  2431. if($shop)
  2432. {
  2433. $where .= " and shop = '$shop'";
  2434. }
  2435. if($so)
  2436. {
  2437. $where .= " and shipremarks like '%$so%'";
  2438. }
  2439. if($source)
  2440. {
  2441. $where .= " and source = '$source'";
  2442. }
  2443. if($country)
  2444. {
  2445. $where .= " and country = '$country'";
  2446. }
  2447. else
  2448. {
  2449. if(isset($_SESSION['api']))
  2450. {
  2451. foreach ($user as $value)
  2452. {
  2453. $fgshop .= " shop = ".$value." or";
  2454. }
  2455. $where .= " and (".rtrim($fgshop,'or').")";
  2456. }
  2457. }
  2458. //数据排序
  2459. $order_str = "librarytime desc";
  2460. if(empty($page))
  2461. {
  2462. $start = 0;
  2463. $perpage = 1;
  2464. }
  2465. else
  2466. {
  2467. $start = ($page - 1)*$perpage;
  2468. }
  2469. //取得信息列表
  2470. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2471. //格式化数据
  2472. foreach ($info_list as $key=>$value)
  2473. {
  2474. $shop = $this->shop->read($value['shop']);
  2475. $info_list[$key]['shop'] = $shop['shopname'];
  2476. $express = $this->express->read($value['express']);
  2477. $info_list[$key]['express'] = $express['servicename'];
  2478. $warehouse = $this->warehouse->read($value['type']);
  2479. $info_list[$key]['type'] = $warehouse['title'];
  2480. if($value['librarytime'] == '0')
  2481. {
  2482. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2483. }
  2484. else
  2485. {
  2486. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2487. }
  2488. }
  2489. $total = $this->$sj->find_count($where);
  2490. $pagenum = ceil($total/$perpage);
  2491. $over = $total-($start+$perpage);
  2492. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2493. echo json_encode($rows);exit;
  2494. }
  2495. $this->data['express'] = $this->express->find_all();
  2496. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2497. $this->data['wlshop'] = $wlshop;
  2498. $this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=5','*','idorder desc');//导出模板
  2499. $this->_Template('specialstock_soutorder',$this->data);
  2500. }
  2501. //订单退库
  2502. public function _retreat()
  2503. {
  2504. $post = $this->input->post(NULL, TRUE);
  2505. if(isset($post['page']))
  2506. {
  2507. $page = $this->input->post('page',true);
  2508. $perpage = $this->input->post('perpage',true);
  2509. $warehouse = $this->input->post('warehouse',true);
  2510. $timetk = $this->input->post('timetk',true);
  2511. $timetj = $this->input->post('timetj',true);
  2512. $shop = $this->input->post('shop',true);
  2513. $source = $this->input->post('source',true);
  2514. $state = $this->input->post('state',true);
  2515. $review = $this->input->post('review',true);
  2516. $state = $this->input->post('state',true);
  2517. $express = $this->input->post('express',true);
  2518. $orderinfo = $this->input->post('orderinfo',true);
  2519. $user = $this->input->post('user',true);
  2520. $name = $this->input->post('name',true);
  2521. $waybill = $this->input->post('waybill',true);
  2522. $timetk = strtotime($timetk);
  2523. $timetj = strtotime($timetj);
  2524. $where = "(state=206 or state=210) and mergeid = 0";
  2525. if($warehouse)
  2526. {
  2527. $where .= " and state = '$warehouse'";
  2528. }
  2529. if($timetk && $timetj)
  2530. {
  2531. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2532. }
  2533. if($shop)
  2534. {
  2535. $where .= " and shop = '$shop'";
  2536. }
  2537. if($source)
  2538. {
  2539. $where .= " and source = '$source'";
  2540. }
  2541. if($state)
  2542. {
  2543. $where .= " and state = '$state'";
  2544. }
  2545. if($review)
  2546. {
  2547. $where .= " and review = '$review'";
  2548. }
  2549. if($state)
  2550. {
  2551. $where .= " and state = '$state'";
  2552. }
  2553. if($express)
  2554. {
  2555. $where .= " and express = '$express'";
  2556. }
  2557. if($orderinfo)
  2558. {
  2559. $where .= " and orderinfo = '$orderinfo'";
  2560. }
  2561. if($user)
  2562. {
  2563. $where .= " and user = '$user'";
  2564. }
  2565. if($name)
  2566. {
  2567. $where .= " and name = '$name'";
  2568. }
  2569. if($waybill)
  2570. {
  2571. $where .= " and waybill = '$waybill'";
  2572. }
  2573. //数据排序
  2574. $order_str = "id desc";
  2575. if(empty($page))
  2576. {
  2577. $start = 0;
  2578. $perpage = 1;
  2579. }
  2580. else
  2581. {
  2582. $start = ($page - 1)*$perpage;
  2583. }
  2584. //取得信息列表
  2585. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  2586. //格式化数据
  2587. foreach ($info_list as $key=>$value)
  2588. {
  2589. $shop = $this->shop->read($value['shop']);
  2590. $info_list[$key]['shop'] = $shop['shopname'];
  2591. $warehouse = $this->warehouse->read($value['warehouse']);
  2592. $info_list[$key]['warehouse'] = $warehouse['title'];
  2593. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  2594. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  2595. if($value['waybill'] == 0)
  2596. {
  2597. $info_list[$key]['waybill'] = "";
  2598. }
  2599. $express = $this->express->read($value['express']);
  2600. $info_list[$key]['express'] = $express['title'];
  2601. $typeclass = $this->typeclass->read($value['state']);
  2602. $info_list[$key]['state'] = $typeclass['title'];
  2603. }
  2604. $total = $this->fullorder->find_count($where);
  2605. $pagenum = ceil($total/$perpage);
  2606. $over = $total-($start+$perpage);
  2607. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2608. echo json_encode($rows);exit;
  2609. }
  2610. $this->data['express'] = $this->express->find_all();
  2611. $this->_Template('specialstock_retreat',$this->data);
  2612. }
  2613. //退库标签浏览
  2614. public function _retreatlk()
  2615. {
  2616. $post = $this->input->post(NULL, TRUE);
  2617. if(isset($post['page']))
  2618. {
  2619. $page = $this->input->post('page',true);
  2620. $perpage = $this->input->post('perpage',true);
  2621. $timetk = $this->input->post('timetk',true);
  2622. $timetj = $this->input->post('timetj',true);
  2623. $sku = $this->input->post('sku',true);
  2624. $warehouse = $this->input->post('warehouse',true);
  2625. $purchase = $this->input->post('purchase',true);
  2626. $orderinfo = $this->input->post('orderinfo',true);
  2627. $waybill = $this->input->post('waybill',true);
  2628. $category = $this->input->post('category',true);
  2629. $size = $this->input->post('size',true);
  2630. $grade = $this->input->post('grade',true);
  2631. $color = $this->input->post('color',true);
  2632. $lowe = $this->input->post('lowe',true);
  2633. $state = $this->input->post('state',true);
  2634. $timetk = strtotime($timetk);
  2635. $timetj = strtotime($timetj);
  2636. $where = "state=2";
  2637. if($timetk && $timetj)
  2638. {
  2639. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  2640. }
  2641. if($sku)
  2642. {
  2643. $where .= " and sku = '$sku'";
  2644. }
  2645. if($warehouse)
  2646. {
  2647. $where .= " and warehouse = '$warehouse'";
  2648. }
  2649. if($purchase)
  2650. {
  2651. $where .= " and purchase = '$purchase'";
  2652. }
  2653. if($orderinfo)
  2654. {
  2655. $where .= " and orderinfo = '$orderinfo'";
  2656. }
  2657. if($waybill)
  2658. {
  2659. $where .= " and waybill = '$waybill'";
  2660. }
  2661. if($category)
  2662. {
  2663. $where .= " and features like '%-$category-%'";
  2664. }
  2665. if($size)
  2666. {
  2667. $where .= " and features like '%-$size-%'";
  2668. }
  2669. if($grade)
  2670. {
  2671. $where .= " and features like '%-$grade-%'";
  2672. }
  2673. if($color)
  2674. {
  2675. $where .= " and features like '%-$color-%'";
  2676. }
  2677. if($lowe)
  2678. {
  2679. $where .= " and features like '%-$lowe-%'";
  2680. }
  2681. //数据排序
  2682. $order_str = "time desc";
  2683. if(empty($page))
  2684. {
  2685. $start = 0;
  2686. $perpage = 1;
  2687. }
  2688. else
  2689. {
  2690. $start = ($page - 1)*$perpage;
  2691. }
  2692. //取得信息列表
  2693. $info_list = $this->specialstock->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  2694. foreach ($info_list as $key=>$value)
  2695. {
  2696. $warehouse = $this->warehouse->read($value['warehouse']);
  2697. $info_list[$key]['warehouse'] = $warehouse['title'];
  2698. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  2699. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  2700. $purchase = $this->purchase->read($value['purchase']);
  2701. $info_list[$key]['purchase'] = $purchase['title'];
  2702. if($value['outk'] != 0)
  2703. {
  2704. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2705. }
  2706. else
  2707. {
  2708. $info_list[$key]['outk'] = "";
  2709. }
  2710. if($value['retreat'] != 0)
  2711. {
  2712. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  2713. }
  2714. else
  2715. {
  2716. $info_list[$key]['retreat'] = "";
  2717. }
  2718. if($value['orderinfo'] == 0)
  2719. {
  2720. $info_list[$key]['orderinfo'] = "";
  2721. }
  2722. if($value['waybill'] == 0)
  2723. {
  2724. $info_list[$key]['waybill'] = "";
  2725. }
  2726. }
  2727. $total = $this->specialstock->find_count($where);
  2728. $pagenum = ceil($total/$perpage);
  2729. $over = $total-($start+$perpage);
  2730. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2731. echo json_encode($rows);exit;
  2732. }
  2733. $this->_Template('specialstock_retreatlk',$this->data);
  2734. }
  2735. //更换标签及浏览
  2736. public function _change()
  2737. {
  2738. $post = $this->input->post(NULL, TRUE);
  2739. if(isset($post['page']))
  2740. {
  2741. $page = $this->input->post('page',true);
  2742. $perpage = $this->input->post('perpage',true);
  2743. $timetk = $this->input->post('timetk',true);
  2744. $timetj = $this->input->post('timetj',true);
  2745. $label = $this->input->post('label',true);
  2746. $oldlabel = $this->input->post('oldlabel',true);
  2747. $timetk = strtotime($timetk);
  2748. $timetj = strtotime($timetj);
  2749. $where = "state=10 ";
  2750. if($timetk && $timetj)
  2751. {
  2752. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  2753. }
  2754. if($label)
  2755. {
  2756. $where .= " and label = '$label'";
  2757. }
  2758. if($oldlabel)
  2759. {
  2760. $where .= " and oldlabel = '$oldlabel'";
  2761. }
  2762. //数据排序
  2763. $order_str = "time asc";
  2764. if(empty($page))
  2765. {
  2766. $start = 0;
  2767. $perpage = 1;
  2768. }
  2769. else
  2770. {
  2771. $start = ($page - 1)*$perpage;
  2772. }
  2773. //取得信息列表
  2774. $info_list = $this->specialstock->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  2775. foreach ($info_list as $key=>$value)
  2776. {
  2777. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  2778. }
  2779. $total = $this->specialstock->find_count($where);
  2780. $pagenum = ceil($total/$perpage);
  2781. $over = $total-($start+$perpage);
  2782. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2783. echo json_encode($rows);exit;
  2784. }
  2785. $this->_Template('specialstock_change',$this->data);
  2786. }
  2787. //产品标签
  2788. public function _cpbqdc()
  2789. {
  2790. if(isset($_GET['excel']))
  2791. {
  2792. $where = "1=1";
  2793. //数据排序
  2794. $order_str = "id desc";
  2795. if(empty($page))
  2796. {
  2797. $start = 0;
  2798. $perpage = 1;
  2799. }
  2800. else
  2801. {
  2802. $start = ($page - 1)*$perpage;
  2803. }
  2804. $warehouse = $this->input->get('warehouse',true);
  2805. $state = $this->input->get('state',true);
  2806. $timetk = $this->input->get('timetkk',true);
  2807. $timetj = $this->input->get('timetjj',true);
  2808. $timetk = strtotime($timetk);
  2809. $timetj = strtotime($timetj);
  2810. if($warehouse)
  2811. {
  2812. $where .= " and warehouse = '$warehouse'";
  2813. }
  2814. if($state || $state == 0)
  2815. {
  2816. $where .= " and state = '$state'";
  2817. }
  2818. if($timetk && $timetj)
  2819. {
  2820. $where .= " and time > '$timetk' and time < '$timetj'";
  2821. }
  2822. //取得信息列表
  2823. $info_list = $this->specialstock->find_all($where,'*');
  2824. $rows = array();$list = array();
  2825. foreach ($info_list as $key=>$value)
  2826. {
  2827. $rows[$value['time']] = $value;//所有数据sku
  2828. }
  2829. foreach ($rows as $value)
  2830. {
  2831. $warehouse = $this->warehouse->read($value['warehouse']);
  2832. $s = $this->specialstock->find_count($where.' and time = "'.$value['time'].'"');
  2833. $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);
  2834. }
  2835. $title = "产品标签统计表";
  2836. $titlename = "<table border=1>
  2837. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  2838. <tr align='center'>
  2839. <td>仓库</td>
  2840. <td>SKU</td>
  2841. <td>产品</td>
  2842. <td>入库时间</td>
  2843. <td>操作时间</td>
  2844. <td>备注</td>
  2845. <td>数量</td>
  2846. </tr>
  2847. </table>";
  2848. $filename = $title.".xls";
  2849. $tail = "";
  2850. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  2851. }
  2852. }
  2853. //进销存导出
  2854. public function _exceljxc()
  2855. {
  2856. if(isset($_GET['excel']))
  2857. {
  2858. $where = "1=1";
  2859. //数据排序
  2860. $order_str = "id desc";
  2861. if(empty($page))
  2862. {
  2863. $start = 0;
  2864. $perpage = 1;
  2865. }
  2866. else
  2867. {
  2868. $start = ($page - 1)*$perpage;
  2869. }
  2870. $category = $this->input->get('category',true);
  2871. $warehouse = $this->input->get('warehouse',true);
  2872. $pc = $this->input->get('pc',true);
  2873. if($pc)
  2874. {
  2875. $pc = trim($pc,'x');
  2876. $pc = explode('x',$pc);
  2877. foreach ($pc as $v)
  2878. {
  2879. $where .= " and warehouse != '".$v."'";
  2880. }
  2881. }
  2882. if($category)
  2883. {
  2884. $where .= " and features like '%-$category-%'";
  2885. }
  2886. if($warehouse)
  2887. {
  2888. $where .= " and warehouse = '$warehouse'";
  2889. }
  2890. //取得信息列表
  2891. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,features,sku,details,warehouse,number,title,cpbz');
  2892. $list = array();
  2893. // foreach ($info_list as $value)
  2894. // {
  2895. // $classid = $this->classid->sku();
  2896. // $pm = $classid;
  2897. // //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2898. // $features = explode('-',trim($value['features'],'-'));
  2899. // foreach ($features as $v)
  2900. // {
  2901. // $typeclass = $this->typeclass->read($v);
  2902. // $pm[$typeclass['classid']] = $typeclass['zh'];
  2903. // //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2904. // }
  2905. // $typeclass = $this->typeclass->read($v);
  2906. // //$scsku = implode("-",$scsku);
  2907. // $zh = implode(" ",$pm);
  2908. // $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2909. // //$scsku = str_replace('- ','-',trim($scsku,'-'));
  2910. // //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2911. // $cpid = '';
  2912. // $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"','cpid');
  2913. // foreach ($c as $v)
  2914. // {
  2915. // if($v['cpid'] != 0)
  2916. // {
  2917. // $cpid .= $v['cpid'].' ';
  2918. // }
  2919. // }
  2920. // $g = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
  2921. // $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  2922. // $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "2" and features = "'.$value['features'].'"');
  2923. // $number = $value['number'];$ftime = time()-15*24*3600;
  2924. // $warehouse = $this->warehouse->read($value['warehouse']);
  2925. // $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$u9_code,$g,count($c),$x,$t,$value['cpbz']);
  2926. // }
  2927. $classid = $this->classid->sku();
  2928. $tcall = $this->typeclass->find_all();
  2929. foreach ($tcall as $v)
  2930. {
  2931. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  2932. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  2933. }
  2934. foreach ($info_list as $value)
  2935. {
  2936. $tmp_r = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  2937. $zh = $tmp_r['zh'];
  2938. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2939. $u9_code = $tmp_r['jm'];
  2940. $cpid = '';
  2941. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"','cpid');
  2942. foreach ($c as $v)
  2943. {
  2944. if($v['cpid'] != 0)
  2945. {
  2946. $cpid .= $v['cpid'].' ';
  2947. }
  2948. }
  2949. $g = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
  2950. $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  2951. $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "2" and features = "'.$value['features'].'"');
  2952. $number = $value['number'];$ftime = time()-15*24*3600;
  2953. $warehouse = $this->warehouse->read($value['warehouse']);
  2954. $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$u9_code,$g,count($c),$x,$t,$value['cpbz']);
  2955. }
  2956. $title = "总进销存统计表";
  2957. $titlename = "<table border=1>
  2958. <tr><th colspan='10' align='center'><h3>".$title."<h3></th></tr>
  2959. <tr align='center'>
  2960. <td>位置</td>
  2961. <td>库存编码</td>
  2962. <td>产品</td>
  2963. <td>SKU</td>
  2964. <td>中文</td>
  2965. <td>u9料号</td>
  2966. <td>入库总量</td>
  2967. <td>库存数量</td>
  2968. <td>销售数量</td>
  2969. <td>退货数量</td>
  2970. <td>备注</td>
  2971. </tr>
  2972. </table>";
  2973. $filename = $title.".xls";
  2974. $tail = "";
  2975. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  2976. }
  2977. }
  2978. //入库导出
  2979. public function _excelr()
  2980. {
  2981. if(isset($_GET['excel']))
  2982. {
  2983. if($_GET['excel'] == '2'){
  2984. $category = $this->input->get('category',true);
  2985. $size = $this->input->get('size',true);
  2986. $grade = $this->input->get('grade',true);
  2987. $color = $this->input->get('color',true);
  2988. $lowe = $this->input->get('lowe',true);
  2989. $sku = $this->input->get('sku',true);
  2990. $warehouse = $this->input->get('warehouse',true);
  2991. $purchase = $this->input->get('purchase',true);
  2992. $ktime = $this->input->get('ktime',true);
  2993. $jtime = $this->input->get('jtime',true);
  2994. $ktime = strtotime($ktime);
  2995. $jtime = strtotime($jtime);
  2996. $this->db->select('sku, DATE_FORMAT(enter, "%Y-%m-%d %H:00:00") as enter_date, COUNT(*) as count');
  2997. $this->db->from('specialstock');
  2998. if($category)
  2999. {
  3000. $this->db->where('features like "%-'.$category.'-%"');
  3001. }
  3002. if($size)
  3003. {
  3004. $this->db->where('features like "%-'.$size.'-%"');
  3005. }
  3006. if($grade)
  3007. {
  3008. $this->db->where('features like "%-'.$grade.'-%"');
  3009. }
  3010. if($color)
  3011. {
  3012. $this->db->where('features like "%-'.$color.'-%"');
  3013. }
  3014. if($lowe)
  3015. {
  3016. $this->db->where('features like "%-'.$lowe.'-%"');
  3017. }
  3018. if($sku)
  3019. {
  3020. $this->db->where('sku = "'.$sku.'"');
  3021. }
  3022. if($warehouse)
  3023. {
  3024. $this->db->where('warehouse = "'.$warehouse.'"');
  3025. }
  3026. if($purchase)
  3027. {
  3028. $this->db->where('purchase = "'.$purchase.'"');
  3029. }
  3030. if($sku)
  3031. {
  3032. $this->db->where('sku = "'.$sku.'"');
  3033. }
  3034. if($ktime && $jtime)
  3035. {
  3036. $this->db->where('enter > "'.$ktime.'" and enter < "'.$jtime.'" and state != 9');
  3037. }
  3038. $this->db->group_by("sku, DATE_FORMAT(enter, '%Y-%m-%d %H:00:00')");
  3039. $this->db->order_by('sku,enter_date');
  3040. $query = $this->db->get();
  3041. $result = $query->result();
  3042. echo "<pre>";
  3043. prin_r($result);
  3044. exit;
  3045. }else{
  3046. $category = $this->input->get('category',true);
  3047. $size = $this->input->get('size',true);
  3048. $grade = $this->input->get('grade',true);
  3049. $color = $this->input->get('color',true);
  3050. $lowe = $this->input->get('lowe',true);
  3051. $sku = $this->input->get('sku',true);
  3052. $warehouse = $this->input->get('warehouse',true);
  3053. $purchase = $this->input->get('purchase',true);
  3054. $ktime = $this->input->get('ktime',true);
  3055. $jtime = $this->input->get('jtime',true);
  3056. $ktime = strtotime($ktime);
  3057. $jtime = strtotime($jtime);
  3058. $where = "1=1";$gj = "";$ck = "";
  3059. $pc = $this->input->get('pc',true);
  3060. if($pc)
  3061. {
  3062. $pc = trim($pc,'x');
  3063. $pc = explode('x',$pc);
  3064. foreach ($pc as $v)
  3065. {
  3066. $where .= " and warehouse != '".$v."'";
  3067. }
  3068. }
  3069. if($category)
  3070. {
  3071. $where .= " and features like '%-$category-%'";
  3072. }
  3073. if($size)
  3074. {
  3075. $where .= " and features like '%-$size-%'";
  3076. }
  3077. if($grade)
  3078. {
  3079. $where .= " and features like '%-$grade-%'";
  3080. }
  3081. if($color)
  3082. {
  3083. $where .= " and features like '%-$color-%'";
  3084. }
  3085. if($lowe)
  3086. {
  3087. $where .= " and features like '%-$lowe-%'";
  3088. }
  3089. if($warehouse)
  3090. {
  3091. $where .= " and warehouse = '$warehouse'";
  3092. }
  3093. if($purchase)
  3094. {
  3095. $where .= " and purchase = '$purchase'";
  3096. }
  3097. if($sku)
  3098. {
  3099. $where .= " and sku = '$sku'";
  3100. }
  3101. if($ktime && $jtime)
  3102. {
  3103. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3104. }
  3105. //数据排序
  3106. $order_str = "id desc";
  3107. if(empty($page))
  3108. {
  3109. $start = 0;
  3110. $perpage = 1;
  3111. }
  3112. else
  3113. {
  3114. $start = ($page - 1)*$perpage;
  3115. }
  3116. //取得信息列表
  3117. $info_list = $this->specialstock->find_pc($where,'enter','*',$order_str);
  3118. $list = array();
  3119. foreach ($info_list as $value)
  3120. {
  3121. $ck = $this->warehouse->read($value['warehouse']);
  3122. $warehouse = $ck['title'];
  3123. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3124. $retreatwarehouse = $tkck['title'];
  3125. $gy = $this->purchase->read($value['purchase']);
  3126. $purchase = $gy['title'];
  3127. $cpid = '';
  3128. $g = $this->specialstock->find_all($where.' and enter = "'.$value['enter'].'" '." and sku = '".$value['sku']."'",'cpid');
  3129. foreach ($g as $v)
  3130. {
  3131. if($v['cpid'] != 0)
  3132. {
  3133. $cpid .= $v['cpid'].' ';
  3134. }
  3135. }
  3136. $list[] = array('details'=>$value['details'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>count($g),'cpid'=>$cpid);
  3137. }
  3138. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3139. $titlename = "<table border=1>
  3140. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  3141. <tr align='center'>
  3142. <td>备注</td>
  3143. <td>产品</td>
  3144. <td>时间</td>
  3145. <td>数量</td>
  3146. <td>编码</td>
  3147. </tr>
  3148. </table>";
  3149. $filename = $title.".xls";
  3150. $tail = "";
  3151. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3152. }
  3153. }
  3154. }
  3155. //出库、退库导出
  3156. public function _excelct()
  3157. {
  3158. if(isset($_GET['excel']))
  3159. {
  3160. $type = $this->input->get('excel',true);
  3161. $category = $this->input->get('category',true);
  3162. $size = $this->input->get('size',true);
  3163. $grade = $this->input->get('grade',true);
  3164. $color = $this->input->get('color',true);
  3165. $lowe = $this->input->get('lowe',true);
  3166. $lacetype = $this->input->get('lacetype',true);
  3167. $details = $this->input->get('details',true);
  3168. $sku = $this->input->get('sku',true);
  3169. $warehouse = $this->input->get('warehouse',true);
  3170. $purchase = $this->input->get('purchase',true);
  3171. $state = $this->input->get('state',true);
  3172. $sid = $this->input->get('sid',true);
  3173. $ktime = $this->input->get('ktime',true);
  3174. $jtime = $this->input->get('jtime',true);
  3175. $ktime = strtotime($ktime);
  3176. $jtime = strtotime($jtime);
  3177. $where = "1=1";$gj = "";$ck = "";
  3178. $pc = $this->input->get('pc',true);
  3179. if($pc)
  3180. {
  3181. $pc = trim($pc,'x');
  3182. $pc = explode('x',$pc);
  3183. foreach ($pc as $v)
  3184. {
  3185. $where .= " and warehouse != '".$v."'";
  3186. }
  3187. }
  3188. if($category)
  3189. {
  3190. $where .= " and features like '%-$category-%'";
  3191. }
  3192. if($size)
  3193. {
  3194. $where .= " and features like '%-$size-%'";
  3195. }
  3196. if($grade)
  3197. {
  3198. $where .= " and features like '%-$grade-%'";
  3199. }
  3200. if($color)
  3201. {
  3202. $where .= " and features like '%-$color-%'";
  3203. }
  3204. if($lowe)
  3205. {
  3206. $where .= " and features like '%-$lowe-%'";
  3207. }
  3208. if($warehouse)
  3209. {
  3210. $where .= " and warehouse = '$warehouse'";
  3211. }
  3212. if($purchase)
  3213. {
  3214. $where .= " and purchase = '$purchase'";
  3215. }
  3216. if($state)
  3217. {
  3218. $where .= " and state = '$state'";
  3219. }
  3220. if($sku)
  3221. {
  3222. $where .= " and sku like '%$sku%'";
  3223. }
  3224. if($lacetype)
  3225. {
  3226. $where .= " and features like '%-$lacetype-%'";
  3227. }
  3228. if($details)
  3229. {
  3230. $where .= " and details like '%$details%'";
  3231. }
  3232. if($ktime && $jtime)
  3233. {
  3234. if($type == 1)
  3235. {
  3236. $tl = '出库';
  3237. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3238. }
  3239. else if($type == 2)
  3240. {
  3241. $tl = '退库';
  3242. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3243. }
  3244. else if($type == 3)
  3245. {
  3246. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3247. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3248. }
  3249. else if($type == 4)
  3250. {
  3251. $tl = '出库+零售';
  3252. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3253. }
  3254. else if($type == 5)
  3255. {
  3256. $tl = '零售';
  3257. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3258. }
  3259. }
  3260. if($sid)
  3261. {
  3262. $sd = "";
  3263. $s = explode(',',trim($sid,','));
  3264. foreach ($s as $value)
  3265. {
  3266. $sd .= " id = ".$value." or";
  3267. }
  3268. $sidwhere .= " and (".rtrim($sd,'or').")";
  3269. }
  3270. //数据排序
  3271. $order_str = "time desc";
  3272. if(empty($page))
  3273. {
  3274. $start = 0;
  3275. $perpage = 1;
  3276. }
  3277. else
  3278. {
  3279. $start = ($page - 1)*$perpage;
  3280. }
  3281. //取得信息列表
  3282. if($type != 3 && $type != 5)
  3283. {
  3284. if($type == 1 || $type == 4)
  3285. {
  3286. $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,outk,cpbz',$order_str);
  3287. foreach ($info_list as $key=>$value)
  3288. {
  3289. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  3290. }
  3291. }
  3292. else
  3293. {
  3294. $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,retreat,cpbz',$order_str);
  3295. foreach ($info_list as $key=>$value)
  3296. {
  3297. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  3298. }
  3299. }
  3300. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  3301. $titlename = "<table border=1>
  3302. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  3303. <tr align='center'>
  3304. <td>位置</td>
  3305. <td>产品编码</td>
  3306. <td>产品</td>
  3307. <td>标签</td>
  3308. <td>订单号</td>
  3309. <td>运单号</td>
  3310. <td>".$tl."时间(中国时间)</td>
  3311. <td>备注</td>
  3312. </tr>
  3313. </table>";
  3314. $filename = $title.".xls";
  3315. $tail = "";
  3316. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  3317. }
  3318. else if($type == 5)
  3319. {
  3320. $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,outk,cpbz',$order_str);
  3321. foreach ($info_list as $key=>$value)
  3322. {
  3323. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  3324. $warehouse = $this->warehouse->read($value['warehouse']);
  3325. $info_list[$key]['warehouse'] = $warehouse['title'];
  3326. }
  3327. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  3328. $titlename = "<table border=1>
  3329. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3330. <tr align='center'>
  3331. <td>位置</td>
  3332. <td>产品编码</td>
  3333. <td>产品</td>
  3334. <td>标签</td>
  3335. <td>".$tl."时间(中国时间)</td>
  3336. <td>备注</td>
  3337. </tr>
  3338. </table>";
  3339. $filename = $title.".xls";
  3340. $tail = "";
  3341. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  3342. }
  3343. else
  3344. {
  3345. $info_list = $this->specialstock->find_pc($where.$sidwhere,'sku,warehouse,features','*');
  3346. $list = array();
  3347. foreach ($info_list as $value)
  3348. {
  3349. $classid = $this->classid->sku();
  3350. $pm = $classid;
  3351. //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  3352. $features = explode('-',trim($value['features'],'-'));
  3353. foreach ($features as $v)
  3354. {
  3355. $typeclass = $this->typeclass->read($v);
  3356. $pm[$typeclass['classid']] = $typeclass['zh'];
  3357. //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
  3358. }
  3359. $typeclass = $this->typeclass->read($v);
  3360. //$scsku = implode("-",$scsku);
  3361. $zh = implode(" ",$pm);
  3362. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  3363. //$scsku = str_replace('- ','-',trim($scsku,'-'));
  3364. //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  3365. $cpid = '';
  3366. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"','cpid');
  3367. foreach ($c as $v)
  3368. {
  3369. if($v['cpid'] != 0)
  3370. {
  3371. $cpid .= $v['cpid'].' ';
  3372. }
  3373. }
  3374. $g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state != "9"');
  3375. $x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "1"');
  3376. $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "2"');
  3377. $number = $value['number'];$ftime = time()-15*24*3600;
  3378. $warehouse = $this->warehouse->read($value['warehouse']);
  3379. $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$g,count($c),$x,$t,$value['cpbz']);
  3380. }
  3381. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  3382. $titlename = "<table border=1>
  3383. <tr><th colspan='9' align='center'><h3>".$title."<h3></th></tr>
  3384. <tr align='center'>
  3385. <td>位置</td>
  3386. <td>库存编码</td>
  3387. <td>产品</td>
  3388. <td>SKU</td>
  3389. <td>中文</td>
  3390. <td>入库总量</td>
  3391. <td>库存数量</td>
  3392. <td>销售数量</td>
  3393. <td>退货数量</td>
  3394. <td>备注</td>
  3395. </tr>
  3396. </table>";
  3397. $filename = $title.".xls";
  3398. $tail = "";
  3399. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3400. }
  3401. }
  3402. }
  3403. //数量调整模板导出
  3404. public function _presetout()
  3405. {
  3406. if(isset($_GET['excel']))
  3407. {
  3408. $where = "1=1";
  3409. //数据排序
  3410. $order_str = "id desc";
  3411. if(empty($page))
  3412. {
  3413. $start = 0;
  3414. $perpage = 1;
  3415. }
  3416. else
  3417. {
  3418. $start = ($page - 1)*$perpage;
  3419. }
  3420. $pc = $this->input->get('pc',true);
  3421. if($pc)
  3422. {
  3423. $pc = trim($pc,'x');
  3424. $pc = explode('x',$pc);
  3425. foreach ($pc as $v)
  3426. {
  3427. $where .= " and warehouse != '".$v."'";
  3428. }
  3429. }
  3430. //取得信息列表
  3431. $info_list = $this->specialstock->find_all($where,'*');
  3432. $rows = array();$list = array();
  3433. foreach ($info_list as $key=>$value)
  3434. {
  3435. $rows[$value['number']] = $value;//所有数据sku
  3436. }
  3437. foreach ($rows as $value)
  3438. {
  3439. $warehouse = $this->warehouse->read($value['warehouse']);
  3440. $number = $value['number'];$ftime = time()-15*24*3600;
  3441. $list[] = array($value['features'],$value['sku'],'0','','0',$warehouse['title']);
  3442. }
  3443. $title = "库存模板";
  3444. $titlename = "<table border=1>
  3445. <tr align='center'>
  3446. <td>编码号</td>
  3447. <td>SKU</td>
  3448. <td>增减数量(正数或负数)</td>
  3449. <td>扣减备注</td>
  3450. <td>扣减方式:0减少库存1删除库存</td>
  3451. <td>所属仓库</td>
  3452. </tr>
  3453. </table>";
  3454. $filename = $title.".xls";
  3455. $tail = "";
  3456. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3457. }
  3458. }
  3459. //数量调整模板导入
  3460. public function _presetedit()
  3461. {
  3462. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3463. $config['upload_path'] = '.'.$dir ;
  3464. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3465. $config['allowed_types'] = 'xls|xlsx|csv';
  3466. $config['max_size'] = 10240;
  3467. $this->load->library('upload', $config);
  3468. $this->upload->initialize($config);
  3469. if ($this->upload->do_upload('userfile'))
  3470. {
  3471. $full_path = $dir.$this->upload->data('file_name');
  3472. $fileName = '.' . $full_path;
  3473. if (!file_exists($fileName))
  3474. {
  3475. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3476. }
  3477. else
  3478. {
  3479. libxml_use_internal_errors(true);
  3480. require_once "./data/excel/PHPExcel/IOFactory.php";
  3481. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3482. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3483. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3484. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3485. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3486. ++$column;//如果列数大于26行
  3487. $list = array();
  3488. for ($i = 2; $i <= $row; $i++) // 行数循环
  3489. {
  3490. $data = array();
  3491. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3492. {
  3493. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3494. }
  3495. $list[] = $data;
  3496. }
  3497. }
  3498. $i = 0;$j = 0;$ed = array();
  3499. foreach ($list as $key=>$value)
  3500. {
  3501. $time = time();
  3502. if($value['0'] == "")
  3503. {
  3504. continue;
  3505. }
  3506. $features = $value['0'];
  3507. $num = $value['2'];//调整数量
  3508. $text = $value['3'];//扣减说明
  3509. $type = $value['4'];//调整方式0扣减1删除
  3510. $d = $this->specialstock->get_features($features);
  3511. if(!$d)//如果没有这个SKU
  3512. {
  3513. $ed[] = array($title.'-库存中不存在此编码');
  3514. $j++;
  3515. continue;
  3516. }
  3517. if($num < 0)//扣减库存
  3518. {
  3519. $data = $this->specialstock->find_all('warehouse = "'.$warehouse['id'].'" and features = "'.$features.'" and zd = "" and state = 0');
  3520. if(count($data) < abs($num))
  3521. {
  3522. $ed[] = array($title.'-扣减数量大于库存剩余数量!');
  3523. $j++;
  3524. continue;
  3525. }
  3526. if($type == 0)//如果扣减方式为 扣减库存
  3527. {
  3528. for($i=0;$i<abs($num);$i++)
  3529. {
  3530. $this->specialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$data[$i]['id']);
  3531. }
  3532. }
  3533. else
  3534. {
  3535. for($i=0;$i<abs($num);$i++)
  3536. {
  3537. $this->specialstock->remove($data[$i]['id']);
  3538. }
  3539. }
  3540. }
  3541. else if($num > 0)//增加库存
  3542. {
  3543. $post['shop'] = $d['shop'];
  3544. $post['purchase'] = $d['purchase'];
  3545. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  3546. $post['state'] = 0;
  3547. $post['title'] = $d['title'];
  3548. $post['number'] = $d['number'];
  3549. $post['features'] = $d['features'];
  3550. $post['enter'] = $time;
  3551. $post['time'] = $time;//操作时间
  3552. for($i=0;$i<$num;$i++)
  3553. {
  3554. $post['label'] = time().rand(100,999).$i;
  3555. $this->specialstock->insert($post);
  3556. }
  3557. }
  3558. sleep(1);//防止入库时间一样,需要延迟1秒
  3559. }
  3560. if($j > 0)
  3561. {
  3562. $tt = date('Ymd',time());
  3563. $title = '库存导入错误信息-'.$tt;
  3564. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3565. $tail = "\n";
  3566. $filename = $title.".xls";
  3567. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3568. $dir = '/data/excel/'.$time.'/';
  3569. $file_name = 'error_'.$time.rand(1000,9999);
  3570. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3571. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3572. fwrite($myfile,$ecl);
  3573. fclose($myfile);
  3574. $error = $dir.$file_name.'.xls';
  3575. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  3576. }
  3577. else
  3578. {
  3579. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  3580. }
  3581. }
  3582. }
  3583. //笛卡儿积
  3584. function cp($ps,$sets,$list)
  3585. {
  3586. $result = array();$j=0;
  3587. for($i=0,$count=count($sets); $i<$count-1; $i++)
  3588. {
  3589. if($i==0)
  3590. {
  3591. $result = $sets[$i];
  3592. }
  3593. $tmp = array();
  3594. foreach($result as $res)
  3595. {
  3596. foreach($sets[$i+1] as $set)
  3597. {
  3598. $tmp[] = $res.','.$set;
  3599. }
  3600. }
  3601. $result = $tmp;
  3602. }
  3603. $this->db->trans_begin();
  3604. foreach ($result as $v)
  3605. {
  3606. $post = array();$title = "";$num="";
  3607. $data = explode(',',$v);
  3608. for($i=0;$i<count($list); $i++)
  3609. {
  3610. $post[$list[$i]] = $data[$i];
  3611. $typeclass = $this->typeclass->read($data[$i]);
  3612. $title = $title.$typeclass['title']." ";
  3613. if($data[$i] != 0)
  3614. {
  3615. $num .=$data[$i];//所有数据ID拼接
  3616. }
  3617. }
  3618. foreach ($ps as $kp=>$vp)
  3619. {
  3620. $post[$kp] = $vp;
  3621. }
  3622. $post['number'] = $num;
  3623. $info_list = $this->specialstock->get_number($num);//查询specialstock是否存在此拼接的数据ID
  3624. if($info_list)
  3625. {
  3626. $j++;
  3627. }
  3628. else
  3629. {
  3630. $skunum = $this->specialstock->find_count();
  3631. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  3632. $post['title'] = rtrim($title,' ');
  3633. $this->specialstock->insert($post);
  3634. }
  3635. }
  3636. if ($this->db->trans_status() === FALSE)
  3637. {
  3638. $this->db->trans_commit();
  3639. return NULL;
  3640. }
  3641. else
  3642. {
  3643. $this->db->trans_commit();
  3644. return $j;
  3645. }
  3646. }
  3647. public function _kj($arg_array)
  3648. {
  3649. if(isset($_POST['number']))
  3650. {
  3651. $time = time();
  3652. $number = $this->input->post('number',true);
  3653. $num = $this->input->post('num',true);
  3654. $text = $this->input->post('text',true);
  3655. $order = $this->specialstock->find_all("number = '$number' and zd = '' and state = 0");
  3656. if($num > count($order))
  3657. {
  3658. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  3659. }
  3660. else
  3661. {
  3662. for($i=0;$i<$num;$i++)
  3663. {
  3664. $this->specialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$order[$i]['id']);
  3665. }
  3666. }
  3667. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  3668. }
  3669. $uid = $this->specialstock->read($arg_array[0]);
  3670. $uid['num'] = $this->specialstock->find_count('number = "'.$uid['number']. '" and zd = "" and state = 0');
  3671. $this->data['data'] = $uid ;
  3672. $this->_Template('specialstock_kj',$this->data);
  3673. }
  3674. public function _summary($arg_array)
  3675. {
  3676. if(isset($_GET['excel']))
  3677. {
  3678. $ktime = $this->input->get('ktime',true);
  3679. $jtime = $this->input->get('jtime',true);
  3680. $ktime = strtotime($ktime);
  3681. $jtime = strtotime($jtime);
  3682. $where = "1=1";
  3683. if($ktime && $jtime)
  3684. {
  3685. $where .= " and outk > '$ktime' and outk < '$jtime'";
  3686. }
  3687. //数据排序
  3688. $order_str = "time desc";
  3689. if(empty($page))
  3690. {
  3691. $start = 0;
  3692. $perpage = 1;
  3693. }
  3694. else
  3695. {
  3696. $start = ($page - 1)*$perpage;
  3697. }
  3698. $pc = $this->input->get('pc',true);
  3699. if($pc)
  3700. {
  3701. $pc = trim($pc,'x');
  3702. $pc = explode('x',$pc);
  3703. foreach ($pc as $v)
  3704. {
  3705. $where .= " and warehouse != '".$v."'";
  3706. }
  3707. }
  3708. //取得信息列表
  3709. $info_list = $this->specialstock->find_pc($where,'number','*');
  3710. foreach ($info_list as $value)
  3711. {
  3712. $xcpid = '';$scpid = '';
  3713. $x = $this->specialstock->find_all($where.' and number = "'.$value['number'].'"');
  3714. foreach ($x as $v)
  3715. {
  3716. if($v['cpid'] != 0)
  3717. {
  3718. $xcpid .= $v['cpid'].' ';
  3719. }
  3720. }
  3721. $s = $this->specialstock->find_all('state = 0 and number = "'.$value['number'].'"');
  3722. foreach ($s as $v)
  3723. {
  3724. if($v['cpid'] != 0)
  3725. {
  3726. $scpid .= $v['cpid'].' ';
  3727. }
  3728. }
  3729. $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']));
  3730. }
  3731. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  3732. $titlename = "<table border=1>
  3733. <tr align='center'>
  3734. <td>仓库备注</td>
  3735. <td>产品名</td>
  3736. <td>总剩余库存</td>
  3737. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  3738. <td>剩余产品编码</td>
  3739. <td>销售产品编码</td>
  3740. <td>出库时间</td>
  3741. </tr>
  3742. </table>";
  3743. $filename = $title.".xls";
  3744. $tail = "";
  3745. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3746. }
  3747. }
  3748. //usps发货清单
  3749. public function _manifest()
  3750. {
  3751. if(isset($_POST['manifest']))
  3752. {
  3753. $wltext = $this->input->post('wltext',true);
  3754. $time = time()-16*3600;
  3755. $ptime = strtotime(date('Y-m-d',$time));
  3756. $waybill = array();
  3757. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  3758. foreach ($fullorder as $v)
  3759. {
  3760. $waybill[$v['waybill']] = $v['waybill'];
  3761. }
  3762. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  3763. foreach ($fullordersmt as $v)
  3764. {
  3765. $waybill[$v['waybill']] = $v['waybill'];
  3766. }
  3767. $wltext = explode(';',$wltext);
  3768. foreach ($wltext as $v)
  3769. {
  3770. if(isset($waybill[$v]))
  3771. {
  3772. unset($waybill[$v]);
  3773. }
  3774. }
  3775. $data = $this->usps->get_manifest($waybill);
  3776. if(isset($data['Description']))
  3777. {
  3778. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  3779. }
  3780. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  3781. {
  3782. $bctime = date('Ymd',time());
  3783. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  3784. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  3785. }
  3786. else
  3787. {
  3788. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  3789. }
  3790. }
  3791. }
  3792. public function _pdf($pdf,$title,$bctime)
  3793. {
  3794. $pdf_path = './data/pdf/'.$bctime.'/';
  3795. $file_base64 = $pdf;
  3796. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  3797. $file_base64 = base64_decode($file_base64);
  3798. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  3799. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  3800. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  3801. }
  3802. /**
  3803. *
  3804. *
  3805. *
  3806. 进销存占单异常索引
  3807. *
  3808. *
  3809. *
  3810. **/
  3811. public function _abnormal()
  3812. {
  3813. $post = $this->input->post(NULL, TRUE);
  3814. if(isset($post['page']))
  3815. {
  3816. $page = $this->input->post('page',true);
  3817. $perpage = $this->input->post('perpage',true);
  3818. $sku = $this->input->post('sku',true);
  3819. $where = "1=1";
  3820. //数据排序
  3821. $order_str = "id desc";
  3822. if(empty($page))
  3823. {
  3824. $start = 0;
  3825. $perpage = 1;
  3826. }
  3827. else
  3828. {
  3829. $start = ($page - 1)*$perpage;
  3830. }
  3831. //取得信息列表
  3832. $info_list = $this->specialstock->find_all($where,'*');
  3833. $rows = array();$list = array();
  3834. foreach ($info_list as $key=>$value)
  3835. {
  3836. $rows[$value['sku']] = $value;//所有数据sku
  3837. }
  3838. foreach ($rows as $value)
  3839. {
  3840. $warehouse = $this->warehouse->read($value['warehouse']);
  3841. $c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  3842. $number = $value['number'];$ftime = time()-15*24*3600;
  3843. if($value['shop'] != '')
  3844. {
  3845. $shop = $value['shop'];
  3846. $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');
  3847. $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');
  3848. $order = array_merge($orderdlz,$ordersmt);
  3849. $od = 0;$a = '';$orid = '';
  3850. foreach ($order as $v)
  3851. {
  3852. $or = explode('|',ltrim($v['specialstock'],'|'));
  3853. for($i=0;$i<count($or);$i++)
  3854. {
  3855. $orod = explode('-',$or[$i]);
  3856. if($orod[0] == $number)
  3857. {
  3858. $od += $orod[1];
  3859. }
  3860. }
  3861. $orid .= $v['number'].'-';
  3862. }
  3863. }
  3864. else
  3865. {
  3866. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  3867. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  3868. $order = array_merge($orderdlz,$ordersmt);
  3869. $od = 0;$a = '';$orid = '';$qt = array();
  3870. foreach ($order as $v)
  3871. {
  3872. $or = explode('|',ltrim($v['specialstock'],'|'));
  3873. for($i=0;$i<count($or);$i++)
  3874. {
  3875. $orod = explode('-',$or[$i]);
  3876. if($orod[0] == $number)
  3877. {
  3878. $czzs = $this->specialstock->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  3879. if($czzs > 0)
  3880. {
  3881. if(isset($qt[$v['shop']]))
  3882. {
  3883. if($qt[$v['shop']] < $orod[1])
  3884. {
  3885. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  3886. $orid .= $v['number'].'+数量'.$orod[1].'-';
  3887. }
  3888. else
  3889. {
  3890. $qt[$v['shop']] -= $orod[1];
  3891. }
  3892. }
  3893. else
  3894. {
  3895. $qt[$v['shop']] = $czzs;
  3896. }
  3897. }
  3898. else
  3899. {
  3900. $od += $orod[1];
  3901. $orid .= $v['number'].'+数量'.$orod[1].'-';
  3902. }
  3903. }
  3904. }
  3905. }
  3906. }
  3907. $z = $od.'('.$orid.')';//查看订单号
  3908. //$z = $od;
  3909. if($od > $c)
  3910. {
  3911. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  3912. }
  3913. }
  3914. $listdata = array_slice($list,$start,$perpage);
  3915. $total = count($list);
  3916. $pagenum = ceil($total/$perpage);
  3917. $over = $total-($start+$perpage);
  3918. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  3919. echo json_encode($rows);exit;
  3920. }
  3921. $this->_Template('specialstock_abnormal',$this->data);
  3922. }
  3923. /**
  3924. *
  3925. *
  3926. *
  3927. 进销存占单异常索引
  3928. *
  3929. *
  3930. *
  3931. **/
  3932. public function _error()
  3933. {
  3934. $post = $this->input->post(NULL, TRUE);
  3935. if(isset($post['page']))
  3936. {
  3937. $page = $this->input->post('page',true);
  3938. $perpage = $this->input->post('perpage',true);
  3939. $sku = $this->input->post('sku',true);
  3940. $warehouse = $this->input->post('warehouse',true);
  3941. $where = "1=1";
  3942. if($sku)
  3943. {
  3944. $where .= " and sku = '$sku'";
  3945. }
  3946. if($warehouse)
  3947. {
  3948. $where .= " and warehouse = '$warehouse'";
  3949. }
  3950. //数据排序
  3951. $order_str = "id desc";
  3952. if(empty($page))
  3953. {
  3954. $start = 0;
  3955. $perpage = 1;
  3956. }
  3957. else
  3958. {
  3959. $start = ($page - 1)*$perpage;
  3960. }
  3961. //取得信息列表
  3962. $info_list = $this->specialstock->find_all($where,'*');
  3963. $rows = array();$list = array();
  3964. foreach ($info_list as $key=>$value)
  3965. {
  3966. if($value['sku'] != '')
  3967. {
  3968. $rows[$value['sku']] = $value;//所有数据sku
  3969. }
  3970. }
  3971. foreach ($rows as $value)
  3972. {
  3973. $warehouse = $this->warehouse->read($value['warehouse']);
  3974. $c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  3975. $number = $value['number'];$ftime = time()-15*24*3600;
  3976. if($c < 1)
  3977. {
  3978. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  3979. }
  3980. }
  3981. $listdata = array_slice($list,$start,$perpage);
  3982. $total = count($list);
  3983. $pagenum = ceil($total/$perpage);
  3984. $over = $total-($start+$perpage);
  3985. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  3986. echo json_encode($rows);exit;
  3987. }
  3988. if(isset($post['s']))
  3989. {
  3990. $id_arr = $this->input->post('s');
  3991. $id_arr = explode(',',$id_arr);
  3992. if(!$id_arr)
  3993. {
  3994. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3995. }
  3996. //循环删除记录
  3997. foreach ($id_arr as $v)
  3998. {
  3999. $dd = $this->specialstock->read($v);
  4000. $deldd = $this->specialstock->find_all("sku = '".$dd['sku']."'");
  4001. foreach ($deldd as $vv)
  4002. {
  4003. $this->specialstock->remove($vv['id']);
  4004. }
  4005. }
  4006. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  4007. }
  4008. $this->_Template('specialstock_error',$this->data);
  4009. }
  4010. /**
  4011. *
  4012. *
  4013. * 占单
  4014. *
  4015. *
  4016. **/
  4017. public function _kcyz()
  4018. {
  4019. $post = $this->input->post(NULL, TRUE);
  4020. if(isset($post['warehouse']))
  4021. {
  4022. $warehouse = $this->input->post('warehouse',true);
  4023. $specialstock = $this->input->post('specialstock',true);
  4024. $id = $this->input->post('id',true);
  4025. $shop = $this->input->post('shop',true);
  4026. $number = $this->input->post('number',true);
  4027. if(!$specialstock || $specialstock == '|')
  4028. {
  4029. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  4030. }
  4031. $pp = explode('|',trim($specialstock,'|'));
  4032. $x = 0;$save = array();
  4033. foreach ($pp as $va)
  4034. {
  4035. $num = explode('-',$va);
  4036. if($number)
  4037. {
  4038. $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 = '')");//通用
  4039. $shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  4040. }
  4041. else
  4042. {
  4043. $specialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  4044. $shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  4045. }
  4046. $x++;
  4047. if(count($specialstock)+count($shopspecialstock) < $num[1])
  4048. {
  4049. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  4050. }
  4051. }
  4052. if(isset($save[0]))
  4053. {
  4054. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  4055. }
  4056. else
  4057. {
  4058. echo json_encode(array('success'=>true));exit;
  4059. }
  4060. }
  4061. }
  4062. public function _hwwz()//货物位置
  4063. {
  4064. if(isset($_GET['id']))
  4065. {
  4066. $id = $this->input->get('id',true);
  4067. $sku = $this->input->get('sku',true);
  4068. $bs = $this->input->get('bs',true);
  4069. $number = $this->input->get('number',true);
  4070. $warehouse = $this->input->get('warehouse',true);
  4071. $purchase = $this->input->get('purchase',true);
  4072. $orderinfo = $this->input->get('orderinfo',true);
  4073. $waybill = $this->input->get('waybill',true);
  4074. $category = $this->input->get('category',true);
  4075. $size = $this->input->get('size',true);
  4076. $grade = $this->input->get('grade',true);
  4077. $color = $this->input->get('color',true);
  4078. $lowe = $this->input->get('lowe',true);
  4079. $state = $this->input->get('state',true);
  4080. $label = $this->input->get('label',true);
  4081. $px = $this->input->get('px',true);
  4082. $details = $this->input->get('details',true);
  4083. $timetk = $this->input->get('timetkk',true);
  4084. $timetj = $this->input->get('timetjj',true);
  4085. $timetk = strtotime($timetk);
  4086. $timetj = strtotime($timetj);
  4087. $where = "state='0'";
  4088. //数据排序
  4089. $order_str = $px." desc";
  4090. if(empty($page))
  4091. {
  4092. $start = 0;
  4093. $perpage = 1;
  4094. }
  4095. else
  4096. {
  4097. $start = ($page - 1)*$perpage;
  4098. }
  4099. $category = $this->input->get('category',true);
  4100. $warehouse = $this->input->get('warehouse',true);
  4101. if($category)
  4102. {
  4103. $where .= " and features like '%-$category-%'";
  4104. }
  4105. if($warehouse)
  4106. {
  4107. $where .= " and warehouse = '$warehouse'";
  4108. }
  4109. if($details)
  4110. {
  4111. $where .= " and details = '$details'";
  4112. }
  4113. if($id != '')
  4114. {
  4115. $sid = "";
  4116. $usersp = explode(',',trim($id,','));
  4117. foreach ($usersp as $value)
  4118. {
  4119. $sid .= " id = ".$value." or";
  4120. }
  4121. $info_list = $this->specialstock->find_all($where." and (".rtrim($sid,'or').")",'*','details desc');
  4122. }
  4123. else
  4124. {
  4125. $info_list = $this->specialstock->find_all($where,'*','details desc');
  4126. }
  4127. $rows = array();$list = array();
  4128. foreach ($info_list as $key=>$value)
  4129. {
  4130. $rows[$value['sku'].$value['warehouse'].$value['details']] = $value;//所有数据sku
  4131. }
  4132. foreach ($rows as $value)
  4133. {
  4134. $classid = $this->classid->sku();
  4135. $pm = $classid;
  4136. //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  4137. $features = explode('-',trim($value['features'],'-'));
  4138. foreach ($features as $v)
  4139. {
  4140. $typeclass = $this->typeclass->read($v);
  4141. $pm[$typeclass['classid']] = $typeclass['zh'];
  4142. //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
  4143. }
  4144. $typeclass = $this->typeclass->read($v);
  4145. //$scsku = implode("-",$scsku);
  4146. $zh = implode(" ",$pm);
  4147. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  4148. //$scsku = str_replace('- ','-',trim($scsku,'-'));
  4149. //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  4150. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"');
  4151. $number = $value['number'];$ftime = time()-15*24*3600;
  4152. $warehouse = $this->warehouse->read($value['warehouse']);
  4153. $list[] = array($value['id'],$value['details'],$zh,$c);
  4154. }
  4155. $title = "库存表";
  4156. $titlename = "";
  4157. $filename = $title.".xls";
  4158. $tail = "";
  4159. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4160. }
  4161. }
  4162. public function _order()
  4163. {
  4164. $post = $this->input->post(NULL, TRUE);
  4165. if(isset($arg_array[0]))
  4166. {
  4167. if($arg_array[0] == 'del')
  4168. {
  4169. $s = $this->input->post('s',true);
  4170. $del = $this->_del($s);
  4171. echo $del;exit;
  4172. }
  4173. }
  4174. if(isset($post['page']))
  4175. {
  4176. $page = $this->input->post('page',true);
  4177. $perpage = $this->input->post('perpage',true);
  4178. $category = $this->input->post('category',true);
  4179. $size = $this->input->post('size',true);
  4180. $grade = $this->input->post('grade',true);
  4181. $color = $this->input->post('color',true);
  4182. $lowe = $this->input->post('lowe',true);
  4183. $sku = $this->input->post('sku',true);
  4184. $details = $this->input->post('details',true);
  4185. $warehouse = $this->input->post('warehouse',true);
  4186. $purchase = $this->input->post('purchase',true);
  4187. $lacetype = $this->input->post('lacetype',true);
  4188. $state = $this->input->post('state',true);
  4189. $ktime = $this->input->post('ktime',true);
  4190. $jtime = $this->input->post('jtime',true);
  4191. $ktime = strtotime($ktime);
  4192. $jtime = strtotime($jtime);
  4193. $where = "zd =''";$gj = "";$ck = "";
  4194. if($category)
  4195. {
  4196. $where .= " and features like '%-$category-%'";
  4197. }
  4198. if($size)
  4199. {
  4200. $where .= " and features like '%-$size-%'";
  4201. }
  4202. if($grade)
  4203. {
  4204. $where .= " and features like '%-$grade-%'";
  4205. }
  4206. if($color)
  4207. {
  4208. $where .= " and features like '%-$color-%'";
  4209. }
  4210. if($lowe)
  4211. {
  4212. $where .= " and features like '%-$lowe-%'";
  4213. }
  4214. if($lacetype)
  4215. {
  4216. $where .= " and features like '%-$lacetype-%'";
  4217. }
  4218. if($warehouse)
  4219. {
  4220. $where .= " and warehouse = '$warehouse'";
  4221. }
  4222. if($purchase)
  4223. {
  4224. $where .= " and purchase = '$purchase'";
  4225. }
  4226. if($state)
  4227. {
  4228. $where .= " and state = '$state'";
  4229. }
  4230. if($sku)
  4231. {
  4232. $where .= " and sku like '%$sku%'";
  4233. }
  4234. if($details)
  4235. {
  4236. $where .= " and details like '%$details%'";
  4237. }
  4238. if($ktime && $jtime)
  4239. {
  4240. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4241. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4242. }
  4243. //数据排序
  4244. $order_str = "id desc";
  4245. if(empty($page))
  4246. {
  4247. $start = 0;
  4248. $perpage = 1;
  4249. }
  4250. else
  4251. {
  4252. $start = ($page - 1)*$perpage;
  4253. }
  4254. //取得信息列表
  4255. $info_list = $this->specialstock->find_all($where,'*');
  4256. $rows = array();$list = array();
  4257. foreach ($info_list as $key=>$value)
  4258. {
  4259. $rows[$value['number'].$value['warehouse']] = $value;//所有数据sku
  4260. }
  4261. $rowsdq = array_slice($rows,$start,$perpage);
  4262. $inch = '';$zh = '';
  4263. $classid = $this->classid->sku();
  4264. $pm = $classid;
  4265. foreach ($rowsdq as $value)
  4266. {
  4267. $features = '-';
  4268. $td = explode('-',trim($value['features'],'-'));
  4269. foreach ($td as $va)
  4270. {
  4271. $s = $this->typeclass->read($va);
  4272. if($s['classid'] == '14')
  4273. {
  4274. $c = $va;
  4275. $inch = $s['spare'];
  4276. if(isset($pm[$s['classid']]))
  4277. {
  4278. $pm[$s['classid']] = $s['zh'];
  4279. }
  4280. }
  4281. else
  4282. {
  4283. $features .= $va.'-';
  4284. if(isset($pm[$s['classid']]))
  4285. {
  4286. $pm[$s['classid']] = $s['zh'];
  4287. }
  4288. }
  4289. }
  4290. $features = $c.','.$features;
  4291. $warehouse = $this->warehouse->read($value['warehouse']);
  4292. $cpid = ($value['cpid']>0)?' - 编码:'.$value['cpid']:'';
  4293. $nr = implode(" ",$pm);
  4294. $nr = preg_replace(array('/(\s+)/','/分\s/u'),array(' ','分'),$nr);
  4295. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  4296. $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>");
  4297. }
  4298. $total = count($rows);
  4299. $pagenum = ceil($total/$perpage);
  4300. $over = $total-($start+$perpage);
  4301. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  4302. echo json_encode($rows);exit;
  4303. }
  4304. $this->_Template('specialstock_order',$this->data);
  4305. }
  4306. public function _0kcdel($id_arr)
  4307. {
  4308. if($id_arr)
  4309. {
  4310. $id_arr = explode(',',$id_arr);
  4311. $j = count($id_arr);
  4312. $i = 0;
  4313. //循环删除记录
  4314. foreach ($id_arr as $value)
  4315. {
  4316. $data = $this->specialstock->read($value);
  4317. $z = $this->specialstock->find_count('sku = "'.$data['sku'].'" and zd = "" and state = 0 and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
  4318. if($z < 1)
  4319. {
  4320. $z = $this->specialstock->find_all('sku = "'.$data['sku'].'" and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
  4321. foreach ($z as $v)
  4322. {
  4323. $this->specialstock->remove($v['id']);
  4324. }
  4325. $i++;
  4326. }
  4327. }
  4328. if($i != $j && $i != 0)
  4329. {
  4330. return json_encode(array('del'=>$id_arr,'msg'=>'有非0库存数据,0库存删除成功!','success'=>true));
  4331. }
  4332. else if($i != $j && $i == 0)
  4333. {
  4334. return json_encode(array('del'=>$id_arr,'msg'=>'库存非0不允许删除!','success'=>false));
  4335. }
  4336. else
  4337. {
  4338. return json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  4339. }
  4340. }
  4341. else
  4342. {
  4343. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4344. }
  4345. }
  4346. }