Specialstock.php 139 KB

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