123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Finance extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->library('session');
- $this->load->_model('Model_finance','finance');
- $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_typeclass','typeclass');
- $this->load->_model('Model_express','express');
- $this->load->_model('Model_country','country');
- $this->load->_model('Model_productdescribe','productdescribe');
- $this->load->_model('Model_customs','customs');
- $this->load->_model('Model_detailed','detailed');
- $this->load->_model('Model_productdescription','productdescription');
- $this->load->_model('Model_logistics','logistics');
- $this->load->_model('Model_hl','hl');
- $this->load->_model('Model_excel','excel');
- $this->load->_model('Model_warehouse','warehouse');
- $this->load->_model('Model_systemwigsout','systemwigsout');
- $this->load->_model('Model_classid','classid');
- }
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- if($arg == 'excel')
- {
- $this->_excel();
- }
- else if($arg == 'ckexcel')
- {
- $this->_ckexcel();
- }
- else if($arg == 'caiwu')
- {
- $this->_caiwu($arg_array);
- }
- else if($arg == 'ckcaiwu')
- {
- $this->_ckcaiwu();
- }
- else if($arg == 'product')
- {
- $this->_product($arg_array);
- }
- else if($arg == 'dhlfp')
- {
- $this->_dhlfp();
- }
- else if($arg == 'ouout')
- {
- $this->_ouout();
- }
- else if($arg == 'cksize')
- {
- $this->_cksize();
- }
- else
- {
- $this->_index($arg);
- }
- }
-
- //店铺统计
- public function _index($arg)
- {
- $fu = (isset($arg))?($arg=="smt"?"fullordersmt":"fullorder"):"fullorder";
- $user = $this->user->get_api($_SESSION['api']);
- if($user)
- {
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $library = $this->input->post('library',true);
- $warehouse = $this->input->post('warehouse',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $user = $this->input->post('user',true);
- $name = $this->input->post('name',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "mergeid = 0";
- if($timetk && $timetj)
- {
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($name)
- {
- $where .= " and name = '$name'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;
- //取得信息列表
- $info_list = $this->$fu->find_all($where,'id,shop,user,type,orderinfo,shouldmoney,budget,expressmoney,refundj,orderremarks,hl',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $order = $this->$fu->read($value['id']);
- $order['hl'] = $order['hl']!=0?$order['hl']:6.71;
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $info_list[$key]['user'] = $shop['shopuser'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- $info_list[$key]['shouldmoney'] = ($order['currencytitle']=='CNY')?sprintf("%.2f",$order['shouldmoney']/$order['hl']):$value['shouldmoney'];
- $shouldmoney += $info_list[$key]['shouldmoney'];
- $expressmoney += $info_list[$key]['expressmoney'];
- $info_list[$key]['budget'] = ($order['currencytitle']=='CNY')?sprintf("%.2f",$order['budget']/$order['hl']):$value['budget'];
- $budget += $info_list[$key]['budget'];
- $refundj += $info_list[$key]['refundj'];
- }
- $money = $this->$fu->find_all($where);
- $shouldmoney = sprintf("%.2f",$shouldmoney);
- $expressmoney = sprintf("%.2f",$expressmoney);
- $budget = sprintf("%.2f",$budget);
- $refundj = sprintf("%.2f",$refundj);
- $total = $this->$fu->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'money'=>(array($shouldmoney,$budget,$expressmoney,$refundj)));
- echo json_encode($rows);exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->data['arg'] = $arg;
- $this->_Template('finance',$this->data);
- }
- public function _caiwu($arg_array)
- {
- $user = $this->user->get_api($_SESSION['api']);
- if($user)
- {
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $library = $this->input->post('library',true);
- $warehouse = $this->input->post('warehouse',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $number = $this->input->post('number',true);
- $user = $this->input->post('user',true);
- $name = $this->input->post('name',true);
- $xztime = $this->input->post('xztime',true);
- $country = $this->input->post('country',true);
- $paypal = $this->input->post('paypal',true);
- $fullorder = $this->input->post('fullorder',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "mergeid = 0";
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($number)
- {
- $where .= " and number = '$number'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($name)
- {
- $where .= " and name = '$name'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- if($paypal)
- {
- $where .= " and paypal = '$paypal'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$cost=0;$lr=0;
- //取得信息列表
- if($fullorder == 'fullordersmt')
- {
- $info_list = $this->fullordersmt->find_all($where,'id,shop,user,type,orderinfo,shouldmoney,budget,expressmoney,refundj,cost,merge,currencytitle,orderremarks,hl',$order_str,$start,$perpage);
- $total = $this->fullordersmt->find_count($where);
- }
- else if($fullorder == 'fullorder')
- {
- $info_list = $this->fullorder->find_all($where,'id,shop,user,type,orderinfo,shouldmoney,budget,expressmoney,refundj,cost,merge,currencytitle,orderremarks,hl',$order_str,$start,$perpage);
-
- $total = $this->fullorder->find_count($where);
- }
- else if($fullorder == 'fullordertt')
- {
- $info_list = $this->fullordertt->find_all($where,'id,shop,user,type,orderinfo,shouldmoney,budget,expressmoney,refundj,cost,merge,currencytitle,orderremarks,hl',$order_str,$start,$perpage);
-
- $total = $this->fullordertt->find_count($where);
- }
- else
- {
- $info_lista = $this->fullordersmt->find_all($where,'id,shop,user,type,orderinfo,shouldmoney,budget,expressmoney,refundj,cost,merge,currencytitle,orderremarks,hl',$order_str,$start,$perpage);
- $info_listb = $this->fullorder->find_all($where,'id,shop,user,type,orderinfo,shouldmoney,budget,expressmoney,refundj,cost,merge,currencytitle,orderremarks,hl',$order_str,$start,$perpage);
- $info_listc = $this->fullordertt->find_all($where,'id,shop,user,type,orderinfo,shouldmoney,budget,expressmoney,refundj,cost,merge,currencytitle,orderremarks,hl',$order_str,$start,$perpage);
- $info_list = array_merge($info_lista,$info_listb);
- $total = $this->fullordersmt->find_count($where);
- $total += $this->fullorder->find_count($where);
- $total += $this->fullordertt->find_count($where);
- }
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $shop = $this->shop->read($value['shop']);
- $fu = ($shop['type'] == "269")?'fullorder':'fullordersmt';
- $order = $this->$fu->read($value['id']);
- $order['hl'] = $order['hl']!=0?$order['hl']:6.71;
- $info_list[$key]['shop'] = $shop['shopname'];
- $info_list[$key]['user'] = $shop['shopuser'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- $merge = $info_list[$key]['budget']-$info_list[$key]['refundj']-$info_list[$key]['cost']/$order['hl']-$info_list[$key]['expressmoney'];
- $info_list[$key]['merge'] = sprintf("%.2f",$merge);//利润
- $currencytitle = ($merge!=0 && $info_list[$key]['budget']!=0)?$merge/$info_list[$key]['budget']*100:0;
- $info_list[$key]['currencytitle'] = $currencytitle==0?'0'.'%':sprintf("%.2f",$currencytitle)."%";//利润百分比
- $info_list[$key]['shouldmoney'] = ($order['currencytitle']=='CNY')?sprintf("%.2f",$order['shouldmoney']/$order['hl']):$value['shouldmoney'];
- $shouldmoney += $info_list[$key]['shouldmoney'];
- $expressmoney += $info_list[$key]['expressmoney'];
- $info_list[$key]['budget'] = ($order['currencytitle']=='CNY')?sprintf("%.2f",$order['budget']/$order['hl']):$value['budget'];
- $budget += $info_list[$key]['budget'];
- $refundj += $info_list[$key]['refundj'];
- $cost += $info_list[$key]['cost'];
- $lr += $merge;
- }
- $shouldmoney = sprintf("%.2f",$shouldmoney);
- $expressmoney = sprintf("%.2f",$expressmoney);
- $budget = sprintf("%.2f",$budget);
- $refundj = sprintf("%.2f",$refundj);
- $cost = sprintf("%.2f",$cost);
- $lr = sprintf("%.2f",$lr);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'money'=>(array($shouldmoney,$budget,$expressmoney,$refundj,$cost,$lr)));
- echo json_encode($rows);exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- if(isset($arg_array[0]))
- {
- $is = ($arg_array[0] == 'dlz')?'1':'2';
- $arg = $arg_array[0];
- }
- else
- {
- $is = '1';
- $arg = 'dlz';
- }
- $this->data['is'] = $is;
- $this->data['arg'] =$arg;
- $this->_Template('finance_cw',$this->data);
- }
- public function _ckcaiwu()//仓库财务
- {
- $user = $this->user->get_api($_SESSION['api']);
- if($user)
- {
- $fgshop = "";$sid = "";
- $user = explode('|',trim($user['shop'],'|'));
- foreach ($user as $value)
- {
- $fgshop .= " shop = ".$value." or";
- $sid .= " id = ".$value." or";
- }
- }
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['page']))
- {
- $page = $this->input->post('page',true);
- $perpage = $this->input->post('perpage',true);
- $timetk = $this->input->post('timetk',true);
- $timetj = $this->input->post('timetj',true);
- $shop = $this->input->post('shop',true);
- $source = $this->input->post('source',true);
- $library = $this->input->post('library',true);
- $warehouse = $this->input->post('warehouse',true);
- $orderinfo = $this->input->post('orderinfo',true);
- $user = $this->input->post('user',true);
- $name = $this->input->post('name',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $fullorder = $this->input->post('fullorder',true);
- $where = "mergeid = 0";
- if($timetk && $timetj)
- {
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($name)
- {
- $where .= " and name = '$name'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$purchase=0;$lr=0;
- //取得信息列表
- $info_list = $this->$fullorder->find_all($where,'id,shop,user,type,orderinfo,shouldmoney,budget,expressmoney,refundj,purchase,merge,currencytitle,orderremarks,hl',$order_str,$start,$perpage);
- //格式化数据
- foreach ($info_list as $key=>$value)
- {
- $order = $this->$fullorder->read($value['id']);
- $order['hl'] = $order['hl']!=0?$order['hl']:6.71;
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $info_list[$key]['user'] = $shop['shopuser'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- $merge = $info_list[$key]['budget']-$info_list[$key]['refundj']-$info_list[$key]['purchase']/$order['hl']-$info_list[$key]['expressmoney'];
- $info_list[$key]['merge'] = sprintf("%.2f",$merge);//利润
- $currencytitle = ($merge!=0 && $info_list[$key]['budget']!=0)?$merge/$info_list[$key]['budget']*100:0;
- $info_list[$key]['currencytitle'] = $currencytitle==0?'0'.'%':sprintf("%.2f",$currencytitle)."%";//利润百分比
- $info_list[$key]['shouldmoney'] = ($order['currencytitle']=='CNY')?sprintf("%.2f",$order['shouldmoney']/$order['hl']):$value['shouldmoney'];
- $shouldmoney += $info_list[$key]['shouldmoney'];
- $expressmoney += $info_list[$key]['expressmoney'];
- $info_list[$key]['budget'] = ($order['currencytitle']=='CNY')?sprintf("%.2f",$order['budget']/$order['hl']):$value['budget'];
- $budget += $info_list[$key]['budget'];
- $refundj += $info_list[$key]['refundj'];
- $purchase += $info_list[$key]['purchase'];
- $lr += $merge;
- }
- $money = $this->$fullorder->find_all($where);
- $shouldmoney = sprintf("%.2f",$shouldmoney);
- $expressmoney = sprintf("%.2f",$expressmoney);
- $budget = sprintf("%.2f",$budget);
- $refundj = sprintf("%.2f",$refundj);
- $purchase = sprintf("%.2f",$purchase);
- $lr = sprintf("%.2f",$lr);
- $total = $this->$fullorder->find_count($where);
- $pagenum = ceil($total/$perpage);
- $over = $total-($start+$perpage);
- $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'money'=>(array($shouldmoney,$budget,$expressmoney,$refundj,$purchase,$lr)));
- echo json_encode($rows);exit;
- }
- $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
- $this->data['wlshop'] = $wlshop;
- $this->_Template('finance_ckcw',$this->data);
- }
- //导出资金统计excel
- public function _excel()
- {
- if(isset($_GET['excel']))
- {
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $shop = $this->input->get('shop',true);
- $source = $this->input->get('source',true);
- $library = $this->input->get('library',true);
- $warehouse = $this->input->get('warehouse',true);
- $orderinfo = $this->input->get('orderinfo',true);
- $user = $this->input->get('user',true);
- $name = $this->input->get('name',true);
- $xztime = $this->input->get('xztime',true);
- $country = $this->input->get('country',true);
- $fullorder = $this->input->get('fullorder',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "mergeid = 0";
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($name)
- {
- $where .= " and name = '$name'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- /* 匹配ID加入 */
- $tc = array();$typeclass = array();
- $tclass = $this->typeclass->find_all();
- foreach ($tclass as $v)
- {
- $tc[$v['id']] = $v['title'];
- $typeclass[$v['id']] = $v;
- }
- $shouldmoney=0;$expressmoney=0;$budget=0;$refundj=0;$refundj=0;$cost=0;$lr=0;
- //取得信息列表
- if($fullorder == 'fullordersmt')
- {
- $info_list = $this->fullordersmt->find_all($where,'id,shop,user,type,client,orderinfo,number,shouldmoney,budget,expressmoney,cost,refundj,refundy,rpaypal,paypal,rtext,merge,mergeid,orderremarks,clientremarks,shipremarks,country,express,librarytime,fpdata,hl,currencytitle');
- }
- else if($fullorder == 'fullorder')
- {
- $info_list = $this->fullorder->find_all($where,'id,shop,user,type,client,orderinfo,number,shouldmoney,budget,expressmoney,cost,refundj,refundy,rpaypal,paypal,rtext,merge,mergeid,orderremarks,clientremarks,shipremarks,country,express,librarytime,fpdata,hl,currencytitle');
- }
- else if($fullorder == 'fullordertt')
- {
- $info_list = $this->fullordertt->find_all($where,'id,shop,user,type,client,orderinfo,number,shouldmoney,budget,expressmoney,cost,refundj,refundy,rpaypal,paypal,rtext,merge,mergeid,orderremarks,clientremarks,shipremarks,country,express,librarytime,fpdata,hl,currencytitle');
- }
- else
- {
- $info_lista = $this->fullordersmt->find_all($where,'id,shop,user,type,client,orderinfo,number,shouldmoney,budget,expressmoney,cost,refundj,refundy,rpaypal,paypal,rtext,merge,mergeid,orderremarks,clientremarks,shipremarks,country,express,librarytime,fpdata,hl,currencytitle');
- $info_listb = $this->fullorder->find_all($where,'id,shop,user,type,client,orderinfo,number,shouldmoney,budget,expressmoney,cost,refundj,refundy,rpaypal,paypal,rtext,merge,mergeid,orderremarks,clientremarks,shipremarks,country,express,librarytime,fpdata,hl,currencytitle');
- $info_listc = $this->fullordertt->find_all($where,'id,shop,user,type,client,orderinfo,number,shouldmoney,budget,expressmoney,cost,refundj,refundy,rpaypal,paypal,rtext,merge,mergeid,orderremarks,clientremarks,shipremarks,country,express,librarytime,fpdata,hl,currencytitle');
- $info_list = array_merge($info_lista,$info_listb,$info_listc);
- }
- //格式化数据
- $i = 0;
- $classid = $this->classid->sku();
- foreach ($info_list as $key=>$value)
- {
- $value['hl'] = $value['hl']!=0?$value['hl']:6.71;
- $shop = $this->shop->read($value['shop']);
- $info_list[$key]['shop'] = $shop['shopname'];
- $info_list[$key]['user'] = $shop['shopuser'];
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- $country = $this->country->read($value['country']);
- $info_list[$key]['country'] = $country['ename'];
- $express = $this->express->read($value['express']);
- $info_list[$key]['express'] = $express['servicename'];
- $merge = $info_list[$key]['budget']-$info_list[$key]['refundj']-$info_list[$key]['cost']/$value['hl']-$info_list[$key]['expressmoney'];
- $info_list[$key]['merge'] = sprintf("%.2f",$merge);//利润
- $mergeid = ($value['budget']!=0)?$merge/$info_list[$key]['budget']*100:0;
- $info_list[$key]['mergeid'] = sprintf("%.2f",$mergeid)."%";//利润百分比
- $info_list[$key]['shouldmoney'] = ($value['currencytitle']=='CNY')?sprintf("%.2f",$value['shouldmoney']/$value['hl']):$value['shouldmoney'];
- $shouldmoney += $info_list[$key]['shouldmoney'];
- $expressmoney += $info_list[$key]['expressmoney'];
- $info_list[$key]['budget'] = ($value['currencytitle']=='CNY')?sprintf("%.2f",$value['budget']/$value['hl']):$value['budget'];
- $budget += $info_list[$key]['budget'];
- $refundj += $info_list[$key]['refundj'];
- $cost += $info_list[$key]['cost'];
- $lr += $info_list[$key]['merge'];
- $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
- $fpdata = array();
- if(stripos($value['fpdata'],';') !== false)
- {
- $fpdata = explode(';',rtrim($value['fpdata'],';'));
- foreach ($fpdata as $ke=>$va)
- {
- $dj = '';$ys = '';$hx = '';
- $pm = $classid;
- $jm = $classid;
- $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
- $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
- $ts = explode('|',trim($features,'|'));
- if(stripos($ts[0],',') !== false)
- {
- $ft = explode(',',$ts[0]);
- $features = explode('-',trim($ft[1],'-'));
- $features[] = $ft[0];
- }
- else
- {
- $features = explode('-',trim($ts[0],'-'));
- }
- foreach($features as $k=>$v)
- {
- if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['bm'] != '')
- {
- $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
- }
- }
- if($v != 0)
- {
- if($typeclass[$v]['classid'] == 13)
- {
- $dj = $typeclass[$v]['title'];
- }
- if($typeclass[$v]['classid'] == 8)
- {
- $ys = $typeclass[$v]['title'];
- }
- if($typeclass[$v]['classid'] == 15)
- {
- $hx = $typeclass[$v]['title'];
- }
- if(isset($pm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['title'] == '9A')
- {
- $pm[$typeclass[$v]['classid']] = '9A';
- }
- else if($typeclass[$v]['title'] == '10A')
- {
- $pm[$typeclass[$v]['classid']] = '10A';
- }
- else
- {
- $clzh = $typeclass[$v]['zh'];
- if(stripos($typeclass[$v]['zh'],'|') !== false)
- {
- $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
- $clzh = $clzh[0];
- }
- $pm[$typeclass[$v]['classid']] = $clzh;
- }
- }
- if(isset($jm[$typeclass[$v]['classid']]))
- {
- if($typeclass[$v]['jm'])
- {
- $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
- }
- }
- }
- }
- $jm = array_filter($jm);//去除空值
- $jm = implode("-",$jm);
- $pm = array_filter($pm);//去除空值
- $zh = implode(" ",$pm);
- $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
- $fpdata[$ke] = array($ts[5],$dj,$ys,$hx,$jm,'03'.implode("",$bmpx),$ts[2]);//内容,尺寸,等级,颜色,数量
- }
- }
- $info_list[$key]['fpdata'] = $fpdata;
- $i++;
- }
- $shouldmoney = sprintf("%.2f",$shouldmoney);
- $expressmoney = sprintf("%.2f",$expressmoney);
- $budget = sprintf("%.2f",$budget);
- $refundj = sprintf("%.2f",$refundj);
- $cost = sprintf("%.2f",$cost);
- $lr = sprintf("%.2f",$lr);
- $data = array($shouldmoney.' USD',$budget.' USD',$expressmoney.' USD',$cost.' CNY',$refundj.' USD',$lr.' USD');
- $title = "财务统计信息";
- $titlename = "<table border=1>
- <tr><th colspan='25' align='left'><h3>".$title."<h3></th></tr>
- <tr>
- <td>NO.</td>
- <td>店铺名称</td>
- <td>负责人</td>
- <td>发货仓库</td>
- <td>客户名称</td>
- <td>订单号</td>
- <td>编号</td>
- <td>订单金额 USD</td>
- <td>预估金额 USD</td>
- <td>运费 USD</td>
- <td>成本 CNY</td>
- <td>补/退原额 USD</td>
- <td>补/退净额 USD</td>
- <td>补/退款交易号</td>
- <td>线下交易号</td>
- <td>原因</td>
- <td>利润 USD</td>
- <td>利润率</td>
- <td>订单备注</td>
- <td>客户备注</td>
- <td>发货备注</td>
- <td>国家</td>
- <td>物流</td>
- <td>出库时间</td>
- <td>
- <table border=1>
- <tr><td colspan='5' align='center'>订单产品信息</td></tr>
- <tr>
- <td>尺寸</td>
- <td>等级</td>
- <td>颜色</td>
- <td>花型</td>
- <td>料号</td>
- <td>编码</td>
- <td>数量</td>
- </tr>
- </table>
- </td>
- <td>总条数</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td><td>".$data[1]."</td><td>".$data[2]."</td><td>".$data[3]."</td><td>".$data[4]."</td><td></td><td></td><td></td><td></td><td>".$data[5]."</td><td></td><td></td></tr>\n";
- $this->excel->get_fz($info_list,$titlename,$filename,$tail);
- }
- }
- //仓库导出资金统计excel
- public function _ckexcel()
- {
- if(isset($_GET['excel']))
- {
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $shop = $this->input->get('shop',true);
- $source = $this->input->get('source',true);
- $library = $this->input->get('library',true);
- $warehouse = $this->input->get('warehouse',true);
- $orderinfo = $this->input->get('orderinfo',true);
- $user = $this->input->get('user',true);
- $name = $this->input->get('name',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $fullorder = $this->input->get('fullorder',true);
- $where = "mergeid = 0";
- if($timetk && $timetj)
- {
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($name)
- {
- $where .= " and name = '$name'";
- }
- /* 匹配ID加入 */
- $tc = array();
- $typeclass = $this->typeclass->find_all();
- foreach ($typeclass as $v)
- {
- if($_GET['excel'] == 2)
- {
- if($v['zh'] == '')
- {
- $tc[$v['id']] = $v['title'];
- }
- else
- {
- $tc[$v['id']] = $v['zh'];
- }
- }
- else
- {
- $tc[$v['id']] = $v['title'];
- }
- }
- $purchase=0;$cost=0;$lr=0;
- //取得信息列表
- $info_list = $this->$fullorder->find_all($where,'id,type,orderinfo,number,purchase,cost,merge,shipremarks,fpdata,hl,currencytitle');
- //格式化数据
- $i = 0;
- foreach ($info_list as $key=>$value)
- {
- $order = $this->$fullorder->read($value['id']);
- $warehouse = $this->warehouse->read($value['type']);
- $info_list[$key]['type'] = $warehouse['title'];
- $merge = $info_list[$key]['cost']-$info_list[$key]['purchase'];
- $info_list[$key]['merge'] = sprintf("%.2f",$merge);//利润
- $purchase += $info_list[$key]['purchase'];
- $cost += $info_list[$key]['cost'];
- $lr += $info_list[$key]['merge'];
- $fpdata = array();
- if(stripos($value['fpdata'],';') !== false)
- {
- $fpdata = explode(';',rtrim($value['fpdata'],';'));
- foreach ($fpdata as $ke=>$va)
- {
- $title = '';
- $fg = explode('|',$va);
- $fg[0] = str_replace(array('163-','164-','165-','166-','-0-'),array('','','','','-'),$fg[0]);
- $cp = explode('-',rtrim($fg[0],'-'));
- $dj = (isset($cp[2]) && isset($tc[$cp[2]]))?$tc[$cp[2]]:'0';
- $ys = isset($cp[3])?(isset($tc[$cp[3]])?$tc[$cp[3]]:'没有此颜色'):'0';
- unset($cp[0],$cp[1],$cp[2],$cp[3]);
- foreach ($cp as $v)
- {
- if(isset($tc[$v]))
- {
- $title .= $tc[$v].' ';
- }
- }
- $fpdata[$ke] = array($fg[5],$dj,$ys,$title,$fg[2]);//内容,尺寸,等级,颜色,数量
- }
- }
- $info_list[$key]['fpdata'] = $fpdata;
- $i++;
- }
- $purchase = sprintf("%.2f",$purchase);
- $cost = sprintf("%.2f",$cost);
- $lr = sprintf("%.2f",$lr);
- $data = array($purchase.' CNY',$cost.' CNY',$lr.' CNY');
- $title = "财务统计信息";
- $titlename = "<table border=1>
- <tr><th colspan='10' align='left'><h3>".$title."<h3></th></tr>
- <tr>
- <td>NO.</td>
- <td>发货仓库</td>
- <td>订单号</td>
- <td>编号</td>
- <td>成本</td>
- <td>外贸成本</td>
- <td>利润</td>
- <td>发货备注</td>
- <td>
- <table border=1>
- <tr><td colspan='5' align='center'>订单产品信息</td></tr>
- <tr>
- <td>尺寸</td>
- <td>等级</td>
- <td>颜色</td>
- <td>花型</td>
- <td>数量</td>
- </tr>
- </table>
- </td>
- <td>总条数</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "<tr><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td><td>".$data[1]."</td><td>".$data[2]."</td><td></td><td></td><td></td></tr>\n";
- $this->excel->get_fz($info_list,$titlename,$filename,$tail);
- }
- }
-
- //导出DHL发货清单统计excel
- public function _dhlfp()
- {
- if(isset($_GET['excel']))
- {
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $fullorder = $this->input->get('fullorder',true);
- $where = "mergeid = 0 and express = 1 and printtype = 1 and library = 2 and print = 3";
- if($timetk && $timetj)
- {
- $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
- }
- //取得信息列表
- $info_list = $this->$fullorder->find_all($where,'id,librarytime,waybill,country,al,zwpm,zsbjz');
- //格式化数据
- $i = 1;
- foreach ($info_list as $key=>$value)
- {
- $country = $this->country->read($value['country']);
- $info_list[$key]['country'] = $country['zname'];
- $info_list[$key]['id'] = $i;
- $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
- $i++;
- }
- $title = "CN PLT- 发票导出清单";
- $titlename = "<table border=1>
- <tr>
- <td>序号</td>
- <td>业务日期</td>
- <td>转单号码</td>
- <td>目的地</td>
- <td>二字码</td>
- <td>中文品名</td>
- <td>申报价</td>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
- }
- }
-
- public function _product($arg_array)
- {
- $post = $this->input->post(NULL, TRUE);
- if(isset($post['id']))
- {
- $id = $this->input->post('id',true);
- $post['fpdata'] = $this->input->post('fpdata');
- $post['expressmoney'] = $this->input->post('expressmoney',true);
- $post['cost'] = $this->input->post('cost',true);
- $post['purchase'] = $this->input->post('purchase',true);
- $fullorder = $this->input->post('fullorder',true);
- /**
- if($post['state'] == 216 && $ud['state'] != 216)
- {
- echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
- }
- **/
- if($this->$fullorder->save($post,$id))
- {
- echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
- }
- }
- $fullorder = $arg_array[0];
- $is = ($fullorder == 'fullorder')?'1':'2';
- $fpdata = array();
- $fullorder = $this->$fullorder->read($arg_array[1]);
- $fullorder['parameter'] = str_replace(",","---",$fullorder['parameter']);
- $e = $fullorder['express'];//快递信息
- $c = $fullorder['country'];//国家信息
- $data = $this->logistics->find_all('express = "'.$e.'" and country = "'.$c.'"');
- if($data)
- {
- $fullorder['expressmoney'] = sprintf("%.2f",$data[0]['firstmoney']);
- }
- $this->data['fullorder'] = $fullorder;
- $this->data['countrys'] = $this->country->find_all();
- $this->data['express'] = $this->express->find_all();
- if(stripos($fullorder['fpdata'],';') !== false)
- {
- $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
- foreach ($fpdata as $k=>$v)
- {
- $fpdata[$k] = explode('|',$v);
- }
- }
- $this->data['fpdata'] = $fpdata;
- $shop = $this->shop->read($fullorder['shop']);
- $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
- //单项开始
- $warehouse = $this->warehouse->read($fullorder['warehouse']);//发货仓库
- $state = $this->typeclass->read($fullorder['state']);//订单状态
- $country = $this->country->read($fullorder['country']);//国家
- if($fullorder['capital'] == 1)
- {
- $capital = '暂未支付';
- }
- else if($fullorder['capital'] == 2)
- {
- $capital = '部分支付';
- }
- else if($fullorder['capital'] == 3)
- {
- $capital = '全部支付';
- }
- if($fullorder['printtype'] == 1)
- {
- $printtype = '运单';
- }
- else if($fullorder['printtype'] == 2)
- {
- $printtype = '发货单';
- }
- else if($fullorder['printtype'] == 3)
- {
- $printtype = '不打印单据';
- }
- else
- {
- $printtype = '未选择';
- }
- $this->data['warehouse'] = $warehouse['title'];
- $this->data['state'] = $state['title'];
- $this->data['capital'] = $capital;
- $this->data['country'] = $country['ename'];
- $this->data['printtype'] = $printtype;
- $this->data['is'] = $is;
- $systemwigsout = $this->systemwigsout->get_number($fullorder['number']);
- $wigsout = array();
- if($systemwigsout)
- {
- $cz = explode('|',trim($systemwigsout['cz'],'|'));
- $cztime = explode('|',trim($systemwigsout['cztime'],'|'));
- $zw = array(1=>'配货',2=>'高针',3=>'完成',4=>'曲发',5=>'前处理',6=>'后处理',7=>'发型师',8=>'包装');
- if($systemwigsout['cz'] != '' && count($cz) > 0)
- {
- for($i=0;$i<count($cz);$i++)
- {
- if(!isset($cztime[$i]))
- {
- $wigsout[] = $zw[$cz[$i]];
- }
- else
- {
- $wigsout[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]);
- }
- }
- }
- }
- $this->data['systemwigsout'] = $wigsout;
- //单项结束
- $this->_Template('finance_product',$this->data);
- }
-
- public function _ouout() //财务汇总导出
- {
- if(isset($_GET['excel']))
- {
- $timetk = $this->input->get('timetk',true);
- $timetj = $this->input->get('timetj',true);
- $shop = $this->input->get('shop',true);
- $source = $this->input->get('source',true);
- $library = $this->input->get('library',true);
- $warehouse = $this->input->get('warehouse',true);
- $orderinfo = $this->input->get('orderinfo',true);
- $user = $this->input->get('user',true);
- $name = $this->input->get('name',true);
- $xztime = $this->input->get('xztime',true);
- $country = $this->input->get('country',true);
- $fullorder = $this->input->get('fullorder',true);
- $timetk = strtotime($timetk);
- $timetj = strtotime($timetj);
- $where = "mergeid = 0";
- if($timetk && $timetj)
- {
- $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
- }
- if($fullorder == 'sd')
- {
- echo '此功能只能单独导出独立站或速卖通数据';exit;
- }
- if($shop)
- {
- $where .= " and shop = '$shop'";
- }
- if($source)
- {
- $where .= " and source = '$source'";
- }
- if($library)
- {
- $where .= " and library = '$library'";
- }
- if($warehouse)
- {
- $where .= " and type = '$warehouse'";
- }
- if($orderinfo)
- {
- $where .= " and orderinfo = '$orderinfo'";
- }
- if($user)
- {
- $where .= " and user = '$user'";
- }
- if($name)
- {
- $where .= " and name = '$name'";
- }
- if($country)
- {
- $where .= " and country = '$country'";
- }
- //数据排序
- $order_str = "id desc";
- if(empty($page))
- {
- $start = 0;
- $perpage = 1;
- }
- else
- {
- $start = ($page - 1)*$perpage;
- }
- //取得信息列表
- $info_list = $this->$fullorder->find_all($where,'fpdata,library');
- $rowsc = array();$rowst = array();
- foreach ($info_list as $key=>$value)
- {
- $fpdata = explode(';',rtrim($value['fpdata'],';'));
- foreach ($fpdata as $va)
- {
- $fpdatason = explode('|',$va);
- $fpdatason[1] = rtrim($fpdatason[1],' ');
- str_replace(array('Peruvian','Indian','Brazilian','Malaysian'),array('','','',''),$fpdatason[1]);
- if($value['library'] == 2)
- {
- $c = 1; $t = 0;
- }
- else
- {
- $c = 0; $t = 1;
- }
- if(isset($rows[$fpdatason[1]]))
- {
- $rows[$fpdatason[1]]['c'] += $c;
- $rows[$fpdatason[1]]['t'] += $t;
- }
- else
- {
- $rows[$fpdatason[1]]['a'] = $fpdatason[1];
- $rows[$fpdatason[1]]['c'] = $c;
- $rows[$fpdatason[1]]['t'] = $t;
- }
- }
- }
- $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj).'汇总详情';
- $titlename = "<table border=1>
- <tr><th colspan='3' align='center'><h3>".$title."<h3></th></tr>
- <tr align='center'>
- <td>产品名称</td>
- <td>销售数量</td>
- <td>退货数量</td>
- </tr>
- </table>";
- $filename = $title.".xls";
- $tail = "";
- $this->excel->get_fz2($rows,$titlename,$filename,$tail);
- }
- }
-
- public function _cksize()
- {
- if(isset($_GET['excel']))
- {
- $type = $this->input->get('excel',true);
- $category = $this->input->get('category',true);
- $size = $this->input->get('size',true);
- $grade = $this->input->get('grade',true);
- $color = $this->input->get('color',true);
- $lowe = $this->input->get('lowe',true);
- $sku = $this->input->get('sku',true);
- $warehouse = $this->input->get('warehouse',true);
- $shop = $this->input->get('shop',true);
- $sid = $this->input->get('sid',true);
- $ktime = $this->input->get('ktime',true);
- $jtime = $this->input->get('jtime',true);
- $ktime = strtotime($ktime);
- $jtime = strtotime($jtime);
- $where = "1=1 and shop != 9 and shop != 26";$gj = "";$ck = "";
- if($category)
- {
- $where .= " and fpdata like '%-$category-%'";
- }
- if($size)
- {
- $where .= " and fpdata like '%-$size-%'";
- }
- if($grade)
- {
- $where .= " and fpdata like '%-$grade-%'";
- }
- if($color)
- {
- $where .= " and fpdata like '%-$color-%'";
- }
- if($lowe)
- {
- $where .= " and fpdata like '%-$lowe-%'";
- }
- if($shop)
- {
- $shopdata = '';
- $sd = explode(',',rtrim($shop,','));
- foreach ($sd as $v)
- {
- $shopdata .= "shop = '$v' or ";
- }
- $where .= " and (".rtrim($shopdata,'or ').")";
- }
- if($warehouse)
- {
- $warehousedata = '';
- $wd = explode(',',rtrim($warehouse,','));
- foreach ($wd as $v)
- {
- $warehousedata .= "warehouse = '$v' or ";
- }
- $where .= " and (".rtrim($warehousedata,'or ').")";
- }
- if($sku)
- {
- $where .= " and sku like '%$sku%'";
- }
- if($ktime && $jtime)
- {
- $where .= " and librarytime > '$ktime' and librarytime < '$jtime'";
- }
- $sidwhere = '';
- if($sid)
- {
- $sd = "";
- $s = explode(',',trim($sid,','));
- foreach ($s as $value)
- {
- $sd .= " id = ".$value." or";
- }
- $sidwhere .= " and (".rtrim($sd,'or').")";
- }
- $typeclass = array();
- $tc = $this->typeclass->find_all();
- foreach ($tc as $v)
- {
- $typeclass[$v['id']] = array('ae'=>$v['spare'],'zh'=>$v['zh']);
- }
- //取得信息列表
- $timeread = $ktime;
- $timenum = ceil(($jtime - $ktime) / (24*3600));
- $timelist = array();
- for($i=4;$i<41;$i++)
- {
- if ($i%2==0)
- {
- $timelist[$i] = 0;
- }
- }
- $info_lista = $this->fullorder->find_all($where.$sidwhere,'fpdata,number');
- $info_listb = $this->fullordersmt->find_all($where.$sidwhere,'fpdata,number');
- $info_list = array_merge($info_lista,$info_listb);
- //echo "<pre>";
- //print_r($info_list);
- //exit();
- $rows = array();$list = array();$cw = array();
- foreach ($info_list as $key=>$value)
- {
- $thistime = $timelist;
- $zdata = explode(';',trim($value['fpdata'],';'));
- foreach ($zdata as $v)
- {
- if(stripos($v,'-131-') !== false || ($category != '' && stripos($v,'-'.$category.'-') === false))
- {
- continue;
- }
- $fpdata = explode('|',trim($v,'|'));
- $xqdata = explode(',',trim($fpdata[0],','));
- $cc = $typeclass[$xqdata[0]]['spare'];
- if(!isset($xqdata[1]))
- {
- $cw[] = array($value['fpdata'],$value['number']);
- }
- $sku = $xqdata[1];
- if(isset($rows[$sku]))
- {
- $rows[$sku][2][$cc] += 1;
- }
- else
- {
- $zh = '';
- $zhdata = explode('-',trim($sku,'-'));
- foreach ($zhdata as $kk => $vv)
- {
- if(isset($typeclass[$vv]['zh']) && $kk != 0)
- {
- $zh .= $typeclass[$vv]['zh'].' ';
- }
- }
- $rows[$sku][0] = preg_replace('/ (\d+)inch/','',$fpdata[1]);
- $rows[$sku][1] = trim($zh,' ');
- $rows[$sku][2] = $thistime;
- $rows[$sku][2][$cc] += 1;
- }
- }
- }
- $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><tr>";
- $str .="<td>英文</td>";
- $str .="<td>中文</td>";
- foreach ($timelist as $k=>$v)
- {
- $str .="<td>".$k."</td>";
- }
- $str .= "</tr></table>";
- $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
- foreach ($rows as $key=>$val)
- {
- $str .= "<tr><td>".$val[0]."</td>";
- $str .= "<td>".$val[1]."</td>";
- foreach ($val[2] as $k=>$v)
- {
- $str .= "<td>".$v."</td>";
- }
- $str .= "</tr>";
- }
- $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);
- }
- 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('finance_cksize',$this->data);
- }
- }
|