DownloadTemplateController.class.php
1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* 【后台】下载人员导入,激励导入模板
* DownloadTemplateController.class.php
* @author:daijun
* @date:2017-08-31
*/
namespace Frontend\Controller\Export;
class DownloadTemplateController extends AbstractController
{
// 激励导入
const INCENTIVES_IMPORT = 1;
// 员工导入
const USER_IMPORT = 2;
public function Index()
{
$type = I('get.type', 0, 'intval');
if (self::INCENTIVES_IMPORT == $type) {
// 下载激励导入模板
$data_path = APP_PATH . 'Data' . D_S . 'Incentives_import.xls';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=激励导入模板.xls');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($data_path));
readfile($data_path);
} elseif (self::USER_IMPORT == $type) {
// 下载员工导入模板
$data_path = APP_PATH . 'Data' . D_S . 'User_import.xls';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=员工导入模板.xls');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($data_path));
readfile($data_path);
}
exit;
}
}