Expense module new changes : venkateshwaran

This commit is contained in:
venkateswaran ubuntu 2023-08-07 15:21:59 +05:30
parent cf204da2b9
commit 4c81a196bb
63 changed files with 2105 additions and 750 deletions

2
.gitignore vendored
View File

@ -10,3 +10,5 @@ application/logs/*
!application/logs/.htaccess !application/logs/.htaccess
vendor vendor
assets/uploads assets/uploads
assets/uploads/Expence_Bill

View File

@ -9,9 +9,7 @@
</div> </div>
</div> </div>
<div class="clearfix"></div>
<div class="row"> <div class="row">
<div class="col-md-12 col-sm-12 ">
<div class="x_panel"> <div class="x_panel">
<div class="x_title"> <div class="x_title">
<div class="clearfix"></div> <div class="clearfix"></div>

View File

@ -96,7 +96,6 @@ public function add_employee_education()
public function add_employee_history() public function add_employee_history()
{ {
$id = $this->input->post('id'); $id = $this->input->post('id');
if ($id) { if ($id) {
$data = $this->input->post(); $data = $this->input->post();
@ -119,7 +118,7 @@ public function add_employee_history()
public function createEmp() public function createEmp()
{ {
//insert in users table //insert in users table
$data = array( $data = array(
'business_id' => user()->business_id, 'business_id' => user()->business_id,
@ -207,6 +206,9 @@ public function createEmp()
} }
} }
if(!empty($this->input->post('group_id')))
{
if($create_user == true) if($create_user == true)
{ {
for($i=0;$i<count($this->input->post('group_id'));$i++) for($i=0;$i<count($this->input->post('group_id'));$i++)
@ -220,6 +222,8 @@ public function createEmp()
} }
} }
}
@ -290,6 +294,7 @@ public function editEmployee($id)
$empData = $this->Emp_model->get_emp_by_md5_id($id,user()->business_id); $empData = $this->Emp_model->get_emp_by_md5_id($id,user()->business_id);
$manager_name = $this->Emp_model->get_manager_name($empData->manager); $manager_name = $this->Emp_model->get_manager_name($empData->manager);
$manager = $this->Emp_model->get_employee(user()->business_id); $manager = $this->Emp_model->get_employee(user()->business_id);
$data = array( $data = array(
'submit_button_title' => 'update' , 'submit_button_title' => 'update' ,
@ -425,14 +430,18 @@ public function editEmployees()
} }
} }
else else
{ for($i=0;$i<count($this->input->post('group_id'));$i++) {
if(!empty($this->input->post('group_id')))
{
for($i=0;$i<count($this->input->post('group_id'));$i++)
{ {
$group['emp_id']=$this->input->post('user_id'); $group['emp_id']=$this->input->post('user_id');
$group['business_id']=user()->business_id; $group['business_id']=user()->business_id;
$group['group_id']=$this->input->post('group_id')[$i]; $group['group_id']=$this->input->post('group_id')[$i];
$group['is_active']=1; $group['is_active']=1;
$this->MY_Model->insert($group,'group_membership'); $this->MY_Model->insert($group,'group_membership');
} }
}
} }

View File

@ -1,4 +1,5 @@
<!-- Body page content --> <!-- Body page content -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
@ -207,11 +208,21 @@
<label class="control-label col-md-1 col-sm-1 " for="first-name"> Manager</label> <label class="control-label col-md-1 col-sm-1 " for="first-name"> Manager</label>
<div class="col-md-5 col-sm-5 "> <div class="col-md-5 col-sm-5 ">
<select id="manager" name="manager" class="form-control"> <select id="manager" name="manager" class="form-control">
<?php foreach ($manager_name as $key => $val) { ?>
<?php
if(isset($manager_name[0]->id))
{ foreach ($manager_name as $key => $val) { ?>
<option value="<?php echo $val->id; ?>"><?php echo $val->name; ?></option> <option value="<?php echo $val->id; ?>"><?php echo $val->name; ?></option>
<?php foreach ($manager as $key => $value) { ?> <?php foreach ($manager as $key => $value) { ?>
<?php if ($val->name !== $value->name) { ?> <?php if ($val->name !== $value->name) { ?>
<option value="<?php echo $value->user_id; ?>"><?php echo $value->name; ?></option> <option value="<?php echo $value->user_id; ?>"><?php echo $value->name; ?></option>
<?php } }?>
<?php } } else { ?>
<?php foreach ($manager as $key => $value) { ?>
<?php if ($val->name !== $value->name) { ?>
<option value="<?php echo $value->user_id; ?>"><?php echo $value->name; ?></option>
<?php } } } ?> <?php } } } ?>
</select> </select>
</div> </div>

View File

@ -41,14 +41,17 @@ public function __construct()
} }
public function expence_form() public function expence_form()
{ {
$id = $this->input->get('id');
$expense_data = $this->Expence_model->get_expense_data($id);
$expense_child_data = $this->Expence_model->get_expense_child_data($id);
$this->layout->set('expense_child_data', $expense_child_data);
$this->layout->buffer('main_content', 'Expence/expence_form'); $this->layout->buffer('main_content', 'Expence/expence_form');
$this->layout->render('Employee_Layout'); $this->layout->render('Employee_Layout');
} }
public function get_emp_name() public function get_emp_name()
{ {
$emp = $this->Expence_model->get_employee_name(user()->business_id); $emp = $this->Expence_model->get_employee_name(user()->business_id);
$html = '<option>--select Employee--</option>'; $html = '<option>--select Employee--</option>';
@ -63,75 +66,90 @@ public function get_emp_name()
} }
public function rise_expence_request() public function rise_expence_request()
{ {
$data = $this->input->post();
unset($data['bill']);
$data = $this->input->post('emp_id');
//file upload confic if(!empty($data)){
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
$config['allowed_types'] = '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'); $emp_id =$this->input->post('emp_id');
}else{ }else{
$emp_id = user()->id; $emp_id = user()->id;
} }
$data['emp_id'] = $emp_id; $get_manager_id = $this->Expence_model->get_manager_id($emp_id);
if($data['manager']==""){ if($get_manager_id[0]->manager == null){
if(employee()->manager == null)
{ $manager = 0;
$manager = 0;
}
else
{
$manager = employee()->manager;
}
}else{ }else{
$manager = $this->input->post('manager'); $manager = $get_manager_id[0]->manager;
} }
$data['manager'] = $manager;
$data['business_id'] = user()->business_id; $data1 = array(
$data['status'] = 'pending'; 'created_by'=>user()->id,
$data['created_date'] = date('d-m-Y'); 'requested_for'=>$emp_id ,
$data['created_time'] = date('H:i A'); 'expense_name'=>$this->input->post('expense_name'),
$data['is_active'] = 1; 'business_reason'=>$this->input->post('business_reason'),
'manager_id' => $manager,
'business_id' => user()->business_id,
$table="expence_list"; 'status'=>'Draft',
$create_leave = $this->MY_Model->insert($data,$table); );
$table="expense";
$create_Expence = $this->MY_Model->insert($data1,$table);
$count = count($this->input->post('date_of_expence'));
for($i=0;$i<$count;$i++)
{
$data2 = array(
'expense_id' => $create_Expence,
'emp_id'=>$emp_id ,
'business_id' => user()->business_id,
'manager_id' => $manager,
'status' => 'Draft',
'date_of_expense'=> $this->input->post('date_of_expence')[$i],
'amount' => $this->input->post('amount')[$i],
'description' => $this->input->post('description')[$i],
);
$this->load->library('upload');
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
$config['allowed_types'] = 'jpg|png|jpeg|pdf';
$config['max_size'] = 80000;
$config['file_name'] = time(). '_' . $_FILES['bill']['name'][$i];
$_FILES['userfile']['name'] = $_FILES['bill']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['bill']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['bill']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['bill']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['bill']['size'][$i];
$this->upload->initialize($config);
if ($this->upload->do_upload('userfile'))
{
$upload_image = $this->upload->data();
$data2['bill'] = $upload_image['file_name'];
}
else
{
$error = $this->upload->display_errors();
}
$table="expense_child";
$create_expence_list = $this->MY_Model->insert($data2,$table);
}
$this->session->set_flashdata('Create', '1'); $this->session->set_flashdata('Create', '1');
redirect('Expence/Emp_Expence_List'); redirect('Expence/Emp_Expence_List');
} }
public function edit_expence() public function edit_expence($id)
{ {
$id = $this->input->get('id'); $expense_data = $this->Expence_model->get_expense_data($id);
$get_expence = $this->Expence_model->get_expence_list_by_id($id); $expense_child_data = $this->Expence_model->get_expense_child_data($id);
$this->layout->set('get_expence', $get_expence); $this->layout->set('expense_data', $expense_data);
$this->layout->set('expense_child_data', $expense_child_data);
$this->layout->buffer('main_content', 'Expence/edit_expence'); $this->layout->buffer('main_content', 'Expence/edit_expence');
$this->layout->render('Employee_Layout'); $this->layout->render('Employee_Layout');
} }
@ -139,63 +157,175 @@ public function edit_expence()
public function edit_rise_expence_request() public function edit_rise_expence_request()
{ {
$id = $this->input->post('expense_pid');
$action = $this->input->post(); $data = $this->input->post('emp_id');
unset($action['bill']); if(!empty($data)){
unset($action['id']);
$id = $this->input->post('id');
//file upload confic
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
$config['allowed_types'] = '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'); $emp_id =$this->input->post('emp_id');
}else{ }else{
$emp_id = user()->id; $emp_id = user()->id;
}
$get_manager_id = $this->Expence_model->get_manager_id($emp_id);
if($get_manager_id[0]->manager == null){
$manager = 0;
}else{
$manager = $get_manager_id[0]->manager;
} }
$action['emp_id'] = $emp_id;
$action['business_id'] = user()->business_id;
$action['status'] = 'pending'; $data1 = array(
$action['updated_at'] = date('d-m-Y H:i:s'); 'created_by'=>user()->id,
$action['updated_by'] = user()->id; 'requested_for'=>$emp_id ,
$action['is_active'] = 1; 'expense_name'=>$this->input->post('expense_name'),
'business_reason'=>$this->input->post('business_reason'),
$table="expence_list"; 'manager_id' => $manager,
$create_leave = $this->MY_Model->edit_option($action, $id, $table); 'business_id' => user()->business_id,
$this->session->set_flashdata('update', 'Claim Request Updated Successfully'); 'status'=>'Draft',
redirect('Expence/Emp_Expence_List'); );
$table="expense";
$create_Expence = $this->MY_Model->edit_option($data1, $id, $table);
$count = count($this->input->post('date_of_expence'));
for($i=0;$i<$count;$i++)
{
$expense_child_id = $this->input->post('expense_child_id')[$i];
$data2 = array(
'date_of_expense'=> $this->input->post('date_of_expence')[$i],
'amount' => $this->input->post('amount')[$i],
'description' => $this->input->post('description')[$i],
);
$this->load->library('upload');
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
$config['allowed_types'] = 'jpg|png|jpeg|pdf';
$config['max_size'] = 80000;
$config['file_name'] = time(). '_' . $_FILES['bill']['name'][$i];
$_FILES['userfile']['name'] = $_FILES['bill']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['bill']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['bill']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['bill']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['bill']['size'][$i];
$this->upload->initialize($config);
if ($this->upload->do_upload('userfile'))
{
$upload_image = $this->upload->data();
$data2['bill'] = $upload_image['file_name'];
}
else
{
$error = $this->upload->display_errors();
}
$table="expense_child";
$update_expence_list = $this->MY_Model->edit_option($data2, $expense_child_id, $table);
}
if($this->input->post('date_of_expence2'))
{
$count = count($this->input->post('date_of_expence2'));
for($i=0;$i<$count;$i++)
{
$data2 = array(
'expense_id' => $this->input->post('expense_pid'),
'emp_id'=>$emp_id ,
'business_id' => user()->business_id,
'manager_id' => $manager,
'status' => 'Draft',
'date_of_expense'=> $this->input->post('date_of_expence2')[$i],
'amount' => $this->input->post('amount2')[$i],
'description' => $this->input->post('description2')[$i],
);
$this->load->library('upload');
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
$config['allowed_types'] = 'jpg|png|jpeg|pdf';
$config['max_size'] = 80000;
$config['file_name'] = time(). '_' . $_FILES['bill2']['name'][$i];
$_FILES['userfile']['name'] = $_FILES['bill2']['name'][$i];
$_FILES['userfile']['type'] = $_FILES['bill2']['type'][$i];
$_FILES['userfile']['tmp_name'] = $_FILES['bill2']['tmp_name'][$i];
$_FILES['userfile']['error'] = $_FILES['bill2']['error'][$i];
$_FILES['userfile']['size'] = $_FILES['bill2']['size'][$i];
$this->upload->initialize($config);
if ($this->upload->do_upload('userfile'))
{
$upload_image = $this->upload->data();
$data2['bill'] = $upload_image['file_name'];
}
else
{
$error = $this->upload->display_errors();
}
$table="expense_child";
$create_expence_list = $this->MY_Model->insert($data2,$table);
//print_r($this->db->last_query()); die;
}
}
redirect('Expence/Emp_Expence_List');
} }
public function expence_list() public function expence_list()
{ {
$business_id = user()->business_id; $business_id = user()->business_id;
$expence_list = $this->Expence_model->get_expence_list($business_id); $expence_list = $this->Expence_model->get_expence_list($business_id);
$get_count_amount = $this->Expence_model->get_count_amount();
$this->layout->set('count_amount', $get_count_amount);
$this->layout->set('tableData', $expence_list); $this->layout->set('tableData', $expence_list);
$this->layout->buffer('main_content', 'Expence/expence_list'); $this->layout->buffer('main_content', 'Expence/expence_list');
$this->layout->render('Employee_Layout'); $this->layout->render('Employee_Layout');
} }
public function expence_list_view($id)
{
$expence_list = $this->Expence_model->get_expense_child_data2($id);
$get_expense_name = $this->Expence_model->get_expense_data_not_md5($id);
$this->layout->set('tableData', $expence_list);
$this->layout->set('expense_name', $get_expense_name);
$this->layout->buffer('main_content', 'Expence/expence_list_view');
$this->layout->render('Employee_Layout');
}
public function expence_list2()
{
$id = $this->input->get('id');
$expence_list2 = $this->Expence_model->get_expence_child_list($id);
echo json_encode($expence_list2);
}
public function Emp_Expence_List()
{
$business_id = user()->business_id;
$expence_list = $this->Expence_model->get_expence_list_all($business_id);
$get_count_amount = $this->Expence_model->get_count_amount();
$this->layout->set('count_amount', $get_count_amount);
$this->layout->set('tableData', $expence_list);
$this->layout->buffer('main_content', 'Expence/emp_expence_list');
$this->layout->render('Employee_Layout');
}
public function Emp_Expence_List_view($id)
{
$expence_list = $this->Expence_model->get_expense_child_data2($id);
$get_expense_name = $this->Expence_model->get_expense_data_not_md5($id);
$this->layout->set('tableData', $expence_list);
$this->layout->set('expense_name', $get_expense_name);
$this->layout->buffer('main_content', 'Expence/emp_expence_list_view');
$this->layout->render('Employee_Layout');
}
public function getDeleteConfirmationPopup() public function getDeleteConfirmationPopup()
{ {
@ -204,73 +334,94 @@ public function getDeleteConfirmationPopup()
echo json_encode($htmlPage); echo json_encode($htmlPage);
} }
public function Approve_Expence() public function Approve_Expence()
{ {
$id=$this->input->post('id'); $id=$this->input->post('id');
$action['status'] = 'Approved'; $action['status'] = 'Approved';
$action['approved_by']= user()->name; $action['approved_by']= user()->name;
$action['approved_at'] = date('d-m-Y H:i:s'); $action['approved_at'] = date('Y-m-d h:i:s');
$table = "expence_list"; $table = "expense";
$this->MY_Model->edit_option($action, $id, $table); $this->MY_Model->edit_option($action, $id, $table);
$this->Expence_model->approve_child_expense($action, $id);
$this->session->set_flashdata('approve', 'Claim Request Approved'); $this->session->set_flashdata('approve', 'Claim Request Approved');
redirect('Expence/expence_list'); redirect('Expence/expence_list');
} }
public function manager_approvel_list() public function Approve_Child_Expence()
{
$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->post('id'); $id=$this->input->post('id');
$action['status'] = 'Approved'; $action['status'] = 'Approved';
$action['approved_by']= user()->name; $action['approved_by']= user()->name;
$action['approved_at'] = date('d-m-Y H:i:s'); $action['approved_at'] = date('Y-m-d h:i:s');
$table = "expence_list"; $this->Expence_model->approve_child_expense_2($action, $id);
$this->MY_Model->edit_option($action, $id, $table); redirect('Expence/expence_list_view/'.$this->input->post('expence_id'));
$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() public function Decline_expence()
{ {
$id=$this->input->get('id'); $id=$this->input->get('id');
$data['status'] = 'Declined'; $data['status'] = 'Declined';
$data['declined_at'] = date('d-m-Y H:i:s'); $data['decline_by'] = user()->name;
$data['DReason'] = $this->input->get('reason'); $data['decline_reason'] = $this->input->get('reason');
$this->Expence_model->ExpenceDecline($id, $data); $this->Expence_model->ExpenceDecline($id, $data);
$this->Expence_model->Expence_Decline_Child($id, $data);
return true; return true;
} }
public function Decline_Child_Expence()
{
$id=$this->input->get('id');
$action['status'] = 'Declined';
$action['decline_by'] = user()->name;
$action['decline_reason'] = $this->input->get('reason');
return $this->Expence_model->approve_child_expense_2($action, $id);
}
public function getCancelConfirmationPopup()
{
$data = array();
$htmlPage = $this->load->view('confirmation_popup.php',$data,true);
echo json_encode($htmlPage);
}
public function cancled_expence() public function cancled_expence()
{ {
$id=$this->input->get('id'); $id=$this->input->post('id');
$data['status'] = 'canceled'; $data['status'] = 'Cancelled';
$data['canceled_at'] = date('d-m-Y H:i:s'); $data['cancelled_at'] = date('Y-m-d h:i:s');
$this->Expence_model->Expencecancle($id, $data); $first = $this->Expence_model->Expencecancle($id, $data);
$this->session->set_flashdata('cancel', 'Claim Request Canceled.... '); $second = $this->Expence_model->Expencecancle_child($id, $data);
redirect('Expence/emp_expence_list'); redirect('Expence/emp_expence_list');
} }
public function remove_row()
{
$get_count_from_child = $this->Expence_model->get_expense_child_data(md5($this->input->post('expence_id')));
$count = count($get_count_from_child);
if($count === 1)
{
$this->session->set_flashdata('remove_row', '1');
redirect('Expence/edit_expence/'.md5($this->input->post('expence_id')));
}
else
{
$id = $this->input->post('id');
$delete = $this->Expence_model->remove_row($id);
redirect('Expence/edit_expence/'.md5($this->input->post('expence_id')));
}
}
public function submit()
{
$id = $this->input->post('id');
$table1 = 'expense';
$data['status'] = "pending";
$data['updated_on'] = date('Y-m-d h:i:s');
$this->MY_Model->edit_option($data, $id, $table1);
$this->Expence_model->update_to_submit_all($id, $data);
redirect('Expence/emp_expence_list');
}
} }

View File

@ -21,19 +21,113 @@ public function get_employee_name($business_id)
public function get_expence_list($business_id) public function get_expence_list($business_id)
{ {
$this->db->select('A.* , name', 'users.name'); $this->db->select('A.*, u1.name as requested_name, u2.name as created_name');
$this->db->from('expence_list A'); $this->db->from('expense A');
$this->db->join('users', 'users.id = A.emp_id', 'left'); $this->db->join('users u1', 'u1.id = A.requested_for', 'left');
//$this->db->join('delegation', 'delegation.emp_id = users.id', 'left'); $this->db->join('users u2', 'u2.id = A.created_by', 'left');
$this->db->where('A.business_id', $business_id); $this->db->where('A.business_id', $business_id);
$this->db->order_by('id','DESC'); $this->db->where('A.status', 'pending');
$this->db->where('A.is_active', 1); $this->db->or_where('A.status', 'Approved');
$this->db->or_where('A.status', 'Declined');
$this->db->order_by('A.id', 'DESC');
$query = $this->db->get(); $query = $this->db->get();
$query = $query->result(); $query = $query->result();
return $query; return $query;
} }
public function get_expence_list_all($business_id)
{
$this->db->select('A.*, u1.name as requested_name, u2.name as created_name');
$this->db->from('expense A');
$this->db->join('users u1', 'u1.id = A.requested_for', 'left');
$this->db->join('users u2', 'u2.id = A.created_by', 'left');
$this->db->where('A.business_id', $business_id);
$this->db->order_by('A.id','DESC');
$query = $this->db->get();
$query = $query->result();
return $query;
}
public function get_expense_data($id)
{
$this->db->select('*');
$this->db->from('expense');
$this->db->where('md5(id)', $id);
$query = $this->db->get();
return $query->result();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return;
}
}
public function get_expense_data_not_md5($id)
{
$this->db->select('A.*, u1.name as requested_name, u2.name as created_name');
$this->db->from('expense A');
$this->db->join('users u1', 'u1.id = A.requested_for', 'left');
$this->db->join('users u2', 'u2.id = A.created_by', 'left');
$this->db->where('A.id', $id);
$query = $this->db->get();
return $query->result();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return;
}
}
public function get_expense_child_data($id)
{
$this->db->select('*');
$this->db->from('expense_child');
$this->db->where('md5(expense_id)', $id);
$query = $this->db->get();
return $query->result();
}
public function get_expense_child_data2($id)
{
$this->db->select('*');
$this->db->from('expense_child');
$this->db->where('expense_id', $id);
$query = $this->db->get();
return $query->result();
}
public function get_expence_child_list($expense_id)
{
$this->db->select('*');
$this->db->from('expense_child');
$this->db->where('expense_id', $expense_id);
$this->db->order_by('id', 'DESC');
$query = $this->db->get();
return $query->result();
}
public function approve_child_expense($action, $id)
{
$this->db->where('expense_id', $id);
$this->db->where('status','pending');
$this->db->update('expense_child',$action);
}
public function approve_child_expense_2($action, $id)
{
$this->db->where('id', $id);
$this->db->where('status','pending');
$this->db->update('expense_child',$action);
}
public function decline_dropdown($business_id) public function decline_dropdown($business_id)
{ {
@ -66,21 +160,36 @@ public function get_expence_list_by_id($id)
} }
public function ExpenceDecline($id, $data) public function ExpenceDecline($id, $data)
{ {
$this->db->where('id',$id); $this->db->where('id',$id);
$this->db->where('status', 'pending'); $this->db->where('status', 'pending');
$this->db->update('expence_list', $data); $this->db->update('expense', $data);
return;
}
public function Expence_Decline_Child($id, $data)
{
$this->db->where('expense_id',$id);
$this->db->where('status', 'pending');
$this->db->update('expense_child', $data);
return; return;
} }
public function Expencecancle($id, $data) public function Expencecancle($id, $data)
{ {
$this->db->where('md5(id)',$id); $this->db->where('md5(id)',$id);
$this->db->where('status', 'pending'); $this->db->where('status', 'Draft');
$this->db->update('expence_list', $data); $this->db->update('expense', $data);
return; return $this->db->last_query();
}
public function Expencecancle_child($id, $data)
{
$this->db->where('md5(expense_id)',$id);
$this->db->where('status', 'Draft');
$this->db->update('expense_child', $data);
return $this->db->last_query();
} }
public function Get_delegation_id($business_id) public function Get_delegation_id($business_id)
@ -94,4 +203,39 @@ public function Get_delegation_id($business_id)
return $query->result(); return $query->result();
} }
public function get_manager_id($user_id)
{
$this->db->select('manager');
$this->db->from('employees');
$this->db->where('user_id', $user_id);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->result();
} else {
return;
}
}
public function remove_row($id)
{
$this->db->where("id", $id);
$this->db->delete("expense_child");
return true;
}
public function update_to_submit_all($id, $data)
{
$this->db->where('expense_id',$id);
$this->db->where('status', 'Draft');
$this->db->update('expense_child', $data);
return;
}
// get the value from expense and expense_child sum of the value and count data
public function get_count_amount()
{
$query = $this->db->query('SELECT expense.id, (SELECT SUM(amount) FROM expense_child WHERE expense_child.expense_id = expense.id) as amount, (SELECT COUNT(expense_id) FROM expense_child WHERE expense_child.expense_id = expense.id) as count FROM expense');
$query = $query->result();
return $query;
}
} }

View File

@ -5,8 +5,8 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h6 class="modal-title" id="myModalLabel2">Are you sure to Approve this Expense</h6> <h6 class="modal-title" id="myModalLabel2">Are you sure to Approve this Action</h6>
<button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> <!-- <button type="button" id="close-form" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> -->
</button> </button>
</div> </div>
</br> </br>
@ -15,6 +15,7 @@
<button type="button" class="btn btn-sm btn-secondary" id="close-form" data-dismiss="modal" aria-label="Close">No</button> <button type="button" class="btn btn-sm btn-secondary" id="close-form" data-dismiss="modal" aria-label="Close">No</button>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<input type="hidden" class="delete_id" name="id" value=""> <input type="hidden" class="delete_id" name="id" value="">
<input type="hidden" class="expence_id" name="expence_id" value="">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>" > <input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>" >
<button type="submit" class="btn btn-sm btn-primary" id="">Yes</button> <button type="submit" class="btn btn-sm btn-primary" id="">Yes</button>
</form> </form>

View File

@ -1,172 +1,334 @@
<!-- Body page content -->
<!-- bootstrap-daterangepicker -->
<script src="https://localhost/ams//assets/default/moment/min/moment.min.js"></script>
<script src="https://localhost/ams//assets/default/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap-datetimepicker -->
<script src="https://localhost/ams//assets/default/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<!-- Body page content -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> -->
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <script src="https://localhost/ams//assets/default/bootstrap-daterangepicker/daterangepicker.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
.alert-success {
background-color: #dff0d8;
color: #3c763d;
border-color: #d6e9c6;
}
<div class=""> .flash-message {
<div class="page-title"> padding: 20px;
<ul class="nav navbar-right panel_toolbox"> margin-bottom: 10px;
<li><a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-primary" style="margin-top: 22px;">Back</a></li> border-radius: 5px;
</ul> margin-left: 500px;
<h1>Edit Expense</h1> }
</div>
.hide-arrow {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-image: none;
</div> }
.drop-zone {
border: 2px dashed #ccc;
padding: 20px;
width: 257px;
height:300px;
text-align: center;
cursor: pointer;
}
.preview-container {
display: flex;
flex-wrap: wrap;
margin-top: 19px;
margin-left: -18px !important;
}
.preview-item {
width: 100%;
margin-right: 10px;
margin-bottom: 10px;
}
.preview-item img,
.preview-item object {
width: 290px;
height: 280px;
}
</style>
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="row"> <div class="row">
<div class="col-md-12 col-sm-12 "> <div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title"> <div class="x_title">
<button hidden id="button" class="btn btn-secondary source" onclick="new PNotify({
title: 'Can not Delete',
text: 'Only change and Update',
styling: 'bootstrap3'
});">Success</button>
<input type="hidden" id="error" value="<?php echo $this->session->userdata('remove_row');?>" >
<?php $this->session->unset_userdata('remove_row');?>
<script>
$(document).ready(function(){
if($('#error').val() == 1 )
{
$('#button').click();
}
})
</script>
<ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-primary" style="margin-top: 20px; font-size: small;">Back</a>
</ul>
<h3>Edit Expense - <?php if(isset($expense_data[0]->id)){echo $expense_data[0]->expense_name; } ?></h3>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="x_content"> <div class="x_content">
<br /> <br />
<?php if(!empty($get_expence)) { ?>
<?php foreach( $get_expence as $data) { ?>
<form id="" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo base_url();?>Expence/edit_rise_expence_request" enctype="multipart/form-data"> <form id="" data-parsley-validate class="form-horizontal form-label-left" method="post" action="<?php echo base_url();?>Expence/edit_rise_expence_request" enctype="multipart/form-data">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>"> <input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
<input type="hidden" name="id" value="<?php echo $data->id; ?>">
<div class="item form-group">
</div>
<div class="x_panel">
<div class="item form-group"> <div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="last-name">Expense Requisted For</label> <label class="control-label col-md-2 col-sm-2" for="last-name">Expense Requisted For</label>
<div class="col-md-5 col-sm-5 "> <div class="col-md-4 col-sm-4 ">
<input type="radio" name="created_by" value="self"style="margin:10px;"checked /><b>Self</b> <input type="radio" name="created_by" value="self (<?php echo user()->id;?>)"style="margin:10px;"checked /><b>Self</b>
<input type="radio" name="created_by" value="<?php echo user()->name;?>" style="margin: 10px;" /><b>Others</b> <input type="radio" name="created_by" value="<?php echo user()->name;?> (<?php echo user()->id;?>)" style="margin: 10px;" /><b>Others</b>
</div> </div>
</div>
<div class="item form-group"> <label class="control-label col-md-1 col-sm-1 " for="last-name"> Employee Name <a style="color:red;">*</a></label>
<label class="control-label col-md-2 col-sm-2 " for="last-name"> Employee Name <a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 "> <div class="col-md-5 col-sm-5 ">
<select id="user_dropdown" name="emp_id" style="margin-top: 10px;padding-bottom: 10px;" class="form-control manager" > </select> <select id="user_dropdown" name="emp_id" style="margin-top: 10px;padding-bottom: 10px;" class="form-control manager" > </select>
</div> </div>
</div>
</div>
<div class="item form-group"> <div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="first-name"> Date of expence<a style="color:red;">*</a></label> <label class="control-label col-md-1 col-sm-1 " for="first-name">Expense Name<a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 "> <div class="col-md-5 col-sm-5 ">
<div class="form-group"> <div class="form-group">
<input type='text' placeholder="DD-MM-YYYY" class="form-control" id='ExpenseDate' required name="date_of_expence" value="<?php echo $data->date_of_expence; ?>" /> <input type='text' class="form-control" name="expense_name" value="<?php if(isset($expense_data[0]->id)){echo $expense_data[0]->expense_name; } ?>" autocomplete='off' required />
</div>
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Business Reason</label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<input type='text' class="form-control" name="business_reason" value="<?php if(isset($expense_data[0]->id)){echo $expense_data[0]->business_reason; } ?>" autocomplete='off'/>
<input type="hidden" id="expense_id" name="expense_pid" value="<?php echo $expense_data[0]->id; ?>">
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="x_panel">
<div class="x_title">
<!-- <ul class="nav navbar-right panel_toolbox">
<button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-info" style="font-size:small;" >Add</button>
</ul> -->
<div class="clearfix"></div>
</div><br>
<?php $i=1; foreach ($expense_child_data as $key => $value) { ?>
<div class="item form-group"> <div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="first-name"> Expense Cost <a style="color:red;">*</a></label> <label class="control-label col-md-1 col-sm-1 " for="first-name"> Date of Expense<a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 "> <div class="col-md-5 col-sm-5 ">
<input id="cost" name="amount" required value="<?php echo $data->amount; ?>" class="form-control" type="text" name="middle-name"> <div class="form-group">
<input type='text' id="ExpenseDate<?php echo $i;?>" class="form-control date" placeholder="DD-MM-YYYY" required name="date_of_expence[]" value="<?php echo $value->date_of_expense ?>" autocomplete='off'/>
</div>
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Amount<a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5">
<input id="cost" name="amount[]" required value="<?php echo $value->amount ?>" class="form-control" onkeypress = "return matchnum(event)" type="number" name="middle-name" autocomplete='off'>
</div> </div>
</div> </div>
<input type="hidden" name="expense_child_id[]" value="<?php echo $value->id; ?>">
<div class="item form-group flex-wrap">
<div class="item form-group"> <label class="control-label col-md-1 col-sm-1" for="last-name">Description</label>
<label class="control-label col-md-2 col-sm-2 " for="last-name">Description</label>
<div class="col-md-5 col-sm-5"> <div class="col-md-5 col-sm-5">
<textarea id="comments" name="comments" value="" class="form-control" style="height:200px !important;" type="text" ><?php echo $data->comments;?></textarea> <textarea id="comments" name="description[]" value="" class="form-control" style="height:50px !important;" type="text" ><?php echo $value->description ?></textarea>
<!-- <input type="hidden" id="manager_id" name="manager" value=""> -->
</div> </div>
</div>
<label class="control-label col-md-1 col-sm-1" required for="first-name">Recipt<a style="color:red;">*</a></label>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " required for="first-name">Upload Bill</label>
<div class="col-md-5 col-sm-5 "> <div class="col-md-5 col-sm-5 ">
<input id="formFile" name="bill" onchange="validateFile(this)" class="typeFile" type="file"> <input id="formFile" name="bill[]" onchange="validateFile(this)" class="typeFile" type="file" value="<?php echo $value->bill ?>" multiple><br>
</div>
</div>
<a href="<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>" target="_blank" class="btn btn-info float-right" style="font-size: x-small; margin-top: 7px;"><b>View Recipt</b></a></div>
<?php if($expense_data[0]->status == 'Draft') { ?>
<!-- <div class="item form-group"> <div class="col-12"><button type="button" class="float-right btn btn-danger deleteexpense hidebtn" data-toggle="modal" data-target=".bs-example-modal-sm" id="<?php echo $value->id;?>"><i class="fa fa-trash"></i></button>
<label class="control-label col-md-2 col-sm-2 " required for="first-name"></label> <button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-primary float-right">Add</button>
<div class="col-md-2 col-sm-2 ">
<img src="<?php echo base_url(); ?>/assets/uploads/Expence_Bill/<?php echo $data->bill; ?>" style="height: 100px; width: 100px;" id="uploadPreview" class="avatar img-circle img-thumbnail" alt="avatar"><br><br>
</div> </div>
</div>--> <?php } ?>
</div>
<script>
flatpickr($('#ExpenseDate'+<?php echo $i;?>), {
dateFormat: 'd-m-Y',
changeYear: true,
yearRange: '2000:' + new Date().getFullYear(),
maxDate: new Date(),
autoclose:true,
onChange: function(selectedDates, dateStr) {
console.log('Selected date: ', dateStr);
}
});
</script>
<?php $i++; } ?>
<div id="formContainer"></div>
</div>
<div class="ln_solid"></div> <div class="ln_solid"></div>
<div class="item form-group"> <div class="item form-group">
<div class=" offset-md-8"> <div class=" offset-md-8">
<?php if($expense_data[0]->status == 'Draft') { ?>
<button class="btn btn-secondary" onclick="history.back()">Cancel</button> <button class="btn btn-secondary" onclick="history.back()">Cancel</button>
<button class="btn btn-primary" type="reset">Reset</button> <button type="submit" class="btn btn-success" name="update">Update</button>
<button type="submit" class="btn btn-success">Update</button> <?php } ?>
</div> </div>
</div> </div>
</form> </form>
<?php } } ?>
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
<div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div>
<div style="display:none" id="sub-value">
</div>
</div>
<!-- /Body page content --> <!-- /Body page content -->
<script> <script>
// hide the dropdown arrow
$(document).ready(function() {
$("#user_dropdown").addClass("hide-arrow");
$("input[name='created_by']").on("change", function() {
var inputValue = $(this).val();
if (inputValue === "<?php echo user()->name;?> (<?php echo user()->id;?>)") {
$("#user_dropdown").removeClass("hide-arrow");
} else {
$("#user_dropdown").addClass("hide-arrow");
}
});
})
</script>
<script>
// $()
// $('.date').on('click', function() {
// const datepickerInput = $(this).attr('id');
// //const datepickerInput = document.getElementById('ExpenseDate');
// console.log(datepickerInput);
// flatpickr(datepickerInput, {
// dateFormat: 'd-m-Y',
// maxDate: new Date(),
// onChange: function(selectedDates, dateStr) {
// console.log('Selected date: ', dateStr);
// }
// });
// });
function validateFile(input) { function validateFile(input) {
const file = input.files[0]; const file = input.files[0];
const allowedExtensions = ["jpg", "jpeg", "png", "pdf"]; const allowedExtensions = ["jpg", "jpeg", "png", "pdf"];
const fileExtension = file.name.split(".").pop().toLowerCase(); const fileExtension = file.name.split(".").pop().toLowerCase();
if (!allowedExtensions.includes(fileExtension)) { if (!allowedExtensions.includes(fileExtension)) {
Swal.fire("Invalid file type. Only JPG, JPEG, PNG, and PDF files are allowed."); new PNotify({
input.value = ""; // Clear the input value title: 'Invalid file type.',
text: 'Only JPG, JPEG, PNG, and PDF files are allowed.',
styling: 'bootstrap3'
});
input.value = "";
return;
} }
} }
</script> </script>
<script> <script>
function matchnum(event)
{
var charcode;
charcode = event.which || event.keyCode;
if(charcode>= 48 && charcode <= 57)return true; //only numbers
return false;
}
$(document).ready(function(){ $(document).ready(function(){
var currentUserName = '<?php echo user()->name; ?>'; var currentUserName = '<?php echo user()->name; ?>';
@ -179,20 +341,21 @@ function validateFile(input) {
}); });
$('input[type="radio"][name="created_by"]').change(function() { $('input[type="radio"][name="created_by"]').change(function() {
var selectedValue = $(this).val(); var selectedValue = $(this).val();
var $userDropdown = $('#user_dropdown'); var $userDropdown = $('#user_dropdown');
$userDropdown.empty(); $userDropdown.empty();
if (selectedValue === 'self') { if (selectedValue === 'self (<?php echo user()->id;?>)') {
var currentUserName = '<?php echo user()->name; ?>'; var currentUserName = '<?php echo user()->name; ?>';
var currentUserId = '<?php echo user()->id; ?>'; var currentUserId = '<?php echo user()->id; ?>';
$userDropdown.append('<option value="' + currentUserId + '">' + currentUserName + '</option>'); $userDropdown.append('<option value="' + currentUserId + '">' + currentUserName + '</option>');
$userDropdown.prop('disabled', true); $userDropdown.prop('disabled', true);
} else if (selectedValue === '<?php echo user()->name; ?>') { } else if (selectedValue === '<?php echo user()->name; ?> (<?php echo user()->id;?>)') {
$.ajax({ $.ajax({
url: '<?php echo base_url('Expence/get_emp_name/')?>"', url: '<?php echo base_url('Expence/get_emp_name/')?>"',
@ -212,21 +375,6 @@ function validateFile(input) {
}); });
var dateFormat = "dd-mm-yy";
var fromDateInput = $("#ExpenseDate");
console.log(fromDateInput);
fromDateInput.datepicker({
dateFormat: dateFormat,
changeYear: true,
changeMonth: true,
yearRange: "1990:c",
onSelect: function (dateText, inst) {
}
});
</script> </script>
<script> <script>
@ -236,19 +384,105 @@ function validateFile(input) {
$("#user_dropdown").on("change", function(){ $("#user_dropdown").on("change", function(){
let manager_id = $(this).children(":selected").attr("id"); let manager_id = $(this).children(":selected").attr("id");
console.log(manager_id);
$("#manager_id").val(manager_id); $("#manager_id").val(manager_id);
}) })
</script> </script>
<!-- <script> <script>
function PreviewImage() { var i=1;
var oFReader = new FileReader(); function createAndAppendFormGroup() {
oFReader.readAsDataURL(document.getElementById("formFile").files[0]); var html1 = '';
i++
html1 += '<div id="removeChild'+i+'">'
html1 += '<br><div class="x_title">'+i+'</div><br>'
html1 += '<div class="item form-group">';
html1 += '<label class="control-label col-md-1 col-sm-1 " for="first-name"> Date of Expense<a style="color:red;">*</a></label>';
html1 += '<div class="col-md-5 col-sm-5 "><div class="form-group"><input type="date" id="datepicker'+i+'" class="form-control dates" placeholder="DD-MM-YYYY" required name="date_of_expence2[]" value="" autocomplete="off"/></div></div>';
html1 += '<label class="control-label col-md-1 col-sm-1 " for="first-name"> Expense Cost <a style="color:red;">*</a></label>';
html1 += '<div class="col-md-5 col-sm-5 "><input id="cost" name="amount2[]" required class="form-control" onkeypress="return matchnum(event)" type="number" name="middle-name" autocomplete="off"></div>';
html1 += '</div>';
oFReader.onload = function (oFREvent) {
document.getElementById("uploadPreview").src = oFREvent.target.result; html1 += '<div class="item form-group flex-wrap">'
}; html1 += '<label class="control-label col-md-1 col-sm-1" for="last-name">Description</label>'
}; html1 += '<div class="col-md-5 col-sm-3"><textarea id="comments" name="description2[]" value="" class="form-control" style="height:50px !important;" type="text" ></textarea></div>'
</script> -->
html1 += '<label class="control-label col-md-1 col-sm-1" required for="first-name">Upload Bill </label>'
html1 += '<div class="col-md-5 col-sm-5 "><input id="formFile" name="bill2[]" multiple onchange="validateFile(this)" class="typeFile" type="file" value="" required></div>'
html1 += '</div>'
html1 += '<div class="col-12"><button type="button" class="float-right btn btn-danger"" id="remove-button" onclick="removebutton('+i+')"><i class="fa fa-trash"></i></button></div><button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-primary float-right">Add</button></div>'
var formContainer = document.getElementById('formContainer');
//formContainer.innerHTML += html1;
formContainer.insertAdjacentHTML('beforeend', html1);
const datepickerInput = document.getElementById('datepicker'+i);
flatpickr(datepickerInput, {
dateFormat: 'd-m-Y',
maxDate: new Date(),
autoclose:true,
onChange: function(selectedDates, dateStr) {
console.log('Selected date: ', dateStr);
}
});
}
function removebutton(index) {
//console.log(index)
var element = document.getElementById('removeChild'+ index);
//console.log(element)
if (element) {
element.remove();
}
}
</script>
<script>
$('.deleteexpense').click(function() {
var id = $(this).attr('id');
var expence_id = document.getElementById('expense_id').value;
var url = "<?php echo base_url()?>Expence/remove_row";
$.ajax({
url: "<?php echo base_url()?>Expence/getCancelConfirmationPopup",
type:"GET",
success:function(data){
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value',id);
$('.expence_id').attr('value',expence_id);
$('.delete_url').attr('action',url);
}
});
});
// $('.hidebtn').click(function() {
// var id = document.getElementById('expense_id').value;
// alert(id)
// $('.hidebtn').disable()
// // $.ajax({
// // data:{id : id},
// // url: "<?php echo base_url()?>Expence/get_expense_child_count",
// // type:"GET",
// // success:function(data){
// // $('#popup').html(JSON.parse(data));
// // $('.delete_id').attr('value',id);
// // $('.expence_id').attr('value',expence_id);
// // $('.delete_url').attr('action',url);
// // }
// // });
// });
</script>

View File

@ -6,7 +6,7 @@
.modal { .modal {
display: none; /* Hide the modal by default */ display: none; /* Hide the modal by default */
position: fixed; position: fixed;
z-index: 1; /* z-index: 1;*/
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
@ -82,7 +82,7 @@
<a href="<?php echo base_url();?>Expence/expence_form" class="btn btn-sm btn-primary" style="margin-top: 20px;">New Claim</a> <a href="<?php echo base_url();?>Expence/expence_form" class="btn btn-sm btn-primary" style="margin-top: 20px;">New Claim</a>
<?php if(is_user() || user()->role == null) { ?> <?php if(is_user() || user()->role == null) { ?>
<a href="<?php echo base_url();?>Expence/manager_approvel_list" class="btn btn-sm btn-warning" style="margin-top: 20px;">My Approval</a> <a href="<?php echo base_url();?>Expence/expence_list" class="btn btn-sm btn-warning" style="margin-top: 20px;">My Approval</a>
<?php } ?> <?php } ?>
<?php if(is_admin()) { ?> <?php if(is_admin()) { ?>
@ -90,62 +90,84 @@
<?php }?> <?php }?>
</ul> </ul>
<h1>Expense Claims</h1> <h3>Expense Claims</h3>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="x_content"> <div class="x_content">
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<table id="datatables" class="table table-striped table-bordered" width="100%"> <div class="table-responsive">
<table class="table table-striped">
<thead> <thead>
<tr class="headings"> <tr class="headings">
<th hidden class="column-title">id</th> <th hidden class="column-title">id</th>
<th class="column-title">Claim Date </th> <th class="column-title">Claim Date</th>
<th class="column-title">Desription</th> <th class="column-title">Expense Name</th>
<th class="column-title">Expense Date</th> <th class="column-title">Business Reason</th>
<th class="column-title">Expense Cost()</th> <th class="column-title">Total Amount()</th>
<th class="column-title">Status </th> <th class="column-title">No of List</th>
<th class="column-title">Action </th> <th class="column-title">Status </th>
<th class="column-title" >Action </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($tableData as $key => $value) { ?> <?php foreach ($tableData as $key => $value) { ?>
<?php if(user()->id == $value->emp_id) { ?> <?php if(user()->id == $value->requested_for) { ?>
<tr class="even pointer"> <tr class="even pointer">
<td hidden class=" "><?php echo $value->id; ?></td> <td hidden><?php echo $value->id; ?></td>
<td class=" "><?php echo $value->created_date; ?><br><?php echo $value->created_time;?></td> <td><?php echo date('d-m-Y', strtotime($value->created_on));?>
<td class=" "><?php echo $value->comments; ?></td> <td class=" "><?php echo $value->expense_name; ?></td>
<td class=" "> <?php echo dateFormat('d-m-Y',$value->date_of_expence);?></td> <td class=" "><?php echo $value->business_reason; ?></td>
<td class=" "> <?php echo $value->amount; ?></td> <?php foreach ($count_amount as $key => $count_value) { ?>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By <?php echo $value->approved_by; ?><br><?php echo $value->approved_at; ?></td>
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"><?php echo $value->status; ?> <br> <?php echo $value->Dreason; ?></td>
<?php }
else if($value->status == 'canceled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?></td>
<?php }
else{
}?> <?php if($value->id == $count_value->id) { ?>
<td class=" "><?php echo $count_value->amount ?></td>
<td class=" "><?php echo $count_value->count ?></td>
<?php } } ?>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By <?php echo $value->approved_by; ?><br><?php echo date('d-m-Y h:i:s', strtotime($value->approved_at));?></td>
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"><?php echo $value->status; ?> by <?php echo $value->decline_by; ?> <br><?php echo $value->decline_reason; ?></td>
<?php }
else if($value->status == 'Cancelled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?> at <br><?php echo date('d-m-Y h:i:s', strtotime($value->cancelled_at));?></td>
<?php }
else if($value->status == 'Draft'){?>
<td style="color:#0000e6;"><?php echo $value->status; ?></td>
<?php } ?>
<td style=" text-align: center; font-size: 16px;"> <td style=" text-align: center; font-size: 16px;">
<?php if(!empty($value->bill)) { ?> <!-- <?php if(!empty($value->bill)) { ?>
<a onclick="openModal('<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>')" title="ViewBill"><i class="fa fa-eye" aria-hidden="true"></i></a><br> <a onclick="openModal('<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>')" title="ViewBill"><i class="fa fa-eye" aria-hidden="true"></i></a><br>
<?php } ?> -->
<?php if( $value->status != 'Draft') { ?>
<a href="<?php echo base_url()?>Expence/edit_expence/<?php echo md5($value->id);?>"><i class="fa fa-list-alt" aria-hidden="true"title="View List"></i></a> &nbsp;
<?php } ?> <?php } ?>
<?php if($value->status == 'pending') { ?> <?php if( $value->status == 'Draft') { ?>
<a href="<?php echo base_url('Expence/edit_expence')?>?id=<?php echo md5($value->id);?> "><i class="fa fa-edit" aria-hidden="true"title="Edit"></i></a> &nbsp; <a href="<?php echo base_url()?>Expence/edit_expence/<?php echo md5($value->id);?> "><i class="fa fa-edit" aria-hidden="true"title="Edit"></i></a> &nbsp;
<a href="#"><i class="fa fa-ban cancelexpense" aria-hidden="true"title="Cancel" data-toggle="modal" data-target=".bs-example-modal-sm" id="<?php echo md5($value->id);?>"></i></a> &nbsp;
<a href="#"><i class="fa fa-check Submitexpense" aria-hidden="true"title="Submit" data-toggle="modal" data-target=".bs-example-modal-sm" id="<?php echo $value->id;?>"></i></a> &nbsp;
<!-- <a href="<?php echo base_url()?>Expence/submit/<?php echo $value->id;?>" onclick="return confirm('Are sure to Submit this Expence')"><i class="fa fa-check" aria-hidden="true"title="Submit All"></i></a> &nbsp; -->
<a href="<?php echo base_url('Expence/cancled_expence')?>?id=<?php echo md5($value->id);?> "><i class="fa fa-ban" aria-hidden="true"title="Cancel"></i></a> &nbsp;
<?php } ?> <?php } ?>
@ -154,6 +176,7 @@
<?php } } ?> <?php } } ?>
</tbody> </tbody>
</table> </table>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -172,23 +195,19 @@
<!-- JavaScript --> <!-- JavaScript -->
<script> <script>
function openModal(itemId) { function openModal(url) {
// Get the image URL for the item with the specified ID if (url.endsWith('.pdf')) {
var imageUrl = itemId; window.open(url, '_blank');
} else if (url.match(/\.(jpeg|jpg|png|gif)$/i)) {
// Set the image source of the modal // If the URL ends with .jpeg, .jpg, .png, or .gif, show the image
document.getElementById("modalImage").src = imageUrl; var img = new Image();
img.src = url;
// Open the modal var win = window.open('', '_blank');
var modal = document.getElementById("myModal"); win.document.write('<img src="' + img.src + '" alt="Image">');
modal.style.display = "block"; } else {
alert('The selected file is not a PDF or an image.');
// Close the modal when the user clicks on the close button }
var closeButton = document.getElementsByClassName("close")[0]; }
closeButton.onclick = function() {
modal.style.display = "none";
}
}
</script> </script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
@ -203,6 +222,41 @@ function openModal(itemId) {
}); });
</script> </script>
<script>
$('.cancelexpense').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Expence/cancled_expence";
$.ajax({
url: "<?php echo base_url()?>Expence/getCancelConfirmationPopup",
type:"GET",
success:function(data){
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value',id);
$('.delete_url').attr('action',url);
}
});
});
$('.Submitexpense').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Expence/submit";
$.ajax({
url: "<?php echo base_url()?>Expence/getCancelConfirmationPopup",
type:"GET",
success:function(data){
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value',id);
$('.delete_url').attr('action',url);
}
});
});
</script>

