|
@@ -11,6 +11,7 @@ class Alarm extends Base_Controller {
|
|
|
$this->load->model('Lamp_model');
|
|
|
$this->load->model('Patrol_model');
|
|
|
$this->load->model('Repair_model');
|
|
|
+ $this->load->model('AlarmSendUserInfo_model');
|
|
|
}
|
|
|
|
|
|
// 获取告警信息列表
|
|
@@ -392,4 +393,119 @@ class Alarm extends Base_Controller {
|
|
|
}
|
|
|
exit(json_result('0000',$this->response['0000'],array('list'=>$repair_list,'total'=>ceil($total/$count))));
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ // 添加编辑推送人员
|
|
|
+ public function save_alarm_send_user(){
|
|
|
+ $id = intval($this->input->post('id',true));
|
|
|
+ $userId = $this->get_user_info('id');
|
|
|
+
|
|
|
+ $name = $this->input->post('name',true);
|
|
|
+ $email = $this->input->post('email',true);
|
|
|
+ $phone = $this->input->post('phone',true);
|
|
|
+
|
|
|
+ $project = $this->input->post('project',true);
|
|
|
+
|
|
|
+ if ($phone === '' || $phone === null) exit(json_result('0607',$this->response['0607']));
|
|
|
+ if ($email === '' || $email === null) exit(json_result('0618',$this->response['0618']));
|
|
|
+
|
|
|
+ $config = array();
|
|
|
+ // $config[] = array(
|
|
|
+ // 'field' => 'phone',
|
|
|
+ // 'label' => 'Phone',
|
|
|
+ // 'rules' => 'required|numeric|exact_length[11]',
|
|
|
+ // 'errors' => array(
|
|
|
+ // 'numeric' => '0406',
|
|
|
+ // 'exact_length' => '0406',
|
|
|
+ // )
|
|
|
+ // );
|
|
|
+
|
|
|
+ $config[] = array(
|
|
|
+ 'field' => 'email',
|
|
|
+ 'label' => 'Email',
|
|
|
+ 'rules' => 'required|valid_email',
|
|
|
+ 'errors' => array(
|
|
|
+ 'valid_email' => '0719',
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $this->load->library('form_validation');
|
|
|
+ $this->form_validation->set_rules($config);
|
|
|
+ if ($this->form_validation->run() == FALSE){
|
|
|
+ $errors = $this->form_validation->error_array();
|
|
|
+ exit(json_result(current($errors),$this->response[current($errors)]));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($id)) {
|
|
|
+ if ($this->AlarmSendUserInfo_model->getDataCount(['email'=>$email])) exit(json_result('0722',$this->response['0722']));
|
|
|
+ if ($this->AlarmSendUserInfo_model->getDataCount(['phone'=>$phone])) exit(json_result('0721',$this->response['0721']));
|
|
|
+ if ($this->AlarmSendUserInfo_model->getDataCount(['name'=>$name,'userId'=>$userId])) exit(json_result('0619',$this->response['0619']));
|
|
|
+
|
|
|
+ $data = array('name'=>$name,'email'=>$email,'phone'=>$phone,'project'=>$project,'userId'=>$userId);
|
|
|
+ $data['createTime'] = date('Y-m-d H:i:s',time());
|
|
|
+
|
|
|
+ $this->AlarmSendUserInfo_model->add($data);
|
|
|
+ }else{
|
|
|
+ if ($this->AlarmSendUserInfo_model->getDataCount(['email'=>$email],$id)) exit(json_result('0722',$this->response['0722']));
|
|
|
+ if ($this->AlarmSendUserInfo_model->getDataCount(['phone'=>$phone],$id)) exit(json_result('0721',$this->response['0721']));
|
|
|
+ if ($this->AlarmSendUserInfo_model->getDataCount(['name'=>$name,'userId'=>$userId],$id)) exit(json_result('0619',$this->response['0619']));
|
|
|
+
|
|
|
+ $data = array('name'=>$name,'email'=>$email,'phone'=>$phone,'project'=>$project,'userId'=>$userId);
|
|
|
+
|
|
|
+ $this->AlarmSendUserInfo_model->update($data,['id'=>$id]);
|
|
|
+ }
|
|
|
+ exit(json_result('0000',$this->response['0000']));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 推送人员列表
|
|
|
+ public function alarm_send_user_list(){
|
|
|
+ $userId = $this->get_user_info('id');
|
|
|
+
|
|
|
+ $where = ['userId'=>$userId];
|
|
|
+
|
|
|
+ $page = intval($this->input->post('page'));
|
|
|
+ $count = intval($this->input->post('count'));
|
|
|
+ $page = empty($page) ? 1 : $page;
|
|
|
+
|
|
|
+ $limit = empty($count) ? 10 : $count;
|
|
|
+ $offset = ($page - 1) * $limit;
|
|
|
+
|
|
|
+ $list = $this->AlarmSendUserInfo_model->get_list($where, 'id,name,email,project,phone,is_send',$limit, $offset, 'convert(name using gbk) asc,id desc', NUll);
|
|
|
+ $total = $this->AlarmSendUserInfo_model->get_count($where);
|
|
|
+
|
|
|
+ exit(json_result('0000',$this->response['0000'],['list'=>$list,'total'=>$total]));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除推送人员
|
|
|
+ public function del_alarm_send_user(){
|
|
|
+ $id = $this->input->post('id',true);
|
|
|
+ if ($id === '' || $id === null) exit(json_result('0007',$this->response['0007']));
|
|
|
+
|
|
|
+ $idArr = explode(',', $id);
|
|
|
+ foreach ($idArr as $id) {
|
|
|
+ $this->AlarmSendUserInfo_model->delete(['id'=>$id]);
|
|
|
+ }
|
|
|
+ exit(json_result('0000',$this->response['0000']));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是否开启推送
|
|
|
+ public function set_alarm_send_user_status(){
|
|
|
+ $id = intval($this->input->post('id',true));
|
|
|
+ $status = intval($this->input->post('status',true));
|
|
|
+
|
|
|
+ if (empty($id)) exit(json_result('0007',$this->response['0007']));
|
|
|
+
|
|
|
+ $is_send = empty($status) ? 0 : 1;
|
|
|
+
|
|
|
+ $this->AlarmSendUserInfo_model->update(['is_send'=>$is_send],['id'=>$id]);
|
|
|
+ exit(json_result('0000',$this->response['0000']));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|