Systemdownload.php 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Systemdownload extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_typeclass','typeclass');
  7. $this->load->_model('Model_fullorder','fullorder');
  8. $this->load->_model('Model_fullordertt','fullordertt');
  9. $this->load->_model('Model_fullordersmt','fullordersmt');
  10. $this->load->_model('Model_shop','shop');
  11. $this->load->_model('Model_user','user');
  12. $this->load->_model('Model_excel','excel');
  13. }
  14. //定义方法的调用规则 获取URI第二段值
  15. public function _remap($arg,$arg_array)
  16. {
  17. if($arg == 'data')
  18. {
  19. $this->_data();
  20. }
  21. else if($arg == 'hd')
  22. {
  23. $this->_hd();
  24. }
  25. else if($arg == 'qm')
  26. {
  27. $this->_qm();
  28. }
  29. else if($arg == 'bh')
  30. {
  31. $this->_bh();
  32. }
  33. else if($arg == 'hsp')
  34. {
  35. $this->_hsp();
  36. }
  37. else if($arg == 'list')
  38. {
  39. $this->_list();
  40. }
  41. else if($arg == 'listread')
  42. {
  43. $this->_listread();
  44. }
  45. else
  46. {
  47. $this->_index();
  48. }
  49. }
  50. public function _index()
  51. {
  52. if(isset($_SESSION['api']))
  53. {
  54. $user = $this->user->get_api($_SESSION['api']);
  55. $usp = $user;
  56. $fgshop = "";$sid = "";
  57. $usersp = explode('|',trim($user['shop'],'|'));
  58. foreach ($usersp as $value)
  59. {
  60. $fgshop .= " shop = ".$value." or";
  61. $sid .= " id = ".$value." or";
  62. }
  63. }
  64. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  65. $this->data['wlshop'] = $wlshop;
  66. $this->_Template('systemdownload',$this->data);
  67. }
  68. public function getCombinationToString($val)
  69. {
  70. static $res = array();
  71. if(empty($res))
  72. {
  73. $res = $val;
  74. }
  75. else
  76. {
  77. $list = array();
  78. foreach ($res as $k => $v)
  79. {
  80. foreach ($val as $key => $value)
  81. {
  82. $list[] = $v.','.$value;
  83. }
  84. }
  85. $res = $list;
  86. }
  87. return $res;
  88. }
  89. public function _data()
  90. {
  91. if(isset($_SESSION['api']))
  92. {
  93. $user = $this->user->get_api($_SESSION['api']);
  94. $usp = $user;
  95. $fgshop = "";$sid = "";$excelshop="";
  96. $usersp = explode('|',trim($user['shop'],'|'));
  97. foreach ($usersp as $value)
  98. {
  99. $fgshop .= " shop = ".$value." or";
  100. $sid .= " id = ".$value." or";
  101. }
  102. $userexcel = explode('|',trim($user['excelshop'],'|'));
  103. foreach ($userexcel as $value)
  104. {
  105. $excelshop .= " shop = ".$value." or";
  106. }
  107. if($excelshop != "")
  108. {
  109. $excelshop = "(".rtrim($excelshop,'or').")";
  110. }
  111. }
  112. $post = $this->input->post(NULL, TRUE);
  113. if(isset($_GET['category']))
  114. {
  115. $timetk = $this->input->get('timetk',true);
  116. $timetj = $this->input->get('timetj',true);
  117. $color = $this->input->get('color',true);
  118. $lowe = $this->input->get('lowe',true);
  119. $size = $this->input->get('size',true);
  120. $grade = $this->input->get('grade',true);
  121. $lacetype = $this->input->get('lacetype',true);
  122. $category = $this->input->get('category',true);
  123. $haircap = $this->input->get('haircap',true);
  124. $shop = $this->input->get('shop',true);
  125. $density = $this->input->get('density',true);
  126. $time = $this->input->get('time',true);
  127. $timetk = strtotime($timetk);
  128. $timetj = strtotime($timetj);
  129. $cw = array();
  130. $class = array();$classdata = array();$lx = array();$pm = array();
  131. $a = $this->typeclass->find_all('classid=6 or classid=7 or classid=8 or classid=10 or classid=12 or classid=13 or classid=19 or classid=20 or classid=21 or classid=22 or classid=23 or classid=24');
  132. foreach ($a as $val)
  133. {
  134. $class[] = '-'.$val['id'].'-';
  135. }
  136. $b = $this->typeclass->find_all();
  137. foreach ($b as $val)
  138. {
  139. $classdata[$val['id']] = $val['title'];
  140. $lx[$val['id']] = $val['classid'];
  141. $pm[$val['id']] = $val['zh'];
  142. }
  143. //Closure wigs
  144. $fpdata = '';
  145. $category = explode('|',trim($category,'|'));
  146. foreach ($category as $value)
  147. {
  148. $fpdata .= "fpdata like '%".$value."%' or ";
  149. }
  150. if(count($category) > 1)
  151. {
  152. $fpdata = "(".trim($fpdata,' or ').")";
  153. }
  154. else
  155. {
  156. $fpdata = trim($fpdata,' or ');
  157. }
  158. $where = "";
  159. if($color)
  160. {
  161. $where .= "fpdata like '%$color%' and ";
  162. }
  163. if($size)
  164. {
  165. $where .= "fpdata like '%$size%' and ";
  166. }
  167. if($grade)
  168. {
  169. $where .= "fpdata like '%$grade%' and ";
  170. }
  171. if($shop)
  172. {
  173. $where .= "shop = '$shop' and ";
  174. }
  175. else
  176. {
  177. $where .= $excelshop." and ";
  178. }
  179. if($lowe)
  180. {
  181. $arraydata[] = explode(',',rtrim($lowe,','));
  182. }
  183. else
  184. {
  185. $arraydata[] = array('z');
  186. }
  187. if($density)
  188. {
  189. $arraydata[] = explode(',',rtrim($density,','));
  190. }
  191. else
  192. {
  193. $arraydata[] = array('z');
  194. }
  195. if($lacetype)
  196. {
  197. $arraydata[] = explode(',',rtrim($lacetype,','));
  198. }
  199. else
  200. {
  201. $arraydata[] = array('z');
  202. }
  203. if($haircap)
  204. {
  205. $arraydata[] = explode(',',rtrim($haircap,','));
  206. }
  207. else
  208. {
  209. $arraydata[] = array('z');
  210. }
  211. $res = array();
  212. foreach ($arraydata as $k => $v)
  213. {
  214. $res = $this->getCombinationToString($v);
  215. }
  216. $warp = array();$cs = array();
  217. if(!$res)
  218. {
  219. $res[0] = 1;
  220. }
  221. foreach ($res as $resval)
  222. {
  223. $wheredata = '';$btpm = '';
  224. $resval = explode(',',rtrim($resval,','));
  225. $lowe = $resval[0];$density = $resval[1];$lacetype = $resval[2];$haircap = $resval[3];
  226. if($lowe != 'z')
  227. {
  228. $wheredata .= "fpdata like '%$lowe%' and ";
  229. $btpm .= $pm[$lowe];
  230. }
  231. if($density != 'z')
  232. {
  233. $wheredata .= "fpdata like '%$density%' and ";
  234. $btpm .= $pm[$density];
  235. }
  236. if($lacetype != 'z')
  237. {
  238. $wheredata .= "fpdata like '%$lacetype%' and ";
  239. }
  240. if($haircap != 'z')
  241. {
  242. $wheredata .= "fpdata like '%$haircap%' and ";
  243. $btpm .= $pm[$haircap];
  244. }
  245. $dataa = $this->fullorder->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  246. $datab = $this->fullordersmt->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  247. $datac = $this->fullordertt->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  248. $data = array_merge($dataa,$datab,$datac);
  249. //echo $where."librarytime > '$timetk' and librarytime < '$timetj' and ".$fpdata;
  250. //echo "<pre>";
  251. //print_r($where);
  252. //exit;
  253. $cs = array();
  254. $pd = '';
  255. $p = $class;
  256. $resdata = array();
  257. foreach ($data as $val)
  258. {
  259. $f = explode(';',trim($val['fpdata'],';'));
  260. foreach ($f as $v)
  261. {
  262. if($color)
  263. {
  264. if(stripos($v,'-'.$color.'-') === false)
  265. {
  266. continue;
  267. }
  268. }
  269. if($lowe != 'z')
  270. {
  271. if(stripos($v,'-'.$lowe.'-') === false)
  272. {
  273. continue;
  274. }
  275. }
  276. if($size)
  277. {
  278. if(stripos($v,$size.',') === false)
  279. {
  280. continue;
  281. }
  282. }
  283. if($grade)
  284. {
  285. if(stripos($v,'-'.$grade.'-') === false)
  286. {
  287. continue;
  288. }
  289. }
  290. if($lacetype != 'z')
  291. {
  292. $cs[] = $lacetype;
  293. if(stripos($v,'-'.$lacetype.'-') === false)
  294. {
  295. continue;
  296. }
  297. }
  298. if($density != 'z')
  299. {
  300. if(stripos($v,'-'.$density.'-') === false)
  301. {
  302. continue;
  303. }
  304. }
  305. if($haircap != 'z')
  306. {
  307. if(stripos($v,'-'.$haircap.'-') === false)
  308. {
  309. continue;
  310. }
  311. }
  312. $i = 0;
  313. foreach ($category as $value)
  314. {
  315. if(stripos($v,'-'.$value.'-') !== false)
  316. {
  317. $i++;
  318. }
  319. }
  320. if($i > 0)
  321. {
  322. $e = explode('|',$v);
  323. $d = str_replace($p,'-',$e[0]);
  324. $q = str_replace(array('-163-','-164-','-165-','-166-'),'-',$e[0]);
  325. $q = explode('-',trim($q,'-'));
  326. $c = explode(',',$e[0]);
  327. if(!isset($resdata[$d]))
  328. {
  329. if(stripos($v,'-126-') !== false)
  330. {
  331. if(!isset($q[4]) || !isset($pm[$q[4]]))
  332. {
  333. continue;
  334. }
  335. @$resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[4],1);//数量、尺寸、曲度、无蕾丝颜色
  336. }
  337. else if(stripos($v,'-127-') !== false)
  338. {
  339. if(isset($q[9]))
  340. {
  341. $s = ($q[9] != 68 && $q[9] != 69)?1:2;
  342. }
  343. else
  344. {
  345. $s = 1;
  346. }
  347. $bt = (!isset($q[8]))?$q[5]:$q[8];//360类型的蕾丝尺寸直接显示为类型名称
  348. if($lx[$q[5]] == '27')//如果是发块类型
  349. {
  350. $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$bt,$s);//数量、尺寸、类型、蕾丝尺寸、蕾丝颜色
  351. }
  352. }
  353. else
  354. {
  355. if(isset($q[8]))
  356. {
  357. $s = ($q[8] != 68 && $q[8] != 69)?1:2;
  358. }
  359. else
  360. {
  361. $s = 1;
  362. }
  363. if(@$lx[$q[5]] == '18')//如果是头套种类
  364. {
  365. $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$s);//数量、尺寸、头套种类、蕾丝颜色
  366. }
  367. }
  368. }
  369. else
  370. {
  371. if(isset($e[2]))
  372. {
  373. if(is_array($e[2]) || !is_numeric($e[2]))
  374. {
  375. $cw[] = $v;
  376. continue;
  377. }
  378. else
  379. {
  380. $resdata[$d][0] += $e[2];
  381. }
  382. }
  383. }
  384. }
  385. }
  386. }
  387. $data = array();
  388. foreach ($resdata as $v)
  389. {
  390. if(isset($v[4]))
  391. {
  392. if(!isset($data[$v[1].$v[2].$v[3].$v[4]]))
  393. {
  394. $data[$v[1].$v[2].$v[3].$v[4]] = array($v[0],$v[1],$pm[$v[2]],$classdata[$v[3]],$v[4]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
  395. }
  396. else
  397. {
  398. $data[$v[1].$v[2].$v[3].$v[4]][0] += $v[0];
  399. }
  400. }
  401. else
  402. {
  403. if(!isset($data[$v[1].$v[2].$v[3]]))
  404. {
  405. $data[$v[1].$v[2].$v[3]] = array($v[0],$v[1],$pm[$v[2]],$v[3]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
  406. }
  407. else
  408. {
  409. $data[$v[1].$v[2].$v[3]][0] += $v[0];
  410. }
  411. }
  412. }
  413. $list = array();
  414. foreach ($data as $v)
  415. {
  416. $x = (isset($v[4]))?$v[3]:$v[2];
  417. if(!isset($list[$v[2]]))
  418. {
  419. $list[$v[2]] = array();
  420. if(!isset($list[$v[2]][$x]))
  421. {
  422. $list[$v[2]][$x] = array();
  423. $list[$v[2]][$x][] = $v;
  424. }
  425. else
  426. {
  427. $list[$v[2]][$x][] = $v;
  428. }
  429. }
  430. else
  431. {
  432. if(!isset($list[$v[2]][$x]))
  433. {
  434. $list[$v[2]][$x] = array();
  435. $list[$v[2]][$x][] = $v;
  436. }
  437. else
  438. {
  439. $list[$v[2]][$x][] = $v;
  440. }
  441. }
  442. }
  443. foreach ($list as $key=>$val)
  444. {
  445. foreach ($val as $k=>$va)
  446. {
  447. $dd = array();
  448. foreach ($va as $v)
  449. {
  450. $ss = (!isset($v[4]))?$v[3]:$v[4];
  451. if(!isset($dd[$v['1']]))
  452. {
  453. $dd[$v['1']] = array();
  454. $dd[$v['1']][$ss] = $v;
  455. }
  456. else
  457. {
  458. $dd[$v['1']][$ss] = $v;
  459. }
  460. }
  461. ksort($dd);
  462. $list[$key][$k] = $dd;
  463. }
  464. }
  465. $warp[] = array($btpm,$list);
  466. }
  467. //echo count($list);
  468. //echo "<pre>";
  469. //print_r($warp);
  470. //exit;
  471. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  472. <head>
  473. <!--[if gte mso 9]><xml>
  474. <x:ExcelWorkbook>
  475. <x:ExcelWorksheets>
  476. <x:ExcelWorksheet>
  477. <x:Name>EXCEL</x:Name>
  478. <x:WorksheetOptions>
  479. <x:Print>
  480. <x:ValidPrinterInfo />
  481. </x:Print>
  482. </x:WorksheetOptions>
  483. </x:ExcelWorksheet>
  484. </x:ExcelWorksheets>
  485. </x:ExcelWorkbook>
  486. </xml>
  487. <![endif]-->
  488. </head><body>";
  489. foreach ($warp as $list)
  490. {
  491. foreach ($list[1] as $key=>$val)
  492. {
  493. $btnum = count($val);
  494. $str .= "<table border=1>
  495. <tr>";
  496. foreach ($val as $k=>$v)
  497. {
  498. $str .="<td style='background-color: #ffff00;color: #F00;width:20px'>".$k.' '.$list[0]."</td>
  499. <td>中棕</td>
  500. <td>透明</td>";
  501. }
  502. $str .= "</tr>
  503. </table>";
  504. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'><tr>";
  505. foreach ($val as $k=>$v)
  506. {
  507. $str .= "<td><table border=1>";
  508. foreach ($v as $sk=>$s)
  509. {
  510. $xk1 = (isset($s[1]))?$s[1][0]:0;
  511. $xk2 = (isset($s[2]))?$s[2][0]:0;
  512. $str .="<tr><td style='color: #F00;'>".$sk."</td><td>".$xk1."</td><td>".$xk2."</td></tr>";
  513. }
  514. $str .= "</table></td>";
  515. }
  516. $str .= "</table>";
  517. }
  518. }
  519. $str .= "</body></html>";
  520. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  521. header( "Content-type: application/octet-stream" );
  522. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  523. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  524. header( "Pragma: no-cache" );
  525. header( "Expires: 0" );
  526. exit($str);
  527. }
  528. }
  529. public function _hd()//区分HD和其他颜色
  530. {
  531. if(isset($_SESSION['api']))
  532. {
  533. $user = $this->user->get_api($_SESSION['api']);
  534. $usp = $user;
  535. $fgshop = "";$sid = "";$excelshop="";
  536. $usersp = explode('|',trim($user['shop'],'|'));
  537. foreach ($usersp as $value)
  538. {
  539. $fgshop .= " shop = ".$value." or";
  540. $sid .= " id = ".$value." or";
  541. }
  542. $userexcel = explode('|',trim($user['excelshop'],'|'));
  543. foreach ($userexcel as $value)
  544. {
  545. $excelshop .= " shop = ".$value." or";
  546. }
  547. if($excelshop != "")
  548. {
  549. $excelshop = "(".rtrim($excelshop,'or').")";
  550. }
  551. }
  552. $post = $this->input->post(NULL, TRUE);
  553. if(isset($_GET['category']))
  554. {
  555. $timetk = $this->input->get('timetk',true);
  556. $timetj = $this->input->get('timetj',true);
  557. $color = $this->input->get('color',true);
  558. $lowe = $this->input->get('lowe',true);
  559. $size = $this->input->get('size',true);
  560. $grade = $this->input->get('grade',true);
  561. $lacetype = $this->input->get('lacetype',true);
  562. $category = $this->input->get('category',true);
  563. $haircap = $this->input->get('haircap',true);
  564. $shop = $this->input->get('shop',true);
  565. $density = $this->input->get('density',true);
  566. $time = $this->input->get('time',true);
  567. $timetk = strtotime($timetk);
  568. $timetj = strtotime($timetj);
  569. $cw = array();
  570. $class = array();$classdata = array();$lx = array();$pm = array();
  571. $a = $this->typeclass->find_all('classid=6 or classid=7 or classid=8 or classid=10 or classid=12 or classid=13 or classid=19 or classid=20 or classid=21 or classid=22 or classid=23 or classid=24');
  572. foreach ($a as $val)
  573. {
  574. $class[] = '-'.$val['id'].'-';
  575. }
  576. $b = $this->typeclass->find_all();
  577. foreach ($b as $val)
  578. {
  579. $classdata[$val['id']] = $val['title'];
  580. $lx[$val['id']] = $val['classid'];
  581. $pm[$val['id']] = $val['zh'];
  582. }
  583. //Closure wigs
  584. $fpdata = '';
  585. $category = explode('|',trim($category,'|'));
  586. foreach ($category as $value)
  587. {
  588. $fpdata .= "fpdata like '%".$value."%' or ";
  589. }
  590. if(count($category) > 1)
  591. {
  592. $fpdata = "(".trim($fpdata,' or ').")";
  593. }
  594. else
  595. {
  596. $fpdata = trim($fpdata,' or ');
  597. }
  598. $where = "";
  599. if($color)
  600. {
  601. $where .= "fpdata like '%$color%' and ";
  602. }
  603. if($size)
  604. {
  605. $where .= "fpdata like '%$size%' and ";
  606. }
  607. if($grade)
  608. {
  609. $where .= "fpdata like '%$grade%' and ";
  610. }
  611. if($shop)
  612. {
  613. $where .= "shop = '$shop' and ";
  614. }
  615. else
  616. {
  617. $where .= $excelshop." and ";
  618. }
  619. if($lowe)
  620. {
  621. $arraydata[] = explode(',',rtrim($lowe,','));
  622. }
  623. else
  624. {
  625. $arraydata[] = array('z');
  626. }
  627. if($density)
  628. {
  629. $arraydata[] = explode(',',rtrim($density,','));
  630. }
  631. else
  632. {
  633. $arraydata[] = array('z');
  634. }
  635. if($lacetype)
  636. {
  637. $arraydata[] = explode(',',rtrim($lacetype,','));
  638. }
  639. else
  640. {
  641. $arraydata[] = array('z');
  642. }
  643. if($haircap)
  644. {
  645. $arraydata[] = explode(',',rtrim($haircap,','));
  646. }
  647. else
  648. {
  649. $arraydata[] = array('z');
  650. }
  651. $res = array();
  652. foreach ($arraydata as $k => $v)
  653. {
  654. $res = $this->getCombinationToString($v);
  655. }
  656. $warp = array();$cs = array();
  657. if(!$res)
  658. {
  659. $res[0] = 1;
  660. }
  661. foreach ($res as $resval)
  662. {
  663. $wheredata = '';$btpm = '';
  664. $resval = explode(',',rtrim($resval,','));
  665. $lowe = $resval[0];$density = $resval[1];$lacetype = $resval[2];$haircap = $resval[3];
  666. if($lowe != 'z')
  667. {
  668. $wheredata .= "fpdata like '%$lowe%' and ";
  669. $btpm .= $pm[$lowe];
  670. }
  671. if($density != 'z')
  672. {
  673. $wheredata .= "fpdata like '%$density%' and ";
  674. $btpm .= $pm[$density];
  675. }
  676. if($lacetype != 'z')
  677. {
  678. $wheredata .= "fpdata like '%$lacetype%' and ";
  679. }
  680. if($haircap != 'z')
  681. {
  682. $wheredata .= "fpdata like '%$haircap%' and ";
  683. $btpm .= $pm[$haircap];
  684. }
  685. $dataa = $this->fullorder->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  686. $datab = $this->fullordersmt->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  687. $datac = $this->fullordertt->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  688. $data = array_merge($dataa,$datab,$datac);
  689. //echo $where."librarytime > '$timetk' and librarytime < '$timetj' and ".$fpdata;
  690. //echo "<pre>";
  691. //print_r($where);
  692. //exit;
  693. $cs = array();
  694. $pd = '';
  695. $p = $class;
  696. $resdata = array();
  697. foreach ($data as $val)
  698. {
  699. $f = explode(';',trim($val['fpdata'],';'));
  700. foreach ($f as $v)
  701. {
  702. if($color)
  703. {
  704. if(stripos($v,'-'.$color.'-') === false)
  705. {
  706. continue;
  707. }
  708. }
  709. if($lowe != 'z')
  710. {
  711. if(stripos($v,'-'.$lowe.'-') === false)
  712. {
  713. continue;
  714. }
  715. }
  716. if($size)
  717. {
  718. if(stripos($v,$size.',') === false)
  719. {
  720. continue;
  721. }
  722. }
  723. if($grade)
  724. {
  725. if(stripos($v,'-'.$grade.'-') === false)
  726. {
  727. continue;
  728. }
  729. }
  730. if($lacetype != 'z')
  731. {
  732. $cs[] = $lacetype;
  733. if(stripos($v,'-'.$lacetype.'-') === false)
  734. {
  735. continue;
  736. }
  737. }
  738. if($density != 'z')
  739. {
  740. if(stripos($v,'-'.$density.'-') === false)
  741. {
  742. continue;
  743. }
  744. }
  745. if($haircap != 'z')
  746. {
  747. if(stripos($v,'-'.$haircap.'-') === false)
  748. {
  749. continue;
  750. }
  751. }
  752. $i = 0;
  753. foreach ($category as $value)
  754. {
  755. if(stripos($v,'-'.$value.'-') !== false)
  756. {
  757. $i++;
  758. }
  759. }
  760. if($i > 0)
  761. {
  762. $e = explode('|',$v);
  763. $d = str_replace($p,'-',$e[0]);
  764. $q = str_replace(array('-163-','-164-','-165-','-166-'),'-',$e[0]);
  765. $q = explode('-',trim($q,'-'));
  766. $c = explode(',',$e[0]);
  767. if(!isset($resdata[$d]))
  768. {
  769. if(stripos($v,'-126-') !== false)
  770. {
  771. if(!isset($q[4]) || !isset($pm[$q[4]]))
  772. {
  773. continue;
  774. }
  775. @$resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[4],1);//数量、尺寸、曲度、无蕾丝颜色
  776. }
  777. else if(stripos($v,'-127-') !== false)
  778. {
  779. if(isset($q[9]))
  780. {
  781. $s = ($q[9] != 335)?1:2;
  782. }
  783. else
  784. {
  785. $s = 1;
  786. }
  787. $bt = (!isset($q[8]))?$q[5]:$q[8];//360类型的蕾丝尺寸直接显示为类型名称
  788. if($lx[$q[5]] == '27')//如果是发块类型
  789. {
  790. $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$bt,$s);//数量、尺寸、类型、蕾丝尺寸、蕾丝颜色
  791. }
  792. }
  793. else
  794. {
  795. if(isset($q[8]))
  796. {
  797. $s = ($q[8] != 335)?1:2;
  798. }
  799. else
  800. {
  801. $s = 1;
  802. }
  803. if(@$lx[$q[5]] == '18')//如果是头套种类
  804. {
  805. $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$s);//数量、尺寸、头套种类、蕾丝颜色
  806. }
  807. }
  808. }
  809. else
  810. {
  811. if(isset($e[2]))
  812. {
  813. if(is_array($e[2]) || !is_numeric($e[2]))
  814. {
  815. $cw[] = $v;
  816. continue;
  817. }
  818. else
  819. {
  820. $resdata[$d][0] += $e[2];
  821. }
  822. }
  823. }
  824. }
  825. }
  826. }
  827. $data = array();
  828. foreach ($resdata as $v)
  829. {
  830. if(isset($v[4]))
  831. {
  832. if(!isset($data[$v[1].$v[2].$v[3].$v[4]]))
  833. {
  834. $data[$v[1].$v[2].$v[3].$v[4]] = array($v[0],$v[1],$pm[$v[2]],$classdata[$v[3]],$v[4]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
  835. }
  836. else
  837. {
  838. $data[$v[1].$v[2].$v[3].$v[4]][0] += $v[0];
  839. }
  840. }
  841. else
  842. {
  843. if(!isset($data[$v[1].$v[2].$v[3]]))
  844. {
  845. $data[$v[1].$v[2].$v[3]] = array($v[0],$v[1],$pm[$v[2]],$v[3]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
  846. }
  847. else
  848. {
  849. $data[$v[1].$v[2].$v[3]][0] += $v[0];
  850. }
  851. }
  852. }
  853. $list = array();
  854. foreach ($data as $v)
  855. {
  856. $x = (isset($v[4]))?$v[3]:$v[2];
  857. if(!isset($list[$v[2]]))
  858. {
  859. $list[$v[2]] = array();
  860. if(!isset($list[$v[2]][$x]))
  861. {
  862. $list[$v[2]][$x] = array();
  863. $list[$v[2]][$x][] = $v;
  864. }
  865. else
  866. {
  867. $list[$v[2]][$x][] = $v;
  868. }
  869. }
  870. else
  871. {
  872. if(!isset($list[$v[2]][$x]))
  873. {
  874. $list[$v[2]][$x] = array();
  875. $list[$v[2]][$x][] = $v;
  876. }
  877. else
  878. {
  879. $list[$v[2]][$x][] = $v;
  880. }
  881. }
  882. }
  883. foreach ($list as $key=>$val)
  884. {
  885. foreach ($val as $k=>$va)
  886. {
  887. $dd = array();
  888. foreach ($va as $v)
  889. {
  890. $ss = (!isset($v[4]))?$v[3]:$v[4];
  891. if(!isset($dd[$v['1']]))
  892. {
  893. $dd[$v['1']] = array();
  894. $dd[$v['1']][$ss] = $v;
  895. }
  896. else
  897. {
  898. $dd[$v['1']][$ss] = $v;
  899. }
  900. }
  901. ksort($dd);
  902. $list[$key][$k] = $dd;
  903. }
  904. }
  905. $warp[] = array($btpm,$list);
  906. }
  907. //echo count($list);
  908. //echo "<pre>";
  909. //print_r($warp);
  910. //exit;
  911. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  912. <head>
  913. <!--[if gte mso 9]><xml>
  914. <x:ExcelWorkbook>
  915. <x:ExcelWorksheets>
  916. <x:ExcelWorksheet>
  917. <x:Name>EXCEL</x:Name>
  918. <x:WorksheetOptions>
  919. <x:Print>
  920. <x:ValidPrinterInfo />
  921. </x:Print>
  922. </x:WorksheetOptions>
  923. </x:ExcelWorksheet>
  924. </x:ExcelWorksheets>
  925. </x:ExcelWorkbook>
  926. </xml>
  927. <![endif]-->
  928. </head><body>";
  929. foreach ($warp as $list)
  930. {
  931. foreach ($list[1] as $key=>$val)
  932. {
  933. $btnum = count($val);
  934. $str .= "<table border=1>
  935. <tr>";
  936. foreach ($val as $k=>$v)
  937. {
  938. $str .="<td style='background-color: #ffff00;color: #F00;width:20px'>".$k.' '.$list[0]."</td>
  939. <td>其它</td>
  940. <td>HD</td>";
  941. }
  942. $str .= "</tr>
  943. </table>";
  944. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'><tr>";
  945. foreach ($val as $k=>$v)
  946. {
  947. $str .= "<td><table border=1>";
  948. foreach ($v as $sk=>$s)
  949. {
  950. $xk1 = (isset($s[1]))?$s[1][0]:0;
  951. $xk2 = (isset($s[2]))?$s[2][0]:0;
  952. $str .="<tr><td style='color: #F00;'>".$sk."</td><td>".$xk1."</td><td>".$xk2."</td></tr>";
  953. }
  954. $str .= "</table></td>";
  955. }
  956. $str .= "</table>";
  957. }
  958. }
  959. $str .= "</body></html>";
  960. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  961. header( "Content-type: application/octet-stream" );
  962. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  963. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  964. header( "Pragma: no-cache" );
  965. header( "Expires: 0" );
  966. exit($str);
  967. }
  968. }
  969. public function _bh()
  970. {
  971. if(isset($_SESSION['api']))
  972. {
  973. $user = $this->user->get_api($_SESSION['api']);
  974. $usp = $user;
  975. $fgshop = "";$sid = "";$exsp = "";$excelshop="";
  976. $usersp = explode('|',trim($user['shop'],'|'));
  977. foreach ($usersp as $value)
  978. {
  979. $fgshop .= " shop = ".$value." or";
  980. $sid .= " id = ".$value." or";
  981. }
  982. $userexcel = explode('|',trim($user['excelshop'],'|'));
  983. foreach ($userexcel as $value)
  984. {
  985. $excelshop .= " shop = ".$value." or";
  986. $exsp .= " id = ".$value." or";
  987. }
  988. if($excelshop != "")
  989. {
  990. $excelshop = "(".rtrim($excelshop,'or').")";
  991. }
  992. }
  993. $cs = array();//测试
  994. $post = $this->input->post(NULL, TRUE);
  995. if(isset($_GET['excel']))
  996. {
  997. $shop = $this->input->get('shop',true);
  998. $color = $this->input->get('color',true);
  999. $grade = $this->input->get('grade',true);
  1000. $lowe = $this->input->get('lowe',true);
  1001. $lacetype = $this->input->get('lacetype',true);
  1002. $time = $this->input->get('time',true);
  1003. $timetk = $this->input->get('timetk',true);
  1004. $timetj = $this->input->get('timetj',true);
  1005. $timetk = strtotime($timetk);
  1006. $timetj = strtotime($timetj);
  1007. $where = "fpdata like '%-128-%' and ";//头套
  1008. $fpdata = '';
  1009. if($lacetype)
  1010. {
  1011. $lacetypefp = '';
  1012. $lacetypedata = explode(',',trim($lacetype,','));
  1013. foreach ($lacetypedata as $value)
  1014. {
  1015. $lacetypefp .= "fpdata like '%-".$value."-%' or ";
  1016. }
  1017. $fpdata .= " and (".rtrim($lacetypefp,' or').")";
  1018. }
  1019. if($lowe)
  1020. {
  1021. $lowefp = '';
  1022. $lowedata = explode(',',trim($lowe,','));
  1023. foreach ($lowedata as $value)
  1024. {
  1025. $lowefp .= "fpdata like '%-".$value."-%' or ";
  1026. }
  1027. $fpdata .= " and (".rtrim($lowefp,' or').")";
  1028. }
  1029. if($shop)
  1030. {
  1031. $where .= "shop = '$shop' and ";
  1032. }
  1033. else
  1034. {
  1035. $where .= $excelshop." and ";
  1036. }
  1037. if($color)
  1038. {
  1039. $where .= "fpdata like '%$color%' and ";
  1040. }
  1041. if($grade)
  1042. {
  1043. $where .= "fpdata like '%$grade%' and ";
  1044. }
  1045. $density = array();
  1046. $size = array();
  1047. $haircap = array();
  1048. $md = $this->typeclass->find_all("classid = '10'");//密度
  1049. foreach ($md as $val)
  1050. {
  1051. $density[$val['id']] = '';
  1052. }
  1053. $cd = $this->typeclass->find_all("classid = '14'",'*','id asc');//长度 and id != '774' and bqsku < 32之前的限制
  1054. foreach ($cd as $val)
  1055. {
  1056. $size[$val['id']] = $density;
  1057. }
  1058. $fm = $this->typeclass->find_all("classid = '6'");
  1059. foreach ($fm as $val)
  1060. {
  1061. $haircap[$val['id']] = $size;
  1062. }
  1063. $dataa = $this->fullorder->find_all($where.$time." > '$timetk' and ".$time." < '$timetj'".$fpdata,'number,fpdata','id desc');
  1064. $datab = $this->fullordersmt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj'".$fpdata,'number,fpdata','id desc');
  1065. $datac = $this->fullordertt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj'".$fpdata,'number,fpdata','id desc');
  1066. $data = array_merge($dataa,$datab,$datac);
  1067. $fpdata = array();
  1068. foreach ($data as $val)
  1069. {
  1070. $f = explode(';',trim($val['fpdata'],';'));
  1071. foreach ($f as $v)
  1072. {
  1073. if(stripos($v,'-128-') === false)
  1074. {
  1075. continue;
  1076. }
  1077. if($color)
  1078. {
  1079. if(stripos($v,'-'.$color.'-') === false)
  1080. {
  1081. continue;
  1082. }
  1083. }
  1084. if($grade)
  1085. {
  1086. if(stripos($v,'-'.$grade.'-') === false)
  1087. {
  1088. continue;
  1089. }
  1090. }
  1091. if($lowe)
  1092. {
  1093. $arraylowe = explode(',',trim($lowe,','));
  1094. $i = 0;
  1095. foreach ($arraylowe as $vv)
  1096. {
  1097. if(stripos($v,'-'.$vv.'-') === false)
  1098. {
  1099. $i++;
  1100. }
  1101. }
  1102. if($i == count($arraylowe))
  1103. {
  1104. continue;
  1105. }
  1106. }
  1107. if($lacetype)
  1108. {
  1109. $arraylacetype = explode(',',trim($lacetype,','));
  1110. $i = 0;
  1111. foreach ($arraylacetype as $vv)
  1112. {
  1113. if(stripos($v,'-'.$vv.'-') === false)
  1114. {
  1115. $i++;
  1116. }
  1117. }
  1118. if($i == count($arraylacetype))
  1119. {
  1120. continue;
  1121. }
  1122. }
  1123. $fdd = explode('|',trim($v,'|'));
  1124. $fddf = explode('-',trim($fdd[0],'-'));
  1125. if(isset($fddf[7]))
  1126. {
  1127. $fpdata[] = array($fddf[4],$fddf[5],$fddf[7],trim($fddf[0],','),$fddf[6],$fdd[2],$val['number']);//曲度,蕾丝种类,密度,长度,发帽大小,数量
  1128. }
  1129. }
  1130. }
  1131. $tc = array();
  1132. $qbtc = $this->typeclass->find_all();
  1133. foreach ($qbtc as $val)
  1134. {
  1135. $tc[$val['id']] = $val['bqsku'];
  1136. }
  1137. $zh = array();
  1138. $qbzh = $this->typeclass->find_all();
  1139. foreach ($qbzh as $val)
  1140. {
  1141. $zh[$val['id']] = $val['zh'];
  1142. }
  1143. $qd = array();$td = '';
  1144. $qddata = $this->typeclass->find_all("classid = '15'");
  1145. foreach ($qddata as $val)
  1146. {
  1147. $qd[$val['id']] = 0;
  1148. $td .= '<td>'.$val['bqsku'].'</td>';
  1149. }
  1150. $zdata = array();
  1151. foreach ($fpdata as $val)
  1152. {
  1153. if(isset($zdata[$val[0].'|'.$val[1]]))
  1154. {
  1155. if(isset($zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]]))
  1156. {
  1157. if($zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]] == '')
  1158. {
  1159. $zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]] = $val[5];
  1160. }
  1161. else
  1162. {
  1163. $zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]] += $val[5];
  1164. }
  1165. }
  1166. }
  1167. else
  1168. {
  1169. $zdata[$val[0].'|'.$val[1]] = $haircap;
  1170. if(isset($zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]]))
  1171. {
  1172. $zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]] = $val[5];
  1173. }
  1174. }
  1175. }
  1176. foreach ($zdata as $key=>$value)
  1177. {
  1178. foreach ($value as $ke=>$va)
  1179. {
  1180. foreach ($va as $kk=>$vv)
  1181. {
  1182. $i = 0;
  1183. foreach ($vv as $v)
  1184. {
  1185. if($v == '')
  1186. {
  1187. $i++;
  1188. }
  1189. }
  1190. if($i == count($density))
  1191. {
  1192. unset($zdata[$key][$ke][$kk]);
  1193. }
  1194. }
  1195. }
  1196. }
  1197. foreach ($zdata as $key=>$value)
  1198. {
  1199. $i = 0;
  1200. foreach ($value as $ke=>$va)
  1201. {
  1202. if(empty($va))
  1203. {
  1204. $i++;
  1205. }
  1206. if($i == count($value))
  1207. {
  1208. unset($zdata[$key]);
  1209. }
  1210. }
  1211. }
  1212. //sort($zdata);//排序
  1213. //echo count($list);
  1214. //echo "<pre>";
  1215. //print_r($zdata);
  1216. //exit;
  1217. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1218. <head>
  1219. <!--[if gte mso 9]><xml>
  1220. <x:ExcelWorkbook>
  1221. <x:ExcelWorksheets>
  1222. <x:ExcelWorksheet>
  1223. <x:Name>EXCEL</x:Name>
  1224. <x:WorksheetOptions>
  1225. <x:Print>
  1226. <x:ValidPrinterInfo />
  1227. </x:Print>
  1228. </x:WorksheetOptions>
  1229. </x:ExcelWorksheet>
  1230. </x:ExcelWorksheets>
  1231. </x:ExcelWorkbook>
  1232. </xml>
  1233. <![endif]-->
  1234. </head><body>";
  1235. foreach ($zdata as $key=>$value)
  1236. {
  1237. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;background-color: #e2efda;'>";
  1238. $key = explode('|',$key);
  1239. $str .= "<tr><th colspan='3' align='center'><h3>".$zh[$key[0]].' '.$zh[$key[1]]."<h3></th></tr><tr height='50'>";
  1240. $y = 0;
  1241. foreach ($value as $ke=>$va)
  1242. {
  1243. $y++;
  1244. if($y == 2)
  1245. {
  1246. $backgrounda = '#ffff00';
  1247. $backgroundb = '#bad5df';
  1248. }
  1249. else
  1250. {
  1251. $backgrounda = '#e2efda';
  1252. $backgroundb = '#9bc2e6';
  1253. }
  1254. $str .= "<td><table border=1 style='font-family: Microsoft Yahei;font-size: 14px;background-color: ".$backgrounda.";'><tr><th colspan='".(count($density)+1)."' align='center'><h3>".$zh[$ke]."<h3></th></tr>";
  1255. $str .= "<tr><td align='center' style='background-color: ".$backgroundb.";'>尺寸/密度</td>";
  1256. foreach ($density as $kk=>$vv)
  1257. {
  1258. $str .= "<td align='center'>".$tc[$kk]."</td>";
  1259. }
  1260. $str .= "</tr>";
  1261. foreach ($va as $kk=>$vv)
  1262. {
  1263. $str .= "<tr height='50'><td align='center' style='background-color: ".$backgroundb.";'><b>".$tc[$kk]."</b></td>";
  1264. foreach ($vv as $v)
  1265. {
  1266. $str .= "<td align='center'>".$v."</td>";
  1267. }
  1268. $str .= "</tr>";
  1269. }
  1270. $str .= "</table></td>";
  1271. }
  1272. $str .= "</tr></table><br><br>";
  1273. }
  1274. $str .= "</body></html>";
  1275. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1276. header( "Content-type: application/octet-stream" );
  1277. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  1278. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1279. header( "Pragma: no-cache" );
  1280. header( "Expires: 0" );
  1281. exit($str);
  1282. }
  1283. $wlshop = $this->shop->find_all('1=1 and '.rtrim($exsp,'or'));
  1284. $this->data['wlshop'] = $wlshop;
  1285. $this->_Template('systemdownload_bh',$this->data);
  1286. }
  1287. public function _hsp()
  1288. {
  1289. if(isset($_SESSION['api']))
  1290. {
  1291. $user = $this->user->get_api($_SESSION['api']);
  1292. $usp = $user;
  1293. $fgshop = "";$sid = "";$excelshop="";
  1294. $usersp = explode('|',trim($user['shop'],'|'));
  1295. foreach ($usersp as $value)
  1296. {
  1297. $fgshop .= " shop = ".$value." or";
  1298. $sid .= " id = ".$value." or";
  1299. }
  1300. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1301. foreach ($userexcel as $value)
  1302. {
  1303. $excelshop .= " shop = ".$value." or";
  1304. }
  1305. if($excelshop != "")
  1306. {
  1307. $excelshop = "(".rtrim($excelshop,'or').")";
  1308. }
  1309. }
  1310. $lx = array();
  1311. $b = $this->typeclass->find_all();
  1312. foreach ($b as $val)
  1313. {
  1314. $lx[$val['id']] = $val['classid'];
  1315. }
  1316. $cs = array();//测试
  1317. $post = $this->input->post(NULL, TRUE);
  1318. if(isset($_GET['excel']))
  1319. {
  1320. $type = $this->input->get('type',true);
  1321. $lace = $this->input->get('lace',true);
  1322. $color = $this->input->get('color',true);
  1323. $lowe = $this->input->get('lowe',true);
  1324. $grade = $this->input->get('grade',true);
  1325. $density = $this->input->get('density',true);
  1326. $lacetype = $this->input->get('lacetype',true);
  1327. $lacecolor = $this->input->get('lacecolor',true);
  1328. $time = $this->input->get('time',true);
  1329. $timetk = $this->input->get('timetk',true);
  1330. $timetj = $this->input->get('timetj',true);
  1331. $timetk = strtotime($timetk);
  1332. $timetj = strtotime($timetj);
  1333. if($type == 1)
  1334. {
  1335. $where = "fpdata like '%-128-%' and ".$excelshop." and ";//头套
  1336. }
  1337. else
  1338. {
  1339. if($lace == 1)
  1340. {
  1341. $where = "fpdata like '%-127-%' and fpdata NOT LIKE '%-335-%' and ".$excelshop." and ";
  1342. }
  1343. else
  1344. {
  1345. $where = "fpdata like '%-127-%' and fpdata like '%-335-%' and ".$excelshop." and ";
  1346. }
  1347. }
  1348. $fpdata = '';$px = array();$fl = array();
  1349. if($lacetype)
  1350. {
  1351. $lacetypefp = '';
  1352. $lacetypedata = explode(',',trim($lacetype,','));
  1353. foreach ($lacetypedata as $value)
  1354. {
  1355. $value = explode('|',$value);
  1356. $px[$value[0]] = '';
  1357. $val = explode('-',$value[1]);
  1358. foreach ($val as $k=>$v)
  1359. {
  1360. $fl[$v] = $value[0];
  1361. $lacetypefp .= " fpdata like '%-".$v."-%' or ";
  1362. }
  1363. }
  1364. $fpdata .= " and (".rtrim($lacetypefp,' or').")";
  1365. }
  1366. $colortitle = '';
  1367. if($color)
  1368. {
  1369. if($color == 'a')
  1370. {
  1371. $where .= " fpdata NOT like '%-57-%' and ";
  1372. }
  1373. else
  1374. {
  1375. $where .= " fpdata like '%-$color-%' and ";
  1376. $colortitle = $this->typeclass->read($color);
  1377. $colortitle = $colortitle['zh'];
  1378. }
  1379. }
  1380. if($lowe)
  1381. {
  1382. $where .= " fpdata like '%-$lowe-%' and ";
  1383. }
  1384. if($grade)
  1385. {
  1386. $where .= " fpdata like '%-$grade-%' and ";
  1387. }
  1388. if($density)
  1389. {
  1390. $where .= " fpdata like '%-$density-%' and ";
  1391. }
  1392. if($lacecolor)
  1393. {
  1394. if($lacecolor == 'a')
  1395. {
  1396. $where .= " fpdata NOT like '%-2071-%' and fpdata NOT like '%-2076-%' and ";
  1397. }
  1398. if($lacecolor == 'b')
  1399. {
  1400. $where .= " (fpdata like '%-2071-%' or fpdata like '%-2076-%') and ";
  1401. }
  1402. }
  1403. $size = array();$cc = array();
  1404. $cd = $this->typeclass->find_all("classid = '14' and id != '774' and id != '6' and id != '99' and id != '100'",'*','id asc');//长度
  1405. foreach ($cd as $val)
  1406. {
  1407. $cc[] = $val['bqsku'];
  1408. $size[$val['id']] = 0;
  1409. }
  1410. $dataa = $this->fullorder->find_all($where." $time > '$timetk' and $time < '$timetj'".$fpdata,'number,fpdata','id desc');
  1411. $datab = $this->fullordersmt->find_all($where." $time > '$timetk' and $time < '$timetj'".$fpdata,'number,fpdata','id desc');
  1412. $datac = $this->fullordertt->find_all($where." $time > '$timetk' and $time < '$timetj'".$fpdata,'number,fpdata','id desc');
  1413. $data = array_merge($dataa,$datab,$datac);
  1414. $fpdata = array();$cs[] = array();$css = '';
  1415. foreach ($data as $val)
  1416. {
  1417. $f = explode(';',trim($val['fpdata'],';'));
  1418. foreach ($f as $v)
  1419. {
  1420. $v = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
  1421. if($type == 1 && stripos($v,'-128-') === false)
  1422. {
  1423. continue;
  1424. }
  1425. else if($type == 2 && stripos($v,'-127-') === false)
  1426. {
  1427. continue;
  1428. }
  1429. if($color)
  1430. {
  1431. if($color == 'a')
  1432. {
  1433. if(stripos($v,'-57-') !== false)
  1434. {
  1435. continue;
  1436. }
  1437. }
  1438. else
  1439. {
  1440. if(stripos($v,'-'.$color.'-') === false)
  1441. {
  1442. continue;
  1443. }
  1444. }
  1445. }
  1446. if($lowe)
  1447. {
  1448. if(stripos($v,'-'.$lowe.'-') === false)
  1449. {
  1450. continue;
  1451. }
  1452. }
  1453. if($grade)
  1454. {
  1455. if(stripos($v,'-'.$grade.'-') === false)
  1456. {
  1457. continue;
  1458. }
  1459. }
  1460. if($density)
  1461. {
  1462. if(stripos($v,'-'.$density.'-') === false)
  1463. {
  1464. continue;
  1465. }
  1466. }
  1467. if($lacecolor)
  1468. {
  1469. if($lacecolor == 'a')
  1470. {
  1471. if(stripos($v,'-2071-') !== false || stripos($v,'-2076-') !== false)
  1472. {
  1473. continue;
  1474. }
  1475. }
  1476. if($lacecolor == 'b')
  1477. {
  1478. if(stripos($v,'-2071-') === false && stripos($v,'-2076-') === false)
  1479. {
  1480. continue;
  1481. }
  1482. }
  1483. }
  1484. if($lacetype)
  1485. {
  1486. $arraylacetype = explode(',',trim($lacetype,','));
  1487. $i = 0;$j = 0;
  1488. foreach ($arraylacetype as $vv)
  1489. {
  1490. $value = explode('|',$vv);
  1491. $value = explode('-',trim($value[1],'-'));
  1492. $j += count($value);
  1493. foreach ($value as $vvv)
  1494. {
  1495. if(stripos($v,'-'.$vvv.'-') === false)
  1496. {
  1497. $i++;
  1498. }
  1499. }
  1500. }
  1501. if($i == $j)
  1502. {
  1503. continue;
  1504. }
  1505. }
  1506. $fdd = explode('|',trim($v,'|'));
  1507. $fddf = explode('-',trim($fdd[0],'-'));
  1508. if($type == 1)
  1509. {
  1510. foreach ($fddf as $vl)
  1511. {
  1512. if(isset($lx[$vl]) && $lx[$vl] == 18)
  1513. {
  1514. $fpdata[] = array($fl[$vl],trim($fddf[0],','),$fdd[2]);//蕾丝种类,长度,数量
  1515. }
  1516. }
  1517. }
  1518. else if($type == 2)
  1519. {
  1520. if(isset($fl[$fddf[8]]))
  1521. {
  1522. $fpdata[] = array($fl[$fddf[8]],trim($fddf[0],','),$fdd[2]);//蕾丝种类,长度,数量
  1523. }
  1524. }
  1525. }
  1526. }
  1527. foreach ($fpdata as $val)
  1528. {
  1529. if(isset($zdata[$val[0]]))
  1530. {
  1531. if(isset($zdata[$val[0]][$val[1]]))
  1532. {
  1533. $zdata[$val[0]][$val[1]] += $val[2];
  1534. }
  1535. }
  1536. else
  1537. {
  1538. $zdata[$val[0]] = $size;
  1539. if(isset($zdata[$val[0]][$val[1]]))
  1540. {
  1541. $zdata[$val[0]][$val[1]] += $val[2];
  1542. }
  1543. }
  1544. }
  1545. /**
  1546. foreach ($zdata as $key=>$value)
  1547. {
  1548. foreach ($value as $ke=>$va)
  1549. {
  1550. if($va == '0')
  1551. {
  1552. unset($zdata[$key][$ke]);
  1553. }
  1554. }
  1555. }
  1556. **/
  1557. $tc = array();
  1558. $qbtc = $this->typeclass->find_all();
  1559. foreach ($qbtc as $val)
  1560. {
  1561. $tc[$val['id']] = $val['bqsku'];
  1562. }
  1563. $zh = array();
  1564. $qbzh = $this->typeclass->find_all();
  1565. foreach ($qbzh as $val)
  1566. {
  1567. $zh[$val['id']] = $val['zh'];
  1568. }
  1569. //$px = array('13*4'=>'','4*4'=>'','5*5'=>'','6*6'=>'','13*6'=>'','360'=>'','HD13*4'=>'','HD4*4'=>'','HD5*5'=>'','HD6*6'=>'','HD13*6'=>'');
  1570. foreach ($zdata as $k=>$v)
  1571. {
  1572. $px[$k] = $v;
  1573. }
  1574. foreach ($px as $k=>$v)
  1575. {
  1576. if(!$v)
  1577. {
  1578. unset($px[$k]);
  1579. }
  1580. }
  1581. $zdata = $px;
  1582. //sort($zdata);//排序
  1583. //echo count($list);
  1584. //echo "<pre>";
  1585. //print_r($zdata);
  1586. //exit;
  1587. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1588. <head>
  1589. <!--[if gte mso 9]><xml>
  1590. <x:ExcelWorkbook>
  1591. <x:ExcelWorksheets>
  1592. <x:ExcelWorksheet>
  1593. <x:Name>EXCEL</x:Name>
  1594. <x:WorksheetOptions>
  1595. <x:Print>
  1596. <x:ValidPrinterInfo />
  1597. </x:Print>
  1598. </x:WorksheetOptions>
  1599. </x:ExcelWorksheet>
  1600. </x:ExcelWorksheets>
  1601. </x:ExcelWorkbook>
  1602. </xml>
  1603. <![endif]-->
  1604. </head><body>";
  1605. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
  1606. $str .= "<tr><td colspan='".(count($zdata)+1)."' align='center' height='30' width='50'>".date('Y-m-d',$timetk).' ~ '.date('Y-m-d',$timetj).' <b>'.$colortitle."</b></td></tr><tr>";
  1607. $str .= "<td><table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
  1608. $str .= "<tr><td align='center' height='30' width='50'>". iconv("UTF-8", "GBK", '尺寸')."</td></tr>";
  1609. foreach ($cc as $kk=>$vv)
  1610. {
  1611. $str .= "<tr><td align='center' height='30' width='50'><b>".$vv."</b></td>";
  1612. $str .= "</tr>";
  1613. }
  1614. $str .= "</table></td>";
  1615. foreach ($zdata as $key=>$value)
  1616. {
  1617. //$str .= "<td><table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'><tr><td align='center' height='30' width='50'><b>".$key."</b></td></tr>";
  1618. $str .= "<td><table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'><tr><td align='center' height='30' width='50'><b>". iconv("UTF-8", "GBK", $key)."</b></td></tr>";
  1619. foreach ($value as $kk=>$vv)
  1620. {
  1621. if($vv == '0')
  1622. {
  1623. $str .= "<tr><td align='center' height='30' width='50'></td>";
  1624. }
  1625. else
  1626. {
  1627. $str .= "<tr><td align='center' height='30' width='50'>".$vv."</td>";
  1628. }
  1629. $str .= "</tr>";
  1630. }
  1631. $str .= "</table></td>";
  1632. }
  1633. $str .= "</tr></table><br><br>";
  1634. $str .= "</body></html>";
  1635. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1636. header( "Content-type: application/octet-stream" );
  1637. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  1638. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1639. header( "Pragma: no-cache" );
  1640. header( "Expires: 0" );
  1641. exit($str);
  1642. }
  1643. $this->_Template('systemdownload_hsp',$this->data);
  1644. }
  1645. public function _qm()//曲度和密度
  1646. {
  1647. if(isset($_SESSION['api']))
  1648. {
  1649. $user = $this->user->get_api($_SESSION['api']);
  1650. $usp = $user;
  1651. $fgshop = "";$sid = "";$excelshop="";
  1652. $usersp = explode('|',trim($user['shop'],'|'));
  1653. foreach ($usersp as $value)
  1654. {
  1655. $fgshop .= " shop = ".$value." or";
  1656. $sid .= " id = ".$value." or";
  1657. }
  1658. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1659. foreach ($userexcel as $value)
  1660. {
  1661. $excelshop .= " shop = ".$value." or";
  1662. }
  1663. if($excelshop != "")
  1664. {
  1665. $excelshop = "(".rtrim($excelshop,'or').")";
  1666. }
  1667. }
  1668. $post = $this->input->post(NULL, TRUE);
  1669. if(isset($_GET['excel']))
  1670. {
  1671. $timetk = $this->input->get('timetk',true);
  1672. $timetj = $this->input->get('timetj',true);
  1673. //$lacetype = $this->input->get('lacetype',true);
  1674. $lacetype = '';
  1675. $time = $this->input->get('time',true);
  1676. $timetk = time()-30*24*3600;
  1677. $timetj = time();
  1678. $where = "fpdata like '%-128-%' and shop != '9' and shop != '26' and ".$excelshop." and ";//头套
  1679. $fpdata = '';
  1680. if($lacetype)
  1681. {
  1682. $lacetype = explode(',',trim($lacetype,','));
  1683. foreach ($lacetype as $value)
  1684. {
  1685. $fpdata .= "fpdata like '%-".$value."-%' or ";
  1686. }
  1687. $fpdata = " and (".rtrim($fpdata,' or').")";
  1688. }
  1689. $dataa = $this->fullorder->find_all($where."librarytime > '$timetk' and librarytime < '$timetj'".$fpdata,'number,fpdata','id desc');
  1690. $datab = $this->fullordersmt->find_all($where."librarytime > '$timetk' and librarytime < '$timetj'".$fpdata,'number,fpdata','id desc');
  1691. $datac = $this->fullordertt->find_all($where."librarytime > '$timetk' and librarytime < '$timetj'".$fpdata,'number,fpdata','id desc');
  1692. $data = array_merge($dataa,$datab,$datac);
  1693. $fpdata = array();
  1694. foreach ($data as $val)
  1695. {
  1696. $f = explode(';',trim($val['fpdata'],';'));
  1697. foreach ($f as $v)
  1698. {
  1699. if($lacetype)
  1700. {
  1701. foreach ($lacetype as $vv)
  1702. {
  1703. if(stripos($v,'-'.$vv.'-') !== false)
  1704. {
  1705. $fdd = explode('|',trim($val['fpdata'],'|'));
  1706. $fddf = explode('-',trim($fdd[0],'-'));
  1707. if(isset($fddf[7]))
  1708. {
  1709. $fpdata[] = array($fddf[4],$fddf[5],$fddf[7]);//曲度,蕾丝种类,密度
  1710. }
  1711. }
  1712. }
  1713. }
  1714. else
  1715. {
  1716. $fdd = explode('|',trim($val['fpdata'],'|'));
  1717. $fddf = explode('-',trim($fdd[0],'-'));
  1718. if(isset($fddf[7]))
  1719. {
  1720. $fpdata[] = array($fddf[4],$fddf[5],$fddf[7]);//曲度,蕾丝种类,密度
  1721. }
  1722. }
  1723. }
  1724. }
  1725. $tc = array();
  1726. $qbtc = $this->typeclass->find_all();
  1727. foreach ($qbtc as $val)
  1728. {
  1729. $tc[$val['id']] = $val['bqsku'];
  1730. }
  1731. $qd = array();$td = '';
  1732. $qddata = $this->typeclass->find_all("classid = '15'");
  1733. foreach ($qddata as $val)
  1734. {
  1735. $qd[$val['id']] = 0;
  1736. $td .= '<td>'.$val['bqsku'].'</td>';
  1737. }
  1738. $zdata = array();
  1739. foreach ($fpdata as $val)
  1740. {
  1741. /**
  1742. if(isset($zdata[$tc[$val[1]].' '.$tc[$val[2]]]))
  1743. {
  1744. if(isset($zdata[$tc[$val[1]].' '.$tc[$val[2]]][$val[0]]))
  1745. {
  1746. $zdata[$tc[$val[1]].' '.$tc[$val[2]]][$val[0]] += 1;
  1747. }
  1748. }
  1749. else
  1750. {
  1751. $zdata[$tc[$val[1]].' '.$tc[$val[2]]] = $qd;
  1752. }
  1753. **/
  1754. if(isset($zdata[$val[1].'|'.$val[2]]))
  1755. {
  1756. if(isset($zdata[$val[1].'|'.$val[2]][$val[0]]))
  1757. {
  1758. $zdata[$val[1].'|'.$val[2]][$val[0]] += 1;
  1759. }
  1760. }
  1761. else
  1762. {
  1763. $zdata[$val[1].'|'.$val[2]] = $qd;
  1764. if(isset($zdata[$val[1].'|'.$val[2]][$val[0]]))
  1765. {
  1766. $zdata[$val[1].'|'.$val[2]][$val[0]] += 1;
  1767. }
  1768. }
  1769. }
  1770. //echo count($list);
  1771. //echo "<pre>";
  1772. //print_r($zdata);
  1773. //exit;
  1774. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1775. <head>
  1776. <!--[if gte mso 9]><xml>
  1777. <x:ExcelWorkbook>
  1778. <x:ExcelWorksheets>
  1779. <x:ExcelWorksheet>
  1780. <x:Name>EXCEL</x:Name>
  1781. <x:WorksheetOptions>
  1782. <x:Print>
  1783. <x:ValidPrinterInfo />
  1784. </x:Print>
  1785. </x:WorksheetOptions>
  1786. </x:ExcelWorksheet>
  1787. </x:ExcelWorksheets>
  1788. </x:ExcelWorkbook>
  1789. </xml>
  1790. <![endif]-->
  1791. </head><body>";
  1792. $str .= "<table border=1 style='background-color: #2ca8a1;font-weight: bold;color:#fff;font-size: 14px;table-layout:fixed'><tr height='50' align='center'>
  1793. <td align='left'>产品</td>
  1794. ".$td."
  1795. </tr></table>";
  1796. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
  1797. foreach ($zdata as $key=>$value)
  1798. {
  1799. $key = explode('|',$key);
  1800. $str .= "<tr height='50'><td align='center'><b>".$tc[$key[0]].' '.$tc[$key[1]]."</b></td>";
  1801. foreach ($value as $ke=>$va)
  1802. {
  1803. if($va > 0)
  1804. {
  1805. $str .= "<td align='center'><b>".$va."</b></td>";
  1806. }
  1807. else
  1808. {
  1809. $str .= "<td align='center'>".$va."</td>";
  1810. }
  1811. }
  1812. $str .= "</tr>\n";
  1813. }
  1814. $str .= "</body></html>";
  1815. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1816. header( "Content-type: application/octet-stream" );
  1817. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  1818. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1819. header( "Pragma: no-cache" );
  1820. header( "Expires: 0" );
  1821. exit($str);
  1822. }
  1823. }
  1824. public function _list()
  1825. {
  1826. if(isset($_SESSION['api']))
  1827. {
  1828. $user = $this->user->get_api($_SESSION['api']);
  1829. $usp = $user;
  1830. $fgshop = "";$sid = "";
  1831. $usersp = explode('|',trim($user['shop'],'|'));
  1832. foreach ($usersp as $value)
  1833. {
  1834. $fgshop .= " shop = ".$value." or";
  1835. $sid .= " id = ".$value." or";
  1836. }
  1837. }
  1838. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1839. $this->data['wlshop'] = $wlshop;
  1840. $this->_Template('systemdownload_list',$this->data);
  1841. }
  1842. public function _listread()
  1843. {
  1844. if(isset($_SESSION['api']))
  1845. {
  1846. $user = $this->user->get_api($_SESSION['api']);
  1847. $usp = $user;
  1848. $fgshop = "";$sid = "";$excelshop="";
  1849. $usersp = explode('|',trim($user['shop'],'|'));
  1850. foreach ($usersp as $value)
  1851. {
  1852. $fgshop .= " shop = ".$value." or";
  1853. $sid .= " id = ".$value." or";
  1854. }
  1855. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1856. foreach ($userexcel as $value)
  1857. {
  1858. $excelshop .= " shop = ".$value." or";
  1859. }
  1860. if($excelshop != "")
  1861. {
  1862. $excelshop = "(".rtrim($excelshop,'or').")";
  1863. }
  1864. }
  1865. $post = $this->input->post(NULL, TRUE);
  1866. if(isset($_GET['category']))
  1867. {
  1868. $timetk = $this->input->get('timetk',true);
  1869. $timetj = $this->input->get('timetj',true);
  1870. $color = $this->input->get('color',true);
  1871. $lowe = $this->input->get('lowe',true);
  1872. $size = $this->input->get('size',true);
  1873. $grade = $this->input->get('grade',true);
  1874. $lacetype = $this->input->get('lacetype',true);
  1875. $category = $this->input->get('category',true);
  1876. $shop = $this->input->get('shop',true);
  1877. $time = $this->input->get('time',true);
  1878. $timetk = strtotime($timetk);
  1879. $timetj = strtotime($timetj);
  1880. $cw = array();
  1881. $class = array();$classdata = array();$lx = array();$pm = array();$ttzllist = array();$hxlist = array();
  1882. $a = $this->typeclass->find_all('classid=6 or classid=7 or classid=8 or classid=10 or classid=12 or classid=13 or classid=19 or classid=20 or classid=21 or classid=22 or classid=23 or classid=24');
  1883. foreach ($a as $val)
  1884. {
  1885. $class[] = '-'.$val['id'].'-';
  1886. }
  1887. $b = $this->typeclass->find_all();
  1888. foreach ($b as $val)
  1889. {
  1890. $classdata[$val['id']] = $val['title'];
  1891. $lx[$val['id']] = $val['classid'];
  1892. $pm[$val['id']] = $val['zh'];
  1893. }
  1894. $ttzl = $this->typeclass->find_all("classid = '18'");
  1895. foreach ($ttzl as $val)
  1896. {
  1897. $ttzllist[$val['id']] = $val['classid'];
  1898. }
  1899. $hx = $this->typeclass->find_all("classid = '15'");
  1900. foreach ($hx as $val)
  1901. {
  1902. $hxlist[$val['id']] = $val['classid'];
  1903. }
  1904. //Closure wigs
  1905. $fpdata = '';
  1906. $category = explode('|',trim($category,'|'));
  1907. foreach ($category as $value)
  1908. {
  1909. $fpdata .= "fpdata like '%".$value."%' or ";
  1910. }
  1911. if(count($category) > 1)
  1912. {
  1913. $fpdata = "(".trim($fpdata,' or ').")";
  1914. }
  1915. else
  1916. {
  1917. $fpdata = trim($fpdata,' or ');
  1918. }
  1919. $where = "shop != '9' and shop != '26' and ";
  1920. if($color)
  1921. {
  1922. $where .= "fpdata like '%$color%' and ";
  1923. }
  1924. if($lowe)
  1925. {
  1926. $where .= "fpdata like '%$lowe%' and ";
  1927. }
  1928. if($size)
  1929. {
  1930. $where .= "fpdata like '%$size%' and ";
  1931. }
  1932. if($grade)
  1933. {
  1934. $where .= "fpdata like '%$grade%' and ";
  1935. }
  1936. if($lacetype)
  1937. {
  1938. $where .= "fpdata like '%$lacetype%' and ";
  1939. }
  1940. if($shop)
  1941. {
  1942. $where .= "shop = '$shop' and ";
  1943. }
  1944. else
  1945. {
  1946. $where .= $excelshop." and ";
  1947. }
  1948. $dataa = $this->fullorder->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  1949. $datab = $this->fullordersmt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  1950. $datac = $this->fullordertt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  1951. $data = array_merge($dataa,$datab,$datac);
  1952. //echo $where."librarytime > '$timetk' and librarytime < '$timetj' and ".$fpdata;
  1953. //echo "<pre>";
  1954. //print_r($data);
  1955. //exit;
  1956. $pd = '';
  1957. $p = $class;
  1958. $resdata = array();
  1959. foreach ($data as $val)
  1960. {
  1961. $f = explode(';',trim($val['fpdata'],';'));
  1962. foreach ($f as $v)
  1963. {
  1964. if($color)
  1965. {
  1966. if(stripos($v,'-'.$color.'-') === false)
  1967. {
  1968. continue;
  1969. }
  1970. }
  1971. if($lowe)
  1972. {
  1973. if(stripos($v,'-'.$lowe.'-') === false)
  1974. {
  1975. continue;
  1976. }
  1977. }
  1978. if($size)
  1979. {
  1980. if(stripos($v,$size.',') === false)
  1981. {
  1982. continue;
  1983. }
  1984. }
  1985. if($grade)
  1986. {
  1987. if(stripos($v,'-'.$grade.'-') === false)
  1988. {
  1989. continue;
  1990. }
  1991. }
  1992. if($lacetype)
  1993. {
  1994. if(stripos($v,'-'.$lacetype.'-') === false)
  1995. {
  1996. continue;
  1997. }
  1998. }
  1999. $i = 0;
  2000. foreach ($category as $value)
  2001. {
  2002. if(stripos($v,'-'.$value.'-') !== false)
  2003. {
  2004. $i++;
  2005. }
  2006. }
  2007. if($i > 0)
  2008. {
  2009. $e = explode('|',$v);
  2010. $d = str_replace($p,'-',$e[0]);
  2011. $q = str_replace(array('-163-','-164-','-165-','-166-','-782-','-79-','-80-','-81-','-497-'),'-',$e[0]);
  2012. $fl = explode(',',$q);//分离出尺寸和其它内容
  2013. $cpkey = str_replace('-','',$fl[1]);
  2014. $tt = explode('-',trim($fl[1],'-'));
  2015. $title = '';$fla='';$flb='';
  2016. foreach ($tt as $value)
  2017. {
  2018. if(isset($ttzllist[$value]))
  2019. {
  2020. if($ttzllist[$value] == '18')
  2021. {
  2022. $fla = $value;
  2023. }
  2024. }
  2025. if(isset($hxlist[$value]))
  2026. {
  2027. if($hxlist[$value] == '15')
  2028. {
  2029. $flb = $value;
  2030. }
  2031. }
  2032. }
  2033. //$c = explode(',',$e[0]);
  2034. if(!isset($resdata[$fla.$flb]) && $fla != '' && $flb != '')
  2035. {
  2036. if(stripos($pm[$fla],'|') !== false)
  2037. {
  2038. $pm[$fla] = explode('|',$pm[$fla]);
  2039. $pm[$fla] = $pm[$fla][0];
  2040. }
  2041. if(stripos($pm[$flb],'|') !== false)
  2042. {
  2043. $pm[$flb] = explode('|',$pm[$flb]);
  2044. $pm[$flb] = $pm[$flb][0];
  2045. }
  2046. $title = $pm[$fla].' '. $pm[$flb];
  2047. $resdata[$fla.$flb] = array('t'=>$title,'82'=>0,'83'=>0,'84'=>0,'85'=>0,'86'=>0,'87'=>0,'88'=>0,'89'=>0,'90'=>0,'91'=>0,'92'=>0,'93'=>0,'94'=>0,'95'=>0,'96'=>0,'97'=>0,'98'=>0,'99'=>0,'100'=>0,'469'=>0);
  2048. if(isset($resdata[$fla.$flb][$fl[0]]))
  2049. {
  2050. $resdata[$fla.$flb][$fl[0]] += $e[2];
  2051. }
  2052. }
  2053. else if ($fla != '' && $flb != '' && isset($resdata[$fla.$flb][$fl[0]]))
  2054. {
  2055. $resdata[$fla.$flb][$fl[0]] += $e[2];
  2056. }
  2057. }
  2058. }
  2059. }
  2060. rsort($resdata);
  2061. //echo count($list);
  2062. //echo "<pre>";
  2063. //print_r($list);
  2064. //exit;
  2065. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  2066. <head>
  2067. <!--[if gte mso 9]><xml>
  2068. <x:ExcelWorkbook>
  2069. <x:ExcelWorksheets>
  2070. <x:ExcelWorksheet>
  2071. <x:Name>EXCEL</x:Name>
  2072. <x:WorksheetOptions>
  2073. <x:Print>
  2074. <x:ValidPrinterInfo />
  2075. </x:Print>
  2076. </x:WorksheetOptions>
  2077. </x:ExcelWorksheet>
  2078. </x:ExcelWorksheets>
  2079. </x:ExcelWorkbook>
  2080. </xml>
  2081. <![endif]-->
  2082. </head><body>";
  2083. $str .= "<table border=1 style='background-color: #2ca8a1;font-weight: bold;color:#fff;font-size: 14px;table-layout:fixed'><tr height='50' align='center'>
  2084. <td align='left'>产品</td>
  2085. <td>6</td>
  2086. <td>8</td>
  2087. <td>10</td>
  2088. <td>12</td>
  2089. <td>14</td>
  2090. <td>16</td>
  2091. <td>18</td>
  2092. <td>20</td>
  2093. <td>22</td>
  2094. <td>24</td>
  2095. <td>26</td>
  2096. <td>28</td>
  2097. <td>30</td>
  2098. <td>32</td>
  2099. <td>34</td>
  2100. <td>36</td>
  2101. <td>38</td>
  2102. <td>40</td>
  2103. <td>42</td>
  2104. <td>44</td>
  2105. </tr></table>";
  2106. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
  2107. foreach ($resdata as $key=>$value)
  2108. {
  2109. $str .= "<tr height='50'>";
  2110. foreach ($value as $ke=>$va)
  2111. {
  2112. if(is_numeric($va))
  2113. {
  2114. if($va > 0)
  2115. {
  2116. $str .= "<td align='center'><b>".$va."</b></td>";
  2117. }
  2118. else
  2119. {
  2120. $str .= "<td align='center'>".$va."</td>";
  2121. }
  2122. }
  2123. else
  2124. {
  2125. $str .= "<td>".$va."</td>";
  2126. }
  2127. }
  2128. $str .= "</tr>\n";
  2129. }
  2130. $str .= "</body></html>";
  2131. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2132. header( "Content-type: application/octet-stream" );
  2133. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  2134. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2135. header( "Pragma: no-cache" );
  2136. header( "Expires: 0" );
  2137. exit($str);
  2138. }
  2139. }
  2140. }