Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme

This commit is contained in:
VE10-Sanjeev 2025-04-17 12:10:14 +00:00
commit 9a01be26d0
19 changed files with 3204 additions and 859 deletions

View File

@ -87,6 +87,7 @@ class Configurationctrl extends BaseController
$isActiveFilter = 1 ; // default flag for active data
$showArchive = 0 ; // default flag for inactive data
$page = 1; // default page number
if ($this->request->getMethod() === 'POST') {
@ -100,6 +101,7 @@ class Configurationctrl extends BaseController
if ($this->request->getMethod() === 'GET') {
$ConfigID = $this->request->getVar('ConfigID');
$page = $this->request->getVar('page');
}
$data['showArchive'] = $showArchive;
@ -109,6 +111,8 @@ class Configurationctrl extends BaseController
$data['child'] = $this->configmodel->GetConfigCenterDetails($ConfigID,$isActiveFilter);
$data['ConfigID'] = $ConfigID;
$data['page'] = $page;
$this->global['pageTitle'] = 'Edit Config';
$this->loadViews("editconfig", $this->global, $data, NULL);
@ -122,6 +126,7 @@ class Configurationctrl extends BaseController
$ConfigName = $this->request->getPost('ConfigName');
$Comments = $this->request->getPost('Remarks');
$Rowcount = $this->request->getPost('txtRowCount');
$page = $this->request->getGet('page')??1;
$config = array('Config_ID' => $ConfigId, 'ConfigName' => $ConfigName, 'Comments' => $Comments);
$result = $this->configmodel->updateconfig($config, $ConfigId);
@ -143,7 +148,7 @@ class Configurationctrl extends BaseController
$this->session->setFlashdata('success', 'Configuration Updated successfully!');
return redirect()->route('configlisting');
return redirect()->to('/configlisting?page=' . $page);
}

View File

@ -447,6 +447,7 @@ class StockController extends BaseController
$this->global['pageTitle'] = 'Drier Details';
$this->loadViews("stock/drierMachineDetails", $this->global, $data, NULL);
}
@ -601,6 +602,8 @@ class StockController extends BaseController
// Convert month format from "Y-m" to "M-Y" for display
$date = DateTime::createFromFormat('Y-m-d', $month.'-01');
$formattedDate = $date->format('M-Y');
@ -1311,7 +1314,7 @@ class StockController extends BaseController
$filterUpdateNeeded = true ;
if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){
$customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ;
$customisedMachineCodes = array_column($existingCustomMachineCodes, 'machine_id') ;
$filterUpdateNeeded = false ;
}
@ -1367,12 +1370,30 @@ class StockController extends BaseController
//possible if no filter applied at all...!!!
if(empty($existingCustomMachineCodes)){
//no filter applied at all just present all active material codes
$existingCustomMachineCodes = $this->factoryMachine_model
->getAllActiveDieselMachines();
$existingCustomMachineCodes = $this ->factoryMachine_model
->getAllActiveDieselMachines() ;
//add this active products in monthwisemachine stock table
$inserts = [];
foreach($existingCustomMachineCodes as $index => $customisedMachineCode){
$inserts [] = [
'date' => "$month-01",
'machine_category' => "diesel",
'machine_id' => $customisedMachineCode['id']
];
}
if(!empty($inserts)){
//insert all the latest applied filter
$this->monthWiseMachineInStockModel->insertBatch($inserts);
}
}else{
//if filter present,get that material codes
$existingCustomMachineCodes = $this->factoryMachine_model
->getSelectedDieselMachines(array_column($existingCustomMachineCodes, 'machine_id'));
->getSelectedDieselMachines(array_column($existingCustomMachineCodes, 'machine_id'));
}
@ -1381,24 +1402,32 @@ class StockController extends BaseController
$machineCodeList = array_column($existingCustomMachineCodes, 'id');
foreach($machineCodeList as $index => $machineCode){
$currentDate = new DateTime();
if($startDate == $currentDate->format('Y-m-01') && $endDate == $currentDate->format('Y-m-t')){
foreach($machineCodeList as $index => $machineCode){
//checking filtered present in table , if not create dummy one for whole month
$findMachineCode = $this->factoryVehicleDieselDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('machine_id',$machineCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMachineCode)){
//create dummy entry for this
$this->createDummyEntryForDieselMachine($machineCode,$startDate,$endDate);
//checking filtered present in table , if not create dummy one for whole month
$findMachineCode = $this->factoryVehicleDieselDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('machine_id',$machineCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMachineCode)){
//create dummy entry for this
$this->createDummyEntryForDieselMachine($machineCode,$startDate,$endDate);
}
}
}
$dieselMachines = $existingCustomMachineCodes;
$data['activeDieselMachines'] = $this->factoryMachine_model->getAllActiveDieselMachines();
@ -1731,7 +1760,8 @@ class StockController extends BaseController
$filterUpdateNeeded = true ;
if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){
$customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ;
$customisedMachineCodes = array_column($existingCustomMachineCodes, 'machine_id') ;
$filterUpdateNeeded = false ;
}
@ -1785,14 +1815,37 @@ class StockController extends BaseController
//possible if no filter applied at all...!!!
if(empty($existingCustomMachineCodes)){
if(empty($existingCustomMachineCodes) ){
//no filter applied at all just present all active material codes
$existingCustomMachineCodes = $this->factoryMachine_model
->getAllActiveElectricMachines();
//if no filter exists , just add current filter for that month ....!!
$inserts = [];
foreach($existingCustomMachineCodes as $index => $customisedMachineCode){
$inserts [] = [
'date' => "$month-01",
'machine_category' => "electric",
'machine_id' => $customisedMachineCode['id']
];
}
if(!empty($inserts)){
//insert all the latest applied filter
$this->monthWiseMachineInStockModel->insertBatch($inserts);
}
}else{
//if filter present,get that material codes
$existingCustomMachineCodes = $this->factoryMachine_model
->getSelectedElectricMachines(array_column($existingCustomMachineCodes, 'machine_id'));
->getSelectedElectricMachines(array_column($existingCustomMachineCodes, 'machine_id'));
}
@ -1801,24 +1854,32 @@ class StockController extends BaseController
//this existingCustomMachineCodes gets its machine after visiting factory machine master table
$machineCodeList = array_column($existingCustomMachineCodes, 'id');
foreach($machineCodeList as $index => $machineCode){
$currentDate = new DateTime();
//checking filtered material code present in table , if not create dummy one for whole month
$findMachineCode = $this->powerConsumptionDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('machine_id',$machineCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMachineCode)){
//create dummy entry for this
$this->createDummyEntryForElectricMachine($machineCode,$startDate,$endDate);
if($startDate == $currentDate->format('Y-m-01') && $endDate == $currentDate->format('Y-m-t')){
foreach($machineCodeList as $index => $machineCode){
//checking filtered material code present in table , if not create dummy one for whole month
$findMachineCode = $this->powerConsumptionDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('machine_id',$machineCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMachineCode)){
//create dummy entry for this
$this->createDummyEntryForElectricMachine($machineCode,$startDate,$endDate);
}
}
}
$electricMachines = $existingCustomMachineCodes;
$data['activeElectricMachines'] = $this->factoryMachine_model->getAllActiveElectricMachines();
@ -2310,8 +2371,31 @@ class StockController extends BaseController
//possible if no filter applied at all...!!!
if(empty($existingCustomMaterialCodes)){
//no filter applied at all just present all active material codes
$existingCustomMaterialCodes = $this->rawmaterialdetails_model->getAllResinMaterialCode();
//if no filter already exists or removed current one , just add current filter for that month ....!!
$inserts = [];
foreach($existingCustomMaterialCodes as $index => $customisedMaterialCode){
$inserts [] = [
'date' => "$month-01",
'stock_category' => "resin",
'materialCode' => $customisedMaterialCode['MaterialCode']
];
}
if(!empty($inserts)){
//insert all the latest applied filter
$this->monthWiseMaterialInStockModel->insertBatch($inserts) ;
}
}else{
//if filter present , Reuse the filter and get that material codes
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
@ -2321,24 +2405,31 @@ class StockController extends BaseController
$materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode');
foreach($materialCodeList as $index => $materialCode){
$currentDate = new DateTime();
if($startDate == $currentDate->format('Y-m-01') && $endDate == $currentDate->format('Y-m-t')){
foreach($materialCodeList as $index => $materialCode){
//checking filtered material code present in table , if not create dummy one for whole month
$findMachineCode = $this->resinStockDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('materialCode',$materialCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMachineCode)){
//create dummy entry for this
$this->createDummyEntryForResin($materialCode,$startDate,$endDate);
//checking filtered material code present in table , if not create dummy one for whole month if it is current month
$findMachineCode = $this->resinStockDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('materialCode',$materialCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMachineCode)){
//create dummy entry for this
$this->createDummyEntryForResin($materialCode,$startDate,$endDate);
}
}
}
}
$resinMaterials = $existingCustomMaterialCodes ;
@ -2590,6 +2681,7 @@ class StockController extends BaseController
{
if ($this->request->getMethod() === 'POST') {
$month = $this->request->getPost('month');
$date = DateTime::createFromFormat('d-M-Y', '01-'.$month);
@ -2698,33 +2790,62 @@ class StockController extends BaseController
//no filter applied at all just present all active material codes
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
->getAllBagMaterialCode();
//if no filter already exists or removed current one , just add current filter for that month ....!!
$inserts = [];
foreach($customisedMaterialCodes as $index => $customisedMaterialCode){
$inserts [] = [
'date' => "$month-01",
'stock_category' => "resin",
'materialCode' => $customisedMaterialCode['MaterialCode']
];
}
if(!empty($inserts)){
//insert all the latest applied filter
$this->monthWiseMaterialInStockModel->insertBatch($inserts) ;
}
}else{
//if filter present,get that material codes
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
->getSelectedBagMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode'));
}
}
$materialCodeList = array_column($existingCustomMaterialCodes, 'MaterialCode');
foreach($materialCodeList as $index => $materialCode){
$currentDate = new DateTime();
if($startDate == $currentDate->format('Y-m-01') && $endDate == $currentDate->format('Y-m-t')){
foreach($materialCodeList as $index => $materialCode){
//checking filtered material code present in table , if not create dummy one for whole month
$findMachineCode = $this->bagStockDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('materialCode',$materialCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMachineCode)){
//create dummy entry for this
$this->createDummyEntryForBag($materialCode,$startDate,$endDate);
//checking filtered material code present in table , if not create dummy one for whole month for current month only
$findMachineCode = $this->bagStockDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('materialCode',$materialCode)
->findAll();
//check any material code is not present in stock table but applied in filter
if(empty($findMachineCode)){
//create dummy entry for this
$this->createDummyEntryForBag($materialCode,$startDate,$endDate);
}
}
}
}
$bagMaterials = $existingCustomMaterialCodes ;
@ -3054,8 +3175,6 @@ class StockController extends BaseController
echo "Data Saved Successfully";
}
public function trpProductionDetails(){
//filtering month in post request
@ -3171,10 +3290,6 @@ class StockController extends BaseController
return $this->loadViews("stock/trpProductionStockDetails", $this->global, $data, NULL);
}
public function updateTrpProductionDetails($inserts = null, $freshEntry = false)
@ -3267,6 +3382,7 @@ class StockController extends BaseController
'gasReceiptBg' => $data['gasReceiptBg'],
'gasReceiptPg' => $data['gasReceiptPg'],
'physicalGasConsumption' => $data['physicalGasConsumption'],
'drierGasConsumption' => $data['drierGasConsumption'],
'trpPlusDrierGasConsumption' => $data['trpPlusDrierGasConsumption'],
'trpPhysicalGasPerTon' => $data['trpPhysicalGasPerTon'],
'panelGasConsumption' => $data['panelGasConsumption'],
@ -3362,9 +3478,6 @@ class StockController extends BaseController
echo "An error occurred: " . $error->getMessage();
}
}
public function updateAbstractDetails() {
@ -3404,20 +3517,6 @@ class StockController extends BaseController
}
// -------------------------------------------- in class helpers ----------------------------------------------
@ -3457,7 +3556,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
}
@ -3627,6 +3726,7 @@ class StockController extends BaseController
'gasReceiptBg' => " ",
'gasReceiptPg' => " ",
'physicalGasConsumption' => " ",
'drierGasConsumption' => " ",
'trpPlusDrierGasConsumption' => " ",
'trpPhysicalGasPerTon' => " ",
'panelGasConsumption' => " ",
@ -3655,7 +3755,6 @@ class StockController extends BaseController

View File

@ -13,7 +13,8 @@ class TrpProductionModel extends Model
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['id','date', 'gasReceiptBg', 'gasReceiptPg', 'physicalGasConsumption', 'trpPlusDrierGasConsumption',
protected $allowedFields = ['id','date', 'gasReceiptBg', 'gasReceiptPg', 'physicalGasConsumption',
'drierGasConsumption','trpPlusDrierGasConsumption',
'trpPhysicalGasPerTon', 'panelGasConsumption','panelGasPerTon','edRunningHours','edProduction','edUsage',
'trpProduction', 'trpProductionPerHour', 'waterReceipt', 'waterConsumption' ,'ebReading',
'ebReadingPerUnitTon'];
@ -88,8 +89,8 @@ class TrpProductionModel extends Model
tpd.physicalGasConsumption,
IFNULL(tdmd.totalGasConsumption, 0) AS drierGasConsumption,
IFNULL(tcmd.totalGasConsumption, 0) AS coatingGasConsumption,
tpd.drierGasConsumption As drierGasConsumption,
tpd.trpPlusDrierGasConsumption,
tpd.trpPhysicalGasPerTon,
tpd.panelGasConsumption,
@ -143,13 +144,15 @@ class TrpProductionModel extends Model
$builder->join("({$subquery1}) tcmd", 'tcmd.date = tpmd.date', 'left');
// Subquery: Drier Machine Gas Consumption
$subquery2 = $this->db->table('t_driermachinedetails')
->select('date, SUM(total_gas_consumption) AS totalGasConsumption')
->groupBy('date')
->getCompiledSelect(false); // Convert Query Builder to raw SQL;
//client requirement change from auto entry to manual entry from drier gas consumption
$builder->join("({$subquery2}) tdmd", 'tdmd.date = tpmd.date', 'left');
// Subquery: Drier Machine Gas Consumption
// $subquery2 = $this->db->table('t_driermachinedetails')
// ->select('date, SUM(total_gas_consumption) AS totalGasConsumption')
// ->groupBy('date')
// ->getCompiledSelect(false); // Convert Query Builder to raw SQL;
// $builder->join("({$subquery2}) tdmd", 'tdmd.date = tpmd.date', 'left');

View File

@ -57,6 +57,10 @@
</style>
<?php
$page = session()->getFlashdata('page') ?? $_GET['page'] ?? 1;
?>
<div class="content-page">
<div class="content">
@ -168,7 +172,9 @@
<td><?= $record->isActive == 1 ? 'Active' : 'InActive'; ?></td>
<td>
<a href="<?php echo base_url() . 'configurationctrl/editconfig?ConfigID=' . $record->Config_ID; ?>"
<a
onclick="editConfig(event)"
href="<?php echo base_url() . 'configurationctrl/editconfig?ConfigID=' . $record->Config_ID; ?>"
data-toggle="tooltip"
title="<?php echo $record->Config_ID ?> - Click here to Edit Config Details">
<i class="fas fa-edit"></i>
@ -225,6 +231,30 @@
}
});
// Ensure the saved page is a valid number
let savedPage =<?= $page ?? 0 ?>; // Default to 1 if not set
savedPage = savedPage -1 ;
// Check if the saved page is a number and not NaN
if (!isNaN(savedPage)) {
// Check if the DataTable is initialized
if ($.fn.DataTable.isDataTable('#config_list_table')) {
var dataTable = $('#config_list_table').DataTable();
// Get the total number of pages in DataTable
var totalPages = dataTable.page.info().pages;
// Ensure the page number is within range
if (savedPage >= totalPages) {
savedPage = totalPages > 0 ? totalPages - 1 : 0;
}
// Set DataTable to the saved page
dataTable.page(savedPage).draw(false);
}
}
// Date range filter function
$.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) {
@ -287,6 +317,30 @@
}
});
});
</script>
<script>
function editConfig(event) {
event.preventDefault();
const targetElement = event.currentTarget;
let href = $(targetElement).attr('href');
let paginationNumber = $('#config_list_table').DataTable().page.info().page + 1; // Get the current page number from dataTable
href += '&page=' + paginationNumber;
// Update the 'href' attribute of the target element
$(targetElement).attr('href', href);
window.location.href = href;
}
</script>

