donation/app/Views/customer_list.php

297 lines
15 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>
<a href="<?= base_url() . "export_Donor"; ?>" class="btn btn-info"><i class="ri-file-excel-2-fill"></i> Export Contributor </a>
<!-- <a href="<?= base_url() . "import_Donor"; ?>" class="btn btn-secondary"><i class="ri-file-excel-2-line"></i> Import Contributor </a> -->
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#standard-modal"><i class="ri-file-excel-2-line"></i> Import Contributor</button>
<div class="row">
<div class="col-12 text-right">
<a href="<?= base_url() . "public/import/sample_contributor.xlsx"; ?>" download class="btn btn-link">Click here to download the sample Excel file for contributor import</a>
</div>
</div>
</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">&times;</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">&times;</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>
<?php if (get_user_role() != 'accounts') { ?>
<th>Action</th><?php } ?>
</tr>
</thead>
<?php foreach ($customer as $value) :?>
<tr>
<td hidden><?$value['donor_id'];?></td>
<?php if($value['donor_type'] == 'organization') { ?>
<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'] == 'individual'): ?>
<?= 'Individual'; ?>
<?php elseif ($value['donor_type'] == 'organization'): ?>
<?= 'Organization'; ?>
<?php endif; ?>
</td>
<?php if (get_user_role() != 'accounts') { ?>
<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>
<?php } ?>
</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">&times;</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">&times;</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>
<div id="standard-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="standard-modalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="standard-modalLabel">Import Contributor</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<form id="form-upload">
<div class="modal-body">
<div class="form-group col-md-12">
<label for="control-label">Choose File <small class="text-danger">*</small></label>
<input type="file" class="form-control" style="border: 0px !important; " id="file" name="file" placeholder="csv,xlsx files" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
application/vnd.ms-excel" required />
<span class="help-block"><small>Upload xlsx or csv file only.</small></span>
</div>
<div class="form-group">
<div class="text-center">
<div class="upload-loader" style="display: none; ">
<i class="fa fa-spinner fa-spin"></i> <small>Please wait ...</small>
</div>
<div class="result"></div>
</div>
<div class="text-left message_in_details"></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" id="btn-upload">Upload</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script>
$(document).ready(function(){
$('#form-upload').on('submit', function(event) {
event.preventDefault(); // Prevent default form submission
var formData = new FormData($('#form-upload')[0]);
$.ajax({
type: "POST",
url: "<?= base_url() . 'import_Donor' ?>",
data: formData,
contentType: false,
processData: false,
beforeSend: function() {
$("#btn-upload").prop('disabled', true);
$(".upload-loader").show();
},
success: function(result) {
$("#btn-upload").prop('disabled', false);
if($.isEmptyObject(result.error_message)) {
$(".result").html(result.success_message).css("color", "green");
} else {
$(".result").html(result.error_message).css("color", "red");
}
if (!$.isEmptyObject(result.message_in_details)) {
$(".message_in_details").html(result.message_in_details+" <center> <br><br> After 12 seconds. Import Contributor pop will be closed </center>").css("color", "blue");
}
$("#form-upload")[0].reset();
$(".upload-loader").hide();
setTimeout(function() {
console.log("Timeout executed!"); // Check if this message appears in the console
refreshPage();
$(".result").html('');
$(".message_in_details").html('');
}, 12000); // 10000 milliseconds = 10 seconds now setted as 12 seconds.
}
});
});
});
</script>