| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357 | <?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_listc = $this->fullordertt->find_all($where.$sidwhere,'fpdata,number');				$info_list = array_merge($info_lista,$info_listb,$info_listc);				//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]]['ae'];						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);	}}
 |