IGR listing fixed-2
This commit is contained in:
parent
c105e7b4dd
commit
69d869c263
@ -278,6 +278,7 @@ $routes->post('inwardgateregister/edituploadfile', 'Inwardgateregister::edituplo
|
|||||||
|
|
||||||
// Non IGR / Expense
|
// Non IGR / Expense
|
||||||
$routes->get('ListIGR', 'Expense::index');
|
$routes->get('ListIGR', 'Expense::index');
|
||||||
|
$routes->post('ListIGR', 'Expense::index'); //for filter usage
|
||||||
$routes->post('addExpense', 'Expense::addExpense');
|
$routes->post('addExpense', 'Expense::addExpense');
|
||||||
$routes->post('editExpense', 'Expense::editExpense');
|
$routes->post('editExpense', 'Expense::editExpense');
|
||||||
$routes->post('getExpenseDetails', 'Expense::getExpenseDetails');
|
$routes->post('getExpenseDetails', 'Expense::getExpenseDetails');
|
||||||
|
|||||||
@ -24,9 +24,27 @@ class Expense extends BaseController
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$data['expense_list'] = $this->expense_model->getAllExpense();
|
|
||||||
|
if ($this->request->getMethod() === 'GET')
|
||||||
|
{
|
||||||
|
$currentYear = date('Y');
|
||||||
|
$currentMonth = date('m');
|
||||||
|
$startOfMonth = "$currentYear-$currentMonth-01";
|
||||||
|
$endOfMonth = date('Y-m-t');
|
||||||
|
$fromDate = $startOfMonth;
|
||||||
|
$toDate = $endOfMonth;
|
||||||
|
} else if ($this->request->getMethod() === 'POST') {
|
||||||
|
$fromDate = $this->request->getPost('fromDate');
|
||||||
|
$toDate = $this->request->getPost('toDate');
|
||||||
|
$fromDate = date('Y-m-d', strtotime($fromDate));
|
||||||
|
$toDate = date('Y-m-d', strtotime($toDate));
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['expense_list'] = $this->expense_model->getAllExpense($fromDate,$toDate);
|
||||||
$data['supplier_list'] = json_encode($this->supplier_model->supplierlisting());
|
$data['supplier_list'] = json_encode($this->supplier_model->supplierlisting());
|
||||||
$this->global['pageTitle'] = 'Non IGR / Expense List';
|
$this->global['pageTitle'] = 'Non IGR / Expense List';
|
||||||
|
$data['fromDate'] = date('d-m-Y', strtotime($fromDate));
|
||||||
|
$data['toDate'] = date('d-m-Y', strtotime($toDate));
|
||||||
$this->loadViews("expense_list", $this->global, $data, NULL);
|
$this->loadViews("expense_list", $this->global, $data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ class Purchaseorder extends BaseController
|
|||||||
$endOfMonth = date('Y-m-t');
|
$endOfMonth = date('Y-m-t');
|
||||||
$fromDate = $startOfMonth;
|
$fromDate = $startOfMonth;
|
||||||
$toDate = $endOfMonth;
|
$toDate = $endOfMonth;
|
||||||
} elseif ($this->request->getMethod() === 'POST') {
|
} else if ($this->request->getMethod() === 'POST') {
|
||||||
$fromDate = $this->request->getPost('fromDate');
|
$fromDate = $this->request->getPost('fromDate');
|
||||||
$toDate = $this->request->getPost('toDate');
|
$toDate = $this->request->getPost('toDate');
|
||||||
$fromDate = date('Y-m-d', strtotime($fromDate));
|
$fromDate = date('Y-m-d', strtotime($fromDate));
|
||||||
|
|||||||
@ -13,9 +13,11 @@ class Expense_model extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Retrieve all active expenses
|
// Retrieve all active expenses
|
||||||
public function getAllExpense() {
|
public function getAllExpense($fromDate,$toDate) {
|
||||||
return $this->join('t_supplierdetailsn', 't_expense.supplier_id = t_supplierdetailsn.SupplierID')
|
return $this->join('t_supplierdetailsn', 't_expense.supplier_id = t_supplierdetailsn.SupplierID')
|
||||||
->where('t_expense.isactive', 1)
|
->where('t_expense.isactive', 1)
|
||||||
|
->where('t_expense.created_on >=',"$fromDate")
|
||||||
|
->where('t_expense.created_on <=',"$toDate")
|
||||||
->orderBy('t_expense.created_on', 'DESC')
|
->orderBy('t_expense.created_on', 'DESC')
|
||||||
->findAll();
|
->findAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,18 +80,29 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
|
<form class="Date-filter-form" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;" method="post" action="<?= base_url('ListIGR'); ?>">
|
||||||
<input type="hidden" name="table" value="requisition">
|
|
||||||
<label for="fromDate">From:</label>
|
|
||||||
<input class="form-control date_range form-date-search" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
|
|
||||||
|
|
||||||
<label for="toDate">To:</label>
|
<label for="fromDate">From:</label>
|
||||||
<input class="form-control date_range to-date-search" type="date" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
|
<input class="form-control date_range form-date-search"
|
||||||
|
value="<?= $fromDate?>"
|
||||||
|
id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
|
||||||
|
|
||||||
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
|
<label for="toDate">To:</label>
|
||||||
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
|
<input class="form-control date_range to-date-search"
|
||||||
<div class="error" id="error"></div>
|
value="<?= $toDate ?>"
|
||||||
</form>
|
id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
|
||||||
|
|
||||||
|
<button type="submit" class="range_search_button" >
|
||||||
|
<i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<i class="fe-rotate-cw range_reset_button"
|
||||||
|
style="cursor:pointer;"
|
||||||
|
aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="error" id="error"></div>
|
||||||
|
</form>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<table class="table table-bordered table-hover" id="expense_list_table" style="background-color:#fff;">
|
<table class="table table-bordered table-hover" id="expense_list_table" style="background-color:#fff;">
|
||||||
<thead>
|
<thead>
|
||||||
@ -460,7 +471,7 @@
|
|||||||
var table = $('#expense_list_table').DataTable({
|
var table = $('#expense_list_table').DataTable({
|
||||||
dom: 'Blfrtip',
|
dom: 'Blfrtip',
|
||||||
buttons: [
|
buttons: [
|
||||||
'copy', 'csv', 'excel', 'pdf', 'print'
|
'csv', 'excel', 'pdf'
|
||||||
],
|
],
|
||||||
pageLength: 10,
|
pageLength: 10,
|
||||||
lengthMenu: [
|
lengthMenu: [
|
||||||
@ -477,60 +488,14 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$.fn.dataTable.ext.search.push(
|
|
||||||
function(settings, data, dataIndex) {
|
|
||||||
var fromDate = $('#fromDate').val();
|
|
||||||
var toDate = $('#toDate').val();
|
|
||||||
console.log(fromDate); // e.g., 01-09-2024
|
|
||||||
console.log(toDate); // e.g., 08-09-2024
|
|
||||||
|
|
||||||
if (!fromDate || !toDate) {
|
|
||||||
return true; // If no dates selected, don't filter
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
|
|
||||||
var fromParts = fromDate.split("-");
|
|
||||||
var toParts = toDate.split("-");
|
|
||||||
|
|
||||||
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
|
|
||||||
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
|
|
||||||
|
|
||||||
// Adjust startDate to include the day before the selected fromDate
|
|
||||||
startDate.setDate(startDate.getDate() - 1);
|
|
||||||
|
|
||||||
// Ensure endDate includes the entire end date by setting time to the end of the day
|
|
||||||
endDate.setHours(23, 59, 59, 999);
|
|
||||||
|
|
||||||
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
|
|
||||||
var dateStr = data[0];
|
|
||||||
var dateParts = dateStr.split("-");
|
|
||||||
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
|
|
||||||
|
|
||||||
// Return true if the row date is within the range
|
|
||||||
return rowDate >= startDate && rowDate <= endDate;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$("#DateRangeFilter").submit(function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
table.draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#resetButton").click(function() {
|
$("#resetButton").click(function() {
|
||||||
$("#fromDate").val('');
|
$("#fromDate").val('');
|
||||||
$("#toDate").val('');
|
$("#toDate").val('');
|
||||||
table.draw();
|
window.location="ListIGR"
|
||||||
});
|
});
|
||||||
|
});
|
||||||
document.getElementById('fromDate').addEventListener('change', function() {
|
|
||||||
var fromDate = this.value;
|
|
||||||
var toDateInput = document.getElementById('toDate');
|
|
||||||
toDateInput.min = fromDate;
|
|
||||||
if (toDateInput.value < fromDate) {
|
|
||||||
toDateInput.value = fromDate;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('click', '#deleteFile', function() {
|
$(document).on('click', '#deleteFile', function() {
|
||||||
var fileName = $(this).data('file');
|
var fileName = $(this).data('file');
|
||||||
|
|||||||
@ -1649,46 +1649,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Date range filter function
|
|
||||||
$.fn.dataTable.ext.search.push(
|
|
||||||
function(settings, data, dataIndex) {
|
|
||||||
var fromDate = $('#fromDate').val();
|
|
||||||
var toDate = $('#toDate').val();
|
|
||||||
console.log(fromDate); // e.g., 01-09-2024
|
|
||||||
console.log(toDate); // e.g., 08-09-2024
|
|
||||||
|
|
||||||
if (!fromDate || !toDate) {
|
|
||||||
return true; // If no dates selected, don't filter
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert the fromDate and toDate from dd-mm-yyyy to Date objects
|
|
||||||
var fromParts = fromDate.split("-");
|
|
||||||
var toParts = toDate.split("-");
|
|
||||||
|
|
||||||
var startDate = new Date(fromParts[2], fromParts[1] - 1, fromParts[0]); // Year, month (0-based), day
|
|
||||||
var endDate = new Date(toParts[2], toParts[1] - 1, toParts[0]);
|
|
||||||
|
|
||||||
// Adjust startDate to include the day before the selected fromDate
|
|
||||||
startDate.setDate(startDate.getDate() - 1);
|
|
||||||
|
|
||||||
// Ensure endDate includes the entire end date by setting time to the end of the day
|
|
||||||
endDate.setHours(23, 59, 59, 999);
|
|
||||||
|
|
||||||
// Get the date from the DataTable row (assuming it's in the first column in dd-mm-yyyy format)
|
|
||||||
var dateStr = data[0];
|
|
||||||
var dateParts = dateStr.split("-");
|
|
||||||
var rowDate = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]);
|
|
||||||
|
|
||||||
// Return true if the row date is within the range
|
|
||||||
return rowDate >= startDate && rowDate <= endDate;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Handle form submission for the date range filter
|
|
||||||
$("#DateRangeFilter").submit(function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
table.draw(); // Redraw the table to apply the filter
|
|
||||||
});
|
|
||||||
|
|
||||||
// Reset button functionality
|
// Reset button functionality
|
||||||
$("#resetButton").click(function() {
|
$("#resetButton").click(function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user