正在显示
3 个修改的文件
包含
106 行增加
和
39 行删除
@@ -127,4 +127,52 @@ class Project extends Backend | @@ -127,4 +127,52 @@ class Project extends Backend | ||
127 | } | 127 | } |
128 | $this->success(); | 128 | $this->success(); |
129 | } | 129 | } |
130 | + | ||
131 | + public function downloadexcel($ids){ | ||
132 | + $workinghours=Db::name("workinghours") | ||
133 | + ->alias("a") | ||
134 | + ->join("user b","a.user_id=b.id") | ||
135 | + ->where("project_id",$ids) | ||
136 | + ->select(); | ||
137 | + $project=Db::name("project")->where("id",$ids)->find(); | ||
138 | + $res=$this->projectexcel($workinghours,$project); | ||
139 | + return $res; | ||
140 | + } | ||
141 | + | ||
142 | + /** | ||
143 | + *导出表 | ||
144 | + */ | ||
145 | + public function projectexcel($workinghours, $project) | ||
146 | + { | ||
147 | + vendor('phpoffice.phpexcel.PHPExcel'); | ||
148 | + Vendor('phpoffice.phpexcel.Classes.PHPExcel'); | ||
149 | + Vendor('phpoffice.phpexcel.Classes.PHPExcel.IOFactory.PHPExcel_IOFactory'); | ||
150 | + //实例化 | ||
151 | + $objExcel = new \PHPExcel(); | ||
152 | + //设置文档属性 | ||
153 | + $objWriter = \PHPExcel_IOFactory::createWriter($objExcel, 'Excel2007'); | ||
154 | + //设置内容 | ||
155 | + $objActSheet = $objExcel->getActiveSheet(); | ||
156 | + $key = ord("A"); | ||
157 | + $letter = explode(',', "A,B,C,D,E"); | ||
158 | + $arrHeader = array('序号', '项目名称', '提交人','工时','提交时间'); | ||
159 | + //填充表头信息 | ||
160 | + $lenth = count($arrHeader); | ||
161 | + for ($i = 0; $i < $lenth; $i++) { | ||
162 | + $objActSheet->setCellValue("$letter[$i]1", "$arrHeader[$i]"); | ||
163 | + }; | ||
164 | + //填充表格信息 | ||
165 | + foreach ($workinghours as $k => $v) { | ||
166 | + $j = $k + 1; | ||
167 | + $k += 2; | ||
168 | + $objActSheet->setCellValue('A' . $k, $j); | ||
169 | + $objActSheet->setCellValue('B' . $k, $project['project_name']); | ||
170 | + $objActSheet->setCellValue('C' . $k, $v['username']); | ||
171 | + $objActSheet->setCellValue('D' . $k, $v['working_hours']); | ||
172 | + $objActSheet->setCellValue('E' . $k, date("Y-m-d",$v['reporttime'])); | ||
173 | + } | ||
174 | + $outfile = $project['project_name'] . ".xlsx"; | ||
175 | + $objWriter->save('./datauploads/' . $outfile); | ||
176 | + return $outfile; | ||
177 | + } | ||
130 | } | 178 | } |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | -return [ | ||
4 | - 'name' => '我的网站', | ||
5 | - 'beian' => '', | ||
6 | - 'cdnurl' => '', | ||
7 | - 'version' => '1.0.1', | ||
8 | - 'timezone' => 'Asia/Shanghai', | ||
9 | - 'forbiddenip' => '', | ||
10 | - 'languages' => [ | ||
11 | - 'backend' => 'zh-cn', | ||
12 | - 'frontend' => 'zh-cn', | ||
13 | - ], | ||
14 | - 'fixedpage' => 'dashboard', | ||
15 | - 'categorytype' => [ | ||
16 | - 'default' => 'Default', | ||
17 | - 'page' => 'Page', | ||
18 | - 'article' => 'Article', | ||
19 | - 'test' => 'Test', | ||
20 | - ], | ||
21 | - 'configgroup' => [ | ||
22 | - 'basic' => 'Basic', | ||
23 | - 'email' => 'Email', | ||
24 | - 'dictionary' => 'Dictionary', | ||
25 | - 'user' => 'User', | ||
26 | - 'example' => 'Example', | ||
27 | - ], | ||
28 | - 'attachmentcategory' => [ | ||
29 | - 'category1' => 'Category1', | ||
30 | - 'category2' => 'Category2', | ||
31 | - 'custom' => 'Custom', | ||
32 | - ], | ||
33 | - 'mail_type' => '1', | ||
34 | - 'mail_smtp_host' => 'smtp.qq.com', | ||
35 | - 'mail_smtp_port' => '465', | ||
36 | - 'mail_smtp_user' => '10000', | ||
37 | - 'mail_smtp_pass' => 'password', | ||
38 | - 'mail_verify_type' => '2', | ||
39 | - 'mail_from' => '10000@qq.com', | ||
40 | -]; | 3 | +return array ( |
4 | + 'name' => '项目工时管理系统', | ||
5 | + 'beian' => '', | ||
6 | + 'cdnurl' => '', | ||
7 | + 'version' => '1.0.2', | ||
8 | + 'timezone' => 'Asia/Shanghai', | ||
9 | + 'forbiddenip' => '', | ||
10 | + 'languages' => | ||
11 | + array ( | ||
12 | + 'backend' => 'zh-cn', | ||
13 | + 'frontend' => 'zh-cn', | ||
14 | + ), | ||
15 | + 'fixedpage' => 'dashboard', | ||
16 | + 'categorytype' => | ||
17 | + array ( | ||
18 | + 'default' => 'Default', | ||
19 | + 'page' => 'Page', | ||
20 | + 'article' => 'Article', | ||
21 | + 'test' => 'Test', | ||
22 | + ), | ||
23 | + 'configgroup' => | ||
24 | + array ( | ||
25 | + 'basic' => 'Basic', | ||
26 | + 'email' => 'Email', | ||
27 | + 'dictionary' => 'Dictionary', | ||
28 | + 'user' => 'User', | ||
29 | + 'example' => 'Example', | ||
30 | + ), | ||
31 | + 'mail_type' => '1', | ||
32 | + 'mail_smtp_host' => 'smtp.qq.com', | ||
33 | + 'mail_smtp_port' => '465', | ||
34 | + 'mail_smtp_user' => '10000', | ||
35 | + 'mail_smtp_pass' => 'password', | ||
36 | + 'mail_verify_type' => '2', | ||
37 | + 'mail_from' => '10000@qq.com', | ||
38 | + 'attachmentcategory' => | ||
39 | + array ( | ||
40 | + 'category1' => 'Category1', | ||
41 | + 'category2' => 'Category2', | ||
42 | + 'custom' => 'Custom', | ||
43 | + ), | ||
44 | +); |
@@ -34,7 +34,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -34,7 +34,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
34 | {field: 'department.name', title: __('Department_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, | 34 | {field: 'department.name', title: __('Department_id'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, |
35 | {field: 'user.username', title: __('User_id'), operate: 'LIKE'}, | 35 | {field: 'user.username', title: __('User_id'), operate: 'LIKE'}, |
36 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | 36 | {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, |
37 | - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | 37 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, |
38 | + buttons: [ | ||
39 | + { | ||
40 | + name: 'ajax', | ||
41 | + title: "下载报表", | ||
42 | + text: "下载报表", | ||
43 | + classname: 'btn btn-xs btn-warning btn-magic btn-ajax', | ||
44 | + icon: 'fa fa-paper-plane', | ||
45 | + confirm: function (row) { | ||
46 | + return "确认下载报表" | ||
47 | + }, | ||
48 | + url: 'project/downloadexcel?id={id}', | ||
49 | + | ||
50 | + } | ||
51 | + | ||
52 | + ]} | ||
38 | ] | 53 | ] |
39 | ] | 54 | ] |
40 | }); | 55 | }); |
-
请 注册 或 登录 后发表评论