Specialstock.php 140 KB

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