diff --git a/frontend/controllers/CommonController.php b/frontend/controllers/CommonController.php index 4eacfe6..ccc3f61 100644 --- a/frontend/controllers/CommonController.php +++ b/frontend/controllers/CommonController.php @@ -381,4 +381,8 @@ class CommonController extends \yii\web\Controller } return $data; } + + public function actionCallPhone() { + return $this->render('call-phone'); + } } diff --git a/frontend/controllers/PhoneCenterController.php b/frontend/controllers/PhoneCenterController.php index 0fb4fb4..19373dc 100644 --- a/frontend/controllers/PhoneCenterController.php +++ b/frontend/controllers/PhoneCenterController.php @@ -45,8 +45,13 @@ use common\models\CompanyT; class PhoneCenterController extends BaseController { public $enableCsrfValidation = false; + public $layout = 'blue-main'; - public function actionCallRecords(){ + public function actionCallRecords() { + return $this->render('call-records'); + } + public function actionCallRecordsJson(){ + Yii::$app->response->format = Response::FORMAT_JSON; $request = Yii::$app->request; $begin_time = $request->get('begin_time',date('Y-m-d')); $end_time = $request->get('end_time',date('Y-m-d')); @@ -57,7 +62,8 @@ class PhoneCenterController extends BaseController $duration_end = $request->get('duration_end',''); $call_result = $request->get('call_result',''); $is_called = $request->get('is_called',''); - $page = $request->get('page',0); + $offset = $request->get('offset',0); + $limit = $request->get('limit', 10); $company_type = $request->get('company_type',0);//0显示全部,1只显示江西,2只显示湖北 @@ -71,79 +77,62 @@ class PhoneCenterController extends BaseController ->leftJoin('user_t','user_t.id=network_phone_t.user_id') ->where('user_t.is_delete=0 and user_t.is_leave=0'); - if($company_type == 3){ - $query = $query->andWhere('user_t.id="'.$this->my->id.'"'); + $query->andWhere('user_t.id="'.$this->my->id.'"'); } if($begin_time != ''){ - $query = $query->andWhere('network_phone_t.begin_date>="'.$begin_time.'"'); + $query->andWhere('network_phone_t.begin_date>="'.$begin_time.'"'); } if($end_time != ''){ - $query = $query->andWhere('network_phone_t.begin_date<="'.$end_time.'"'); + $query->andWhere('network_phone_t.begin_date<="'.$end_time.'"'); } if($caller != ''){ - $query = $query->andWhere('network_phone_t.caller='.$caller); + $query->andWhere('network_phone_t.caller='.$caller); } if($called != ''){ - $query = $query->andWhere('network_phone_t.called='.$called); + $query->andWhere('network_phone_t.called='.$called); } if($duration_begin != ''){ - $query = $query->andWhere('network_phone_t.call_duration>='.$duration_begin); + $query->andWhere('network_phone_t.call_duration>='.$duration_begin); } if($duration_end != ''){ - $query = $query->andWhere('network_phone_t.call_duration<='.$duration_end); + $query->andWhere('network_phone_t.call_duration<='.$duration_end); } if($call_result != ''){ - $query = $query->andWhere('network_phone_t.call_result="'.$call_result.'"'); + $query->andWhere('network_phone_t.call_result="'.$call_result.'"'); } if($is_called == 1){ - $query = $query->andWhere('network_phone_t.is_called=1'); + $query->andWhere('network_phone_t.is_called=1'); }elseif ($is_called ==2){ - $query = $query->andWhere('network_phone_t.is_called=0 or network_phone_t.is_called is null'); + $query->andWhere('network_phone_t.is_called=0 or network_phone_t.is_called is null'); } if($username != ''){ - $query = $query->andWhere('user_t.username="'.$username.'"'); + $query->andWhere('user_t.username="'.$username.'"'); } - if($company_id > 0) { - $query = $query->andWhere('user_t.company_id='.$company_id); + $query->andWhere('user_t.company_id='.$company_id); } - - - $company_items = CompanyT::find()->all(); - - $total = $query->count(); - $pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]); - $pagination->setPage($page-1); - - $query = $query->offset($pagination->offset)->limit($pagination->limit); - - - $page_info = MyLib::getPageInfo($pagination); + $query->offset($offset)->limit($limit); $record_items = $query->orderBy('network_phone_t.id desc') ->all(); - return $this->render('call-records',[ - 'record_items' => $record_items, - 'begin_time' => $begin_time, - 'end_time' => $end_time, - 'is_called' => $is_called, - - 'username' => $username, - 'caller' => $caller, - 'called' => $called, - 'duration_begin' => $duration_begin, - 'duration_end' => $duration_end, - 'call_result' => $call_result, - 'page_info' => $page_info, - 'company_items'=>$company_items, - 'company_type'=>$company_type - ]); + $data = []; + $data['total'] = $total; + $data['rows'] = []; + foreach($record_items as $item) { + $row = $item->toArray(); + $row['username'] = $item->user ? $item->user->getShowName():''; + $row['call_duration'] = MyLib::HMSByTime($item->call_duration); + $row['call_result'] = MyLib::phoneCenterStatus($item->call_result); + $data['rows'][] = $row; + } + + return $data; } public function actionDownloadFile(){ @@ -237,33 +226,66 @@ public function actionDownload(){ } -public function actionAssignPhone(){ - $user_items = UserT::find()->orderBy('username')->all(); + public function actionAssignPhone(){ + return $this->render('assign-phone'); + } + + public function actionAssignPhoneJson(){ + Yii::$app->response->format = Response::FORMAT_JSON; + $request = Yii::$app->request; + $offset = $request->get('offset',0); + $limit = $request->get('limit', 10); - $phone_items = NetworkPhoneAssignT::find() - ->leftJoin('user_t','user_t.id=network_phone_assign_t.user_id') - ->orderBy('user_t.username') - ->all(); + $user_items = UserT::find()->orderBy('username')->all(); - return $this->render('assign-phone',[ - 'user_items' => $user_items, - 'phone_items' => $phone_items - ]); -} + $phone_items = NetworkPhoneAssignT::find() + ->leftJoin('user_t','user_t.id=network_phone_assign_t.user_id') + ->orderBy('user_t.username') + ->all(); + + $data = []; + $data['total'] = count($phone_items); + $data['rows'] = []; + foreach($phone_items as $item) { + $row = $item->toArray(); + $row['username'] = $item->user->getShowName(); + $data['rows'][] = $row; + } + + return $data; + } public function actionSubIndex(){ $request = Yii::$app->request; - $id = $request->get('id',0); + $id = $request->get('phone_id',0); $assign_info = NetworkPhoneAssignT::findOne($id); - $sub_items = NetworkPhoneSubT::find()->where('assign_id='.$assign_info->id)->all(); return $this->render('sub-index',[ - 'assign_info' => $assign_info, - 'sub_items' => $sub_items + 'assign_info' => $assign_info ]); } + public function actionSubIndexJson(){ + Yii::$app->response->format = Response::FORMAT_JSON; + $request = Yii::$app->request; + $id = $request->get('phone_id',0); + $offset = $request->get('offset', 0); + $limit = $request->get('limit', 10); + + $assign_info = NetworkPhoneAssignT::findOne($id); + $sub_items = NetworkPhoneSubT::find()->where('assign_id='.$assign_info->id)->all(); + + $data = []; + $data['total'] = count($sub_items); + $data['rows'] = []; + foreach($sub_items as $item) { + $row = $item->toArray(); + $data['rows'][] = $row; + } + + return $data; + } public function actionEdit() { @@ -328,16 +350,18 @@ public function actionAssignPhone(){ } $row->user_id = $user_id; $row->phone = $phone; - $row->save(); - + if(!$row->save()) { + throw new \Exception(print_r($row->getErrors(), true)); + } $tran->commit(); + + $result['success'] = true; + $result['msg'] = '保存成功'; + } catch(\Exception $e) { $tran->rollBack(); - throw $e; + $result['msg'] = $e->getMessage(); } - - $result['success'] = true; - $result['msg'] = '保存成功'; } return $result; } @@ -485,9 +509,11 @@ public function actionAssignPhone(){ return $result; } - - public function actionUsercallIndex(){ - + public function actionUsercallIndex() { + return $this->render('usercall-index'); + } + public function actionUsercallIndexJson(){ + Yii::$app->response->format = Response::FORMAT_JSON; set_time_limit(0); ini_set('memory_limit', '3072M'); @@ -497,8 +523,8 @@ public function actionAssignPhone(){ $caller = $request->get('caller',''); $company_id = $request->get('company_id',0); $company_type = $request->get('company_type',0);//0显示全部,1只显示江西,2只显示湖北,3只显示个人 - - $page = $request->get('page', 1); + $offset = $request->get('offset', 0); + $limit = $request->get('limit', 10); $user_id = 0; @@ -513,17 +539,17 @@ public function actionAssignPhone(){ if($company_type == 3){ - $query = $query->andWhere('user_t.id="'.$this->my->id.'"'); + $query->andWhere('user_t.id="'.$this->my->id.'"'); } if($caller != ''){ - $query = $query->andWhere('user_t.username="'.$caller.'"'); + $query->andWhere('user_t.username="'.$caller.'"'); } if($company_id > 0) { - $query = $query->andWhere('user_t.company_id='.$company_id); + $query->andWhere('user_t.company_id='.$company_id); } - $query = $query->andWhere('user_t.is_delete=0 and user_t.is_leave=0')->orderBy('user_t.username'); + $query->andWhere('user_t.is_delete=0 and user_t.is_leave=0')->orderBy('user_t.username'); if($caller != ''){ $query1 = clone $query; @@ -545,28 +571,19 @@ public function actionAssignPhone(){ // dd($items); // die; - $pagination = new Pagination(['totalCount' => $total, 'pageSize' => 20]); - $pagination->setPage($page - 1); - - $query = $query->offset($pagination->offset)->limit($pagination->limit); + $query = $query->offset($offset)->limit($limit); $items = $query->all(); - $page_info = MyLib::getPageInfo($pagination); - $company_items = CompanyT::find()->all(); + $data = []; + $data['total'] = $total; + $data['rows'] = []; + foreach($items as $item) { + $row = $item->toArray(); + $data['rows'][] = $row; + } - return $this->render('usercall-index',[ - 'items' => $items, - 'begin_date' => $begin_date, - 'end_date' => $end_date, - 'caller' => $caller, - 'company_items'=>$company_items, - 'company_id'=>$company_id, - 'company_type'=>$company_type, - 'page_info'=>$page_info, - 'page'=>$page, - 'user_id'=>$user_id - ]); + return $data; } public function actionUsercallIndexbak(){ diff --git a/frontend/views/common/call-phone.php b/frontend/views/common/call-phone.php new file mode 100644 index 0000000..9c9f092 --- /dev/null +++ b/frontend/views/common/call-phone.php @@ -0,0 +1,335 @@ + +beginBlock('header_css'); ?> + +endBlock(); ?> + +
+ + + +人员名称 | -电话号码 | -操作 | -
序号 | -坐席人员 | -通话时间 | -主叫真实号码 | -被叫真实号码 | -主叫分配号码 | -被叫分配号码 | -通话时长 | -通话状态 | -语音 | -
- |
- - | -
- - - - | -
- - - - | -
人员名称 | -- =$assign_info->user->getShowName()?> - | -|
电话 | -- =$assign_info->phone?> - | -|
- | ||
小号 | -- [添加] - | -|
=$k+1?> | -- =$item->phone?> [绑定] +beginBlock('header_css'); ?> + +endBlock(); ?> - | -- [修改] - [删除] - | -
+ - - | -
- 发送报文:
-
- 接收报文:
-
-
- - - - - -
- - - - - - - -备注:status:0挂机,1来电,2呼叫,3接通 -挂机状态时,number号码为空。
-- - - - - - - -
-- - - - -
-- 备注:声音范围 1~100。 -
-- - - - -
-- 备注:0 关闭耳机模式,1 开耳机模式。 -
- -- - - - -
- -- 备注:0 关闭远端播放,1 开启远端播放。 -
-- - - - url: - 坐席工号: - 计费账号: - 本机号码: - -
- - + +beginBlock('header_css'); ?> + +endBlock(); ?> + +ID | +工号 | +姓名 | +通话数量 | +呼出时长 | +通话时长 | +呼入次数 | +成功呼入 | +呼入接通率 | +呼出次数 | +成功呼出 | +呼出接通率 | +通话状态 | +
---|