(description) * @version GIT: $Id$ * @since Version 0.0.1 * @filesource * */ class Delegation extends Admin_Controller { /** * [__construct description] * * @method __construct */ public function __construct() { // To inherit directly the attributes of the parent class. parent::__construct(); ### Syntax : $this->load->model('Model Path' , 'Alias name'); ### The second parameter (optional) is used to call the method. $this->load->model('MY_Model','MY_Model'); $this->load->model('Delegation_model','Delegation_model'); $this->load->model('Employee/Employee_model','Emp_model'); $this->load->model('Audit/Audit_model','audit_model'); $this->load->helper(array('form', 'url')); } public function Delegation_form() { $business_id = user()->business_id; $Employee_list = $this->Delegation_model->Employee_list_by_business_id($business_id); $this->layout->set('emp', $Employee_list); $this->layout->buffer('main_content', 'Delegation/delegation_form'); $this->layout->render('Employee_Layout'); } public function Assign_Delecation() { $data = $this->input->post(); $data['business_id'] = user()->business_id; $data['is_active'] = 1; $data['from_date'] = date('Y-m-d', strtotime($this->input->post('from_date'))); $data['to_date'] = date('Y-m-d', strtotime($this->input->post('to_date'))); $table="delegation"; $Delecation_id = $this->MY_Model->insert($data, $table); if($Delecation_id){ $code = 'ASSIGN_DELEGATION'; $type = 'Email'; $this->notification->sendNotificationForDelegation($Delecation_id, $code, $type); } if($Delecation_id){ $this->session->set_flashdata('FlashMsg', ''); }else{ $this->session->set_flashdata('FlashMsg', ''); } redirect('Delegation/Delegation_list'); } public function Edit_Delegation() { $id = $this->input->get('id'); $business_id = user()->business_id; $Employee_list = $this->Delegation_model->Employee_list_by_business_id($business_id); $Delegation_list_Row = $this->Delegation_model->Delegation_list_by_id($id); $this->layout->set('emp', $Employee_list); $this->layout->set('Delegation_list', $Delegation_list_Row); $this->layout->buffer('main_content', 'Delegation/edit_delegation_form'); $this->layout->render('Employee_Layout'); } public function Edit_Create_Delecation() { $action = $this->input->post(); unset($action['id']); $id = $this->input->post('id'); $action['business_id'] = user()->business_id; $action['is_active'] = 1; $action['from_date'] = date('Y-m-d', strtotime($this->input->post('from_date'))); $action['to_date'] = date('Y-m-d', strtotime($this->input->post('to_date'))); $table="delegation"; $Delecation = $this->MY_Model->edit_option($action, $id, $table); if($Delecation){ $this->session->set_flashdata('FlashMsg', ''); }else{ $this->session->set_flashdata('FlashMsg', ''); } redirect('Delegation/Delegation_list'); } public function Delegation_list() { $business_id = user()->business_id; $Delegation_list = $this->Delegation_model->Get_Delegation_list($business_id); $get_emp_id = null; if (!empty($get_delegation)) { $get_emp_id = array_shift($Delegation_list)->delegated_to; } $get_emp_name = $this->Delegation_model->Get_emp_name_list($get_emp_id, $business_id); $this->layout->set('tableData', $Delegation_list); $this->layout->set('empname', $get_emp_name); $this->layout->buffer('main_content', 'Delegation/delegation_list'); $this->layout->render('Employee_Layout'); } public function checkUniqueValue() { $data = $this->input->get('emp_id'); $table = 'delegation'; $where = 'delegated_to'; $result = $this->Delegation_model->checkUniqueValueInDataBase($table, $where, $data); if(count($result)){ $this->output->set_output(true); }else{ $this->output->set_output(false); } } }