View File

@ -35,7 +35,7 @@ if (!empty($master)) {
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Edit Config <?= ' - ' . $ConfigName; ?> Details</h4>
<a class="btn btn-secondary" href="<?php echo base_url(); ?>configlisting"><span
<a class="btn btn-secondary" href="<?php echo base_url(); ?>configlisting?page=<?=$page?>"><span
class="bold">Back</span></a>
</div>
</div>
@ -68,7 +68,7 @@ if (!empty($master)) {
<div class="card-body">
<?php
$attributes = array('class' => 'form-horizontal', 'id' => 'editConfig');
echo form_open(base_url() . 'configurationctrl/updateconfig', $attributes); ?>
echo form_open(base_url() . "configurationctrl/updateconfig?page=$page", $attributes); ?>
<div class="form-row" style="margin-top:10px">
<div class="col-md-2">
@ -241,7 +241,9 @@ if (!empty($master)) {
<div class="form-row text-right" style="margin-top:10px; text-align:right">
<div class="col-md-12 text-right">
<a href="<?php echo base_url() ?>configlisting" class="btn btn-secondary">Cancel</a>
<a href="<?php echo base_url() ?>configlisting?page=<?=$page?>" class="btn btn-secondary" >
Cancel
</a>
<input type="button" id="updateConfigBtnId" class="btn btn-success" value="Update" />
</div>
</div>
@ -608,9 +610,17 @@ if (!empty($master)) {
data-materialCode="${item.MaterialCode}"
data-materialType="${item.MaterialType}"
data-uom="${item.UOM}"
style="cursor: pointer; color: #02a8b5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" onmouseover="this.style.color='#016269';">
style="cursor: pointer; color: #02a8b5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" onmouseover="this.style.color='#016269'; width:10%;
text-align:center;">
<u>${item.MaterialCode}</u>
</td>
<td style="text-align:left; overflow: hidden;text-overflow: ellipsis; word-wrap: break-word !important;
white-space: normal !important; width: 100px !important; width:70%;
text-align:left;">${item.MaterialName}</td>
<td style="text-align:left; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width:10%;
text-align:center;">${item.MaterialType}</td>
<td style="text-align:left; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width:10%;
text-align:center;">${item.IsActive == 1 ?"Active":"InActive"}</td>
<td style="text-align: center; white-space: normal;">${item.MaterialName}</td>
<td style="text-align: left; white-space: nowrap;">${item.MaterialType}</td>

View File

@ -152,7 +152,7 @@
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">Inward</a></li>
<li class="breadcrumb-item active">
<h4 class="page-title">Gas Cylinder Returned </h4>
<h4 class="page-title">Gas Cylinder Completed </h4>
</li>
</ol>
</div>
@ -543,12 +543,12 @@
<td>${item.IGRNO}</td>
<td>${item.fullCylinderDate}</td>
<td>${item.cylinderNo}</td>
<td>${item.grossWeight}</td>
<td align="right">${item.grossWeight}</td>
<td>${item.emptyCylinderDate}</td>
<td>${item.tareWeight}</td>
<td>${item.netWeight}</td>
<td>${item.actualWeight}</td>
<td>${item.shortage}</td>
<td align="right">${item.tareWeight}</td>
<td align="right">${item.netWeight}</td>
<td align="right">${item.actualWeight}</td>
<td align="right">${item.shortage}</td>
<td>${item.invoiceNo}</td>
<td>${item.DeliveryChellanDate}</td>
<td>${item.DriverName}</td>
@ -570,10 +570,10 @@
<td></td>
<td></td>
<td></td>
<td> Weight</td>
<td>${totalNetWeight}</td>
<td>${totalActualWeight}</td>
<td>${totalShortage}</td>
<td align="right"> Weight</td>
<td align="right">${totalNetWeight}</td>
<td align="right">${totalActualWeight}</td>
<td align="right">${totalShortage}</td>
<td></td>
<td></td>
<td></td>

View File

@ -759,7 +759,7 @@
<div class="dropdown-menu" aria-labelledby="topnav-po" >
<a href="<?php echo base_url(); ?>gasCylinderEntered" class="dropdown-item"><i class="fa fa-truck mr-1"></i>Gas Cylinder Entered</a>
<a href="<?php echo base_url(); ?>gasCylinderPending" class="dropdown-item"><i class="fa fa fa-hourglass-half mr-1"></i>Gas Cylinder Pending </a>
<a href="<?php echo base_url(); ?>gasCylinderReturned" class="dropdown-item"><i class="fa fa-check mr-1"></i>Gas Cylinder Returned</a>
<a href="<?php echo base_url(); ?>gasCylinderReturned" class="dropdown-item"><i class="fa fa-check mr-1"></i>Gas Cylinder Completed</a>
</div>
</div>

View File

@ -232,7 +232,7 @@
</tbody>
</table>
<p>( Note :The entries count includes archived data... )</p>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->

View File

@ -1296,7 +1296,7 @@
<script>
function confirmDelete(event) {
let result = confirm(` Do you Confirm to Delete the Coating Machine Detail?`);
let result = confirm(`Do you Confirm to Delete the Coating Machine Detail?`);
if (result) {
return result;
} else {
@ -1314,8 +1314,7 @@
$('#editMachineOffTimeHrId ').select2();
$('#fromDateFilter ').select2();
$('#toDateFilter ').select2();
});
});
</script>
@ -1459,7 +1458,6 @@
let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOffTimeHr);
if (!machineRunningInHrs) {
$('#machineOffTimeHrId').val('');
return
}
@ -1467,12 +1465,31 @@
$('#totalCoatingSandId').trigger('change');
$('#totalGasConsumptionId').trigger('change');
})
$('#totalCoatingId , #shiftId , #gradeId').change(function(){
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
})
$('#totalCoatingSandId').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
let totalCoatingSandValue = $(this).val();
let machineRunningInHrsValue = $('#machineRunningInHrsId').val();
@ -1486,6 +1503,15 @@
$('#totalGasConsumptionId').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
let totalGasConsumptionValue = $(this).val();
let machineRunningInHrsValue = $('#machineRunningInHrsId').val();
if (totalGasConsumptionValue && machineRunningInHrsValue) {
@ -1496,14 +1522,6 @@
})
})
</script>
<!-- calculations for some fields needed in onChange while editing coating machine details -->
<script>
$(document).ready(function() {
$('#editMachineOnTimeHrId , #editDateId').change(function() {
@ -1562,11 +1580,34 @@
})
$('#editTotalCoatingId , #editShiftId , #editGradeId').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
})
$('#editTotalCoatingSandId').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
let totalCoatingSandValue = $(this).val();
let machineRunningInHrsValue = $('#editMachineRunningInHrsId').val();
if (totalCoatingSandValue && machineRunningInHrsValue) {
let perHourCoatingSandQTYValue = (totalCoatingSandValue / machineRunningInHrsValue).toFixed(2);
$('#editPerHourCoatingSandQTYId').val(perHourCoatingSandQTYValue);
@ -1577,6 +1618,13 @@
$('#editTotalGasConsumptionId').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
let totalGasConsumptionValue = $(this).val();
let machineRunningInHrsValue = $('#editMachineRunningInHrsId').val();
if (totalGasConsumptionValue && machineRunningInHrsValue) {
@ -1587,6 +1635,16 @@
})
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
})
</script>
@ -1712,48 +1770,59 @@
<script>
$(document).ready(function() {
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let rows = [];
$(document).ready(function() {
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let rows = [];
// Extract table data row-by-row
$(table).find('tr').each(function(rowIndex) {
let rowData = [];
// Extract table data row-by-row
$(table).find('tr').each(function(rowIndex) {
let rowData = [];
$(this).find('th, td').each(function(colIndex) {
// Skip hidden columns
if ($(this).css('display') === 'none') return;
$(this).find('th, td').each(function(colIndex) {
// Skip hidden columns
if ($(this).css('display') === 'none') return;
let cellText = $(this).text().trim();
rowData.push(cellText);
});
// Add the cleaned row only if it has data
if (rowData.length > 0) {
rows.push(rowData);
}
let cellText = $(this).text().trim();
rowData.push(cellText);
});
// Create a worksheet from array (no DOM needed!)
let ws = XLSX.utils.aoa_to_sheet(rows);
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'coatingMachineDetailTableId';
document.getElementById('coatingMachineDetailsExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'coatingMachineDetails_<?= $month ?>.xlsx');
// Add the cleaned row only if it has data
if (rowData.length > 0) {
rows.push(rowData);
}
});
// Create a worksheet from array (no DOM needed!)
let ws = XLSX.utils.aoa_to_sheet(rows);
// Set column widths: wch: 10 for each column
if (rows.length > 0) {
const colCount = rows[0].length;
const wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 10 });
}
ws['!cols'] = wscols;
}
// Create a new workbook and add the sheet
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
// Write the workbook to a file
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'coatingMachineDetailTableId';
document.getElementById('coatingMachineDetailsExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'coatingMachineDetails_<?= $month ?>.xlsx');
});
});
</script>
<script>
$(document).ready(function() {
$('#batchCardAddBtnId').click(function() {

View File

@ -328,9 +328,20 @@ foreach ($period as $day) {
<div class="row">
<div class="col-12">
<div class="card" id="fullscreenDiv">
<div class="card-body">
<div id="successMessage"
style="
display: none;
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: green;
color: white;
padding: 10px;
border-radius: 5px;
z-index: 1000;">
</div>
<form id="changeMonthForm" action="<?= base_url('bagStockDetails'); ?>" method="post">
@ -676,6 +687,7 @@ foreach ($period as $day) {
'receipt' => 0,
'used' => 0,
'balanceStock' => 0,
'materialCode' => $materialCode,
];
}
@ -701,10 +713,14 @@ foreach ($period as $day) {
?>
<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>
<td class="celda_normal openingStock"
data-id="footer <?=$each['materialCode']?>"></td>
<td class="celda_normal receiptStock"
data-id="footer <?=$each['materialCode']?>"> <?= $each['receipt'] == 0 ? " " : $each['receipt'] ?> </td>
<td class="celda_normal usedStock"
data-id="footer <?=$each['materialCode']?>"> <?= $each['used'] == 0 ? " " : $each['used'] ?></td>
<td class="celda_normal balanceStock"
data-id="footer <?=$each['materialCode']?>"></td>
<?php } ?>
@ -801,7 +817,36 @@ foreach ($period as $day) {
</td>
<?php } ?>
</tr>
<?php } ?>
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<?php foreach ($bagMaterials as $each) {
?>
<td class="celda_normal openingStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal receiptStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal usedStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal balanceStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<?php } ?>
</tr>
</tfoot>
<?php } ?>
@ -914,9 +959,8 @@ foreach ($period as $day) {
var updateBagStockDetails = tableToJson();
alert('Updation may take a while, And we appreciate your patience..!!');
showMessage('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updateBagStockDetails
@ -928,8 +972,7 @@ foreach ($period as $day) {
if (data) {
$('#loader').hide();
console.log(data);
alert(data);
window.location.reload();
showMessage(data);
}
},
@ -988,6 +1031,13 @@ foreach ($period as $day) {
<script>
function openingStockChange(tdElement) {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
try {
let dataId = tdElement.getAttribute('data-id');
@ -1005,6 +1055,14 @@ foreach ($period as $day) {
updateStockValue(date, materialCode, currentBalanceStock)
let table = document.getElementById('bagStockDetailsTableId');
let column1 = 'usedStock';
let column2 = 'receiptStock';
calculateTotal(table, dataId, column1);
calculateTotal(table, dataId, column2);
} catch (error) {
@ -1016,6 +1074,13 @@ foreach ($period as $day) {
function receiptStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let [date, materialCode] = tdElement.getAttribute('data-id').split(' ');
@ -1030,7 +1095,15 @@ foreach ($period as $day) {
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock == 0 ? " " : currentBalanceStock;
updateStockValue(date, materialCode, currentBalanceStock)
updateStockValue(date, materialCode, currentBalanceStock);
let table = document.getElementById('bagStockDetailsTableId');
let column1 = 'usedStock';
let column2 = 'receiptStock';
calculateTotal(table, dataId, column1);
calculateTotal(table, dataId, column2);
} catch (error) {
@ -1046,6 +1119,13 @@ foreach ($period as $day) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let [date, materialCode] = tdElement.getAttribute('data-id').split(' ');
@ -1060,7 +1140,16 @@ foreach ($period as $day) {
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock == 0 ? " " : currentBalanceStock;
updateStockValue(date, materialCode, currentBalanceStock)
updateStockValue(date, materialCode, currentBalanceStock);
let table = document.getElementById('bagStockDetailsTableId');
let column1 = 'usedStock';
let column2 = 'receiptStock';
calculateTotal(table, dataId, column1);
calculateTotal(table, dataId, column2);
} catch (error) {
@ -1128,12 +1217,21 @@ foreach ($period as $day) {
// Validate against the regex
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
alert('Invalid input! Please enter a valid number.');
return 0;
}
return input;
}
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
</script>
@ -1141,60 +1239,70 @@ foreach ($period as $day) {
<script>
$(document).ready(function() {
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let cloneTable = table.cloneNode(true); // Clone the table to modify
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 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();
}
});
$(cloneTable).find('tbody tr').each(function() {
let firstTd = $(this).find('td').eq(0); // Get the first column (Date)
// Remove hidden columns
$(cloneTable).find('th, td').each(function() {
if ($(this).css('display') === 'none') {
$(this).remove();
}
});
// Convert Date Format (Assuming it's in YYYY-MM-DD format)
let originalDate = firstTd.text().trim(); // Get the text value
let parts = originalDate.split('-'); // Split into [YYYY, MM, DD]
// Convert Date Format and align date column
$(cloneTable).find('tbody tr').each(function() {
let firstTd = $(this).find('td').eq(0);
let originalDate = firstTd.text().trim();
let parts = originalDate.split('-');
if (parts.length === 3) {
let formattedDate = `${parts[2]}-${parts[1]}-${parts[0]}`;
firstTd.text(formattedDate);
}
firstTd.css("text-align", "left");
});
if (parts.length === 3) {
let formattedDate = `${parts[2]}-${parts[1]}-${parts[0]}`; // Rearrange to DD-MM-YYYY
firstTd.text(formattedDate); // Update the cell value
}
// Create a new workbook
let wb = XLSX.utils.book_new();
// Apply left alignment to the date column
firstTd.css("text-align", "left");
// Convert the modified table to a sheet
let ws = XLSX.utils.table_to_sheet(cloneTable);
// Set custom column widths based on number of columns in the table header
const columnWidth = 10;
const wscols = [];
});
// Count the number of visible columns in the table after hidden ones are removed
let visibleColumnCount = $(cloneTable).find('thead tr th').length;
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
for (let i = 0; i < visibleColumnCount; i++) {
wscols.push({ wch: columnWidth });
}
ws['!cols'] = wscols;
// Append the sheet to the workbook
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
let tableId = 'bagStockDetailsTableId';
// Write the workbook to a file
XLSX.writeFile(wb, filename || 'export.xlsx');
}
document.getElementById('bagStockExport').addEventListener('click', function() {
let tableId = 'bagStockDetailsTableId';
exportTableToExcel(tableId, 'Bag_Stock_Details<?= $month ?>.xlsx');
document.getElementById('bagStockExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'Bag_Stock_Details<?= $month ?>.xlsx');
});
})
})
});
</script>
<script>
document.addEventListener("keydown", function(event) {
@ -1431,4 +1539,77 @@ foreach ($period as $day) {
}, 200);
});
});
</script>
<script>
function showMessage(msg) {
let msgBox = document.getElementById("successMessage");
msgBox.innerText = msg; // Set API message
msgBox.style.display = "block";
// Hide message after 3 seconds
setTimeout(() => {
msgBox.style.display = "none";
}, 5000);
}
</script>
<script>
function calculateTotal(table,dataId,column) {
let columnTotal = 0;
let rows = table.querySelectorAll('tbody tr');
let materialCode = dataId.split(' ')[1];
rows.forEach(row => {
let date = row.querySelector('td:first-child').innerText.trim().split('-');
date = date[2] + "-" + date[1] + "-" + date[0]; // Convert to YYYY-MM-DD format
let cell = row.querySelector(`td.${column}[data-id="${date} ${materialCode}"]`);
if (cell) {
let value = parseFloat(cell.innerText.trim()) || 0;
columnTotal += value;
}
});
// Update the total cell in the footer
let footerColumn = table.querySelector(`tfoot tr td.${column}[data-id="footer ${materialCode}"]`);
if (footerColumn) {
footerColumn.innerText = columnTotal == 0 ? " " : columnTotal.toFixed(2); // Set the total value in the footer cell
}
// let footerColumnOpeningStock = table.querySelector(`tfoot tr td.openingStock[data-id="footer ${materialCode}`)??0;
// let footerColumnReceiptStock = table.querySelector(`tfoot tr td.receiptStock[data-id="footer ${materialCode}`)??0;
// let footerColumnUsedStock = table.querySelector(`tfoot tr td.usedStock[data-id="footer ${materialCode}`)??0;
// let footerColumnBalanceStock = table.querySelector(`tfoot tr td.balanceStock[data-id="footer ${materialCode}`);
// footerColumnOpeningStock.innerText = "-";
// footerColumnBalanceStock.innerText = ( parseFloat(footerColumnOpeningStock.innerText.trim())
// +
// parseFloat(footerColumnReceiptStock.innerText.trim())
// )
// -
// parseFloat(footerColumnUsedStock.innerText.trim()) ;
// footerColumnBalanceStock.innerText = "-";
}
</script>

View File

@ -319,6 +319,19 @@ foreach ($period as $day) {
<div class="col-12">
<div class="card" id="fullscreenDiv">
<div class="card-body">
<div id="successMessage"
style="
display: none;
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: green;
color: white;
padding: 10px;
border-radius: 5px;
z-index: 1000;">
</div>
<form id="changeMonthForm" action="<?= base_url('dieselMachineDetails'); ?>" method="post">
@ -368,7 +381,7 @@ foreach ($period as $day) {
<i class="fa fa-download btn-lg mt-2"
title="Excel Download"
style="font-size: x-large; cursor:pointer; color: #0b7cba"
id="bagStockExport">
id="dieselMachineStockDetailsExport">
</i>
<i class="fe-maximize noti-icon btn-lg mt-2"
@ -744,6 +757,7 @@ foreach ($period as $day) {
'consumption' => 0,
'running_hours' => 0,
'mileage' => 0,
'machineId' => $machineId,
];
}
@ -782,21 +796,39 @@ foreach ($period as $day) {
</td>
<td class="celda_normal "><?= $summary['openingStock'] ?></td>
<td class="celda_normal "><?= $summary['totalPurchaseDiesel'] ?></td>
<td class="celda_normal "><?= $summary['totalFillingDiesel'] ?></td>
<td class="celda_normal "><?= $summary['balanceStock'] ?></td>
<td class="celda_normal openingTD"
data-id="footer openingTD"></td>
<td class="celda_normal purchaseTD"
data-id="footer purchaseTD"><?= $summary['totalPurchaseDiesel'] ?></td>
<td class="celda_normal fillingTD"
data-id="footer fillingTD"><?= $summary['totalFillingDiesel'] ?></td>
<td class="celda_normal balanceTD"
data-id="footer balanceTD"></td>
<?php foreach ($summary as $each) {
if (is_array($each)) {
?>
<td class="celda_normal "><?= $each['opening_reading'] ?> </td>
<td class="celda_normal "><?= $each['closing_reading'] ?></td>
<td class="celda_normal "><?= $each['filling_diesel'] ?></td>
<td class="celda_normal "><?= $each['consumption'] ?></td>
<td class="celda_normal "><?= $each['running_hours'] ?></td>
<td class="celda_normal "><?= $each['mileage'] ?></td>
<td class="celda_normal openingReading"
data-id="footer <?=$each['machineId']?>" > </td>
<td class="celda_normal closingReading"
data-id="footer <?=$each['machineId']?>" ></td>
<td class="celda_normal fillingDiesel"
data-id="footer <?=$each['machineId']?>" ><?= $each['filling_diesel'] ?></td>
<td class="celda_normal consumption"
data-id="footer <?=$each['machineId']?>" ><?= $each['consumption'] ?></td>
<td class="celda_normal runningHours"
data-id="footer <?=$each['machineId']?>" ><?= $each['running_hours'] ?></td>
<td class="celda_normal mileage"
data-id="footer <?=$each['machineId']?>" ><?= $each['mileage'] ?></td>
<?php
}
@ -1017,6 +1049,59 @@ foreach ($period as $day) {
<?php } ?>
</tr>
<?php } ?>
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<td class="celda_normal openingTD" style="color:rgb(235, 236, 203);"
data-id="footer openingTD"></td>
<td class="celda_normal purchaseTD"
data-id="footer purchaseTD"></td>
<td class="celda_normal fillingTD"
data-id="footer fillingTD"></td>
<td class="celda_normal balanceTD" style="color:rgb(235, 236, 203);"
data-id="footer balanceTD"></td>
<?php foreach ($dieselMachines as $each) {
if (is_array($each)) {
?>
<td class="celda_normal openingReading" style="color:rgb(235, 236, 203);"
data-id="footer <?=$each['id']?>" > </td>
<td class="celda_normal closingReading" style="color:rgb(235, 236, 203);"
data-id="footer <?=$each['id']?>" > </td>
<td class="celda_normal fillingDiesel"
data-id="footer <?=$each['id']?>" > </td>
<td class="celda_normal consumption"
data-id="footer <?=$each['id']?>" > </td>
<td class="celda_normal runningHours"
data-id="footer <?=$each['id']?>" > </td>
<td class="celda_normal mileage"
data-id="footer <?=$each['id']?>" > </td>
<?php
}
}
?>
</tr>
</tfoot>
<?php } ?>
@ -1123,10 +1208,9 @@ foreach ($period as $day) {
var updateDieselMachineDetails = tableToJson();
alert('Updation may take a while, And we appreciate your patience..!!');
showMessage('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
$.ajax({
data: {
updateDieselMachineDetails
},
@ -1135,16 +1219,13 @@ foreach ($period as $day) {
success: function(data) {
if (data) {
$('#loader').hide();
console.log(data);
alert(data);
window.location.reload();
showMessage(data);
}
},
error: function(xhr, status, error) {
alert("An error occurred while processing the request. Please try again.");
showMessage("An error occurred while processing the request. Please try again.");
console.error("Error Code:", xhr.status);
console.error("Error Message:", error);
console.error("Response Text:", xhr.responseText);
@ -1223,6 +1304,15 @@ foreach ($period as $day) {
function openingReadingChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
let openingReading = validateInput(tdElement.innerText);
@ -1235,7 +1325,16 @@ foreach ($period as $day) {
document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = parseFloat(mileage).toFixed(2);
updateStockValue(date, machine_id, closingReading)
updateStockValue(date, machine_id, closingReading);
let table = document.getElementById('dieselStockDetailsTableId');
let column1 = 'runningHours';
let column2 = 'mileage';
calculateTotal(table,dataId,column1)
calculateTotal(table,dataId,column2)
} catch (error) {
@ -1248,6 +1347,15 @@ foreach ($period as $day) {
function closingReadingChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
let closingReading = validateInput(tdElement.innerText);
@ -1259,8 +1367,16 @@ foreach ($period as $day) {
document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText = parseFloat(runningHours).toFixed(2);
document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = parseFloat(mileage).toFixed(2);
updateStockValue(date, machine_id, closingReading)
updateStockValue(date, machine_id, closingReading);
let table = document.getElementById('dieselStockDetailsTableId');
let column1 = 'runningHours';
let column2 = 'mileage';
calculateTotal(table,dataId,column1)
calculateTotal(table,dataId,column2)
} catch (error) {
@ -1273,6 +1389,15 @@ foreach ($period as $day) {
function consumptionChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
let closingReading = validateInput(document.querySelector(`td.closingReading[data-id="${dataId}"]`).innerText);
@ -1284,7 +1409,16 @@ foreach ($period as $day) {
document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText = parseFloat(runningHours).toFixed(2);
document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = parseFloat(mileage).toFixed(2);
updateStockValue(date, machine_id, closingReading)
updateStockValue(date, machine_id, closingReading);
let table = document.getElementById('dieselStockDetailsTableId');
let column1 = 'consumption';
let column2 = 'mileage';
calculateTotal(table,dataId,column1)
calculateTotal(table,dataId,column2)
} catch (error) {
@ -1298,6 +1432,15 @@ foreach ($period as $day) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let [date, machine_id] = tdElement.getAttribute('data-id').split(" ");
@ -1327,6 +1470,17 @@ foreach ($period as $day) {
updateTotalStockValue(date, balanceTD);
let table = document.getElementById('dieselStockDetailsTableId');
let column1 = 'fillingDiesel';
let column2 = 'fillingTD';
let column3 = 'purchaseTD';
calculateTotal(table,dataId,column1);
calculateTotal(table,date,column2);
calculateTotal(table,date,column3);
} catch (error) {
@ -1344,6 +1498,14 @@ foreach ($period as $day) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let openingTD = validateInput(tdElement.innerText);
@ -1355,7 +1517,17 @@ foreach ($period as $day) {
document.querySelector(`td.balanceTD[data-id="${dataId}"]`).innerText = parseFloat(balanceTD).toFixed(2);
updateTotalStockValue(dataId, balanceTD)
updateTotalStockValue(dataId, balanceTD);
let table = document.getElementById('dieselStockDetailsTableId');
let column1 = 'fillingTD';
let column2 = 'purchaseTD';
calculateTotal(table,dataId,column1);
calculateTotal(table,dataId,column2);
} catch (error) {
@ -1369,6 +1541,16 @@ foreach ($period as $day) {
function purchaseTDStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let purchaseTD = validateInput(tdElement.innerText);
let openingTD = validateInput(document.querySelector(`td.openingTD[data-id="${dataId}"]`).innerText);
@ -1381,6 +1563,18 @@ foreach ($period as $day) {
updateTotalStockValue(dataId, balanceTD);
let table = document.getElementById('dieselStockDetailsTableId');
let column1 = 'fillingTD';
let column2 = 'purchaseTD';
calculateTotal(table,dataId,column1);
calculateTotal(table,dataId,column2);
} catch (error) {
@ -1405,12 +1599,23 @@ foreach ($period as $day) {
// Validate against the regex
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
alert('Invalid input! Please enter a valid number.');
return 0;
}
return input;
}
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
</script>
<script>
@ -1546,7 +1751,17 @@ foreach ($period as $day) {
});
let ws = XLSX.utils.table_to_sheet(cloneTable); // Convert modified table to sheet
// Convert modified table to sheet
let ws = XLSX.utils.table_to_sheet(cloneTable);
// Set custom column widths (wch: 10 for each)
const colCount = $(cloneTable).find('tr').first().find('th, td').length;
const wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 10 });
}
ws['!cols'] = wscols;
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
@ -1656,7 +1871,7 @@ foreach ($period as $day) {
window.removeSelectedMaterial = function(checkbox) {
let container = checkbox.closest(".sortable-item");
let materialCode = checkbox.value;
let machineId = checkbox.value;
let materialName = container.querySelector("label").innerText;
container.remove();
@ -1667,17 +1882,17 @@ foreach ($period as $day) {
let selectedOption = dropdown.options[dropdown.selectedIndex];
if (selectedOption.value !== "") {
let materialCode = selectedOption.value;
let machineId = selectedOption.value;
let materialName = selectedOption.text;
let container = document.createElement("div");
container.classList.add("sortable-item");
container.id = materialCode + "_container";
container.id = machineId + "_container";
container.innerHTML = `
<input type="checkbox" id="${materialCode}_checkboxId"
name="customisedMachineCodes[]" value="${materialCode}"
<input type="checkbox" id="${machineId}_checkboxId"
name="customisedMachineCodes[]" value="${machineId}"
onclick="removeSelectedMaterial(this)" checked>
<label class="grab" for="${materialCode}_checkboxId"> ${materialName} </label>
<label class="grab" for="${machineId}_checkboxId"> ${materialName} </label>
<br>
`;
@ -1778,25 +1993,160 @@ foreach ($period as $day) {
<script>
//getting modal backdrop inside full screen
$(document).ready(function() {
function moveModalBackdropToFullscreen() {
setTimeout(() => {
$('.modal-backdrop').appendTo('#fullscreenDiv'); // Move backdrop inside fullscreen
}, 10); // Small delay ensures backdrop is created first
$('#fullscreenBtn').click(function() {
// Show fullscreen container
$('#fullscreenDiv').show();
// Request fullscreen
if (document.fullscreenElement == null) {
document.getElementById('fullscreenDiv').requestFullscreen();
}
// Move the modal backdrop when a modal opens
$('#bs-example-modal-lg, #customizeModalId').on('show.bs.modal', function() {
moveModalBackdropToFullscreen();
// Add custom backdrop
$('#fullscreenDiv').prepend('<div class="custom-backdrop"></div>');
// Move modal into fullscreen div and show it manually
$('#fullscreenDiv').append($('#customizeModalId'));
$('#customizeModalId').modal('show');
});
// On modal close, clean up
$('#customizeModalId').on('hidden.bs.modal', function () {
$('.custom-backdrop').remove();
$('#fullscreenDiv').hide();
if (document.fullscreenElement) {
document.exitFullscreen();
}
});
});
</script>
<script>
function showMessage(msg) {
let msgBox = document.getElementById("successMessage");
msgBox.innerText = msg; // Set API message
msgBox.style.display = "block";
// Hide message after 3 seconds
setTimeout(() => {
msgBox.style.display = "none";
}, 5000);
}
</script>
<script>
function calculateTotal(table,dataId,column) {
let columnTotal = 0;
let rows = table.querySelectorAll('tbody tr');
let machineId = dataId.split(' ')[1]??'';
console.log("here")
rows.forEach(row => {
let date = row.querySelector('td:first-child').innerText.trim().split('-');
date = date[2] + "-" + date[1] + "-" + date[0]; // Convert to YYYY-MM-DD format
let cell = null;
if(machineId) {
cell = row.querySelector(`td.${column}[data-id="${date} ${machineId}"]`);
}else{
cell = row.querySelector(`td.${column}[data-id="${date}"]`);
console.log('inside machine id not present');
}
if (cell) {
let value = parseFloat(cell.innerText.trim()) || 0;
columnTotal += value;
}
});
// Ensure modals work properly in fullscreen mode
document.addEventListener("fullscreenchange", function() {
setTimeout(() => {
$('.modal-backdrop').remove(); // Remove any existing backdrops
moveModalBackdropToFullscreen();
}, 200);
});
});
if(machineId) {
// Update the total cell in the footer
let footerColumn = table.querySelector(`tfoot tr td.${column}[data-id="footer ${machineId}"]`);
if (footerColumn) {
footerColumn.innerText = columnTotal == 0 ? " " : columnTotal.toFixed(2);
}
// let footerColumnOpeningReading = table.querySelector(`tfoot tr td.openingReading[data-id="footer ${machineId}`)??0;
// let footerColumnClosingReading = table.querySelector(`tfoot tr td.closingReading[data-id="footer ${machineId}`)??0;
// let footerColumnFillingReading = table.querySelector(`tfoot tr td.fillingDiesel[data-id="footer ${machineId}`)??0;
// let footerColumnConsumption = table.querySelector(`tfoot tr td.consumption[data-id="footer ${machineId}`);
// let footerColumnMachineRunningHours = table.querySelector(`tfoot tr td.runningHours[data-id="footer ${machineId}`)??0;
// let footerColumnMileage = table.querySelector(`tfoot tr td.mileage[data-id="footer ${machineId}`);
// footerColumnMachineRunningHours.innerText = isNaN(
// (parseFloat(footerColumnClosingReading.innerText.trim())
// -
// parseFloat(footerColumnOpeningReading.innerText.trim()))
// ) ? " " :
// (parseFloat(footerColumnClosingReading.innerText.trim())
// -
// parseFloat(footerColumnOpeningReading.innerText.trim())).toFixed(2);
// footerColumnMileage.innerText = (
// isNaN(parseFloat(footerColumnConsumption.innerText.trim()))
// ||
// isNaN(parseFloat(footerColumnMachineRunningHours.innerText.trim()))
// ||
// parseFloat(footerColumnMachineRunningHours.innerText.trim()) === 0
// ) ? " " :
// (parseFloat(footerColumnConsumption.innerText.trim()) / parseFloat(footerColumnMachineRunningHours.innerText.trim())).toFixed(2);
}else{
// Update the total cell in the footer for TD
let footerColumn = table.querySelector(`tfoot tr td.${column}[data-id="footer ${column}"]`);
if (footerColumn) {
footerColumn.innerText = columnTotal == 0 ? " " : columnTotal;
}
// let footerColumnOpeningTD = table.querySelector(`tfoot tr td.openingTD[data-id="footer openingTD`)??0;
// let footerColumnPurchaseTD = table.querySelector(`tfoot tr td.purchaseTD[data-id="footer purchaseTD`)??0;
// let footerColumnFillingTD = table.querySelector(`tfoot tr td.fillingTD[data-id="footer fillingTD`)??0;
// let footerColumnBalanceTD = table.querySelector(`tfoot tr td.balanceTD[data-id="footer balanceTD`);
// footerColumnOpeningTD.innerText = " ";
// footerColumnBalanceTD.innerText = " ";
// footerColumnBalanceTD.innerText = ( parseFloat(footerColumnOpeningTD.innerText.trim())
// +
// parseFloat(footerColumnPurchaseTD.innerText.trim())
// )
// -
// parseFloat(footerColumnFillingTD.innerText.trim());
}
}
</script>

View File

@ -535,7 +535,9 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<div class="col-md-3">
<label class="form" for="additionalEntryInputSandMoistureId">Input Sand Moisture (%)</label>
<span class="text-danger">*</span>
<input type="text" class="form-control" id="additionalEntryInputSandMoistureId" name="input_sand_moisture" value="" required>
<input type="text" class="form-control" id="additionalEntryInputSandMoistureId" name="input_sand_moisture" value=""
onchange="additionalEntryInputSandMoisture();"
required>
</div>
@ -592,9 +594,11 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<!-- dust qty -->
<div class="col-md-3">
<label class="form" for="additionalEntryDustQtyId">Dust Qty (Metric Ton)</label>
<label class="form" for="additionalEntryDustQtyId">Dust Qty (Kgs)</label>
<span class="text-danger">*</span>
<input type="text" class="form-control" id="additionalEntryDustQtyId" name="dust_qty" value="" required>
<input type="text" class="form-control" id="additionalEntryDustQtyId" name="dust_qty" value=""
onchange="additionalEntryDustQty();"
required>
</div>
@ -699,7 +703,9 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<div class="col-md-3">
<label class="form" for="editEntryInputSandMoistureId">Input Sand Moisture (%)</label>
<span class="text-danger">*</span>
<input type="text" class="form-control" id="editEntryInputSandMoistureId" name="input_sand_moisture" value="" required>
<input type="text" class="form-control" id="editEntryInputSandMoistureId" name="input_sand_moisture" value=""
onchange="editEntryInputSandMoisture();"
required>
</div>
@ -756,9 +762,11 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<!-- dust qty -->
<div class="col-md-3">
<label class="form" for="editEntryDustQtyId">Dust Qty (Metric Ton)</label>
<label class="form" for="editEntryDustQtyId">Dust Qty (Kgs)</label>
<span class="text-danger">*</span>
<input type="text" class="form-control" id="editEntryDustQtyId" name="dust_qty" value="" required>
<input type="text" class="form-control" id="editEntryDustQtyId" name="dust_qty" value=""
onchange="editEntryDustQty();"
required>
</div>
@ -807,7 +815,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<th class="celda_encabezado_general">Gas Per Ton</th>
<th class="celda_encabezado_general">Qty Per Hrs (Metric Ton)</th>
<th class="celda_encabezado_general">Moisture Loss Qty (Metric Ton)</th>
<th class="celda_encabezado_general">Dust Qty (Metric Ton)</th>
<th class="celda_encabezado_general">Dust Qty (Kgs)</th>
<th class="celda_encabezado_general" align="left">Customer Name</th>
<th class="celda_encabezado_general" style="display:none;">id</th>
@ -895,12 +903,12 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<!-- td:eq(9) gas_per_ton -->
<td class="celda_normal">
<?php echo round($a['gas_per_ton']); ?>
<?php echo $a['gas_per_ton']; ?>
</td>
<!-- td:eq(10) qty_per_hours -->
<td class="celda_normal">
<?php echo round($a['qty_per_hours']); ?>
<?php echo $a['qty_per_hours']; ?>
</td>
@ -1122,9 +1130,9 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
hours = parseInt(hours, 10);
// Adjust hours based on AM/PM
if (modifier === "pm" && hours < 12) {
if (modifier === "PM" && hours < 12) {
hours += 12;
} else if (modifier === "am" && hours === 12) {
} else if (modifier === "AM" && hours === 12) {
hours = 0;
}
@ -1188,6 +1196,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
let totalGasConsumption = $('#additionalEntryTotalGasConsumptionId').val();
let sandDriedQty = $('#additionalEntrySandDriedQtyId').val();
let basicCheck = checkIsNumber(totalGasConsumption);
let basicCheck2 = checkIsNumber(sandDriedQty);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (basicCheck2 == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (totalGasConsumption != '' && sandDriedQty != '') {
let gasPerTon = (parseFloat(totalGasConsumption) / parseFloat(sandDriedQty)).toFixed(2);
@ -1203,6 +1222,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
let inputSandQty = $('#additionalEntryInputSandQtyId').val();
let sandDriedQty = $('#additionalEntrySandDriedQtyId').val();
let basicCheck = checkIsNumber(inputSandQty);
let basicCheck2 = checkIsNumber(sandDriedQty);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (basicCheck2 == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (inputSandQty != '' && sandDriedQty != '') {
let moistureLossQty = parseFloat(inputSandQty) - parseFloat(sandDriedQty);
@ -1219,6 +1249,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
let drierRunninhHrs = $('#additionalEntryRunningHrsId').val();
let sandDriedQty = $('#additionalEntrySandDriedQtyId').val();
let basicCheck = checkIsNumber(drierRunninhHrs);
let basicCheck2 = checkIsNumber(sandDriedQty);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (basicCheck2 == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (drierRunninhHrs != '' && sandDriedQty != '') {
let qtyPerHrs = parseFloat(sandDriedQty) / parseFloat(drierRunninhHrs);
@ -1233,13 +1274,38 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
}
function additionalEntryInputSandMoisture(value) {
let sandMoisture = $('#additionalEntryInputSandMoistureId').val();
let basicCheck = checkIsNumber(sandMoisture);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
}
function additionalEntryDustQty(value) {
let dustQty = $('#additionalEntryDustQtyId').val();
let basicCheck = checkIsNumber(dustQty);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
}
// this for edit entry in ten ton f=drier
function editEntryCalculateMachineRunningHrs() {
let dreierMachineOnTime = $('#editEntryDrierOnTimeId').val();
let dreierMachineOnTime = $('#editEntryDrierOnTimeId').val();
let dreierMachineOffTime = $('#editEntryDrierOffTimeId').val();
if (dreierMachineOnTime == dreierMachineOffTime) {
@ -1291,6 +1357,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
let totalGasConsumption = $('#editEntryTotalGasConsumptionId').val();
let sandDriedQty = $('#editEntrySandDriedQtyId').val();
let basicCheck = checkIsNumber(totalGasConsumption);
let basicCheck2 = checkIsNumber(sandDriedQty);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (basicCheck2 == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (totalGasConsumption != '' && sandDriedQty != '') {
let gasPerTon = (parseFloat(totalGasConsumption) / parseFloat(sandDriedQty)).toFixed(2);
@ -1306,6 +1383,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
let inputSandQty = $('#editEntryInputSandQtyId').val();
let sandDriedQty = $('#editEntrySandDriedQtyId').val();
let basicCheck = checkIsNumber(inputSandQty);
let basicCheck2 = checkIsNumber(sandDriedQty);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (basicCheck2 == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (inputSandQty != '' && sandDriedQty != '') {
let moistureLossQty = parseFloat(inputSandQty) - parseFloat(sandDriedQty);
@ -1322,6 +1410,17 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
let drierRunninhHrs = $('#editEntryRunningHrsId').val();
let sandDriedQty = $('#editEntrySandDriedQtyId').val();
let basicCheck = checkIsNumber(drierRunninhHrs);
let basicCheck2 = checkIsNumber(sandDriedQty);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (basicCheck2 == 0) {
alert("Kindly Enter Numbers only..!!");
}
if (drierRunninhHrs != '' && sandDriedQty != '') {
let qtyPerHrs = parseFloat(sandDriedQty) / parseFloat(drierRunninhHrs);
@ -1332,6 +1431,41 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
}
}
function editEntryInputSandMoisture(value) {
let sandMoisture = $('#editEntryInputSandMoistureId').val();
let basicCheck = checkIsNumber(sandMoisture);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
}
function editEntryDustQty(value) {
let dustQty = $('#editEntryDustQtyId').val();
let basicCheck = checkIsNumber(dustQty);
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
}
}
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
</script>
<!-- date filter optiond -->
@ -1395,17 +1529,14 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
let rows = [];
// Extract table data row-by-row
$(table).find('tr').each(function(rowIndex) {
$(table).find('tr').each(function() {
let rowData = [];
$(this).find('th, td').each(function(colIndex) {
$(this).find('th, td').each(function() {
// Skip hidden columns
if ($(this).css('display') === 'none') return;
let cellText = $(this).text().trim();
rowData.push(cellText);
});
@ -1417,25 +1548,37 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
// Create a worksheet from array (no DOM needed!)
let ws = XLSX.utils.aoa_to_sheet(rows);
// Calculate max column count from the collected rows
let colCount = 0;
rows.forEach(row => {
if (row.length > colCount) colCount = row.length;
});
// Set custom column widths (10 for each column)
const wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 10 });
}
ws['!cols'] = wscols;
// Create workbook and export
let wb = XLSX.utils.book_new();
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

@ -332,73 +332,86 @@
<div class="card" id="fullscreenDiv">
<div class="card-body">
<form align="center" id="changeMonthForm" action="<?= base_url('dustAndRoughStockDetails'); ?>" method="post">
<div class="row">
<?php $today = date('M-Y'); ?>
<div class="col-3">
</div>
<div class="col-2 mt-2 ml-4">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control "
data-provide="datepicker"
data-date-format="M-yyyy"
data-date-min-view-mode="1" readonly
style="max-width: 175px;">
</div>
<div class="col-3 text-right d-flex" style="justify-content: end;">
<input type="text" id="searchInput" placeholder="Search..."
class="mt-2"
style="padding: 8px;margin-bottom: 10px;width: 150px;border: 2px solid rgb(123, 11, 214);
border-radius: 5px;margin-right:15px;">
<i class="fa fa-table btn-lg mt-2"
title="Date Range Filter"
style="font-size: x-large; cursor:pointer; color:rgb(95, 102, 105)"
data-toggle="modal"
data-target="#filterModalId">
</i>
<i class="fa fa-download btn-lg mt-2"
title="Excel Download"
style="font-size: x-large; cursor:pointer; color: #0b7cba"
id="dustAndRoughStockExport">
</i>
<i class="fe-maximize noti-icon btn-lg mt-2"
title="Full Screen"
style="font-size: x-large; cursor:pointer; color:rgb(241, 9, 136)"
onclick="toggleDivFullscreen()">
</i>
<i class="fa fa-save btn-lg mt-2"
title="Save"
style="font-size: x-large; cursor:pointer; color:rgb(31, 132, 3)"
id="saveId">
</i>
</div>
<div class="col-4">
</div>
<div id="successMessage"
style="
display: none;
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: green;
color: white;
padding: 10px;
border-radius: 5px;
z-index: 1000;">
</div>
</form>
<div align="center">
<form style="width: 700px;" id="changeMonthForm" action="<?= base_url('dustAndRoughStockDetails'); ?>" method="post">
<div class="row">
<?php $today = date('M-Y'); ?>
<div class="col-3 mt-2">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control "
data-provide="datepicker"
data-date-format="M-yyyy"
data-date-min-view-mode="1" readonly
style="max-width: 175px;">
</div>
<div class="col-9 text-right d-flex" style="justify-content: end;">
<input type="text" id="searchInput" placeholder="Search..."
class="mt-2"
style="padding: 8px;margin-bottom: 10px;width: 150px;border: 2px solid rgb(123, 11, 214);
border-radius: 5px;margin-right:15px;">
<i class="fa fa-table btn-lg mt-2"
title="Date Range Filter"
style="font-size: x-large; cursor:pointer; color:rgb(95, 102, 105)"
data-toggle="modal"
data-target="#filterModalId">
</i>
<i class="fa fa-download btn-lg mt-2"
title="Excel Download"
style="font-size: x-large; cursor:pointer; color: #0b7cba"
id="dustAndRoughStockExport">
</i>
<i class="fe-maximize noti-icon btn-lg mt-2"
title="Full Screen"
style="font-size: x-large; cursor:pointer; color:rgb(241, 9, 136)"
onclick="toggleDivFullscreen()">
</i>
<i class="fa fa-save btn-lg mt-2"
title="Save"
style="font-size: x-large; cursor:pointer; color:rgb(31, 132, 3)"
id="saveId">
</i>
</div>
<div class="col-4">
</div>
</div>
</form>
</div>
<!-- filter modal -->
<div class="modal fade" id="filterModalId" tabindex="-1" role="dialog" aria-labelledby="filterModalLabelId" aria-hidden="true">
@ -560,9 +573,9 @@
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;"> Total </td>
<td class="celda_normal "> <b> <?= $summary['finalRough'] ?> </b> </td>
<td class="celda_normal "> <b> <?= $summary['dust'] ?> </b> </td>
<td class="celda_normal "> <b> <?= $summary['total'] ?> </b> </td>
<td class="celda_normal finalRough"> <b> <?= $summary['finalRough'] ?> </b> </td>
<td class="celda_normal dust"> <b> <?= $summary['dust'] ?> </b> </td>
<td class="celda_normal total"> <b> <?= $summary['total'] ?> </b> </td>
</tr>
</tfoot>
@ -597,7 +610,8 @@
if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"';
}
?>>
?>
>
<td class="celda_normal">
<?php
echo date("d-m-Y", strtotime($dateInMonth));
@ -618,8 +632,20 @@
data-id="<?= $dateInMonth ?>"><?= ' ' ?></td>
</tr>
<?php
}
}
}
?>
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;"> Total </td>
<td class="celda_normal finalRough">0</td>
<td class="celda_normal dust">0</td>
<td class="celda_normal total">0</td>
</tr>
</tfoot>
<?php
}
?>
@ -667,8 +693,6 @@
}
function checkDateRange(fromDate, toDate, tableDate) {
// Convert the dates to a comparable format (YYYY-MM-DD)
let from = convertToDate(fromDate);
@ -703,9 +727,8 @@
var updateDustAndRoughStockDetails = tableToJson();
alert('Updation may take a while, And we appreciate your patience..!!');
showMessage('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updateDustAndRoughStockDetails
@ -715,10 +738,8 @@
success: function(data) {
if (data) {
$('#loader').hide();
console.log(data);
alert(data);
window.location.reload();
showMessage(data);
}
},
@ -730,7 +751,7 @@
console.error("Response Text:", xhr.responseText);
},
complete: function() {
$('#loader').hide();
console.log("Ajax Request Completed for dust and Rough Stock Details");
}
});
@ -774,12 +795,26 @@
function finalRoughStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id')
let finalRoughStock = validateInput(tdElement.innerText);
let dustStock = validateInput(document.querySelector(`td.dust[data-id="${dataId}"]`).innerText);
let total = (Number(finalRoughStock) + Number(dustStock));
document.querySelector(`td.total[data-id="${dataId}"]`).innerText = total;
let table = document.getElementById('dustAndRoughStockDetailsTableId');
let column = 'finalRough' ;
calculateTotal(table,dataId,column);
} catch (error) {
console.error("There is an error updating stock ..!!" + error);
}
@ -787,12 +822,25 @@
function dustStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id')
let finalRoughStock = validateInput(document.querySelector(`td.finalRough[data-id="${dataId}"]`).innerText);
let dustStock = validateInput(tdElement.innerText);
let total = (Number(finalRoughStock) + Number(dustStock));
document.querySelector(`td.total[data-id="${dataId}"]`).innerText = total;
let table = document.getElementById('dustAndRoughStockDetailsTableId');
let column = 'dust';
calculateTotal(table,dataId,column);
} catch (error) {
@ -801,8 +849,6 @@
}
}
function validateInput(input) {
@ -818,12 +864,21 @@
// Validate against the regex
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
alert('Invalid input! Please enter a valid number.');
return 0;
}
return input;
}
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
</script>
@ -847,45 +902,52 @@
}
});
// Format date in first column and left-align
$(cloneTable).find('tbody tr').each(function() {
let firstTd = $(this).find('td').eq(0); // Get the first column (Date)
// Convert Date Format (Assuming it's in YYYY-MM-DD format)
let originalDate = firstTd.text().trim(); // Get the text value
let parts = originalDate.split('-'); // Split into [YYYY, MM, DD]
let firstTd = $(this).find('td').eq(0);
let originalDate = firstTd.text().trim();
let parts = originalDate.split('-');
if (parts.length === 3) {
let formattedDate = `${parts[2]}-${parts[1]}-${parts[0]}`; // Rearrange to DD-MM-YYYY
firstTd.text(formattedDate); // Update the cell value
let formattedDate = `${parts[2]}-${parts[1]}-${parts[0]}`;
firstTd.text(formattedDate);
}
// Apply left alignment to the date column
firstTd.css("text-align", "left");
});
// Convert modified table to worksheet
let ws = XLSX.utils.table_to_sheet(cloneTable);
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
// Dynamically get maximum column count
let colCount = 0;
$(cloneTable).find('tr').each(function() {
let count = $(this).find('th, td').length;
if (count > colCount) colCount = count;
});
// Set column widths to 10 units for each
const wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 10 });
}
ws['!cols'] = wscols;
// Create workbook and save
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'dustAndRoughStockDetailsTableId';
document.getElementById('dustAndRoughStockExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'dustAndRoughStockDetails.xlsx');
});
})
})
});
</script>
<script>
document.addEventListener("keydown", function(event) {
@ -1024,4 +1086,54 @@
}, 200);
});
});
</script>
<script>
function showMessage(msg) {
let msgBox = document.getElementById("successMessage");
msgBox.innerText = msg; // Set API message
msgBox.style.display = "block";
// Hide message after 3 seconds
setTimeout(() => {
msgBox.style.display = "none";
}, 5000);
}
</script>
<script>
function calculateTotal(table,dataId,column) {
let columnTotal = 0;
let rows = table.querySelectorAll('tbody tr');
rows.forEach(row => {
let cell = row.querySelector(`td.${column}`);
if (cell) {
let value = parseFloat(cell.innerText.trim()) || 0;
columnTotal += value;
}
});
// Update the total cell in the footer
let footerColumn = table.querySelector(`tfoot tr td.${column}`);
if (footerColumn) {
footerColumn.innerText = columnTotal == 0 ? " " : columnTotal.toFixed(2); // Format to 2 decimal places
}
let footerColumnTotal = table.querySelector(`tfoot tr td.total`);
let footerColumnFinalRough = table.querySelector(`tfoot tr td.finalRough`);
let footerColumnDust = table.querySelector(`tfoot tr td.dust`);
footerColumnTotal.innerText = parseFloat(footerColumnFinalRough.innerText.trim())
+
parseFloat(footerColumnDust.innerText.trim()) ;
}
</script>

View File

@ -312,6 +312,20 @@
<div class="card" id="fullscreenDiv">
<div class="card-body">
<div id="successMessage"
style="
display: none;
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: green;
color: white;
padding: 10px;
border-radius: 5px;
z-index: 1000;">
</div>
<form id="changeMonthForm" action="<?= base_url('gasStockDetails'); ?>" method="post">
@ -656,20 +670,34 @@
</td>
<td class="celda_normal"><?= $summary['opening'] ?></td>
<td class="celda_normal"><?= $summary['purchaseBharath'] ?></td>
<td class="celda_normal"><?= $summary['purchaseIndian'] ?></td>
<td class="celda_normal"><?= $summary['total'] ?></td>
<td class="celda_normal"><?= $summary['consumption'] ?></td>
<td class="celda_normal"><?= $summary['total'] - $summary['consumption'] ?></td>
<td class="celda_normal"><?= $summary['drierMachineGasConsumption'] ?></td>
<td class="celda_normal"><?= $summary['sandDried'] ?></td>
<td class="celda_normal"><?= $summary['coatingMachineGasconsumption'] ?></td>
<td class="celda_normal"><?= $summary['coatedSand'] ?></td>
<td class="celda_normal"><?= $summary['trp_panel_gas_consumption'] ?></td>
<td class="celda_normal"><?= $summary['trp_physical_gas_consumption'] ?></td>
<td class="celda_normal"><?= $summary['trp_sand_production'] ?></td>
<td class="celda_normal"><?= $summary['rotary_drier_consumption'] ?></td>
<td class="celda_normal openingStock"
data-id="footer openingStock"> </td>
<td class="celda_normal purchaseBharath"
data-id="footer purchaseBharath" ><?= $summary['purchaseBharath'] == 0 ? "" : $summary['purchaseBharath'] ?></td>
<td class="celda_normal purchaseIndian"
data-id="footer purchaseIndian"><?= $summary['purchaseIndian'] == 0 ? "" : $summary['purchaseIndian'] ?></td>
<td class="celda_normal total"
data-id="footer total"><?= $summary['total'] == 0 ? "" : $summary['total'] ?></td>
<td class="celda_normal consumption"
data-id="footer consumption"><?= $summary['consumption'] == 0 ? "" : $summary['consumption'] ?></td>
<td class="celda_normal balanceStock"
data-id="footer balanceStock" ><?= $summary['total'] - $summary['consumption'] == 0 ? "" : $summary['total'] - $summary['consumption'] ?></td>
<td class="celda_normal tenTonGasConsumption"
data-id="footer tenTonGasConsumption"><?= $summary['drierMachineGasConsumption'] == 0 ? "" : $summary['drierMachineGasConsumption'] ?></td>
<td class="celda_normal sandDried"
data-id="footer sandDried"><?= $summary['sandDried'] == 0 ? "" : $summary['sandDried'] ?></td>
<td class="celda_normal coatingGasConsumption"
data-id="footer coatingGasConsumption"><?= $summary['coatingMachineGasconsumption'] == 0 ? "" : $summary['coatingMachineGasconsumption'] ?></td>
<td class="celda_normal coatedSand"
data-id="footer coatedSand"><?= $summary['coatedSand'] == 0 ? "" : $summary['coatedSand'] ?></td>
<td class="celda_normal trpPanelGasConsumption"
data-id="footer trpPanelGasConsumption"><?= $summary['trp_panel_gas_consumption'] == 0 ? "" : $summary['trp_panel_gas_consumption'] ?></td>
<td class="celda_normal trpPhysicalGasConsumption"
data-id="footer trpPhysicalGasConsumption"><?= $summary['trp_physical_gas_consumption'] == 0 ? "" : $summary['trp_physical_gas_consumption'] ?></td>
<td class="celda_normal trpSandProduction"
data-id="footer trpSandProduction"><?= $summary['trp_sand_production'] == 0 ? "" : $summary['trp_sand_production'] ?></td>
<td class="celda_normal rotaryGasConsumption"
data-id="footer rotaryGasConsumption"><?= $summary['rotary_drier_consumption'] == 0 ? "" : $summary['rotary_drier_consumption'] ?></td>
@ -768,8 +796,51 @@
oninput="gasConsumptionChange(this)"
contenteditable="true"> </td>
</tr>
<?php }
} ?>
<?php } ?>
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<td class="celda_normal openingStock"
data-id="footer openingStock"> </td>
<td class="celda_normal purchaseBharath"
data-id="footer purchaseBharath" > </td>
<td class="celda_normal purchaseIndian"
data-id="footer purchaseIndian"></td>
<td class="celda_normal total"
data-id="footer total"></td>
<td class="celda_normal consumption"
data-id="footer consumption"> </td>
<td class="celda_normal balanceStock"
data-id="footer balanceStock" > </td>
<td class="celda_normal tenTonGasConsumption"
data-id="footer tenTonGasConsumption"> </td>
<td class="celda_normal sandDried"
data-id="footer sandDried"> </td>
<td class="celda_normal coatingGasConsumption"
data-id="footer coatingGasConsumption"> </td>
<td class="celda_normal coatedSand"
data-id="footer coatedSand"> </td>
<td class="celda_normal trpPanelGasConsumption"
data-id="footer trpPanelGasConsumption"> </td>
<td class="celda_normal trpPhysicalGasConsumption"
data-id="footer trpPhysicalGasConsumption"> </td>
<td class="celda_normal trpSandProduction"
data-id="footer trpSandProduction"> </td>
<td class="celda_normal rotaryGasConsumption"
data-id="footer rotaryGasConsumption"> </td>
</tr>
</tfoot>
<?php } ?>
</tbody>
</table>
</div>
@ -826,9 +897,8 @@
var updateGasStockDetails = tableToJson();
alert('Updation may take a while, And we appreciate your patience..!!');
showMessage('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updateGasStockDetails
@ -838,22 +908,19 @@
success: function(data) {
if (data) {
$('#loader').hide();
console.log(data);
alert(data);
window.location.reload();
showMessage(data);
}
},
error: function(xhr, status, error) {
alert("An error occurred while processing the request. Please try again.");
showMessage("An error occurred while processing the request. Please try again.");
console.error("Error Code:", xhr.status);
console.error("Error Message:", error);
console.error("Response Text:", xhr.responseText);
},
complete: function() {
$('#loader').hide();
console.log("Request completed.");
}
});
@ -900,6 +967,14 @@
function openingStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let date = dataId;
let openingStock = validateInput(tdElement.innerText);
@ -912,7 +987,16 @@
document.querySelector(`td.total[data-id="${dataId}"]`).innerText = totalGas;
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
updateStockValue(date, currentBalanceStock)
updateStockValue(date, currentBalanceStock);
let table = document.getElementById('gasStockDetailsTableId');
let column2 = "openingStock";
let column3 = "total";
let column4 = "balanceStock";
calculateTotal(table,dataId,column2);
calculateTotal(table,dataId,column3);
calculateTotal(table,dataId,column4);
} catch (error) {
@ -924,6 +1008,14 @@
function purchaseBharathStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let date = dataId;
let openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText);
@ -936,7 +1028,18 @@
document.querySelector(`td.total[data-id="${dataId}"]`).innerText = totalGas;
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
updateStockValue(date, currentBalanceStock)
updateStockValue(date, currentBalanceStock);
let table = document.getElementById('gasStockDetailsTableId');
let column1 = 'purchaseBharath';
let column2 = "openingStock";
let column3 = "total";
let column4 = "balanceStock";
calculateTotal(table,dataId,column1);
calculateTotal(table,dataId,column2);
calculateTotal(table,dataId,column3);
calculateTotal(table,dataId,column4);
} catch (error) {
@ -949,6 +1052,14 @@
function purchaseIndianStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let date = dataId;
let openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText);
@ -961,7 +1072,19 @@
document.querySelector(`td.total[data-id="${dataId}"]`).innerText = totalGas;
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
updateStockValue(date, currentBalanceStock)
updateStockValue(date, currentBalanceStock);
let table = document.getElementById('gasStockDetailsTableId') ;
let column1 = 'purchaseIndian' ;
let column2 = "openingStock" ;
let column3 = "total" ;
let column4 = "balanceStock" ;
calculateTotal(table,dataId,column1);
calculateTotal(table,dataId,column2);
calculateTotal(table,dataId,column3);
calculateTotal(table,dataId,column4);
} catch (error) {
@ -974,18 +1097,29 @@
function gasConsumptionChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let date = dataId;
//total gas consumption
let tenTonGasConsumption = validateInput(document.querySelector(`td.tenTonGasConsumption[data-id="${dataId}"]`).innerText);
let coatingGasConsumption = validateInput(document.querySelector(`td.coatingGasConsumption[data-id="${dataId}"]`).innerText);
let trpPanelGasConsumption = validateInput(document.querySelector(`td.trpPanelGasConsumption[data-id="${dataId}"]`).innerText);
let trpPhysicalGasConsumption = validateInput(document.querySelector(`td.trpPhysicalGasConsumption[data-id="${dataId}"]`).innerText);
let rotaryGasConsumption = validateInput(document.querySelector(`td.rotaryGasConsumption[data-id="${dataId}"]`).innerText);
let toatalGasConsumption = Number(tenTonGasConsumption) + Number(coatingGasConsumption) + Number(trpPhysicalGasConsumption) +
Number(trpPanelGasConsumption) + Number(rotaryGasConsumption);
let tenTonGasConsumption = validateInput(document.querySelector(`td.tenTonGasConsumption[data-id="${dataId}"]`).innerText);
let coatingGasConsumption = validateInput(document.querySelector(`td.coatingGasConsumption[data-id="${dataId}"]`).innerText);
let trpPanelGasConsumption = validateInput(document.querySelector(`td.trpPanelGasConsumption[data-id="${dataId}"]`).innerText);
let trpPhysicalGasConsumption = validateInput(document.querySelector(`td.trpPhysicalGasConsumption[data-id="${dataId}"]`).innerText);
let rotaryGasConsumption = validateInput(document.querySelector(`td.rotaryGasConsumption[data-id="${dataId}"]`).innerText);
let toatalGasConsumption = Number(tenTonGasConsumption) + Number(coatingGasConsumption)
+ Number(trpPhysicalGasConsumption)
// + Number(trpPanelGasConsumption)
//panel gas is not used in consumption calculation but needed its value in sheet..!!
+ Number(rotaryGasConsumption);
//total gas purchase and opening addition
@ -1001,13 +1135,38 @@
document.querySelector(`td.consumption[data-id="${dataId}"]`).innerText = toatalGasConsumption;
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
updateStockValue(date, currentBalanceStock)
updateStockValue(date, currentBalanceStock);
let table = document.getElementById('gasStockDetailsTableId');
let column1 = tdElement.className.split(' ')[1];
let column2 = "openingStock";
let column3 = "total";
let column4 = "balanceStock";
let column5 = "consumption";
calculateTotal(table,dataId,column5);
calculateTotal(table,dataId,column1);
calculateTotal(table,dataId,column2);
calculateTotal(table,dataId,column3);
calculateTotal(table,dataId,column4);
} catch (error) {
console.error("There is an error updating stock ..!!" + error);
}
}
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
</script>
<script>
@ -1167,43 +1326,52 @@
}
});
// Format date in first column and left-align
$(cloneTable).find('tbody tr').each(function() {
let firstTd = $(this).find('td').eq(0); // Get the first column (Date)
// Convert Date Format (Assuming it's in YYYY-MM-DD format)
let originalDate = firstTd.text().trim(); // Get the text value
let parts = originalDate.split('-'); // Split into [YYYY, MM, DD]
let firstTd = $(this).find('td').eq(0);
let originalDate = firstTd.text().trim();
let parts = originalDate.split('-');
if (parts.length === 3) {
let formattedDate = `${parts[2]}-${parts[1]}-${parts[0]}`; // Rearrange to DD-MM-YYYY
firstTd.text(formattedDate); // Update the cell value
let formattedDate = `${parts[2]}-${parts[1]}-${parts[0]}`;
firstTd.text(formattedDate);
}
// Apply left alignment to the date column
firstTd.css("text-align", "left");
});
// Convert modified table to worksheet
let ws = XLSX.utils.table_to_sheet(cloneTable);
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
// Dynamically get maximum column count
let colCount = 0;
$(cloneTable).find('tr').each(function() {
let count = $(this).find('th, td').length;
if (count > colCount) colCount = count;
});
// Set each column width to 10
const wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 10 });
}
ws['!cols'] = wscols;
// Create workbook and save
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'gasStockDetailsTableId';
document.getElementById('gasStockDetailsExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'gasStockDetails<?= $month ?>.xlsx');
});
})
})
});
</script>
<script>
document.addEventListener("keydown", function(event) {
@ -1337,4 +1505,99 @@
</script>
<script>
function showMessage(msg) {
let msgBox = document.getElementById("successMessage");
msgBox.innerText = msg; // Set API message
msgBox.style.display = "block";
// Hide message after 3 seconds
setTimeout(() => {
msgBox.style.display = "none";
}, 5000);
}
</script>
<script>
function calculateTotal(table,dataId,column) {
let columnTotal = 0;
let rows = table.querySelectorAll('tbody tr');
rows.forEach(row => {
let date = row.querySelector('td:first-child').innerText.trim().split('-');
date = date[2] + "-" + date[1] + "-" + date[0]; // Convert to YYYY-MM-DD format
let cell = null;
cell = row.querySelector(`td.${column}[data-id="${date}"]`);
if (cell) {
let value = parseFloat(cell.innerText.trim()) || 0;
columnTotal += value ;
}
});
// Update the total cell in the footer
let footerColumn = table.querySelector(`tfoot tr td.${column}[data-id="footer ${column}"]`);
if (footerColumn) {
footerColumn.innerText = columnTotal == 0 ? " " : columnTotal.toFixed(2);
}
let footerColumnOpeningStock = table.querySelector(`tfoot tr td.openingStock[data-id="footer openingStock`);
let footerColumnPurchaseBharath = table.querySelector(`tfoot tr td.purchaseBharath[data-id="footer purchaseBharath`);
let footerColumnPurchaseIndian = table.querySelector(`tfoot tr td.purchaseIndian[data-id="footer purchaseIndian`);
let footerColumnTotal = table.querySelector(`tfoot tr td.total[data-id="footer total`);
let footerColumnConsumption = table.querySelector(`tfoot tr td.consumption[data-id="footer consumption`);
let footerColumnBalanceStock = table.querySelector(`tfoot tr td.balanceStock[data-id="footer balanceStock`);
footerColumnTotal.innerText = isNaN(
parseFloat(footerColumnOpeningStock.innerText.trim() )
+
parseFloat(footerColumnPurchaseBharath.innerText.trim())
+
parseFloat(footerColumnPurchaseIndian.innerText.trim())
) == true
?
" " : (
parseFloat(footerColumnOpeningStock.innerText.trim() )
+
parseFloat(footerColumnPurchaseBharath.innerText.trim())
+
parseFloat(footerColumnPurchaseIndian.innerText.trim())
) ;
footerColumnBalanceStock.innerText = isNaN(
parseFloat(footerColumnTotal.innerText.trim())
-
parseFloat(footerColumnConsumption.innerText.trim())
) == true
?
" " : (
parseFloat(footerColumnTotal.innerText.trim())
-
parseFloat(footerColumnConsumption.innerText.trim())
) ;
}
</script>

View File

@ -720,7 +720,7 @@
<span style="min-width: 150px; max-width: 150px;">
<select class="form-control select2" name="remark" id="remarkInFormId" required>
<option value="">select</option>
<option value="">Select</option>
<option value="noRemark">No Remark</option>
<option value="accepted">Accepted</option>
<option value="conditionallyAccepted">Conditionally Accepted</option>
@ -1550,12 +1550,20 @@
<!-- Calculate Row on oninput inside sand report modal -->
<script>
function calculateRow(value) {
function calculateRow(tdElement) {
var table = $('#meshTableId');
if (value != "moistureValue") {
var tr = $(value).closest('tr');
if (tdElement != "moistureValue") {
let basicCheck = checkIsNumber(tdElement.innerText.trim()) ;
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return;
}
var tr = $(tdElement).closest('tr');
var weighOfSand = validateInput(tr.find('td:eq(3)').text());
var factor = validateInput(tr.find('td:eq(4)').text());
tr.find('td:eq(5)').text(parseFloat((weighOfSand * factor).toFixed(2)));
@ -1645,6 +1653,35 @@
return;
}
$('#dwnldMoistureActualId , #dwnldMoistureSpecId , dwnldLossOfIgnitionId , #dwnldClayId , #dwnldGradeId , .celda_normal').on('input', function() {
let input = $(this).text().trim();
let isValid = checkIsNumber(input);
if (isValid == 0) {
alert("Kindly Enter Numbers only..!!");
return;
} else {
$(this).text(input);
}
calculateRow(value='moistureValue');
});
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}else{
return 1;
}
}
</script>
@ -1761,7 +1798,6 @@
// Validate against the regex
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
alert('Invalid input! Please enter a valid number.');
return 0;
}
@ -1777,7 +1813,6 @@
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let cloneTable = table.cloneNode(true); // Clone the table to modify
// Remove hidden rows
@ -1792,55 +1827,64 @@
}
});
// Format Invoice Date and Material Received Date columns
$(cloneTable).find('tbody tr').each(function() {
let invoiceTd = $(this).find('td').eq(2); // Get the first column (Date)
let materialReceivedTd = $(this).find('td').eq(3); // Get the second column (Material Received)
let invoiceTd = $(this).find('td').eq(2);
let materialReceivedTd = $(this).find('td').eq(3);
// Convert Date Format (Assuming it's in YYYY-MM-DD format)
let originalInvoiceDate = invoiceTd.text().trim(); // Get the text value
let originalMaterialReceivedDate = materialReceivedTd.text().trim(); // Get the text value
let originalInvoiceDate = invoiceTd.text().trim();
let originalMaterialReceivedDate = materialReceivedTd.text().trim();
let originalInvoiceParts = originalInvoiceDate.split('-'); // Split into [YYYY, MM, DD]
let originalMaterialReceivedParts = originalMaterialReceivedDate.split('-'); // Split into [YYYY, MM, DD]
let invoiceParts = originalInvoiceDate.split('-');
let materialReceivedParts = originalMaterialReceivedDate.split('-');
if (originalInvoiceParts.length === 3) {
let formattedDate = `${originalInvoiceParts[2]}-${originalInvoiceParts[1]}-${originalInvoiceParts[0]}`; // Rearrange to DD-MM-YYYY
invoiceTd.text(formattedDate); // Update the cell value
if (invoiceParts.length === 3) {
let formattedInvoiceDate = `${invoiceParts[2]}-${invoiceParts[1]}-${invoiceParts[0]}`;
invoiceTd.text(formattedInvoiceDate);
}
if (originalMaterialReceivedParts.length === 3) {
let formattedDate = `${originalMaterialReceivedParts[2]}-${originalMaterialReceivedParts[1]}-${originalMaterialReceivedParts[0]}`; // Rearrange to DD-MM-YYYY
materialReceivedTd.text(formattedDate); // Update the cell value
if (materialReceivedParts.length === 3) {
let formattedMaterialDate = `${materialReceivedParts[2]}-${materialReceivedParts[1]}-${materialReceivedParts[0]}`;
materialReceivedTd.text(formattedMaterialDate);
}
// Apply left alignment to the date column
invoiceTd.css("text-align", "left");
materialReceivedTd.css("text-align", "left");
});
// Convert modified table to sheet
let ws = XLSX.utils.table_to_sheet(cloneTable);
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
// Dynamically calculate visible column count for setting column widths
let colCount = 0;
$(cloneTable).find('tr').each(function() {
let count = $(this).find('th, td').length;
if (count > colCount) colCount = count;
});
// Set each column width to 10 characters
let wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 15 });
}
ws['!cols'] = wscols;
// Create workbook and save
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'incomingSilicaSandDetailsTable';
document.getElementById('incomingSilicaSandDetailsExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'incomingSilicaSandDetails_<?= $month ?>.xlsx');
});
})
})
});
</script>
<!-- on enter key press allowing user to go next line instead of submitting any form here -->
<script>
document.addEventListener("keydown", function(event) {

View File

@ -326,6 +326,20 @@ foreach ($period as $day) {
<div class="card" id="fullscreenDiv">
<div class="card-body">
<div id="successMessage"
style="
display: none;
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: green;
color: white;
padding: 10px;
border-radius: 5px;
z-index: 1000;">
</div>
<form id="changeMonthForm" action="<?= base_url('powerConsumptionDetails'); ?>" method="post">
@ -334,6 +348,7 @@ foreach ($period as $day) {
<div class="col-2">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control mt-2"
style="z-index:30;" readonly>
</div>
@ -374,7 +389,7 @@ foreach ($period as $day) {
<i class="fa fa-download btn-lg mt-2"
title="Excel Download"
style="font-size: x-large; cursor:pointer; color: #0b7cba"
id="bagStockExport">
id="powerConsumptionExport">
</i>
<i class="fe-maximize noti-icon btn-lg mt-2"
@ -774,6 +789,7 @@ foreach ($period as $day) {
'opening_units' => "-",
'closing_units' => 0,
'total_units' => 0,
'machine_id' => $machineId,
];
}
@ -797,22 +813,48 @@ foreach ($period as $day) {
<b> Total </b>
</td>
<td class="celda_normal "><?= $summary['openingReading'] ?></td>
<td class="celda_normal "><?= $summary['finalReading'] ?></td>
<td class="celda_normal "><?= $summary['totalReading'] ?></td>
<td class="celda_normal "><?= $summary['totalUnits'] ?></td>
<td class="celda_normal "><?= $summary['averagePf'] ?></td>
<td class="celda_normal "><?= $summary['presentPf'] ?></td>
<td class="celda_normal "><?= $summary['md'] ?></td>
<td class="celda_normal "><?= $summary['mf'] ?></td>
<td class="celda_normal openingTP"
data-id="footer openingTP">
</td>
<td class="celda_normal finalTP"
data-id="footer finalTP">
</td>
<td class="celda_normal totalReadingTP"
data-id="footer totalReadingTP">
<?= $summary['totalReading'] ?></td>
<td class="celda_normal totalUnitsTP"
data-id="footer totalUnitsTP">
<?= $summary['totalUnits'] ?></td>
<td class="celda_normal averagePf"
data-id="footer averagePf">
</td>
<td class="celda_normal presentPf"
data-id="footer presentPf">
</td>
<td class="celda_normal mdTP"
data-id="footer mdTP">
</td>
<td class="celda_normal mfTP"
data-id="footer mfTP">
</td>
<?php foreach ($summary as $each) {
if (is_array($each)) {
?>
<td class="celda_normal "><?= $each['opening_units'] ?> </td>
<td class="celda_normal "><?= $each['closing_units'] ?></td>
<td class="celda_normal "><?= $each['total_units'] ?></td>
<td class="celda_normal openingUnits"
data-id="footer <?=$each['machine_id']?>"> </td>
<td class="celda_normal closingUnits"
data-id="footer <?=$each['machine_id']?>"></td>
<td class="celda_normal totalUnits"
data-id="footer <?=$each['machine_id']?>"><?= $each['total_units'] ?></td>
<?php
}
@ -968,7 +1010,70 @@ foreach ($period as $day) {
<?php } ?>
</tr>
<?php } ?>
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<td class="celda_normal openingTP"
data-id="footer openingTP">
</td>
<td class="celda_normal finalTP"
data-id="footer finalTP">
</td>
<td class="celda_normal totalReadingTP"
data-id="footer totalReadingTP">
</td>
<td class="celda_normal totalUnitsTP"
data-id="footer totalUnitsTP">
</td>
<td class="celda_normal averagePf"
data-id="footer averagePf">
</td>
<td class="celda_normal presentPf"
data-id="footer presentPf">
</td>
<td class="celda_normal mdTP"
data-id="footer mdTP">
</td>
<td class="celda_normal mfTP"
data-id="footer mfTP">
</td>
<?php foreach ($electricMachines as $each) {
if (is_array($each)) {
?>
<td class="celda_normal openingUnits"
data-id="footer <?=$each['id']?>"></td>
<td class="celda_normal closingUnits"
data-id="footer <?=$each['id']?>"></td>
<td class="celda_normal totalUnits"
data-id="footer <?=$each['id']?>"></td>
<?php
}
}
?>
</tr>
</tfoot>
<?php } ?>
@ -1077,9 +1182,8 @@ foreach ($period as $day) {
var updatePowerConsumptionDetails = tableToJson();
alert('Updation may take a while, And we appreciate your patience..!!');
showMessage('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updatePowerConsumptionDetails
@ -1089,21 +1193,19 @@ foreach ($period as $day) {
success: function(data) {
if (data) {
$('#loader').hide();
alert(data);
window.location.reload();
showMessage(data);
}
},
error: function(xhr, status, error) {
alert("An error occurred while processing the request. Please try again.");
showMessage("An error occurred while processing the request. Please try again.");
console.error("Error Code:", xhr.status);
console.error("Error Message:", error);
console.error("Response Text:", xhr.responseText);
},
complete: function() {
$('#loader').hide();
console.log("Request completed.");
}
});
@ -1176,6 +1278,14 @@ foreach ($period as $day) {
function openingUnitsChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
let openingUnits = validateInput(tdElement.innerText);
@ -1186,7 +1296,13 @@ foreach ($period as $day) {
document.querySelector(`td.totalUnits[data-id="${dataId}"]`).innerText = parseFloat(totalUnits).toFixed(2);
updateStockValue(date, machine_id, closingUnits)
updateStockValue(date, machine_id, closingUnits);
let table = document.getElementById('powerStockDetailsTableId');
let column1 = 'totalUnits';
calculateTotal(table,dataId,column1);
} catch (error) {
@ -1199,6 +1315,14 @@ foreach ($period as $day) {
function closingUnitsChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
let openingUnits = validateInput(document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText);
@ -1209,7 +1333,13 @@ foreach ($period as $day) {
document.querySelector(`td.totalUnits[data-id="${dataId}"]`).innerText = parseFloat(totalUnits).toFixed(2);
updateStockValue(date, machine_id, closingUnits)
updateStockValue(date, machine_id, closingUnits);
let table = document.getElementById('powerStockDetailsTableId');
let column1 = 'totalUnits';
calculateTotal(table,dataId,column1);
} catch (error) {
@ -1224,6 +1354,13 @@ foreach ($period as $day) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let openingTP = validateInput(tdElement.innerText);
@ -1239,6 +1376,15 @@ foreach ($period as $day) {
updateTotalStockValue(dataId, finalTP);
let table = document.getElementById('powerStockDetailsTableId');
let column2 = 'totalReadingTP';
let column3 = 'totalUnitsTP';
calculateTotal(table,dataId,column2);
calculateTotal(table,dataId,column3);
} catch (error) {
@ -1252,6 +1398,13 @@ foreach ($period as $day) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let openingTP = validateInput(document.querySelector(`td.openingTP[data-id="${dataId}"]`).innerText);
@ -1265,8 +1418,19 @@ foreach ($period as $day) {
document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = parseFloat(totalUnitsTP).toFixed(2);
updateTotalStockValue(dataId, finalTP)
updateTotalStockValue(dataId, finalTP);
let table = document.getElementById('powerStockDetailsTableId');
let column2 = 'totalReadingTP';
let column3 = 'totalUnitsTP';
calculateTotal(table,dataId,column2);
calculateTotal(table,dataId,column3);
} catch (error) {
@ -1280,12 +1444,30 @@ foreach ($period as $day) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let mdTP = validateInput(tdElement.innerText);
document.querySelector(`td.mfTP[data-id="${dataId}"]`).innerText = parseFloat(mdTP * 60).toFixed(2);
// let table = document.getElementById('powerStockDetailsTableId');
// let column1 = 'mdTP';
// let cloumn2 = 'mfTP';
// calculateTotal(table,dataId,column1);
// calculateTotal(table,dataId,column2);
} catch (error) {
console.error("There is an error updating stock ..!!" + error);
@ -1315,6 +1497,16 @@ foreach ($period as $day) {
return input;
}
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
</script>
<script>
@ -1408,9 +1600,8 @@ foreach ($period as $day) {
<script>
$(document).ready(function() {
function exportTableToExcel(tableID, filename = '') {
function exportTableToExcel(tableID, filename = '', dateColumns = []) {
let table = document.getElementById(tableID);
let cloneTable = table.cloneNode(true); // Clone the table to modify
// Remove hidden rows
@ -1425,43 +1616,52 @@ foreach ($period as $day) {
}
});
// Format specified date columns
$(cloneTable).find('tbody tr').each(function() {
let firstTd = $(this).find('td').eq(0); // Get the first column (Date)
dateColumns.forEach(function(colIndex) {
let td = $(this).find('td').eq(colIndex);
let originalDate = td.text().trim();
let parts = originalDate.split('-');
// Convert Date Format (Assuming it's in YYYY-MM-DD format)
let originalDate = firstTd.text().trim(); // Get the text value
let parts = originalDate.split('-'); // Split into [YYYY, MM, DD]
if (parts.length === 3) {
let formattedDate = `${parts[2]}-${parts[1]}-${parts[0]}`; // Rearrange to DD-MM-YYYY
firstTd.text(formattedDate); // Update the cell value
}
// Apply left alignment to the date column
firstTd.css("text-align", "left");
if (parts.length === 3) {
let formattedDate = `${parts[2]}-${parts[1]}-${parts[0]}`;
td.text(formattedDate);
}
td.css("text-align", "left");
}.bind(this));
});
let ws = XLSX.utils.table_to_sheet(cloneTable);
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
// Set column width to 10 for all columns
let colCount = 0;
$(cloneTable).find('tr').each(function() {
let count = $(this).find('th, td').length;
if (count > colCount) colCount = count;
});
let wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 10 }); // Set width of 10 for all columns
}
ws['!cols'] = wscols;
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'powerStockDetailsTableId';
// Power Stock Table Export
document.getElementById('powerConsumptionExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'power_Consumption_details<?= $month ?>.xlsx');
})
exportTableToExcel('powerStockDetailsTableId', 'power_Consumption_details<?= $month ?>.xlsx', [0]);
});
})
});
</script>
<script>
document.addEventListener("keydown", function(event) {
@ -1692,4 +1892,117 @@ foreach ($period as $day) {
}, 200);
});
});
</script>
<script>
function showMessage(msg) {
let msgBox = document.getElementById("successMessage");
msgBox.innerText = msg; // Set API message
msgBox.style.display = "block";
// Hide message after 3 seconds
setTimeout(() => {
msgBox.style.display = "none";
}, 5000);
}
</script>
<script>
function calculateTotal(table,dataId,column) {
let columnTotal = 0;
let rows = table.querySelectorAll('tbody tr');
let machineId = dataId.split(' ')[1]??'';
rows.forEach(row => {
let date = row.querySelector('td:first-child').innerText.trim().split('-');
date = date[2] + "-" + date[1] + "-" + date[0]; // Convert to YYYY-MM-DD format
let cell = null;
if(machineId) {
cell = row.querySelector(`td.${column}[data-id="${date} ${machineId}"]`);
}else{
cell = row.querySelector(`td.${column}[data-id="${date}"]`);
console.log('inside machine id not present');
}
if (cell) {
let value = parseFloat(cell.innerText.trim()) || 0;
columnTotal += value ;
}
});
if(machineId) {
// Update the total cell in the footer
let footerColumn = table.querySelector(`tfoot tr td.${column}[data-id="footer ${machineId}"]`);
if (footerColumn) {
footerColumn.innerText = columnTotal == 0 ? " " : columnTotal.toFixed(2);
}
// let footerColumnOpeningUnits = table.querySelector(`tfoot tr td.openingUnits[data-id="footer ${machineId}`)??0;
// let footerColumnClosingUnits = table.querySelector(`tfoot tr td.closingUnits[data-id="footer ${machineId}`)??0;
// let footerColumnTotalUnits = table.querySelector(`tfoot tr td.totalUnits[data-id="footer ${machineId}`)??0;
// footerColumnTotalUnits.innerText = (
// parseFloat(footerColumnClosingUnits.innerText.trim())
// -
// parseFloat(footerColumnOpeningUnits.innerText.trim())
// ) ?? '';
}else{
// Update the total cell in the footer for TD
let footerColumn = table.querySelector(`tfoot tr td.${column}[data-id="footer ${column}"]`);
if (footerColumn) {
footerColumn.innerText = columnTotal == 0 ? " " : columnTotal.toFixed(2);
}
// let footerColumnOpeningTP = table.querySelector(`tfoot tr td.openingTP[data-id="footer openingTP`);
// let footerColumnFinalTP = table.querySelector(`tfoot tr td.finalTP[data-id="footer finalTP`);
// let footerColumnTotalReadingTP = table.querySelector(`tfoot tr td.totalReadingTP[data-id="footer totalReadingTP`)??0;
// let footerColumnTotalUnitsTP = table.querySelector(`tfoot tr td.totalUnitsTP[data-id="footer totalUnitsTP`);
// let footerColumnMdTP = table.querySelector(`tfoot tr td.mdTP[data-id="footer mdTP`);
// let footerColumnMfTP = table.querySelector(`tfoot tr td.mfTP[data-id="footer mfTP`);
// footerColumnTotalReadingTP.innerText = ( parseFloat(footerColumnFinalTP.innerText.trim())
// -
// parseFloat(footerColumnOpeningTP.innerText.trim())
// ) ?? '';
// footerColumnTotalUnitsTP.innerText = ( parseFloat(footerColumnTotalReadingTP.innerText.trim())
// * 60
// ) ?? '';
// footerColumnMfTP.innerText = ( parseFloat(footerColumnMdTP.innerText.trim())
// * 60
// ) ?? '';
}
}
</script>

View File

@ -325,6 +325,20 @@ foreach ($period as $day) {
<div class="card" id="fullscreenDiv">
<div class="card-body">
<div id="successMessage"
style="
display: none;
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: green;
color: white;
padding: 10px;
border-radius: 5px;
z-index: 1000;">
</div>
<form id="changeMonthForm" action="<?= base_url('resinStockDetails'); ?>" method="post">
@ -374,7 +388,7 @@ foreach ($period as $day) {
<i class="fa fa-download btn-lg mt-2"
title="Excel Download"
style="font-size: x-large; cursor:pointer; color: #0b7cba"
id="bagStockExport">
id="resinStockExport">
</i>
<i class="fe-maximize noti-icon btn-lg mt-2"
@ -660,6 +674,7 @@ foreach ($period as $day) {
'receipt' => 0,
'used' => 0,
'balanceStock' => 0,
'materialCode' => $resinStock['materialCode'],
];
}
@ -686,10 +701,14 @@ foreach ($period as $day) {
<?php foreach ($summary as $each) { ?>
<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>
<td class="celda_normal openingStock"
data-id="footer <?=$each['materialCode']?>"></td>
<td class="celda_normal receiptStock"
data-id="footer <?=$each['materialCode']?>"><?= $each['receipt'] == 0 ? " " : $each['receipt'] ?></td>
<td class="celda_normal usedStock"
data-id="footer <?=$each['materialCode']?>"><?= $each['used'] == 0 ? " " : $each['used'] ?></td>
<td class="celda_normal balanceStock"
data-id="footer <?=$each['materialCode']?>"></td>
<?php } ?>
@ -788,6 +807,31 @@ foreach ($period as $day) {
<?php } ?>
</tr>
<?php } ?>
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<?php foreach ($resinMaterials as $each) { ?>
<td class="celda_normal openingStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal receiptStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal usedStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal balanceStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<?php } ?>
</tr>
</tfoot>
<?php } ?>
@ -901,9 +945,8 @@ foreach ($period as $day) {
var updateResinStockDetails = tableToJson();
alert('Updation may take a while, And we appreciate your patience..!!');
showMessage('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updateResinStockDetails
@ -913,10 +956,9 @@ foreach ($period as $day) {
success: function(data) {
if (data) {
$('#loader').hide();
console.log(data);
alert(data);
window.location.reload();
showMessage(data);
}
},
@ -928,7 +970,7 @@ foreach ($period as $day) {
console.error("Response Text:", xhr.responseText);
},
complete: function() {
$('#loader').hide();
console.log("Ajax request is completed..!!")
}
});
@ -976,6 +1018,14 @@ foreach ($period as $day) {
function openingStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id');
let [date, materialCode] = tdElement.getAttribute('data-id').split(' ');
let openingStock = validateInput(tdElement.innerText);
@ -984,7 +1034,16 @@ foreach ($period as $day) {
let currentBalanceStock = validateInput((Number(openingStock) + Number(receiptStock)) - Number(usedStock));
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
updateStockValue(date, materialCode, currentBalanceStock)
updateStockValue(date, materialCode, currentBalanceStock);
let table = document.getElementById('resinStockDetailsTableId');
let column1 = 'receiptStock';
let column2 = 'usedStock';
calculateTotal(table, dataId, column1);
calculateTotal(table, dataId, column2);
} catch (error) {
@ -996,6 +1055,12 @@ foreach ($period as $day) {
function receiptStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
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);
@ -1004,7 +1069,17 @@ foreach ($period as $day) {
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
updateStockValue(date, materialCode, currentBalanceStock)
updateStockValue(date, materialCode, currentBalanceStock);
let table = document.getElementById('resinStockDetailsTableId');
let column1 = 'receiptStock';
let column2 = 'usedStock';
calculateTotal(table, dataId, column1);
calculateTotal(table, dataId, column2);
} catch (error) {
@ -1019,6 +1094,14 @@ foreach ($period as $day) {
function usedStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
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);
@ -1027,7 +1110,16 @@ foreach ($period as $day) {
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
updateStockValue(date, materialCode, currentBalanceStock)
updateStockValue(date, materialCode, currentBalanceStock);
let table = document.getElementById('resinStockDetailsTableId');
let column1 = 'receiptStock';
let column2 = 'usedStock';
calculateTotal(table, dataId, column1);
calculateTotal(table, dataId, column2);
} catch (error) {
@ -1059,6 +1151,16 @@ foreach ($period as $day) {
return input;
}
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
</script>
<script>
@ -1134,7 +1236,21 @@ foreach ($period as $day) {
});
let ws = XLSX.utils.table_to_sheet(cloneTable); // Convert modified table to sheet
let ws = XLSX.utils.table_to_sheet(cloneTable);
// Set column width to 10 for all columns
let colCount = 0;
$(cloneTable).find('tr').each(function() {
let count = $(this).find('th, td').length;
if (count > colCount) colCount = count;
});
let wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 10 }); // Set width of 10 for all columns
}
ws['!cols'] = wscols;
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
@ -1164,6 +1280,7 @@ foreach ($period as $day) {
let table = activeElement.closest("table");
if (table && cell) {
event.preventDefault(); // Prevent form submission
let columnIndex = cell.cellIndex; // Get the current column index
@ -1384,4 +1501,70 @@ foreach ($period as $day) {
}, 200);
});
});
</script>
<script>
function showMessage(msg) {
let msgBox = document.getElementById("successMessage");
msgBox.innerText = msg; // Set API message
msgBox.style.display = "block";
// Hide message after 3 seconds
setTimeout(() => {
msgBox.style.display = "none";
}, 5000);
}
</script>
<script>
function calculateTotal(table,dataId,column) {
let columnTotal = 0;
let rows = table.querySelectorAll('tbody tr');
let materialCode = dataId.split(' ')[1];
rows.forEach(row => {
let date = row.querySelector('td:first-child').innerText.trim().split('-');
date = date[2] + "-" + date[1] + "-" + date[0]; // Convert to YYYY-MM-DD format
let cell = row.querySelector(`td.${column}[data-id="${date} ${materialCode}"]`);
if (cell) {
let value = parseFloat(cell.innerText.trim()) || 0;
columnTotal += value;
}
});
// Update the total cell in the footer
let footerColumn = table.querySelector(`tfoot tr td.${column}[data-id="footer ${materialCode}"]`);
if (footerColumn) {
footerColumn.innerText = columnTotal == 0 ? " " : columnTotal.toFixed(2); // Set the total value in the footer cell
}
// let footerColumnOpeningStock = table.querySelector(`tfoot tr td.openingStock[data-id="footer ${materialCode}`)??0;
// let footerColumnReceiptStock = table.querySelector(`tfoot tr td.receiptStock[data-id="footer ${materialCode}`)??0;
// let footerColumnUsedStock = table.querySelector(`tfoot tr td.usedStock[data-id="footer ${materialCode}`)??0;
// let footerColumnBalanceStock = table.querySelector(`tfoot tr td.balanceStock[data-id="footer ${materialCode}`);
// footerColumnBalanceStock.innerText = ( parseFloat(footerColumnOpeningStock.innerText.trim())
// +
// parseFloat(footerColumnReceiptStock.innerText.trim())
// )
// -
// parseFloat(footerColumnUsedStock.innerText.trim()) ;
}
</script>

