|
@@ -3,6 +3,7 @@ |
|
@@ -3,6 +3,7 @@ |
3
|
namespace app\admin\controller\litestore;
|
3
|
namespace app\admin\controller\litestore;
|
4
|
|
4
|
|
5
|
use app\admin\model\litestore\Litestoregoodsspec;
|
5
|
use app\admin\model\litestore\Litestoregoodsspec;
|
|
|
6
|
+use app\api\model\Goods;
|
6
|
use app\common\controller\Backend;
|
7
|
use app\common\controller\Backend;
|
7
|
use app\admin\model\litestore\Litestorespec as SpecModel;
|
8
|
use app\admin\model\litestore\Litestorespec as SpecModel;
|
8
|
use app\admin\model\litestore\Litestorespecvalue as SpecValueModel;
|
9
|
use app\admin\model\litestore\Litestorespecvalue as SpecValueModel;
|
|
@@ -272,16 +273,23 @@ class Litestoregoods extends Backend |
|
@@ -272,16 +273,23 @@ class Litestoregoods extends Backend |
272
|
/**
|
273
|
/**
|
273
|
* 导出
|
274
|
* 导出
|
274
|
*/
|
275
|
*/
|
275
|
- public function clubpeople(){
|
|
|
276
|
- //1.从数据库中导出需要进行要导出的数据
|
|
|
277
|
- $list =Db::query('SELECT stu_list.stu_name,stu_list.stu_department,stu_list.stu_phone,stu_list.stu_email,stu_list.stu_profess
|
|
|
278
|
- ,club_branch.* FROM club_branch INNER JOIN stu_list ON club_branch.stu_number = stu_list.stu_number
|
|
|
279
|
- where club_branch.club_id=:acc order by club_branch.club_branch_name ',['acc'=>$clubid]);
|
|
|
280
|
-
|
|
|
281
|
-
|
276
|
+ public function clubpeople()
|
|
|
277
|
+ {
|
|
|
278
|
+ //1.从数据库中导出需要进行要导出的数据
|
|
|
279
|
+// $list = Db::query('SELECT stu_list.stu_name,stu_list.stu_department,stu_list.stu_phone,stu_list.stu_email,stu_list.stu_profess
|
|
|
280
|
+// ,club_branch.* FROM club_branch INNER JOIN stu_list ON club_branch.stu_number = stu_list.stu_number
|
|
|
281
|
+// where club_branch.club_id=:acc order by club_branch.club_branch_name ', ['acc' => $clubid]);
|
|
|
282
|
+ $goods = new Goods();
|
|
|
283
|
+ $list = $goods->select()->each(function (&$item){
|
|
|
284
|
+// $;
|
|
|
285
|
+ });
|
|
|
286
|
+ if (empty($list)){
|
|
|
287
|
+ $this->error('没有可导出的数据');
|
|
|
288
|
+ }
|
|
|
289
|
+// foreach ()
|
282
|
|
290
|
|
283
|
|
291
|
|
284
|
- //重要补助
|
292
|
+ //重要补助
|
285
|
//2.加载PHPExcle类库
|
293
|
//2.加载PHPExcle类库
|
286
|
vendor('PHPExcel.PHPExcel');
|
294
|
vendor('PHPExcel.PHPExcel');
|
287
|
//3.实例化PHPExcel类
|
295
|
//3.实例化PHPExcel类
|
|
@@ -308,29 +316,29 @@ class Litestoregoods extends Backend |
|
@@ -308,29 +316,29 @@ class Litestoregoods extends Backend |
308
|
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);
|
316
|
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);
|
309
|
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(30);
|
317
|
$objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(30);
|
310
|
|
318
|
|
311
|
- for($i=0;$i<count($list);$i++){
|
|
|
312
|
- $objPHPExcel->getActiveSheet()->setCellValue('A'.($i+2),$list[$i]['club_branch_name']);//ID
|
|
|
313
|
- $objPHPExcel->getActiveSheet()->setCellValue('B'.($i+2),$list[$i]['club_position']);//标签码
|
|
|
314
|
- $objPHPExcel->getActiveSheet()->setCellValue('C'.($i+2),$list[$i]['stu_number']);//防伪码
|
|
|
315
|
- $objPHPExcel->getActiveSheet()->setCellValue('D'.($i+2),$list[$i]['stu_name']);//ID
|
|
|
316
|
- $objPHPExcel->getActiveSheet()->setCellValue('E'.($i+2),$list[$i]['stu_phone']);//标签码
|
|
|
317
|
- $objPHPExcel->getActiveSheet()->setCellValue('F'.($i+2),$list[$i]['stu_email']);//ID
|
|
|
318
|
- $objPHPExcel->getActiveSheet()->setCellValue('G'.($i+2),$list[$i]['stu_department']);//标签码
|
|
|
319
|
- $objPHPExcel->getActiveSheet()->setCellValue('H'.($i+2),$list[$i]['stu_profess']);//防伪码
|
319
|
+ for ($i = 0; $i < count($list); $i++) {
|
|
|
320
|
+ $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $list[$i]['club_branch_name']);//ID
|
|
|
321
|
+ $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $list[$i]['club_position']);//标签码
|
|
|
322
|
+ $objPHPExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $list[$i]['stu_number']);//防伪码
|
|
|
323
|
+ $objPHPExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $list[$i]['stu_name']);//ID
|
|
|
324
|
+ $objPHPExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $list[$i]['stu_phone']);//标签码
|
|
|
325
|
+ $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $list[$i]['stu_email']);//ID
|
|
|
326
|
+ $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $list[$i]['stu_department']);//标签码
|
|
|
327
|
+ $objPHPExcel->getActiveSheet()->setCellValue('H' . ($i + 2), $list[$i]['stu_profess']);//防伪码
|
320
|
}
|
328
|
}
|
321
|
//7.设置保存的Excel表格名称
|
329
|
//7.设置保存的Excel表格名称
|
322
|
- $filename = $club_name.'人员名单'.date('ymd',time()).'.xls';
|
330
|
+ $filename = $club_name . '人员名单' . date('ymd', time()) . '.xls';
|
323
|
//8.设置当前激活的sheet表格名称;
|
331
|
//8.设置当前激活的sheet表格名称;
|
324
|
$objPHPExcel->getActiveSheet()->setTitle('人员名单');
|
332
|
$objPHPExcel->getActiveSheet()->setTitle('人员名单');
|
325
|
//9.设置浏览器窗口下载表格
|
333
|
//9.设置浏览器窗口下载表格
|
326
|
header("Content-Type: application/force-download");
|
334
|
header("Content-Type: application/force-download");
|
327
|
header("Content-Type: application/octet-stream");
|
335
|
header("Content-Type: application/octet-stream");
|
328
|
header("Content-Type: application/download");
|
336
|
header("Content-Type: application/download");
|
329
|
- header('Content-Disposition:inline;filename="'.$filename.'"');
|
337
|
+ header('Content-Disposition:inline;filename="' . $filename . '"');
|
330
|
//生成excel文件
|
338
|
//生成excel文件
|
331
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
339
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
332
|
//下载文件在浏览器窗口
|
340
|
//下载文件在浏览器窗口
|
333
|
$objWriter->save('php://output');
|
341
|
$objWriter->save('php://output');
|
334
|
exit;
|
342
|
exit;
|
335
|
-}
|
343
|
+ }
|
336
|
} |
344
|
} |