Specialstock.php 142 KB

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