260 lines
8.1 KiB
PHP
260 lines
8.1 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 Expence 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('Expence_model','Expence_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 expence_form()
|
|
{
|
|
|
|
$this->layout->buffer('main_content', 'Expence/expence_form');
|
|
$this->layout->render('Employee_Layout');
|
|
}
|
|
|
|
public function get_emp_name()
|
|
{
|
|
$emp = $this->Expence_model->get_employee_name(user()->business_id);
|
|
$html = '<option>--select Employee--</option>';
|
|
foreach($emp as $val)
|
|
{
|
|
if($val->user_id != user()->id)
|
|
{
|
|
$html .='<option id="'.$val->manager.'" value="'.$val->user_id.'">'.$val->name.'</option>';
|
|
}
|
|
}
|
|
echo json_encode($html);
|
|
}
|
|
|
|
public function rise_expence_request()
|
|
{
|
|
$data = $this->input->post();
|
|
unset($data['bill']);
|
|
|
|
|
|
//file upload confic
|
|
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
|
|
$config['allowed_types'] = 'gif|jpg|png|jpeg|pdf';
|
|
$config['file_name'] = time();
|
|
$config['max_size'] = 80000;
|
|
//upload
|
|
$this->load->library('upload', $config);
|
|
$this->upload->initialize($config);
|
|
$this->upload->do_upload('bill');
|
|
if ( ! $this->upload->do_upload('bill'))
|
|
{
|
|
$error = array('error' => $this->upload->display_errors());
|
|
//print_r($error);
|
|
|
|
} else{
|
|
$upload_image = $this->upload->data();
|
|
$data['bill'] = $upload_image['file_name'];
|
|
|
|
}
|
|
|
|
|
|
if(isset($data['emp_id'])){
|
|
$emp_id =$this->input->post('emp_id');
|
|
}else{
|
|
$emp_id = user()->id;
|
|
}
|
|
$data['emp_id'] = $emp_id;
|
|
|
|
if($data['manager']){
|
|
$manager = $this->input->post('manager');
|
|
}else{
|
|
$manager = employee()->manager;
|
|
}
|
|
$data['manager'] = $manager;
|
|
$data['business_id'] = user()->business_id;
|
|
$data['status'] = 'pending';
|
|
$data['created_date'] = date('d-m-Y');
|
|
$data['created_time'] = date('H:i A');
|
|
$data['is_active'] = 1;
|
|
|
|
|
|
$table="expence_list";
|
|
$create_leave = $this->MY_Model->insert($data,$table);
|
|
|
|
$this->session->set_flashdata('Create', 'Claim Request Rised Successfully');
|
|
redirect('Expence/Emp_Expence_List');
|
|
}
|
|
|
|
|
|
public function edit_expence()
|
|
{
|
|
$id = $this->input->get('id');
|
|
$get_expence = $this->Expence_model->get_expence_list_by_id($id);
|
|
$this->layout->set('get_expence', $get_expence);
|
|
$this->layout->buffer('main_content', 'Expence/edit_expence');
|
|
$this->layout->render('Employee_Layout');
|
|
}
|
|
|
|
|
|
public function edit_rise_expence_request()
|
|
{
|
|
|
|
$action = $this->input->post();
|
|
unset($action['bill']);
|
|
unset($action['id']);
|
|
$id = $this->input->post('id');
|
|
|
|
|
|
//file upload confic
|
|
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
|
|
$config['allowed_types'] = 'gif|jpg|png|jpeg|pdf';
|
|
$config['file_name'] = time();
|
|
$config['max_size'] = 80000;
|
|
//upload
|
|
$this->load->library('upload', $config);
|
|
$this->upload->initialize($config);
|
|
$this->upload->do_upload('bill');
|
|
if ( ! $this->upload->do_upload('bill'))
|
|
{
|
|
$error = array('error' => $this->upload->display_errors());
|
|
//print_r($error);
|
|
|
|
} else{
|
|
$upload_image = $this->upload->data();
|
|
$action['bill'] = $upload_image['file_name'];
|
|
|
|
}
|
|
|
|
|
|
if(isset($data['emp_id'])){
|
|
$emp_id =$this->input->post('emp_id');
|
|
}else{
|
|
$emp_id = user()->id;
|
|
}
|
|
$action['emp_id'] = $emp_id;
|
|
$action['business_id'] = user()->business_id;
|
|
$action['status'] = 'pending';
|
|
$action['updated_at'] = date('d-m-Y H:i:s');
|
|
$action['updated_by'] = user()->id;
|
|
$action['is_active'] = 1;
|
|
|
|
$table="expence_list";
|
|
$create_leave = $this->MY_Model->edit_option($action, $id, $table);
|
|
$this->session->set_flashdata('update', 'Claim Request Updated Successfully');
|
|
redirect('Expence/Emp_Expence_List');
|
|
|
|
}
|
|
|
|
|
|
public function expence_list()
|
|
{
|
|
$business_id = user()->business_id;
|
|
$expence_list = $this->Expence_model->get_expence_list($business_id);
|
|
$this->layout->set('tableData', $expence_list);
|
|
$this->layout->buffer('main_content', 'Expence/expence_list');
|
|
$this->layout->render('Employee_Layout');
|
|
}
|
|
|
|
|
|
public function Approve_Expence()
|
|
{
|
|
$id=$this->input->get('id');
|
|
$action['status'] = 'Approved';
|
|
$action['approved_by']= user()->name;
|
|
$action['approved_at'] = date('d-m-Y H:i:s');
|
|
$table = "expence_list";
|
|
$this->MY_Model->edit_option($action, $id, $table);
|
|
$this->session->set_flashdata('approve', 'Claim Request Approved');
|
|
redirect('Expence/expence_list');
|
|
}
|
|
|
|
public function manager_approvel_list()
|
|
{
|
|
$business_id = user()->business_id;
|
|
$user_id = user()->id;
|
|
$expence_list = $this->Expence_model->get_expence_list($business_id);
|
|
$get_delegation = $this->Expence_model->Get_delegation_id($business_id);
|
|
//print_r($expence_list); die();
|
|
$this->layout->set('get_delegation', $get_delegation);
|
|
$this->layout->set('tableData', $expence_list);
|
|
$this->layout->buffer('main_content', 'Expence/expence_manager_approvel');
|
|
$this->layout->render('Employee_Layout');
|
|
}
|
|
|
|
public function Manager_Approvel()
|
|
{
|
|
$id=$this->input->get('id');
|
|
$action['status'] = 'Approved';
|
|
$action['approved_by']= user()->name;
|
|
$action['approved_at'] = date('d-m-Y H:i:s');
|
|
$table = "expence_list";
|
|
$this->MY_Model->edit_option($action, $id, $table);
|
|
$this->session->set_flashdata('manager_approve', 'Claim Request Approved');
|
|
redirect('Expence/manager_approvel_list');
|
|
}
|
|
|
|
public function Emp_Expence_List()
|
|
{
|
|
$Emp_Expence_List = $this->Expence_model->get_expence_list(user()->business_id);
|
|
$this->layout->set('tableData', $Emp_Expence_List);
|
|
$this->layout->buffer('main_content', 'Expence/emp_expence_list');
|
|
$this->layout->render('Employee_Layout');
|
|
}
|
|
|
|
|
|
|
|
public function Decline_expence()
|
|
{
|
|
$id=$this->input->get('id');
|
|
$data['status'] = 'Declined';
|
|
$data['declined_at'] = date('d-m-Y H:i:s');
|
|
$data['DReason'] = $this->input->get('reason');
|
|
$this->Expence_model->ExpenceDecline($id, $data);
|
|
return true;
|
|
}
|
|
|
|
public function cancled_expence()
|
|
{
|
|
$id=$this->input->get('id');
|
|
$data['status'] = 'canceled';
|
|
$data['canceled_at'] = date('d-m-Y H:i:s');
|
|
$this->Expence_model->Expencecancle($id, $data);
|
|
$this->session->set_flashdata('cancel', 'Claim Request Canceled.... ');
|
|
redirect('Expence/emp_expence_list');
|
|
}
|
|
|
|
|
|
|
|
}
|