|
@@ -69,6 +69,7 @@ class OrderStatistics extends Auth
|
|
|
}
|
|
|
$data = list_sort_by($list,'nums','desc');
|
|
|
|
|
|
+
|
|
|
include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
|
|
|
|
|
|
$objPHPExcel =new \PHPExcel();
|
|
@@ -164,7 +165,6 @@ class OrderStatistics extends Auth
|
|
|
}
|
|
|
$data = list_sort_by($list,'nums','desc');
|
|
|
$result['rows'] = $data;
|
|
|
-
|
|
|
return json($result);
|
|
|
}else{
|
|
|
$this->assign('start',$start);
|
|
@@ -173,6 +173,102 @@ class OrderStatistics extends Auth
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function repairCateExport(){
|
|
|
+ $start = input('start',date('Y-m-d',strtotime('-7 day')));
|
|
|
+ $end = input('end',date('Y-m-d'));
|
|
|
+ $sTime = $start.' 00:00:00';
|
|
|
+ $eTime = $end.' 23:59:59';
|
|
|
+
|
|
|
+ $list = Db::name('order_type')
|
|
|
+ ->field('id,title,parent_id')
|
|
|
+ ->where('enable',1)
|
|
|
+ ->where('del',0)
|
|
|
+ ->where('org_id',$this->orgId)
|
|
|
+ ->where('parent_id','=',0)
|
|
|
+ ->select();
|
|
|
+ foreach ($list as $k=>$v){
|
|
|
+ $type = Db::name('order_type')
|
|
|
+ ->field('id')
|
|
|
+ ->where('enable',1)
|
|
|
+ ->where('del',0)
|
|
|
+ ->where('org_id',$this->orgId)
|
|
|
+ ->where('parent_id',$v['id'])
|
|
|
+ ->select();
|
|
|
+ $ids = [];
|
|
|
+ foreach ($type as $kk=>$vv){
|
|
|
+ $ids[$kk] = $vv['id'];
|
|
|
+ }
|
|
|
+ $list[$k]['ids'] = $ids;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($list as $k=>$v){
|
|
|
+ $list[$k]['nums'] = Db::name('orders')
|
|
|
+ ->alias('o')
|
|
|
+ ->join('order_repair or','or.order_id=o.id')
|
|
|
+ ->whereIn('or.type_id',$v['ids'])
|
|
|
+ ->where('o.del',0)
|
|
|
+ ->where('o.org_id',$this->orgId)
|
|
|
+ ->where('o.create_time','>=',$sTime)
|
|
|
+ ->where('o.create_time','<=',$eTime)
|
|
|
+ ->count();
|
|
|
+ }
|
|
|
+ $data = list_sort_by($list,'nums','desc');
|
|
|
+
|
|
|
+
|
|
|
+ include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
|
|
|
+
|
|
|
+ $objPHPExcel =new \PHPExcel();
|
|
|
+
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0);
|
|
|
+
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)
|
|
|
+ ->setCellValue('A1', '报修类型')
|
|
|
+ ->setCellValue('B1', '总数');
|
|
|
+
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()
|
|
|
+ ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)->getStyle('B1')->getAlignment()
|
|
|
+ ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)->getStyle('C1')->getAlignment()
|
|
|
+ ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)->getStyle('A')->getAlignment()
|
|
|
+ ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)->getStyle('B')->getAlignment()
|
|
|
+ ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)->getStyle('C')->getAlignment()
|
|
|
+ ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
+
|
|
|
+
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setWidth(30);
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(30);
|
|
|
+ $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(30);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for ($i = 0; $i < count($data); $i++) {
|
|
|
+ $objPHPExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $data[$i]['title']);
|
|
|
+ $objPHPExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $data[$i]['nums']);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $filename = '报修类型统计报表_' . date('YmdHis', time()) . '.xls';
|
|
|
+
|
|
|
+ $objPHPExcel->getActiveSheet()->setTitle('报修类型统计报表');
|
|
|
+
|
|
|
+ ob_end_clean();
|
|
|
+ header("Content-Type: application/force-download");
|
|
|
+ header("Content-Type: application/octet-stream");
|
|
|
+ header("Content-Type: application/download");
|
|
|
+ header('Content-Disposition:inline;filename="' . $filename);
|
|
|
+
|
|
|
+ $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
+
|
|
|
+ return $objWriter->save('php://output');
|
|
|
+ }
|
|
|
+
|
|
|
public function repairWorkload($mode){
|
|
|
$start = input('start',date('Y-m-d 00:00:00',strtotime('-7 day')));
|
|
|
$end = input('end',date('Y-m-d 23:59:59'));
|