File diff suppressed because it is too large Load Diff

View File

@ -319,76 +319,92 @@
<div class="card" id="fullscreenDiv">
<div class="card-body">
<form align="center" id="changeMonthForm" action="<?= base_url('trpSandUseStockDetails'); ?>" method="post">
<div class="row">
<?php $today = date('M-Y'); ?>
<div class="col-3">
<div class="header">
<div id="successMessage"
style="
display: none;
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
background: green;
color: white;
padding: 10px;
border-radius: 5px;
z-index: 1000;">
</div>
<div class="col-2 mt-2 ml-4">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control "
data-provide="datepicker"
data-date-format="M-yyyy"
data-date-min-view-mode="1" readonly
style="max-width: 175px;">
<div>
</div>
<div align="center">
<form style="width: 750px;" id="changeMonthForm" action="<?= base_url('trpSandUseStockDetails'); ?>" method="post">
<div class="row">
<?php $today = date('M-Y'); ?>
<div class="col-3 text-right d-flex" style="justify-content: end;">
<div class="col-3 mt-2">
<input type="text" id="searchInput" placeholder="Search..."
class="mt-2"
style="padding: 8px;margin-bottom: 10px;width: 150px;border: 2px solid rgb(123, 11, 214);
border-radius: 5px;margin-right:15px;">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control "
data-provide="datepicker"
data-date-format="M-yyyy"
data-date-min-view-mode="1" readonly
style="max-width: 175px;">
<i class="fa fa-table btn-lg mt-2"
title="Date Range Filter"
style="font-size: x-large; cursor:pointer; color:rgb(95, 102, 105)"
data-toggle="modal"
data-target="#filterModalId">
</i>
<i class="fa fa-download btn-lg mt-2"
title="Excel Download"
style="font-size: x-large; cursor:pointer; color: #0b7cba"
id="trpSandUseStockExport">
</i>
<i class="fe-maximize noti-icon btn-lg mt-2"
title="Full Screen"
style="font-size: x-large; cursor:pointer; color:rgb(241, 9, 136)"
onclick="toggleDivFullscreen()">
</i>
<i class="fa fa-save btn-lg mt-2"
title="Save"
style="font-size: x-large; cursor:pointer; color:rgb(31, 132, 3)"
id="saveId">
</i>
</div>
<div class="col-9 text-right d-flex" style="justify-content: end;">
<input type="text" id="searchInput" placeholder="Search..."
class="mt-2"
style="padding: 8px;margin-bottom: 10px;width: 150px;border: 2px solid rgb(123, 11, 214);
border-radius: 5px;margin-right:15px;">
<i class="fa fa-table btn-lg mt-2"
title="Date Range Filter"
style="font-size: x-large; cursor:pointer; color:rgb(95, 102, 105)"
data-toggle="modal"
data-target="#filterModalId">
</i>
<i class="fa fa-download btn-lg mt-2"
title="Excel Download"
style="font-size: x-large; cursor:pointer; color: #0b7cba"
id="trpSandUseStockExport">
</i>
<i class="fe-maximize noti-icon btn-lg mt-2"
title="Full Screen"
style="font-size: x-large; cursor:pointer; color:rgb(241, 9, 136)"
onclick="toggleDivFullscreen()">
</i>
<i class="fa fa-save btn-lg mt-2"
title="Save"
style="font-size: x-large; cursor:pointer; color:rgb(31, 132, 3)"
id="saveId">
</i>
</div>
</div>
</form>
</div>
<div class="col-4">
</div>
</div>
</div>
</form>
<!-- filter modal -->
<!-- filter modal -->
<div class="modal fade" id="filterModalId" tabindex="-1" role="dialog" aria-labelledby="filterModalLabelId" aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content">
@ -462,17 +478,14 @@
</div>
<!-- end modal section -->
<!-- end modal section -->
<div class="table-responsive" id="table-responsive" align="center">
<table style="width: 700px;" id="trpSandUseStockDetailsTableId" class="fht-table ">
<thead class="celda_encabezado_general">
<tr>
<th class="celda_encabezado_general" colspan="5">Trp Sand To Use Coating Sand </th>
<th class="celda_encabezado_general" colspan="5">TRP SAND TO USE COATING SAND </th>
</tr>
<tr>
@ -559,9 +572,9 @@
<b> Total </b>
</td>
<td class="celda_normal "><b><?= $summary['rough_kgs'] ?></b></td>
<td class="celda_normal "><b><?= $summary['fine_kgs'] ?></b></td>
<td class="celda_normal "><b><?= $summary['total_kgs'] ?></b></td>
<td class="celda_normal rough"><b><?= $summary['rough_kgs'] ?></b></td>
<td class="celda_normal fine"><b><?= $summary['fine_kgs'] ?></b></td>
<td class="celda_normal total"><b><?= $summary['total_kgs'] ?></b></td>
<td class="celda_normal "> </td>
</tr>
@ -575,75 +588,95 @@
<?php } else {
<?php } else {
$date = DateTime::createFromFormat('M-Y', $month);
$date = DateTime::createFromFormat('M-Y', $month);
$startDate = $date->modify('first day of this month')->format('Y-m-d');
$endDate = $date->modify('last day of this month')->format('Y-m-d');
$startDate = $date->modify('first day of this month')->format('Y-m-d');
$endDate = $date->modify('last day of this month')->format('Y-m-d');
$datesInMonth = [];
$datesInMonth = [];
$period = new DatePeriod(
new DateTime($startDate),
new DateInterval('P1D'),
(new DateTime($endDate))->modify('+1 day')
);
$period = new DatePeriod(
new DateTime($startDate),
new DateInterval('P1D'),
(new DateTime($endDate))->modify('+1 day')
);
foreach ($period as $day) {
$datesInMonth[] = $day->format('Y-m-d');
}
foreach ($period as $day) {
$datesInMonth[] = $day->format('Y-m-d');
}
foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
?>
<tr
<?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = date("d-m-Y", strtotime($dateInMonth));
if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"';
}
?>>
foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
?>
<tr
<?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = date("d-m-Y", strtotime($dateInMonth));
if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"';
}
?>>
<!-- td:eq(0) -->
<td class="celda_normal">
<?php
echo date("d-m-Y", strtotime($dateInMonth));
?>
</td>
<!-- td:eq(0) -->
<td class="celda_normal">
<?php
echo date("d-m-Y", strtotime($dateInMonth));
?>
</td>
<!-- td:eq(1) -->
<td class="celda_normal rough"
data-id="<?= $dateInMonth ?>"
oninput="roughStockChange(this)"
contenteditable="true"><?= " " ?></td>
<!-- td:eq(1) -->
<td class="celda_normal rough"
data-id="<?= $dateInMonth ?>"
oninput="roughStockChange(this)"
contenteditable="true"><?= " " ?></td>
<!-- td:eq(2) -->
<td class="celda_normal fine"
data-id="<?= $dateInMonth ?>"
oninput="fineStockChange(this)"
contenteditable="true"><?= " " ?></td>
<!-- td:eq(2) -->
<td class="celda_normal fine"
data-id="<?= $dateInMonth ?>"
oninput="fineStockChange(this)"
contenteditable="true"><?= " " ?></td>
<!-- td:eq(3) -->
<td class="celda_normal total"
data-id="<?= $dateInMonth ?>"><?= " " ?></td>
<!-- td:eq(3) -->
<td class="celda_normal total"
data-id="<?= $dateInMonth ?>"><?= " " ?></td>
<!-- td:eq(4) -->
<td class="celda_normal customer"
data-id="<?= $dateInMonth ?>"
contenteditable="true"><?= " " ?></td>
<!-- td:eq(4) -->
<td class="celda_normal customer"
data-id="<?= $dateInMonth ?>"
contenteditable="true"><?= " " ?></td>
<!-- td:eq(5) -->
<td style="display:none"
data-id="<?= $dateInMonth ?>"
contenteditable="true"><?= " " ?></td>
<!-- td:eq(5) -->
<td style="display:none"
data-id="<?= $dateInMonth ?>"
contenteditable="true"><?= " " ?></td>
</tr>
<?php
}
}
?>
</tr>
<?php
}?>
<tfoot>
<tr class="total_row">
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<td class="celda_normal rough">0</td>
<td class="celda_normal fine">0</td>
<td class="celda_normal total">0</b></td>
<td class="celda_normal ">0</td>
</tr>
</tfoot>
<?php
}
?>
</tbody>
</table>
@ -728,9 +761,8 @@
var updateTrpSandUseStockDetails = tableToJson();
alert('Updation may take a while, And we appreciate your patience..!!');
showMessage('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updateTrpSandUseStockDetails
@ -740,22 +772,19 @@
success: function(data) {
if (data) {
$('#loader').hide();
console.log(data);
alert(data);
window.location.reload();
showMessage(data);
}
},
error: function(xhr, status, error) {
alert("An error occurred while processing the request. Please try again.");
showMessage("An error occurred while processing the request. Please try again.");
console.error("Error Code:", xhr.status);
console.error("Error Message:", error);
console.error("Response Text:", xhr.responseText);
},
complete: function() {
$('#loader').hide();
console.log("Request completed.");
}
});
@ -795,6 +824,14 @@
function roughStockChange(tdElement) {
try {
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
console.log("just an alert from RoughStockChange..!!")
console.log(tdElement.innerText)
let dataId = tdElement.getAttribute('data-id')
@ -803,6 +840,10 @@
let total = (Number(roughStock) + Number(fineStock));
document.querySelector(`td.total[data-id="${dataId}"]`).innerText = total == 0 ? " " : total;
let table = document.getElementById('trpSandUseStockDetailsTableId');
let column = 'rough';
calculateTotal(table,dataId,column);
} catch (error) {
console.error("There is an error updating stock ..!!" + error);
@ -812,14 +853,24 @@
function fineStockChange(tdElement) {
try {
console.log("just an alert from fineStockChange..!!")
console.log(tdElement.innerText)
let basicCheck =checkIsNumber(tdElement.innerText.trim());
if(basicCheck == 0){
alert("Kindly Enter Numbers only..!!");
return ;
}
let dataId = tdElement.getAttribute('data-id')
let roughStock = validateInput(document.querySelector(`td.rough[data-id="${dataId}"]`).innerText);
let fineStock = validateInput(tdElement.innerText);
let total = (Number(roughStock) + Number(fineStock));
document.querySelector(`td.total[data-id="${dataId}"]`).innerText = total == 0 ? " " : total;
let table = document.getElementById('trpSandUseStockDetailsTableId');
let column = 'fine';
calculateTotal(table,dataId,column);
} catch (error) {
console.error("There is an error updating stock ..!!" + error);
@ -851,6 +902,17 @@
return input;
}
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
</script>
@ -896,7 +958,21 @@
});
let ws = XLSX.utils.table_to_sheet(cloneTable); // Convert modified table to sheet
let ws = XLSX.utils.table_to_sheet(cloneTable);
// Set column width to 10 for all columns
let colCount = 0;
$(cloneTable).find('tr').each(function() {
let count = $(this).find('th, td').length;
if (count > colCount) colCount = count;
});
let wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 10 }); // Set width of 10 for all columns
}
ws['!cols'] = wscols;
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
@ -1058,3 +1134,49 @@
});
</script>
<script>
function showMessage(msg) {
let msgBox = document.getElementById("successMessage");
msgBox.innerText = msg; // Set API message
msgBox.style.display = "block";
// Hide message after 3 seconds
setTimeout(() => {
msgBox.style.display = "none";
}, 5000);
}
</script>
<script>
function calculateTotal(table,dataId,column) {
let columnTotal = 0;
let rows = table.querySelectorAll('tbody tr');
rows.forEach(row => {
let cell = row.querySelector(`td.${column}`);
if (cell) {
let value = parseFloat(cell.innerText.trim()) || 0;
columnTotal += value;
}
});
// Update the total cell in the footer
let footerColumn = table.querySelector(`tfoot tr td.${column}`);
if (footerColumn) {
footerColumn.innerText = columnTotal == 0 ? " " : columnTotal.toFixed(2); // Format to 2 decimal places
}
let footerColumnTotal = table.querySelector(`tfoot tr td.total`);
let footerColumnRough = table.querySelector(`tfoot tr td.rough`);
let footerColumnFine = table.querySelector(`tfoot tr td.fine`);
footerColumnTotal.innerText = parseFloat(footerColumnRough.innerText.trim())
+
parseFloat(footerColumnFine.innerText.trim()) ;
}
</script>