462 lines
15 KiB
PHP
462 lines
15 KiB
PHP
<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;
|
||
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;
|
||
}
|
||
|
||
</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">
|
||
|
||
|
||
|
||
<button hidden id="button" class="btn btn-secondary source" onclick="new PNotify({
|
||
text: '<html><h2>Expense Approved<h2></html>',
|
||
type: 'success',
|
||
styling: 'bootstrap3'
|
||
});">Success</button>
|
||
<button hidden id="button2" class="btn btn-secondary source" onclick="new PNotify({
|
||
text: '<html><h2>Expense Declined<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();
|
||
}
|
||
else if($('#error').val() == 2)
|
||
{
|
||
$('#button2').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>My Approvals</h3>
|
||
|
||
<div class="clearfix"></div>
|
||
</div>
|
||
<div class="x_content">
|
||
<div class="row">
|
||
<div class="col-sm-12" style="overflow: auto;">
|
||
<div class="table-responsive">
|
||
<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">Created By</th>
|
||
<th class="column-title">Requested For</th>
|
||
<th class="column-title">Expense Name</th>
|
||
<th class="column-title">Business Reason</th>
|
||
<th class="column-title">Total Amount(₹)</th>
|
||
<th class="column-title">No of List</th>
|
||
<th class="column-title">Status </th>
|
||
<th class="column-title" >Action </th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($tableData as $key => $value) { ?>
|
||
|
||
<?php if(is_admin() || user()->id == $value->manager_id){ ?>
|
||
|
||
<tr class="even pointer">
|
||
<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($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 } else if($value->status == 'Partially approved'){?>
|
||
|
||
<td style="color:#0000e6;"><?php echo $value->status; ?></td>
|
||
|
||
<?php } ?>
|
||
|
||
<td style=" text-align: center; font-size: 16px;">
|
||
|
||
<!-- <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="<?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>
|
||
|
||
|
||
<?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>
|
||
<a><i class="fa fa-times test" data-toggle="modal" data-target=".bs-example-modal-sm" title="Decline" id="<?php echo $value->id;?>"></i></a>
|
||
<!-- <a><i class="fa fa-times test" aria-hidden="true" title="Decline" onclick="showCustomPrompt()" id= "<?php echo $value->id; ?>"></i></a> -->
|
||
<?php } ?>
|
||
</td>
|
||
</tr>
|
||
<?php } } ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</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" 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 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 url = "<?php echo base_url()?>Expence/Approve_Expence";
|
||
|
||
$.ajax({
|
||
url: "<?php echo base_url()?>Expence/getDeleteConfirmationPopup",
|
||
type:"GET",
|
||
success:function(data){
|
||
$('#popup').html(JSON.parse(data));
|
||
$('.delete_id').attr('value',id);
|
||
$('.delete_url').attr('action',url);
|
||
}
|
||
});
|
||
});
|
||
|
||
$('.test').click(function() {
|
||
var id = $(this).attr('id');
|
||
var url = "<?php echo base_url()?>Expence/Decline_expence";
|
||
|
||
$.ajax({
|
||
url: "<?php echo base_url()?>Expence/getDeclineConfirmationPopup",
|
||
type:"GET",
|
||
success:function(data){
|
||
$('#popup').html(JSON.parse(data));
|
||
$('.delete_id').attr('value',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;
|
||
console.log(id, reason);
|
||
if( reason != "")
|
||
|
||
$.ajax({
|
||
|
||
data:{id : id , reason : reason },
|
||
url:"<?php echo base_url('Expence/Decline_expence/');?>",
|
||
type:"get",
|
||
success: function(response) {
|
||
|
||
console.log(response);
|
||
window.location ='<?php echo base_url('Expence/expence_list');?>';
|
||
new PNotify({
|
||
text: '<html><h2>Expense Declined<h2></html>',
|
||
type: 'success',
|
||
styling: 'bootstrap3'
|
||
});
|
||
}
|
||
|
||
|
||
});
|
||
else
|
||
|
||
alert('Decline Reason is required');
|
||
}
|
||
|
||
</script>
|
||
</div>
|
||
|
||
<div id="myModal" class="modal modal_default">
|
||
<span class="close">×</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>
|
||
<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> '
|
||
table += '<a><i class="fa fa-check " onclick="returndata('+expense.id+')" title="Approve Expense" id="' + expense.id + '"></i></a> '
|
||
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>
|
||
|
||
|
||
|
||
|
||
|
||
|