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'] = $user_info->username; $row['truename'] = $user_info->name; $tmp_query = OrderT::find() ->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.'"'); } 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); } // 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;//总签单净保费 } } //提单总数 $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(); //通时 $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; $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]; } $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 ]); } public function actionCleanWork() { $request = Yii::$app->request; $date_begin = $request->get('date_begin',date('Y-m-d')); $date_end = $request->get('date_end',date('Y-m-d')); $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.'" and '; } $user_items = $this->my->getChildrenClean($userSql); 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; $sum_total[1] = 0; $sum_total[2] = 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; } } $row = array(); $row['id'] = $user_info->id; $row['username'] = $user_info->username; $row['truename'] = $user_info->name; $tmp_query = CleanTongji::find() ->where('user_id='.$user_info->id); if($date_begin != '') { $tmp_query = $tmp_query->andWhere('yuefen>="'.$date_begin.'"'); } if($date_end != '') { $tmp_query = $tmp_query->andWhere('yuefen<="'.$date_end.'"'); } if($company_id > 0) { $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'); $row['total'] = $total; $user_rows[] = $row; $sum_total[0] += $total['right_num']; $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() ->all(); return $this->render('clean-work',[ 'user_rows' => $user_rows, 'date_begin' => $date_begin, 'date_end' => $date_end, 'username' => $username, 'sum_total' => $sum_total, 'group_id' => $group_id, 'group_items' => $group_items, 'company_items' => $company_items, 'company_id' => $company_id ]); } public function actionCleanWorkZj() { $request = Yii::$app->request; $date_begin = $request->get('date_begin',date('Y-m-d')); $date_end = $request->get('date_end',date('Y-m-d')); $query = CleanFenpei::find(); if($date_begin != '') { $query = $query->andWhere('fenpei_date>="'.$date_begin.'"'); } if($date_end != '') { $query = $query->andWhere('fenpei_date<="'.$date_end.'"'); } $CleanFenpei=$query ->count(); return $this->render('clean-work-zj',[ 'CleanFenpei' => $CleanFenpei, 'date_begin' => $date_begin, 'date_end' => $date_end, ]); } public function actionFixWork() { $request = Yii::$app->request; $date_begin = $request->get('date_begin',date('Y-m-d')); $date_end = $request->get('date_end',date('Y-m-d')); $join_date_begin = $request->get('join_date_begin',date('Y-m-d')); $join_date_end = $request->get('join_date_end',date('Y-m-d')); $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'] = $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($company_id > 0) { // $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;//总签单净保费 // } // } //提车总数 $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($join_date_begin != '') { $tmp_query = $tmp_query->andWhere('join_date>="'.$join_date_begin.'"'); } if($join_date_end != '') { $tmp_query = $tmp_query->andWhere('join_date<="'.$join_date_end.'"'); } foreach($tmp_query->each() as $item) { //提单总数 if ($item->status > 0) { $total[2] += $item->dingsun_hour_money;//工时费 $total[3] += $item->dingsun_huanjian_money;//配件费 $total[4] += $item->zhuche_money;//定损金额 } } $total[7] = $tmp_query->count(); //通时 // $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] = 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]; } $company_items = InsurerCompanyT::find() ->all(); return $this->render('fix-work',[ 'user_rows' => $user_rows, 'date_begin' => $date_begin, 'date_end' => $date_end, 'join_date_begin' => $join_date_begin, 'join_date_end' => $join_date_end, 'username' => $username, 'sum_total' => $sum_total, 'group_id' => $group_id, 'group_items' => $group_items, 'company_items' => $company_items, '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,'总签单净保费'); $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'); } public function actionWorkInfo() { $request = Yii::$app->request; $user_id = $request->get('user_id'); $date_begin = $request->get('date_begin'); $date_end = $request->get('date_end'); $date2_begin = $request->get('date2_begin'); $date2_end = $request->get('date2_end'); $username = $request->get('username'); $user_info = UserT::findOne(['id'=>$user_id]); $total[0] = ''; $total[1] = 0; $total[2] = 0; $total[3] = 0; $total[4] = 0; $total[5] = 0; $total[6] = 0; $total[7] = 0; $total[8] = 0; $total[9] = 0; $total[10] = 0; //提交单数 $tmp_query = OrderT::find() ->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.'"'); } 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.'"'); } // echo $tmp_query->createCommand()->rawSql."
"; $items = $tmp_query->all(); foreach($items as $item) { $total[0]++; //提单总数 if($item->status_id > 1) { $total[1]++; $total[2] += $item->total1_clear;//商业总净保费 $total[3] += $item->total1;//商业含税总保费 $total[4] += $item->total2_clear;//交强总净保费 $total[5] += $item->total2;//交强含税总保费 $total[6] += $item->total3;//车船税 $total[7] += $item->total_all;//共计签单 $total[8] += $item->total1_real;//折扣后商业净保费 $total[9] += $item->total1_dis;//减免金额 $total[10] += $item->total_real;//应收 } } //通时 $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 ]); } public function actionFixWorkInfo() { $request = Yii::$app->request; $user_id = $request->get('user_id'); $date_begin = $request->get('date_begin'); $date_end = $request->get('date_end'); $join_date_begin = $request->get('join_date_begin'); $join_date_end = $request->get('join_date_end'); $username = $request->get('username'); $user_info = UserT::findOne(['id'=>$user_id]); $total[0] = 0; $total[1] = 0; $total[2] = 0; //提交单数 $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($join_date_begin != '') { $tmp_query = $tmp_query->andWhere('join_date>="'.$join_date_begin.'"'); } if($join_date_end != '') { $tmp_query = $tmp_query->andWhere('join_date<="'.$join_date_end.'"'); } // echo $tmp_query->createCommand()->rawSql."
"; $items = $tmp_query->all(); foreach($items as $item) { //提单总数 if ($item->status > 0) { $total[0] += $item->dingsun_hour_money;//工时费 $total[1] += $item->dingsun_huanjian_money;//配件费 $total[2] += $item->zhuche_money;//定损金额 } } // foreach($items as $item) { // $total[0]++; // //提单总数 // if($item->status_id > 1) { // $total[1]++; // $total[2] += $item->total1_clear;//商业总净保费 // $total[3] += $item->total1;//商业含税总保费 // $total[4] += $item->total2_clear;//交强总净保费 // $total[5] += $item->total2;//交强含税总保费 // $total[6] += $item->total3;//车船税 // $total[7] += $item->total_all;//共计签单 // $total[8] += $item->total1_real;//折扣后商业净保费 // $total[9] += $item->total1_dis;//减免金额 // $total[10] += $item->total_real;//应收 // } // } // // //通时 // $phone_time = ''; // $total[0] = $phone_time; return $this->render('fix-work-info',[ 'user_info' => $user_info, 'items' => $items, 'date_begin' => $date_begin, 'date_end' => $date_end, 'join_date_begin' => $join_date_begin, 'join_date_end' => $join_date_end, 'username' => $username, 'total' => $total ]); } public function actionNonWork() { $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'] = $user_info->username; $row['truename'] = $user_info->name; $tmp_query = OrderT::find() ->where('user_id='.$user_info->id.' and status_id>1') ->andWhere('insurance_status=2'); 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); } // exit; foreach($tmp_query->each() as $item) { $total[0]++; //提单总数 if ($item->status_id > 0) { $total[1]++; $total[2] += $item->nona->baofei;//保险费用 $total[3] += $item->non_num;//投保份数 } } //通时 $phone_time = ''; $total[0] = $phone_time; $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]; } $company_items = InsurerCompanyT::find() ->all(); return $this->render('non-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 ]); } public function actionNonWorkInfo() { $request = Yii::$app->request; $user_id = $request->get('user_id'); $date_begin = $request->get('date_begin'); $date_end = $request->get('date_end'); $date2_begin = $request->get('date2_begin'); $date2_end = $request->get('date2_end'); $username = $request->get('username'); $user_info = UserT::findOne(['id'=>$user_id]); $total[0] = ''; $total[1] = 0; $total[2] = 0; $total[3] = 0; $total[4] = 0; $total[5] = 0; $total[6] = 0; $total[7] = 0; $total[8] = 0; $total[9] = 0; $total[10] = 0; //提交单数 $tmp_query = OrderT::find() ->where('user_id='.$user_info->id.' and status_id>1') ->andWhere('insurance_status=2'); 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.'"'); } // echo $tmp_query->createCommand()->rawSql."
"; $items = $tmp_query->all(); foreach($items as $item) { $total[0]++; //提单总数 if($item->status_id > 1) { $total[1]++; $total[2] += $item->nona->baofei;//保险费用 $total[3] += $item->non_num;//投保份数 } } return $this->render('non-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 ]); } }