diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 35ced9e1..4795365d 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -395,6 +395,7 @@ $routes->get('getInvoiceAttachments', 'Sales::getInvoiceAttachments'); $routes->get('deleteAttachment', 'Sales::deleteAttachment'); $routes->post('saveAttachment', 'Sales::saveAttachment'); $routes->get('sales_invoice', 'Sales::sales_invoice'); +$routes->post('sales_invoice', 'Sales::sales_invoice'); // transporter Routes $routes->get('transporterListing', 'Supplier::transporterListing'); diff --git a/app/Controllers/Purchaseorder.php b/app/Controllers/Purchaseorder.php index 08c09ede..29027f0f 100755 --- a/app/Controllers/Purchaseorder.php +++ b/app/Controllers/Purchaseorder.php @@ -2554,6 +2554,9 @@ class Purchaseorder extends BaseController function porelease() { + $fromDate=''; + $toDate=''; + if ($this->request->getMethod() === 'GET') { $currentYear = date('Y'); @@ -2568,13 +2571,14 @@ class Purchaseorder extends BaseController $fromDate = date('Y-m-d', strtotime($fromDate)); $toDate = date('Y-m-d', strtotime($toDate)); } - + $q = "RELEASE"; $this->global['pageTitle'] = 'Purchase Order Release'; // $data['Status']= $this->purchaseorder_model->getStatus(); $userID = $this->session->get('userId'); //print_r($data['Status']);echo "CON"; $appList = $this->purchaseorder_model->getPOList($q , $fromDate , $toDate); + $filteredAppList = array_filter($appList, function ($item) { return $item->Status !== PO_DRAFT; }); diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index 4df396b0..dbc27e72 100755 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -91,10 +91,32 @@ class Sales extends BaseController // Sales Invoice List 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'; - $data['sales_invoice'] = $this->ipinvoice_model->saleInvoiceListing(); + $data['sales_invoice'] = $this->ipinvoice_model->saleInvoiceListing($fromDate , $toDate); // echo "
";
// 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);
}
diff --git a/app/Models/Ipinvoice_model.php b/app/Models/Ipinvoice_model.php
index d7ddacad..ad7999cf 100755
--- a/app/Models/Ipinvoice_model.php
+++ b/app/Models/Ipinvoice_model.php
@@ -15,7 +15,7 @@ class Ipinvoice_model extends Model
* @param number $segment : This is pagination limit
* @return array $result : This is result
*/
- function saleInvoiceListing()
+ function saleInvoiceListing($fromDate,$toDate)
{
$builder = $this->db->table('ip_invoices')
->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_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_invoice_amounts', 'ip_invoices.invoice_id = ip_invoice_amounts.invoice_id', 'left')
- ->orderBy('ip_invoices.invoice_number', 'DESC')
- ->limit(100);
+ ->join('ip_invoice_amounts', 'ip_invoices.invoice_id = ip_invoice_amounts.invoice_id', 'left');
+ $builder->where('ip_invoices.invoice_date_created >=', $fromDate );
+ $builder->where('ip_invoices.invoice_date_created <=', $toDate );
+ $builder->orderBy('ip_invoices.invoice_date_created', 'DESC');
$query = $builder->get();
$result = $query->getResult();
diff --git a/app/Models/Purchaseorder_model.php b/app/Models/Purchaseorder_model.php
index b043b4ed..d5f3f33f 100755
--- a/app/Models/Purchaseorder_model.php
+++ b/app/Models/Purchaseorder_model.php
@@ -1607,6 +1607,8 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
->join('tbl_users tbl', 'rmast.createdby=tbl.userid', 'left')
->join('t_employee_details as emp', 'emp.empid=tbl.empid', 'left')
->join('t_departmentdetails as Dep', 'Dep.DEPCode=emp.Departmentcode', 'left');
+
+
// old Status Don't Delete it.
// if ($type == 'APPROVAL') {
@@ -1625,6 +1627,10 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath,
// $builder->orWhere('mast.Status', PO_RELEASED);
// $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') {
$builder->orWhere('mast.Status', PO_DRAFT);
$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->where('mast.CreatedDate >=', $fromDate)
- ->where('mast.CreatedDate <=', $toDate);
-
- $builder->orderBy('mast.CreatedDate', 'DESC');
+
$result = $builder->get();
diff --git a/app/Views/sales_invoice.php b/app/Views/sales_invoice.php
index 9419236a..34552930 100755
--- a/app/Views/sales_invoice.php
+++ b/app/Views/sales_invoice.php
@@ -133,18 +133,36 @@
-
+
+
-
-
-
-
-
-
@@ -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) {
- return true; // If no dates selected, don't filter
- }
+ // Reset button functionality
+ $("#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());
});
+
+
+
// AJAX request using FormData
$.ajax({
url: 'saveAttachment',