Specialstock.php 142 KB

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