140 lines
4.4 KiB
PHP
140 lines
4.4 KiB
PHP
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
use chillerlan\QRCode\Data\QRMatrix;
|
|
use chillerlan\QRCode\QRCode;
|
|
use chillerlan\QRCode\QROptions;
|
|
|
|
date_default_timezone_set('Asia/Kolkata');
|
|
|
|
/**
|
|
* AMS
|
|
*
|
|
* @package HMVC
|
|
* @author Venba
|
|
* @copyright 2022 Venba
|
|
* @license https://venbainfotech.com/licenses/MIT MIT License
|
|
* @link <URI> (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);
|
|
}
|
|
|
|
|
|
$this->session->set_flashdata('Success', 'Delegation Assigned Successfully');
|
|
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);
|
|
$this->session->set_flashdata('Success', 'Delegation Updated Successfully');
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
}
|