Expense issues fixes : ps
This commit is contained in:
parent
a19d955513
commit
c9f450541a
@ -162,127 +162,108 @@ public function edit_expence($id)
|
|||||||
|
|
||||||
public function edit_rise_expence_request()
|
public function edit_rise_expence_request()
|
||||||
{
|
{
|
||||||
|
// Expense primary key
|
||||||
$id = $this->input->post('expense_pid');
|
$id = $this->input->post('expense_pid');
|
||||||
$data = $this->input->post('emp_id');
|
|
||||||
if(!empty($data)){
|
|
||||||
$emp_id =$this->input->post('emp_id');
|
|
||||||
}else{
|
|
||||||
$emp_id = user()->id;
|
|
||||||
}
|
|
||||||
$get_manager_id = $this->Expence_model->get_manager_id($emp_id);
|
|
||||||
|
|
||||||
if($get_manager_id[0]->manager == null){
|
// Employee id
|
||||||
|
$emp_id = (!empty($this->input->post('emp_id'))) ? $this->input->post('emp_id') : user()->id;
|
||||||
|
|
||||||
$manager = 0;
|
// Manager id
|
||||||
}else{
|
$manager = $this->Expence_model->get_manager_id($emp_id);
|
||||||
|
$manager_id = (!empty($manager)) ? $manager[0]->manager : 0;
|
||||||
|
|
||||||
$manager = $get_manager_id[0]->manager;
|
// Table Name Declarations
|
||||||
}
|
$expense_master_table = "expense";
|
||||||
|
$expense_child_table = "expense_child";
|
||||||
|
|
||||||
|
// Array formation for updating the master details
|
||||||
$data1 = array(
|
$expense_master_arr = array(
|
||||||
'created_by' => user()->id,
|
'created_by' => user()->id,
|
||||||
'requested_for' => $emp_id,
|
'requested_for' => $emp_id,
|
||||||
'expense_name' => $this->input->post('expense_name'),
|
'expense_name' => $this->input->post('expense_name'),
|
||||||
'business_reason' => $this->input->post('business_reason'),
|
'business_reason' => $this->input->post('business_reason'),
|
||||||
'manager_id' => $manager,
|
'manager_id' => $manager_id,
|
||||||
'business_id' => user()->business_id,
|
'business_id' => user()->business_id,
|
||||||
'status' => 'Draft',
|
'status' => 'Draft',
|
||||||
);
|
);
|
||||||
$table="expense";
|
|
||||||
$create_Expence = $this->MY_Model->edit_option($data1, $id, $table);
|
|
||||||
|
|
||||||
$count = count($this->input->post('date_of_expence'));
|
// Update process for master
|
||||||
for($i=0;$i<$count;$i++)
|
$update_expense = $this->MY_Model->edit_option($expense_master_arr, $id, $expense_master_table);
|
||||||
{
|
log_message('info', "update_expense_master - expense_id => ".$id." is updated == ".$update_expense);
|
||||||
|
$first = $this->input->post('date_of_expence_new');
|
||||||
|
$count = (gettype($first) == 'array') ? count($first) : 0;
|
||||||
|
if ($count > 0) {
|
||||||
|
for ($i = 0; $i < $count; $i++) {
|
||||||
$expense_child_id = $this->input->post('expense_child_id')[$i];
|
$expense_child_id = $this->input->post('expense_child_id')[$i];
|
||||||
$data2 = array(
|
$first_child = array(
|
||||||
'date_of_expense'=> $this->input->post('date_of_expence')[$i],
|
'date_of_expense' => $this->input->post('date_of_expence_new')[$i],
|
||||||
'amount' => $this->input->post('amount')[$i],
|
'amount' => $this->input->post('amount')[$i],
|
||||||
'description' => $this->input->post('description')[$i],
|
'description' => $this->input->post('description')[$i],
|
||||||
);
|
);
|
||||||
$this->load->library('upload');
|
|
||||||
|
|
||||||
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
|
$update_expense_list = $this->MY_Model->edit_option($first_child, $expense_child_id, $expense_child_table);
|
||||||
$config['allowed_types'] = 'jpg|png|jpeg|pdf';
|
log_message('info', "update_expense_list - expense_id => ".$id." is updated == ".$update_expense_list);
|
||||||
$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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Details gathering from JavaScript new entries
|
||||||
$table="expense_child";
|
$second = $this->input->post('date_of_expence2');
|
||||||
$update_expence_list = $this->MY_Model->edit_option($data2, $expense_child_id, $table);
|
$additional_count = (gettype($second) == 'array') ? count($second) : 0;
|
||||||
|
if ($additional_count > 0) {
|
||||||
}
|
for ($j = 0; $j < $additional_count; $j++) {
|
||||||
|
$second_child = array(
|
||||||
if($this->input->post('date_of_expence2'))
|
'expense_id' => $id,
|
||||||
{
|
|
||||||
|
|
||||||
$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,
|
'emp_id' => $emp_id,
|
||||||
'business_id' => user()->business_id,
|
'business_id' => user()->business_id,
|
||||||
'manager_id' => $manager,
|
'manager_id' => $manager_id,
|
||||||
'status' => 'Draft',
|
'status' => 'Draft',
|
||||||
'date_of_expense'=> $this->input->post('date_of_expence2')[$i],
|
'date_of_expense' => $this->input->post('date_of_expence2')[$j],
|
||||||
'amount' => $this->input->post('amount2')[$i],
|
'amount' => $this->input->post('amount2')[$j],
|
||||||
'description' => $this->input->post('description2')[$i],
|
'description' => $this->input->post('description2')[$j],
|
||||||
);
|
);
|
||||||
$this->load->library('upload');
|
if (!empty($_FILES['bill2']['name'][$j])) {
|
||||||
|
$upload_result = $this->upload_file($_FILES['bill2'], $j);
|
||||||
$config['upload_path'] = APPPATH. '../assets/uploads/Expence_Bill/';
|
if ($upload_result['success']) {
|
||||||
$config['allowed_types'] = 'jpg|png|jpeg|pdf';
|
$second_child['bill'] = $upload_result['file_name'];
|
||||||
$config['max_size'] = 80000;
|
} else {
|
||||||
$config['file_name'] = time(). '_' . $_FILES['bill2']['name'][$i];
|
log_message('error', $upload_result['error']);
|
||||||
|
|
||||||
$_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();
|
|
||||||
}
|
}
|
||||||
|
$create_expense_list = $this->MY_Model->insert($second_child, $expense_child_table);
|
||||||
$table="expense_child";
|
log_message('info', "create_expense_list - expense_id => ".$id." is created == ".$create_expense_list);
|
||||||
$create_expence_list = $this->MY_Model->insert($data2,$table);
|
|
||||||
//print_r($this->db->last_query()); die;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
redirect('Expence/Emp_Expence_List');
|
redirect('Expence/Emp_Expence_List');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function upload_file($file_data, $index)
|
||||||
|
{
|
||||||
|
$this->load->library('upload');
|
||||||
|
|
||||||
|
$config['upload_path'] = APPPATH . '../assets/uploads/Expense_Bill/';
|
||||||
|
$config['allowed_types'] = 'jpg|png|jpeg|pdf';
|
||||||
|
$config['max_size'] = 80000;
|
||||||
|
$config['file_name'] = time() . '_' . $file_data['name'][$index];
|
||||||
|
|
||||||
|
$_FILES['userfile']['name'] = $file_data['name'][$index];
|
||||||
|
$_FILES['userfile']['type'] = $file_data['type'][$index];
|
||||||
|
$_FILES['userfile']['tmp_name'] = $file_data['tmp_name'][$index];
|
||||||
|
$_FILES['userfile']['error'] = $file_data['error'][$index];
|
||||||
|
$_FILES['userfile']['size'] = $file_data['size'][$index];
|
||||||
|
|
||||||
|
$this->upload->initialize($config);
|
||||||
|
|
||||||
|
if ($this->upload->do_upload('userfile')) {
|
||||||
|
$upload_data = $this->upload->data();
|
||||||
|
return array('success' => true, 'file_name' => $upload_data['file_name']);
|
||||||
|
} else {
|
||||||
|
$error = $this->upload->display_errors();
|
||||||
|
return array('success' => false, 'error' => $error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function expence_list()
|
public function expence_list()
|
||||||
{
|
{
|
||||||
$business_id = user()->business_id;
|
$business_id = user()->business_id;
|
||||||
@ -504,7 +485,7 @@ public function cancled_expence()
|
|||||||
|
|
||||||
public function remove_row()
|
public function remove_row()
|
||||||
{
|
{
|
||||||
$get_count_from_child = $this->Expence_model->get_expense_child_data(md5($this->input->post('expence_id')));
|
$get_count_from_child = $this->Expence_model->get_expense_child_data2($this->input->post('expence_id'));
|
||||||
$count = count($get_count_from_child);
|
$count = count($get_count_from_child);
|
||||||
if($count === 1)
|
if($count === 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -63,7 +63,6 @@
|
|||||||
a:hover {
|
a:hover {
|
||||||
background-color: skyblue;
|
background-color: skyblue;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
@ -81,12 +80,10 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
if($('#error').val() == 1 )
|
if ($('#error').val() == 1) {
|
||||||
{
|
|
||||||
$('#button').click();
|
$('#button').click();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul class="nav navbar-right panel_toolbox">
|
<ul class="nav navbar-right panel_toolbox">
|
||||||
@ -97,9 +94,13 @@
|
|||||||
|
|
||||||
<?php if ($expense_data[0]->status == 'Draft') { ?>
|
<?php if ($expense_data[0]->status == 'Draft') { ?>
|
||||||
|
|
||||||
Edit Expense - <?php if(isset($expense_data[0]->id)){echo $expense_data[0]->expense_name; } ?>
|
Edit Expense - <?php if (isset($expense_data[0]->id)) {
|
||||||
|
echo $expense_data[0]->expense_name;
|
||||||
|
} ?>
|
||||||
|
|
||||||
<?php } else { echo $expense_data[0]->expense_name; } ?>
|
<?php } else {
|
||||||
|
echo $expense_data[0]->expense_name;
|
||||||
|
} ?>
|
||||||
|
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
@ -136,7 +137,9 @@
|
|||||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Expense Name<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' class="form-control" name="expense_name" value="<?php if(isset($expense_data[0]->id)){echo $expense_data[0]->expense_name; } ?>" autocomplete='off' required />
|
<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>
|
||||||
|
|
||||||
@ -145,7 +148,9 @@
|
|||||||
<label class="control-label col-md-1 col-sm-1 " for="first-name">Business Reason</label>
|
<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="col-md-5 col-sm-5 ">
|
||||||
<div class="form-group">
|
<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='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; ?>">
|
<input type="hidden" id="expense_id" name="expense_pid" value="<?php echo $expense_data[0]->id; ?>">
|
||||||
|
|
||||||
@ -165,26 +170,20 @@
|
|||||||
</div><br>
|
</div><br>
|
||||||
|
|
||||||
|
|
||||||
<?php $i=1; foreach ($expense_child_data as $key => $value) { ?>
|
<?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-1 col-sm-1 " for="first-name">Status</label>
|
<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="col-md-5 col-sm-5">
|
||||||
<input id="cost" class="form-control" readonly name="middle-name" autocomplete='off' value="
|
<input id="cost" class="form-control" readonly name="middle-name" autocomplete='off' value="
|
||||||
<?php if($value->status == "Approved")
|
<?php if ($value->status == "Approved") {
|
||||||
{
|
|
||||||
echo $value->status . ' By ' . $value->approved_by . ' - ' . date('d-m-Y h:i:s', strtotime($value->approved_at));
|
echo $value->status . ' By ' . $value->approved_by . ' - ' . date('d-m-Y h:i:s', strtotime($value->approved_at));
|
||||||
}
|
} else if ($value->status == "Declined") {
|
||||||
else if($value->status == "Declined")
|
|
||||||
{
|
|
||||||
echo $value->status . ' By ' . $value->decline_by . ' ( ' . $value->decline_reason . ' )';
|
echo $value->status . ' By ' . $value->decline_by . ' ( ' . $value->decline_reason . ' )';
|
||||||
}
|
} else if ($value->status == "Cancelled") {
|
||||||
else if($value->status == "Cancelled")
|
|
||||||
{
|
|
||||||
echo $value->status . ' at ' . date('d-m-Y h:i:s', strtotime($value->cancelled_at));
|
echo $value->status . ' at ' . date('d-m-Y h:i:s', strtotime($value->cancelled_at));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
echo $value->status;
|
echo $value->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,11 +229,12 @@
|
|||||||
<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" value="<?php echo $value->bill ?>" multiple><br>
|
<input id="formFile" name="bill[]" onchange="validateFile(this)" class="typeFile" type="file" value="<?php echo $value->bill ?>" multiple><br>
|
||||||
|
|
||||||
<a href="<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>" target="_blank" class="float-right" style="font-size: x-small; color: darkblue; margin-top: 7px;"><b>View Recipt(<?php echo $value->bill; ?>)</b></a></div>
|
<a href="<?php echo base_url(); ?>assets/uploads/Expence_Bill/<?php echo $value->bill; ?>" target="_blank" class="float-right" style="font-size: x-small; color: darkblue; margin-top: 7px;"><b>View Recipt(<?php echo $value->bill; ?>)</b></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php if ($expense_data[0]->status == 'Draft') { ?>
|
<?php if ($expense_data[0]->status == 'Draft') { ?>
|
||||||
|
|
||||||
<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>
|
<div class="col-12"><?php if($i > 1){ ?><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> <?php } ?>
|
||||||
|
|
||||||
<button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-primary float-right">Add</button>
|
<button type="button" id="add-button" onclick="createAndAppendFormGroup()" class="btn btn-primary float-right">Add</button>
|
||||||
|
|
||||||
@ -245,7 +245,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
flatpickr($('#ExpenseDate' + <?php echo $i; ?>), {
|
flatpickr($('#ExpenseDate' + <?php echo $i; ?>), {
|
||||||
dateFormat: 'd-m-Y',
|
dateFormat: 'd-m-Y',
|
||||||
changeYear: true,
|
changeYear: true,
|
||||||
@ -259,11 +258,11 @@
|
|||||||
instance._input.removeAttribute("readonly");
|
instance._input.removeAttribute("readonly");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<?php $i++; } ?>
|
<?php $i++;
|
||||||
|
} ?>
|
||||||
|
|
||||||
<div id="formContainer"></div>
|
<div id="formContainer"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -300,7 +299,6 @@
|
|||||||
<!-- /Body page content -->
|
<!-- /Body page content -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
// hide the dropdown arrow
|
// hide the dropdown arrow
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -316,12 +314,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
// $()
|
// $()
|
||||||
|
|
||||||
// $('.date').on('click', function() {
|
// $('.date').on('click', function() {
|
||||||
@ -358,15 +354,12 @@ function validateFile(input) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
function matchnum(event) {
|
||||||
function matchnum(event)
|
|
||||||
{
|
|
||||||
var charcode;
|
var charcode;
|
||||||
|
|
||||||
charcode = event.which || event.keyCode;
|
charcode = event.which || event.keyCode;
|
||||||
@ -421,11 +414,9 @@ function matchnum(event)
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
//get manager id from the dropdown employee assign the value to $("#manager_id") input field
|
//get manager id from the dropdown employee assign the value to $("#manager_id") input field
|
||||||
|
|
||||||
$("#user_dropdown").on("change", function() {
|
$("#user_dropdown").on("change", function() {
|
||||||
@ -441,6 +432,7 @@ function matchnum(event)
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
var i = 1;
|
var i = 1;
|
||||||
|
|
||||||
function createAndAppendFormGroup() {
|
function createAndAppendFormGroup() {
|
||||||
var html1 = '';
|
var html1 = '';
|
||||||
i++
|
i++
|
||||||
@ -461,7 +453,7 @@ function createAndAppendFormGroup() {
|
|||||||
html1 += '<label class="control-label col-md-1 col-sm-1" required for="first-name">Receipt </label>'
|
html1 += '<label class="control-label col-md-1 col-sm-1" required for="first-name">Receipt </label>'
|
||||||
html1 += '<div class="col-md-5 col-sm-5 "><input id="formFile" name="bill2[]" multiple onchange="validateFile(this)" class="typeFile" type="file" value="" ></div>'
|
html1 += '<div class="col-md-5 col-sm-5 "><input id="formFile" name="bill2[]" multiple onchange="validateFile(this)" class="typeFile" type="file" value="" ></div>'
|
||||||
html1 += '</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>'
|
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></br>'
|
||||||
|
|
||||||
|
|
||||||
var formContainer = document.getElementById('formContainer');
|
var formContainer = document.getElementById('formContainer');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user