From 698b6d8f3e06c392e5831550a9da0d90cd7b228d Mon Sep 17 00:00:00 2001 From: zengchaoxin Date: Tue, 15 Oct 2019 04:13:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=B7=A5=E4=BD=9C=E9=87=8F?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/controllers/StatisticsController.php | 347 +++++------------- frontend/views/statistics/work-info.php | 133 ++++--- frontend/views/statistics/work.php | 255 ++++++++----- frontend/views/user/edit.php | 129 ++++--- 4 files changed, 389 insertions(+), 475 deletions(-) diff --git a/frontend/controllers/StatisticsController.php b/frontend/controllers/StatisticsController.php index e4cb4f6..a517c24 100644 --- a/frontend/controllers/StatisticsController.php +++ b/frontend/controllers/StatisticsController.php @@ -21,8 +21,21 @@ class StatisticsController extends BaseController public $enableCsrfValidation = false; public $layout = 'blue-main'; - public function actionWork() + public function actionWork() { + $group_items = GroupT::getTree((int)$this->my->group_id); + if($this->my->id == 1 || $this->my->username=='6002') + $group_items = GroupT::getTree(); + $company_items = InsurerCompanyT::find() + ->all(); + return $this->render('work',[ + 'group_items' => $group_items, + 'company_items' => $company_items + ]); + } + + public function actionWorkJson() { + Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request; $date_begin = $request->get('date_begin',date('Y-m-d')); $date_end = $request->get('date_end',date('Y-m-d')); @@ -31,9 +44,7 @@ class StatisticsController extends BaseController $username = $request->get('username'); $group_id = $request->get('group_id'); $company_id = $request->get('company_id'); - $group_items = GroupT::getTree((int)$this->my->group_id); - if($this->my->id == 1 || $this->my->username=='6002') - $group_items = GroupT::getTree(); + $group_ids[] = $group_id; if($group_id > 0) { $items = GroupT::getTree($group_id); @@ -42,12 +53,6 @@ class StatisticsController extends BaseController } } -// 原来的搜索条件 -// $userSql = ''; -// if($username != '') { -// $userSql = ' username like "'.$username.'"'; -// } - // 现在的搜索条件 $userSql = ''; if($username != '') { @@ -58,8 +63,6 @@ class StatisticsController extends BaseController $user_items = $this->my->getChildren($userSql); if($this->my->username == '6002') $user_items = $this->my->getChildren($userSql,1); -// $user_items[] = $this->my; -//var_dump($user_items); $user_rows = array(); $sum_total = array(); $sum_total[0] = ''; @@ -95,22 +98,21 @@ class StatisticsController extends BaseController ->where('user_id='.$user_info->id.' and status_id>1') ->andWhere('insurance_status=1 or insurance_status=3'); if($date_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); + $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); } if($date_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date_end.'"'); + $tmp_query->andWhere('submit_date<="'.$date_end.'"'); } if($date2_begin != '') { - $tmp_query = $tmp_query->andWhere('print_date>="'.$date2_begin.'"'); + $tmp_query->andWhere('print_date>="'.$date2_begin.'"'); } if($date2_end != '') { - $tmp_query = $tmp_query->andWhere('print_date<="'.$date2_end.'"'); + $tmp_query->andWhere('print_date<="'.$date2_end.'"'); } if($company_id > 0) { - $tmp_query = $tmp_query->andWhere('company_id='.$company_id); + $tmp_query->andWhere('company_id='.$company_id); } -// exit; foreach($tmp_query->each() as $item) { $total[0]++; //提单总数 @@ -129,16 +131,16 @@ class StatisticsController extends BaseController $tmp_query = FixCarT::find() ->where('user_id='.$user_info->id.' and status>0'); if($date_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); + $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); } if($date_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date_end.'"'); + $tmp_query->andWhere('submit_date<="'.$date_end.'"'); } if($date2_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date2_begin.'"'); + $tmp_query->andWhere('submit_date>="'.$date2_begin.'"'); } if($date2_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date2_end.'"'); + $tmp_query->andWhere('submit_date<="'.$date2_end.'"'); } $total[7] = $tmp_query->count(); @@ -146,7 +148,6 @@ class StatisticsController extends BaseController $phone_time = ''; $query = PhoneDayT::find() ->where('user_id='.$user_info->id.' and call_date>="'.$date_begin.'" and call_date<="'.$date_end.'"'); -// echo $query->createCommand()->rawSql; $items = $query->all(); $call_time = 0; foreach($items as $item) { @@ -163,7 +164,6 @@ class StatisticsController extends BaseController $row['total'] = $total; $user_rows[] = $row; -// $sum_total[0] += $total[0]; $sum_total[1] += $total[1]; $sum_total[2] += $total[2]; $sum_total[3] += $total[3]; @@ -173,23 +173,37 @@ class StatisticsController extends BaseController $sum_total[7] += $total[7]; } - $company_items = InsurerCompanyT::find() - ->all(); - - return $this->render('work',[ - 'user_rows' => $user_rows, - 'date_begin' => $date_begin, - 'date_end' => $date_end, - 'date2_begin' => $date2_begin, - 'date2_end' => $date2_end, - 'username' => $username, - 'sum_total' => $sum_total, - 'group_id' => $group_id, - 'group_items' => $group_items, - 'company_items' => $company_items, - 'company_id' => $company_id - ]); + $data = []; + $data['total'] = count($user_rows); + $data['rows'] = []; + foreach($user_rows as $item) { + $row = $item; + $row['total_0'] = $item['total'][0]!=''?$item['total'][0]:''; + $row['total_7'] = $item['total'][7]>0?$item['total'][7]:''; + $row['total_1'] = $item['total'][1]>0?$item['total'][1]:''; + $row['total_2'] = $item['total'][2]>0?'¥'.number_format($item['total'][2],2):''; + $row['total_3'] = $item['total'][3]>0?'¥'.number_format($item['total'][3],2):''; + $row['total_4'] = $item['total'][4]>0?'¥'.number_format($item['total'][4],2):''; + $row['total_5'] = $item['total'][5]>0?'¥'.number_format($item['total'][5],2):''; + $row['total_6'] = $item['total'][6]>0?'¥'.number_format($item['total'][6],2):''; + $row['op'] = 1; + $data['rows'][] = $row; + } + $row = []; + $row['username'] = '汇总'; + $row['total_7'] = $sum_total[7]>0?$sum_total[7]:''; + $row['total_1'] = $sum_total[1]>0?$sum_total[1]:''; + $row['total_2'] = $sum_total[2]>0?'¥'.number_format($sum_total[2],2):''; + $row['total_3'] = $sum_total[3]>0?'¥'.number_format($sum_total[3],2):''; + $row['total_4'] = $sum_total[4]>0?'¥'.number_format($sum_total[4],2):''; + $row['total_5'] = $sum_total[5]>0?'¥'.number_format($sum_total[5],2):''; + $row['total_6'] = $sum_total[6]>0?'¥'.number_format($sum_total[6],2):''; + $row['op'] = 0; + $data['rows'][] = $row; + + return $data; } + public function actionCleanWork() { $request = Yii::$app->request; @@ -210,7 +224,6 @@ class StatisticsController extends BaseController } } -// 现在的搜索条件 $userSql = ''; if($username != '') { $userSql = ' username like "'.$username.'" and '; @@ -221,7 +234,7 @@ class StatisticsController extends BaseController if($this->my->username == '6002') $user_items = $this->my->getChildrenClean($userSql,1); $user_items[] = $this->my; -//var_dump($user_items); + $user_rows = array(); $sum_total = array(); $sum_total[0] = 0; @@ -255,21 +268,6 @@ class StatisticsController extends BaseController $tmp_query = $tmp_query->andWhere('company_id='.$company_id); } -// exit; -// foreach($tmp_query->each() as $item) { -// $total[0]++; -// //提单总数 -// if ($item->status_id > 0) { -// $total[1]++; -// $total[2] += $item->total1_clear;//提单总净保费 -// $total[3] += $item->total2_clear;//交强总净保费 -// if($item->status_id > 5) { -// $total[4] += $item->total1_clear;//商业已收净保费 -// $total[5] += $item->total2_clear;//商业已收净保费 -// } -// $total[6] += $item->total1_clear + $item->total2_clear;//总签单净保费 -// } -// } $total['right_num']=$tmp_query->sum('right_num'); $total['wrong_num']=$tmp_query->sum('wrong_num'); $total['yuyue_num']=$tmp_query->sum('yuyue_num'); @@ -285,11 +283,6 @@ class StatisticsController extends BaseController $sum_total[1] += $total['wrong_num']; $sum_total[2] += $total['yuyue_num']; -// $sum_total[3] += $total[3]; -// $sum_total[4] += $total[4]; -// $sum_total[5] += $total[5]; -// $sum_total[6] += $total[6]; - } $company_items = InsurerCompanyT::find() @@ -510,198 +503,17 @@ class StatisticsController extends BaseController 'company_id' => $company_id ]); } - - public function actionWorkOutput() - { - $objectPHPExcel = new \PHPExcel(); - $index = 1; - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,'工号'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,'真实姓名'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,'通时'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,'提车总数'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,'提单总数'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,'商业总净保费'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,'交强总净保费'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,'商业已收净保费'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,'交强已收净保费'); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,'总签单净保费'); - + public function actionWorkInfo() { $request = Yii::$app->request; - $date_begin = $request->get('date_begin',date('Y-m-d')); - $date_end = $request->get('date_end',date('Y-m-d')); - $date2_begin = $request->get('date2_begin'); - $date2_end = $request->get('date2_end'); - $username = $request->get('username'); - $group_id = $request->get('group_id'); - $company_id = $request->get('company_id'); - $group_items = GroupT::getTree((int)$this->my->group_id); - if($this->my->id == 1 || $this->my->username=='6002') - $group_items = GroupT::getTree(); - $group_ids[] = $group_id; - if($group_id > 0) { - $items = GroupT::getTree($group_id); - foreach($items as $group_info) { - $group_ids[] = $group_info->id; - } - } - -// 原来的搜索条件 -// $userSql = ''; -// if($username != '') { -// $userSql = ' username like "'.$username.'"'; -// } - -// 现在的搜索条件 - $userSql = ''; - if($username != '') { - $userSql = ' username like "'.$username.'" and '; - } - //$userSql .= 'is_locked=0 and is_login=1'; - - $user_items = $this->my->getChildren($userSql); - if($this->my->username == '6002') - $user_items = $this->my->getChildren($userSql,1); - $user_items[] = $this->my; -//var_dump($user_items); - $user_rows = array(); - $sum_total = array(); - $sum_total[0] = ''; - $sum_total[1] = 0; - $sum_total[2] = 0; - $sum_total[3] = 0; - $sum_total[4] = 0; - $sum_total[5] = 0; - $sum_total[6] = 0; - $sum_total[7] = 0; - foreach($user_items as $user_info) { - if($user_info->is_leave == 1) continue; - - if($group_id > 0) { - if(!in_array($user_info->group_id,$group_ids)) { - continue; - } - } - $total[0] = 0; - $total[1] = 0; - $total[2] = 0; - $total[3] = 0; - $total[4] = 0; - $total[5] = 0; - $total[6] = 0; - $total[7] = 0; - - $row = array(); - $row['id'] = $user_info->id; - $row['username'] = trim($user_info->username); - $row['truename'] = $user_info->name; - $tmp_query = OrderT::find() - ->where('user_id='.$user_info->id.' and status_id>1'); - if($date_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); - } - if($date_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date_end.'"'); - } - if($date2_begin != '') { - $tmp_query = $tmp_query->andWhere('print_date>="'.$date2_begin.'"'); - } - if($date2_end != '') { - $tmp_query = $tmp_query->andWhere('print_date<="'.$date2_end.'"'); - } - if($company_id > 0) { - $tmp_query = $tmp_query->andWhere('company_id='.$company_id); - } - $index++; -// exit; - foreach($tmp_query->each() as $item) { - - $total[0]++; - //提单总数 - if ($item->status_id > 0) { - $total[1]++; - $total[2] += $item->total1_clear;//提单总净保费 - $total[3] += $item->total2_clear;//交强总净保费 - if($item->status_id > 5) { - $total[4] += $item->total1_clear;//商业已收净保费 - $total[5] += $item->total2_clear;//商业已收净保费 - } - $total[6] += $item->total1_clear + $item->total2_clear;//总签单净保费 - } - - } - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$index,$row['username']); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('B'.$index,$row['truename']); - - - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('E'.$index,$total[1]>0?$total[1]:''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('F'.$index,$total[2]>0?'¥'.number_format($total[2],2):''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('G'.$index,$total[3]>0?'¥'.number_format($total[3],2):''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('H'.$index,$total[4]>0?'¥'.number_format($total[4],2):''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('I'.$index,$total[5]>0?'¥'.number_format($total[5],2):''); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('J'.$index,$total[6]>0?'¥'.number_format($total[6],2):''); - //提单总数 - $tmp_query = FixCarT::find() - ->where('user_id='.$user_info->id.' and status>0'); - if($date_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); - } - if($date_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date_end.'"'); - } - if($date2_begin != '') { - $tmp_query = $tmp_query->andWhere('submit_date>="'.$date2_begin.'"'); - } - if($date2_end != '') { - $tmp_query = $tmp_query->andWhere('submit_date<="'.$date2_end.'"'); - } - $total[7] = $tmp_query->count(); - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('D'.$index,$total[7]>0?$total[7]:''); - - //通时 - $phone_time = ''; - $query = PhoneDayT::find() - ->where('user_id='.$user_info->id.' and call_date>="'.$date_begin.'" and call_date<="'.$date_end.'"'); -// echo $query->createCommand()->rawSql; - $items = $query->all(); - $call_time = 0; - foreach($items as $item) { - $call_time += $item->call_time; - } - if($call_time > 0) { - $h = floor($call_time/3600); - $m = floor(($call_time - $h * 3600)/60); - $s = $call_time - $h * 3600 - $m * 60; - $phone_time = $h.':'.$m.':'.$s; - } - - $total[0] = $phone_time; - $objectPHPExcel->setActiveSheetIndex(0)->setCellValue('C'.$index,$total[0]!=''?$total[0]:''); - $row['total'] = $total; - $user_rows[] = $row; - - - -// $sum_total[0] += $total[0]; -// $sum_total[1] += $total[1]; -// $sum_total[2] += $total[2]; -// $sum_total[3] += $total[3]; -// $sum_total[4] += $total[4]; -// $sum_total[5] += $total[5]; -// $sum_total[6] += $total[6]; -// $sum_total[7] += $total[7]; - } - - header('Content-Type: application/vnd.ms-excel;charset=utf-8'); - header('Content-Disposition:attachment;filename="'.date("YmjHis").'.xls"'); - header('Cache-Control: max-age=0'); - $objWriter = \PHPExcel_IOFactory::createWriter($objectPHPExcel, 'Excel5'); - $objWriter->save('php://output'); - + $user_id = $request->get('user_id'); + return $this->render('work-info',[ + 'user_id' => $user_id + ]); } - - public function actionWorkInfo() + public function actionWorkInfoJson() { + Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request; $user_id = $request->get('user_id'); $date_begin = $request->get('date_begin'); @@ -726,8 +538,7 @@ class StatisticsController extends BaseController //提交单数 $tmp_query = OrderT::find() - ->where('user_id='.$user_info->id.' and status_id>1') - ->andWhere('insurance_status=1 or insurance_status=3'); + ->where('user_id='.$user_info->id.' and status_id>1'); if($date_begin != '') { $tmp_query = $tmp_query->andWhere('submit_date>="'.$date_begin.'"'); } @@ -763,17 +574,29 @@ class StatisticsController extends BaseController $phone_time = ''; $total[0] = $phone_time; - return $this->render('work-info',[ - 'user_info' => $user_info, - 'items' => $items, - 'date_begin' => $date_begin, - 'date_end' => $date_end, - 'date2_begin' => $date2_begin, - 'date2_end' => $date2_end, - 'username' => $username, - 'total' => $total - ]); + $data = []; + $data['total'] = count($items); + $data['rows'] = []; + foreach($items as $item) { + $row = $item->toArray(); + $row['total1_clear'] = '¥'.$item->total1_clear; + $row['total1_real'] = '¥'.$item->total1_real; + $row['total1_dis'] = '¥'.$item->total1_dis; + $row['total1_percent'] = '¥'.$item->total1_percent; + $row['status_name'] = '¥'.$item->status->name; + $row['op'] = 1; + $data['rows'][] = $row; + } + $row = []; + $row['id'] = '汇总'; + $row['total1_clear'] = $total[2]?'¥'.number_format($total[2],2):''; + $row['total1_real'] = $total[8]?'¥'.number_format($total[8],2):''; + $row['total1_dis'] = $total[9]?'¥'.number_format($total[9],2):''; + $row['op'] = 0; + $data['rows'][] = $row; + return $data; } + public function actionFixWorkInfo() { $request = Yii::$app->request; diff --git a/frontend/views/statistics/work-info.php b/frontend/views/statistics/work-info.php index 019139e..9a9eb13 100644 --- a/frontend/views/statistics/work-info.php +++ b/frontend/views/statistics/work-info.php @@ -1,65 +1,80 @@ - - - - - + + + + - - - - - - -
- - 提单日期: - 正本日期: -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
车主车牌号商业总净保费折扣后商业净保费减免金额商业折扣率状态详情
car_man?>car_no?>total1_clear?>total1_real?>total1_dis?>total1_percent?>status->name?> - [详情] -
汇总
+endBlock(); ?> diff --git a/frontend/views/statistics/work.php b/frontend/views/statistics/work.php index 61e09b1..ce509d8 100644 --- a/frontend/views/statistics/work.php +++ b/frontend/views/statistics/work.php @@ -1,108 +1,161 @@ - - - - - + + + + - - - - - - -
- 提单日期:从截止 - 正本日期:从截止 - 工号: - 级别: - - - - 当天   - &date_end=">7天   - &date_end=">1个月   - &date_end=">3个月   -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
工号真实姓名通时提车总数提单总数商业总净保费交强总净保费商业已收净保费交强已收净保费总签单净保费详情
0?$row['total'][7]:''?>0?$row['total'][1]:''?>0?'¥'.number_format($row['total'][2],2):''?>0?'¥'.number_format($row['total'][3],2):''?>0?'¥'.number_format($row['total'][4],2):''?>0?'¥'.number_format($row['total'][5],2):''?>0?'¥'.number_format($row['total'][6],2):''?>[详情]
汇总
+endBlock(); ?> diff --git a/frontend/views/user/edit.php b/frontend/views/user/edit.php index 3ee591a..0bb7b55 100644 --- a/frontend/views/user/edit.php +++ b/frontend/views/user/edit.php @@ -19,26 +19,26 @@ use \common\libs\MyLib;
- -
+ +
- -
+ +
- -
+ +
- -
+ +
- -
+ +
- -
+ +
is_login==1?'checked':''?>>
- -
+ +
is_outer==1?'checked':''?>>
- -
+ +
is_leave==1?'checked':''?>> @@ -93,56 +93,48 @@ use \common\libs\MyLib;
- -
+ +
- +
- -
+ +
- +
- -
+ +
- -
+ +
- -
- + +
+
+ +
%
+
- -
- + +
+
+ +
+
- -
- -
- -
+ +
is_double==1?'checked':''?>> @@ -197,7 +189,7 @@ use \common\libs\MyLib; ->all(); foreach ($child_menus as $child_menu) { echo '
-
+
@@ -269,10 +261,41 @@ use \common\libs\MyLib; $(subs[i]).prop('checked', ''); } } + var threes = $(this).parent().parent().next().find('.three_checkbox'); + for(var i = 0; i < threes.length; i++) { + if(checked) { + $(threes[i]).prop('checked', 'checked'); + } else { + $(threes[i]).prop('checked', ''); + } + } }); $('.sub_checkbox').click(function() { var checked = $(this).prop('checked'); - var subs = $(this).parent().parent().parent().parent().parent().parent().prev().find('.parent_checkbox'); + var parents = $(this).parent().parent().parent().parent().parent().parent().prev().find('.parent_checkbox'); + for(var i = 0; i < parents.length; i++) { + if(checked) { + $(parents[i]).prop('checked', 'checked'); + } + } + var threes = $(this).parent().parent().next().find('.three_checkbox'); + for(var i = 0; i < threes.length; i++) { + if(checked) { + $(threes[i]).prop('checked', 'checked'); + } else { + $(threes[i]).prop('checked', ''); + } + } + }); + $('.three_checkbox').click(function() { + var checked = $(this).prop('checked'); + var parents = $(this).parent().parent().parent().parent().parent().parent().prev().find('.parent_checkbox'); + for(var i = 0; i < parents.length; i++) { + if(checked) { + $(parents[i]).prop('checked', 'checked'); + } + } + var subs = $(this).parent().parent().prev().find('.sub_checkbox'); for(var i = 0; i < subs.length; i++) { if(checked) { $(subs[i]).prop('checked', 'checked');