changes in purchase module 11-03-2025
This commit is contained in:
parent
976a77d344
commit
77ddd302dd
@ -1189,7 +1189,7 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
//diesel stock details
|
//diesel stock details
|
||||||
|
|
||||||
public function dieselMachineStockDetails(){
|
public function dieselMachineStockDetails(){
|
||||||
|
|
||||||
|
|
||||||
@ -2064,9 +2064,17 @@ class StockController extends BaseController
|
|||||||
->where('stock_category','resin')
|
->where('stock_category','resin')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
$filterUpdateNeeded = true ;
|
||||||
|
|
||||||
|
if( empty($customisedMaterialCodes) && !empty($existingCustomMaterialCodes)){
|
||||||
|
$customisedMaterialCodes = array_column($existingCustomMaterialCodes, 'materialCode') ;
|
||||||
|
$filterUpdateNeeded = false ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//check user applies for filter currently
|
//check user applies for filter currently
|
||||||
if(!empty($customisedMaterialCodes)){
|
if(!empty($customisedMaterialCodes) && $filterUpdateNeeded){
|
||||||
|
|
||||||
//user applied filter,
|
//user applied filter,
|
||||||
|
|
||||||
@ -2201,7 +2209,35 @@ class StockController extends BaseController
|
|||||||
$groupedByDate[$date][] = $detail;
|
$groupedByDate[$date][] = $detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort each date's materials based on the custom order to set table body td
|
||||||
|
if (!empty($customisedMaterialCodes)) {
|
||||||
|
|
||||||
|
foreach ($groupedByDate as $date => &$materials) {
|
||||||
|
|
||||||
|
usort($materials, function ($a, $b) use ($customisedMaterialCodes) {
|
||||||
|
|
||||||
|
$indexA = array_search($a['materialCode'], $customisedMaterialCodes);
|
||||||
|
$indexB = array_search($b['materialCode'], $customisedMaterialCodes);
|
||||||
|
|
||||||
|
if ($indexA === false && $indexB === false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ($indexA === false) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ($indexB === false) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $indexA - $indexB;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
unset($materials);
|
||||||
|
}
|
||||||
|
|
||||||
// Reset the structure to have indexed arrays without the date keys
|
// Reset the structure to have indexed arrays without the date keys
|
||||||
|
|
||||||
|
//this is for tbody table data td
|
||||||
$data['groupedResinStockDetails'] = array_values($groupedByDate);
|
$data['groupedResinStockDetails'] = array_values($groupedByDate);
|
||||||
|
|
||||||
|
|
||||||
@ -2219,6 +2255,30 @@ class StockController extends BaseController
|
|||||||
->first()['customer'] ?? '';
|
->first()['customer'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort each date's materials based on the custom order to set table header th
|
||||||
|
if (!empty($customisedMaterialCodes)) {
|
||||||
|
|
||||||
|
usort($resinMaterials, function ($a, $b) use ($customisedMaterialCodes) {
|
||||||
|
|
||||||
|
$indexA = array_search($a['MaterialCode'], $customisedMaterialCodes);
|
||||||
|
$indexB = array_search($b['MaterialCode'], $customisedMaterialCodes);
|
||||||
|
|
||||||
|
if ($indexA === false && $indexB === false) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ($indexA === false) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if ($indexB === false) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $indexA - $indexB;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$resinMaterialCount = count($resinMaterials);
|
$resinMaterialCount = count($resinMaterials);
|
||||||
|
|
||||||
$data['resinMaterialCount'] = $resinMaterialCount;
|
$data['resinMaterialCount'] = $resinMaterialCount;
|
||||||
|
|||||||
@ -2188,12 +2188,20 @@ category = '" . $cat . "' ";
|
|||||||
function pending_purchase($cname, $prod, $fa, $aa, $m, $frm, $t, $purchaseorder_number)
|
function pending_purchase($cname, $prod, $fa, $aa, $m, $frm, $t, $purchaseorder_number)
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "select po.PONO as po,date_format(po.PODate,'%d-%m-%Y') as pdate,sup.SupplierName as supplier,mm.MaterialName as material,mm.Category as category,pl.Quantity as quantity,pl.ReceivedQuantity as received, (pl.Quantity - pl.ReceivedQuantity) as pending
|
$sql = "select po.PONO as po,
|
||||||
|
date_format(po.PODate,'%d-%m-%Y') as pdate,
|
||||||
|
sup.SupplierName as supplier,
|
||||||
|
mm.MaterialName as material,
|
||||||
|
cd.ConfigValue as category,
|
||||||
|
pl.Quantity as quantity,
|
||||||
|
pl.ReceivedQuantity as received,
|
||||||
|
(pl.Quantity - pl.ReceivedQuantity) as pending
|
||||||
from t_purchaseorder_lineitem pl
|
from t_purchaseorder_lineitem pl
|
||||||
join t_purchaseorder_master po on po.PONO = pl.PONO
|
join t_purchaseorder_master po on po.PONO = pl.PONO
|
||||||
join t_supplierdetailsn sup on sup.SupplierID=po.SupplierID
|
join t_supplierdetailsn sup on sup.SupplierID=po.SupplierID
|
||||||
join t_materialmaster mm on mm.MaterialCode=pl.MaterialCode
|
join t_materialmaster mm on mm.MaterialCode=pl.MaterialCode
|
||||||
where po.Status != 'ST030' and po.Status = 'ST026'
|
join t_configdetails cd on cd.key = mm.Category
|
||||||
|
where po.Status != 'ST030' and po.Status = 'ST026'
|
||||||
";
|
";
|
||||||
if ($cname != '') {
|
if ($cname != '') {
|
||||||
|
|
||||||
@ -2231,7 +2239,7 @@ where po.Status != 'ST030' and po.Status = 'ST026'
|
|||||||
if($purchaseorder_number != ''){
|
if($purchaseorder_number != ''){
|
||||||
$sql .= " and po.PONO = '" . $purchaseorder_number . "' ";
|
$sql .= " and po.PONO = '" . $purchaseorder_number . "' ";
|
||||||
}
|
}
|
||||||
$sql .= "order by po.PONO";
|
$sql .= "order by date(po.PODate) desc";
|
||||||
$query = $this->db->query($sql);
|
$query = $this->db->query($sql);
|
||||||
//echo $sql;
|
//echo $sql;
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
|
|||||||
@ -220,11 +220,12 @@
|
|||||||
$yqt = 0.00;
|
$yqt = 0.00;
|
||||||
$yvt = 0.00;
|
$yvt = 0.00;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($ppurchse as $rel) {
|
foreach ($ppurchse as $rel) {
|
||||||
$cat = $rel->category;
|
$cat = $rel->category;
|
||||||
|
//dd($rel);
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
@ -363,140 +364,21 @@
|
|||||||
// Bootstrap datepicker
|
// Bootstrap datepicker
|
||||||
// Set up your table
|
// Set up your table
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// $.fn.dataTable.moment('DD-MM-YYYY');
|
// Initialize the DataTable with only pagination enabled
|
||||||
// table = $('#cc').DataTable({
|
var table = $('#cc').DataTable({
|
||||||
// "language": {
|
paging: true, // Enable pagination
|
||||||
// "emptyTable": "<center> Data Not Found ! </center>"
|
searching: true, // Disable search
|
||||||
// },
|
ordering: false, // Disable column sorting
|
||||||
// "aaSorting": [
|
info: false, // Disable table information
|
||||||
// [0, "desc"]
|
lengthChange: false, // Disable page length options
|
||||||
// ],
|
pageLength: 10, // Default rows per page
|
||||||
// "pageLength": 10,
|
responsive: true, // Keep responsive design
|
||||||
// "lengthMenu": [10, 25, 50, 100],
|
language: {
|
||||||
// "autoWidth": false,
|
paginate: {
|
||||||
// orderCellsTop: true,
|
next: '<i class="fas fa-angle-right"></i>', // Next button icon
|
||||||
// "dom": "<'row'<'col-md-6'l><'col-md-6'Bf>>" +
|
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
|
||||||
// "<'row'<'col-md-6'><'col-md-6'>>" +
|
}
|
||||||
// "<'row'<'col-md-12't>><'row'<'col-md-4'i><'col-md-8'p>>",
|
}
|
||||||
// buttons: [
|
|
||||||
|
|
||||||
// // {
|
|
||||||
// // extend: 'excelHtml5',
|
|
||||||
// // footer: 'true',
|
|
||||||
// // //messageTop: $('h3').text(),
|
|
||||||
// // title: $('h3').text(),
|
|
||||||
// // exportOptions: {
|
|
||||||
// // columns: ':visible'
|
|
||||||
// // }
|
|
||||||
// // },
|
|
||||||
|
|
||||||
// 'colvis'
|
|
||||||
// ],
|
|
||||||
// "footerCallback": function(row, data, start, end, display) {
|
|
||||||
// var api = this.api(),
|
|
||||||
// data;
|
|
||||||
|
|
||||||
// // Remove the formatting to get integer data for summation
|
|
||||||
// var intVal = function(i) {
|
|
||||||
// return typeof i === 'string' ?
|
|
||||||
// parseFloat(i.replace(/[^0-9]+/g, "") * 1) :
|
|
||||||
// typeof i === 'number' ?
|
|
||||||
// parseFloat(i) : 0;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// TotalOrderedQTY = api
|
|
||||||
// .column(5, {
|
|
||||||
// search: 'applied'
|
|
||||||
// })
|
|
||||||
// .data()
|
|
||||||
// .reduce(function(a, b) {
|
|
||||||
// return intVal(a) + intVal(b);
|
|
||||||
// }, 0);
|
|
||||||
|
|
||||||
// $(api.column(5).footer()).html(TotalOrderedQTY.toFixed().bold());
|
|
||||||
|
|
||||||
// TotalRcvdQTY = api
|
|
||||||
// .column(6, {
|
|
||||||
// search: 'applied'
|
|
||||||
// })
|
|
||||||
// .data()
|
|
||||||
// .reduce(function(a, b) {
|
|
||||||
// return intVal(a) + intVal(b);
|
|
||||||
// }, 0);
|
|
||||||
|
|
||||||
// $(api.column(6).footer()).html(TotalRcvdQTY.toFixed().bold());
|
|
||||||
|
|
||||||
// TotalPendingQTY = api
|
|
||||||
// .column(7, {
|
|
||||||
// search: 'applied'
|
|
||||||
// })
|
|
||||||
// .data()
|
|
||||||
// .reduce(function(a, b) {
|
|
||||||
// return intVal(a) + intVal(b);
|
|
||||||
// }, 0);
|
|
||||||
|
|
||||||
// $(api.column(7).footer()).html(TotalPendingQTY.toFixed().bold());
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Initialize the DataTable
|
|
||||||
var table = $('#cc').DataTable({
|
|
||||||
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
|
|
||||||
buttons: [
|
|
||||||
'copy', 'csv' // Export buttons
|
|
||||||
],
|
|
||||||
pageLength: 10, // Default rows per page
|
|
||||||
lengthMenu: [
|
|
||||||
[10, 20, 30, 50, -1],
|
|
||||||
[10, 20, 30, 50, "All"]
|
|
||||||
], // Rows per page options
|
|
||||||
responsive: true, // Responsive table
|
|
||||||
order: [
|
|
||||||
[0, 'desc']
|
|
||||||
], // Default ordering (column index 0, descending)
|
|
||||||
language: {
|
|
||||||
paginate: {
|
|
||||||
next: '<i class="fas fa-angle-right"></i>', // Next button icon
|
|
||||||
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$('#mySelect').on('change', function() {
|
|
||||||
|
|
||||||
table
|
|
||||||
.column(4)
|
|
||||||
.search(this.value)
|
|
||||||
.draw();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(function() {
|
|
||||||
var dateFormat = 'dd-mm-yyyy';
|
|
||||||
|
|
||||||
// Initialize min-date (Start Date)
|
|
||||||
var from = $("#min-date").datepicker({
|
|
||||||
format: dateFormat,
|
|
||||||
autoclose: true,
|
|
||||||
todayHighlight: true,
|
|
||||||
clearBtn: true,
|
|
||||||
orientation: 'bottom'
|
|
||||||
}).on('changeDate', function(e) {
|
|
||||||
// When a date is selected in #min-date, update the minDate option for #max-date
|
|
||||||
// to.datepicker('setStartDate', e.date);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Initialize max-date (End Date)
|
|
||||||
var to = $("#max-date").datepicker({
|
|
||||||
format: dateFormat,
|
|
||||||
// startDate: new Date(), // Start date cannot be in the past
|
|
||||||
autoclose: true,
|
|
||||||
todayHighlight: true,
|
|
||||||
clearBtn: true,
|
|
||||||
orientation: 'bottom'
|
|
||||||
}).on('changeDate', function(e) {
|
|
||||||
// When a date is selected in #max-date, update the endDate option for #min-date
|
|
||||||
from.datepicker('setStartDate', e.date);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user