136 lines
4.8 KiB
PHP
Executable File

<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Website_notification extends MX_Controller {
function __construct() {
parent::__construct();
$this->load->model('Website_messages_model');
//$this->load->model('caregivers/Caregiver_model');
// if (!$this->ion_auth->in_group(array('admin','Coordinator'))) {
// redirect('home/permission');
// }
}
public function index() {
$this->load->view('home/dashboard'); // just the header file
$this->load->view('list');
$this->load->view('home/master_assets');
$this->load->view('home/footer'); // just the header file
}
public function expireNotificationCreate($type){
$today=date('Y-m-d');
$expdate=date('Y-m-d', strtotime($today . ' +30 day'));
$notificationTo=$this->notification_model->getAllCoordinator();
$expireDateList=$this->notification_model->getCaregiverExpireDocs($expdate);
foreach ($expireDateList as $expire) {
//pre($expire);
$doc_name=$this->getDocumentsName($expire->doc_name);
$for['type']='Caregiver';
$for['id']=$expire->caregiver_id;
$data['notification_text']=$doc_name.' Expire on '.$expire->ExpirationDate;
$data['notification_heading']='Caregiver Document Expire';
$data['notification_for']=json_encode($for);
$data['status']='1';
if($type=='Notification'){
//FOR Corordinator
foreach ($notificationTo as $noti) {
$data['To_ionId']=$noti->ion_user_id;
$this->notification_model->createNotification($data);
//pre($data);
}
//For Admin
$data['To_ionId']=1;
$this->notification_model->createNotification($data);
}
}
//echo $expdate;
}
function getDocumentsName($docCode){
if($docCode=='SFI'){ $output='State or Federal Issued ID'; }
else if($docCode=='malpractice_policy'){ $output='Malpractice Insurance Policy'; }
else if($docCode=='rn_license'){ $output='RN License'; }
else { $output=$docCode; }
return $output;
}
public function getList()
{
$requestData = $_REQUEST;
$start = $requestData['start'];
$limit = $requestData['length'];
$orderColumn=$requestData['order'][0]['column'];
$orderType=$requestData['order'][0]['dir'];
$search = $this->input->post('search')['value'];
$user_id=$this->session->userdata('user_id');
if (!empty($search)) {
$data['name'] = $this->Website_messages_model->getNameByLimitBySearch($limit, $start, $search,$orderColumn, $orderType);
} else {
$data['name'] = $this->Website_messages_model->getNameByLimit($limit, $start, $orderColumn, $orderType);
}
//pre($data['name']);die;
$listCount = sizeof($data['name']);
foreach ($data['name'] as $data) {
static $slno = 1;
$statusChk = '';
$for = '';
if($data->status == "0"){
$statusChk = '';
}else{
$statusChk = 'checked';
}
$switch = '<div class="material-switch ">
<input id="someSwitchOptionSuccess'.$slno.'" attrid="'.$data->id.'" class="switchValue" name="someSwitchOption001" value="'.$data->status.'" onclick="changeStatus(this)" type="checkbox" '.$statusChk.' />
<label for="someSwitchOptionSuccess'.$slno.'" class="label-success"></label>
</div>';
$info[] = array(
$slno,
$data->name,
$data->email,
$data->subject,
$data->message,
$switch,
//$options1 . ' ' . $options2
);
$slno++;
}
$csrf_name = $this->security->get_csrf_token_name();
$csrf_hash = $this->security->get_csrf_hash();
if ($listCount > 0) {
$output = array(
"draw" => intval($requestData['draw']),
"recordsTotal" => $listCount,
"recordsFiltered" => $listCount,
"data" => $info
);
}
else {
$output = array(
// "draw" => 1,
"recordsTotal" => 0,
"recordsFiltered" => 0,
"data" => []
);
$output[$csrf_name] = $csrf_hash;
}
echo json_encode($output);
}
public function statusChange(){
//pre($_POST);die;
$res = $this->Website_messages_model->status_change($_POST);
echo $res;
}
}