Specialstock.php 142 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331
  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. foreach($list as $k=>$v)
  1579. {
  1580. if($v != 0)
  1581. {
  1582. $num .=$v;
  1583. $features .=$v.'-';
  1584. $post[$k] = $v;
  1585. $typeclass = $this->typeclass->read($v);
  1586. if($k != 'size')
  1587. {
  1588. $title .= $typeclass['title']." ";
  1589. }
  1590. }
  1591. }
  1592. $typeclass = $this->typeclass->read($list['size']);
  1593. $title .= $typeclass['title'];
  1594. $time = time();
  1595. $post['title'] = rtrim($title,' ');
  1596. $post['number'] = $num;
  1597. $post['features'] = '-'.$features;
  1598. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  1599. $featurespp = explode('-',trim($featurespp,'-'));
  1600. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  1601. $post['enter'] = $time;
  1602. $post['time'] = $time;//操作时间
  1603. for($i=0;$i<$order;$i++)
  1604. {
  1605. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1606. $this->specialstock->insert($post);
  1607. }
  1608. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  1609. }
  1610. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1611. $this->data['wlshop'] = $wlshop;
  1612. $this->_Template('specialstock_enteradd',$this->data);
  1613. }
  1614. //修改产品
  1615. public function _enteredit($arg_array)
  1616. {
  1617. $dt = 0;
  1618. if(isset($_SESSION['api']))
  1619. {
  1620. $user = $this->user->get_api($_SESSION['api']);
  1621. $usp = $user;
  1622. $fgshop = "";$sid = "";
  1623. $user = explode('|',trim($user['shop'],'|'));
  1624. foreach ($user as $value)
  1625. {
  1626. $fgshop .= " shop = ".$value." or";
  1627. $sid .= " id = ".$value." or";
  1628. }
  1629. }
  1630. $post = $this->input->post(NULL, TRUE);
  1631. if(isset($post['details']))
  1632. {
  1633. $list = array();$num = "";$title = "";$features = "";$state=0;//正常入库
  1634. $id = $this->input->post('id',true);
  1635. $order = $this->input->post('order',true);
  1636. $post['details'] = $this->input->post('details',true);
  1637. $post['sku'] = $this->input->post('sku',true);
  1638. $category = $this->input->post('category',true);
  1639. $list['category'] = $category;
  1640. $list['hairtype'] = $this->input->post('hairtype',true);
  1641. $list['grade'] = $this->input->post('grade',true);
  1642. $size = $this->input->post('size',true);
  1643. $list['size'] = rtrim($size,',');
  1644. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1645. $list['extension'] = $this->input->post('extension',true);
  1646. if($category == 1297)
  1647. {
  1648. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1649. }
  1650. if($category == 1702)
  1651. {
  1652. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1653. $list['syother'] = $this->input->post('syother',true);
  1654. }
  1655. if($category == 133)
  1656. {
  1657. $list['fittype'] = $this->input->post('fittype',true);
  1658. $list['acother'] = $this->input->post('acother',true);
  1659. }
  1660. $list['color'] = $this->input->post('color',true);
  1661. $list['lowe'] = $this->input->post('lowe',true);
  1662. $post['warehouse'] = $this->input->post('warehouse',true);
  1663. if($category == 127)
  1664. {
  1665. $list['type'] = $this->input->post('type',true);
  1666. $list['headroad'] = $this->input->post('headroad',true);
  1667. $list['density'] = $this->input->post('density',true);
  1668. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1669. {
  1670. $list['lacesize'] = $this->input->post('lacesize',true);
  1671. }
  1672. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1673. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1674. }
  1675. if($category == 128)
  1676. {
  1677. $list['lacetype'] = $this->input->post('lacetype',true);
  1678. $list['haircap'] = $this->input->post('haircap',true);
  1679. $list['density'] = $this->input->post('density',true);
  1680. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1681. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1682. $list['wigother'] = $this->input->post('wigother',true);
  1683. $list['wigother1'] = $this->input->post('wigother1',true);
  1684. $list['wigother2'] = $this->input->post('wigother2',true);
  1685. }
  1686. if($category == 129)
  1687. {
  1688. $list['wide'] = $this->input->post('wide',true);
  1689. }
  1690. if($category == 131)
  1691. {
  1692. $list['gifttype'] = $this->input->post('gifttype',true);
  1693. $list['giftother'] = $this->input->post('giftother',true);
  1694. }
  1695. if($category == 134)
  1696. {
  1697. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1698. }
  1699. if($category == 1297)
  1700. {
  1701. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1702. $list['sywigother'] = $this->input->post('sywigother',true);
  1703. }
  1704. if($category == 130 || $category == 133 || $category == 1702)
  1705. {
  1706. $list['items'] = $this->input->post('items',true);
  1707. $list['weight'] = $this->input->post('weight',true);
  1708. }
  1709. else if($category == 1702)
  1710. {
  1711. $list['syhairther'] = $this->input->post('syhairther',true);
  1712. }
  1713. foreach($list as $k=>$v)
  1714. {
  1715. if($v != 0)
  1716. {
  1717. $num .=$v;
  1718. $features .=$v.'-';
  1719. $typeclass = $this->typeclass->read($v);
  1720. if($k != 'size')
  1721. {
  1722. $title .= $typeclass['title']." ";
  1723. }
  1724. }
  1725. }
  1726. $typeclass = $this->typeclass->read($list['size']);
  1727. $title .= $typeclass['title'];
  1728. $time = time();
  1729. $post['title'] = rtrim($title,' ');
  1730. $post['number'] = $num;
  1731. $post['features'] = '-'.$features;
  1732. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  1733. $featurespp = explode('-',trim($featurespp,'-'));
  1734. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  1735. $post['time'] = $time;//操作时间
  1736. $uid = $this->specialstock->read($id);
  1737. $datanum = $this->specialstock->find_count("state = 0 and number = '".$uid['number']."' and zd != ''");
  1738. if($datanum > 0)
  1739. {
  1740. echo json_encode(array('msg'=>'此库存有占单,请解除占单后再修改!','success'=>false));exit;
  1741. }
  1742. $data = $this->specialstock->find_all("number = '".$uid['number']."' and enter = '".$uid['enter']."'");// and enter = '".$uid['enter']."'
  1743. foreach ($data as $v)
  1744. {
  1745. $post['id'] = $v['id'];
  1746. $this->specialstock->save($post,$v['id']);
  1747. }
  1748. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  1749. }
  1750. $uid = $this->specialstock->read($arg_array[0]);
  1751. $uid['order'] = $this->specialstock->find_count('enter = '.$uid['enter']);
  1752. $this->data['enter'] = $uid ;
  1753. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1754. $this->data['wlshop'] = $wlshop;
  1755. $whlabelwz = $this->whlabelwz->find_all();
  1756. $this->data['whlabelwz'] = $whlabelwz;
  1757. $this->_Template('specialstock_enteredit',$this->data);
  1758. }
  1759. //入库浏览
  1760. public function _enter()
  1761. {
  1762. $post = $this->input->post(NULL, TRUE);
  1763. if(isset($post['s']))
  1764. {
  1765. $id_arr = $this->input->post('s');
  1766. $id_arr = explode(',',$id_arr);
  1767. if(!$id_arr)
  1768. {
  1769. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1770. }
  1771. //循环删除记录
  1772. foreach ($id_arr as $v)
  1773. {
  1774. $sid = $this->specialstock->read($v);
  1775. $info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
  1776. foreach ($info_list as $va)
  1777. {
  1778. $this->specialstock->remove($va['id']);
  1779. }
  1780. }
  1781. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  1782. }
  1783. if(isset($post['page']))
  1784. {
  1785. $page = $this->input->post('page',true);
  1786. $perpage = $this->input->post('perpage',true);
  1787. $category = $this->input->post('category',true);
  1788. $size = $this->input->post('size',true);
  1789. $grade = $this->input->post('grade',true);
  1790. $color = $this->input->post('color',true);
  1791. $details = $this->input->post('details',true);
  1792. $sku = $this->input->post('sku',true);
  1793. $warehouse = '';//12
  1794. $ktime = $this->input->post('ktime',true);
  1795. $jtime = $this->input->post('jtime',true);
  1796. $ktime = strtotime($ktime);
  1797. $jtime = strtotime($jtime);
  1798. $where = "1=1";$gj = "";$ck = "";
  1799. if($category)
  1800. {
  1801. $where .= " and features like '%-$category-%'";
  1802. }
  1803. if($size)
  1804. {
  1805. $where .= " and features like '%-$size-%'";
  1806. }
  1807. if($grade)
  1808. {
  1809. $where .= " and features like '%-$grade-%'";
  1810. }
  1811. if($color)
  1812. {
  1813. $where .= " and features like '%-$color-%'";
  1814. }
  1815. if($details)
  1816. {
  1817. $where .= " and details like '%$details%'";
  1818. }
  1819. if($sku)
  1820. {
  1821. $where .= " and sku like '%$sku%'";
  1822. }
  1823. if($warehouse)
  1824. {
  1825. $where .= " and warehouse = '$warehouse'";
  1826. }
  1827. if($ktime && $jtime)
  1828. {
  1829. $where .= " and enter > '$ktime' and enter < '$jtime'";
  1830. }
  1831. //数据排序
  1832. $order_str = "enter desc";
  1833. if(empty($page))
  1834. {
  1835. $start = 0;
  1836. $perpage = 1;
  1837. }
  1838. else
  1839. {
  1840. $start = ($page - 1)*$perpage;
  1841. }
  1842. //取得信息列表
  1843. $info_list = $this->specialstock->find_all($where,'*',$order_str);
  1844. $rows = array();$list = array();
  1845. foreach ($info_list as $key=>$value)
  1846. {
  1847. $rows[$value['enter'].$value['number']] = $value;//所有数据sku
  1848. }
  1849. foreach ($rows as $value)
  1850. {
  1851. $g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9');
  1852. $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);
  1853. }
  1854. $total = count($list);
  1855. $pagenum = ceil($total/$perpage);
  1856. $over = $total-($start+$perpage);
  1857. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  1858. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list),'abc'=>($where));
  1859. echo json_encode($rows);exit;
  1860. }
  1861. $this->_Template('specialstock_enter',$this->data);
  1862. }
  1863. //入库浏览
  1864. public function _xhcenter()
  1865. {
  1866. $post = $this->input->post(NULL, TRUE);
  1867. if(isset($post['s']))
  1868. {
  1869. $id_arr = $this->input->post('s');
  1870. $id_arr = explode(',',$id_arr);
  1871. if(!$id_arr)
  1872. {
  1873. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1874. }
  1875. //循环删除记录
  1876. foreach ($id_arr as $v)
  1877. {
  1878. $sid = $this->specialstock->read($v);
  1879. $info_list = $this->specialstock->find_all('enter ='.$sid['enter']);
  1880. foreach ($info_list as $va)
  1881. {
  1882. $this->specialstock->remove($va['id']);
  1883. }
  1884. }
  1885. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  1886. }
  1887. if(isset($post['page']))
  1888. {
  1889. $page = $this->input->post('page',true);
  1890. $perpage = $this->input->post('perpage',true);
  1891. $category = $this->input->post('category',true);
  1892. $size = $this->input->post('size',true);
  1893. $grade = $this->input->post('grade',true);
  1894. $color = $this->input->post('color',true);
  1895. $details = $this->input->post('details',true);
  1896. $sku = $this->input->post('sku',true);
  1897. $warehouse = $this->input->post('warehouse',true);
  1898. $ktime = $this->input->post('ktime',true);
  1899. $jtime = $this->input->post('jtime',true);
  1900. $ktime = strtotime($ktime);
  1901. $jtime = strtotime($jtime);
  1902. $where = "warehouse != '12'";$gj = "";$ck = "";
  1903. if($category)
  1904. {
  1905. $where .= " and features like '%-$category-%'";
  1906. }
  1907. if($size)
  1908. {
  1909. $where .= " and features like '%-$size-%'";
  1910. }
  1911. if($grade)
  1912. {
  1913. $where .= " and features like '%-$grade-%'";
  1914. }
  1915. if($color)
  1916. {
  1917. $where .= " and features like '%-$color-%'";
  1918. }
  1919. if($details)
  1920. {
  1921. $where .= " and details like '%$details%'";
  1922. }
  1923. if($sku)
  1924. {
  1925. $where .= " and sku like '%$sku%'";
  1926. }
  1927. if($warehouse)
  1928. {
  1929. $where .= " and warehouse = '$warehouse'";
  1930. }
  1931. if($ktime && $jtime)
  1932. {
  1933. $where .= " and enter > '$ktime' and enter < '$jtime'";
  1934. }
  1935. //数据排序
  1936. $order_str = "enter desc";
  1937. if(empty($page))
  1938. {
  1939. $start = 0;
  1940. $perpage = 1;
  1941. }
  1942. else
  1943. {
  1944. $start = ($page - 1)*$perpage;
  1945. }
  1946. //取得信息列表
  1947. $info_list = $this->specialstock->find_all($where,'*',$order_str);
  1948. $rows = array();$list = array();
  1949. foreach ($info_list as $key=>$value)
  1950. {
  1951. $rows[$value['enter'].$value['number']] = $value;//所有数据sku
  1952. }
  1953. foreach ($rows as $value)
  1954. {
  1955. $g = $this->specialstock->find_count($where.' and enter = "'.$value['enter'].'" and state != 9');
  1956. $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);
  1957. }
  1958. $total = count($list);
  1959. $pagenum = ceil($total/$perpage);
  1960. $over = $total-($start+$perpage);
  1961. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  1962. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1963. echo json_encode($rows);exit;
  1964. }
  1965. $this->_Template('specialstock_xhcenter',$this->data);
  1966. }
  1967. //出库浏览
  1968. public function _out()
  1969. {
  1970. $post = $this->input->post(NULL, TRUE);
  1971. if(isset($post['page']))
  1972. {
  1973. $page = $this->input->post('page',true);
  1974. $perpage = $this->input->post('perpage',true);
  1975. $category = $this->input->post('category',true);
  1976. $size = $this->input->post('size',true);
  1977. $grade = $this->input->post('grade',true);
  1978. $color = $this->input->post('color',true);
  1979. $lowe = $this->input->post('lowe',true);
  1980. $sku = $this->input->post('sku',true);
  1981. $warehouse = $this->input->post('warehouse',true);
  1982. $purchase = $this->input->post('purchase',true);
  1983. $ktime = $this->input->post('ktime',true);
  1984. $jtime = $this->input->post('jtime',true);
  1985. $ktime = strtotime($ktime);
  1986. $jtime = strtotime($jtime);
  1987. $where = "state=3";$gj = "";$ck = "";
  1988. if($category)
  1989. {
  1990. $where .= " and features like '%-$category-%'";
  1991. }
  1992. if($size)
  1993. {
  1994. $where .= " and features like '%-$size-%'";
  1995. }
  1996. if($grade)
  1997. {
  1998. $where .= " and features like '%-$grade-%'";
  1999. }
  2000. if($color)
  2001. {
  2002. $where .= " and features like '%-$color-%'";
  2003. }
  2004. if($lowe)
  2005. {
  2006. $where .= " and features like '%-$lowe-%'";
  2007. }
  2008. if($state)
  2009. {
  2010. $where .= " and state = '$state'";
  2011. }
  2012. if($warehouse)
  2013. {
  2014. $where .= " and warehouse = '$warehouse'";
  2015. }
  2016. if($purchase)
  2017. {
  2018. $where .= " and purchase = '$purchase'";
  2019. }
  2020. if($sku)
  2021. {
  2022. $where .= " and sku = '$sku'";
  2023. }
  2024. if($ktime && $jtime)
  2025. {
  2026. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2027. }
  2028. //数据排序
  2029. $order_str = "id desc";
  2030. if(empty($page))
  2031. {
  2032. $start = 0;
  2033. $perpage = 1;
  2034. }
  2035. else
  2036. {
  2037. $start = ($page - 1)*$perpage;
  2038. }
  2039. //取得信息列表
  2040. $info_list = $this->specialstock->find_all($where,'sku');
  2041. $rows = array();$list = array();
  2042. foreach ($info_list as $key=>$value)
  2043. {
  2044. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2045. }
  2046. $rows = array_unique($rows);//删除重复记录
  2047. foreach ($rows as $key=>$value)
  2048. {
  2049. $data = $this->specialstock->get_sku($value);//获取目前sku的所有数据
  2050. $ck = $this->warehouse->read($data['warehouse']);
  2051. $warehouse = $ck['title'];
  2052. $gy = $this->purchase->read($data['purchase']);
  2053. $purchase = $gy['purchase'];
  2054. $g = $this->specialstock->find_count($where.' and sku = "'.$value.'" and state = 3');
  2055. $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);
  2056. }
  2057. $total = count($list);
  2058. $pagenum = ceil($total/$perpage);
  2059. $over = $total-($start+$perpage);
  2060. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2061. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2062. echo json_encode($rows);exit;
  2063. }
  2064. $this->_Template('specialstock_out',$this->data);
  2065. }
  2066. //出库标签浏览
  2067. public function _label()
  2068. {
  2069. $post = $this->input->post(NULL, TRUE);
  2070. if(isset($post['page']))
  2071. {
  2072. $page = $this->input->post('page',true);
  2073. $perpage = $this->input->post('perpage',true);
  2074. $sku = $this->input->post('sku',true);
  2075. $warehouse = $this->input->post('warehouse',true);
  2076. $purchase = $this->input->post('purchase',true);
  2077. $orderinfo = $this->input->post('orderinfo',true);
  2078. $waybill = $this->input->post('waybill',true);
  2079. $category = $this->input->post('category',true);
  2080. $size = $this->input->post('size',true);
  2081. $grade = $this->input->post('grade',true);
  2082. $color = $this->input->post('color',true);
  2083. $lowe = $this->input->post('lowe',true);
  2084. $where = "state=1";
  2085. if($sku)
  2086. {
  2087. $where .= " and sku = '$sku'";
  2088. }
  2089. if($warehouse)
  2090. {
  2091. $where .= " and warehouse = '$warehouse'";
  2092. }
  2093. if($purchase)
  2094. {
  2095. $where .= " and purchase = '$purchase'";
  2096. }
  2097. if($orderinfo)
  2098. {
  2099. $where .= " and orderinfo = '$orderinfo'";
  2100. }
  2101. if($waybill)
  2102. {
  2103. $where .= " and waybill = '$waybill'";
  2104. }
  2105. if($category)
  2106. {
  2107. $where .= " and features like '%-$category-%'";
  2108. }
  2109. if($size)
  2110. {
  2111. $where .= " and features like '%-$size-%'";
  2112. }
  2113. if($grade)
  2114. {
  2115. $where .= " and features like '%-$grade-%'";
  2116. }
  2117. if($color)
  2118. {
  2119. $where .= " and features like '%-$color-%'";
  2120. }
  2121. if($lowe)
  2122. {
  2123. $where .= " and features like '%-$lowe-%'";
  2124. }
  2125. //数据排序
  2126. $order_str = "outk desc";
  2127. if(empty($page))
  2128. {
  2129. $start = 0;
  2130. $perpage = 1;
  2131. }
  2132. else
  2133. {
  2134. $start = ($page - 1)*$perpage;
  2135. }
  2136. //取得信息列表
  2137. $info_list = $this->specialstock->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2138. foreach ($info_list as $key=>$value)
  2139. {
  2140. $warehouse = $this->warehouse->read($value['warehouse']);
  2141. $info_list[$key]['warehouse'] = $warehouse['title'];
  2142. $purchase = $this->purchase->read($value['purchase']);
  2143. $info_list[$key]['purchase'] = $purchase['title'];
  2144. if($value['outk'] != 0)
  2145. {
  2146. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2147. }
  2148. else
  2149. {
  2150. $info_list[$key]['outk'] = "";
  2151. }
  2152. if($value['orderinfo'] == 0)
  2153. {
  2154. $info_list[$key]['orderinfo'] = "";
  2155. }
  2156. if($value['waybill'] == 0)
  2157. {
  2158. $info_list[$key]['waybill'] = "";
  2159. }
  2160. }
  2161. $total = $this->specialstock->find_count($where);
  2162. $pagenum = ceil($total/$perpage);
  2163. $over = $total-($start+$perpage);
  2164. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2165. echo json_encode($rows);exit;
  2166. }
  2167. $this->_Template('specialstock_label',$this->data);
  2168. }
  2169. //独立站出库订单
  2170. public function _outorder()
  2171. {
  2172. if(isset($_SESSION['api']))
  2173. {
  2174. $user = $this->user->get_api($_SESSION['api']);
  2175. $usp = $user;
  2176. $fgshop = "";$sid = "";
  2177. $user = explode('|',trim($user['shop'],'|'));
  2178. foreach ($user as $value)
  2179. {
  2180. $sid .= " id = ".$value." or";
  2181. }
  2182. }
  2183. $post = $this->input->post(NULL, TRUE);
  2184. if(isset($post['page']))
  2185. {
  2186. $page = $this->input->post('page',true);
  2187. $perpage = $this->input->post('perpage',true);
  2188. $warehouse = $this->input->post('warehouse',true);
  2189. $xztime = $this->input->post('xztime',true);
  2190. $timetk = $this->input->post('timetkk',true);
  2191. $timetj = $this->input->post('timetjj',true);
  2192. $shop = $this->input->post('shop',true);
  2193. $source = $this->input->post('source',true);
  2194. $orderinfo = $this->input->post('orderinfo',true);
  2195. $number = $this->input->post('number',true);
  2196. $express = $this->input->post('express',true);
  2197. $waybill = $this->input->post('waybill',true);
  2198. $library = $this->input->post('library',true);
  2199. $country = $this->input->post('country',true);
  2200. $so = $this->input->post('so',true);
  2201. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2202. $print = $this->input->post('print',true);
  2203. $state = $this->input->post('state',true);
  2204. $timetk = strtotime($timetk);
  2205. $timetj = strtotime($timetj);
  2206. /**
  2207. $sj = $this->input->post('sj',true);
  2208. if($sj)
  2209. {
  2210. $sj = $this->input->post('sj',true);
  2211. }
  2212. else
  2213. {
  2214. $sj = "fullorder";
  2215. }
  2216. **/
  2217. $sj = "fullorder";
  2218. $where = "mergeid = 0";
  2219. if($warehouse)
  2220. {
  2221. $where .= " and type = '$warehouse'";
  2222. }
  2223. if($timetk && $timetj)
  2224. {
  2225. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2226. }
  2227. if($orderinfo)
  2228. {
  2229. $where .= " and orderinfo = '$orderinfo'";
  2230. }
  2231. if($number)
  2232. {
  2233. $where .= " and number = '$number'";
  2234. }
  2235. if($express)
  2236. {
  2237. $where .= " and express = '$express'";
  2238. }
  2239. if($waybill)
  2240. {
  2241. $where .= " and waybill = '$waybill'";
  2242. }
  2243. if($library)
  2244. {
  2245. $where .= " and library = '$library'";
  2246. }
  2247. if($print)
  2248. {
  2249. $where .= " and print = '$print'";
  2250. }
  2251. if($libraryconfirm)
  2252. {
  2253. $where .= " and libraryconfirm = '$libraryconfirm'";
  2254. }
  2255. if($state)
  2256. {
  2257. $where .= " and state = '$state'";
  2258. }
  2259. if($shop)
  2260. {
  2261. $where .= " and shop = '$shop'";
  2262. }
  2263. if($country)
  2264. {
  2265. $where .= " and country = '$country'";
  2266. }
  2267. if($so)
  2268. {
  2269. $where .= " and shipremarks like '%$so%'";
  2270. }
  2271. if($source)
  2272. {
  2273. $where .= " and source = '$source'";
  2274. }
  2275. else
  2276. {
  2277. if(isset($_SESSION['api']))
  2278. {
  2279. foreach ($user as $value)
  2280. {
  2281. $fgshop .= " shop = ".$value." or";
  2282. }
  2283. $where .= " and (".rtrim($fgshop,'or').")";
  2284. }
  2285. }
  2286. //数据排序
  2287. $order_str = "librarytime desc";
  2288. if(empty($page))
  2289. {
  2290. $start = 0;
  2291. $perpage = 1;
  2292. }
  2293. else
  2294. {
  2295. $start = ($page - 1)*$perpage;
  2296. }
  2297. //取得信息列表
  2298. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2299. //格式化数据
  2300. foreach ($info_list as $key=>$value)
  2301. {
  2302. $shop = $this->shop->read($value['shop']);
  2303. $info_list[$key]['shop'] = $shop['shopname'];
  2304. $express = $this->express->read($value['express']);
  2305. $info_list[$key]['express'] = $express['servicename'];
  2306. $warehouse = $this->warehouse->read($value['type']);
  2307. $info_list[$key]['type'] = $warehouse['title'];
  2308. if($value['librarytime'] == '0')
  2309. {
  2310. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2311. }
  2312. else
  2313. {
  2314. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2315. }
  2316. }
  2317. $total = $this->$sj->find_count($where);
  2318. $pagenum = ceil($total/$perpage);
  2319. $over = $total-($start+$perpage);
  2320. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2321. echo json_encode($rows);exit;
  2322. }
  2323. $this->data['express'] = $this->express->find_all();
  2324. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2325. $this->data['wlshop'] = $wlshop;
  2326. $this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=2','*','idorder desc');//导出模板
  2327. $this->_Template('specialstock_outorder',$this->data);
  2328. }
  2329. //速卖通出库订单
  2330. public function _soutorder()
  2331. {
  2332. if(isset($_SESSION['api']))
  2333. {
  2334. $user = $this->user->get_api($_SESSION['api']);
  2335. $usp = $user;
  2336. $fgshop = "";$sid = "";
  2337. $user = explode('|',trim($user['shop'],'|'));
  2338. foreach ($user as $value)
  2339. {
  2340. $sid .= " id = ".$value." or";
  2341. }
  2342. }
  2343. $post = $this->input->post(NULL, TRUE);
  2344. if(isset($post['page']))
  2345. {
  2346. $page = $this->input->post('page',true);
  2347. $perpage = $this->input->post('perpage',true);
  2348. $warehouse = $this->input->post('warehouse',true);
  2349. $xztime = $this->input->post('xztime',true);
  2350. $timetk = $this->input->post('timetkk',true);
  2351. $timetj = $this->input->post('timetjj',true);
  2352. $shop = $this->input->post('shop',true);
  2353. $source = $this->input->post('source',true);
  2354. $orderinfo = $this->input->post('orderinfo',true);
  2355. $number = $this->input->post('number',true);
  2356. $express = $this->input->post('express',true);
  2357. $waybill = $this->input->post('waybill',true);
  2358. $library = $this->input->post('library',true);
  2359. $country = $this->input->post('country',true);
  2360. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2361. $print = $this->input->post('print',true);
  2362. $state = $this->input->post('state',true);
  2363. $so = $this->input->post('so',true);
  2364. $timetk = strtotime($timetk);
  2365. $timetj = strtotime($timetj);
  2366. /**
  2367. $sj = $this->input->post('sj',true);
  2368. if($sj)
  2369. {
  2370. $sj = $this->input->post('sj',true);
  2371. }
  2372. else
  2373. {
  2374. $sj = "fullorder";
  2375. }
  2376. **/
  2377. $sj = "fullordersmt";
  2378. $where = "mergeid = 0";
  2379. if($warehouse)
  2380. {
  2381. $where .= " and type = '$warehouse'";
  2382. }
  2383. if($timetk && $timetj)
  2384. {
  2385. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2386. }
  2387. if($orderinfo)
  2388. {
  2389. $where .= " and orderinfo = '$orderinfo'";
  2390. }
  2391. if($number)
  2392. {
  2393. $where .= " and number = '$number'";
  2394. }
  2395. if($express)
  2396. {
  2397. $where .= " and express = '$express'";
  2398. }
  2399. if($waybill)
  2400. {
  2401. $where .= " and waybill = '$waybill'";
  2402. }
  2403. if($library)
  2404. {
  2405. $where .= " and library = '$library'";
  2406. }
  2407. if($print)
  2408. {
  2409. $where .= " and print = '$print'";
  2410. }
  2411. if($libraryconfirm)
  2412. {
  2413. $where .= " and libraryconfirm = '$libraryconfirm'";
  2414. }
  2415. if($state)
  2416. {
  2417. $where .= " and state = '$state'";
  2418. }
  2419. if($shop)
  2420. {
  2421. $where .= " and shop = '$shop'";
  2422. }
  2423. if($so)
  2424. {
  2425. $where .= " and shipremarks like '%$so%'";
  2426. }
  2427. if($source)
  2428. {
  2429. $where .= " and source = '$source'";
  2430. }
  2431. if($country)
  2432. {
  2433. $where .= " and country = '$country'";
  2434. }
  2435. else
  2436. {
  2437. if(isset($_SESSION['api']))
  2438. {
  2439. foreach ($user as $value)
  2440. {
  2441. $fgshop .= " shop = ".$value." or";
  2442. }
  2443. $where .= " and (".rtrim($fgshop,'or').")";
  2444. }
  2445. }
  2446. //数据排序
  2447. $order_str = "librarytime desc";
  2448. if(empty($page))
  2449. {
  2450. $start = 0;
  2451. $perpage = 1;
  2452. }
  2453. else
  2454. {
  2455. $start = ($page - 1)*$perpage;
  2456. }
  2457. //取得信息列表
  2458. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2459. //格式化数据
  2460. foreach ($info_list as $key=>$value)
  2461. {
  2462. $shop = $this->shop->read($value['shop']);
  2463. $info_list[$key]['shop'] = $shop['shopname'];
  2464. $express = $this->express->read($value['express']);
  2465. $info_list[$key]['express'] = $express['servicename'];
  2466. $warehouse = $this->warehouse->read($value['type']);
  2467. $info_list[$key]['type'] = $warehouse['title'];
  2468. if($value['librarytime'] == '0')
  2469. {
  2470. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2471. }
  2472. else
  2473. {
  2474. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2475. }
  2476. }
  2477. $total = $this->$sj->find_count($where);
  2478. $pagenum = ceil($total/$perpage);
  2479. $over = $total-($start+$perpage);
  2480. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2481. echo json_encode($rows);exit;
  2482. }
  2483. $this->data['express'] = $this->express->find_all();
  2484. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2485. $this->data['wlshop'] = $wlshop;
  2486. $this->data['fullorderexcel'] = $this->fullorderexcel->find_all('type=5','*','idorder desc');//导出模板
  2487. $this->_Template('specialstock_soutorder',$this->data);
  2488. }
  2489. //订单退库
  2490. public function _retreat()
  2491. {
  2492. $post = $this->input->post(NULL, TRUE);
  2493. if(isset($post['page']))
  2494. {
  2495. $page = $this->input->post('page',true);
  2496. $perpage = $this->input->post('perpage',true);
  2497. $warehouse = $this->input->post('warehouse',true);
  2498. $timetk = $this->input->post('timetk',true);
  2499. $timetj = $this->input->post('timetj',true);
  2500. $shop = $this->input->post('shop',true);
  2501. $source = $this->input->post('source',true);
  2502. $state = $this->input->post('state',true);
  2503. $review = $this->input->post('review',true);
  2504. $state = $this->input->post('state',true);
  2505. $express = $this->input->post('express',true);
  2506. $orderinfo = $this->input->post('orderinfo',true);
  2507. $user = $this->input->post('user',true);
  2508. $name = $this->input->post('name',true);
  2509. $waybill = $this->input->post('waybill',true);
  2510. $timetk = strtotime($timetk);
  2511. $timetj = strtotime($timetj);
  2512. $where = "(state=206 or state=210) and mergeid = 0";
  2513. if($warehouse)
  2514. {
  2515. $where .= " and state = '$warehouse'";
  2516. }
  2517. if($timetk && $timetj)
  2518. {
  2519. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2520. }
  2521. if($shop)
  2522. {
  2523. $where .= " and shop = '$shop'";
  2524. }
  2525. if($source)
  2526. {
  2527. $where .= " and source = '$source'";
  2528. }
  2529. if($state)
  2530. {
  2531. $where .= " and state = '$state'";
  2532. }
  2533. if($review)
  2534. {
  2535. $where .= " and review = '$review'";
  2536. }
  2537. if($state)
  2538. {
  2539. $where .= " and state = '$state'";
  2540. }
  2541. if($express)
  2542. {
  2543. $where .= " and express = '$express'";
  2544. }
  2545. if($orderinfo)
  2546. {
  2547. $where .= " and orderinfo = '$orderinfo'";
  2548. }
  2549. if($user)
  2550. {
  2551. $where .= " and user = '$user'";
  2552. }
  2553. if($name)
  2554. {
  2555. $where .= " and name = '$name'";
  2556. }
  2557. if($waybill)
  2558. {
  2559. $where .= " and waybill = '$waybill'";
  2560. }
  2561. //数据排序
  2562. $order_str = "id desc";
  2563. if(empty($page))
  2564. {
  2565. $start = 0;
  2566. $perpage = 1;
  2567. }
  2568. else
  2569. {
  2570. $start = ($page - 1)*$perpage;
  2571. }
  2572. //取得信息列表
  2573. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  2574. //格式化数据
  2575. foreach ($info_list as $key=>$value)
  2576. {
  2577. $shop = $this->shop->read($value['shop']);
  2578. $info_list[$key]['shop'] = $shop['shopname'];
  2579. $warehouse = $this->warehouse->read($value['warehouse']);
  2580. $info_list[$key]['warehouse'] = $warehouse['title'];
  2581. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  2582. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  2583. if($value['waybill'] == 0)
  2584. {
  2585. $info_list[$key]['waybill'] = "";
  2586. }
  2587. $express = $this->express->read($value['express']);
  2588. $info_list[$key]['express'] = $express['title'];
  2589. $typeclass = $this->typeclass->read($value['state']);
  2590. $info_list[$key]['state'] = $typeclass['title'];
  2591. }
  2592. $total = $this->fullorder->find_count($where);
  2593. $pagenum = ceil($total/$perpage);
  2594. $over = $total-($start+$perpage);
  2595. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2596. echo json_encode($rows);exit;
  2597. }
  2598. $this->data['express'] = $this->express->find_all();
  2599. $this->_Template('specialstock_retreat',$this->data);
  2600. }
  2601. //退库标签浏览
  2602. public function _retreatlk()
  2603. {
  2604. $post = $this->input->post(NULL, TRUE);
  2605. if(isset($post['page']))
  2606. {
  2607. $page = $this->input->post('page',true);
  2608. $perpage = $this->input->post('perpage',true);
  2609. $timetk = $this->input->post('timetk',true);
  2610. $timetj = $this->input->post('timetj',true);
  2611. $sku = $this->input->post('sku',true);
  2612. $warehouse = $this->input->post('warehouse',true);
  2613. $purchase = $this->input->post('purchase',true);
  2614. $orderinfo = $this->input->post('orderinfo',true);
  2615. $waybill = $this->input->post('waybill',true);
  2616. $category = $this->input->post('category',true);
  2617. $size = $this->input->post('size',true);
  2618. $grade = $this->input->post('grade',true);
  2619. $color = $this->input->post('color',true);
  2620. $lowe = $this->input->post('lowe',true);
  2621. $state = $this->input->post('state',true);
  2622. $timetk = strtotime($timetk);
  2623. $timetj = strtotime($timetj);
  2624. $where = "state=2";
  2625. if($timetk && $timetj)
  2626. {
  2627. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  2628. }
  2629. if($sku)
  2630. {
  2631. $where .= " and sku = '$sku'";
  2632. }
  2633. if($warehouse)
  2634. {
  2635. $where .= " and warehouse = '$warehouse'";
  2636. }
  2637. if($purchase)
  2638. {
  2639. $where .= " and purchase = '$purchase'";
  2640. }
  2641. if($orderinfo)
  2642. {
  2643. $where .= " and orderinfo = '$orderinfo'";
  2644. }
  2645. if($waybill)
  2646. {
  2647. $where .= " and waybill = '$waybill'";
  2648. }
  2649. if($category)
  2650. {
  2651. $where .= " and features like '%-$category-%'";
  2652. }
  2653. if($size)
  2654. {
  2655. $where .= " and features like '%-$size-%'";
  2656. }
  2657. if($grade)
  2658. {
  2659. $where .= " and features like '%-$grade-%'";
  2660. }
  2661. if($color)
  2662. {
  2663. $where .= " and features like '%-$color-%'";
  2664. }
  2665. if($lowe)
  2666. {
  2667. $where .= " and features like '%-$lowe-%'";
  2668. }
  2669. //数据排序
  2670. $order_str = "time desc";
  2671. if(empty($page))
  2672. {
  2673. $start = 0;
  2674. $perpage = 1;
  2675. }
  2676. else
  2677. {
  2678. $start = ($page - 1)*$perpage;
  2679. }
  2680. //取得信息列表
  2681. $info_list = $this->specialstock->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  2682. foreach ($info_list as $key=>$value)
  2683. {
  2684. $warehouse = $this->warehouse->read($value['warehouse']);
  2685. $info_list[$key]['warehouse'] = $warehouse['title'];
  2686. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  2687. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  2688. $purchase = $this->purchase->read($value['purchase']);
  2689. $info_list[$key]['purchase'] = $purchase['title'];
  2690. if($value['outk'] != 0)
  2691. {
  2692. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2693. }
  2694. else
  2695. {
  2696. $info_list[$key]['outk'] = "";
  2697. }
  2698. if($value['retreat'] != 0)
  2699. {
  2700. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  2701. }
  2702. else
  2703. {
  2704. $info_list[$key]['retreat'] = "";
  2705. }
  2706. if($value['orderinfo'] == 0)
  2707. {
  2708. $info_list[$key]['orderinfo'] = "";
  2709. }
  2710. if($value['waybill'] == 0)
  2711. {
  2712. $info_list[$key]['waybill'] = "";
  2713. }
  2714. }
  2715. $total = $this->specialstock->find_count($where);
  2716. $pagenum = ceil($total/$perpage);
  2717. $over = $total-($start+$perpage);
  2718. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2719. echo json_encode($rows);exit;
  2720. }
  2721. $this->_Template('specialstock_retreatlk',$this->data);
  2722. }
  2723. //更换标签及浏览
  2724. public function _change()
  2725. {
  2726. $post = $this->input->post(NULL, TRUE);
  2727. if(isset($post['page']))
  2728. {
  2729. $page = $this->input->post('page',true);
  2730. $perpage = $this->input->post('perpage',true);
  2731. $timetk = $this->input->post('timetk',true);
  2732. $timetj = $this->input->post('timetj',true);
  2733. $label = $this->input->post('label',true);
  2734. $oldlabel = $this->input->post('oldlabel',true);
  2735. $timetk = strtotime($timetk);
  2736. $timetj = strtotime($timetj);
  2737. $where = "state=10 ";
  2738. if($timetk && $timetj)
  2739. {
  2740. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  2741. }
  2742. if($label)
  2743. {
  2744. $where .= " and label = '$label'";
  2745. }
  2746. if($oldlabel)
  2747. {
  2748. $where .= " and oldlabel = '$oldlabel'";
  2749. }
  2750. //数据排序
  2751. $order_str = "time asc";
  2752. if(empty($page))
  2753. {
  2754. $start = 0;
  2755. $perpage = 1;
  2756. }
  2757. else
  2758. {
  2759. $start = ($page - 1)*$perpage;
  2760. }
  2761. //取得信息列表
  2762. $info_list = $this->specialstock->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  2763. foreach ($info_list as $key=>$value)
  2764. {
  2765. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  2766. }
  2767. $total = $this->specialstock->find_count($where);
  2768. $pagenum = ceil($total/$perpage);
  2769. $over = $total-($start+$perpage);
  2770. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2771. echo json_encode($rows);exit;
  2772. }
  2773. $this->_Template('specialstock_change',$this->data);
  2774. }
  2775. //产品标签
  2776. public function _cpbqdc()
  2777. {
  2778. if(isset($_GET['excel']))
  2779. {
  2780. $where = "1=1";
  2781. //数据排序
  2782. $order_str = "id desc";
  2783. if(empty($page))
  2784. {
  2785. $start = 0;
  2786. $perpage = 1;
  2787. }
  2788. else
  2789. {
  2790. $start = ($page - 1)*$perpage;
  2791. }
  2792. $warehouse = $this->input->get('warehouse',true);
  2793. $state = $this->input->get('state',true);
  2794. $timetk = $this->input->get('timetkk',true);
  2795. $timetj = $this->input->get('timetjj',true);
  2796. $timetk = strtotime($timetk);
  2797. $timetj = strtotime($timetj);
  2798. if($warehouse)
  2799. {
  2800. $where .= " and warehouse = '$warehouse'";
  2801. }
  2802. if($state || $state == 0)
  2803. {
  2804. $where .= " and state = '$state'";
  2805. }
  2806. if($timetk && $timetj)
  2807. {
  2808. $where .= " and time > '$timetk' and time < '$timetj'";
  2809. }
  2810. //取得信息列表
  2811. $info_list = $this->specialstock->find_all($where,'*');
  2812. $rows = array();$list = array();
  2813. foreach ($info_list as $key=>$value)
  2814. {
  2815. $rows[$value['time']] = $value;//所有数据sku
  2816. }
  2817. foreach ($rows as $value)
  2818. {
  2819. $warehouse = $this->warehouse->read($value['warehouse']);
  2820. $s = $this->specialstock->find_count($where.' and time = "'.$value['time'].'"');
  2821. $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);
  2822. }
  2823. $title = "产品标签统计表";
  2824. $titlename = "<table border=1>
  2825. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  2826. <tr align='center'>
  2827. <td>仓库</td>
  2828. <td>SKU</td>
  2829. <td>产品</td>
  2830. <td>入库时间</td>
  2831. <td>操作时间</td>
  2832. <td>备注</td>
  2833. <td>数量</td>
  2834. </tr>
  2835. </table>";
  2836. $filename = $title.".xls";
  2837. $tail = "";
  2838. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  2839. }
  2840. }
  2841. //进销存导出
  2842. public function _exceljxc()
  2843. {
  2844. if(isset($_GET['excel']))
  2845. {
  2846. $where = "1=1";
  2847. //数据排序
  2848. $order_str = "id desc";
  2849. if(empty($page))
  2850. {
  2851. $start = 0;
  2852. $perpage = 1;
  2853. }
  2854. else
  2855. {
  2856. $start = ($page - 1)*$perpage;
  2857. }
  2858. $category = $this->input->get('category',true);
  2859. $warehouse = $this->input->get('warehouse',true);
  2860. $pc = $this->input->get('pc',true);
  2861. if($pc)
  2862. {
  2863. $pc = trim($pc,'x');
  2864. $pc = explode('x',$pc);
  2865. foreach ($pc as $v)
  2866. {
  2867. $where .= " and warehouse != '".$v."'";
  2868. }
  2869. }
  2870. if($category)
  2871. {
  2872. $where .= " and features like '%-$category-%'";
  2873. }
  2874. if($warehouse)
  2875. {
  2876. $where .= " and warehouse = '$warehouse'";
  2877. }
  2878. //取得信息列表
  2879. $info_list = $this->specialstock->find_pc($where,'sku,features,warehouse','id,features,sku,details,warehouse,number,title,cpbz');
  2880. $list = array();
  2881. // foreach ($info_list as $value)
  2882. // {
  2883. // $classid = $this->classid->sku();
  2884. // $pm = $classid;
  2885. // //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  2886. // $features = explode('-',trim($value['features'],'-'));
  2887. // foreach ($features as $v)
  2888. // {
  2889. // $typeclass = $this->typeclass->read($v);
  2890. // $pm[$typeclass['classid']] = $typeclass['zh'];
  2891. // //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
  2892. // }
  2893. // $typeclass = $this->typeclass->read($v);
  2894. // //$scsku = implode("-",$scsku);
  2895. // $zh = implode(" ",$pm);
  2896. // $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2897. // //$scsku = str_replace('- ','-',trim($scsku,'-'));
  2898. // //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2899. // $cpid = '';
  2900. // $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"','cpid');
  2901. // foreach ($c as $v)
  2902. // {
  2903. // if($v['cpid'] != 0)
  2904. // {
  2905. // $cpid .= $v['cpid'].' ';
  2906. // }
  2907. // }
  2908. // $g = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
  2909. // $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  2910. // $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "2" and features = "'.$value['features'].'"');
  2911. // $number = $value['number'];$ftime = time()-15*24*3600;
  2912. // $warehouse = $this->warehouse->read($value['warehouse']);
  2913. // $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$u9_code,$g,count($c),$x,$t,$value['cpbz']);
  2914. // }
  2915. $classid = $this->classid->sku();
  2916. $tcall = $this->typeclass->find_all();
  2917. foreach ($tcall as $v)
  2918. {
  2919. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  2920. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  2921. }
  2922. foreach ($info_list as $value)
  2923. {
  2924. $tmp_r = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  2925. $zh = $tmp_r['zh'];
  2926. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  2927. $u9_code = $tmp_r['jm'];
  2928. $cpid = '';
  2929. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"','cpid');
  2930. foreach ($c as $v)
  2931. {
  2932. if($v['cpid'] != 0)
  2933. {
  2934. $cpid .= $v['cpid'].' ';
  2935. }
  2936. }
  2937. $g = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state != "9" and features = "'.$value['features'].'"');
  2938. $x = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  2939. $t = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "2" and features = "'.$value['features'].'"');
  2940. $number = $value['number'];$ftime = time()-15*24*3600;
  2941. $warehouse = $this->warehouse->read($value['warehouse']);
  2942. $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$u9_code,$g,count($c),$x,$t,$value['cpbz']);
  2943. }
  2944. $title = "总进销存统计表";
  2945. $titlename = "<table border=1>
  2946. <tr><th colspan='10' align='center'><h3>".$title."<h3></th></tr>
  2947. <tr align='center'>
  2948. <td>位置</td>
  2949. <td>库存编码</td>
  2950. <td>产品</td>
  2951. <td>SKU</td>
  2952. <td>中文</td>
  2953. <td>u9料号</td>
  2954. <td>入库总量</td>
  2955. <td>库存数量</td>
  2956. <td>销售数量</td>
  2957. <td>退货数量</td>
  2958. <td>备注</td>
  2959. </tr>
  2960. </table>";
  2961. $filename = $title.".xls";
  2962. $tail = "";
  2963. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  2964. }
  2965. }
  2966. //入库导出
  2967. public function _excelr()
  2968. {
  2969. if(isset($_GET['excel']))
  2970. {
  2971. $category = $this->input->get('category',true);
  2972. $size = $this->input->get('size',true);
  2973. $grade = $this->input->get('grade',true);
  2974. $color = $this->input->get('color',true);
  2975. $lowe = $this->input->get('lowe',true);
  2976. $sku = $this->input->get('sku',true);
  2977. $warehouse = $this->input->get('warehouse',true);
  2978. $purchase = $this->input->get('purchase',true);
  2979. $ktime = $this->input->get('ktime',true);
  2980. $jtime = $this->input->get('jtime',true);
  2981. $ktime = strtotime($ktime);
  2982. $jtime = strtotime($jtime);
  2983. $where = "1=1";$gj = "";$ck = "";
  2984. $pc = $this->input->get('pc',true);
  2985. if($pc)
  2986. {
  2987. $pc = trim($pc,'x');
  2988. $pc = explode('x',$pc);
  2989. foreach ($pc as $v)
  2990. {
  2991. $where .= " and warehouse != '".$v."'";
  2992. }
  2993. }
  2994. if($category)
  2995. {
  2996. $where .= " and features like '%-$category-%'";
  2997. }
  2998. if($size)
  2999. {
  3000. $where .= " and features like '%-$size-%'";
  3001. }
  3002. if($grade)
  3003. {
  3004. $where .= " and features like '%-$grade-%'";
  3005. }
  3006. if($color)
  3007. {
  3008. $where .= " and features like '%-$color-%'";
  3009. }
  3010. if($lowe)
  3011. {
  3012. $where .= " and features like '%-$lowe-%'";
  3013. }
  3014. if($warehouse)
  3015. {
  3016. $where .= " and warehouse = '$warehouse'";
  3017. }
  3018. if($purchase)
  3019. {
  3020. $where .= " and purchase = '$purchase'";
  3021. }
  3022. if($sku)
  3023. {
  3024. $where .= " and sku = '$sku'";
  3025. }
  3026. if($ktime && $jtime)
  3027. {
  3028. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3029. }
  3030. //数据排序
  3031. $order_str = "id desc";
  3032. if(empty($page))
  3033. {
  3034. $start = 0;
  3035. $perpage = 1;
  3036. }
  3037. else
  3038. {
  3039. $start = ($page - 1)*$perpage;
  3040. }
  3041. //取得信息列表
  3042. $info_list = $this->specialstock->find_pc($where,'enter','*',$order_str);
  3043. $list = array();
  3044. foreach ($info_list as $value)
  3045. {
  3046. $ck = $this->warehouse->read($value['warehouse']);
  3047. $warehouse = $ck['title'];
  3048. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3049. $retreatwarehouse = $tkck['title'];
  3050. $gy = $this->purchase->read($value['purchase']);
  3051. $purchase = $gy['title'];
  3052. $cpid = '';
  3053. $g = $this->specialstock->find_all($where.' and enter = "'.$value['enter'].'"','cpid');
  3054. foreach ($g as $v)
  3055. {
  3056. if($v['cpid'] != 0)
  3057. {
  3058. $cpid .= $v['cpid'].' ';
  3059. }
  3060. }
  3061. $list[] = array('details'=>$value['details'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>count($g),'cpid'=>$cpid);
  3062. }
  3063. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3064. $titlename = "<table border=1>
  3065. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  3066. <tr align='center'>
  3067. <td>备注</td>
  3068. <td>产品</td>
  3069. <td>时间</td>
  3070. <td>数量</td>
  3071. <td>编码</td>
  3072. </tr>
  3073. </table>";
  3074. $filename = $title.".xls";
  3075. $tail = "";
  3076. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3077. }
  3078. }
  3079. //出库、退库导出
  3080. public function _excelct()
  3081. {
  3082. if(isset($_GET['excel']))
  3083. {
  3084. $type = $this->input->get('excel',true);
  3085. $category = $this->input->get('category',true);
  3086. $size = $this->input->get('size',true);
  3087. $grade = $this->input->get('grade',true);
  3088. $color = $this->input->get('color',true);
  3089. $lowe = $this->input->get('lowe',true);
  3090. $lacetype = $this->input->get('lacetype',true);
  3091. $details = $this->input->get('details',true);
  3092. $sku = $this->input->get('sku',true);
  3093. $warehouse = $this->input->get('warehouse',true);
  3094. $purchase = $this->input->get('purchase',true);
  3095. $state = $this->input->get('state',true);
  3096. $sid = $this->input->get('sid',true);
  3097. $ktime = $this->input->get('ktime',true);
  3098. $jtime = $this->input->get('jtime',true);
  3099. $ktime = strtotime($ktime);
  3100. $jtime = strtotime($jtime);
  3101. $where = "1=1";$gj = "";$ck = "";
  3102. $pc = $this->input->get('pc',true);
  3103. if($pc)
  3104. {
  3105. $pc = trim($pc,'x');
  3106. $pc = explode('x',$pc);
  3107. foreach ($pc as $v)
  3108. {
  3109. $where .= " and warehouse != '".$v."'";
  3110. }
  3111. }
  3112. if($category)
  3113. {
  3114. $where .= " and features like '%-$category-%'";
  3115. }
  3116. if($size)
  3117. {
  3118. $where .= " and features like '%-$size-%'";
  3119. }
  3120. if($grade)
  3121. {
  3122. $where .= " and features like '%-$grade-%'";
  3123. }
  3124. if($color)
  3125. {
  3126. $where .= " and features like '%-$color-%'";
  3127. }
  3128. if($lowe)
  3129. {
  3130. $where .= " and features like '%-$lowe-%'";
  3131. }
  3132. if($warehouse)
  3133. {
  3134. $where .= " and warehouse = '$warehouse'";
  3135. }
  3136. if($purchase)
  3137. {
  3138. $where .= " and purchase = '$purchase'";
  3139. }
  3140. if($state)
  3141. {
  3142. $where .= " and state = '$state'";
  3143. }
  3144. if($sku)
  3145. {
  3146. $where .= " and sku like '%$sku%'";
  3147. }
  3148. if($lacetype)
  3149. {
  3150. $where .= " and features like '%-$lacetype-%'";
  3151. }
  3152. if($details)
  3153. {
  3154. $where .= " and details like '%$details%'";
  3155. }
  3156. if($ktime && $jtime)
  3157. {
  3158. if($type == 1)
  3159. {
  3160. $tl = '出库';
  3161. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3162. }
  3163. else if($type == 2)
  3164. {
  3165. $tl = '退库';
  3166. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3167. }
  3168. else if($type == 3)
  3169. {
  3170. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3171. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3172. }
  3173. else if($type == 4)
  3174. {
  3175. $tl = '出库+零售';
  3176. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3177. }
  3178. else if($type == 5)
  3179. {
  3180. $tl = '零售';
  3181. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3182. }
  3183. }
  3184. if($sid)
  3185. {
  3186. $sd = "";
  3187. $s = explode(',',trim($sid,','));
  3188. foreach ($s as $value)
  3189. {
  3190. $sd .= " id = ".$value." or";
  3191. }
  3192. $sidwhere .= " and (".rtrim($sd,'or').")";
  3193. }
  3194. //数据排序
  3195. $order_str = "time desc";
  3196. if(empty($page))
  3197. {
  3198. $start = 0;
  3199. $perpage = 1;
  3200. }
  3201. else
  3202. {
  3203. $start = ($page - 1)*$perpage;
  3204. }
  3205. //取得信息列表
  3206. if($type != 3 && $type != 5)
  3207. {
  3208. if($type == 1 || $type == 4)
  3209. {
  3210. $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,outk,cpbz',$order_str);
  3211. foreach ($info_list as $key=>$value)
  3212. {
  3213. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  3214. }
  3215. }
  3216. else
  3217. {
  3218. $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,orderinfo,waybill,retreat,cpbz',$order_str);
  3219. foreach ($info_list as $key=>$value)
  3220. {
  3221. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  3222. }
  3223. }
  3224. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  3225. $titlename = "<table border=1>
  3226. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  3227. <tr align='center'>
  3228. <td>位置</td>
  3229. <td>产品编码</td>
  3230. <td>产品</td>
  3231. <td>标签</td>
  3232. <td>订单号</td>
  3233. <td>运单号</td>
  3234. <td>".$tl."时间(中国时间)</td>
  3235. <td>备注</td>
  3236. </tr>
  3237. </table>";
  3238. $filename = $title.".xls";
  3239. $tail = "";
  3240. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  3241. }
  3242. else if($type == 5)
  3243. {
  3244. $info_list = $this->specialstock->find_all($where,'details,cpid,title,label,outk,cpbz',$order_str);
  3245. foreach ($info_list as $key=>$value)
  3246. {
  3247. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  3248. $warehouse = $this->warehouse->read($value['warehouse']);
  3249. $info_list[$key]['warehouse'] = $warehouse['title'];
  3250. }
  3251. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  3252. $titlename = "<table border=1>
  3253. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3254. <tr align='center'>
  3255. <td>位置</td>
  3256. <td>产品编码</td>
  3257. <td>产品</td>
  3258. <td>标签</td>
  3259. <td>".$tl."时间(中国时间)</td>
  3260. <td>备注</td>
  3261. </tr>
  3262. </table>";
  3263. $filename = $title.".xls";
  3264. $tail = "";
  3265. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  3266. }
  3267. else
  3268. {
  3269. $info_list = $this->specialstock->find_pc($where.$sidwhere,'sku,warehouse,features','*');
  3270. $list = array();
  3271. foreach ($info_list as $value)
  3272. {
  3273. $classid = $this->classid->sku();
  3274. $pm = $classid;
  3275. //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  3276. $features = explode('-',trim($value['features'],'-'));
  3277. foreach ($features as $v)
  3278. {
  3279. $typeclass = $this->typeclass->read($v);
  3280. $pm[$typeclass['classid']] = $typeclass['zh'];
  3281. //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
  3282. }
  3283. $typeclass = $this->typeclass->read($v);
  3284. //$scsku = implode("-",$scsku);
  3285. $zh = implode(" ",$pm);
  3286. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  3287. //$scsku = str_replace('- ','-',trim($scsku,'-'));
  3288. //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  3289. $cpid = '';
  3290. $c = $this->specialstock->find_all($where.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"','cpid');
  3291. foreach ($c as $v)
  3292. {
  3293. if($v['cpid'] != 0)
  3294. {
  3295. $cpid .= $v['cpid'].' ';
  3296. }
  3297. }
  3298. $g = $this->specialstock->find_count($where.$gj.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state != "9"');
  3299. $x = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "1"');
  3300. $t = $this->specialstock->find_count($where.$ck.' and sku = "'.$value['sku'].'" and features = "'.$value['features'].'" and warehouse = "'.$value['warehouse'].'" and state = "2"');
  3301. $number = $value['number'];$ftime = time()-15*24*3600;
  3302. $warehouse = $this->warehouse->read($value['warehouse']);
  3303. $list[] = array($value['details'],$cpid,$value['title'],$value['sku'],$zh,$g,count($c),$x,$t,$value['cpbz']);
  3304. }
  3305. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  3306. $titlename = "<table border=1>
  3307. <tr><th colspan='9' align='center'><h3>".$title."<h3></th></tr>
  3308. <tr align='center'>
  3309. <td>位置</td>
  3310. <td>库存编码</td>
  3311. <td>产品</td>
  3312. <td>SKU</td>
  3313. <td>中文</td>
  3314. <td>入库总量</td>
  3315. <td>库存数量</td>
  3316. <td>销售数量</td>
  3317. <td>退货数量</td>
  3318. <td>备注</td>
  3319. </tr>
  3320. </table>";
  3321. $filename = $title.".xls";
  3322. $tail = "";
  3323. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3324. }
  3325. }
  3326. }
  3327. //数量调整模板导出
  3328. public function _presetout()
  3329. {
  3330. if(isset($_GET['excel']))
  3331. {
  3332. $where = "1=1";
  3333. //数据排序
  3334. $order_str = "id desc";
  3335. if(empty($page))
  3336. {
  3337. $start = 0;
  3338. $perpage = 1;
  3339. }
  3340. else
  3341. {
  3342. $start = ($page - 1)*$perpage;
  3343. }
  3344. $pc = $this->input->get('pc',true);
  3345. if($pc)
  3346. {
  3347. $pc = trim($pc,'x');
  3348. $pc = explode('x',$pc);
  3349. foreach ($pc as $v)
  3350. {
  3351. $where .= " and warehouse != '".$v."'";
  3352. }
  3353. }
  3354. //取得信息列表
  3355. $info_list = $this->specialstock->find_all($where,'*');
  3356. $rows = array();$list = array();
  3357. foreach ($info_list as $key=>$value)
  3358. {
  3359. $rows[$value['number']] = $value;//所有数据sku
  3360. }
  3361. foreach ($rows as $value)
  3362. {
  3363. $warehouse = $this->warehouse->read($value['warehouse']);
  3364. $number = $value['number'];$ftime = time()-15*24*3600;
  3365. $list[] = array($value['features'],$value['sku'],'0','','0',$warehouse['title']);
  3366. }
  3367. $title = "库存模板";
  3368. $titlename = "<table border=1>
  3369. <tr align='center'>
  3370. <td>编码号</td>
  3371. <td>SKU</td>
  3372. <td>增减数量(正数或负数)</td>
  3373. <td>扣减备注</td>
  3374. <td>扣减方式:0减少库存1删除库存</td>
  3375. <td>所属仓库</td>
  3376. </tr>
  3377. </table>";
  3378. $filename = $title.".xls";
  3379. $tail = "";
  3380. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3381. }
  3382. }
  3383. //数量调整模板导入
  3384. public function _presetedit()
  3385. {
  3386. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3387. $config['upload_path'] = '.'.$dir ;
  3388. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3389. $config['allowed_types'] = 'xls|xlsx|csv';
  3390. $config['max_size'] = 10240;
  3391. $this->load->library('upload', $config);
  3392. $this->upload->initialize($config);
  3393. if ($this->upload->do_upload('userfile'))
  3394. {
  3395. $full_path = $dir.$this->upload->data('file_name');
  3396. $fileName = '.' . $full_path;
  3397. if (!file_exists($fileName))
  3398. {
  3399. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3400. }
  3401. else
  3402. {
  3403. libxml_use_internal_errors(true);
  3404. require_once "./data/excel/PHPExcel/IOFactory.php";
  3405. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3406. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3407. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3408. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3409. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3410. ++$column;//如果列数大于26行
  3411. $list = array();
  3412. for ($i = 2; $i <= $row; $i++) // 行数循环
  3413. {
  3414. $data = array();
  3415. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3416. {
  3417. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3418. }
  3419. $list[] = $data;
  3420. }
  3421. }
  3422. $i = 0;$j = 0;$ed = array();
  3423. foreach ($list as $key=>$value)
  3424. {
  3425. $time = time();
  3426. if($value['0'] == "")
  3427. {
  3428. continue;
  3429. }
  3430. $features = $value['0'];
  3431. $num = $value['2'];//调整数量
  3432. $text = $value['3'];//扣减说明
  3433. $type = $value['4'];//调整方式0扣减1删除
  3434. $d = $this->specialstock->get_features($features);
  3435. if(!$d)//如果没有这个SKU
  3436. {
  3437. $ed[] = array($title.'-库存中不存在此编码');
  3438. $j++;
  3439. continue;
  3440. }
  3441. if($num < 0)//扣减库存
  3442. {
  3443. $data = $this->specialstock->find_all('warehouse = "'.$warehouse['id'].'" and features = "'.$features.'" and zd = "" and state = 0');
  3444. if(count($data) < abs($num))
  3445. {
  3446. $ed[] = array($title.'-扣减数量大于库存剩余数量!');
  3447. $j++;
  3448. continue;
  3449. }
  3450. if($type == 0)//如果扣减方式为 扣减库存
  3451. {
  3452. for($i=0;$i<abs($num);$i++)
  3453. {
  3454. $this->specialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$data[$i]['id']);
  3455. }
  3456. }
  3457. else
  3458. {
  3459. for($i=0;$i<abs($num);$i++)
  3460. {
  3461. $this->specialstock->remove($data[$i]['id']);
  3462. }
  3463. }
  3464. }
  3465. else if($num > 0)//增加库存
  3466. {
  3467. $post['shop'] = $d['shop'];
  3468. $post['purchase'] = $d['purchase'];
  3469. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  3470. $post['state'] = 0;
  3471. $post['title'] = $d['title'];
  3472. $post['number'] = $d['number'];
  3473. $post['features'] = $d['features'];
  3474. $post['enter'] = $time;
  3475. $post['time'] = $time;//操作时间
  3476. for($i=0;$i<$num;$i++)
  3477. {
  3478. $post['label'] = time().rand(100,999).$i;
  3479. $this->specialstock->insert($post);
  3480. }
  3481. }
  3482. sleep(1);//防止入库时间一样,需要延迟1秒
  3483. }
  3484. if($j > 0)
  3485. {
  3486. $tt = date('Ymd',time());
  3487. $title = '库存导入错误信息-'.$tt;
  3488. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3489. $tail = "\n";
  3490. $filename = $title.".xls";
  3491. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3492. $dir = '/data/excel/'.$time.'/';
  3493. $file_name = 'error_'.$time.rand(1000,9999);
  3494. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3495. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3496. fwrite($myfile,$ecl);
  3497. fclose($myfile);
  3498. $error = $dir.$file_name.'.xls';
  3499. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  3500. }
  3501. else
  3502. {
  3503. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  3504. }
  3505. }
  3506. }
  3507. //笛卡儿积
  3508. function cp($ps,$sets,$list)
  3509. {
  3510. $result = array();$j=0;
  3511. for($i=0,$count=count($sets); $i<$count-1; $i++)
  3512. {
  3513. if($i==0)
  3514. {
  3515. $result = $sets[$i];
  3516. }
  3517. $tmp = array();
  3518. foreach($result as $res)
  3519. {
  3520. foreach($sets[$i+1] as $set)
  3521. {
  3522. $tmp[] = $res.','.$set;
  3523. }
  3524. }
  3525. $result = $tmp;
  3526. }
  3527. $this->db->trans_begin();
  3528. foreach ($result as $v)
  3529. {
  3530. $post = array();$title = "";$num="";
  3531. $data = explode(',',$v);
  3532. for($i=0;$i<count($list); $i++)
  3533. {
  3534. $post[$list[$i]] = $data[$i];
  3535. $typeclass = $this->typeclass->read($data[$i]);
  3536. $title = $title.$typeclass['title']." ";
  3537. if($data[$i] != 0)
  3538. {
  3539. $num .=$data[$i];//所有数据ID拼接
  3540. }
  3541. }
  3542. foreach ($ps as $kp=>$vp)
  3543. {
  3544. $post[$kp] = $vp;
  3545. }
  3546. $post['number'] = $num;
  3547. $info_list = $this->specialstock->get_number($num);//查询specialstock是否存在此拼接的数据ID
  3548. if($info_list)
  3549. {
  3550. $j++;
  3551. }
  3552. else
  3553. {
  3554. $skunum = $this->specialstock->find_count();
  3555. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  3556. $post['title'] = rtrim($title,' ');
  3557. $this->specialstock->insert($post);
  3558. }
  3559. }
  3560. if ($this->db->trans_status() === FALSE)
  3561. {
  3562. $this->db->trans_commit();
  3563. return NULL;
  3564. }
  3565. else
  3566. {
  3567. $this->db->trans_commit();
  3568. return $j;
  3569. }
  3570. }
  3571. public function _kj($arg_array)
  3572. {
  3573. if(isset($_POST['number']))
  3574. {
  3575. $time = time();
  3576. $number = $this->input->post('number',true);
  3577. $num = $this->input->post('num',true);
  3578. $text = $this->input->post('text',true);
  3579. $order = $this->specialstock->find_all("number = '$number' and zd = '' and state = 0");
  3580. if($num > count($order))
  3581. {
  3582. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  3583. }
  3584. else
  3585. {
  3586. for($i=0;$i<$num;$i++)
  3587. {
  3588. $this->specialstock->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$order[$i]['id']);
  3589. }
  3590. }
  3591. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  3592. }
  3593. $uid = $this->specialstock->read($arg_array[0]);
  3594. $uid['num'] = $this->specialstock->find_count('number = "'.$uid['number']. '" and zd = "" and state = 0');
  3595. $this->data['data'] = $uid ;
  3596. $this->_Template('specialstock_kj',$this->data);
  3597. }
  3598. public function _summary($arg_array)
  3599. {
  3600. if(isset($_GET['excel']))
  3601. {
  3602. $ktime = $this->input->get('ktime',true);
  3603. $jtime = $this->input->get('jtime',true);
  3604. $ktime = strtotime($ktime);
  3605. $jtime = strtotime($jtime);
  3606. $where = "1=1";
  3607. if($ktime && $jtime)
  3608. {
  3609. $where .= " and outk > '$ktime' and outk < '$jtime'";
  3610. }
  3611. //数据排序
  3612. $order_str = "time desc";
  3613. if(empty($page))
  3614. {
  3615. $start = 0;
  3616. $perpage = 1;
  3617. }
  3618. else
  3619. {
  3620. $start = ($page - 1)*$perpage;
  3621. }
  3622. $pc = $this->input->get('pc',true);
  3623. if($pc)
  3624. {
  3625. $pc = trim($pc,'x');
  3626. $pc = explode('x',$pc);
  3627. foreach ($pc as $v)
  3628. {
  3629. $where .= " and warehouse != '".$v."'";
  3630. }
  3631. }
  3632. //取得信息列表
  3633. $info_list = $this->specialstock->find_pc($where,'number','*');
  3634. foreach ($info_list as $value)
  3635. {
  3636. $xcpid = '';$scpid = '';
  3637. $x = $this->specialstock->find_all($where.' and number = "'.$value['number'].'"');
  3638. foreach ($x as $v)
  3639. {
  3640. if($v['cpid'] != 0)
  3641. {
  3642. $xcpid .= $v['cpid'].' ';
  3643. }
  3644. }
  3645. $s = $this->specialstock->find_all('state = 0 and number = "'.$value['number'].'"');
  3646. foreach ($s as $v)
  3647. {
  3648. if($v['cpid'] != 0)
  3649. {
  3650. $scpid .= $v['cpid'].' ';
  3651. }
  3652. }
  3653. $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']));
  3654. }
  3655. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  3656. $titlename = "<table border=1>
  3657. <tr align='center'>
  3658. <td>仓库备注</td>
  3659. <td>产品名</td>
  3660. <td>总剩余库存</td>
  3661. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  3662. <td>剩余产品编码</td>
  3663. <td>销售产品编码</td>
  3664. <td>出库时间</td>
  3665. </tr>
  3666. </table>";
  3667. $filename = $title.".xls";
  3668. $tail = "";
  3669. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3670. }
  3671. }
  3672. //usps发货清单
  3673. public function _manifest()
  3674. {
  3675. if(isset($_POST['manifest']))
  3676. {
  3677. $wltext = $this->input->post('wltext',true);
  3678. $time = time()-16*3600;
  3679. $ptime = strtotime(date('Y-m-d',$time));
  3680. $waybill = array();
  3681. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  3682. foreach ($fullorder as $v)
  3683. {
  3684. $waybill[$v['waybill']] = $v['waybill'];
  3685. }
  3686. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  3687. foreach ($fullordersmt as $v)
  3688. {
  3689. $waybill[$v['waybill']] = $v['waybill'];
  3690. }
  3691. $wltext = explode(';',$wltext);
  3692. foreach ($wltext as $v)
  3693. {
  3694. if(isset($waybill[$v]))
  3695. {
  3696. unset($waybill[$v]);
  3697. }
  3698. }
  3699. $data = $this->usps->get_manifest($waybill);
  3700. if(isset($data['Description']))
  3701. {
  3702. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  3703. }
  3704. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  3705. {
  3706. $bctime = date('Ymd',time());
  3707. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  3708. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  3709. }
  3710. else
  3711. {
  3712. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  3713. }
  3714. }
  3715. }
  3716. public function _pdf($pdf,$title,$bctime)
  3717. {
  3718. $pdf_path = './data/pdf/'.$bctime.'/';
  3719. $file_base64 = $pdf;
  3720. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  3721. $file_base64 = base64_decode($file_base64);
  3722. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  3723. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  3724. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  3725. }
  3726. /**
  3727. *
  3728. *
  3729. *
  3730. 进销存占单异常索引
  3731. *
  3732. *
  3733. *
  3734. **/
  3735. public function _abnormal()
  3736. {
  3737. $post = $this->input->post(NULL, TRUE);
  3738. if(isset($post['page']))
  3739. {
  3740. $page = $this->input->post('page',true);
  3741. $perpage = $this->input->post('perpage',true);
  3742. $sku = $this->input->post('sku',true);
  3743. $where = "1=1";
  3744. //数据排序
  3745. $order_str = "id desc";
  3746. if(empty($page))
  3747. {
  3748. $start = 0;
  3749. $perpage = 1;
  3750. }
  3751. else
  3752. {
  3753. $start = ($page - 1)*$perpage;
  3754. }
  3755. //取得信息列表
  3756. $info_list = $this->specialstock->find_all($where,'*');
  3757. $rows = array();$list = array();
  3758. foreach ($info_list as $key=>$value)
  3759. {
  3760. $rows[$value['sku']] = $value;//所有数据sku
  3761. }
  3762. foreach ($rows as $value)
  3763. {
  3764. $warehouse = $this->warehouse->read($value['warehouse']);
  3765. $c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  3766. $number = $value['number'];$ftime = time()-15*24*3600;
  3767. if($value['shop'] != '')
  3768. {
  3769. $shop = $value['shop'];
  3770. $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');
  3771. $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');
  3772. $order = array_merge($orderdlz,$ordersmt);
  3773. $od = 0;$a = '';$orid = '';
  3774. foreach ($order as $v)
  3775. {
  3776. $or = explode('|',ltrim($v['specialstock'],'|'));
  3777. for($i=0;$i<count($or);$i++)
  3778. {
  3779. $orod = explode('-',$or[$i]);
  3780. if($orod[0] == $number)
  3781. {
  3782. $od += $orod[1];
  3783. }
  3784. }
  3785. $orid .= $v['number'].'-';
  3786. }
  3787. }
  3788. else
  3789. {
  3790. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  3791. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and specialstock like '%|$number-%'",'specialstock,shop,orderinfo,number');
  3792. $order = array_merge($orderdlz,$ordersmt);
  3793. $od = 0;$a = '';$orid = '';$qt = array();
  3794. foreach ($order as $v)
  3795. {
  3796. $or = explode('|',ltrim($v['specialstock'],'|'));
  3797. for($i=0;$i<count($or);$i++)
  3798. {
  3799. $orod = explode('-',$or[$i]);
  3800. if($orod[0] == $number)
  3801. {
  3802. $czzs = $this->specialstock->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  3803. if($czzs > 0)
  3804. {
  3805. if(isset($qt[$v['shop']]))
  3806. {
  3807. if($qt[$v['shop']] < $orod[1])
  3808. {
  3809. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  3810. $orid .= $v['number'].'+数量'.$orod[1].'-';
  3811. }
  3812. else
  3813. {
  3814. $qt[$v['shop']] -= $orod[1];
  3815. }
  3816. }
  3817. else
  3818. {
  3819. $qt[$v['shop']] = $czzs;
  3820. }
  3821. }
  3822. else
  3823. {
  3824. $od += $orod[1];
  3825. $orid .= $v['number'].'+数量'.$orod[1].'-';
  3826. }
  3827. }
  3828. }
  3829. }
  3830. }
  3831. $z = $od.'('.$orid.')';//查看订单号
  3832. //$z = $od;
  3833. if($od > $c)
  3834. {
  3835. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  3836. }
  3837. }
  3838. $listdata = array_slice($list,$start,$perpage);
  3839. $total = count($list);
  3840. $pagenum = ceil($total/$perpage);
  3841. $over = $total-($start+$perpage);
  3842. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  3843. echo json_encode($rows);exit;
  3844. }
  3845. $this->_Template('specialstock_abnormal',$this->data);
  3846. }
  3847. /**
  3848. *
  3849. *
  3850. *
  3851. 进销存占单异常索引
  3852. *
  3853. *
  3854. *
  3855. **/
  3856. public function _error()
  3857. {
  3858. $post = $this->input->post(NULL, TRUE);
  3859. if(isset($post['page']))
  3860. {
  3861. $page = $this->input->post('page',true);
  3862. $perpage = $this->input->post('perpage',true);
  3863. $sku = $this->input->post('sku',true);
  3864. $warehouse = $this->input->post('warehouse',true);
  3865. $where = "1=1";
  3866. if($sku)
  3867. {
  3868. $where .= " and sku = '$sku'";
  3869. }
  3870. if($warehouse)
  3871. {
  3872. $where .= " and warehouse = '$warehouse'";
  3873. }
  3874. //数据排序
  3875. $order_str = "id desc";
  3876. if(empty($page))
  3877. {
  3878. $start = 0;
  3879. $perpage = 1;
  3880. }
  3881. else
  3882. {
  3883. $start = ($page - 1)*$perpage;
  3884. }
  3885. //取得信息列表
  3886. $info_list = $this->specialstock->find_all($where,'*');
  3887. $rows = array();$list = array();
  3888. foreach ($info_list as $key=>$value)
  3889. {
  3890. if($value['sku'] != '')
  3891. {
  3892. $rows[$value['sku']] = $value;//所有数据sku
  3893. }
  3894. }
  3895. foreach ($rows as $value)
  3896. {
  3897. $warehouse = $this->warehouse->read($value['warehouse']);
  3898. $c = $this->specialstock->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  3899. $number = $value['number'];$ftime = time()-15*24*3600;
  3900. if($c < 1)
  3901. {
  3902. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  3903. }
  3904. }
  3905. $listdata = array_slice($list,$start,$perpage);
  3906. $total = count($list);
  3907. $pagenum = ceil($total/$perpage);
  3908. $over = $total-($start+$perpage);
  3909. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  3910. echo json_encode($rows);exit;
  3911. }
  3912. if(isset($post['s']))
  3913. {
  3914. $id_arr = $this->input->post('s');
  3915. $id_arr = explode(',',$id_arr);
  3916. if(!$id_arr)
  3917. {
  3918. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3919. }
  3920. //循环删除记录
  3921. foreach ($id_arr as $v)
  3922. {
  3923. $dd = $this->specialstock->read($v);
  3924. $deldd = $this->specialstock->find_all("sku = '".$dd['sku']."'");
  3925. foreach ($deldd as $vv)
  3926. {
  3927. $this->specialstock->remove($vv['id']);
  3928. }
  3929. }
  3930. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  3931. }
  3932. $this->_Template('specialstock_error',$this->data);
  3933. }
  3934. /**
  3935. *
  3936. *
  3937. * 占单
  3938. *
  3939. *
  3940. **/
  3941. public function _kcyz()
  3942. {
  3943. $post = $this->input->post(NULL, TRUE);
  3944. if(isset($post['warehouse']))
  3945. {
  3946. $warehouse = $this->input->post('warehouse',true);
  3947. $specialstock = $this->input->post('specialstock',true);
  3948. $id = $this->input->post('id',true);
  3949. $shop = $this->input->post('shop',true);
  3950. $number = $this->input->post('number',true);
  3951. if(!$specialstock || $specialstock == '|')
  3952. {
  3953. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  3954. }
  3955. $pp = explode('|',trim($specialstock,'|'));
  3956. $x = 0;$save = array();
  3957. foreach ($pp as $va)
  3958. {
  3959. $num = explode('-',$va);
  3960. if($number)
  3961. {
  3962. $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 = '')");//通用
  3963. $shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  3964. }
  3965. else
  3966. {
  3967. $specialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  3968. $shopspecialstock = $this->specialstock->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  3969. }
  3970. $x++;
  3971. if(count($specialstock)+count($shopspecialstock) < $num[1])
  3972. {
  3973. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  3974. }
  3975. }
  3976. if(isset($save[0]))
  3977. {
  3978. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  3979. }
  3980. else
  3981. {
  3982. echo json_encode(array('success'=>true));exit;
  3983. }
  3984. }
  3985. }
  3986. public function _hwwz()//货物位置
  3987. {
  3988. if(isset($_GET['id']))
  3989. {
  3990. $id = $this->input->get('id',true);
  3991. $sku = $this->input->get('sku',true);
  3992. $bs = $this->input->get('bs',true);
  3993. $number = $this->input->get('number',true);
  3994. $warehouse = $this->input->get('warehouse',true);
  3995. $purchase = $this->input->get('purchase',true);
  3996. $orderinfo = $this->input->get('orderinfo',true);
  3997. $waybill = $this->input->get('waybill',true);
  3998. $category = $this->input->get('category',true);
  3999. $size = $this->input->get('size',true);
  4000. $grade = $this->input->get('grade',true);
  4001. $color = $this->input->get('color',true);
  4002. $lowe = $this->input->get('lowe',true);
  4003. $state = $this->input->get('state',true);
  4004. $label = $this->input->get('label',true);
  4005. $px = $this->input->get('px',true);
  4006. $details = $this->input->get('details',true);
  4007. $timetk = $this->input->get('timetkk',true);
  4008. $timetj = $this->input->get('timetjj',true);
  4009. $timetk = strtotime($timetk);
  4010. $timetj = strtotime($timetj);
  4011. $where = "state='0'";
  4012. //数据排序
  4013. $order_str = $px." desc";
  4014. if(empty($page))
  4015. {
  4016. $start = 0;
  4017. $perpage = 1;
  4018. }
  4019. else
  4020. {
  4021. $start = ($page - 1)*$perpage;
  4022. }
  4023. $category = $this->input->get('category',true);
  4024. $warehouse = $this->input->get('warehouse',true);
  4025. if($category)
  4026. {
  4027. $where .= " and features like '%-$category-%'";
  4028. }
  4029. if($warehouse)
  4030. {
  4031. $where .= " and warehouse = '$warehouse'";
  4032. }
  4033. if($details)
  4034. {
  4035. $where .= " and details = '$details'";
  4036. }
  4037. if($id != '')
  4038. {
  4039. $sid = "";
  4040. $usersp = explode(',',trim($id,','));
  4041. foreach ($usersp as $value)
  4042. {
  4043. $sid .= " id = ".$value." or";
  4044. }
  4045. $info_list = $this->specialstock->find_all($where." and (".rtrim($sid,'or').")",'*','details desc');
  4046. }
  4047. else
  4048. {
  4049. $info_list = $this->specialstock->find_all($where,'*','details desc');
  4050. }
  4051. $rows = array();$list = array();
  4052. foreach ($info_list as $key=>$value)
  4053. {
  4054. $rows[$value['sku'].$value['warehouse'].$value['details']] = $value;//所有数据sku
  4055. }
  4056. foreach ($rows as $value)
  4057. {
  4058. $classid = $this->classid->sku();
  4059. $pm = $classid;
  4060. //$scsku = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',7=>'','dc'=>'','c'=>'',14=>'',12=>'',25=>'',26=>'',27=>'',10=>'',6=>'',9=>'',999=>'',9999=>'');
  4061. $features = explode('-',trim($value['features'],'-'));
  4062. foreach ($features as $v)
  4063. {
  4064. $typeclass = $this->typeclass->read($v);
  4065. $pm[$typeclass['classid']] = $typeclass['zh'];
  4066. //$scsku[$typeclass['classid']] = $typeclass['bqsku'];
  4067. }
  4068. $typeclass = $this->typeclass->read($v);
  4069. //$scsku = implode("-",$scsku);
  4070. $zh = implode(" ",$pm);
  4071. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  4072. //$scsku = str_replace('- ','-',trim($scsku,'-'));
  4073. //$scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  4074. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and details = "'.$value['details'].'" and warehouse = "'.$value['warehouse'].'" and state = "0"');
  4075. $number = $value['number'];$ftime = time()-15*24*3600;
  4076. $warehouse = $this->warehouse->read($value['warehouse']);
  4077. $list[] = array($value['id'],$value['details'],$zh,$c);
  4078. }
  4079. $title = "库存表";
  4080. $titlename = "";
  4081. $filename = $title.".xls";
  4082. $tail = "";
  4083. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4084. }
  4085. }
  4086. public function _order()
  4087. {
  4088. $post = $this->input->post(NULL, TRUE);
  4089. if(isset($arg_array[0]))
  4090. {
  4091. if($arg_array[0] == 'del')
  4092. {
  4093. $s = $this->input->post('s',true);
  4094. $del = $this->_del($s);
  4095. echo $del;exit;
  4096. }
  4097. }
  4098. if(isset($post['page']))
  4099. {
  4100. $page = $this->input->post('page',true);
  4101. $perpage = $this->input->post('perpage',true);
  4102. $category = $this->input->post('category',true);
  4103. $size = $this->input->post('size',true);
  4104. $grade = $this->input->post('grade',true);
  4105. $color = $this->input->post('color',true);
  4106. $lowe = $this->input->post('lowe',true);
  4107. $sku = $this->input->post('sku',true);
  4108. $details = $this->input->post('details',true);
  4109. $warehouse = $this->input->post('warehouse',true);
  4110. $purchase = $this->input->post('purchase',true);
  4111. $lacetype = $this->input->post('lacetype',true);
  4112. $state = $this->input->post('state',true);
  4113. $ktime = $this->input->post('ktime',true);
  4114. $jtime = $this->input->post('jtime',true);
  4115. $ktime = strtotime($ktime);
  4116. $jtime = strtotime($jtime);
  4117. $where = "zd =''";$gj = "";$ck = "";
  4118. if($category)
  4119. {
  4120. $where .= " and features like '%-$category-%'";
  4121. }
  4122. if($size)
  4123. {
  4124. $where .= " and features like '%-$size-%'";
  4125. }
  4126. if($grade)
  4127. {
  4128. $where .= " and features like '%-$grade-%'";
  4129. }
  4130. if($color)
  4131. {
  4132. $where .= " and features like '%-$color-%'";
  4133. }
  4134. if($lowe)
  4135. {
  4136. $where .= " and features like '%-$lowe-%'";
  4137. }
  4138. if($lacetype)
  4139. {
  4140. $where .= " and features like '%-$lacetype-%'";
  4141. }
  4142. if($warehouse)
  4143. {
  4144. $where .= " and warehouse = '$warehouse'";
  4145. }
  4146. if($purchase)
  4147. {
  4148. $where .= " and purchase = '$purchase'";
  4149. }
  4150. if($state)
  4151. {
  4152. $where .= " and state = '$state'";
  4153. }
  4154. if($sku)
  4155. {
  4156. $where .= " and sku like '%$sku%'";
  4157. }
  4158. if($details)
  4159. {
  4160. $where .= " and details like '%$details%'";
  4161. }
  4162. if($ktime && $jtime)
  4163. {
  4164. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4165. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4166. }
  4167. //数据排序
  4168. $order_str = "id desc";
  4169. if(empty($page))
  4170. {
  4171. $start = 0;
  4172. $perpage = 1;
  4173. }
  4174. else
  4175. {
  4176. $start = ($page - 1)*$perpage;
  4177. }
  4178. //取得信息列表
  4179. $info_list = $this->specialstock->find_all($where,'*');
  4180. $rows = array();$list = array();
  4181. foreach ($info_list as $key=>$value)
  4182. {
  4183. $rows[$value['number'].$value['warehouse']] = $value;//所有数据sku
  4184. }
  4185. $rowsdq = array_slice($rows,$start,$perpage);
  4186. $inch = '';$zh = '';
  4187. $classid = $this->classid->sku();
  4188. $pm = $classid;
  4189. foreach ($rowsdq as $value)
  4190. {
  4191. $features = '-';
  4192. $td = explode('-',trim($value['features'],'-'));
  4193. foreach ($td as $va)
  4194. {
  4195. $s = $this->typeclass->read($va);
  4196. if($s['classid'] == '14')
  4197. {
  4198. $c = $va;
  4199. $inch = $s['spare'];
  4200. if(isset($pm[$s['classid']]))
  4201. {
  4202. $pm[$s['classid']] = $s['zh'];
  4203. }
  4204. }
  4205. else
  4206. {
  4207. $features .= $va.'-';
  4208. if(isset($pm[$s['classid']]))
  4209. {
  4210. $pm[$s['classid']] = $s['zh'];
  4211. }
  4212. }
  4213. }
  4214. $features = $c.','.$features;
  4215. $warehouse = $this->warehouse->read($value['warehouse']);
  4216. $cpid = ($value['cpid']>0)?' - 编码:'.$value['cpid']:'';
  4217. $nr = implode(" ",$pm);
  4218. $nr = preg_replace(array('/(\s+)/','/分\s/u'),array(' ','分'),$nr);
  4219. $c = $this->specialstock->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  4220. $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>");
  4221. }
  4222. $total = count($rows);
  4223. $pagenum = ceil($total/$perpage);
  4224. $over = $total-($start+$perpage);
  4225. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  4226. echo json_encode($rows);exit;
  4227. }
  4228. $this->_Template('specialstock_order',$this->data);
  4229. }
  4230. public function _0kcdel($id_arr)
  4231. {
  4232. if($id_arr)
  4233. {
  4234. $id_arr = explode(',',$id_arr);
  4235. $j = count($id_arr);
  4236. $i = 0;
  4237. //循环删除记录
  4238. foreach ($id_arr as $value)
  4239. {
  4240. $data = $this->specialstock->read($value);
  4241. $z = $this->specialstock->find_count('sku = "'.$data['sku'].'" and zd = "" and state = 0 and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
  4242. if($z < 1)
  4243. {
  4244. $z = $this->specialstock->find_all('sku = "'.$data['sku'].'" and warehouse = "'.$data['warehouse'].'" and features = "'.$data['features'].'"');
  4245. foreach ($z as $v)
  4246. {
  4247. $this->specialstock->remove($v['id']);
  4248. }
  4249. $i++;
  4250. }
  4251. }
  4252. if($i != $j && $i != 0)
  4253. {
  4254. return json_encode(array('del'=>$id_arr,'msg'=>'有非0库存数据,0库存删除成功!','success'=>true));
  4255. }
  4256. else if($i != $j && $i == 0)
  4257. {
  4258. return json_encode(array('del'=>$id_arr,'msg'=>'库存非0不允许删除!','success'=>false));
  4259. }
  4260. else
  4261. {
  4262. return json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  4263. }
  4264. }
  4265. else
  4266. {
  4267. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4268. }
  4269. }
  4270. }