|
@@ -1,11 +1,17 @@
|
|
<?php
|
|
<?php
|
|
|
|
+
|
|
|
|
+require_once "include/PHPExcel.php";
|
|
|
|
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
|
+use PhpOffice\PhpSpreadsheet\Style;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 印章申请使用
|
|
* 印章申请使用
|
|
*/
|
|
*/
|
|
class mode_sealaplClassAction extends inputAction{
|
|
class mode_sealaplClassAction extends inputAction{
|
|
-
|
|
|
|
|
|
|
|
- protected function savebefore($table, $arr, $id, $addbo){
|
|
|
|
|
|
+
|
|
|
|
+ protected function savebefore($table, $arr, $id, $addbo){
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -55,7 +61,198 @@ class mode_sealaplClassAction extends inputAction{
|
|
|
|
|
|
return $barr;
|
|
return $barr;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ public function getSealListAjax() {
|
|
|
|
+ $seal_list = m("seal")->getall("1=1", "id, name");
|
|
|
|
+ array_unshift($seal_list, ["id"=>"0","name"=>"全部"]);
|
|
|
|
+ $this->returnjson($seal_list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @throws PHPExcel_Exception
|
|
|
|
+ * @throws PHPExcel_Writer_Exception
|
|
|
|
+ * @throws PHPExcel_Reader_Exception
|
|
|
|
+ * @throws \PhpOffice\PhpSpreadsheet\Exception
|
|
|
|
+ */
|
|
|
|
+ public function export_listAjax() {
|
|
|
|
+
|
|
|
|
+ $startDate = $this->post("start_date");
|
|
|
|
+ $stopDate = $this->post("stop_date");
|
|
|
|
+ $status = $this->post("status");
|
|
|
|
+ $export_type = $this->post("export_type");
|
|
|
|
+
|
|
|
|
+ $excelTitle = "枣泉煤矿用印登记台账";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $sealArr = m("seal")->getall("1=1", "id, name, specialized");
|
|
|
|
+
|
|
|
|
+ $sealDic = [];
|
|
|
|
+ foreach ($sealArr as $k=>$v) {
|
|
|
|
+ $sealDic[$v["id"]] = $v;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $where = "1=1";
|
|
|
|
+ if (!empty($startDate) && !empty($stopDate)) {
|
|
|
|
+ $where .= " and `applydt` >= '{$startDate}' and `applydt` <= '{$stopDate}'";
|
|
|
|
+ }
|
|
|
|
+ if ($status == 1) {
|
|
|
|
+ $where .= " and `status` = 1";
|
|
|
|
+ }
|
|
|
|
+ if (!empty($export_type) && $export_type != 0) {
|
|
|
|
+ $where .= " and `seal_name` = $export_type";
|
|
|
|
+ $excelTitle .= "({$sealDic[$export_type]['name']})";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $list = m("sealapl")
|
|
|
|
+ ->getall($where, "id, seal_name, applydt, substr(applydt, 1, 4) as year, year_num, office_date, reason, opp_name, amount, contract_num, use_con, applicant, apply_pnum, advice_level4_leader, advice_level3_leader, advice_level2_leader, advice_level1_leader, notes, office_date", "substr(applydt, 1, 4) desc, id asc");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 创建一个新的PHPExcel对象
|
|
|
|
+
|
|
|
|
+ # 实例化 Spreadsheet 对象
|
|
|
|
+ $spreadsheet = new Spreadsheet();
|
|
|
|
+ $spreadsheet->setActiveSheetIndex(0); // 设置活动的工作表
|
|
|
|
+ # 获取活动工作薄
|
|
|
|
+ $sheet = $spreadsheet->getActiveSheet();
|
|
|
|
+ $sheet->mergeCells("A1:P1"); // 水平合并A1单元格
|
|
|
|
+ $sheet->setCellValue('A1', $excelTitle); // 设置表头
|
|
|
|
+ // 设置样式
|
|
|
|
+ // 设置表头和第二行的样式(获取样式及设置方式类似,但类名不同)
|
|
|
|
+ $bodersStyle = [
|
|
|
|
+ 'borders' => [
|
|
|
|
+ 'allBorders' => [
|
|
|
|
+ 'borderStyle' => Style\Border::BORDER_THIN,
|
|
|
|
+ ],
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ $styleArray = [
|
|
|
|
+ 'borders' => $bodersStyle['borders'],
|
|
|
|
+ 'alignment' => [
|
|
|
|
+ 'horizontal' => Style\Alignment::HORIZONTAL_CENTER,
|
|
|
|
+ 'vertical' => Style\Alignment::VERTICAL_CENTER,
|
|
|
|
+ 'wrapText' => true,
|
|
|
|
+ ]
|
|
|
|
+ ];
|
|
|
|
+ $sheet->getStyle('A1:P2')->applyFromArray($styleArray);
|
|
|
|
+ $spreadsheet->getActiveSheet()->getRowDimension('1')->setRowHeight(95);
|
|
|
|
+ $sheet->getStyle('A1')->getFont()->setBold(false)->setSize(24);
|
|
|
|
+ $sheet->getStyle('A2:P2')->getFont()->setBold(true)->setSize(14);
|
|
|
|
+ // 设置为字符串格式
|
|
|
|
+ $sheet->getStyle('J')->getNumberFormat()->setFormatCode(Style\NumberFormat::FORMAT_TEXT);
|
|
|
|
+ // 列宽
|
|
|
|
+ $sheet->getColumnDimension('A')->setWidth(13);
|
|
|
|
+ $sheet->getColumnDimension('B')->setWidth(7);
|
|
|
|
+ $sheet->getColumnDimension('C')->setWidth(47);
|
|
|
|
+ $sheet->getColumnDimension('D')->setWidth(18);
|
|
|
|
+ $sheet->getColumnDimension('E')->setWidth(10);
|
|
|
|
+ $sheet->getColumnDimension('F')->setWidth(12);
|
|
|
|
+ $sheet->getColumnDimension('G')->setWidth(8);
|
|
|
|
+ $sheet->getColumnDimension('H')->setWidth(11);
|
|
|
|
+ $sheet->getColumnDimension('I')->setWidth(12);
|
|
|
|
+ $sheet->getColumnDimension('J')->setWidth(11); // 手机号
|
|
|
|
+ $sheet->getColumnDimension('K')->setWidth(13);
|
|
|
|
+ $sheet->getColumnDimension('L')->setWidth(12);
|
|
|
|
+ $sheet->getColumnDimension('M')->setWidth(12);
|
|
|
|
+ $sheet->getColumnDimension('N')->setWidth(12);
|
|
|
|
+ $sheet->getColumnDimension('O')->setWidth(12);
|
|
|
|
+ $sheet->getColumnDimension('P')->setWidth(12);
|
|
|
|
+
|
|
|
|
+ // 表头
|
|
|
|
+ $titleArr = ["时间","年度\n编号","用印事由摘要、\n用印材料明细(全称)","相对方名称","金额、\n工作量","合同号","用印\n数量","申请\n单位\n负责人","经办人","手机号","矿最终审\n批领导","法律事\n务审核\n人","业务\n部门\n审核人","办公室\n审核人","印章\n专管人","备注"];
|
|
|
|
+
|
|
|
|
+ // 设置列,循环设置表头单元格的值
|
|
|
|
+ $column = 'A';
|
|
|
|
+ foreach ($titleArr as $title) {
|
|
|
|
+ $sheet->setCellValue($column.'2', $title);
|
|
|
|
+ $column++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $rowArr = [];
|
|
|
|
+ foreach ($list as $key=>$row) {
|
|
|
|
+ $num = $row['id'];
|
|
|
|
+
|
|
|
|
+ $date = $row['applydt'];
|
|
|
|
+ $year = date("Y", strtotime($date));
|
|
|
|
+ $month = date("m", strtotime($date));
|
|
|
|
+
|
|
|
|
+ $this_month = date("Y-m", strtotime($date));
|
|
|
|
+ $last_month = date("Y-m", strtotime("-1 month", strtotime($date)));
|
|
|
|
+
|
|
|
|
+ $office_date = date("Y-m-d", strtotime($row['office_date']));
|
|
|
|
+ $year_num = $row['year_num'];
|
|
|
|
+ $reason = $row['reason'];
|
|
|
|
+ $opp_name = $row['opp_name'];
|
|
|
|
+ $amount = $row['amount'];
|
|
|
|
+ $contract_num = $row['contract_num'];
|
|
|
|
+ $use_con = $row['use_con'];
|
|
|
|
+ $applicant = $row['applicant'];
|
|
|
|
+ $apply_pnum = $row['apply_pnum'];
|
|
|
|
+ $advice_level4_leader = $row['advice_level4_leader'];
|
|
|
|
+ $advice_level3_leader = $row['advice_level3_leader'];
|
|
|
|
+ $advice_level2_leader = $row['advice_level2_leader'];
|
|
|
|
+ $advice_level1_leader = $row['advice_level1_leader'];
|
|
|
|
+ $notes = $row['notes'];
|
|
|
|
+ $seal_name = $row['seal_name'];
|
|
|
|
+ $bgr = $sealDic[$seal_name]['specialized'];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $rowArr[] = [
|
|
|
|
+ $office_date, // 时间
|
|
|
|
+ $year_num, // 年度编号
|
|
|
|
+ $reason, // 用印事由摘要、用印材料明细(全称)
|
|
|
|
+ $opp_name, // 相对方名称
|
|
|
|
+ $amount, // 金额、工作量
|
|
|
|
+ $contract_num, // 合同号
|
|
|
|
+ $use_con, // 用印数量
|
|
|
|
+ $advice_level1_leader, // 申请单位负责人
|
|
|
|
+ $applicant, // 经办人
|
|
|
|
+ $apply_pnum, // 手机号
|
|
|
|
+ null, // 矿最终审批领导
|
|
|
|
+ $advice_level4_leader, // 法律事务审核人
|
|
|
|
+ $advice_level1_leader, // 业务部门审核人
|
|
|
|
+ $advice_level2_leader, // 办公室审核人
|
|
|
|
+ $bgr, // 印章保管业务核实人
|
|
|
|
+ $notes // 备注
|
|
|
|
+
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ $rowNum = 3;
|
|
|
|
+ foreach ($rowArr as $row) {
|
|
|
|
+ $column = 'A';
|
|
|
|
+ foreach ($row as $key => $value) {
|
|
|
|
+ $sheet->setCellValue($column.$rowNum, $value);
|
|
|
|
+ $column++;
|
|
|
|
+ }
|
|
|
|
+ $rowNum++;
|
|
|
|
+ }
|
|
|
|
+ // 其他表格式设置
|
|
|
|
+ $rowCode = 'A3:P'.(count($rowArr)+2);
|
|
|
|
+ $sheet->getStyle($rowCode)->applyFromArray($styleArray);
|
|
|
|
+ $spreadsheet->getActiveSheet()->getStyle($rowCode)->getFont()->setSize(14);
|
|
|
|
+
|
|
|
|
+ // 定义保存的文件名和路径
|
|
|
|
+ $mkdir = UPDIR.'/logs/'.date('Y-m');
|
|
|
|
+
|
|
|
|
+ if(!contain(strtolower(PHP_OS),'win')){
|
|
|
|
+ $excelTitle = c('pingyin')->get("用印列表", 1);//linux要用拼音,不然会乱码
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $filename = ''.$excelTitle.'_'.date('Y_m_d_H_i_s').'.xlsx';
|
|
|
|
+ $filename = str_replace('/','',$filename);
|
|
|
|
+ $savePath = $mkdir.'/'.$filename;
|
|
|
|
+
|
|
|
|
+ $writer = new Xlsx($spreadsheet);
|
|
|
|
+ $writer->save($savePath);
|
|
|
|
+
|
|
|
|
+ $this->returnjson(array(
|
|
|
|
+ 'url' => $savePath,
|
|
|
|
+ 'totalCount'=> count($list),
|
|
|
|
+ 'downCount' => count($list),
|
|
|
|
+ ));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
//获取相关信息放到说明里
|
|
//获取相关信息放到说明里
|
|
public function getbinfoAjax()
|
|
public function getbinfoAjax()
|
|
{
|
|
{
|