Systemdownload.php 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094
  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. $cs = array();//测试
  1311. $post = $this->input->post(NULL, TRUE);
  1312. if(isset($_GET['excel']))
  1313. {
  1314. $type = $this->input->get('type',true);
  1315. $lace = $this->input->get('lace',true);
  1316. $color = $this->input->get('color',true);
  1317. $grade = $this->input->get('grade',true);
  1318. $lacetype = $this->input->get('lacetype',true);
  1319. $time = $this->input->get('time',true);
  1320. $timetk = $this->input->get('timetk',true);
  1321. $timetj = $this->input->get('timetj',true);
  1322. $timetk = strtotime($timetk);
  1323. $timetj = strtotime($timetj);
  1324. if($type == 1)
  1325. {
  1326. $where = "fpdata like '%-128-%' and ".$excelshop." and ";//头套
  1327. }
  1328. else
  1329. {
  1330. if($lace == 1)
  1331. {
  1332. $where = "fpdata like '%-127-%' and fpdata NOT LIKE '%-335-%' and ".$excelshop." and ";
  1333. }
  1334. else
  1335. {
  1336. $where = "fpdata like '%-127-%' and fpdata like '%-335-%' and ".$excelshop." and ";
  1337. }
  1338. }
  1339. $fpdata = '';$px = array();$fl = array();
  1340. if($lacetype)
  1341. {
  1342. $lacetypefp = '';
  1343. $lacetypedata = explode(',',trim($lacetype,','));
  1344. foreach ($lacetypedata as $value)
  1345. {
  1346. $value = explode('|',$value);
  1347. $px[$value[0]] = '';
  1348. $val = explode('-',$value[1]);
  1349. foreach ($val as $k=>$v)
  1350. {
  1351. $fl[$v] = $value[0];
  1352. $lacetypefp .= " fpdata like '%-".$v."-%' or ";
  1353. }
  1354. }
  1355. $fpdata .= " and (".rtrim($lacetypefp,' or').")";
  1356. }
  1357. $colortitle = '';
  1358. if($color)
  1359. {
  1360. $where .= " fpdata like '%-$color-%' and ";
  1361. $colortitle = $this->typeclass->read($color);
  1362. $colortitle = $colortitle['zh'];
  1363. }
  1364. if($grade)
  1365. {
  1366. $where .= " fpdata like '%-$grade-%' and ";
  1367. }
  1368. $size = array();$cc = array();
  1369. $cd = $this->typeclass->find_all("classid = '14' and id != '774' and id != '6' and id != '99' and id != '100'",'*','id asc');//长度
  1370. foreach ($cd as $val)
  1371. {
  1372. $cc[] = $val['bqsku'];
  1373. $size[$val['id']] = 0;
  1374. }
  1375. $dataa = $this->fullorder->find_all($where." $time > '$timetk' and $time < '$timetj'".$fpdata,'number,fpdata','id desc');
  1376. $datab = $this->fullordersmt->find_all($where." $time > '$timetk' and $time < '$timetj'".$fpdata,'number,fpdata','id desc');
  1377. $datac = $this->fullordertt->find_all($where." $time > '$timetk' and $time < '$timetj'".$fpdata,'number,fpdata','id desc');
  1378. $data = array_merge($dataa,$datab,$datac);
  1379. $fpdata = array();$cs[] = array();
  1380. foreach ($data as $val)
  1381. {
  1382. $f = explode(';',trim($val['fpdata'],';'));
  1383. foreach ($f as $v)
  1384. {
  1385. $v = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
  1386. if($type == 1 && stripos($v,'-128-') === false)
  1387. {
  1388. continue;
  1389. }
  1390. else if($type == 2 && stripos($v,'-127-') === false)
  1391. {
  1392. continue;
  1393. }
  1394. if($color)
  1395. {
  1396. if(stripos($v,'-'.$color.'-') === false)
  1397. {
  1398. continue;
  1399. }
  1400. }
  1401. if($grade)
  1402. {
  1403. if(stripos($v,'-'.$grade.'-') === false)
  1404. {
  1405. continue;
  1406. }
  1407. }
  1408. if($lacetype)
  1409. {
  1410. $arraylacetype = explode(',',trim($lacetype,','));
  1411. $i = 0;$j = 0;
  1412. foreach ($arraylacetype as $vv)
  1413. {
  1414. $value = explode('|',$vv);
  1415. $value = explode('-',trim($value[1],'-'));
  1416. $j += count($value);
  1417. foreach ($value as $val)
  1418. {
  1419. if(stripos($v,'-'.$val.'-') === false)
  1420. {
  1421. $i++;
  1422. }
  1423. }
  1424. }
  1425. if($i == $j)
  1426. {
  1427. continue;
  1428. }
  1429. }
  1430. $fdd = explode('|',trim($v,'|'));
  1431. $fddf = explode('-',trim($fdd[0],'-'));
  1432. if($type == 1)
  1433. {
  1434. if(isset($fddf[7]) && isset($fl[$fddf[5]]))
  1435. {
  1436. $fpdata[] = array($fl[$fddf[5]],trim($fddf[0],','),$fdd[2]);//蕾丝种类,长度,数量
  1437. }
  1438. }
  1439. else if($type == 2)
  1440. {
  1441. if(isset($fl[$fddf[8]]))
  1442. {
  1443. $fpdata[] = array($fl[$fddf[8]],trim($fddf[0],','),$fdd[2]);//蕾丝种类,长度,数量
  1444. }
  1445. }
  1446. }
  1447. }
  1448. foreach ($fpdata as $val)
  1449. {
  1450. if(isset($zdata[$val[0]]))
  1451. {
  1452. if(isset($zdata[$val[0]][$val[1]]))
  1453. {
  1454. $zdata[$val[0]][$val[1]] += $val[2];
  1455. }
  1456. }
  1457. else
  1458. {
  1459. $zdata[$val[0]] = $size;
  1460. if(isset($zdata[$val[0]][$val[1]]))
  1461. {
  1462. $zdata[$val[0]][$val[1]] += $val[2];
  1463. }
  1464. }
  1465. }
  1466. /**
  1467. foreach ($zdata as $key=>$value)
  1468. {
  1469. foreach ($value as $ke=>$va)
  1470. {
  1471. if($va == '0')
  1472. {
  1473. unset($zdata[$key][$ke]);
  1474. }
  1475. }
  1476. }
  1477. **/
  1478. $tc = array();
  1479. $qbtc = $this->typeclass->find_all();
  1480. foreach ($qbtc as $val)
  1481. {
  1482. $tc[$val['id']] = $val['bqsku'];
  1483. }
  1484. $zh = array();
  1485. $qbzh = $this->typeclass->find_all();
  1486. foreach ($qbzh as $val)
  1487. {
  1488. $zh[$val['id']] = $val['zh'];
  1489. }
  1490. //$px = array('13*4'=>'','4*4'=>'','5*5'=>'','6*6'=>'','13*6'=>'','360'=>'','HD13*4'=>'','HD4*4'=>'','HD5*5'=>'','HD6*6'=>'','HD13*6'=>'');
  1491. foreach ($zdata as $k=>$v)
  1492. {
  1493. $px[$k] = $v;
  1494. }
  1495. foreach ($px as $k=>$v)
  1496. {
  1497. if(!$v)
  1498. {
  1499. unset($px[$k]);
  1500. }
  1501. }
  1502. $zdata = $px;
  1503. //sort($zdata);//排序
  1504. //echo count($list);
  1505. //echo "<pre>";
  1506. //print_r($zdata);
  1507. //exit;
  1508. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1509. <head>
  1510. <!--[if gte mso 9]><xml>
  1511. <x:ExcelWorkbook>
  1512. <x:ExcelWorksheets>
  1513. <x:ExcelWorksheet>
  1514. <x:Name>EXCEL</x:Name>
  1515. <x:WorksheetOptions>
  1516. <x:Print>
  1517. <x:ValidPrinterInfo />
  1518. </x:Print>
  1519. </x:WorksheetOptions>
  1520. </x:ExcelWorksheet>
  1521. </x:ExcelWorksheets>
  1522. </x:ExcelWorkbook>
  1523. </xml>
  1524. <![endif]-->
  1525. </head><body>";
  1526. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
  1527. $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>";
  1528. $str .= "<td><table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
  1529. $str .= "<tr><td align='center' height='30' width='50'>尺寸</td></tr>";
  1530. foreach ($cc as $kk=>$vv)
  1531. {
  1532. $str .= "<tr><td align='center' height='30' width='50'><b>".$vv."</b></td>";
  1533. $str .= "</tr>";
  1534. }
  1535. $str .= "</table></td>";
  1536. foreach ($zdata as $key=>$value)
  1537. {
  1538. $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>";
  1539. foreach ($value as $kk=>$vv)
  1540. {
  1541. if($vv == '0')
  1542. {
  1543. $str .= "<tr><td align='center' height='30' width='50'></td>";
  1544. }
  1545. else
  1546. {
  1547. $str .= "<tr><td align='center' height='30' width='50'>".$vv."</td>";
  1548. }
  1549. $str .= "</tr>";
  1550. }
  1551. $str .= "</table></td>";
  1552. }
  1553. $str .= "</tr></table><br><br>";
  1554. $str .= "</body></html>";
  1555. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1556. header( "Content-type: application/octet-stream" );
  1557. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  1558. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1559. header( "Pragma: no-cache" );
  1560. header( "Expires: 0" );
  1561. exit($str);
  1562. }
  1563. $this->_Template('systemdownload_hsp',$this->data);
  1564. }
  1565. public function _qm()//曲度和密度
  1566. {
  1567. if(isset($_SESSION['api']))
  1568. {
  1569. $user = $this->user->get_api($_SESSION['api']);
  1570. $usp = $user;
  1571. $fgshop = "";$sid = "";$excelshop="";
  1572. $usersp = explode('|',trim($user['shop'],'|'));
  1573. foreach ($usersp as $value)
  1574. {
  1575. $fgshop .= " shop = ".$value." or";
  1576. $sid .= " id = ".$value." or";
  1577. }
  1578. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1579. foreach ($userexcel as $value)
  1580. {
  1581. $excelshop .= " shop = ".$value." or";
  1582. }
  1583. if($excelshop != "")
  1584. {
  1585. $excelshop = "(".rtrim($excelshop,'or').")";
  1586. }
  1587. }
  1588. $post = $this->input->post(NULL, TRUE);
  1589. if(isset($_GET['excel']))
  1590. {
  1591. $timetk = $this->input->get('timetk',true);
  1592. $timetj = $this->input->get('timetj',true);
  1593. //$lacetype = $this->input->get('lacetype',true);
  1594. $lacetype = '';
  1595. $time = $this->input->get('time',true);
  1596. $timetk = time()-30*24*3600;
  1597. $timetj = time();
  1598. $where = "fpdata like '%-128-%' and shop != '9' and shop != '26' and ".$excelshop." and ";//头套
  1599. $fpdata = '';
  1600. if($lacetype)
  1601. {
  1602. $lacetype = explode(',',trim($lacetype,','));
  1603. foreach ($lacetype as $value)
  1604. {
  1605. $fpdata .= "fpdata like '%-".$value."-%' or ";
  1606. }
  1607. $fpdata = " and (".rtrim($fpdata,' or').")";
  1608. }
  1609. $dataa = $this->fullorder->find_all($where."librarytime > '$timetk' and librarytime < '$timetj'".$fpdata,'number,fpdata','id desc');
  1610. $datab = $this->fullordersmt->find_all($where."librarytime > '$timetk' and librarytime < '$timetj'".$fpdata,'number,fpdata','id desc');
  1611. $datac = $this->fullordertt->find_all($where."librarytime > '$timetk' and librarytime < '$timetj'".$fpdata,'number,fpdata','id desc');
  1612. $data = array_merge($dataa,$datab,$datac);
  1613. $fpdata = array();
  1614. foreach ($data as $val)
  1615. {
  1616. $f = explode(';',trim($val['fpdata'],';'));
  1617. foreach ($f as $v)
  1618. {
  1619. if($lacetype)
  1620. {
  1621. foreach ($lacetype as $vv)
  1622. {
  1623. if(stripos($v,'-'.$vv.'-') !== false)
  1624. {
  1625. $fdd = explode('|',trim($val['fpdata'],'|'));
  1626. $fddf = explode('-',trim($fdd[0],'-'));
  1627. if(isset($fddf[7]))
  1628. {
  1629. $fpdata[] = array($fddf[4],$fddf[5],$fddf[7]);//曲度,蕾丝种类,密度
  1630. }
  1631. }
  1632. }
  1633. }
  1634. else
  1635. {
  1636. $fdd = explode('|',trim($val['fpdata'],'|'));
  1637. $fddf = explode('-',trim($fdd[0],'-'));
  1638. if(isset($fddf[7]))
  1639. {
  1640. $fpdata[] = array($fddf[4],$fddf[5],$fddf[7]);//曲度,蕾丝种类,密度
  1641. }
  1642. }
  1643. }
  1644. }
  1645. $tc = array();
  1646. $qbtc = $this->typeclass->find_all();
  1647. foreach ($qbtc as $val)
  1648. {
  1649. $tc[$val['id']] = $val['bqsku'];
  1650. }
  1651. $qd = array();$td = '';
  1652. $qddata = $this->typeclass->find_all("classid = '15'");
  1653. foreach ($qddata as $val)
  1654. {
  1655. $qd[$val['id']] = 0;
  1656. $td .= '<td>'.$val['bqsku'].'</td>';
  1657. }
  1658. $zdata = array();
  1659. foreach ($fpdata as $val)
  1660. {
  1661. /**
  1662. if(isset($zdata[$tc[$val[1]].' '.$tc[$val[2]]]))
  1663. {
  1664. if(isset($zdata[$tc[$val[1]].' '.$tc[$val[2]]][$val[0]]))
  1665. {
  1666. $zdata[$tc[$val[1]].' '.$tc[$val[2]]][$val[0]] += 1;
  1667. }
  1668. }
  1669. else
  1670. {
  1671. $zdata[$tc[$val[1]].' '.$tc[$val[2]]] = $qd;
  1672. }
  1673. **/
  1674. if(isset($zdata[$val[1].'|'.$val[2]]))
  1675. {
  1676. if(isset($zdata[$val[1].'|'.$val[2]][$val[0]]))
  1677. {
  1678. $zdata[$val[1].'|'.$val[2]][$val[0]] += 1;
  1679. }
  1680. }
  1681. else
  1682. {
  1683. $zdata[$val[1].'|'.$val[2]] = $qd;
  1684. if(isset($zdata[$val[1].'|'.$val[2]][$val[0]]))
  1685. {
  1686. $zdata[$val[1].'|'.$val[2]][$val[0]] += 1;
  1687. }
  1688. }
  1689. }
  1690. //echo count($list);
  1691. //echo "<pre>";
  1692. //print_r($zdata);
  1693. //exit;
  1694. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1695. <head>
  1696. <!--[if gte mso 9]><xml>
  1697. <x:ExcelWorkbook>
  1698. <x:ExcelWorksheets>
  1699. <x:ExcelWorksheet>
  1700. <x:Name>EXCEL</x:Name>
  1701. <x:WorksheetOptions>
  1702. <x:Print>
  1703. <x:ValidPrinterInfo />
  1704. </x:Print>
  1705. </x:WorksheetOptions>
  1706. </x:ExcelWorksheet>
  1707. </x:ExcelWorksheets>
  1708. </x:ExcelWorkbook>
  1709. </xml>
  1710. <![endif]-->
  1711. </head><body>";
  1712. $str .= "<table border=1 style='background-color: #2ca8a1;font-weight: bold;color:#fff;font-size: 14px;table-layout:fixed'><tr height='50' align='center'>
  1713. <td align='left'>产品</td>
  1714. ".$td."
  1715. </tr></table>";
  1716. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
  1717. foreach ($zdata as $key=>$value)
  1718. {
  1719. $key = explode('|',$key);
  1720. $str .= "<tr height='50'><td align='center'><b>".$tc[$key[0]].' '.$tc[$key[1]]."</b></td>";
  1721. foreach ($value as $ke=>$va)
  1722. {
  1723. if($va > 0)
  1724. {
  1725. $str .= "<td align='center'><b>".$va."</b></td>";
  1726. }
  1727. else
  1728. {
  1729. $str .= "<td align='center'>".$va."</td>";
  1730. }
  1731. }
  1732. $str .= "</tr>\n";
  1733. }
  1734. $str .= "</body></html>";
  1735. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  1736. header( "Content-type: application/octet-stream" );
  1737. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  1738. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  1739. header( "Pragma: no-cache" );
  1740. header( "Expires: 0" );
  1741. exit($str);
  1742. }
  1743. }
  1744. public function _list()
  1745. {
  1746. if(isset($_SESSION['api']))
  1747. {
  1748. $user = $this->user->get_api($_SESSION['api']);
  1749. $usp = $user;
  1750. $fgshop = "";$sid = "";
  1751. $usersp = explode('|',trim($user['shop'],'|'));
  1752. foreach ($usersp as $value)
  1753. {
  1754. $fgshop .= " shop = ".$value." or";
  1755. $sid .= " id = ".$value." or";
  1756. }
  1757. }
  1758. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1759. $this->data['wlshop'] = $wlshop;
  1760. $this->_Template('systemdownload_list',$this->data);
  1761. }
  1762. public function _listread()
  1763. {
  1764. if(isset($_SESSION['api']))
  1765. {
  1766. $user = $this->user->get_api($_SESSION['api']);
  1767. $usp = $user;
  1768. $fgshop = "";$sid = "";$excelshop="";
  1769. $usersp = explode('|',trim($user['shop'],'|'));
  1770. foreach ($usersp as $value)
  1771. {
  1772. $fgshop .= " shop = ".$value." or";
  1773. $sid .= " id = ".$value." or";
  1774. }
  1775. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1776. foreach ($userexcel as $value)
  1777. {
  1778. $excelshop .= " shop = ".$value." or";
  1779. }
  1780. if($excelshop != "")
  1781. {
  1782. $excelshop = "(".rtrim($excelshop,'or').")";
  1783. }
  1784. }
  1785. $post = $this->input->post(NULL, TRUE);
  1786. if(isset($_GET['category']))
  1787. {
  1788. $timetk = $this->input->get('timetk',true);
  1789. $timetj = $this->input->get('timetj',true);
  1790. $color = $this->input->get('color',true);
  1791. $lowe = $this->input->get('lowe',true);
  1792. $size = $this->input->get('size',true);
  1793. $grade = $this->input->get('grade',true);
  1794. $lacetype = $this->input->get('lacetype',true);
  1795. $category = $this->input->get('category',true);
  1796. $shop = $this->input->get('shop',true);
  1797. $time = $this->input->get('time',true);
  1798. $timetk = strtotime($timetk);
  1799. $timetj = strtotime($timetj);
  1800. $cw = array();
  1801. $class = array();$classdata = array();$lx = array();$pm = array();$ttzllist = array();$hxlist = array();
  1802. $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');
  1803. foreach ($a as $val)
  1804. {
  1805. $class[] = '-'.$val['id'].'-';
  1806. }
  1807. $b = $this->typeclass->find_all();
  1808. foreach ($b as $val)
  1809. {
  1810. $classdata[$val['id']] = $val['title'];
  1811. $lx[$val['id']] = $val['classid'];
  1812. $pm[$val['id']] = $val['zh'];
  1813. }
  1814. $ttzl = $this->typeclass->find_all("classid = '18'");
  1815. foreach ($ttzl as $val)
  1816. {
  1817. $ttzllist[$val['id']] = $val['classid'];
  1818. }
  1819. $hx = $this->typeclass->find_all("classid = '15'");
  1820. foreach ($hx as $val)
  1821. {
  1822. $hxlist[$val['id']] = $val['classid'];
  1823. }
  1824. //Closure wigs
  1825. $fpdata = '';
  1826. $category = explode('|',trim($category,'|'));
  1827. foreach ($category as $value)
  1828. {
  1829. $fpdata .= "fpdata like '%".$value."%' or ";
  1830. }
  1831. if(count($category) > 1)
  1832. {
  1833. $fpdata = "(".trim($fpdata,' or ').")";
  1834. }
  1835. else
  1836. {
  1837. $fpdata = trim($fpdata,' or ');
  1838. }
  1839. $where = "shop != '9' and shop != '26' and ";
  1840. if($color)
  1841. {
  1842. $where .= "fpdata like '%$color%' and ";
  1843. }
  1844. if($lowe)
  1845. {
  1846. $where .= "fpdata like '%$lowe%' and ";
  1847. }
  1848. if($size)
  1849. {
  1850. $where .= "fpdata like '%$size%' and ";
  1851. }
  1852. if($grade)
  1853. {
  1854. $where .= "fpdata like '%$grade%' and ";
  1855. }
  1856. if($lacetype)
  1857. {
  1858. $where .= "fpdata like '%$lacetype%' and ";
  1859. }
  1860. if($shop)
  1861. {
  1862. $where .= "shop = '$shop' and ";
  1863. }
  1864. else
  1865. {
  1866. $where .= $excelshop." and ";
  1867. }
  1868. $dataa = $this->fullorder->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  1869. $datab = $this->fullordersmt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  1870. $datac = $this->fullordertt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
  1871. $data = array_merge($dataa,$datab,$datac);
  1872. //echo $where."librarytime > '$timetk' and librarytime < '$timetj' and ".$fpdata;
  1873. //echo "<pre>";
  1874. //print_r($data);
  1875. //exit;
  1876. $pd = '';
  1877. $p = $class;
  1878. $resdata = array();
  1879. foreach ($data as $val)
  1880. {
  1881. $f = explode(';',trim($val['fpdata'],';'));
  1882. foreach ($f as $v)
  1883. {
  1884. if($color)
  1885. {
  1886. if(stripos($v,'-'.$color.'-') === false)
  1887. {
  1888. continue;
  1889. }
  1890. }
  1891. if($lowe)
  1892. {
  1893. if(stripos($v,'-'.$lowe.'-') === false)
  1894. {
  1895. continue;
  1896. }
  1897. }
  1898. if($size)
  1899. {
  1900. if(stripos($v,$size.',') === false)
  1901. {
  1902. continue;
  1903. }
  1904. }
  1905. if($grade)
  1906. {
  1907. if(stripos($v,'-'.$grade.'-') === false)
  1908. {
  1909. continue;
  1910. }
  1911. }
  1912. if($lacetype)
  1913. {
  1914. if(stripos($v,'-'.$lacetype.'-') === false)
  1915. {
  1916. continue;
  1917. }
  1918. }
  1919. $i = 0;
  1920. foreach ($category as $value)
  1921. {
  1922. if(stripos($v,'-'.$value.'-') !== false)
  1923. {
  1924. $i++;
  1925. }
  1926. }
  1927. if($i > 0)
  1928. {
  1929. $e = explode('|',$v);
  1930. $d = str_replace($p,'-',$e[0]);
  1931. $q = str_replace(array('-163-','-164-','-165-','-166-','-782-','-79-','-80-','-81-','-497-'),'-',$e[0]);
  1932. $fl = explode(',',$q);//分离出尺寸和其它内容
  1933. $cpkey = str_replace('-','',$fl[1]);
  1934. $tt = explode('-',trim($fl[1],'-'));
  1935. $title = '';$fla='';$flb='';
  1936. foreach ($tt as $value)
  1937. {
  1938. if(isset($ttzllist[$value]))
  1939. {
  1940. if($ttzllist[$value] == '18')
  1941. {
  1942. $fla = $value;
  1943. }
  1944. }
  1945. if(isset($hxlist[$value]))
  1946. {
  1947. if($hxlist[$value] == '15')
  1948. {
  1949. $flb = $value;
  1950. }
  1951. }
  1952. }
  1953. //$c = explode(',',$e[0]);
  1954. if(!isset($resdata[$fla.$flb]) && $fla != '' && $flb != '')
  1955. {
  1956. if(stripos($pm[$fla],'|') !== false)
  1957. {
  1958. $pm[$fla] = explode('|',$pm[$fla]);
  1959. $pm[$fla] = $pm[$fla][0];
  1960. }
  1961. if(stripos($pm[$flb],'|') !== false)
  1962. {
  1963. $pm[$flb] = explode('|',$pm[$flb]);
  1964. $pm[$flb] = $pm[$flb][0];
  1965. }
  1966. $title = $pm[$fla].' '. $pm[$flb];
  1967. $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);
  1968. if(isset($resdata[$fla.$flb][$fl[0]]))
  1969. {
  1970. $resdata[$fla.$flb][$fl[0]] += $e[2];
  1971. }
  1972. }
  1973. else if ($fla != '' && $flb != '' && isset($resdata[$fla.$flb][$fl[0]]))
  1974. {
  1975. $resdata[$fla.$flb][$fl[0]] += $e[2];
  1976. }
  1977. }
  1978. }
  1979. }
  1980. rsort($resdata);
  1981. //echo count($list);
  1982. //echo "<pre>";
  1983. //print_r($list);
  1984. //exit;
  1985. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  1986. <head>
  1987. <!--[if gte mso 9]><xml>
  1988. <x:ExcelWorkbook>
  1989. <x:ExcelWorksheets>
  1990. <x:ExcelWorksheet>
  1991. <x:Name>EXCEL</x:Name>
  1992. <x:WorksheetOptions>
  1993. <x:Print>
  1994. <x:ValidPrinterInfo />
  1995. </x:Print>
  1996. </x:WorksheetOptions>
  1997. </x:ExcelWorksheet>
  1998. </x:ExcelWorksheets>
  1999. </x:ExcelWorkbook>
  2000. </xml>
  2001. <![endif]-->
  2002. </head><body>";
  2003. $str .= "<table border=1 style='background-color: #2ca8a1;font-weight: bold;color:#fff;font-size: 14px;table-layout:fixed'><tr height='50' align='center'>
  2004. <td align='left'>产品</td>
  2005. <td>6</td>
  2006. <td>8</td>
  2007. <td>10</td>
  2008. <td>12</td>
  2009. <td>14</td>
  2010. <td>16</td>
  2011. <td>18</td>
  2012. <td>20</td>
  2013. <td>22</td>
  2014. <td>24</td>
  2015. <td>26</td>
  2016. <td>28</td>
  2017. <td>30</td>
  2018. <td>32</td>
  2019. <td>34</td>
  2020. <td>36</td>
  2021. <td>38</td>
  2022. <td>40</td>
  2023. <td>42</td>
  2024. <td>44</td>
  2025. </tr></table>";
  2026. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
  2027. foreach ($resdata as $key=>$value)
  2028. {
  2029. $str .= "<tr height='50'>";
  2030. foreach ($value as $ke=>$va)
  2031. {
  2032. if(is_numeric($va))
  2033. {
  2034. if($va > 0)
  2035. {
  2036. $str .= "<td align='center'><b>".$va."</b></td>";
  2037. }
  2038. else
  2039. {
  2040. $str .= "<td align='center'>".$va."</td>";
  2041. }
  2042. }
  2043. else
  2044. {
  2045. $str .= "<td>".$va."</td>";
  2046. }
  2047. }
  2048. $str .= "</tr>\n";
  2049. }
  2050. $str .= "</body></html>";
  2051. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  2052. header( "Content-type: application/octet-stream" );
  2053. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  2054. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  2055. header( "Pragma: no-cache" );
  2056. header( "Expires: 0" );
  2057. exit($str);
  2058. }
  2059. }
  2060. }