123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Systemdownload extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_typeclass','typeclass');
- $this->load->_model('Model_fullorder','fullorder');
- $this->load->_model('Model_fullordertt','fullordertt');
- $this->load->_model('Model_fullordersmt','fullordersmt');
- $this->load->_model('Model_shop','shop');
- $this->load->_model('Model_user','user');
- $this->load->_model('Model_excel','excel');
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'data')
- {
- $this->_data();
- }
- else if($arg == 'hd')
- {
- $this->_hd();
- }
- else if($arg == 'qm')
- {
- $this->_qm();
- }
- else if($arg == 'bh')
- {
- $this->_bh();
- }
- else if($arg == 'hsp')
- {
- $this->_hsp();
- }
- else if($arg == 'list')
- {
- $this->_list();
- }
- else if($arg == 'listread')
- {
- $this->_listread();
- }
- else
- {
- $this->_index();
- }
- }
-
- public function _index()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('systemdownload',$this->data);
- }
-
- public function getCombinationToString($val)
- {
- static $res = array();
- if(empty($res))
- {
- $res = $val;
- }
- else
- {
- $list = array();
- foreach ($res as $k => $v)
- {
- foreach ($val as $key => $value)
- {
- $list[] = $v.','.$value;
- }
- }
- $res = $list;
- }
- return $res;
- }
- public function _data()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$excelshop="";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- $userexcel = explode('|',trim($user['excelshop'],'|'));
- foreach ($userexcel as $value)
- {
- $excelshop .= " shop = ".$value." or";
- }
- if($excelshop != "")
- {
- $excelshop = "(".rtrim($excelshop,'or').")";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($_GET['category']))
- {
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $lacetype = $this->input->get('lacetype',true);
- $category = $this->input->get('category',true);
- $haircap = $this->input->get('haircap',true);
- $shop = $this->input->get('shop',true);
- $density = $this->input->get('density',true);
- $time = $this->input->get('time',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
-
- $cw = array();
- $class = array();$classdata = array();$lx = array();$pm = array();
- $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');
- foreach ($a as $val)
- {
- $class[] = '-'.$val['id'].'-';
- }
- $b = $this->typeclass->find_all();
- foreach ($b as $val)
- {
- $classdata[$val['id']] = $val['title'];
- $lx[$val['id']] = $val['classid'];
- $pm[$val['id']] = $val['zh'];
- }
- //Closure wigs
- $fpdata = '';
- $category = explode('|',trim($category,'|'));
- foreach ($category as $value)
- {
- $fpdata .= "fpdata like '%".$value."%' or ";
- }
- if(count($category) > 1)
- {
- $fpdata = "(".trim($fpdata,' or ').")";
- }
- else
- {
- $fpdata = trim($fpdata,' or ');
- }
- $where = "";
- if($color)
- {
- $where .= "fpdata like '%$color%' and ";
- }
- if($size)
- {
- $where .= "fpdata like '%$size%' and ";
- }
- if($grade)
- {
- $where .= "fpdata like '%$grade%' and ";
- }
- if($shop)
- {
- $where .= "shop = '$shop' and ";
- }
- else
- {
- $where .= $excelshop." and ";
- }
- if($lowe)
- {
- $arraydata[] = explode(',',rtrim($lowe,','));
- }
- else
- {
- $arraydata[] = array('z');
- }
- if($density)
- {
- $arraydata[] = explode(',',rtrim($density,','));
- }
- else
- {
- $arraydata[] = array('z');
- }
- if($lacetype)
- {
- $arraydata[] = explode(',',rtrim($lacetype,','));
- }
- else
- {
- $arraydata[] = array('z');
- }
- if($haircap)
- {
- $arraydata[] = explode(',',rtrim($haircap,','));
- }
- else
- {
- $arraydata[] = array('z');
- }
- $res = array();
- foreach ($arraydata as $k => $v)
- {
- $res = $this->getCombinationToString($v);
- }
- $warp = array();$cs = array();
- if(!$res)
- {
- $res[0] = 1;
- }
- foreach ($res as $resval)
- {
- $wheredata = '';$btpm = '';
- $resval = explode(',',rtrim($resval,','));
- $lowe = $resval[0];$density = $resval[1];$lacetype = $resval[2];$haircap = $resval[3];
- if($lowe != 'z')
- {
- $wheredata .= "fpdata like '%$lowe%' and ";
- $btpm .= $pm[$lowe];
- }
- if($density != 'z')
- {
- $wheredata .= "fpdata like '%$density%' and ";
- $btpm .= $pm[$density];
- }
- if($lacetype != 'z')
- {
- $wheredata .= "fpdata like '%$lacetype%' and ";
- }
- if($haircap != 'z')
- {
- $wheredata .= "fpdata like '%$haircap%' and ";
- $btpm .= $pm[$haircap];
- }
- $dataa = $this->fullorder->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
- $datab = $this->fullordersmt->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
- $datac = $this->fullordertt->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
- $data = array_merge($dataa,$datab,$datac);
- //echo $where."librarytime > '$timetk' and librarytime < '$timetj' and ".$fpdata;
- //echo "<pre>";
- //print_r($where);
- //exit;
- $cs = array();
- $pd = '';
- $p = $class;
- $resdata = array();
- foreach ($data as $val)
- {
- $f = explode(';',trim($val['fpdata'],';'));
- foreach ($f as $v)
- {
- if($color)
- {
- if(stripos($v,'-'.$color.'-') === false)
- {
- continue;
- }
- }
- if($lowe != 'z')
- {
- if(stripos($v,'-'.$lowe.'-') === false)
- {
- continue;
- }
- }
- if($size)
- {
- if(stripos($v,$size.',') === false)
- {
- continue;
- }
- }
- if($grade)
- {
- if(stripos($v,'-'.$grade.'-') === false)
- {
- continue;
- }
- }
- if($lacetype != 'z')
- {
- $cs[] = $lacetype;
- if(stripos($v,'-'.$lacetype.'-') === false)
- {
- continue;
- }
- }
- if($density != 'z')
- {
- if(stripos($v,'-'.$density.'-') === false)
- {
- continue;
- }
- }
- if($haircap != 'z')
- {
- if(stripos($v,'-'.$haircap.'-') === false)
- {
- continue;
- }
- }
- $i = 0;
- foreach ($category as $value)
- {
- if(stripos($v,'-'.$value.'-') !== false)
- {
- $i++;
- }
- }
- if($i > 0)
- {
- $e = explode('|',$v);
- $d = str_replace($p,'-',$e[0]);
- $q = str_replace(array('-163-','-164-','-165-','-166-'),'-',$e[0]);
- $q = explode('-',trim($q,'-'));
- $c = explode(',',$e[0]);
- if(!isset($resdata[$d]))
- {
- if(stripos($v,'-126-') !== false)
- {
- if(!isset($q[4]) || !isset($pm[$q[4]]))
- {
- continue;
- }
- @$resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[4],1);//数量、尺寸、曲度、无蕾丝颜色
- }
- else if(stripos($v,'-127-') !== false)
- {
- if(isset($q[9]))
- {
- $s = ($q[9] != 68 && $q[9] != 69)?1:2;
- }
- else
- {
- $s = 1;
- }
- $bt = (!isset($q[8]))?$q[5]:$q[8];//360类型的蕾丝尺寸直接显示为类型名称
- if($lx[$q[5]] == '27')//如果是发块类型
- {
- $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$bt,$s);//数量、尺寸、类型、蕾丝尺寸、蕾丝颜色
- }
- }
- else
- {
- if(isset($q[8]))
- {
- $s = ($q[8] != 68 && $q[8] != 69)?1:2;
- }
- else
- {
- $s = 1;
- }
- if(@$lx[$q[5]] == '18')//如果是头套种类
- {
- $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$s);//数量、尺寸、头套种类、蕾丝颜色
- }
- }
- }
- else
- {
- if(isset($e[2]))
- {
- if(is_array($e[2]) || !is_numeric($e[2]))
- {
- $cw[] = $v;
- continue;
- }
- else
- {
- $resdata[$d][0] += $e[2];
- }
- }
- }
- }
- }
- }
- $data = array();
- foreach ($resdata as $v)
- {
- if(isset($v[4]))
- {
- if(!isset($data[$v[1].$v[2].$v[3].$v[4]]))
- {
- $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]]中文名
- }
- else
- {
- $data[$v[1].$v[2].$v[3].$v[4]][0] += $v[0];
- }
- }
- else
- {
- if(!isset($data[$v[1].$v[2].$v[3]]))
- {
- $data[$v[1].$v[2].$v[3]] = array($v[0],$v[1],$pm[$v[2]],$v[3]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
- }
- else
- {
- $data[$v[1].$v[2].$v[3]][0] += $v[0];
- }
- }
- }
- $list = array();
- foreach ($data as $v)
- {
- $x = (isset($v[4]))?$v[3]:$v[2];
- if(!isset($list[$v[2]]))
- {
- $list[$v[2]] = array();
- if(!isset($list[$v[2]][$x]))
- {
- $list[$v[2]][$x] = array();
- $list[$v[2]][$x][] = $v;
- }
- else
- {
- $list[$v[2]][$x][] = $v;
- }
- }
- else
- {
- if(!isset($list[$v[2]][$x]))
- {
- $list[$v[2]][$x] = array();
- $list[$v[2]][$x][] = $v;
- }
- else
- {
- $list[$v[2]][$x][] = $v;
- }
- }
- }
- foreach ($list as $key=>$val)
- {
- foreach ($val as $k=>$va)
- {
- $dd = array();
- foreach ($va as $v)
- {
- $ss = (!isset($v[4]))?$v[3]:$v[4];
- if(!isset($dd[$v['1']]))
- {
- $dd[$v['1']] = array();
- $dd[$v['1']][$ss] = $v;
- }
- else
- {
- $dd[$v['1']][$ss] = $v;
- }
- }
- ksort($dd);
- $list[$key][$k] = $dd;
- }
- }
- $warp[] = array($btpm,$list);
- }
- //echo count($list);
- //echo "<pre>";
- //print_r($warp);
- //exit;
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- foreach ($warp as $list)
- {
- foreach ($list[1] as $key=>$val)
- {
- $btnum = count($val);
- $str .= "<table border=1>
- <tr>";
- foreach ($val as $k=>$v)
- {
- $str .="<td style='background-color: #ffff00;color: #F00;width:20px'>".$k.' '.$list[0]."</td>
- <td>中棕</td>
- <td>透明</td>";
- }
- $str .= "</tr>
- </table>";
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'><tr>";
- foreach ($val as $k=>$v)
- {
- $str .= "<td><table border=1>";
- foreach ($v as $sk=>$s)
- {
- $xk1 = (isset($s[1]))?$s[1][0]:0;
- $xk2 = (isset($s[2]))?$s[2][0]:0;
- $str .="<tr><td style='color: #F00;'>".$sk."</td><td>".$xk1."</td><td>".$xk2."</td></tr>";
- }
- $str .= "</table></td>";
- }
- $str .= "</table>";
- }
- }
- $str .= "</body></html>";
- header( "Content-Type: application/vnd.ms-excel; name='excel'" );
- header( "Content-type: application/octet-stream" );
- header( "Content-Disposition: attachment; filename=".time().'.xls' );
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header( "Pragma: no-cache" );
- header( "Expires: 0" );
- exit($str);
- }
- }
-
-
- public function _hd()//区分HD和其他颜色
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$excelshop="";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- $userexcel = explode('|',trim($user['excelshop'],'|'));
- foreach ($userexcel as $value)
- {
- $excelshop .= " shop = ".$value." or";
- }
- if($excelshop != "")
- {
- $excelshop = "(".rtrim($excelshop,'or').")";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($_GET['category']))
- {
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $lacetype = $this->input->get('lacetype',true);
- $category = $this->input->get('category',true);
- $haircap = $this->input->get('haircap',true);
- $shop = $this->input->get('shop',true);
- $density = $this->input->get('density',true);
- $time = $this->input->get('time',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
-
- $cw = array();
- $class = array();$classdata = array();$lx = array();$pm = array();
- $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');
- foreach ($a as $val)
- {
- $class[] = '-'.$val['id'].'-';
- }
- $b = $this->typeclass->find_all();
- foreach ($b as $val)
- {
- $classdata[$val['id']] = $val['title'];
- $lx[$val['id']] = $val['classid'];
- $pm[$val['id']] = $val['zh'];
- }
- //Closure wigs
- $fpdata = '';
- $category = explode('|',trim($category,'|'));
- foreach ($category as $value)
- {
- $fpdata .= "fpdata like '%".$value."%' or ";
- }
- if(count($category) > 1)
- {
- $fpdata = "(".trim($fpdata,' or ').")";
- }
- else
- {
- $fpdata = trim($fpdata,' or ');
- }
- $where = "";
- if($color)
- {
- $where .= "fpdata like '%$color%' and ";
- }
- if($size)
- {
- $where .= "fpdata like '%$size%' and ";
- }
- if($grade)
- {
- $where .= "fpdata like '%$grade%' and ";
- }
- if($shop)
- {
- $where .= "shop = '$shop' and ";
- }
- else
- {
- $where .= $excelshop." and ";
- }
- if($lowe)
- {
- $arraydata[] = explode(',',rtrim($lowe,','));
- }
- else
- {
- $arraydata[] = array('z');
- }
- if($density)
- {
- $arraydata[] = explode(',',rtrim($density,','));
- }
- else
- {
- $arraydata[] = array('z');
- }
- if($lacetype)
- {
- $arraydata[] = explode(',',rtrim($lacetype,','));
- }
- else
- {
- $arraydata[] = array('z');
- }
- if($haircap)
- {
- $arraydata[] = explode(',',rtrim($haircap,','));
- }
- else
- {
- $arraydata[] = array('z');
- }
- $res = array();
- foreach ($arraydata as $k => $v)
- {
- $res = $this->getCombinationToString($v);
- }
- $warp = array();$cs = array();
- if(!$res)
- {
- $res[0] = 1;
- }
- foreach ($res as $resval)
- {
- $wheredata = '';$btpm = '';
- $resval = explode(',',rtrim($resval,','));
- $lowe = $resval[0];$density = $resval[1];$lacetype = $resval[2];$haircap = $resval[3];
- if($lowe != 'z')
- {
- $wheredata .= "fpdata like '%$lowe%' and ";
- $btpm .= $pm[$lowe];
- }
- if($density != 'z')
- {
- $wheredata .= "fpdata like '%$density%' and ";
- $btpm .= $pm[$density];
- }
- if($lacetype != 'z')
- {
- $wheredata .= "fpdata like '%$lacetype%' and ";
- }
- if($haircap != 'z')
- {
- $wheredata .= "fpdata like '%$haircap%' and ";
- $btpm .= $pm[$haircap];
- }
- $dataa = $this->fullorder->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
- $datab = $this->fullordersmt->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
- $datac = $this->fullordertt->find_all($wheredata.$where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
- $data = array_merge($dataa,$datab,$datac);
- //echo $where."librarytime > '$timetk' and librarytime < '$timetj' and ".$fpdata;
- //echo "<pre>";
- //print_r($where);
- //exit;
- $cs = array();
- $pd = '';
- $p = $class;
- $resdata = array();
- foreach ($data as $val)
- {
- $f = explode(';',trim($val['fpdata'],';'));
- foreach ($f as $v)
- {
- if($color)
- {
- if(stripos($v,'-'.$color.'-') === false)
- {
- continue;
- }
- }
- if($lowe != 'z')
- {
- if(stripos($v,'-'.$lowe.'-') === false)
- {
- continue;
- }
- }
- if($size)
- {
- if(stripos($v,$size.',') === false)
- {
- continue;
- }
- }
- if($grade)
- {
- if(stripos($v,'-'.$grade.'-') === false)
- {
- continue;
- }
- }
- if($lacetype != 'z')
- {
- $cs[] = $lacetype;
- if(stripos($v,'-'.$lacetype.'-') === false)
- {
- continue;
- }
- }
- if($density != 'z')
- {
- if(stripos($v,'-'.$density.'-') === false)
- {
- continue;
- }
- }
- if($haircap != 'z')
- {
- if(stripos($v,'-'.$haircap.'-') === false)
- {
- continue;
- }
- }
- $i = 0;
- foreach ($category as $value)
- {
- if(stripos($v,'-'.$value.'-') !== false)
- {
- $i++;
- }
- }
- if($i > 0)
- {
- $e = explode('|',$v);
- $d = str_replace($p,'-',$e[0]);
- $q = str_replace(array('-163-','-164-','-165-','-166-'),'-',$e[0]);
- $q = explode('-',trim($q,'-'));
- $c = explode(',',$e[0]);
- if(!isset($resdata[$d]))
- {
- if(stripos($v,'-126-') !== false)
- {
- if(!isset($q[4]) || !isset($pm[$q[4]]))
- {
- continue;
- }
- @$resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[4],1);//数量、尺寸、曲度、无蕾丝颜色
- }
- else if(stripos($v,'-127-') !== false)
- {
- if(isset($q[9]))
- {
- $s = ($q[9] != 335)?1:2;
- }
- else
- {
- $s = 1;
- }
- $bt = (!isset($q[8]))?$q[5]:$q[8];//360类型的蕾丝尺寸直接显示为类型名称
- if($lx[$q[5]] == '27')//如果是发块类型
- {
- $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$bt,$s);//数量、尺寸、类型、蕾丝尺寸、蕾丝颜色
- }
- }
- else
- {
- if(isset($q[8]))
- {
- $s = ($q[8] != 335)?1:2;
- }
- else
- {
- $s = 1;
- }
- if(@$lx[$q[5]] == '18')//如果是头套种类
- {
- $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$s);//数量、尺寸、头套种类、蕾丝颜色
- }
- }
- }
- else
- {
- if(isset($e[2]))
- {
- if(is_array($e[2]) || !is_numeric($e[2]))
- {
- $cw[] = $v;
- continue;
- }
- else
- {
- $resdata[$d][0] += $e[2];
- }
- }
- }
- }
- }
- }
- $data = array();
- foreach ($resdata as $v)
- {
- if(isset($v[4]))
- {
- if(!isset($data[$v[1].$v[2].$v[3].$v[4]]))
- {
- $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]]中文名
- }
- else
- {
- $data[$v[1].$v[2].$v[3].$v[4]][0] += $v[0];
- }
- }
- else
- {
- if(!isset($data[$v[1].$v[2].$v[3]]))
- {
- $data[$v[1].$v[2].$v[3]] = array($v[0],$v[1],$pm[$v[2]],$v[3]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
- }
- else
- {
- $data[$v[1].$v[2].$v[3]][0] += $v[0];
- }
- }
- }
- $list = array();
- foreach ($data as $v)
- {
- $x = (isset($v[4]))?$v[3]:$v[2];
- if(!isset($list[$v[2]]))
- {
- $list[$v[2]] = array();
- if(!isset($list[$v[2]][$x]))
- {
- $list[$v[2]][$x] = array();
- $list[$v[2]][$x][] = $v;
- }
- else
- {
- $list[$v[2]][$x][] = $v;
- }
- }
- else
- {
- if(!isset($list[$v[2]][$x]))
- {
- $list[$v[2]][$x] = array();
- $list[$v[2]][$x][] = $v;
- }
- else
- {
- $list[$v[2]][$x][] = $v;
- }
- }
- }
- foreach ($list as $key=>$val)
- {
- foreach ($val as $k=>$va)
- {
- $dd = array();
- foreach ($va as $v)
- {
- $ss = (!isset($v[4]))?$v[3]:$v[4];
- if(!isset($dd[$v['1']]))
- {
- $dd[$v['1']] = array();
- $dd[$v['1']][$ss] = $v;
- }
- else
- {
- $dd[$v['1']][$ss] = $v;
- }
- }
- ksort($dd);
- $list[$key][$k] = $dd;
- }
- }
- $warp[] = array($btpm,$list);
- }
- //echo count($list);
- //echo "<pre>";
- //print_r($warp);
- //exit;
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- foreach ($warp as $list)
- {
- foreach ($list[1] as $key=>$val)
- {
- $btnum = count($val);
- $str .= "<table border=1>
- <tr>";
- foreach ($val as $k=>$v)
- {
- $str .="<td style='background-color: #ffff00;color: #F00;width:20px'>".$k.' '.$list[0]."</td>
- <td>其它</td>
- <td>HD</td>";
- }
- $str .= "</tr>
- </table>";
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'><tr>";
- foreach ($val as $k=>$v)
- {
- $str .= "<td><table border=1>";
- foreach ($v as $sk=>$s)
- {
- $xk1 = (isset($s[1]))?$s[1][0]:0;
- $xk2 = (isset($s[2]))?$s[2][0]:0;
- $str .="<tr><td style='color: #F00;'>".$sk."</td><td>".$xk1."</td><td>".$xk2."</td></tr>";
- }
- $str .= "</table></td>";
- }
- $str .= "</table>";
- }
- }
- $str .= "</body></html>";
- header( "Content-Type: application/vnd.ms-excel; name='excel'" );
- header( "Content-type: application/octet-stream" );
- header( "Content-Disposition: attachment; filename=".time().'.xls' );
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header( "Pragma: no-cache" );
- header( "Expires: 0" );
- exit($str);
- }
- }
-
-
- public function _bh()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$exsp = "";$excelshop="";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- $userexcel = explode('|',trim($user['excelshop'],'|'));
- foreach ($userexcel as $value)
- {
- $excelshop .= " shop = ".$value." or";
- $exsp .= " id = ".$value." or";
- }
- if($excelshop != "")
- {
- $excelshop = "(".rtrim($excelshop,'or').")";
- }
- }
- $cs = array();//测试
- $post = $this->input->post(NULL, TRUE);
- if(isset($_GET['excel']))
- {
- $shop = $this->input->get('shop',true);
- $color = $this->input->get('color',true);
- $grade = $this->input->get('grade',true);
- $lowe = $this->input->get('lowe',true);
- $lacetype = $this->input->get('lacetype',true);
- $time = $this->input->get('time',true);
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "fpdata like '%-128-%' and ";//头套
- $fpdata = '';
- if($lacetype)
- {
- $lacetypefp = '';
- $lacetypedata = explode(',',trim($lacetype,','));
- foreach ($lacetypedata as $value)
- {
- $lacetypefp .= "fpdata like '%-".$value."-%' or ";
- }
- $fpdata .= " and (".rtrim($lacetypefp,' or').")";
- }
- if($lowe)
- {
- $lowefp = '';
- $lowedata = explode(',',trim($lowe,','));
- foreach ($lowedata as $value)
- {
- $lowefp .= "fpdata like '%-".$value."-%' or ";
- }
- $fpdata .= " and (".rtrim($lowefp,' or').")";
- }
- if($shop)
- {
- $where .= "shop = '$shop' and ";
- }
- else
- {
- $where .= $excelshop." and ";
- }
- if($color)
- {
- $where .= "fpdata like '%$color%' and ";
- }
- if($grade)
- {
- $where .= "fpdata like '%$grade%' and ";
- }
- $density = array();
- $size = array();
- $haircap = array();
- $md = $this->typeclass->find_all("classid = '10'");//密度
- foreach ($md as $val)
- {
- $density[$val['id']] = '';
- }
- $cd = $this->typeclass->find_all("classid = '14'",'*','id asc');//长度 and id != '774' and bqsku < 32之前的限制
- foreach ($cd as $val)
- {
- $size[$val['id']] = $density;
- }
- $fm = $this->typeclass->find_all("classid = '6'");
- foreach ($fm as $val)
- {
- $haircap[$val['id']] = $size;
- }
- $dataa = $this->fullorder->find_all($where.$time." > '$timetk' and ".$time." < '$timetj'".$fpdata,'number,fpdata','id desc');
- $datab = $this->fullordersmt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj'".$fpdata,'number,fpdata','id desc');
- $datac = $this->fullordertt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj'".$fpdata,'number,fpdata','id desc');
- $data = array_merge($dataa,$datab,$datac);
- $fpdata = array();
- foreach ($data as $val)
- {
- $f = explode(';',trim($val['fpdata'],';'));
- foreach ($f as $v)
- {
- if(stripos($v,'-128-') === false)
- {
- continue;
- }
- if($color)
- {
- if(stripos($v,'-'.$color.'-') === false)
- {
- continue;
- }
- }
- if($grade)
- {
- if(stripos($v,'-'.$grade.'-') === false)
- {
- continue;
- }
- }
- if($lowe)
- {
- $arraylowe = explode(',',trim($lowe,','));
- $i = 0;
- foreach ($arraylowe as $vv)
- {
- if(stripos($v,'-'.$vv.'-') === false)
- {
- $i++;
- }
- }
- if($i == count($arraylowe))
- {
- continue;
- }
- }
- if($lacetype)
- {
- $arraylacetype = explode(',',trim($lacetype,','));
- $i = 0;
- foreach ($arraylacetype as $vv)
- {
- if(stripos($v,'-'.$vv.'-') === false)
- {
- $i++;
- }
- }
- if($i == count($arraylacetype))
- {
- continue;
- }
- }
- $fdd = explode('|',trim($v,'|'));
- $fddf = explode('-',trim($fdd[0],'-'));
- if(isset($fddf[7]))
- {
- $fpdata[] = array($fddf[4],$fddf[5],$fddf[7],trim($fddf[0],','),$fddf[6],$fdd[2],$val['number']);//曲度,蕾丝种类,密度,长度,发帽大小,数量
- }
- }
- }
-
- $tc = array();
- $qbtc = $this->typeclass->find_all();
- foreach ($qbtc as $val)
- {
- $tc[$val['id']] = $val['bqsku'];
- }
- $zh = array();
- $qbzh = $this->typeclass->find_all();
- foreach ($qbzh as $val)
- {
- $zh[$val['id']] = $val['zh'];
- }
- $qd = array();$td = '';
- $qddata = $this->typeclass->find_all("classid = '15'");
- foreach ($qddata as $val)
- {
- $qd[$val['id']] = 0;
- $td .= '<td>'.$val['bqsku'].'</td>';
- }
-
- $zdata = array();
- foreach ($fpdata as $val)
- {
- if(isset($zdata[$val[0].'|'.$val[1]]))
- {
- if(isset($zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]]))
- {
- if($zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]] == '')
- {
- $zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]] = $val[5];
- }
- else
- {
- $zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]] += $val[5];
- }
- }
- }
- else
- {
- $zdata[$val[0].'|'.$val[1]] = $haircap;
- if(isset($zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]]))
- {
- $zdata[$val[0].'|'.$val[1]][$val[4]][$val[3]][$val[2]] = $val[5];
- }
- }
- }
- foreach ($zdata as $key=>$value)
- {
- foreach ($value as $ke=>$va)
- {
- foreach ($va as $kk=>$vv)
- {
- $i = 0;
- foreach ($vv as $v)
- {
- if($v == '')
- {
- $i++;
- }
- }
- if($i == count($density))
- {
- unset($zdata[$key][$ke][$kk]);
- }
- }
- }
- }
- foreach ($zdata as $key=>$value)
- {
- $i = 0;
- foreach ($value as $ke=>$va)
- {
- if(empty($va))
- {
- $i++;
- }
- if($i == count($value))
- {
- unset($zdata[$key]);
- }
- }
- }
- //sort($zdata);//排序
- //echo count($list);
- //echo "<pre>";
- //print_r($zdata);
- //exit;
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- foreach ($zdata as $key=>$value)
- {
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;background-color: #e2efda;'>";
- $key = explode('|',$key);
- $str .= "<tr><th colspan='3' align='center'><h3>".$zh[$key[0]].' '.$zh[$key[1]]."<h3></th></tr><tr height='50'>";
- $y = 0;
- foreach ($value as $ke=>$va)
- {
- $y++;
- if($y == 2)
- {
- $backgrounda = '#ffff00';
- $backgroundb = '#bad5df';
- }
- else
- {
- $backgrounda = '#e2efda';
- $backgroundb = '#9bc2e6';
- }
- $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>";
- $str .= "<tr><td align='center' style='background-color: ".$backgroundb.";'>尺寸/密度</td>";
- foreach ($density as $kk=>$vv)
- {
- $str .= "<td align='center'>".$tc[$kk]."</td>";
- }
- $str .= "</tr>";
- foreach ($va as $kk=>$vv)
- {
- $str .= "<tr height='50'><td align='center' style='background-color: ".$backgroundb.";'><b>".$tc[$kk]."</b></td>";
- foreach ($vv as $v)
- {
- $str .= "<td align='center'>".$v."</td>";
- }
- $str .= "</tr>";
- }
- $str .= "</table></td>";
- }
- $str .= "</tr></table><br><br>";
- }
- $str .= "</body></html>";
- header( "Content-Type: application/vnd.ms-excel; name='excel'" );
- header( "Content-type: application/octet-stream" );
- header( "Content-Disposition: attachment; filename=".time().'.xls' );
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header( "Pragma: no-cache" );
- header( "Expires: 0" );
- exit($str);
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($exsp,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('systemdownload_bh',$this->data);
- }
-
-
- public function _hsp()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$excelshop="";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- $userexcel = explode('|',trim($user['excelshop'],'|'));
- foreach ($userexcel as $value)
- {
- $excelshop .= " shop = ".$value." or";
- }
- if($excelshop != "")
- {
- $excelshop = "(".rtrim($excelshop,'or').")";
- }
- }
- $cs = array();//测试
- $post = $this->input->post(NULL, TRUE);
- if(isset($_GET['excel']))
- {
- $type = $this->input->get('type',true);
- $lace = $this->input->get('lace',true);
- $color = $this->input->get('color',true);
- $grade = $this->input->get('grade',true);
- $lacetype = $this->input->get('lacetype',true);
- $time = $this->input->get('time',true);
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- if($type == 1)
- {
- $where = "fpdata like '%-128-%' and ".$excelshop." and ";//头套
- }
- else
- {
- if($lace == 1)
- {
- $where = "fpdata like '%-127-%' and fpdata NOT LIKE '%-335-%' and ".$excelshop." and ";
- }
- else
- {
- $where = "fpdata like '%-127-%' and fpdata like '%-335-%' and ".$excelshop." and ";
- }
- }
- $fpdata = '';$px = array();$fl = array();
- if($lacetype)
- {
- $lacetypefp = '';
- $lacetypedata = explode(',',trim($lacetype,','));
- foreach ($lacetypedata as $value)
- {
- $value = explode('|',$value);
- $px[$value[0]] = '';
- $val = explode('-',$value[1]);
- foreach ($val as $k=>$v)
- {
- $fl[$v] = $value[0];
- $lacetypefp .= " fpdata like '%-".$v."-%' or ";
- }
- }
- $fpdata .= " and (".rtrim($lacetypefp,' or').")";
- }
- $colortitle = '';
- if($color)
- {
- $where .= " fpdata like '%-$color-%' and ";
- $colortitle = $this->typeclass->read($color);
- $colortitle = $colortitle['zh'];
- }
- if($grade)
- {
- $where .= " fpdata like '%-$grade-%' and ";
- }
- $size = array();$cc = array();
- $cd = $this->typeclass->find_all("classid = '14' and id != '774' and id != '6' and id != '99' and id != '100'",'*','id asc');//长度
- foreach ($cd as $val)
- {
- $cc[] = $val['bqsku'];
- $size[$val['id']] = 0;
- }
- $dataa = $this->fullorder->find_all($where." $time > '$timetk' and $time < '$timetj'".$fpdata,'number,fpdata','id desc');
- $datab = $this->fullordersmt->find_all($where." $time > '$timetk' and $time < '$timetj'".$fpdata,'number,fpdata','id desc');
- $datac = $this->fullordertt->find_all($where." $time > '$timetk' and $time < '$timetj'".$fpdata,'number,fpdata','id desc');
- $data = array_merge($dataa,$datab,$datac);
- $fpdata = array();$cs[] = array();
- foreach ($data as $val)
- {
- $f = explode(';',trim($val['fpdata'],';'));
- foreach ($f as $v)
- {
- $v = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
- if($type == 1 && stripos($v,'-128-') === false)
- {
- continue;
- }
- else if($type == 2 && stripos($v,'-127-') === false)
- {
- continue;
- }
- if($color)
- {
- if(stripos($v,'-'.$color.'-') === false)
- {
- continue;
- }
- }
- if($grade)
- {
- if(stripos($v,'-'.$grade.'-') === false)
- {
- continue;
- }
- }
- if($lacetype)
- {
- $arraylacetype = explode(',',trim($lacetype,','));
- $i = 0;$j = 0;
- foreach ($arraylacetype as $vv)
- {
- $value = explode('|',$vv);
- $value = explode('-',trim($value[1],'-'));
- $j += count($value);
- foreach ($value as $val)
- {
- if(stripos($v,'-'.$val.'-') === false)
- {
- $i++;
- }
- }
- }
- if($i == $j)
- {
- continue;
- }
- }
- $fdd = explode('|',trim($v,'|'));
- $fddf = explode('-',trim($fdd[0],'-'));
- if($type == 1)
- {
- if(isset($fddf[7]) && isset($fl[$fddf[5]]))
- {
- $fpdata[] = array($fl[$fddf[5]],trim($fddf[0],','),$fdd[2]);//蕾丝种类,长度,数量
- }
- }
- else if($type == 2)
- {
- if(isset($fl[$fddf[8]]))
- {
- $fpdata[] = array($fl[$fddf[8]],trim($fddf[0],','),$fdd[2]);//蕾丝种类,长度,数量
- }
- }
- }
- }
- foreach ($fpdata as $val)
- {
- if(isset($zdata[$val[0]]))
- {
- if(isset($zdata[$val[0]][$val[1]]))
- {
- $zdata[$val[0]][$val[1]] += $val[2];
- }
- }
- else
- {
- $zdata[$val[0]] = $size;
- if(isset($zdata[$val[0]][$val[1]]))
- {
- $zdata[$val[0]][$val[1]] += $val[2];
- }
- }
- }
- /**
- foreach ($zdata as $key=>$value)
- {
- foreach ($value as $ke=>$va)
- {
- if($va == '0')
- {
- unset($zdata[$key][$ke]);
- }
- }
- }
- **/
- $tc = array();
- $qbtc = $this->typeclass->find_all();
- foreach ($qbtc as $val)
- {
- $tc[$val['id']] = $val['bqsku'];
- }
- $zh = array();
- $qbzh = $this->typeclass->find_all();
- foreach ($qbzh as $val)
- {
- $zh[$val['id']] = $val['zh'];
- }
- //$px = array('13*4'=>'','4*4'=>'','5*5'=>'','6*6'=>'','13*6'=>'','360'=>'','HD13*4'=>'','HD4*4'=>'','HD5*5'=>'','HD6*6'=>'','HD13*6'=>'');
- foreach ($zdata as $k=>$v)
- {
- $px[$k] = $v;
- }
- foreach ($px as $k=>$v)
- {
- if(!$v)
- {
- unset($px[$k]);
- }
- }
- $zdata = $px;
- //sort($zdata);//排序
- //echo count($list);
- //echo "<pre>";
- //print_r($zdata);
- //exit;
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
-
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
- $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>";
- $str .= "<td><table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
- $str .= "<tr><td align='center' height='30' width='50'>尺寸</td></tr>";
- foreach ($cc as $kk=>$vv)
- {
- $str .= "<tr><td align='center' height='30' width='50'><b>".$vv."</b></td>";
- $str .= "</tr>";
- }
- $str .= "</table></td>";
- foreach ($zdata as $key=>$value)
- {
- $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>";
- foreach ($value as $kk=>$vv)
- {
- if($vv == '0')
- {
- $str .= "<tr><td align='center' height='30' width='50'></td>";
- }
- else
- {
- $str .= "<tr><td align='center' height='30' width='50'>".$vv."</td>";
- }
- $str .= "</tr>";
- }
- $str .= "</table></td>";
- }
- $str .= "</tr></table><br><br>";
-
-
- $str .= "</body></html>";
- header( "Content-Type: application/vnd.ms-excel; name='excel'" );
- header( "Content-type: application/octet-stream" );
- header( "Content-Disposition: attachment; filename=".time().'.xls' );
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header( "Pragma: no-cache" );
- header( "Expires: 0" );
- exit($str);
- }
- $this->_Template('systemdownload_hsp',$this->data);
- }
-
-
- public function _qm()//曲度和密度
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$excelshop="";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- $userexcel = explode('|',trim($user['excelshop'],'|'));
- foreach ($userexcel as $value)
- {
- $excelshop .= " shop = ".$value." or";
- }
- if($excelshop != "")
- {
- $excelshop = "(".rtrim($excelshop,'or').")";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($_GET['excel']))
- {
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- //$lacetype = $this->input->get('lacetype',true);
- $lacetype = '';
- $time = $this->input->get('time',true);
- $timetk = time()-30*24*3600;
- $timetj = time();
- $where = "fpdata like '%-128-%' and shop != '9' and shop != '26' and ".$excelshop." and ";//头套
- $fpdata = '';
- if($lacetype)
- {
- $lacetype = explode(',',trim($lacetype,','));
- foreach ($lacetype as $value)
- {
- $fpdata .= "fpdata like '%-".$value."-%' or ";
- }
- $fpdata = " and (".rtrim($fpdata,' or').")";
- }
-
- $dataa = $this->fullorder->find_all($where."librarytime > '$timetk' and librarytime < '$timetj'".$fpdata,'number,fpdata','id desc');
- $datab = $this->fullordersmt->find_all($where."librarytime > '$timetk' and librarytime < '$timetj'".$fpdata,'number,fpdata','id desc');
- $datac = $this->fullordertt->find_all($where."librarytime > '$timetk' and librarytime < '$timetj'".$fpdata,'number,fpdata','id desc');
- $data = array_merge($dataa,$datab,$datac);
- $fpdata = array();
- foreach ($data as $val)
- {
- $f = explode(';',trim($val['fpdata'],';'));
- foreach ($f as $v)
- {
- if($lacetype)
- {
- foreach ($lacetype as $vv)
- {
- if(stripos($v,'-'.$vv.'-') !== false)
- {
- $fdd = explode('|',trim($val['fpdata'],'|'));
- $fddf = explode('-',trim($fdd[0],'-'));
- if(isset($fddf[7]))
- {
- $fpdata[] = array($fddf[4],$fddf[5],$fddf[7]);//曲度,蕾丝种类,密度
- }
- }
- }
- }
- else
- {
- $fdd = explode('|',trim($val['fpdata'],'|'));
- $fddf = explode('-',trim($fdd[0],'-'));
- if(isset($fddf[7]))
- {
- $fpdata[] = array($fddf[4],$fddf[5],$fddf[7]);//曲度,蕾丝种类,密度
- }
- }
- }
- }
- $tc = array();
- $qbtc = $this->typeclass->find_all();
- foreach ($qbtc as $val)
- {
- $tc[$val['id']] = $val['bqsku'];
- }
- $qd = array();$td = '';
- $qddata = $this->typeclass->find_all("classid = '15'");
- foreach ($qddata as $val)
- {
- $qd[$val['id']] = 0;
- $td .= '<td>'.$val['bqsku'].'</td>';
- }
-
- $zdata = array();
- foreach ($fpdata as $val)
- {
- /**
- if(isset($zdata[$tc[$val[1]].' '.$tc[$val[2]]]))
- {
- if(isset($zdata[$tc[$val[1]].' '.$tc[$val[2]]][$val[0]]))
- {
- $zdata[$tc[$val[1]].' '.$tc[$val[2]]][$val[0]] += 1;
- }
- }
- else
- {
- $zdata[$tc[$val[1]].' '.$tc[$val[2]]] = $qd;
- }
- **/
- if(isset($zdata[$val[1].'|'.$val[2]]))
- {
- if(isset($zdata[$val[1].'|'.$val[2]][$val[0]]))
- {
- $zdata[$val[1].'|'.$val[2]][$val[0]] += 1;
- }
- }
- else
- {
- $zdata[$val[1].'|'.$val[2]] = $qd;
- if(isset($zdata[$val[1].'|'.$val[2]][$val[0]]))
- {
- $zdata[$val[1].'|'.$val[2]][$val[0]] += 1;
- }
- }
- }
- //echo count($list);
- //echo "<pre>";
- //print_r($zdata);
- //exit;
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- $str .= "<table border=1 style='background-color: #2ca8a1;font-weight: bold;color:#fff;font-size: 14px;table-layout:fixed'><tr height='50' align='center'>
- <td align='left'>产品</td>
- ".$td."
- </tr></table>";
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
- foreach ($zdata as $key=>$value)
- {
- $key = explode('|',$key);
- $str .= "<tr height='50'><td align='center'><b>".$tc[$key[0]].' '.$tc[$key[1]]."</b></td>";
-
- foreach ($value as $ke=>$va)
- {
- if($va > 0)
- {
- $str .= "<td align='center'><b>".$va."</b></td>";
- }
- else
- {
- $str .= "<td align='center'>".$va."</td>";
- }
- }
- $str .= "</tr>\n";
- }
- $str .= "</body></html>";
- header( "Content-Type: application/vnd.ms-excel; name='excel'" );
- header( "Content-type: application/octet-stream" );
- header( "Content-Disposition: attachment; filename=".time().'.xls' );
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header( "Pragma: no-cache" );
- header( "Expires: 0" );
- exit($str);
- }
- }
-
- public function _list()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('systemdownload_list',$this->data);
- }
-
- public function _listread()
- {
- if(isset($_SESSION['api']))
- {
- $user = $this->user->get_api($_SESSION['api']);
- $usp = $user;
- $fgshop = "";$sid = "";$excelshop="";
- $usersp = explode('|',trim($user['shop'],'|'));
- foreach ($usersp as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- $userexcel = explode('|',trim($user['excelshop'],'|'));
- foreach ($userexcel as $value)
- {
- $excelshop .= " shop = ".$value." or";
- }
- if($excelshop != "")
- {
- $excelshop = "(".rtrim($excelshop,'or').")";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($_GET['category']))
- {
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $lacetype = $this->input->get('lacetype',true);
- $category = $this->input->get('category',true);
- $shop = $this->input->get('shop',true);
- $time = $this->input->get('time',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
-
- $cw = array();
- $class = array();$classdata = array();$lx = array();$pm = array();$ttzllist = array();$hxlist = array();
- $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');
- foreach ($a as $val)
- {
- $class[] = '-'.$val['id'].'-';
- }
- $b = $this->typeclass->find_all();
- foreach ($b as $val)
- {
- $classdata[$val['id']] = $val['title'];
- $lx[$val['id']] = $val['classid'];
- $pm[$val['id']] = $val['zh'];
- }
- $ttzl = $this->typeclass->find_all("classid = '18'");
- foreach ($ttzl as $val)
- {
- $ttzllist[$val['id']] = $val['classid'];
- }
- $hx = $this->typeclass->find_all("classid = '15'");
- foreach ($hx as $val)
- {
- $hxlist[$val['id']] = $val['classid'];
- }
- //Closure wigs
- $fpdata = '';
- $category = explode('|',trim($category,'|'));
- foreach ($category as $value)
- {
- $fpdata .= "fpdata like '%".$value."%' or ";
- }
- if(count($category) > 1)
- {
- $fpdata = "(".trim($fpdata,' or ').")";
- }
- else
- {
- $fpdata = trim($fpdata,' or ');
- }
- $where = "shop != '9' and shop != '26' and ";
- if($color)
- {
- $where .= "fpdata like '%$color%' and ";
- }
- if($lowe)
- {
- $where .= "fpdata like '%$lowe%' and ";
- }
- if($size)
- {
- $where .= "fpdata like '%$size%' and ";
- }
- if($grade)
- {
- $where .= "fpdata like '%$grade%' and ";
- }
- if($lacetype)
- {
- $where .= "fpdata like '%$lacetype%' and ";
- }
- if($shop)
- {
- $where .= "shop = '$shop' and ";
- }
- else
- {
- $where .= $excelshop." and ";
- }
- $dataa = $this->fullorder->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
- $datab = $this->fullordersmt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
- $datac = $this->fullordertt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and ".$fpdata,'number,fpdata','id desc');
- $data = array_merge($dataa,$datab,$datac);
-
- //echo $where."librarytime > '$timetk' and librarytime < '$timetj' and ".$fpdata;
- //echo "<pre>";
- //print_r($data);
- //exit;
-
- $pd = '';
- $p = $class;
- $resdata = array();
- foreach ($data as $val)
- {
- $f = explode(';',trim($val['fpdata'],';'));
- foreach ($f as $v)
- {
- if($color)
- {
- if(stripos($v,'-'.$color.'-') === false)
- {
- continue;
- }
- }
- if($lowe)
- {
- if(stripos($v,'-'.$lowe.'-') === false)
- {
- continue;
- }
- }
- if($size)
- {
- if(stripos($v,$size.',') === false)
- {
- continue;
- }
- }
- if($grade)
- {
- if(stripos($v,'-'.$grade.'-') === false)
- {
- continue;
- }
- }
- if($lacetype)
- {
- if(stripos($v,'-'.$lacetype.'-') === false)
- {
- continue;
- }
- }
- $i = 0;
- foreach ($category as $value)
- {
- if(stripos($v,'-'.$value.'-') !== false)
- {
- $i++;
- }
- }
- if($i > 0)
- {
- $e = explode('|',$v);
- $d = str_replace($p,'-',$e[0]);
- $q = str_replace(array('-163-','-164-','-165-','-166-','-782-','-79-','-80-','-81-','-497-'),'-',$e[0]);
- $fl = explode(',',$q);//分离出尺寸和其它内容
- $cpkey = str_replace('-','',$fl[1]);
- $tt = explode('-',trim($fl[1],'-'));
- $title = '';$fla='';$flb='';
- foreach ($tt as $value)
- {
- if(isset($ttzllist[$value]))
- {
- if($ttzllist[$value] == '18')
- {
- $fla = $value;
- }
- }
- if(isset($hxlist[$value]))
- {
- if($hxlist[$value] == '15')
- {
- $flb = $value;
- }
- }
- }
- //$c = explode(',',$e[0]);
- if(!isset($resdata[$fla.$flb]) && $fla != '' && $flb != '')
- {
- if(stripos($pm[$fla],'|') !== false)
- {
- $pm[$fla] = explode('|',$pm[$fla]);
- $pm[$fla] = $pm[$fla][0];
- }
- if(stripos($pm[$flb],'|') !== false)
- {
- $pm[$flb] = explode('|',$pm[$flb]);
- $pm[$flb] = $pm[$flb][0];
- }
- $title = $pm[$fla].' '. $pm[$flb];
- $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);
- if(isset($resdata[$fla.$flb][$fl[0]]))
- {
- $resdata[$fla.$flb][$fl[0]] += $e[2];
- }
- }
- else if ($fla != '' && $flb != '' && isset($resdata[$fla.$flb][$fl[0]]))
- {
- $resdata[$fla.$flb][$fl[0]] += $e[2];
- }
- }
- }
- }
- rsort($resdata);
- //echo count($list);
- //echo "<pre>";
- //print_r($list);
- //exit;
-
- $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
- <head>
- <!--[if gte mso 9]><xml>
- <x:ExcelWorkbook>
- <x:ExcelWorksheets>
- <x:ExcelWorksheet>
- <x:Name>EXCEL</x:Name>
- <x:WorksheetOptions>
- <x:Print>
- <x:ValidPrinterInfo />
- </x:Print>
- </x:WorksheetOptions>
- </x:ExcelWorksheet>
- </x:ExcelWorksheets>
- </x:ExcelWorkbook>
- </xml>
- <![endif]-->
- </head><body>";
- $str .= "<table border=1 style='background-color: #2ca8a1;font-weight: bold;color:#fff;font-size: 14px;table-layout:fixed'><tr height='50' align='center'>
- <td align='left'>产品</td>
- <td>6</td>
- <td>8</td>
- <td>10</td>
- <td>12</td>
- <td>14</td>
- <td>16</td>
- <td>18</td>
- <td>20</td>
- <td>22</td>
- <td>24</td>
- <td>26</td>
- <td>28</td>
- <td>30</td>
- <td>32</td>
- <td>34</td>
- <td>36</td>
- <td>38</td>
- <td>40</td>
- <td>42</td>
- <td>44</td>
- </tr></table>";
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 14px;'>";
- foreach ($resdata as $key=>$value)
- {
- $str .= "<tr height='50'>";
- foreach ($value as $ke=>$va)
- {
- if(is_numeric($va))
- {
- if($va > 0)
- {
- $str .= "<td align='center'><b>".$va."</b></td>";
- }
- else
- {
- $str .= "<td align='center'>".$va."</td>";
- }
- }
- else
- {
- $str .= "<td>".$va."</td>";
- }
- }
- $str .= "</tr>\n";
- }
- $str .= "</body></html>";
- header( "Content-Type: application/vnd.ms-excel; name='excel'" );
- header( "Content-type: application/octet-stream" );
- header( "Content-Disposition: attachment; filename=".time().'.xls' );
- header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
- header( "Pragma: no-cache" );
- header( "Expires: 0" );
- exit($str);
-
- }
- }
- }
|