210 lines
9.1 KiB
PHP
210 lines
9.1 KiB
PHP
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="float-right">
|
|
<a href="<?= base_url() . "new_Donor/0"; ?>" class="btn btn-primary"><i class="ri-map-pin-user-fill"></i> Add Contributor </a>
|
|
</div><!-- end col-->
|
|
<br>
|
|
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
|
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
|
<?php if (session()->getFlashdata('success')) : ?>
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<?= session('success') ?>
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (session()->getFlashdata('error')) : ?>
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<?= session('error') ?>
|
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
<div class="table-responsive">
|
|
<table id="scroll-horizontal-datatable_customer" class="table w-100 nowrap">
|
|
<thead class="thead-light">
|
|
<tr>
|
|
<th hidden></th>
|
|
<th>Name</th>
|
|
<th>Mobile Number</th>
|
|
<th>Contributor Type</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<?php foreach ($customer as $value) :?>
|
|
<tr>
|
|
<td hidden><?$value['donor_id'];?></td>
|
|
<?php if($value['donor_type'] == 'option2') { ?>
|
|
<td><?= $value['org_name']; ?></td>
|
|
<?php } else { ?>
|
|
<td><?= $value['first_name'].' '.$value['last_name'] ; ?></td>
|
|
<?php } ?>
|
|
<td><?= $value['mobile_no']; ?></td>
|
|
<td>
|
|
<?php if ($value['donor_type'] == 'option1'): ?>
|
|
<?= 'Individual'; ?>
|
|
<?php elseif ($value['donor_type'] == 'option2'): ?>
|
|
<?= 'Organization'; ?>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<a href="<?= "new_Donor/" . $value['donor_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
|
<a href="#" class="view-receipts" data-donor-id="<?= $value['donor_id']; ?>"><i class="ri-eye-fill"></i></a>
|
|
|
|
<?php if(get_user_role() != 'auditor') { ?>
|
|
<a href="<?= "delete_donor/" . $value['donor_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
|
<?php } ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div> <!-- end card body-->
|
|
</div> <!-- end card -->
|
|
</div><!-- end col-->
|
|
</div>
|
|
<!-- Add a modal for receipt details -->
|
|
<div class="modal fade" id="receiptModal" tabindex="-1" role="dialog" aria-labelledby="receiptModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-lg" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="receiptModalLabel">Receipt Details</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<table id="scroll-horizontal-datatable_customer" class="table w-100 nowrap">
|
|
<thead>
|
|
<tr>
|
|
<th>Receipt Number</th>
|
|
<th>Donor Name</th>
|
|
<th>Amount</th>
|
|
<th>Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="receiptDetailsBody">
|
|
<!-- Receipt details will be dynamically added here -->
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
|
|
|
|
</div>
|
|
</div><!-- /.modal-content -->
|
|
</div><!-- /.modal-dialog -->
|
|
</div><!-- /.modal -->
|
|
|
|
<!-- <div class="modal fade" id="receiptModal" tabindex="-1" role="dialog" aria-labelledby="receiptModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-lg" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="receiptModalLabel">Receipt Details</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> -->
|
|
|
|
<!-- end row-->
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#scroll-horizontal-datatable_customer').DataTable({
|
|
"order": [[0, "desc"]] // 4 is the column index of "created_on" in your table
|
|
// Other DataTables configuration options
|
|
});
|
|
});
|
|
</script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Handle click on eye icon
|
|
// Use event delegation for handling click on "View Receipts"
|
|
$(document).on('click', '.view-receipts', function(e) {
|
|
e.preventDefault();
|
|
|
|
// Get donor ID from data attribute
|
|
var donorId = $(this).data('donor-id');
|
|
console.log("Donor ID:", donorId);
|
|
|
|
// AJAX request to fetch receipt details
|
|
$.ajax({
|
|
url: '<?= base_url('Customer/getReceiptDetails/') ?>' + donorId,
|
|
type: 'GET',
|
|
success: function(response) {
|
|
console.log("AJAX Success. Response:", response);
|
|
// Populate modal content with receipt details
|
|
populateReceiptDetails(response);
|
|
|
|
// Show the modal
|
|
$('#receiptModal').modal('show');
|
|
},
|
|
error: function(error) {
|
|
console.error('Error fetching receipt details:', error);
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
// Function to populate receipt details in the modal
|
|
function populateReceiptDetails(details) {
|
|
var detailsBody = $('#receiptDetailsBody');
|
|
|
|
// Clear existing content
|
|
detailsBody.empty();
|
|
|
|
// Populate details
|
|
details.forEach(function(detail) {
|
|
var currencySymbol = '';
|
|
|
|
|
|
// Determine currency symbol and name based on the currency code
|
|
switch (detail.currency) {
|
|
case 'INR':
|
|
currencySymbol = '₹';
|
|
|
|
break;
|
|
case 'USD':
|
|
currencySymbol = '$';
|
|
|
|
break;
|
|
case 'EUR':
|
|
currencySymbol = '€';
|
|
|
|
break;
|
|
case 'INR':
|
|
currencySymbol = '₹';
|
|
|
|
break;
|
|
// Add cases for other currencies as needed
|
|
default:
|
|
currencySymbol = '';
|
|
currencyName = '';
|
|
break;
|
|
}
|
|
var receiptDate = new Date(detail.receipt_date);
|
|
var formattedDate = ('0' + receiptDate.getDate()).slice(-2) + '-' + ('0' + (receiptDate.getMonth() + 1)).slice(-2) + '-' + receiptDate.getFullYear();
|
|
|
|
var row = '<tr>' +
|
|
'<td>' + detail.receipt_number + '</td>' +
|
|
'<td>' + detail.first_name + '</td>' +
|
|
'<td>' + currencySymbol + ' ' + detail.amount + '</td>'+
|
|
'<td>' + formattedDate + '</td>' +
|
|
'</tr>';
|
|
detailsBody.append(row);
|
|
});
|
|
}
|
|
});
|
|
</script>
|