invoice listing
This commit is contained in:
parent
fd5690f745
commit
2e9d7a914d
@ -395,6 +395,7 @@ $routes->get('getInvoiceAttachments', 'Sales::getInvoiceAttachments');
|
|||||||
$routes->get('deleteAttachment', 'Sales::deleteAttachment');
|
$routes->get('deleteAttachment', 'Sales::deleteAttachment');
|
||||||
$routes->post('saveAttachment', 'Sales::saveAttachment');
|
$routes->post('saveAttachment', 'Sales::saveAttachment');
|
||||||
$routes->get('sales_invoice', 'Sales::sales_invoice');
|
$routes->get('sales_invoice', 'Sales::sales_invoice');
|
||||||
|
$routes->post('sales_invoice', 'Sales::sales_invoice');
|
||||||
|
|
||||||
// transporter Routes
|
// transporter Routes
|
||||||
$routes->get('transporterListing', 'Supplier::transporterListing');
|
$routes->get('transporterListing', 'Supplier::transporterListing');
|
||||||
|
|||||||
@ -2554,6 +2554,9 @@ class Purchaseorder extends BaseController
|
|||||||
function porelease()
|
function porelease()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$fromDate='';
|
||||||
|
$toDate='';
|
||||||
|
|
||||||
if ($this->request->getMethod() === 'GET')
|
if ($this->request->getMethod() === 'GET')
|
||||||
{
|
{
|
||||||
$currentYear = date('Y');
|
$currentYear = date('Y');
|
||||||
@ -2568,13 +2571,14 @@ class Purchaseorder extends BaseController
|
|||||||
$fromDate = date('Y-m-d', strtotime($fromDate));
|
$fromDate = date('Y-m-d', strtotime($fromDate));
|
||||||
$toDate = date('Y-m-d', strtotime($toDate));
|
$toDate = date('Y-m-d', strtotime($toDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
$q = "RELEASE";
|
$q = "RELEASE";
|
||||||
$this->global['pageTitle'] = 'Purchase Order Release';
|
$this->global['pageTitle'] = 'Purchase Order Release';
|
||||||
// $data['Status']= $this->purchaseorder_model->getStatus();
|
// $data['Status']= $this->purchaseorder_model->getStatus();
|
||||||
$userID = $this->session->get('userId');
|
$userID = $this->session->get('userId');
|
||||||
//print_r($data['Status']);echo "CON";
|
//print_r($data['Status']);echo "CON";
|
||||||
$appList = $this->purchaseorder_model->getPOList($q , $fromDate , $toDate);
|
$appList = $this->purchaseorder_model->getPOList($q , $fromDate , $toDate);
|
||||||
|
|
||||||
$filteredAppList = array_filter($appList, function ($item) {
|
$filteredAppList = array_filter($appList, function ($item) {
|
||||||
return $item->Status !== PO_DRAFT;
|
return $item->Status !== PO_DRAFT;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -91,10 +91,32 @@ class Sales extends BaseController
|
|||||||
|
|
||||||
// Sales Invoice List
|
// Sales Invoice List
|
||||||
function sales_invoice(){
|
function sales_invoice(){
|
||||||
|
$fromDate='';
|
||||||
|
$toDate='';
|
||||||
|
|
||||||
|
if ($this->request->getMethod() === 'GET')
|
||||||
|
{
|
||||||
|
$currentYear = date('Y');
|
||||||
|
$currentMonth = date('m');
|
||||||
|
$startOfMonth = "$currentYear-$currentMonth-01";
|
||||||
|
$endOfMonth = date('Y-m-t');
|
||||||
|
$fromDate = $startOfMonth;
|
||||||
|
$toDate = $endOfMonth;
|
||||||
|
} elseif ($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));
|
||||||
|
}
|
||||||
|
|
||||||
$this->global['pageTitle'] = 'Sales Invoice';
|
$this->global['pageTitle'] = 'Sales Invoice';
|
||||||
$data['sales_invoice'] = $this->ipinvoice_model->saleInvoiceListing();
|
$data['sales_invoice'] = $this->ipinvoice_model->saleInvoiceListing($fromDate , $toDate);
|
||||||
// echo "<pre>";
|
// echo "<pre>";
|
||||||
// print_r($data);die;
|
// print_r($data);die;
|
||||||
|
$data['fromDate'] = date('d-m-Y', strtotime($fromDate));
|
||||||
|
$data['toDate'] = date('d-m-Y', strtotime($toDate));
|
||||||
|
|
||||||
|
|
||||||
$this->loadViews("sales_invoice", $this->global, $data, NULL);
|
$this->loadViews("sales_invoice", $this->global, $data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class Ipinvoice_model extends Model
|
|||||||
* @param number $segment : This is pagination limit
|
* @param number $segment : This is pagination limit
|
||||||
* @return array $result : This is result
|
* @return array $result : This is result
|
||||||
*/
|
*/
|
||||||
function saleInvoiceListing()
|
function saleInvoiceListing($fromDate,$toDate)
|
||||||
{
|
{
|
||||||
$builder = $this->db->table('ip_invoices')
|
$builder = $this->db->table('ip_invoices')
|
||||||
->select('ip_invoices.invoice_id, ip_invoices.user_id, ip_invoices.client_id,
|
->select('ip_invoices.invoice_id, ip_invoices.user_id, ip_invoices.client_id,
|
||||||
@ -30,9 +30,10 @@ class Ipinvoice_model extends Model
|
|||||||
->join('ip_users', 'ip_invoices.user_id = ip_users.user_id', 'left')
|
->join('ip_users', 'ip_invoices.user_id = ip_users.user_id', 'left')
|
||||||
->join('ip_invoice_items', 'ip_invoices.invoice_id = ip_invoice_items.invoice_id', 'left')
|
->join('ip_invoice_items', 'ip_invoices.invoice_id = ip_invoice_items.invoice_id', 'left')
|
||||||
->join('ip_products', 'ip_invoice_items.item_product_id = ip_products.product_id', 'left')
|
->join('ip_products', 'ip_invoice_items.item_product_id = ip_products.product_id', 'left')
|
||||||
->join('ip_invoice_amounts', 'ip_invoices.invoice_id = ip_invoice_amounts.invoice_id', 'left')
|
->join('ip_invoice_amounts', 'ip_invoices.invoice_id = ip_invoice_amounts.invoice_id', 'left');
|
||||||
->orderBy('ip_invoices.invoice_number', 'DESC')
|
$builder->where('ip_invoices.invoice_date_created >=', $fromDate );
|
||||||
->limit(100);
|
$builder->where('ip_invoices.invoice_date_created <=', $toDate );
|
||||||
|
$builder->orderBy('ip_invoices.invoice_date_created', 'DESC');
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
|
|||||||
@ -1607,6 +1607,8 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
|
|||||||
->join('tbl_users tbl', 'rmast.createdby=tbl.userid', 'left')
|
->join('tbl_users tbl', 'rmast.createdby=tbl.userid', 'left')
|
||||||
->join('t_employee_details as emp', 'emp.empid=tbl.empid', 'left')
|
->join('t_employee_details as emp', 'emp.empid=tbl.empid', 'left')
|
||||||
->join('t_departmentdetails as Dep', 'Dep.DEPCode=emp.Departmentcode', 'left');
|
->join('t_departmentdetails as Dep', 'Dep.DEPCode=emp.Departmentcode', 'left');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// old Status Don't Delete it.
|
// old Status Don't Delete it.
|
||||||
// if ($type == 'APPROVAL') {
|
// if ($type == 'APPROVAL') {
|
||||||
@ -1625,6 +1627,10 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
|
|||||||
// $builder->orWhere('mast.Status', PO_RELEASED);
|
// $builder->orWhere('mast.Status', PO_RELEASED);
|
||||||
// $builder->orderBy('mast.Status');
|
// $builder->orderBy('mast.Status');
|
||||||
// }
|
// }
|
||||||
|
$builder->where('mast.CreatedDate >=', $fromDate . '00:00:00');
|
||||||
|
$builder->where('mast.CreatedDate <=', $toDate .'00:00:00');
|
||||||
|
$builder->orderBy('mast.CreatedDate', 'DESC');
|
||||||
|
|
||||||
if ($type == 'RELEASE') {
|
if ($type == 'RELEASE') {
|
||||||
$builder->orWhere('mast.Status', PO_DRAFT);
|
$builder->orWhere('mast.Status', PO_DRAFT);
|
||||||
$builder->orWhere('mast.Status', PO_CREATED);
|
$builder->orWhere('mast.Status', PO_CREATED);
|
||||||
@ -1636,10 +1642,7 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
|
|||||||
// $builder->orderBy('mast.Status');
|
// $builder->orderBy('mast.Status');
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->where('mast.CreatedDate >=', $fromDate)
|
|
||||||
->where('mast.CreatedDate <=', $toDate);
|
|
||||||
|
|
||||||
$builder->orderBy('mast.CreatedDate', 'DESC');
|
|
||||||
|
|
||||||
$result = $builder->get();
|
$result = $builder->get();
|
||||||
|
|
||||||
|
|||||||
@ -133,18 +133,36 @@
|
|||||||
<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;">
|
|
||||||
<input type="hidden" name="table" value="requisition">
|
|
||||||
<label for="fromDate">From:</label>
|
<form class="Date-filter-form" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;"
|
||||||
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
|
method="post" action="<?= base_url('sales_invoice'); ?>">
|
||||||
|
|
||||||
|
<label for="fromDate">From:</label>
|
||||||
|
<input class="form-control date_range form-date-search"
|
||||||
|
value="<?= $fromDate?>"
|
||||||
|
id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
|
||||||
|
|
||||||
|
<label for="toDate">To:</label>
|
||||||
|
<input class="form-control date_range to-date-search"
|
||||||
|
value="<?= $toDate ?>"
|
||||||
|
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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<label for="toDate">To:</label>
|
|
||||||
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
|
|
||||||
|
|
||||||
<button type="submit" class="range_search_button" title="Search"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
|
|
||||||
<i class="fe-rotate-cw range_reset_button" 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 id="datatable-buttosns" class="table dt-responsive nowrap w-100">
|
<table id="datatable-buttosns" class="table dt-responsive nowrap w-100">
|
||||||
<thead>
|
<thead>
|
||||||
@ -299,67 +317,14 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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) {
|
// Reset button functionality
|
||||||
return true; // If no dates selected, don't filter
|
$("#resetButton").click(function() {
|
||||||
}
|
$("#fromDate").val('');
|
||||||
|
$("#toDate").val('');
|
||||||
|
window.location="sales_invoice"
|
||||||
|
});
|
||||||
|
|
||||||
// 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
|
|
||||||
$("#resetButton").click(function() {
|
|
||||||
$("#fromDate").val('');
|
|
||||||
$("#toDate").val('');
|
|
||||||
table.draw(); // Redraw the table to clear the filter
|
|
||||||
});
|
|
||||||
|
|
||||||
// Automatically focus and open the To Date picker when From Date is selected
|
|
||||||
document.getElementById('fromDate').addEventListener('change', function() {
|
|
||||||
var fromDate = this.value;
|
|
||||||
var toDateInput = document.getElementById('toDate');
|
|
||||||
|
|
||||||
// Set the min attribute of the To Date input to the selected From Date
|
|
||||||
toDateInput.min = fromDate;
|
|
||||||
|
|
||||||
// Optionally reset the To Date input if the current value is before the new min date
|
|
||||||
if (toDateInput.value < fromDate) {
|
|
||||||
toDateInput.value = fromDate;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -499,6 +464,9 @@
|
|||||||
formData.append('file_name[]', $(input).val());
|
formData.append('file_name[]', $(input).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// AJAX request using FormData
|
// AJAX request using FormData
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<?php echo base_url() ?>saveAttachment',
|
url: '<?php echo base_url() ?>saveAttachment',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user