View File

@ -0,0 +1,201 @@
<head>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'>
<style>
/* Modal Popup Styles */
.modal {
display: none; /* Hide the modal by default */
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.9);
}
.modal img {
display: block;
margin: 0 auto;
max-width: 80%;
max-height: 100%;
margin-top: 5%;
margin-bottom: 5%;
}
.close {
color: #fff;
font-size: 40px;
font-weight: bold;
position: absolute;
top: 10px;
right: 20px;
cursor: pointer;
}
div.dataTables_wrapper div.dataTables_filter{
margin-top: -30px !important; //search to up
}
.alert-success {
background-color: #dff0d8;
color: #3c763d;
border-color: #d6e9c6;
}
.flash-message {
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
margin-left: 690px;
}
</style>
</head>
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title">
<button hidden id="button" class="btn btn-secondary source" onclick="new PNotify({
text: '<html><h2>Submmited for Approvel.<h2></html>',
type: 'success',
styling: 'bootstrap3'
});">Success</button>
<input type="hidden" id="error" value="<?php echo $this->session->userdata('Create');?>" >
<?php $this->session->unset_userdata('Create');?>
<script>
$(document).ready(function(){
if($('#error').val() == 1 )
{
$('#button').click();
}
})
</script>
<ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Expence/Emp_Expence_List" class="btn btn-sm btn-primary" style="margin-top: 20px;">Back</a>
</ul>
<h3>List of Expense - <?php echo $expense_name[0]->expense_name; ?></h3>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="row">
<div class="col-sm-12">
<table class="table table-striped">
<thead>
<tr class="headings">
<th hidden class="column-title">id</th>
<th class="column-title">Claim Date</th>
<th class="column-title">Date of Expense</th>
<th class="column-title">Amount</th>
<th class="column-title">Description</th>
<th class="column-title">Status </th>
<th class="column-title" >Action </th>
</tr>
</thead>
<tbody>
<?php foreach ($tableData as $key => $value) { ?>
<tr class="even pointer">
<td hidden><?php echo $value->id; ?></td>
<td><?php echo date('d-m-Y', strtotime($value->created_on));?>
<td class=" "><?php echo date('d-m-Y', strtotime($value->date_of_expense)) ?></td>
<td class=" "><?php echo $value->amount; ?></td>
<td class=" "><?php echo $value->description; ?></td>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By <?php echo $value->approved_by; ?><br><?php echo $value->approved_at;?></td>
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"><?php echo $value->status; ?> by <?php echo $value->decline_by; ?> <br><?php echo $value->decline_reason; ?></td>
<?php }
else if($value->status == 'Cancelled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?> at <br><?php echo $value->cancelled_at; ?></td>
<?php }
else if($value->status == 'Draft'){?>
<td style="color:#0000e6;"><?php echo $value->status; ?></td>
<?php } ?>
<td style=" text-align: center; font-size: 16px;">
<a onclick="openModal('<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>')" title="ViewBill"><i class="fa fa-eye" aria-hidden="true"></i></a>
<?php if( $value->status == 'Draft' || $value->status == 'Draft') { ?>
<!-- <a href="<?php echo base_url('Expence/edit_expence')?>?id=<?php echo md5($value->id);?> "><i class="fa fa-edit" aria-hidden="true"title="View List"></i></a> &nbsp; -->
<!-- <a href="<?php echo base_url('Expence/cancled_expence')?>?id=<?php echo md5($value->id);?> "><i class="fa fa-ban" aria-hidden="true"title="Cancel"></i></a> &nbsp; -->
<!-- <a href="<?php echo base_url()?>Expence/submit/<?php echo $value->id;?>" onclick="return confirm('Are sure to Submit this Expence')"><i class="fa fa-check" aria-hidden="true"title="Submit All"></i></a> &nbsp; -->
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<br/>
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
<div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div>
<div id="myModal" class="modal">
<span class="close">&times;</span>
<img id="modalImage" src="" alt="Image">
</div>
<!-- JavaScript -->
<script>
function openModal(url) {
if (url.endsWith('.pdf')) {
window.open(url, '_blank');
} else if (url.match(/\.(jpeg|jpg|png|gif)$/i)) {
// If the URL ends with .jpeg, .jpg, .png, or .gif, show the image
var img = new Image();
img.src = url;
var win = window.open('', '_blank');
win.document.write('<img src="' + img.src + '" alt="Image">');
} else {
alert('The selected file is not a PDF or an image.');
}
}
</script>
<script>
$(document).ready(function() {
$('#datatables').DataTable({
"order": [[0, 'desc']], // Set initial sorting to descending on the first column
"dom": 'Bfrtip', // Show export buttons
"buttons": [ 'excel', 'pdf'], // Enable export options
"language": {
"search": "Search: " // Customize search label
}
});
});
</script>

View File

@ -1,22 +1,10 @@
<!-- bootstrap-daterangepicker -->
<script src="https://localhost/ams//assets/default/moment/min/moment.min.js"></script>
<script src="https://localhost/ams//assets/default/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap-datetimepicker -->
<script src="https://localhost/ams//assets/default/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<!-- Body page content -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> -->
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <script src="https://localhost/ams//assets/default/bootstrap-daterangepicker/daterangepicker.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style> <style>
@ -77,14 +65,12 @@
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="row"> <div class="row">
<div class="col-md-12 col-sm-12 "> <div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title"> <div class="x_title">
<ul class="nav navbar-right panel_toolbox"> <ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-primary" style="margin-top: 20px;">Back</a> <a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-primary" style="margin-top: 20px; font-size: small;">Back</a>
</ul> </ul>
<h3>Expense Claim</h3>
<h1>Expense Claim</h1>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
@ -94,25 +80,18 @@
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>"> <input type="hidden" name="<?php echo $this->security->get_csrf_token_name();?>" value="<?php echo $this->security->get_csrf_hash();?>">
<div class="x_panel">
<div class="item form-group"> <div class="item form-group">
<label class="control-label col-md-2 col-sm-2 label-align" for="last-name">Expense Requisted For</label>
<div class="col-md-4 col-sm-4">
</div>
<div class="item form-group">
<label class="control-label col-md-2 col-sm-2" for="last-name">Expense Requisted For</label>
<div class="col-md-5 col-sm-5 ">
<input type="radio" name="created_by" value="self (<?php echo user()->id;?>)"style="margin:10px;"checked /><b>Self</b> <input type="radio" name="created_by" value="self (<?php echo user()->id;?>)"style="margin:10px;"checked /><b>Self</b>
<input type="radio" name="created_by" value="<?php echo user()->name;?> (<?php echo user()->id;?>)" style="margin: 10px;" /><b>Others</b> <input type="radio" name="created_by" value="<?php echo user()->name;?> (<?php echo user()->id;?>)" style="margin: 10px;" /><b>Others</b>
</div> </div>
</div>
<div class="item form-group"> <label class="control-label col-md-1 col-sm-1 label-align" for="last-name"> Employee Name <a style="color:red;">*</a></label>
<label class="control-label col-md-2 col-sm-2 " for="last-name"> Employee Name <a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 "> <div class="col-md-5 col-sm-5 ">
<select id="user_dropdown" name="emp_id" style="margin-top: 10px;padding-bottom: 10px;" class="form-control manager" > </select> <select id="user_dropdown" name="emp_id" style="margin-top: 10px;padding-bottom: 10px;" class="form-control manager" > </select>
</div> </div>
@ -120,67 +99,123 @@
</div> </div>
<div class="item form-group"> <div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="first-name"> Date of Expense<a style="color:red;">*</a></label> <label class="control-label col-md-1 col-sm-1 label-align" for="first-name">Expense Name<a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 "> <div class="col-md-5 col-sm-5 ">
<div class="form-group"> <div class="form-group">
<input type='text' id='ExpenseDate' class="form-control" placeholder="DD-MM-YYYY" required name="date_of_expence" value="" autocomplete='off' /> <input type='text' class="form-control" name="expense_name" value="<?php if(isset($expense_data[0]->id)){echo $expense_data[0]->expense_name; } ?>" autocomplete='off' required />
</div>
</div>
<label class="control-label col-md-1 col-sm-1 label-align" for="first-name">Business Reason</label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<input type='text' class="form-control" name="business_reason" value="<?php if(isset($expense_data[0]->id)){echo $expense_data[0]->business_reason; } ?>" autocomplete='off'/>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="x_panel">
<div class="x_title">
<!-- <ul class="nav navbar-right panel_toolbox">
<button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-info" style="font-size:small;" >Add</button>
</ul> -->
<div class="clearfix"></div>
</div><br>
<?php if(isset($expense_child_data[0]->id)) { foreach ($expense_child_data as $key => $value) { ?>
<div class="item form-group"> <div class="item form-group">
<label class="control-label col-md-2 col-sm-2 " for="first-name"> Expense Cost <a style="color:red;">*</a></label> <label class="control-label col-md-1 col-sm-1 label-align" for="first-name"> Date of Expense<a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 "> <div class="col-md-5 col-sm-5 ">
<input id="cost" name="amount" required value="<?php if(isset($assetData)) { echo $assetData->cost; } ?>" class="form-control" onkeypress = "return matchnum(event)" type="number" name="middle-name" autocomplete='off'> <div class="form-group">
<input type='date' id='ExpenseDate' class="form-control" placeholder="DD-MM-YYYY" required name="date_of_expence[]" value="<?php echo $value->date_of_expense ?>" autocomplete='off' />
</div>
<input type="hidden" name="expense_pid" value="<?php echo $expense_data[0]->id; ?>">
</div>
<label class="control-label col-md-1 col-sm-1 label-align" for="first-name"> Expense Cost <a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 ">
<input id="cost" name="amount[]" required value="<?php echo $value->amount ?>" class="form-control" onkeypress = "return matchnum(event)" type="number" name="middle-name" autocomplete='off'>
</div> </div>
</div> </div>
<div class="item form-group flex-wrap">
<div class="item form-group"> <label class="control-label col-md-1 col-sm-1 label-align" for="last-name">Description</label>
<label class="control-label col-md-2 col-sm-2 " for="last-name">Description</label>
<div class="col-md-5 col-sm-3"> <div class="col-md-5 col-sm-3">
<textarea id="comments" name="comments" value="" class="form-control" style="height:200px !important;" type="text" ></textarea> <textarea id="comments" name="description[]" value="" class="form-control" style="height:50px !important;" type="text" ><?php echo $value->description ?></textarea>
<input type="hidden" id="manager_id" name="manager" value=""> <!-- <input type="hidden" id="manager_id" name="manager" value=""> -->
</div> </div>
<label class="control-label col-md-1 col-sm-1 label-align" required for="first-name">Recipt<a style="color:red;">*</a> </label>
<div class="col-md-5 col-sm-5 ">
<input id="formFile" name="bill[]" onchange="validateFile(this)" class="typeFile" type="file" value="<?php echo $value->bill ?>" required multiple>
</div>
<div class="col-12"><button type="button" class="float-right btn btn-danger" onclick="remove_row(<?php echo $value->id ?>)" id="remove-button2"><i class="fa fa-trash"></i></button></div></div>
<?php } } else { ?>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 label-align" for="first-name"> Date of Expense<a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<input type='text' id='ExpenseDate' class="form-control" placeholder="DD-MM-YYYY" required name="date_of_expence[]" value="" autocomplete='off' />
</div>
</div>
<label class="control-label col-md-1 col-sm-1 label-align" for="first-name"> Amount <a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 ">
<input id="cost" name="amount[]" required value="" class="form-control" onkeypress = "return matchnum(event)" type="number" name="middle-name" autocomplete='off'>
</div>
</div> </div>
<div class="item form-group"> <div class="item form-group">
<label class="control-label col-md-1 col-sm-1 label-align" for="last-name">Description</label>
<div class="col-md-5 col-sm-3">
<textarea id="comments" name="description[]" value="" class="form-control" style="height:50px !important;" type="text" ></textarea>
<label class="control-label col-md-2 col-sm-2 " required for="first-name">Upload Bill </label>
<div class="col-md-5 col-sm-5 ">
<input id="formFile" name="bill" onchange="validateFile(this)" class="typeFile" type="file" value="">
</div>
</div>
<!-- <div class="item form-group">
<div class="col-md-2 col-sm-2 ">
</div> </div>
</div> -->
<!-- <div class="item form-group"> <label class="control-label col-md-1 col-sm-1 label-align" required for="first-name">Recipt<a style="color:red;">*</a></label>
<div class="col-md-5 col-sm-5 ">
<input id="formFile" name="bill[]" onchange="validateFile(this)" class="typeFile" type="file" value="" required multiple></div>
</div><div class="col-12"><button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-primary float-right">Add</button></div>
<label class="control-label col-md-2 col-sm-2 " required for="first-name"></label>
<img src="http://ssl.gstatic.com/accounts/ui/avatar_2x.png" width="100" height="100" id="uploadPreview" class="avatar img-circle img-thumbnail" style="height: 100px; width: 100px;" alt="avatar"/>
<?php } ?>
<div id="formContainer"></div>
</div> </div>
</div> -->
<div class="ln_solid"></div> <div class="ln_solid"></div>
<div class="item form-group"> <div class="item form-group">
<div class=" offset-md-8"> <div class=" offset-md-8">
<button class="btn btn-secondary" onclick="history.back()">Cancel</button> <button class="btn btn-secondary" onclick="history.back()">Cancel</button>
<button class="btn btn-primary" type="reset">Reset</button> <button type="submit" class="btn btn-primary" name="save">Save</button>
<button type="submit" class="btn btn-success">Submit</button> <?php if(isset($expense_data[0]->id)) { ?>
<button type="submit" class="btn btn-success" name="submit">Submit</button>
<button type="submit" class="btn btn-warning" name="update">Update</button>
<?php } ?>
</div> </div>
</div> </div>
@ -188,9 +223,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
</div> </div>
@ -217,36 +250,16 @@
</script> </script>
<!-- <script>
function validateFile(input) {
const file = input.files[0];
const allowedExtensions = ["jpg", "jpeg", "png", "pdf"];
const fileExtension = file.name.split(".").pop().toLowerCase();
if (!allowedExtensions.includes(fileExtension)) {
Swal.fire("Invalid file type. Only JPG, JPEG, PNG, and PDF files are allowed.");
input.value = ""; // Clear the input value
}
}
</script>
-->
<script> <script>
const datepickerInput = document.getElementById('ExpenseDate');
var dateFormat = "dd-mm-yy"; flatpickr(datepickerInput, {
var fromDateInput = $("#ExpenseDate"); dateFormat: 'd-m-Y',
console.log(fromDateInput); maxDate: new Date(),
fromDateInput.datepicker({ onChange: function(selectedDates, dateStr) {
dateFormat: dateFormat, console.log('Selected date: ', dateStr);
changeYear: true, }
changeMonth: true, });
yearRange: "1990:c",
onSelect: function (dateText, inst) {
}
});
function validateFile(input) { function validateFile(input) {
@ -255,30 +268,16 @@ function validateFile(input) {
const fileExtension = file.name.split(".").pop().toLowerCase(); const fileExtension = file.name.split(".").pop().toLowerCase();
if (!allowedExtensions.includes(fileExtension)) { if (!allowedExtensions.includes(fileExtension)) {
// Invalid file type new PNotify({
Swal.fire("Invalid file type. Only JPG, JPEG, PNG, and PDF files are allowed."); title: 'Invalid file type.',
input.value = ""; // Clear the input value text: 'Only JPG, JPEG, PNG, and PDF files are allowed.',
styling: 'bootstrap3'
});
input.value = "";
return; return;
} }
if (fileExtension === "pdf") {
// Preview PDF
const reader = new FileReader();
reader.onload = function(e) {
const pdfObject = `<embed src="${e.target.result}" width="500" height="600" type="application/pdf">`;
document.getElementById("previewContainer").innerHTML = pdfObject;
};
reader.readAsDataURL(file);
} else {
// Preview image
const reader = new FileReader();
reader.onload = function(e) {
const imageObject = `<img src="${e.target.result}" alt="Preview" width="500">`;
document.getElementById("previewContainer").innerHTML = imageObject;
};
reader.readAsDataURL(file);
}
} }
</script> </script>
@ -357,8 +356,78 @@ function matchnum(event)
}) })
</script> </script>
<script>
var i=1;
function createAndAppendFormGroup() {
var html1 = '';
i++
html1 += '<div id="removeChild'+i+'">'
html1 += '<br><div class="x_title">'+i+'</div><br>'
html1 += '<div class="item form-group">';
html1 += '<label class="control-label col-md-1 col-sm-1 label-align" for="first-name"> Date of Expense<a style="color:red;">*</a></label>';
html1 += '<div class="col-md-5 col-sm-5 "><div class="form-group"><input type="text" id="datepicker'+i+'" class="form-control date-picker" placeholder="DD-MM-YYYY" required name="date_of_expence[]" value="" autocomplete="off"/></div></div>';
html1 += '<label class="control-label col-md-1 col-sm-1 label-align" for="first-name"> Expense Cost <a style="color:red;">*</a></label>';
html1 += '<div class="col-md-5 col-sm-5 "><input id="cost" name="amount[]" required class="form-control" onkeypress="return matchnum(event)" type="number" name="middle-name" autocomplete="off"></div>';
html1 += '</div>';
html1 += '<div class="item form-group flex-wrap">'
html1 += '<label class="control-label col-md-1 col-sm-1 label-align" for="last-name">Description</label>'
html1 += '<div class="col-md-5 col-sm-3"><textarea id="comments" name="description[]" value="" class="form-control" style="height:50px !important;" type="text" ></textarea></div>'
html1 += '<label class="control-label col-md-1 col-sm-1 label-align" required for="first-name">Upload Bill </label>'
html1 += '<div class="col-md-5 col-sm-5 "><input id="formFile" name="bill[]" multiple onchange="validateFile(this)" class="typeFile" type="file" value="" required></div>'
html1 += '</div>'
html1 += '<div class="col-12"><button type="button" class="float-right btn btn-danger"" id="remove-button" onclick="removebutton('+i+')"><i class="fa fa-trash"></i></button></div><button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-primary float-right">Add</button></div>'
var formContainer = document.getElementById('formContainer');
//formContainer.innerHTML += html1;
formContainer.insertAdjacentHTML('beforeend', html1);
const datepickerInput = document.getElementById('datepicker'+i);
flatpickr(datepickerInput, {
dateFormat: 'd-m-Y',
maxDate: new Date(),
autoclose:true,
onChange: function(selectedDates, dateStr) {
console.log('Selected date: ', dateStr);
}
});
}
function removebutton(index) {
//console.log(index)
var element = document.getElementById('removeChild'+ index);
//console.log(element)
if (element) {
element.remove();
}
}
// function date(date){
// console.log('called');
// var element = document.getElementById('ExpenseDates'+ date);
// element.datepicker({
// dateFormat: "dd-mm-yy",
// changeYear: true,
// changeMonth: true,
// yearRange: "1990:c",
// maxDate: new Date(),
// autoclose: true,
// todayHighlight: true,
// });
// }
</script>
<!-- <script> <!-- <script>
function PreviewImage() { function PreviewImage() {
var oFReader = new FileReader(); var oFReader = new FileReader();
@ -369,75 +438,28 @@ function PreviewImage() {
}; };
}; };
</script> --> </script> -->
<script> <script>
function handleFiles(files) {
const dropZone = document.getElementById('drop-zone'); function remove_row(id)
const previewContainer = document.getElementById('preview-container'); {
previewContainer.innerHTML = ''; $.ajax({
for (let i = 0; i < files.length; i++) { data:{id : id},
const file = files[i]; url:"<?php echo base_url('Expence/remove_row');?>",
const reader = new FileReader(); type:"get",
success: function(response) {
if(response==true);
{
location.reload(true)
}
reader.onload = function(e) {
const previewItem = document.createElement('div');
previewItem.className = 'preview-item';
if (file.type.startsWith('image/')) {
const img = document.createElement('img');
img.src = e.target.result;
previewItem.appendChild(img);
} else if (file.type === 'application/pdf') {
const obj = document.createElement('object');
obj.data = e.target.result;
obj.type = 'application/pdf';
obj.width = '100%';
obj.height = '200';
previewItem.appendChild(obj);
} }
previewContainer.appendChild(previewItem); });
};
reader.readAsDataURL(file);
} }
dropZone.classList.remove('dragover');
}
function handleDragOver(e) {
e.preventDefault();
const dropZone = document.getElementById('drop-zone');
dropZone.classList.add('dragover');
}
function handleDragLeave(e) {
e.preventDefault();
const dropZone = document.getElementById('drop-zone');
dropZone.classList.remove('dragover');
}
function initializeDropZone() {
const dropZone = document.getElementById('drop-zone');
const fileInput = document.getElementById('file-input');
dropZone.addEventListener('dragover', handleDragOver);
dropZone.addEventListener('dragleave', handleDragLeave);
dropZone.addEventListener('drop', function(e) {
e.preventDefault();
const files = e.dataTransfer.files;
handleFiles(files);
});
fileInput.addEventListener('change', function(e) {
const files = e.target.files;
handleFiles(files);
});
}
initializeDropZone();
</script> </script>

