stock module latest today vadivel J 21-02-2025
This commit is contained in:
parent
2885d14239
commit
474e2c0392
@ -2545,7 +2545,7 @@ class StockController extends BaseController
|
||||
$this->global['pageTitle'] = 'Diesel Machine Stock Details';
|
||||
|
||||
|
||||
// Get the previous month's last date resin stock details for next month updation
|
||||
// Get the previous month's last date diesel stock details for next month updation
|
||||
|
||||
$previousMonth = DateTime::createFromFormat('Y-m', $month)->modify('-1 month')->format('Y-m');
|
||||
$previousMonthStartDate = "$previousMonth-01";
|
||||
|
||||
@ -21,7 +21,16 @@
|
||||
background-color: #50bbd9;
|
||||
color: #ffffff;
|
||||
}
|
||||
/*
|
||||
|
||||
.grab {
|
||||
cursor: grab; /* Default open-hand cursor */
|
||||
}
|
||||
|
||||
.grab:active {
|
||||
cursor: grabbing; /* Closed-hand cursor when dragging */
|
||||
}
|
||||
|
||||
/*
|
||||
.fht-table td[contenteditable="true"] {
|
||||
background-color: lightyellow;
|
||||
color:rgb(13, 7, 7);
|
||||
@ -155,14 +164,14 @@
|
||||
}
|
||||
|
||||
.celda_encabezado_total {
|
||||
background-color:#ffffff !important;
|
||||
background-color: #ffffff !important;
|
||||
border: 1px solid #ffffff;
|
||||
color: #ffffff !important;
|
||||
font-weight: bold;
|
||||
padding: 6px 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.celda_normal {
|
||||
/*background-color: #fff;*/
|
||||
/* <!-- ad9271 into ffffff brown-light to green-light --> */
|
||||
@ -176,12 +185,14 @@
|
||||
.fht-table thead {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 20; /* Ensure the entire header stays above table rows */
|
||||
background-color: #50bbd9; /* Header background color */
|
||||
z-index: 20;
|
||||
/* Ensure the entire header stays above table rows */
|
||||
background-color: #50bbd9;
|
||||
/* Header background color */
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
z-index :25 ;
|
||||
.dropdown-menu {
|
||||
z-index: 25;
|
||||
}
|
||||
|
||||
|
||||
@ -190,8 +201,10 @@
|
||||
.fht-table thead th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 11; /* Higher than table rows but lower than first column */
|
||||
background-color: #50bbd9; /* Green background */
|
||||
z-index: 11;
|
||||
/* Higher than table rows but lower than first column */
|
||||
background-color: #50bbd9;
|
||||
/* Green background */
|
||||
color: #ffffff;
|
||||
border: 1px solid #ddd;
|
||||
padding: 10px;
|
||||
@ -203,7 +216,8 @@
|
||||
position: sticky;
|
||||
left: 0;
|
||||
background-color: #50bbd9;
|
||||
z-index: 15; /* Ensures it stays above other cells */
|
||||
z-index: 15;
|
||||
/* Ensures it stays above other cells */
|
||||
border-right: 2px solid #ddd;
|
||||
color: #ffffff;
|
||||
}
|
||||
@ -211,17 +225,16 @@
|
||||
/* Table Wrapper for Scrolling */
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
overflow-y: auto;
|
||||
max-height: 500px; /* Adjust as needed */
|
||||
overflow-y: auto;
|
||||
max-height: 500px;
|
||||
/* Adjust as needed */
|
||||
position: relative;
|
||||
}
|
||||
|
||||
td{
|
||||
min-width: 100px;
|
||||
max-width: 100px;
|
||||
td {
|
||||
min-width: 100px;
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@ -291,10 +304,14 @@ foreach ($period as $day) {
|
||||
class="form-control mt-2" data-provide="datepicker"
|
||||
data-date-format="M-yyyy" data-date-min-view-mode="1">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<div class="form-group col-md-3">
|
||||
<button type="submit" class="btn btn-success"> Change Month </button>
|
||||
|
||||
<button type="button" class="btn" style="background-color:maroon;color:white" data-target="#customizeModalId"
|
||||
data-toggle="modal">
|
||||
Customize
|
||||
</button>
|
||||
</div>
|
||||
<div class="col-md-1"></div>
|
||||
<div class="col-6">
|
||||
<div class="dropdown float-right">
|
||||
<a href="#" class="dropdown-toggle arrow-none" data-toggle="dropdown"
|
||||
@ -354,9 +371,9 @@ foreach ($period as $day) {
|
||||
|
||||
<?php if (!empty($groupedResinStockDetails)) {
|
||||
|
||||
$summary = [];
|
||||
$summary = [];
|
||||
|
||||
|
||||
|
||||
foreach ($groupedResinStockDetails as $groupedResinStockDetailsIndex => $resinStockDetails) {
|
||||
|
||||
?>
|
||||
@ -370,9 +387,9 @@ foreach ($period as $day) {
|
||||
echo 'style="background: #cef0ad;"';
|
||||
}
|
||||
?>>
|
||||
<?php foreach ($resinStockDetails as $resinStockIndex => $resinStock) {
|
||||
|
||||
?>
|
||||
<?php foreach ($resinStockDetails as $resinStockIndex => $resinStock) {
|
||||
|
||||
?>
|
||||
<?php if ($resinStockIndex == 0): ?>
|
||||
<?php
|
||||
$startDate = DateTime::createFromFormat('Y-m-d', $resinStock['date'])->format('d-m-Y');
|
||||
@ -424,32 +441,31 @@ foreach ($period as $day) {
|
||||
<?= $resinStock['balanceStock'] ?? ' ' ?>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
//before closing inner loop we just adding the total values insidde it
|
||||
|
||||
$materialCode = $resinStock['materialCode']; // Unique identifier
|
||||
//before closing inner loop we just adding the total values insidde it
|
||||
|
||||
// Initialize the material entry if it doesn't exist
|
||||
if (!isset($summary[$materialCode])) {
|
||||
$summary[$materialCode] = [
|
||||
'opening' => "-" ,
|
||||
'receipt' => 0,
|
||||
'used' => 0,
|
||||
'balanceStock' => 0,
|
||||
];
|
||||
}
|
||||
$materialCode = $resinStock['materialCode']; // Unique identifier
|
||||
|
||||
// Sum values for the material
|
||||
;
|
||||
$summary[$materialCode]['opening'] = "-" ;
|
||||
$summary[$materialCode]['receipt'] += is_numeric($resinStock['receipt']) ? $resinStock['receipt'] : 0;
|
||||
$summary[$materialCode]['used'] += is_numeric($resinStock['used']) ? $resinStock['used'] : 0;
|
||||
$summary[$materialCode]['balanceStock'] = is_numeric($resinStock['balanceStock']) ? $resinStock['balanceStock'] : 0;
|
||||
// Initialize the material entry if it doesn't exist
|
||||
if (!isset($summary[$materialCode])) {
|
||||
$summary[$materialCode] = [
|
||||
'opening' => "-",
|
||||
'receipt' => 0,
|
||||
'used' => 0,
|
||||
'balanceStock' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
} ?>
|
||||
// Sum values for the material
|
||||
;
|
||||
$summary[$materialCode]['opening'] = "-";
|
||||
$summary[$materialCode]['receipt'] += is_numeric($resinStock['receipt']) ? $resinStock['receipt'] : 0;
|
||||
$summary[$materialCode]['used'] += is_numeric($resinStock['used']) ? $resinStock['used'] : 0;
|
||||
$summary[$materialCode]['balanceStock'] = is_numeric($resinStock['balanceStock']) ? $resinStock['balanceStock'] : 0;
|
||||
} ?>
|
||||
|
||||
</tr>
|
||||
|
||||
@ -457,41 +473,41 @@ foreach ($period as $day) {
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="resinStockDetailsTableSummaryId" class="fht-table table-striped">
|
||||
<table id="resinStockDetailsTableSummaryId" class="fht-table table-striped">
|
||||
|
||||
<thead >
|
||||
<th class="celda_encabezado_total">Total Sum</th>
|
||||
<?php foreach($summary as $each){ ?>
|
||||
<th class="celda_encabezado_total">Opening Stock</th>
|
||||
<th class="celda_encabezado_total">Receipt</th>
|
||||
<th class="celda_encabezado_total">Used</th>
|
||||
<th class="celda_encabezado_total">Balance Stock</th>
|
||||
<?php } ?>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<thead>
|
||||
<th class="celda_encabezado_total">Total Sum</th>
|
||||
<?php foreach ($summary as $each) { ?>
|
||||
<th class="celda_encabezado_total">Opening Stock</th>
|
||||
<th class="celda_encabezado_total">Receipt</th>
|
||||
<th class="celda_encabezado_total">Used</th>
|
||||
<th class="celda_encabezado_total">Balance Stock</th>
|
||||
<?php } ?>
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<tbody>
|
||||
|
||||
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
|
||||
<b> Total </b>
|
||||
</td>
|
||||
<tr>
|
||||
|
||||
<?php foreach($summary as $each){ ?>
|
||||
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
|
||||
<b> Total </b>
|
||||
</td>
|
||||
|
||||
|
||||
<td class="celda_normal "><?=$each['opening']?></td>
|
||||
<td class="celda_normal "><?=$each['receipt']?></td>
|
||||
<td class="celda_normal "><?=$each['used']?></td>
|
||||
<td class="celda_normal "><?=$each['balanceStock']?></td>
|
||||
<?php foreach ($summary as $each) { ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</tr>
|
||||
|
||||
<td class="celda_normal "><?= $each['opening'] ?></td>
|
||||
<td class="celda_normal "><?= $each['receipt'] ?></td>
|
||||
<td class="celda_normal "><?= $each['used'] ?></td>
|
||||
<td class="celda_normal "><?= $each['balanceStock'] ?></td>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- this else condition work if groupedBagStockDetails is empty and creating new records
|
||||
@ -511,7 +527,7 @@ foreach ($period as $day) {
|
||||
}
|
||||
?>>
|
||||
<?php
|
||||
// dd($resinMaterials);
|
||||
// dd($resinMaterials);
|
||||
foreach ($resinMaterials as $resinMaterialIndex => $resinMaterial) { ?>
|
||||
<!-- this will loop till materials present -->
|
||||
|
||||
@ -640,6 +656,86 @@ foreach ($period as $day) {
|
||||
|
||||
|
||||
|
||||
<!---------------------------------------
|
||||
this modal is used to customize table header
|
||||
1)list table header order
|
||||
2)choose which material/machines you want
|
||||
------------------------------------------------------------>
|
||||
|
||||
<div>
|
||||
<div class="modal fade" id="customizeModalId" tabindex="-1" role="dialog" aria-labelledby="customizeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-md">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="customizeModalLabel">Customize</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<!-- Dropdown to add back removed items -->
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="customizeHeader"> Add For This Month </label>
|
||||
<select id="customizeHeader" class="form-control" onchange="addBackToList()">
|
||||
<option value="">Select</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h5>List of Selected Items</h5>
|
||||
|
||||
|
||||
|
||||
|
||||
<div id="selectedItemsContainer">
|
||||
<ul id="sortableList">
|
||||
<?php foreach ($resinMaterials as $resinMaterial): ?>
|
||||
|
||||
<div class="sortable-item" draggable="true" id="<?= $resinMaterial['MaterialCode'] ?>_container">
|
||||
<input type="checkbox"
|
||||
id="<?= $resinMaterial['MaterialCode'] ?>_checkboxId"
|
||||
name="materialCodes[]"
|
||||
value="<?= $resinMaterial['MaterialCode'] ?>"
|
||||
onclick="removeSelectedMaterial(this)"
|
||||
checked>
|
||||
<label class="grab" for="<?= $resinMaterial['MaterialCode'] ?>_checkboxId">
|
||||
<?= $resinMaterial['MaterialName']; ?>
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
|
||||
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary float-right"> Apply </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- modal section ends -->
|
||||
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
function navigateToResin() {
|
||||
@ -817,7 +913,7 @@ foreach ($period as $day) {
|
||||
}
|
||||
|
||||
function receiptStockChange(tdElement) {
|
||||
try {
|
||||
try {
|
||||
let dataId = tdElement.getAttribute('data-id');
|
||||
let [date, materialCode] = tdElement.getAttribute('data-id').split(' ');
|
||||
let openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText);
|
||||
@ -845,7 +941,7 @@ foreach ($period as $day) {
|
||||
let [date, materialCode] = tdElement.getAttribute('data-id').split(' ');
|
||||
let openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText);
|
||||
let receiptStock = validateInput(document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText);
|
||||
let usedStock = validateInput(tdElement.innerText);
|
||||
let usedStock = validateInput(tdElement.innerText);
|
||||
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
|
||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
|
||||
|
||||
@ -881,8 +977,6 @@ foreach ($period as $day) {
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
@ -921,20 +1015,19 @@ foreach ($period as $day) {
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function() {
|
||||
|
||||
function exportTableToExcel(tableID, filename = '') {
|
||||
let table = document.getElementById(tableID);
|
||||
let cloneTable = table.cloneNode(true); // Clone the table to modify
|
||||
|
||||
|
||||
// Remove hidden rows
|
||||
$(cloneTable).find('tr').filter(function () {
|
||||
$(cloneTable).find('tr').filter(function() {
|
||||
return $(this).css('display') === 'none';
|
||||
}).remove();
|
||||
|
||||
|
||||
// Remove hidden columns
|
||||
$(cloneTable).find('th, td').each(function () {
|
||||
$(cloneTable).find('th, td').each(function() {
|
||||
if ($(this).css('display') === 'none') {
|
||||
$(this).remove();
|
||||
}
|
||||
@ -948,53 +1041,139 @@ foreach ($period as $day) {
|
||||
|
||||
let tableId = 'resinStockDetailsTableId';
|
||||
|
||||
document.getElementById('resinStockExport').addEventListener('click',function(){
|
||||
document.getElementById('resinStockExport').addEventListener('click', function() {
|
||||
|
||||
exportTableToExcel(tableId,'Resin_Stock_Details<?=$month?>.xlsx');
|
||||
exportTableToExcel(tableId, 'Resin_Stock_Details<?= $month ?>.xlsx');
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener("keydown", function (event) {
|
||||
document.addEventListener("keydown", function(event) {
|
||||
|
||||
if (event.key === "Enter") {
|
||||
if (event.key === "Enter") {
|
||||
|
||||
let activeElement = document.activeElement;
|
||||
let activeElement = document.activeElement;
|
||||
|
||||
// Check if the focused element is inside a table
|
||||
let cell = activeElement.closest("td, th");
|
||||
let table = activeElement.closest("table");
|
||||
// Check if the focused element is inside a table
|
||||
let cell = activeElement.closest("td, th");
|
||||
let table = activeElement.closest("table");
|
||||
|
||||
if (table && cell) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
if (table && cell) {
|
||||
event.preventDefault(); // Prevent form submission
|
||||
|
||||
let columnIndex = cell.cellIndex; // Get the current column index
|
||||
let columnIndex = cell.cellIndex; // Get the current column index
|
||||
|
||||
let currentRow = cell.parentElement; // Get the current row
|
||||
|
||||
let nextRow = currentRow.nextElementSibling; // Get the next row
|
||||
|
||||
let currentRow = cell.parentElement; // Get the current row
|
||||
|
||||
// Move to the same column in the next row if available
|
||||
if (nextRow) {
|
||||
|
||||
let nextRow = currentRow.nextElementSibling; // Get the next row
|
||||
|
||||
let nextCell = nextRow.cells[columnIndex];
|
||||
|
||||
if (nextCell) {
|
||||
// Move to the same column in the next row if available
|
||||
if (nextRow) {
|
||||
|
||||
nextCell.focus();
|
||||
|
||||
let nextCell = nextRow.cells[columnIndex];
|
||||
|
||||
if (nextCell) {
|
||||
|
||||
nextCell.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const list = document.getElementById("sortableList");
|
||||
|
||||
let draggedItem = null;
|
||||
|
||||
function attachDragEvents(item) {
|
||||
item.setAttribute("draggable", "true");
|
||||
|
||||
item.addEventListener("dragstart", (event) => {
|
||||
draggedItem = event.target;
|
||||
event.target.classList.add("dragging");
|
||||
});
|
||||
|
||||
item.addEventListener("dragend", (event) => {
|
||||
event.target.classList.remove("dragging");
|
||||
});
|
||||
}
|
||||
|
||||
list.addEventListener("dragover", (event) => {
|
||||
event.preventDefault(); // Allow dropping
|
||||
const dragging = document.querySelector(".dragging");
|
||||
const closestItem = getClosestItem(list, event.clientY);
|
||||
|
||||
if (closestItem) {
|
||||
list.insertBefore(dragging, closestItem);
|
||||
} else {
|
||||
list.appendChild(dragging);
|
||||
}
|
||||
});
|
||||
|
||||
function getClosestItem(container, y) {
|
||||
const items = [...container.querySelectorAll(".sortable-item:not(.dragging)")];
|
||||
|
||||
return items.reduce((closest, child) => {
|
||||
const box = child.getBoundingClientRect();
|
||||
const offset = y - box.top - box.height / 2;
|
||||
|
||||
return offset < 0 && offset > closest.offset
|
||||
? { offset, element: child }
|
||||
: closest;
|
||||
}, { offset: Number.NEGATIVE_INFINITY }).element;
|
||||
}
|
||||
|
||||
// Attach drag events to existing items
|
||||
document.querySelectorAll(".sortable-item").forEach(attachDragEvents);
|
||||
|
||||
window.removeSelectedMaterial = function (checkbox) {
|
||||
let container = checkbox.closest(".sortable-item");
|
||||
let materialCode = checkbox.value;
|
||||
let materialName = container.querySelector("label").innerText;
|
||||
|
||||
let dropdown = document.getElementById("customizeHeader");
|
||||
let newOption = document.createElement("option");
|
||||
newOption.value = materialCode;
|
||||
newOption.text = materialName;
|
||||
dropdown.appendChild(newOption);
|
||||
|
||||
container.remove();
|
||||
};
|
||||
|
||||
window.addBackToList = function () {
|
||||
let dropdown = document.getElementById("customizeHeader");
|
||||
let selectedOption = dropdown.options[dropdown.selectedIndex];
|
||||
|
||||
if (selectedOption.value !== "") {
|
||||
let materialCode = selectedOption.value;
|
||||
let materialName = selectedOption.text;
|
||||
|
||||
let container = document.createElement("div");
|
||||
container.classList.add("sortable-item");
|
||||
container.id = materialCode + "_container";
|
||||
container.innerHTML = `
|
||||
<input type="checkbox" id="${materialCode}_checkboxId"
|
||||
name="materialCodes[]" value="${materialCode}"
|
||||
onclick="removeSelectedMaterial(this)" checked>
|
||||
<label class="grab" for="${materialCode}_checkboxId"> ${materialName} </label>
|
||||
<br>
|
||||
`;
|
||||
|
||||
attachDragEvents(container);
|
||||
|
||||
document.getElementById("sortableList").appendChild(container);
|
||||
dropdown.removeChild(selectedOption);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user