<?php
namespace app\admin\controller;
use think\App;
use think\facade\Session;
use think\facade\View;
use think\facade\Request;
 
class excel extends Base{
	
	//导出数据
	public function excel(){
		$tdata=Request::param();
        if($tdata['pid']==1){
            $table="form_content";
            $title="申领免费试听课";
        }
       		
		$lists=\app\index\model\Common::form($table);

		header("Content-type:application/vnd.ms-excel");
 		header("Content-Disposition:filename=".$title.".xls");

        $list='';  
        $list.= "<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#CCCCCC\">";
        
        if($tdata['pid']==1){
            
			$list.= "<tr>";
			$list.= "<td height=\"30\" align=\"center\" bgcolor=\"9bc2e6\">宝贝姓名</td>";
			$list.= "<td height=\"30\" align=\"center\" bgcolor=\"70ad47\">出生日期</td>";
			$list.= "<td height=\"30\" align=\"center\" bgcolor=\"9bc2e6\">家长电话</td>";
			$list.= "<td height=\"30\" align=\"center\" bgcolor=\"70ad47\">所在城市</td>";
			$list.= "<td height=\"30\" align=\"center\" bgcolor=\"9bc2e6\">附近中心</td>";
			$list.= "<td height=\"30\" align=\"center\" bgcolor=\"70ad47\">时间</td>";
			$list.= "</tr>";
			
			foreach ($lists as $k=>$c){
			$list.= "<tr>";
			$list.= "<td height=\"30\" align=\"left\" bgcolor=\"9bc2e6\">".$c['ly1']."</td>";
			$list.= "<td height=\"30\" align=\"left\" bgcolor=\"70ad47\">".$c['ly2']."</td>";
			$list.= "<td height=\"30\" align=\"left\" bgcolor=\"9bc2e6\">".$c['phone']."</td>";
			$list.= "<td height=\"30\" align=\"left\" bgcolor=\"70ad47\">".$c['ly3']."</td>";
			$list.= "<td height=\"30\" align=\"left\" bgcolor=\"9bc2e6\">".$c['ly4']."</td>";
			$list.= "<td height=\"30\" align=\"left\" bgcolor=\"70ad47\">".date('Y-m-d H:i:s',$c['create_time'])."</td>";
			$list.= "</tr>";
			}

        }
        
        $list.= "</table>";
        exit($list);
        //var_dump($list);exit;
        //$list=iconv('UTF-8',"GB2312//IGNORE",$list);
        //exit($list);
    }	
	
	
}