View File

@ -1,16 +1,16 @@
<head> <head>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'> <!-- <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<style> <style>
.modal_default { .modal_default {
display: none; display: none;
position: fixed; position: fixed;
z-index: 1; /* z-index: 1;*/
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
@ -90,101 +90,135 @@
<ul class="nav navbar-right panel_toolbox"> <ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-sm btn-primary" style="margin-top: 20px;">Back</a> <a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-sm btn-primary" style="margin-top: 20px;">Back</a>
</ul> </ul>
<h1>My Approvals</h1> <h3>My Approvals</h3>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="x_content"> <div class="x_content">
<div class="row"> <div class="row">
<div class="col-sm-12" style="overflow: auto;"> <div class="col-sm-12" style="overflow: auto;">
<table id="datatables" class="table table-striped table-bordered" width="100%"> <div class="table-responsive">
<thead> <table class="table table-striped" width="100%">
<tr class="headings"> <thead>
<th hidden class="column-title">id</th> <tr class="headings">
<th class="column-title">Claim Date</th> <th hidden class="column-title">id</th>
<th class="column-title">Employee Name</th> <th class="column-title">Claim Date</th>
<th class="column-title">Description </th> <th class="column-title">Created By</th>
<th class="column-title">Expense Date</th> <th class="column-title">Requested For</th>
<th class="column-title">Expense Cost()</th> <th class="column-title">Expense Name</th>
<th class="column-title">Claim Raised By</th> <th class="column-title">Business Reason</th>
<th class="column-title">Status </th> <th class="column-title">Total Amount()</th>
<th class="column-title" >Action </th> <th class="column-title">No of List</th>
</tr> <th class="column-title">Status </th>
</thead> <th class="column-title" >Action </th>
<tbody> </tr>
<?php foreach ($tableData as $key => $value) { ?> </thead>
<tr class="even pointer"> <tbody>
<td hidden><?php echo $value->id; ?></td> <?php foreach ($tableData as $key => $value) { ?>
<td class=" "><?php echo $value->created_date; ?><br><?php echo $value->created_time;?></td>
<td class=" "><?php echo $value->name; ?> (<?php echo $value->emp_id; ?>) </td> <?php if(is_admin() || user()->id == $value->manager_id){ ?>
<td class=" "><?php echo $value->comments; ?></td>
<td class=" "><?php echo $value->date_of_expence; ?></td>
<td class=" "> <?php echo $value->amount; ?></td>
<td class=" "><?php echo $value->created_by; ?></td>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?>By <?php echo $value->approved_by; ?><br><?php echo $value->approved_at;?></td>
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"><?php echo $value->status; ?><br><?php echo $value->Dreason; ?></td>
<?php }
else if($value->status == 'canceled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?></td>
<?php }
else{
}?> <tr class="even pointer">
<td style=" text-align: center; font-size: 16px;"> <td hidden><?php echo $value->id; ?></td>
<td><?php echo date('d-m-Y', strtotime($value->updated_on));?></td>
<td class=" "><?php echo $value->created_name; ?></td>
<td class=" "><?php echo $value->requested_name; ?></td>
<td class=" "><?php echo $value->expense_name; ?></td>
<td class=" "><?php echo $value->business_reason; ?></td>
<?php foreach ($count_amount as $key => $count_value) { ?>
<?php if(!empty($value->bill)) { ?> <?php if($value->id == $count_value->id) { ?>
<a onclick="openModal('<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>')" title="ViewBill"><i class="fa fa-eye" aria-hidden="true" target="_blank"></i></a><br> <td class=" "><?php echo $count_value->amount ?></td>
<td class=" "><?php echo $count_value->count ?></td>
<?php } ?> <?php } } ?>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By <?php echo $value->approved_by; ?><br><?php echo date('d-m-Y h:i:s', strtotime($value->approved_at));?></td>
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"><?php echo $value->status; ?> by <?php echo $value->decline_by; ?> <br><?php echo $value->decline_reason; ?></td>
<?php }
else if($value->status == 'Cancelled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?> at <br><?php echo date('d-m-Y h:i:s', strtotime($value->cancelled_at));?></td>
<?php }
else if($value->status == 'Draft'){?>
<td style="color:#0000e6;"><?php echo $value->status; ?></td>
<?php } ?>
<?php if($value->status == 'pending') { ?> <td style=" text-align: center; font-size: 16px;">
<a><i class="fa fa-check approveexpense" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve Expense" id="<?php echo $value->id;?>"></i></a>&nbsp; <!-- <a href="<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>" title="ViewExpenseList"><i class="fa fa-eye" aria-hidden="true"></i></a><br> -->
<!-- <a onclick="get_expense_child_data(<?php echo $value->id;?>)" data-toggle="modal" data-target=".bs-example-modal-lg"><i class="fa fa-eye btn btn-info" aria-hidden="true" target="_blank"></i></a> -->
<a href="#"><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()"
id= "<?php echo $value->id; ?>"></i></a>&nbsp;
<?php } ?> <a href="<?php echo base_url()?>Expence/expence_list_view/<?php echo $value->id;?>"><i class="fa fa-list-alt" aria-hidden="true"title="View List"></i></a> &nbsp;
</td>
</tr>
<?php } ?> <?php if($value->status == 'pending') { ?>
</tbody>
</table> <a><i class="fa fa-check approveexpense" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()"
id= "<?php echo $value->id; ?>"></i></a>&nbsp;
<?php } ?>
</td>
</tr>
<?php } } ?>
</tbody>
</table>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="customPrompt" class="modal modal_default"> <div id="customPrompt" class="modal modal_default" style="z-index: 1060;">
<div class="modal-content modal-content_default "> <div class="modal-content modal-content_default ">
<span onclick="$('#customPrompt').hide()" style="text-align: right;"><i class="fa fa-times fa-2x" aria-hidden="true"></i></span> <span onclick="$('#customPrompt').hide()" style="text-align: right;"><i class="fa fa-times fa-2x" aria-hidden="true"></i></span>
<h3>Decline Reason</h3> <h3>Decline Reason</h3>
<input list="browsers" style="padding:20px; margin:6px;" id="decline_reason" required name="myBrowser" /> <input list="browsers" style="padding:20px; margin:6px;" id="decline_reason" required name="myBrowser" />
<datalist id="browsers" > <button onclick="submitCustomPrompt()" type="button" class="btn btn-primary">Submit</button>
<?php foreach ($dropdown as $key => $value) { ?>
<option value="<?php echo $value->enum_value; ?>"><?php echo $value->enum_value; ?></option>
<?php } ?>
</datalist>
<button onclick="submitCustomPrompt()" type="button" class="btn btn-primary">Submit</button>
</div> </div>
</div> </div>
<br/> <br/>
<!-- Large modal -->
<!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg" hidden>Large modal</button> --> <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Expense List</h4>
<button type="button" class="close" data-dismiss="modal"><span >×</span>
</button>
</div>
<div class="modal-body">
<div id="expenseTableContainer"></div>
</div>
<!-- <div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Decline All</button>
<button type="button" class="btn btn-primary">Approve All</button>
</div> -->
</div>
</div>
</div>
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div> <div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
<div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div> <div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div>
@ -219,16 +253,17 @@ function submitCustomPrompt() {
var id = $('.test').attr("id"); var id = $('.test').attr("id");
var reason = document.getElementById("decline_reason").value; var reason = document.getElementById("decline_reason").value;
console.log(id, reason);
if( reason != "") if( reason != "")
$.ajax( $.ajax({
{
data:{id : id , reason : reason }, data:{id : id , reason : reason },
url:"<?php echo base_url('Expence/Decline_expence');?>", url:"<?php echo base_url('Expence/Decline_expence/');?>",
type:"get", type:"get",
success: function(response) { success: function(response) {
console.log(response);
window.location ='<?php echo base_url('Expence/expence_list');?>'; window.location ='<?php echo base_url('Expence/expence_list');?>';
} }
@ -249,39 +284,22 @@ function submitCustomPrompt() {
<!-- JavaScript --> <!-- JavaScript -->
<script> <script>
function openModal(itemId) { function openModal(url) {
// Get the image URL for the item with the specified ID if (url.endsWith('.pdf')) {
var imageUrl = itemId; window.open(url, '_blank');
} else if (url.match(/\.(jpeg|jpg|png|gif)$/i)) {
// Set the image source of the modal // If the URL ends with .jpeg, .jpg, .png, or .gif, show the image
document.getElementById("modalImage").src = imageUrl; var img = new Image();
img.src = url;
// Open the modal var win = window.open('', '_blank');
var modal = document.getElementById("myModal"); win.document.write('<img src="' + img.src + '" alt="Image">');
modal.style.display = "block"; } else {
alert('The selected file is not a PDF or an image.');
// Close the modal when the user clicks on the close button
var closeButton = document.getElementsByClassName("close")[0];
closeButton.onclick = function() {
modal.style.display = "none";
}
}
</script>
<script>
function alert()
{
Swal.fire({
title: 'Custom animation with Animate.css',
showClass: {
popup: 'animate__animated animate__fadeInDown'
},
hideClass: {
popup: 'animate__animated animate__fadeOutUp'
}
})
} }
}
</script> </script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#datatables').DataTable({ $('#datatables').DataTable({
@ -294,6 +312,93 @@ function alert()
}); });
}); });
</script> </script>
<script>
function get_expense_child_data(id)
{
$.ajax({
data:{id : id},
url:"<?php echo base_url('Expence/expence_list2');?>",
type:"get",
success: function(response) {
response = JSON.parse(response);
var url ="<?php echo base_url(); ?>"+"assets/uploads/Expence_Bill/";
var url2 ="<?php echo base_url(); ?>"+"Expence/Approve_Child_Expence/"
var table = '<table class="table table-striped" width="100%">';
table += ' <thead><tr class="headings"><th hidden class="column-title">id</th><th class="column-title">Date of Expense</th><th class="column-title">Amount</th><th class="column-title">Description</th><th class="column-title">Status </th><th class="column-title" >Action </th></tr></thead><tbody>'
for (let i = 0; i < response.length; i++) {
const expense = response[i];
table += '<tr class="even pointer">';
table += '<td hidden>' + expense.id + '</td>';
table += '<td>' + expense.date_of_expense + '</td>';
table += '<td>' + expense.amount + '</td>';
table += '<td>' + expense.description + '</td>';
table += '<td>' + expense.status + '</td>';
table += '<td><a href="'+url+expense.bill+'" target="_blank" title="ViewBill"><i class="fa fa-eye " aria-hidden="true" ></i></a>&nbsp'
table += '<a><i class="fa fa-check " onclick="returndata('+expense.id+')" title="Approve Expense" id="' + expense.id + '"></i></a>&nbsp'
table += '<a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="returndatadecline('+expense.id+')" id= "' + expense.id + '"></i></a></td>'
}
table += '</tbody>'
table += '</table>'
$('#expenseTableContainer').html(table);
}
});
}
function returndata(id)
{
$.ajax({
data:{id : id},
url:"<?php echo base_url('Expence/Approve_Child_Expence');?>",
type:"get",
success: function(response) {
alert(response);
if(response==true);
{
location.reload(true)
}
}
});
}
function returndatadecline(id)
{
$.ajax({
data:{id : id},
url:"<?php echo base_url('Expence/Decline_Child_Expence');?>",
type:"get",
success: function(response) {
alert(response);
if(response==true);
{
location.reload(true)
}
}
});
}
</script>

