~~~
//入库
public function outxls()
{
$data = $_REQUEST;
$g= M("goods")->where('id='.$data['gid'])->find();
$time=$data['year'].'-'.$data['month'].'-01 12:00:00';
$today = strtotime($time);
//本月月初时间戳
$month_start=mktime(0, 0 , 0,date('m',$today),1,date('Y',$today));
//本月月末
$month_end=mktime(23,59,59,date('m',$today),date('t',$today),date('Y',$today));
$mon_start = date('Y-m-d H:i:s',$month_start);
$mon_end = date('Y-m-d H:i:s',$month_end);
$map['a.addtime'] = array(array('egt', $mon_start), array('elt',$mon_end));
$px = C('DB_PREFIX');//数据库前缀
$list =M("goodlists")->alias('a')->field('a.id,a.barcode,a.addtime,a.store,a.bianhao,b.title,a.gid as gg,jingban,sn,c.title as ctt')
->join($px.'goods b on b.id=a.gid','left')
->join($px.'ftype c on a.status=c.sort','left')
->where('a.gid='.$data['gid'])->where($map)->select();
$list= $this->outxlsformat($list);
//var_dump($list);exit();
$headArr = array('商品ID','批号','入库时间','厂库','产品编号','产品名称','产品规格','经办人','订单号','状态');
$filename = '入库记录';
$this->xlsout($filename, $headArr, $list);
}
//入库单格式化
public function outxlsformat($voList){
foreach ($voList as $key => &$list) {
$g= M("goods")->where('id='.$list['gg'])->find();
$list['gg']=$g['type'].'ml*'.$g['chainum'].'瓶';
}
return $voList;
}
~~~