Merge with stock code : ps

This commit is contained in:
VE10-Sanjeev 2025-01-28 12:05:28 +00:00
commit ec0388aebc
9 changed files with 563 additions and 274 deletions

View File

@ -1698,7 +1698,7 @@ class StockController extends BaseController
while ($start <= $end) {
$timeValue = date('H:i', $start); // 24-hour format for value
$timeLabel = date('h:i A', $start); // 12-hour format with AM/PM for display
$timeLabel = date('h:i a', $start); // 12-hour format with AM/PM for display
$times[$timeValue] = $timeLabel; // Store time in associative array
$start = strtotime('+15 minutes', $start); // Increment by 15 minutes
}
@ -1737,138 +1737,118 @@ class StockController extends BaseController
public function addOrEditdrierMachineDetails()
{
$drierData = [];
$drierData = json_decode($this->request->getPost('drierData'), true);
$drierData = json_decode($this->request->getPost('drierData'), true) ?? [];
// If drierData is empty, check for additionalEntry
if (empty($drierData)) {
$additionalEntry = $this->request->getPost();
if (!empty($additionalEntry)) {
$drierData[] = [
'Date' => $this->convertToDateWithFlexibleFormats($additionalEntry['Date'], ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d"),
'Drier On Time' => $additionalEntry['Drier_On_Time'],
'Drier Off Time' => $additionalEntry['Drier_Off_Time'],
'Running Hrs' => $additionalEntry['Running_Hrs'],
'Supplier Name' => $additionalEntry['Supplier_Name'],
'i/p Sand Moisture(%)' => $additionalEntry['i/p_Sand_Moisture(%)'],
'Tot Gas Consumption' => $additionalEntry['Tot_Gas_Consumption'],
'Gas Per Ton' => $additionalEntry['Gas_Per_Ton'],
'i/p Sand Qty' => $additionalEntry['i/p_Sand_Qty'],
'Moisture Loss Qty' => $additionalEntry['Moisture_Loss_Qty'],
'Sand Dried Qty' => $additionalEntry['Sand_Dried_Qty'],
'Qty Per Hrs' => $additionalEntry['Qty_Per_Hrs'],
'Dust Qty' => $additionalEntry['Dust_Qty'],
'Customer Name' => $additionalEntry['Customer_Name']
];
} else {
if (empty($additionalEntry)) {
echo "No data received.";
return;
}
$drierData[] = $this->mapDrierEntry($additionalEntry);
}
$message1 = '';
$this->db->transBegin();
try {
$inserts = [];
$updates = [];
foreach ($drierData as $row) {
$data = [
'date' => $this->convertToDateWithFlexibleFormats($row['Date'], ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d"),
'drier_on_time' => $row['Drier On Time'],
'drier_off_time' => $row['Drier Off Time'],
'drier_running_hours' => $row['Running Hrs'],
'supplier_name' => $row['Supplier Name'],
'input_sand_moisture' => $row['i/p Sand Moisture(%)'],
'total_gas_consumption' => $row['Tot Gas Consumption'],
'gas_per_ton' => $row['Gas Per Ton'],
'input_sand_qty' => $row['i/p Sand Qty'],
'moisture_loss_qty' => $row['Moisture Loss Qty'],
'sand_dried_qty' => $row['Sand Dried Qty'],
'qty_per_hours' => $row['Qty Per Hrs'],
'dust_qty' => $row['Dust Qty'],
'customer_name' => $row['Customer Name']
];
// Check if a row with the same date already exists
$existingRow = $this->drierMachineDetails_model->where('id', $row['id'] ?? '')->first();
$inserts = [];
$updates = [];
$data = $this->mapDrierEntry($row, $existingRow);
if ($existingRow) {
// If exists, update the row
//before updating the row update gas stock
$existingDrierGasConsumption = $existingRow['total_gas_consumption'];
$updatedDrierGasConsumption = $row['Tot Gas Consumption'];
if ($existingDrierGasConsumption != $updatedDrierGasConsumption) {
$changeInConsumption = $updatedDrierGasConsumption - $existingDrierGasConsumption;
$dateToBeUpdated = $existingRow['date'];
$this->updateGasStockConsumption($dateToBeUpdated, $changeInConsumption);
}
$data['id'] = $existingRow['id'];
$this->handleGasStockUpdate($existingRow, $row);
$updates[] = $data;
} else {
// If not, insert a new row
//before inserting the row update gas stock
$consumption = $row['Tot Gas Consumption'];
$dateToBeInserted = $data['date'];
$this->updateGasStockConsumption($dateToBeInserted, $consumption);
$this->updateGasStockConsumption($data['date'], $data['total_gas_consumption']);
$inserts[] = $data;
}
if (!empty($inserts)) {
$this->drierMachineDetails_model->insertBatch($inserts);
$message1 = "Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!";
}
if (!empty($updates)) {
$this->drierMachineDetails_model->updateBatch($updates, 'id');
$message1 = "Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!";
}
if ($this->db->transStatus() === false) {
throw new \Exception('Transaction failed due to database error.');
}
}
if (!empty($inserts)) {
$this->drierMachineDetails_model->insertBatch($inserts);
}
if (!empty($updates)) {
$this->drierMachineDetails_model->updateBatch($updates, 'id');
}
if ($this->db->transStatus() === false) {
throw new \Exception('Transaction failed due to database error.');
}
$this->db->transCommit();
if (!empty($additionalEntry)) {
// Data to be sent via POST
$postData = [
'month' => $this->convertToDateWithFlexibleFormats($additionalEntry['Date'], ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "M-Y"),
];
echo '<form id="postForm" action="' . base_url('drierMachineDetails') . '" method="POST">';
foreach ($postData as $key => $value) {
echo '<input type="hidden" name="' . $key . '" value="' . $value . '">';
}
echo '</form>';
echo '<script type="text/javascript">
document.getElementById("postForm").submit();
</script>';
exit;
// Redirect if additional entry was provided
if (!empty($additionalEntry)) {
$this->redirectToDrierMachineDetails($additionalEntry['date']);
return;
}
echo "Data saved successfully . $message1";
} catch (\Exception $e) {
// Rollback the transaction on any failure
echo "Data saved successfully. Warning..!! Kindly Update the next subsequent month Gas Stock If older month Gas Stock Updated..!!";
} catch (\Exception $e) {
$this->db->transRollback();
echo "Failed to save/Update data: " . $e->getMessage();
}
}
/**
* Maps input row to expected format.
*/
private function mapDrierEntry(array $row, $existingRow = null): array
{
return [
'id' => $existingRow['id'] ?? null,
'date' => $this->convertToDateWithFlexibleFormats($row['date'], ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d"),
'drier_on_time' => $row['drier_on_time'],
'drier_off_time' => $row['drier_off_time'],
'drier_running_hours' => $row['drier_running_hours'],
'supplier_name' => $row['supplier_name'],
'input_sand_moisture' => $row['input_sand_moisture'],
'total_gas_consumption' => $row['total_gas_consumption'],
'gas_per_ton' => $row['gas_per_ton'],
'input_sand_qty' => $row['input_sand_qty'],
'moisture_loss_qty' => $row['moisture_loss_qty'],
'sand_dried_qty' => $row['sand_dried_qty'],
'qty_per_hours' => $row['qty_per_hours'],
'dust_qty' => $row['dust_qty'],
'customer_name' => $row['customer_name']
];
}
/**
* Updates gas stock consumption if the value changes.
*/
private function handleGasStockUpdate($existingRow, $newRow)
{
$existingConsumption = $existingRow['total_gas_consumption'];
$updatedConsumption = $newRow['total_gas_consumption'];
if ($existingConsumption != $updatedConsumption) {
$changeInConsumption = $updatedConsumption - $existingConsumption;
$this->updateGasStockConsumption($existingRow['date'], $changeInConsumption);
}
}
/**
* Redirects to the drier machine details page.
*/
private function redirectToDrierMachineDetails(string $date)
{
$postData = ['month' => $this->convertToDateWithFlexibleFormats($date, ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "M-Y")];
echo '<form id="postForm" action="' . base_url('drierMachineDetails') . '" method="POST">';
foreach ($postData as $key => $value) {
echo '<input type="hidden" name="' . $key . '" value="' . $value . '">';
}
echo '</form>';
echo '<script type="text/javascript">document.getElementById("postForm").submit();</script>';
exit;
}
function convertToDateWithFlexibleFormats($dateInput, array $inputFormats, string $outputFormat): ?string
{

View File

@ -6,7 +6,7 @@ use CodeIgniter\Model;
class PowerConsumptionSummaryModel extends Model
{
protected $table = 't_powerConsumptionSummary';
protected $table = 't_powerconsumptionsummary';
protected $primaryKey = 'id';
protected $allowedFields = [

View File

@ -169,7 +169,7 @@ class Rawmaterialdetails_model extends Model
$builder = $this->db->table('t_materialmaster')
->select('MaterialCode , MaterialName')
->where('IsActive', 1)
->where('Category', 'bag')
->where('Category', 'Packing Material')
->orderBy('MaterialCode', 'asc');
$query = $builder->get();
$materialResults = $query->getResultArray();
@ -199,7 +199,7 @@ class Rawmaterialdetails_model extends Model
$builder = $this->db->table('t_materialmaster')
->select('MaterialCode , MaterialName')
->where('IsActive', 1)
->where('Category', 'plastic_chemicals')
->where('Category', 'Resin')
->orderBy('MaterialCode', 'asc');
$query = $builder->get();
$materialResults = $query->getResultArray();

View File

@ -295,10 +295,10 @@
<a href="#" class="dropdown-toggle arrow-none" data-toggle="dropdown"
aria-expanded="false">
<i class="mdi mdi-dots-vertical m-0 text-muted h3"></i>
</a>
</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a>
<a class="dropdown-item" href="#">Export</a>
<a class="dropdown-item" id="bagStockExport" href="#">Export</a>
</div>
</div>
</div>
@ -968,3 +968,44 @@
</script>
<script>
$(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 () {
return $(this).css('display') === 'none';
}).remove();
// Remove hidden columns
$(cloneTable).find('th, td').each(function () {
if ($(this).css('display') === 'none') {
$(this).remove();
}
});
let ws = XLSX.utils.table_to_sheet(cloneTable); // Convert modified table to sheet
let wb = XLSX.utils.book_new(); // Create a new workbook
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); // Append sheet to workbook
XLSX.writeFile(wb, filename || 'export.xlsx'); // Save the file
}
let tableId = 'bagStockDetailsTableId';
document.getElementById('bagStockExport').addEventListener('click',function(){
exportTableToExcel(tableId,'Bag_Stock_Details<?=$month?>.xlsx');
})
})
</script>

View File

@ -630,6 +630,7 @@ foreach ($period as $day) {
with initial values 0 for entire month -->
<?php } else { ?>
<?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { ?>
<tr
@ -663,7 +664,10 @@ foreach ($period as $day) {
<?php } ?>
><?= $previousMonthTotalDieselMachineStockDetails[0]['balance_stock'] ?></td>
><?= !empty($previousMonthTotalDieselMachineStockDetails)
? $previousMonthTotalDieselMachineStockDetails[0]['balance_stock']
:" " ;
?></td>
@ -679,7 +683,11 @@ foreach ($period as $day) {
<td class="celda_normal balanceTD"
data-id="<?= $dateInMonth ?>"
><?= $previousMonthTotalDieselMachineStockDetails[0]['balance_stock'] ?></td>
><?= !empty($previousMonthTotalDieselMachineStockDetails)
? $previousMonthTotalDieselMachineStockDetails[0]['balance_stock']
:" " ;
?>
</td>
@ -708,14 +716,22 @@ foreach ($period as $day) {
contenteditable="true"
<?php } ?>
><?= $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading'] ?>
><?= !empty($previousMonthDieselMachineStockDetails)
? $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading']
:" " ;
?>
</td>
<td class="celda_normal closingReading"
data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>"
oninput="closingReadingChange(this)"
contenteditable="true"><?= $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading'] ?>
contenteditable="true"><?= !empty($previousMonthDieselMachineStockDetails)
? $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading']
:" " ;
?>
</td>
<td class="celda_normal fillingDiesel"

View File

@ -193,7 +193,6 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
color: #ffffff;
font-weight: bold;
padding: 6px 10px;
text-align: center;
}
.celda_encabezado_total {
@ -210,7 +209,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
/* <!-- ad9271 into ffffff brown-light to green-light --> */
text-align: center;
border: 1px solid #ccc;
padding: 10px 6px;
padding: 4px 6px;
}
@ -230,13 +229,19 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
/* Ensure each <th> in thead stays sticky */
.fht-table thead th {
position: sticky;
top: 0;
z-index: 11; /* Higher than table rows but lower than first column */
background-color: #00a65a; /* Green background */
background-color:rgb(80, 187, 217); /* blue background */
color: #ffffff;
border: 1px solid #ddd;
padding: 10px;
padding:5px;
white-space: normal; /* Allows text to wrap */
word-wrap: break-word; /* Breaks long words if needed */
text-align: center; /* Centers text for better alignment */
max-width: 150px; /* Set a max width to control wrapping */
}
/* Sticky First Column */
@ -244,7 +249,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
.fht-table td:nth-child(1) {
position: sticky;
left: 0;
background-color: #00a65a;
background-color:rgb(80, 187, 217); /* blue background */
z-index: 15; /* Ensures it stays above other cells */
border-right: 2px solid #ddd;
color: #ffffff;
@ -286,9 +291,10 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
</div>
</div>
<div class="col-6 text-right">
<div class="col-4 text-right">
<!-- Right-aligned buttons or links can be added here -->
</div>
</div>
</div>
@ -309,8 +315,11 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
</div>
<div class="col-3">
<input type="submit" value="Change Month" class="btn btn-success" style="margin-top:0px;">
</div>
<button type="button" style="margin-top:0px; background-color:grey" class="btn btn-success" data-target="#additionalEntriesModalId" data-toggle="modal">
Add Shift
</button>
</div>
<div class="col-6">
<div class="dropdown float-right">
<a href="#" class="dropdown-toggle arrow-none" data-toggle="dropdown"
@ -320,8 +329,6 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<div class="dropdown-menu dropdown-menu-right">
<a style="cursor:pointer"
class="dropdown-item" data-toggle="modal" data-target="#filterModalId">Filter</a>
<a style="cursor:pointer"
class="dropdown-item" data-toggle="modal" data-target="#additionalEntriesModalId">Add Entry</a>
<a style="cursor:pointer"
class="dropdown-item" id="drierMachineDetailsExport" href="#">Export</a>
</div>
@ -339,20 +346,22 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<tr>
<th class="celda_encabezado_general" style="padding: 10px;">Date</th>
<th class="celda_encabezado_general" style="padding: 10px;">Drier On Time</th>
<th class="celda_encabezado_general" style="padding: 10px;">Drier Off Time</th>
<th class="celda_encabezado_general" style="padding: 10px;">Running Hrs</th>
<th class="celda_encabezado_general" style="padding: 10px;">Supplier Name</th>
<th class="celda_encabezado_general" style="padding: 10px;">i/p Sand Moisture(%)</th>
<th class="celda_encabezado_general" style="padding: 10px;">Tot Gas Consumption</th>
<th class="celda_encabezado_general" style="padding: 10px;">Gas Per Ton</th>
<th class="celda_encabezado_general" style="padding: 10px;">i/p Sand Qty</th>
<th class="celda_encabezado_general" style="padding: 10px;">Moisture Loss Qty</th>
<th class="celda_encabezado_general" style="padding: 10px;">Sand Dried Qty</th>
<th class="celda_encabezado_general" style="padding: 10px;">Qty Per Hrs</th>
<th class="celda_encabezado_general" style="padding: 10px;">Dust Qty</th>
<th class="celda_encabezado_general" style="padding: 10px;">Customer Name</th>
<th class="celda_encabezado_general" style="padding:5px;">Date</th>
<th class="celda_encabezado_general" style="padding:5px;">Drier On Time</th>
<th class="celda_encabezado_general" style="padding:5px;">Drier Off Time</th>
<th class="celda_encabezado_general" style="padding:5px;">Running Hrs</th>
<th class="celda_encabezado_general" style="padding:5px;">Supplier Name</th>
<th class="celda_encabezado_general" style="padding:5px;">Input Sand Qty</th>
<th class="celda_encabezado_general" style="padding:5px;">Input Sand Moisture(%)</th>
<th class="celda_encabezado_general" style="padding:5px;">Sand Dried Qty</th>
<th class="celda_encabezado_general" style="padding:5px;">Total Gas Consumption</th>
<th class="celda_encabezado_general" style="padding:5px;">Gas Per Ton</th>
<th class="celda_encabezado_general" style="padding:5px;">Qty Per Hrs</th>
<th class="celda_encabezado_general" style="padding:5px;">Moisture Loss Qty</th>
<th class="celda_encabezado_general" style="padding:5px;">Dust Qty</th>
<th class="celda_encabezado_general" style="padding:5px;">Customer Name</th>
<th class="celda_encabezado_general" style="display:none;">id</th>
</tr>
@ -431,46 +440,54 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
</select>
</td>
<!-- td:eq(5) input_sand_moisture -->
<!-- td:eq(5) input_sand_qty -->
<td class="celda_normal" oninput="gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this)" contenteditable="true">
<?php echo $a['input_sand_qty']; ?>
</td>
<!-- td:eq(6) input_sand_moisture -->
<td class="celda_normal" contenteditable="true">
<?php echo $a['input_sand_moisture']; ?>
</td>
<!-- td:eq(6) total_gas_consumption -->
<!-- td:eq(7) sand_dried_qty -->
<td class="celda_normal" oninput="gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this)" contenteditable="true">
<?php echo $a['sand_dried_qty']; ?>
</td>
<!-- td:eq(8) total_gas_consumption -->
<td class="celda_normal" oninput="gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this)" contenteditable="true">
<?php echo $a['total_gas_consumption']; ?>
</td>
<!-- td:eq(7) gas_per_ton -->
<!-- td:eq(9) gas_per_ton -->
<td class="celda_normal">
<?php echo $a['gas_per_ton']; ?>
</td>
<!-- td:eq(8) input_sand_qty -->
<td class="celda_normal" oninput="gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this)" contenteditable="true">
<?php echo $a['input_sand_qty']; ?>
<!-- td:eq(10) qty_per_hours -->
<td class="celda_normal">
<?php echo $a['qty_per_hours']; ?>
</td>
<!-- td:eq(9) moisture_loss_qty -->
<!-- td:eq(11) moisture_loss_qty -->
<td class="celda_normal">
<?php echo $a['moisture_loss_qty']; ?>
</td>
<!-- td:eq(10) sand_dried_qty -->
<td class="celda_normal" oninput="gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this)" contenteditable="true">
<?php echo $a['sand_dried_qty']; ?>
</td>
<!-- td:eq(11) qty_per_hours -->
<td class="celda_normal">
<?php echo $a['qty_per_hours']; ?>
</td>
<!-- td:eq(12) dust_qty -->
<td class="celda_normal" contenteditable="true">
@ -522,21 +539,23 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<table id="drierTableSummaryId" class="fht-table table-striped">
<thead >
<tr>
<th class="celda_encabezado_total"
style="padding: 10px; border:#ffffff; background-color: #ffffff;">Date value</th>
<th class="celda_encabezado_total" style="padding: 10px;">Drier On Time </th>
<th class="celda_encabezado_total" style="padding: 10px;">Drier Off Time</th>
<th class="celda_encabezado_total" style="padding: 10px;">Running Hrs</th>
<th class="celda_encabezado_total" style="padding: 10px;">Supplier Name is a dropdown feature</th>
<th class="celda_encabezado_total" style="padding: 10px;">i/p Sand Moisture(%)</th>
<th class="celda_encabezado_total" style="padding: 10px;">Tot Gas Consumption</th>
<th class="celda_encabezado_total" style="padding: 10px;">Gas Per Ton</th>
<th class="celda_encabezado_total" style="padding: 10px;">i/p Sand Qty</th>
<th class="celda_encabezado_total" style="padding: 10px;">Moisture Loss Qty</th>
<th class="celda_encabezado_total" style="padding: 10px;">Sand Dried Qty</th>
<th class="celda_encabezado_total" style="padding: 10px;">Qty Per Hrs</th>
<th class="celda_encabezado_total" style="padding: 10px;">Dust Qty</th>
style="padding:5px; border:#ffffff; background-color: #ffffff;">Date value</th>
<th class="celda_encabezado_total" style="padding:5px;">Drier On Time </th>
<th class="celda_encabezado_total" style="padding:5px;">Drier Off Time</th>
<th class="celda_encabezado_total" style="padding:5px;">Running Hrs</th>
<th class="celda_encabezado_total" style="padding:5px;">Supplier Name </th>
<th class="celda_encabezado_total" style="padding:5px;">input Sand Qty</th>
<th class="celda_encabezado_total" style="padding:5px;">inputp Sand Moisture(%)</th>
<th class="celda_encabezado_total" style="padding:5px;">Sand Dried Qty</th>
<th class="celda_encabezado_total" style="padding:5px;">Total Gas Consumption</th>
<th class="celda_encabezado_total" style="padding:5px;">Gas Per Ton</th>
<th class="celda_encabezado_total" style="padding:5px;">Qty Per Hrs</th>
<th class="celda_encabezado_total" style="padding:5px;">Moisture Loss Qty</th>
<th class="celda_encabezado_total" style="padding:5px;">Dust Qty</th>
</tr>
</thead>
@ -548,17 +567,18 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<td class="celda_normal ">-</td>
<td class="celda_normal ">-</td>
<td class="celda_normal ">-</td>
<td class="celda_normal ">-</td>
<td class="celda_normal "><?=$summary['drier_running_hours']?></td>
<td class="celda_normal ">-</td>
<td class="celda_normal ">-</td>
<td class="celda_normal "><?=$summary['total_gas_consumption']?></td>
<td class="celda_normal ">-</td>
<td class="celda_normal "><?=$summary['input_sand_qty']?></td>
<td class="celda_normal "><?=$summary['moisture_loss_qty']?></td>
<td class="celda_normal "><?=$summary['sand_dried_qty']?></td>
<td class="celda_normal ">-</td>
<td class="celda_normal "><?=$summary['sand_dried_qty']?></td>
<td class="celda_normal "><?=$summary['total_gas_consumption']?></td>
<td class="celda_normal "></td>
<td class="celda_normal "></td>
<td class="celda_normal "><?=$summary['moisture_loss_qty']?></td>
<td class="celda_normal "><?=$summary['dust_qty']?></td>
</tr>
@ -581,10 +601,11 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
</div><!-- End table-responsive -->
<br>
<div class="row">
<div class="col-md-12 text-right">
<input type="button" class="btn btn-success" id="save" value="save">
<input type="button" class="btn btn-success btn-md px-3" id="save" value="save">
</div>
</div>
@ -691,7 +712,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<div class="row">
<div class="col-md-3">
<label class="form" for="additionalEntryDateId">Date</label>
<input type="date" class="form-control" id="additionalEntryDateId" name="Date" value="<?= $calendarStartDate?>"
<input type="date" class="form-control" id="additionalEntryDateId" name="date" value="<?= $calendarStartDate?>"
min="<?= $calendarStartDate?>" max="<?=$calendarEndDate?>" required>
</div>
<div class="col-md-3">
@ -699,7 +720,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<select onchange="calculateMachineRunningHrs()"
class="timeDropdown" style="width: 100px;"
id="additionalEntryDrierOnTimeId" name="Drier On Time">
id="additionalEntryDrierOnTimeId" name="drier_on_time">
<option value="">Select</option>
<?php foreach ($timeDropdown as $key => $time) { ?>
<option value="<?= $time; ?>"> <?= $time; ?></option>
@ -711,7 +732,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<select onchange="calculateMachineRunningHrs()"
class="timeDropdown " style="width: 100px;"
id="additionalEntryDrierOffTimeId" name="Drier Off Time">
id="additionalEntryDrierOffTimeId" name="drier_off_time">
<option value="">Select</option>
<?php foreach ($timeDropdown as $key => $time) { ?>
<option value="<?= $time; ?>"> <?= $time; ?></option>
@ -720,7 +741,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryRunningHrsId">Running hrs</label>
<input type="text" class="form-control" id="additionalEntryRunningHrsId" name="Running Hrs" value=""
<input type="text" class="form-control" id="additionalEntryRunningHrsId" name="drier_running_hours" value=""
readonly>
</div>
</div>
@ -728,21 +749,21 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<div class="row mt-2">
<div class="col-md-3">
<label class="form" for="additionalEntryInputSandMoistureId">Input Sand Moisture (%)</label>
<input type="text" class="form-control" id="additionalEntryInputSandMoistureId" name="i/p Sand Moisture(%)" value="">
<input type="text" class="form-control" id="additionalEntryInputSandMoistureId" name="input_sand_moisture" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryTotalGasConsumptionId">Total Gas Consumption</label>
<input onchange="additionalEntryGasPerTon(); additionalEntryMoistureLossQty(); additionalEntryQtyPerHrs(); "
type="text" class="form-control" id="additionalEntryTotalGasConsumptionId" name="Tot Gas Consumption" value="">
type="text" class="form-control" id="additionalEntryTotalGasConsumptionId" name="total_gas_consumption" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntrySandDriedQtyId">Sand Dried Qty</label>
<input onchange="additionalEntryGasPerTon(); additionalEntryMoistureLossQty(); additionalEntryQtyPerHrs(); "
type="text" class="form-control" id="additionalEntrySandDriedQtyId" name="Sand Dried Qty" value="">
type="text" class="form-control" id="additionalEntrySandDriedQtyId" name="sand_dried_qty" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryGasPerTonId">Gas per Ton</label>
<input type="text" class="form-control" id="additionalEntryGasPerTonId" name="Gas Per Ton" value=""
<input type="text" class="form-control" id="additionalEntryGasPerTonId" name="gas_per_ton" value=""
readonly>
</div>
</div>
@ -750,21 +771,21 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<div class="row mt-2">
<div class="col-md-3">
<label class="form" for="additionalEntryDustQtyId">Dust Qty</label>
<input type="text" class="form-control" id="additionalEntryDustQtyId" name="Dust Qty" value="">
<input type="text" class="form-control" id="additionalEntryDustQtyId" name="dust_qty" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryInputSandQtyId">Input sand Quantity</label>
<input onchange="additionalEntryGasPerTon(); additionalEntryMoistureLossQty(); additionalEntryQtyPerHrs(); "
type="text" class="form-control" id="additionalEntryInputSandQtyId" name="i/p Sand Qty" value="">
type="text" class="form-control" id="additionalEntryInputSandQtyId" name="input_sand_qty" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryMoistureLossQtyId">Moisture Loss Qty</label>
<input type="text" class="form-control" id="additionalEntryMoistureLossQtyId" name="Moisture Loss Qty" value=""
<input type="text" class="form-control" id="additionalEntryMoistureLossQtyId" name="moisture_loss_qty" value=""
readonly>
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryQtyPerHoursId">Qty per Hours</label>
<input type="text" class="form-control" id="additionalEntryQtyPerHoursId" name="Qty Per Hrs" value=""
<input type="text" class="form-control" id="additionalEntryQtyPerHoursId" name="qty_per_hours" value=""
readonly>
</div>
</div>
@ -773,7 +794,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<div class="col-md-3">
<label class="form" for="additionalEntrySupplierNameId">Supplier Name</label>
<select class="timeDropdown supplier_name" style="width: 300px;"
id="additionalEntrySupplierNameId" name="Supplier Name">
id="additionalEntrySupplierNameId" name="supplier_name">
<option value="">Select</option>
<?php foreach ($supplierData as $key => $value) { ?>
<option value="<?= $value->SupplierID; ?>"> <?= $value->SupplierName; ?> </option>
@ -782,7 +803,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryCustomerNameId">Customer Name</label>
<input type="text" class="form-control" id="additionalEntryCustomerNameId" name="Customer Name" value="">
<input type="text" class="form-control" id="additionalEntryCustomerNameId" name="customer_name" value="">
</div>
</div>
<button type="submit" class="btn btn-primary float-right">Add</button>
@ -806,56 +827,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<script>
$(document).ready(function(){
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let rows = table.rows;
let data = [];
for (let i = 0; i < rows.length; i++) {
let row = rows[i];
let cols = row.querySelectorAll('td, th');
let rowData = [];
for (let j = 0; j < cols.length; j++) {
let cell = cols[j];
// Check if the cell contains a <select> dropdown
let select = cell.querySelector('select');
if (select) {
rowData.push(select.options[select.selectedIndex].text); // Get only selected value
} else {
rowData.push(cell.innerText.trim()); // Normal text
}
}
data.push(rowData);
}
let wb = XLSX.utils.book_new();
let ws = XLSX.utils.aoa_to_sheet(data);
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'drierTable';
document.getElementById('drierMachineDetailsExport').addEventListener('click',function(){
exportTableToExcel(tableId,'drierMachineDetails_<?=$datefordropdown?>.xlsx');
})
})
</script>
<!-- script section starts -->
<script type="text/javascript">
@ -867,25 +839,53 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
$('#save').click(function() {
var alldata = $("#drierTable").tableToJSON();
console.log('alldata', alldata);
let alldata = [];
$("#drierTable").find('tbody tr').each(function() {
const rowCells = $(this).find('td');
const rowData = {
date : rowCells.eq(0).text().trim(),
drier_on_time : rowCells.eq(1).text().trim(),
drier_off_time : rowCells.eq(2).text().trim(),
drier_running_hours : rowCells.eq(3).text().trim(),
supplier_name : rowCells.eq(4).text().trim(),
input_sand_qty : rowCells.eq(5).text().trim(),
input_sand_moisture : rowCells.eq(6).text().trim(),
sand_dried_qty : rowCells.eq(7).text().trim(),
total_gas_consumption : rowCells.eq(8).text().trim(),
gas_per_ton : rowCells.eq(9).text().trim(),
qty_per_hours : rowCells.eq(10).text().trim(),
moisture_loss_qty : rowCells.eq(11).text().trim(),
dust_qty : rowCells.eq(12).text().trim(),
customer_name : rowCells.eq(13).text().trim(),
id : rowCells.eq(14).text().trim()
};
alldata.push(rowData);
})
$('#drierTable tbody tr:visible').each(function(index) {
if (alldata[index]) {
let row = alldata[index];
// Get the selected values from dropdowns
row['Drier On Time'] = $(this).find('.drier_on_time').val();
row['Drier Off Time'] = $(this).find('.drier_off_time').val();
row['Supplier Name'] = $(this).find('.supplier_name').val();
row['drier_on_time'] = $(this).find('.drier_on_time').val();
row['drier_off_time'] = $(this).find('.drier_off_time').val();
row['supplier_name'] = $(this).find('.supplier_name').val();
}
});
});
alldata = JSON.stringify(alldata);
@ -932,11 +932,24 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
var drierOnTime = $(this).val();
var drierOffTime = tr.find('.drier_off_time').val();
if(drierOnTime == drierOffTime){
tr.find('td:eq(3)').text(24.00);
gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this);
return;
}
if (drierOnTime != '' && drierOffTime != '') {
const startDate = new Date(`1970-01-01T${convertTo24Hour(drierOnTime)}`);
const endDate = new Date(`1970-01-01T${convertTo24Hour(drierOffTime)}`);
const endDate = new Date(`1970-01-01T${convertTo24Hour(drierOffTime)}`);
// Handle the case where end time is on the next day
if (endDate < startDate) {
@ -959,6 +972,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
qtyPerHrs(this);
return;
}
});
@ -969,6 +983,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
var drierOffTime = $(this).val();
var drierOnTime = tr.find('.drier_on_time').val();
if(drierOnTime == drierOffTime){
tr.find('td:eq(3)').text(24.00);
gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this);
return;
}
if (drierOnTime != '' && drierOffTime != '') {
const startDate = new Date(`1970-01-01T${convertTo24Hour(drierOnTime)}`);
@ -1002,17 +1027,21 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
});
</script>
<script>
function gasPerTon(value) {
let tr = $(value).closest('tr');
var totalGasConsumption = tr.find('td:eq(6)').text();
var sandDriedQty = tr.find('td:eq(10)').text();
var totalGasConsumption = tr.find('td:eq(8)').text();
var sandDriedQty = tr.find('td:eq(7)').text();
if (totalGasConsumption != '' && sandDriedQty != '') {
var gasPerTon = parseFloat(totalGasConsumption) / parseFloat(sandDriedQty);
if (gasPerTon && gasPerTon != NaN && gasPerTon != Infinity)
tr.find('td:eq(7)').text(gasPerTon.toFixed(2));
tr.find('td:eq(9)').text(gasPerTon.toFixed(2));
}
@ -1021,15 +1050,15 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
function moistureLossQty(value) {
let tr = $(value).closest('tr');
var inputSandQty = tr.find('td:eq(8)').text();
var sandDriedQty = tr.find('td:eq(10)').text();
var inputSandQty = tr.find('td:eq(5)').text();
var sandDriedQty = tr.find('td:eq(7)').text();
if (inputSandQty != '' && sandDriedQty != '') {
var moistureLossQty = parseFloat(inputSandQty) - parseFloat(sandDriedQty);
var moistureLossQty = parseFloat(inputSandQty) - parseFloat(sandDriedQty) ;
if (moistureLossQty != NaN && moistureLossQty != Infinity)
tr.find('td:eq(9)').text(moistureLossQty.toFixed(2));
tr.find('td:eq(11)').text(moistureLossQty.toFixed(2)) ;
}
@ -1039,14 +1068,14 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
let tr = $(value).closest('tr');
var drierRunninhHrs = tr.find('td:eq(3)').text();
var sandDriedQty = tr.find('td:eq(10)').text();
var sandDriedQty = tr.find('td:eq(7)').text();
if (drierRunninhHrs != '' && sandDriedQty != '') {
var qtyPerHrs = parseFloat(sandDriedQty) / parseFloat(drierRunninhHrs);
if (qtyPerHrs && qtyPerHrs != NaN && qtyPerHrs != Infinity)
tr.find('td:eq(11)').text(qtyPerHrs.toFixed(3));
tr.find('td:eq(10)').text(qtyPerHrs.toFixed(3));
}
@ -1078,6 +1107,16 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
let dreierMachineOnTime = $('#additionalEntryDrierOnTimeId').val();
let dreierMachineOffTime = $('#additionalEntryDrierOffTimeId').val();
if(dreierMachineOnTime == dreierMachineOffTime){
$('#additionalEntryRunningHrsId').val(24.00);
additionalEntryGasPerTon();
additionalEntryMoistureLossQty();
additionalEntryQtyPerHrs();
return;
}
if (dreierMachineOnTime != '' && dreierMachineOffTime != '') {
@ -1217,3 +1256,57 @@ function convertToDate(dateString) {
</script>
<!-- excel export -->
<script>
$(document).ready(function(){
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let rows = table.rows;
let data = [];
for (let i = 0; i < rows.length; i++) {
let row = rows[i];
let cols = row.querySelectorAll('td, th');
let rowData = [];
for (let j = 0; j < cols.length; j++) {
let cell = cols[j];
// Check if the cell contains a <select> dropdown
let select = cell.querySelector('select');
if (select) {
rowData.push(select.options[select.selectedIndex].text); // Get only selected value
} else {
rowData.push(cell.innerText.trim()); // Normal text
}
}
data.push(rowData);
}
let wb = XLSX.utils.book_new();
let ws = XLSX.utils.aoa_to_sheet(data);
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'drierTable';
document.getElementById('drierMachineDetailsExport').addEventListener('click',function(){
exportTableToExcel(tableId,'drierMachineDetails_<?=$datefordropdown?>.xlsx');
})
})
</script>
<!-- script section ends -->

View File

@ -305,7 +305,7 @@ foreach ($period as $day) {
</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a>
<a class="dropdown-item" href="#">Export</a>
<a class="dropdown-item" id="powerConsumptionExport" href="#">Export</a>
</div>
</div>
</div>
@ -776,13 +776,28 @@ foreach ($period as $day) {
<?php } ?>
><?= $previousMonthPowerConsumptionStockDetails[$powerMachineIndex]['closing_units'] ?>
><?php
if(empty( $previousMonthPowerConsumptionStockDetails)){
echo " " ;
}else{
echo $previousMonthPowerConsumptionStockDetails[$powerMachineIndex]['closing_units'] ;
}
?>
</td>
<td class="celda_normal closingUnits"
data-id="<?= $dateInMonth ?> <?= $powerMachine['id'] ?>"
oninput="closingUnitsChange(this)"
contenteditable="true"><?= $previousMonthPowerConsumptionStockDetails[$powerMachineIndex]['closing_units'] ?>
contenteditable="true">
<?php
if(empty( $previousMonthPowerConsumptionStockDetails)){
echo " " ;
}else{
echo $previousMonthPowerConsumptionStockDetails[$powerMachineIndex]['closing_units'] ;
}
?>
</td>
<td class="celda_normal totalUnits"
@ -1284,4 +1299,47 @@ foreach ($period as $day) {
}
</script>
</script>
<script>
$(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 () {
return $(this).css('display') === 'none';
}).remove();
// Remove hidden columns
$(cloneTable).find('th, td').each(function () {
if ($(this).css('display') === 'none') {
$(this).remove();
}
});
let ws = XLSX.utils.table_to_sheet(cloneTable); // Convert modified table to sheet
let wb = XLSX.utils.book_new(); // Create a new workbook
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); // Append sheet to workbook
XLSX.writeFile(wb, filename || 'export.xlsx'); // Save the file
}
let tableId = 'powerStockDetailsTableId';
document.getElementById('powerConsumptionExport').addEventListener('click',function(){
exportTableToExcel(tableId,'power_Consumption_details<?=$month?>.xlsx');
})
})
</script>

View File

@ -298,7 +298,7 @@ foreach ($period as $day) {
</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a>
<a class="dropdown-item" href="#">Export</a>
<a class="dropdown-item" id="resinStockExport" href="#">Export</a>
</div>
</div>
</div>
@ -907,4 +907,47 @@ foreach ($period as $day) {
}
})
}
</script>
<script>
$(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 () {
return $(this).css('display') === 'none';
}).remove();
// Remove hidden columns
$(cloneTable).find('th, td').each(function () {
if ($(this).css('display') === 'none') {
$(this).remove();
}
});
let ws = XLSX.utils.table_to_sheet(cloneTable); // Convert modified table to sheet
let wb = XLSX.utils.book_new(); // Create a new workbook
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); // Append sheet to workbook
XLSX.writeFile(wb, filename || 'export.xlsx'); // Save the file
}
let tableId = 'resinStockDetailsTableId';
document.getElementById('resinStockExport').addEventListener('click',function(){
exportTableToExcel(tableId,'Resin_Stock_Details<?=$month?>.xlsx');
})
})
</script>

View File

@ -270,6 +270,19 @@
<div class="form-group col-md-2">
<button type="submit" class="btn btn-success"> Change Month </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"
aria-expanded="false">
<i class="mdi mdi-dots-vertical m-0 text-muted h3"></i>
</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a>
<a class="dropdown-item" id="trpSandUseStockExport" href="#">Export</a>
</div>
</div>
</div>
</div>
</form>
@ -642,3 +655,48 @@
</script>
<script>
$(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 () {
return $(this).css('display') === 'none';
}).remove();
// Remove hidden columns
$(cloneTable).find('th, td').each(function () {
if ($(this).css('display') === 'none') {
$(this).remove();
}
});
let ws = XLSX.utils.table_to_sheet(cloneTable); // Convert modified table to sheet
let wb = XLSX.utils.book_new(); // Create a new workbook
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); // Append sheet to workbook
XLSX.writeFile(wb, filename || 'export.xlsx'); // Save the file
}
let tableId = 'trpSandUseStockDetailsTableId';
document.getElementById('trpSandUseStockExport').addEventListener('click',function(){
exportTableToExcel(tableId,'Trp_Sand_Use_Stock_Details_<?=$month?>.xlsx');
})
})
</script>