View File

@ -0,0 +1,357 @@
<head>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
.modal_default {
display: none;
position: fixed;
/* z-index: 1;*/
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content_default {
background-color: #fefefe;
margin: 15% auto;s
padding: 20px;
border: 1px solid #888;
width: 380px;
height: 280px;
text-align: center;
}
button {
margin-top: 10px;
}
div.dataTables_wrapper div.dataTables_filter{
margin-top: -30px !important; //search to up
</style>
<style>
/* Modal Popup Styles */
.modal_default {
display: none; /* Hide the modal by default */
position: fixed;
/* z-index: 1;*/
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.9);
}
.modal_default img {
display: block;
margin: 0 auto;
max-width: 80%;
max-height: 100%;
margin-top: 5%;
margin-bottom: 5%;
}
.close {
color: #fff;
font-size: 40px;
font-weight: bold;
position: absolute;
top: 10px;
right: 20px;
cursor: pointer;
}
.modal-content_default {
background-color: #fefefe;
margin: 15% auto;
padding: 30px;
border: 1px solid #888;
width: 380px;
height: 280px;
text-align: center;
}
</style>
</head>
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title">
<ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Expence/expence_list" class="btn btn-sm btn-primary" style="margin-top: 20px;">Back</a>
</ul>
<h3>Expense Approval List </h3>
<div class="clearfix"></div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">Created by</label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<input readonly type='text' class="form-control" name="expense_name" value="<?php if(isset($expense_name[0]->id)){echo $expense_name[0]->created_name; } ?>" autocomplete='off' required />
</div>
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Requested For</label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<input readonly type='text' class="form-control" name="business_reason" value="<?php if(isset($expense_name[0]->id)){echo $expense_name[0]->requested_name; } ?>" autocomplete='off'/>
</div>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">Expense Name</label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<input readonly type='text' class="form-control" name="expense_name" value="<?php if(isset($expense_name[0]->id)){echo $expense_name[0]->expense_name; } ?>" autocomplete='off' required />
</div>
</div>
<input type="hidden" id="expense_id" name="expense_pid" value="<?php echo $expense_name[0]->id; ?>">
<label class="control-label col-md-1 col-sm-1 " for="first-name">Business Reason</label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<input readonly type='text' class="form-control" name="business_reason" value="<?php if(isset($expense_name[0]->id)){echo $expense_name[0]->business_reason; } ?>" autocomplete='off'/>
</div>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 " for="first-name">Status</label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<input readonly type='text' class="form-control" name="expense_name" value="<?php if(isset($expense_name[0]->id))
{
if($expense_name[0]->status == "Approved")
{
echo $expense_name[0]->status .' By '. $expense_name[0]->approved_by .' - '. date('d-m-Y h:i:s', strtotime($expense_name[0]->approved_at));
}
else if($expense_name[0]->status == "Declined")
{
echo $expense_name[0]->status .' By '. $expense_name[0]->decline_by;
}
else
{
echo $expense_name[0]->status;
}
}
?>"
autocomplete='off' required />
</div>
</div>
<label class="control-label col-md-1 col-sm-1 " for="first-name">Submitted Date</label>
<div class="col-md-5 col-sm-5 ">
<div class="form-group">
<input readonly type='text' class="form-control" name="business_reason" value="<?php if(isset($expense_name[0]->id)){echo date('d-m-Y h:i:s', strtotime($expense_name[0]->updated_on)); } ?>" autocomplete='off'/>
</div>
</div>
</div>
</div>
</div>
<div class="x_content">
<div class="row">
<div class="col-sm-12" style="overflow: auto;">
<table class="table table-striped" width="100%">
<thead>
<tr class="headings">
<th hidden class="column-title">id</th>
<th class="column-title">Claim Date</th>
<th class="column-title">Date of Expense</th>
<th class="column-title">Amount</th>
<th class="column-title">Description</th>
<th class="column-title">Status </th>
<th class="column-title" >Action </th>
</tr>
</thead>
<tbody>
<?php foreach ($tableData as $key => $value) { ?>
<tr class="even pointer">
<td hidden><?php echo $value->id; ?></td>
<td><?php echo date('d-m-Y', strtotime($value->created_on));?></td>
<td class=" "><?php echo date('d-m-Y', strtotime($value->date_of_expense)) ?></td>
<td class=" "><?php echo $value->amount; ?></td>
<td class=" "><?php echo $value->description; ?></td>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By <?php echo $value->approved_by; ?><br><?php echo date('d-m-Y h:i:s', strtotime($value->approved_at)) ?></td>
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"><?php echo $value->status; ?> by <?php echo $value->decline_by; ?> <br><?php echo $value->decline_reason; ?></td>
<?php }
else if($value->status == 'Cancelled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?> at <br><?php echo $value->cancelled_at; ?></td>
<?php }
else if($value->status == 'Draft'){?>
<td style="color:#0000e6;"><?php echo $value->status; ?></td>
<?php } ?>
<td style=" text-align: center; font-size: 16px;">
<a onclick="openModal('<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>')" title="ViewBill"><i class="fa fa-eye" aria-hidden="true"></i></a><br>
<?php if($value->status == 'pending') { ?>
<a><i class="fa fa-check approveexpense" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()"
id= "<?php echo $value->id; ?>"></i></a>&nbsp;
<?php } ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div id="customPrompt" class="modal modal_default" style="z-index: 1060;">
<div class="modal-content modal-content_default ">
<span onclick="$('#customPrompt').hide()" style="text-align: right;"><i class="fa fa-times fa-2x" aria-hidden="true"></i></span>
<h3>Decline Reason</h3>
<input list="browsers" style="padding:20px; margin:6px;" id="decline_reason" required name="myBrowser" />
<button onclick="submitCustomPrompt()" type="button" class="btn btn-primary">Submit</button>
</div>
</div>
<br/>
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
<div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div>
<div style="display:none" id="sub-value">
<script>
$('.approveexpense').click(function() {
var id = $(this).attr('id');
var expence_id = document.getElementById('expense_id').value;
var url = "<?php echo base_url()?>Expence/Approve_Child_Expence";
$.ajax({
url: "<?php echo base_url()?>Expence/getDeleteConfirmationPopup",
type:"GET",
success:function(data){
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value',id);
$('.expence_id').attr('value',expence_id);
$('.delete_url').attr('action',url);
}
});
});
</script>
<script>
function showCustomPrompt() {
var customPrompt = document.getElementById("customPrompt");
customPrompt.style.display = "block";
}
function submitCustomPrompt() {
var id = $('.test').attr("id");
var reason = document.getElementById("decline_reason").value;
var expence_id = document.getElementById('expense_id').value;
if( reason != "")
$.ajax({
data:{id : id , reason : reason },
url:"<?php echo base_url('Expence/Decline_Child_Expence');?>",
type:"get",
success: function(response) {
console.log(response);
window.location ="<?php echo base_url()?>Expence/expence_list_view/"+expence_id;
}
});
else
alert('Decline Reason is required');
}
</script>
</div>
<div id="myModal" class="modal modal_default">
<span class="close">&times;</span>
<img id="modalImage" src="" alt="Image">
</div>
<!-- JavaScript -->
<script>
function openModal(url) {
if (url.endsWith('.pdf')) {
window.open(url, '_blank');
} else if (url.match(/\.(jpeg|jpg|png|gif)$/i)) {
// If the URL ends with .jpeg, .jpg, .png, or .gif, show the image
var img = new Image();
img.src = url;
var win = window.open('', '_blank');
win.document.write('<img src="' + img.src + '" alt="Image">');
} else {
alert('The selected file is not a PDF or an image.');
}
}
</script>
<script>
$(document).ready(function() {
$('#datatables').DataTable({
"order": [[0, 'desc']], // Set initial sorting to descending on the first column
"dom": 'Bfrtip', // Show export buttons
"buttons": [ 'excel', 'pdf'], // Enable export options
"language": {
"search": "Search: " // Customize search label
}
});
});
</script>
</div>

View File

@ -1,17 +1,17 @@
<head> <head>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'> <!-- <link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<style> <style>
.modal_default { .modal_default {
display: none; display: none;
position: fixed; position: fixed;
z-index: 1; /* z-index: 1;*/
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
@ -83,163 +83,134 @@
} }
</style> </style>
</head> </head>
<div class="col-md-12 col-sm-12 "> <div class="col-md-12 col-sm-12 ">
<div class="x_panel"> <div class="x_panel">
<div class="x_title"> <div class="x_title">
<ul class="nav navbar-right panel_toolbox current-page"> <ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-primary current-page" style="margin-top: 20px;">Back</a> <a href="<?php echo base_url();?>Expence/emp_expence_list" class="btn btn-sm btn-primary" style="margin-top: 20px;">Back</a>
</ul> </ul>
<h1>My Approvals</h1> <h3>My Approvals</h3>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="x_content"> <div class="x_content">
<div class="row"> <div class="row">
<div class="col-sm-12" style="overflow: auto;"> <div class="col-sm-12" style="overflow: auto;">
<table id="datatables" class="table table-striped table-bordered" width="100%"> <table class="table table-striped" width="100%">
<thead> <thead>
<tr class="headings"> <tr class="headings">
<th hidden class="column-title">id</th> <th hidden class="column-title">id</th>
<th class="column-title">Claim Date</th> <th class="column-title">Claim Date</th>
<th class="column-title">Employee Name</th> <th class="column-title">Created By</th>
<th class="column-title">Description </th> <th class="column-title">Requested For</th>
<th class="column-title">Expense Date</th> <th class="column-title">Expense Name</th>
<th class="column-title">Expense Cost()</th> <th class="column-title">Business Reason</th>
<th class="column-title">Claim Raised By</th> <!-- <th class="column-title">Expense Cost()</th>
<th class="column-title">Status </th> <th class="column-title">Claim Raised By</th> -->
<th class="column-title" >Action </th> <th class="column-title">Status </th>
</tr> <th class="column-title" >Action </th>
</thead> </tr>
<tbody> </thead>
<tbody>
<?php foreach ($tableData as $key => $value) { ?>
<?php if(user()->id == $value->manager_id){ ?>
<?php foreach ($tableData as $key => $value) { ?> <tr class="even pointer">
<td hidden><?php echo $value->id; ?></td>
<?php if(user()->id == $value->manager){ ?> <td><?php echo date('d-m-Y', strtotime($value->created_on));?>
<td class=" "><?php echo $value->created_name; ?></td>
<td class=" "><?php echo $value->requested_name; ?></td>
<td class=" "><?php echo $value->expense_name; ?></td>
<td class=" "><?php echo $value->business_reason; ?></td>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By <?php echo $value->approved_by; ?><br><?php echo $value->approved_at;?></td>
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"><?php echo $value->status; ?> by <?php echo $value->decline_by; ?><br><?php echo $value->decline_reason; ?></td>
<?php }
else if($value->status == 'Cancelled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?> at <br><?php echo $value->cancelled_at; ?></td>
<?php }
else if($value->status == 'Draft'){?>
<td style="color:#0000e6;"><?php echo $value->status; ?></td>
<?php } ?>
<tr class="even pointer"> <td style=" text-align: center; font-size: 16px;">
<td hidden><?php echo $value->id; ?></td>
<td class=" "><?php echo $value->created_date; ?><br><?php echo $value->created_time;?></td>
<td class=" "><?php echo $value->name; ?> (<?php echo $value->emp_id; ?>)</td>
<td class=" "><?php echo $value->comments; ?></td>
<td class=" "><?php echo $value->date_of_expence; ?></td>
<td class=" "> <?php echo $value->amount; ?></td>
<td class=" "><?php echo $value->created_by; ?></td>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By <?php echo $value->approved_by; ?><br><?php echo $value->approved_at;?></td>
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"> <?php echo $value->status; ?><br><?php echo $value->Dreason; ?></td>
<?php }
else if($value->status == 'canceled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?></td>
<?php }
else{
}?> <!-- <a href="<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>" title="ViewExpenseList"><i class="fa fa-eye" aria-hidden="true"></i></a><br> -->
<td style=" text-align: center; font-size: 16px;">
<!-- <a onclick="get_expense_child_data(<?php echo $value->id;?>)" data-toggle="modal" data-target=".bs-example-modal-lg"><i class="fa fa-eye btn btn-info" aria-hidden="true" target="_blank"></i></a> -->
<?php if(!empty($value->bill)) { ?>
<a href="<?php echo base_url()?>Expence/expence_list_view/<?php echo $value->id;?>"><i class="fa fa-list-alt" aria-hidden="true"title="View List"></i></a> &nbsp;
<a onclick="openModal('<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>')" title="ViewBill"><i class="fa fa-eye" aria-hidden="true"></i></a><br> <?php if($value->status == 'pending') { ?>
<?php } ?>
<?php if($value->status == 'pending') { ?> <a><i class="fa fa-check approveexpense" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a><i class="fa fa-check approveexpense" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve Expense" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()"
id= "<?php echo $value->id; ?>"></i></a>&nbsp;
<?php } ?>
<a href="#"><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()" </td>
id= "<?php echo $value->id; ?>"></i></a>&nbsp; </tr>
<?php } } ?>
<?php } ?> </tbody>
</table>
</td>
</tr>
<?php } ?>
<?php foreach ($get_delegation as $key => $val) { ?>
<?php if(user()->id == $val->delegated_to && date('d-m-Y') >= $val->from_date && date('d-m-Y') <= $val->to_date && $value->created_date >= $val->from_date && $value->created_date <= $val->to_date) { ?>
<tr class="even pointer">
<td hidden><?php echo $value->id; ?></td>
<td class=" "><?php echo $value->created_date; ?><br><?php echo $value->created_time;?></td>
<td class=" "><?php echo $value->name; ?> (<?php echo $value->emp_id; ?>)</td>
<td class=" "><?php echo $value->comments; ?></td>
<td class=" "><?php echo $value->date_of_expence; ?></td>
<td class=" "> <?php echo $value->amount; ?></td>
<td class=" "><?php echo $value->created_by; ?></td>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php }
else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By <?php echo $value->approved_by; ?><br><?php echo $value->approved_at;?></td>
<?php }
else if($value->status == 'Declined'){ ?>
<td style="color:red"> <?php echo $value->status; ?><br><?php echo $value->Dreason; ?></td>
<?php }
else if($value->status == 'canceled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?></td>
<?php }
else{
}?>
<td style=" text-align: center; font-size: 16px;">
<?php if(!empty($value->bill)) { ?>
<a onclick="openModal('<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>')" title="ViewBill"><i class="fa fa-eye" aria-hidden="true"></i></a><br>
<?php } ?>
<?php if($value->status == 'pending') { ?>
<a><i class="fa fa-check approveexpense" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve Expense" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a href="#"><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()"
id= "<?php echo $value->id; ?>"></i></a>&nbsp;
<?php } ?>
</td>
</tr>
<?php } } }?>
</tbody>
</table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="customPrompt" class="modal modal_default"> <div id="customPrompt" class="modal modal_default" style="z-index: 1060;">
<div class="modal-content modal-content_default"> <div class="modal-content modal-content_default ">
<span onclick="$('#customPrompt').hide()" style="text-align: right;"><i class="fa fa-times fa-2x" aria-hidden="true"></i></span> <span onclick="$('#customPrompt').hide()" style="text-align: right;"><i class="fa fa-times fa-2x" aria-hidden="true"></i></span>
<h3>Decline Reason</h3> <h3>Decline Reason</h3>
<input list="browsers" style="padding:20px; margin:6px;" id="decline_reason" required name="myBrowser" /> <input list="browsers" style="padding:20px; margin:6px;" id="decline_reason" required name="myBrowser" />
<datalist id="browsers" > <button onclick="submitCustomPrompt()" type="button" class="btn btn-primary">Submit</button>
<?php foreach ($dropdown as $key => $value) { ?>
<option value="<?php echo $value->enum_value; ?>"><?php echo $value->enum_value; ?></option>
<?php } ?>
</datalist>
<button onclick="submitCustomPrompt()" type="button" class="btn btn-primary">Submit</button>
</div> </div>
</div> </div>
<br/> <br/>
<!-- Large modal -->
<!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg" hidden>Large modal</button> --> <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Expense List</h4>
<button type="button" class="close" data-dismiss="modal"><span >×</span>
</button>
</div>
<div class="modal-body">
<div id="expenseTableContainer"></div>
</div>
<!-- <div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Decline All</button>
<button type="button" class="btn btn-primary">Approve All</button>
</div> -->
</div>
</div>
</div>
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div> <div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
<div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div> <div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div>
@ -274,16 +245,17 @@ function submitCustomPrompt() {
var id = $('.test').attr("id"); var id = $('.test').attr("id");
var reason = document.getElementById("decline_reason").value; var reason = document.getElementById("decline_reason").value;
console.log(id, reason);
if( reason != "") if( reason != "")
$.ajax( $.ajax({
{
data:{id : id , reason : reason }, data:{id : id , reason : reason },
url:"<?php echo base_url('Expence/Decline_expence');?>", url:"<?php echo base_url('Expence/Decline_expence/');?>",
type:"get", type:"get",
success: function(response) { success: function(response) {
console.log(response);
window.location ='<?php echo base_url('Expence/expence_list');?>'; window.location ='<?php echo base_url('Expence/expence_list');?>';
} }
@ -296,6 +268,7 @@ function submitCustomPrompt() {
</script> </script>
</div> </div>
<div id="myModal" class="modal modal_default"> <div id="myModal" class="modal modal_default">
<span class="close">&times;</span> <span class="close">&times;</span>
<img id="modalImage" src="" alt="Image"> <img id="modalImage" src="" alt="Image">
@ -303,19 +276,22 @@ function submitCustomPrompt() {
<!-- JavaScript --> <!-- JavaScript -->
<script> <script>
function openModal(itemId) { function openModal(url) {
if (url.endsWith('.pdf')) {
var imageUrl = itemId; window.open(url, '_blank');
document.getElementById("modalImage").src = imageUrl; } else if (url.match(/\.(jpeg|jpg|png|gif)$/i)) {
var modal = document.getElementById("myModal"); // If the URL ends with .jpeg, .jpg, .png, or .gif, show the image
modal.style.display = "block"; var img = new Image();
var closeButton = document.getElementsByClassName("close")[0]; img.src = url;
closeButton.onclick = function() var win = window.open('', '_blank');
{ win.document.write('<img src="' + img.src + '" alt="Image">');
modal.style.display = "none"; } else {
} alert('The selected file is not a PDF or an image.');
} }
}
</script> </script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {
$('#datatables').DataTable({ $('#datatables').DataTable({
@ -328,6 +304,96 @@ function openModal(itemId) {
}); });
}); });
</script> </script>
<script>
function get_expense_child_data(id)
{
$.ajax({
data:{id : id},
url:"<?php echo base_url('Expence/expence_list2');?>",
type:"get",
success: function(response) {
response = JSON.parse(response);
var url ="<?php echo base_url(); ?>"+"assets/uploads/Expence_Bill/";
var url2 ="<?php echo base_url(); ?>"+"Expence/Approve_Child_Expence/"
var table = '<table class="table table-striped" width="100%">';
table += ' <thead><tr class="headings"><th hidden class="column-title">id</th><th class="column-title">Date of Expense</th><th class="column-title">Amount</th><th class="column-title">Description</th><th class="column-title">Status </th><th class="column-title" >Action </th></tr></thead><tbody>'
for (let i = 0; i < response.length; i++) {
const expense = response[i];
table += '<tr class="even pointer">';
table += '<td hidden>' + expense.id + '</td>';
table += '<td>' + expense.date_of_expense + '</td>';
table += '<td>' + expense.amount + '</td>';
table += '<td>' + expense.description + '</td>';
table += '<td>' + expense.status + '</td>';
table += '<td><a href="'+url+expense.bill+'" target="_blank" title="ViewBill"><i class="fa fa-eye " aria-hidden="true" ></i></a>&nbsp'
table += '<a><i class="fa fa-check " onclick="returndata('+expense.id+')" title="Approve Expense" id="' + expense.id + '"></i></a>&nbsp'
table += '<a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="returndatadecline('+expense.id+')" id= "' + expense.id + '"></i></a></td>'
}
table += '</tbody>'
table += '</table>'
$('#expenseTableContainer').html(table);
}
});
}
function returndata(id)
{
$.ajax({
data:{id : id},
url:"<?php echo base_url('Expence/Approve_Child_Expence');?>",
type:"get",
success: function(response) {
alert(response);
if(response==true);
{
location.reload(true)
}
}
});
}
function returndatadecline(id)
{
$.ajax({
data:{id : id},
url:"<?php echo base_url('Expence/Decline_Child_Expence');?>",
type:"get",
success: function(response) {
alert(response);
if(response==true);
{
location.reload(true)
}
}
});
}
</script>

View File

@ -1,7 +1,7 @@
<!-- Footer code --> <!-- Footer code -->
<footer > <footer >
<div class="pull-right"> <div class="pull-right">
<?php if(check_auth() && is_admin() || is_user()){echo $business->business_name;}else{echo $settings->site_name;}?> <?php if(check_auth() && is_admin() || is_user() || !is_null(is_user())) {echo $business->business_name;}else{echo $settings->site_name;}?>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
</footer> </footer>

View File

@ -111,7 +111,7 @@
<li><a href="<?php echo base_url();?>Expence/expence_form">New Claim</a></li> <li><a href="<?php echo base_url();?>Expence/expence_form">New Claim</a></li>
<li><a href="<?php echo base_url();?>Expence/manager_approvel_list">My Approvals</a></li> <li><a href="<?php echo base_url();?>Expence/expence_list">My Approvals</a></li>
</ul> </ul>
</li> </li>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB