Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme
This commit is contained in:
commit
d9ee3ac144
@ -588,25 +588,62 @@ class StockController extends BaseController
|
|||||||
$data['endDate'] = $monthData[count($monthData)-1]['database'];
|
$data['endDate'] = $monthData[count($monthData)-1]['database'];
|
||||||
$data['datefordropdown'] = $currentMonth;
|
$data['datefordropdown'] = $currentMonth;
|
||||||
|
|
||||||
|
//Machine Details
|
||||||
$data['machineDetails'] = $this->factoryMachine_model->where('energy_type', 'diesel')->where('is_active', 1)->findAll();
|
$data['machineDetails'] = $this->factoryMachine_model->where('energy_type', 'diesel')->where('is_active', 1)->findAll();
|
||||||
|
if(!count([$data['machineDetails']]))
|
||||||
$data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model
|
|
||||||
->where('date >=', $data['startDate'])
|
|
||||||
->where('date <=', $data['endDate'])
|
|
||||||
->findAll();
|
|
||||||
if(!count($data['summaryDetails']))
|
|
||||||
{
|
{
|
||||||
|
return $this->response->setBody("<script>alert('No Machine data available');</script>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Diesel Stock Summary Details
|
||||||
|
$data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model->select('date,opening_stock as opening_stock_0,purchase_diesel as purchase_diesel_0,total_filling_diesel as total_filling_diesel_0,balance_stock as balance_stock_0')->where('date >=', $data['startDate'])->where('date <=', $data['endDate'])->findAll();
|
||||||
|
if(!count($data['summaryDetails']))
|
||||||
|
{
|
||||||
|
//insert empty data
|
||||||
|
$tempInsert = [];
|
||||||
|
foreach ($monthData as $key => $value) {
|
||||||
|
array_push($tempInsert,[ 'date'=>$value['database'] ]);
|
||||||
|
}
|
||||||
|
$this->factoryVehicleDieselStockSummary_model->insertBatch($tempInsert);
|
||||||
|
|
||||||
|
$data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model->where('date >=', $data['startDate'])->where('date <=', $data['endDate'])->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Diesel Consumption Details
|
||||||
$data['dieselConsumptionDetails'] = $this->getDieselConsumptionPivot($data['machineDetails'] , $data['startDate'] , $data['endDate']);
|
$data['dieselConsumptionDetails'] = $this->getDieselConsumptionPivot($data['machineDetails'] , $data['startDate'] , $data['endDate']);
|
||||||
|
if(!count($data['dieselConsumptionDetails']))
|
||||||
|
{
|
||||||
|
//insert empty data
|
||||||
|
$tempInsert = [];
|
||||||
|
foreach ($monthData as $key => $value) {
|
||||||
|
array_push($tempInsert,['date'=>$value['database'] , 'machine_id'=>$data['machineDetails'][0]['id'] ]);
|
||||||
|
}
|
||||||
|
$this->factoryVehicleDieselDetails_model->insertBatch($tempInsert);
|
||||||
|
|
||||||
|
$data['dieselConsumptionDetails'] = $this->getDieselConsumptionPivot($data['machineDetails'] , $data['startDate'] , $data['endDate']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$mergedArray = [];
|
||||||
|
|
||||||
|
// Loop through the first array
|
||||||
|
foreach ($data['summaryDetails'] as $item1) {
|
||||||
|
$date = $item1["date"];
|
||||||
|
|
||||||
|
// Find the matching item in the second array by date
|
||||||
|
foreach ($data['dieselConsumptionDetails'] as $item2) {
|
||||||
|
if ($item2["date"] === $date) {
|
||||||
|
// Merge the two arrays
|
||||||
|
$mergedArray[] = array_merge($item1, $item2);
|
||||||
|
break; // Stop once the matching date is found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data['dieselConsumptionDetails'] = $mergedArray;
|
||||||
|
|
||||||
$data['machineName'] = array_column($data['machineDetails'], 'machine_name');
|
$data['machineName'] = array_column($data['machineDetails'], 'machine_name');
|
||||||
|
|
||||||
$this->global['pageTitle'] = 'Drier Details';
|
$this->global['pageTitle'] = 'Drier Details';
|
||||||
// this is a code that i want to see in $this->global aiyo pakurane ena nu solrathu
|
|
||||||
|
|
||||||
|
|
||||||
$this->loadViews("factoryDieselMachineDetails", $this->global, $data, NULL);
|
$this->loadViews("factoryDieselMachineDetails", $this->global, $data, NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -638,5 +675,65 @@ class StockController extends BaseController
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addOrEditfactoryVehicleDieselDetails()
|
||||||
|
{
|
||||||
|
$dieselMachineTableData = json_decode($this->request->getPost('dieselMachineTableData'), true);
|
||||||
|
|
||||||
|
$transformedData = [];
|
||||||
|
foreach ($dieselMachineTableData as $entry) {
|
||||||
|
$date = $entry['date'];
|
||||||
|
|
||||||
|
foreach ($entry as $key => $value) {
|
||||||
|
|
||||||
|
if ($key === 'date') { continue; }
|
||||||
|
|
||||||
|
preg_match('/(.*?)_(\d+)$/', $key, $matches);
|
||||||
|
|
||||||
|
if (count($matches) === 3) {
|
||||||
|
$field = $matches[1];
|
||||||
|
$machineId = $matches[2];
|
||||||
|
|
||||||
|
$insertKey = "{$date}_{$machineId}";
|
||||||
|
if (!isset($transformedData[$insertKey])) {
|
||||||
|
$transformedData[$insertKey] = [
|
||||||
|
'date' => DateTime::createFromFormat('d-m-Y', $date)->format('Y-m-d'),
|
||||||
|
'machine_id' => $machineId,
|
||||||
|
'opening_reading' => 0.00,
|
||||||
|
'closing_reading' => 0.00,
|
||||||
|
'filling_diesel' => 0.00,
|
||||||
|
'consumption' => 0.00,
|
||||||
|
'running_hours' => 0.00,
|
||||||
|
'mileage' => 0.00,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$transformedData[$insertKey][$field] = (float) $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($transformedData as $row) {
|
||||||
|
|
||||||
|
|
||||||
|
// Check if a row with the same date already exists
|
||||||
|
$existingRow = $this->factoryVehicleDieselDetails_model->where('date', $row['date'])->where('machine_id', $row['machine_id'])->first();
|
||||||
|
|
||||||
|
|
||||||
|
if ($existingRow) {
|
||||||
|
// If exists, update the row
|
||||||
|
$this->factoryVehicleDieselDetails_model->update($existingRow['id'], $row);
|
||||||
|
} else {
|
||||||
|
// If not, insert a new row
|
||||||
|
$this->factoryVehicleDieselDetails_model->insert($row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo "Data successfully saved.";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,9 +11,9 @@ class FactoryVehicleDieselStockSummaryModel extends Model
|
|||||||
|
|
||||||
protected $allowedFields = [
|
protected $allowedFields = [
|
||||||
'date',
|
'date',
|
||||||
'opening',
|
'opening_stock',
|
||||||
'purchase_diesel',
|
'purchase_diesel',
|
||||||
'filling_diesel',
|
'total_filling_diesel',
|
||||||
'balance_stock'
|
'balance_stock'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -177,6 +177,21 @@ $currentday = date('d');
|
|||||||
.modal {
|
.modal {
|
||||||
padding-right: 30% ! important;
|
padding-right: 30% ! important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* .fht-table th:nth-child(1),
|
||||||
|
.fht-table td:nth-child(1),
|
||||||
|
.fht-table th:nth-child(2),
|
||||||
|
.fht-table td:nth-child(2),
|
||||||
|
.fht-table th:nth-child(3),
|
||||||
|
.fht-table td:nth-child(3)
|
||||||
|
{
|
||||||
|
position: sticky;
|
||||||
|
left: 0;
|
||||||
|
background-color: #00a65a;
|
||||||
|
z-index: 2;
|
||||||
|
border-right: 2px solid #ddd;
|
||||||
|
color: #ffffff;
|
||||||
|
} */
|
||||||
</style>
|
</style>
|
||||||
<div class="content-page">
|
<div class="content-page">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|||||||
@ -1,176 +1,228 @@
|
|||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
$datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
||||||
?>
|
?>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.num {
|
.num {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.fht-table,
|
.fht-table,
|
||||||
.fht-table thead,
|
.fht-table thead,
|
||||||
.fht-table tfoot,
|
.fht-table tfoot,
|
||||||
.fht-table tbody,
|
.fht-table tbody,
|
||||||
.fht-table tr,
|
.fht-table tr,
|
||||||
.fht-table th,
|
.fht-table th,
|
||||||
.fht-table td {
|
.fht-table td {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-table td {
|
.fht-table td {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-table td:hover {
|
.fht-table td:hover {
|
||||||
background-color: #41a1c8;
|
background-color: #41a1c8;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-table {
|
.fht-table {
|
||||||
border: 0 none;
|
border: 0 none;
|
||||||
height: auto;
|
height: auto;
|
||||||
width: auto;
|
width: auto;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
/*table-layout: fixed; Algoritmo de distribucion fijo */
|
/*table-layout: fixed; Algoritmo de distribucion fijo */
|
||||||
white-space:nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-table th,
|
.fht-table th,
|
||||||
.fht-table td {
|
.fht-table td {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-table-wrapper,
|
.fht-table-wrapper,
|
||||||
.fht-table-wrapper .fht-thead,
|
.fht-table-wrapper .fht-thead,
|
||||||
.fht-table-wrapper .fht-tfoot,
|
.fht-table-wrapper .fht-tfoot,
|
||||||
.fht-table-wrapper .fht-fixed-column .fht-tbody,
|
.fht-table-wrapper .fht-fixed-column .fht-tbody,
|
||||||
.fht-table-wrapper .fht-fixed-body .fht-tbody,
|
.fht-table-wrapper .fht-fixed-body .fht-tbody,
|
||||||
.fht-table-wrapper .fht-tbody {
|
.fht-table-wrapper .fht-tbody {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-table-wrapper .fht-fixed-body .fht-tbody,
|
.fht-table-wrapper .fht-fixed-body .fht-tbody,
|
||||||
.fht-table-wrapper .fht-tbody {
|
.fht-table-wrapper .fht-tbody {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-table-wrapper .fht-table .fht-cell {
|
.fht-table-wrapper .fht-table .fht-cell {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-table-wrapper .fht-fixed-column,
|
.fht-table-wrapper .fht-fixed-column,
|
||||||
.fht-table-wrapper .fht-fixed-body {
|
.fht-table-wrapper .fht-fixed-body {
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-table-wrapper .fht-fixed-column {
|
.fht-table-wrapper .fht-fixed-column {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fht-fixed-body .fht-thead table {
|
.fht-fixed-body .fht-thead table {
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
border: 0 none;
|
border: 0 none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*For Examples*/
|
/*For Examples*/
|
||||||
|
|
||||||
.ContenedorTabla {
|
.ContenedorTabla {
|
||||||
height: 500px;
|
height: 500px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
width: auto;
|
width: auto;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header,
|
.header,
|
||||||
.main {
|
.main {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: auto;
|
height: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.titulosHeader {
|
.titulosHeader {
|
||||||
border-bottom: 1px solid #e8bb25;
|
border-bottom: 1px solid #e8bb25;
|
||||||
height: auto;
|
height: auto;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.celda_encabezado_general {
|
.celda_encabezado_general {
|
||||||
background-color: #c45151f5;
|
background-color: #00a65a;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 2px 4px;
|
padding: 2px 4px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
._Separador {
|
._Separador {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
height: 12px;
|
height: 12px;
|
||||||
border-left: 1px solid #ccc;
|
border-left: 1px solid #ccc;
|
||||||
border-right: 1px solid #ccc;
|
border-right: 1px solid #ccc;
|
||||||
width: 7px;
|
width: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
._Separador div {
|
._Separador div {
|
||||||
width: 4px;
|
width: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.celda_normal {
|
.celda_normal {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
padding: 2px 4px;
|
padding: 2px 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*style excel*/
|
|
||||||
.excel_cell {
|
|
||||||
border: 1px solid #CCC;
|
|
||||||
color: #222;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: normal;
|
|
||||||
padding: 4px;
|
|
||||||
white-space: pre-line;
|
|
||||||
empty-cells: show;
|
|
||||||
}
|
|
||||||
|
|
||||||
._cell_header {
|
|
||||||
background-color: #EEE;
|
|
||||||
}
|
|
||||||
|
|
||||||
._cell_Default {
|
|
||||||
background-color: #FFF;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.excel_cell div {
|
|
||||||
width: 30px;
|
|
||||||
height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal {
|
|
||||||
padding-right: 30% ! important;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/*style excel*/
|
||||||
|
.excel_cell {
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
color: #222;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: normal;
|
||||||
|
padding: 4px;
|
||||||
|
white-space: pre-line;
|
||||||
|
empty-cells: show;
|
||||||
|
}
|
||||||
|
|
||||||
|
._cell_header {
|
||||||
|
background-color: #EEE;
|
||||||
|
}
|
||||||
|
|
||||||
|
._cell_Default {
|
||||||
|
background-color: #FFF;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.excel_cell div {
|
||||||
|
width: 30px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#dieselMachineTable th:nth-child(1),
|
||||||
|
#dieselMachineTable td:nth-child(1) {
|
||||||
|
position: sticky;
|
||||||
|
left: 0;
|
||||||
|
background-color: #00a65a;
|
||||||
|
z-index: 2;
|
||||||
|
border-right: 2px solid #ddd;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="myLargeModalLabel">Navigation Options</h4>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="row">
|
||||||
|
<!-- Machine Dropdown -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="machineDropdown">Select Machine</label>
|
||||||
|
<select id="machineDropdown" class="form-control">
|
||||||
|
<option value="">Select Machine</option>
|
||||||
|
<?php foreach ($machineName as $name): ?>
|
||||||
|
<option value="<?= $name; ?>"><?= $name; ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Date Dropdown -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="dateDropdown">Select Date</label>
|
||||||
|
<select id="dateDropdown" class="form-control">
|
||||||
|
<option value="01-11-2024">01-11-2024</option>
|
||||||
|
<option value="02-11-2024">02-11-2024</option>
|
||||||
|
<option value="10-11-2024">10-11-2024</option>
|
||||||
|
<option value="15-11-2024">15-11-2024</option>
|
||||||
|
<option value="25-11-2024">25-11-2024</option>
|
||||||
|
<option value="30-11-2024">30-11-2024</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary float-right" onclick="navigateToMachine()">Navigate</button>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="content-page">
|
<div class="content-page">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<!-- Start Content-->
|
<!-- Start Content-->
|
||||||
@ -180,11 +232,11 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<div class="page-title-box page-title-box-alt">
|
<div class="page-title-box page-title-box-alt">
|
||||||
<div class="page-title-right">
|
<div class="page-title-right">
|
||||||
<ol class="breadcrumb m-0">
|
<ol class="breadcrumb m-0">
|
||||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Stocks</a></li>
|
<li class="breadcrumb-item"><a href="javascript: void(0);">Stocks</a></li>
|
||||||
<li class="breadcrumb-item active">
|
<li class="breadcrumb-item active">
|
||||||
<h4 class="page-title">Diesel - Factory Vehicle Details</h4>
|
<h4 class="page-title">Diesel - Factory Vehicle Details</h4>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@ -201,6 +253,8 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
|
|
||||||
@ -208,21 +262,46 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<?php $today = date('M-Y'); ?>
|
<?php $today = date('M-Y'); ?>
|
||||||
<input type="text" name="month" id="month" value="<?php echo $datefordropdown; ?>" class="form-control" data-provide="datepicker" data-date-format="M-yyyy" data-date-min-view-mode="1">
|
<input type="text" name="month" id="month"
|
||||||
|
value="<?php echo $datefordropdown; ?>" class="form-control"
|
||||||
|
data-provide="datepicker" data-date-format="M-yyyy"
|
||||||
|
data-date-min-view-mode="1">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<input type="submit" value="Change Month" class="btn btn-success" style="margin-top:0px;">
|
<input type="submit" value="Change Month" class="btn btn-success"
|
||||||
|
style="margin-top:0px;">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-6">
|
||||||
|
<div class="dropdown float-right">
|
||||||
|
<a href="#" class="dropdown-toggle arrow-none" data-toggle="dropdown"
|
||||||
|
aria-expanded="false">
|
||||||
|
<i class="mdi mdi-dots-vertical m-0 text-muted h3"></i>
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
|
<a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a>
|
||||||
|
<a class="dropdown-item" href="#">Export</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Add table-responsive for horizontal scroll -->
|
|
||||||
<div class="table-responsive">
|
|
||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Add table-responsive for horizontal scroll -->
|
||||||
|
<div class="table-responsive">
|
||||||
|
<?php
|
||||||
$columns = array_keys($dieselConsumptionDetails[0]);
|
$columns = array_keys($dieselConsumptionDetails[0]);
|
||||||
|
|
||||||
function formatHeader($key)
|
function formatHeader($key)
|
||||||
@ -232,55 +311,92 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
|||||||
return ucwords(implode(' ', $parts));
|
return ucwords(implode(' ', $parts));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<table id="drierTable" class="fht-table table-striped" style="font-size: small;">
|
<table id="dieselMachineTable" class="fht-table table-striped"
|
||||||
|
style="font-size: small;">
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="celda_encabezado_general" style="padding: 10px;"></th>
|
<th class="celda_encabezado_general" style="padding: 10px;"></th>
|
||||||
<?php foreach ($machineName as $name): ?>
|
<th class="celda_encabezado_general" colspan="4" style="padding: 10px;">
|
||||||
<th class="celda_encabezado_general" colspan="6" style="padding: 10px;"><?= $name; ?></th>
|
Total Diesel</th>
|
||||||
<?php endforeach; ?>
|
<?php foreach ($machineName as $name): ?>
|
||||||
</tr>
|
<th class="celda_encabezado_general" colspan="6" data-id="<?= $name; ?>"
|
||||||
</thead>
|
style="padding: 10px;"><?= $name; ?></th>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach ($columns as $column): ?>
|
<?php foreach ($columns as $column): ?>
|
||||||
<th class="celda_encabezado_general" style="padding: 10px;"><?= formatHeader($column) ?></th>
|
<th class="celda_encabezado_general" style="padding: 10px;"
|
||||||
<?php endforeach; ?>
|
id="<?= $column ?>"><?= formatHeader($column) ?></th>
|
||||||
</tr>
|
<?php endforeach; ?>
|
||||||
</thead>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($dieselConsumptionDetails as $row): ?>
|
<?php foreach ($dieselConsumptionDetails as $key => $row): ?>
|
||||||
<tr>
|
<tr id="<?php echo $key + 1; ?>">
|
||||||
<?php foreach ($columns as $index => $column): ?>
|
<?php foreach ($columns as $index => $column): ?>
|
||||||
|
|
||||||
<?php if($index == 0) : ?>
|
<?php if($index == 0) : ?>
|
||||||
<td class="celda_normal" style="padding: 5px;" ><?php echo DateTime::createFromFormat('Y-m-d', $row[$column])->format('d-m-Y'); ?></td>
|
<td class="celda_normal" style="padding: 5px;">
|
||||||
|
<?php echo DateTime::createFromFormat('Y-m-d', $row[$column])->format('d-m-Y'); ?>
|
||||||
|
</td>
|
||||||
|
<?php elseif(formatHeader($column) == 'Opening Reading'): ?>
|
||||||
|
<td class="celda_normal"
|
||||||
|
<?= ($key == 0) ? 'contenteditable="true"' : ''; ?>
|
||||||
|
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||||
|
<?php elseif(formatHeader($column) == 'Closing Reading'): ?>
|
||||||
|
<td class="celda_normal" contenteditable="true"
|
||||||
|
onkeyup="calculateRunningHrs(this.parentNode.id,this.textContent);"
|
||||||
|
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||||
|
<?php elseif(formatHeader($column) == 'Filling Diesel'): ?>
|
||||||
|
<td class="celda_normal" contenteditable="true"
|
||||||
|
onkeyup="calculateTotalFillingDiesel(this.parentNode.id,this.textContent);"
|
||||||
|
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||||
|
<?php elseif(formatHeader($column) == 'Consumption'): ?>
|
||||||
|
<td class="celda_normal" contenteditable="true"
|
||||||
|
onkeyup="calculateMileage(this.parentNode.id,this.textContent);"
|
||||||
|
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||||
|
<?php elseif(formatHeader($column) == 'Running Hours'): ?>
|
||||||
|
<td class="celda_normal" style="padding: 5px;">
|
||||||
|
<?= $row[$column] ?? 'N/A' ?></td>
|
||||||
|
<?php elseif(formatHeader($column) == 'Mileage'): ?>
|
||||||
|
<td class="celda_normal" style="padding: 5px;">
|
||||||
|
<?= $row[$column] ?? 'N/A' ?></td>
|
||||||
|
<?php elseif(formatHeader($column) == 'Opening Stock'): ?>
|
||||||
|
<td class="celda_normal"
|
||||||
|
<?= ($key == 0) ? 'contenteditable="true"' : ''; ?>
|
||||||
|
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||||
|
<?php elseif(formatHeader($column) == 'Purchase Diesel'): ?>
|
||||||
|
<td class="celda_normal" contenteditable="true"
|
||||||
|
onkeyup="calculateBalanceStock(this.parentNode.id,this.textContent);"
|
||||||
|
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<td class="celda_normal" contenteditable="true" style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
<td class="celda_normal" style="padding: 5px;">
|
||||||
|
<?= $row[$column] ?? 'N/A' ?></td>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</tr>
|
</tbody>
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
</div><!-- End table-responsive -->
|
</div><!-- End table-responsive -->
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 text-right">
|
<div class="col-md-12 text-right">
|
||||||
<input type="button" class="btn btn-success" id="save" value="save">
|
<input type="button" class="btn btn-success" id="save" value="save">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -301,49 +417,232 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
|||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#save').click(function() {
|
||||||
|
|
||||||
|
// Get headers from the second <thead> as keys
|
||||||
$(document).ready(function()
|
var headers = [];
|
||||||
{
|
$("#dieselMachineTable thead:nth-child(2) th").each(function() {
|
||||||
|
headers.push($(this).attr("id"));
|
||||||
$('.timeDropdown').select2({
|
|
||||||
placeholder: "Select a time",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#save').click(function() {
|
// Convert table to JSON using custom headers as keys
|
||||||
|
var tableData = [];
|
||||||
|
$("#dieselMachineTable tbody tr").each(function() {
|
||||||
|
var rowData = {};
|
||||||
|
$(this).find("td").each(function(index) {
|
||||||
|
var key = headers[index] || `column_${index}`;
|
||||||
|
rowData[key] = $(this).text().trim();
|
||||||
|
});
|
||||||
|
tableData.push(rowData);
|
||||||
|
});
|
||||||
|
|
||||||
var alldata = $("#drierTable").tableToJSON();
|
var jsonData = JSON.stringify(tableData);
|
||||||
|
|
||||||
|
|
||||||
alldata = JSON.stringify(alldata);
|
$('#loader').show();
|
||||||
|
$.ajax({
|
||||||
|
data: {
|
||||||
|
dieselMachineTableData: jsonData,
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
url: "<?php echo base_url() ?>/addOrEditfactoryVehicleDieselDetails",
|
||||||
|
|
||||||
$('#loader').show();
|
success: function(data) {
|
||||||
$.ajax({
|
if (data) {
|
||||||
data: {
|
|
||||||
drierData: alldata,
|
|
||||||
},
|
|
||||||
type: "POST",
|
|
||||||
url: "<?php echo base_url() ?>",
|
|
||||||
|
|
||||||
success: function(data) {
|
$('#loader').hide();
|
||||||
if (data) {
|
alert(data);
|
||||||
|
|
||||||
$('#loader').hide();
|
|
||||||
alert(data);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function openingReading(parentId, textContent) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function calculateRunningHrs(parentId, textContent) {
|
||||||
|
|
||||||
|
var tr = $('#' + parentId);
|
||||||
|
var currentTd = $(event.target);
|
||||||
|
var tdIndex = currentTd.index();
|
||||||
|
|
||||||
|
// runningHrs calculation
|
||||||
|
closingReading = currentTd.text();
|
||||||
|
openingReading = tr.find('td:eq(' + (tdIndex - 1) + ')').text();
|
||||||
|
runningHrs = closingReading - openingReading;
|
||||||
|
if (runningHrs != NaN && runningHrs != Infinity)
|
||||||
|
tr.find('td:eq(' + (tdIndex + 3) + ')').text(runningHrs.toFixed(2));
|
||||||
|
|
||||||
|
// mileage calculation
|
||||||
|
consumption = tr.find('td:eq(' + (tdIndex + 2) + ')').text();
|
||||||
|
runningHrs = runningHrs.toFixed(2);
|
||||||
|
mileage = consumption / runningHrs;
|
||||||
|
if (mileage != NaN && mileage != Infinity)
|
||||||
|
tr.find('td:eq(' + (tdIndex + 4) + ')').text(mileage.toFixed(2));
|
||||||
|
|
||||||
|
//next opening reading
|
||||||
|
nextTrIndex = parseInt(parentId, 10) + 1
|
||||||
|
var nexttr = $('#' + nextTrIndex);
|
||||||
|
nexttr.find('td:eq(' + (tdIndex - 1) + ')').text(textContent);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateMileage(parentId, textContent) {
|
||||||
|
|
||||||
|
var tr = $('#' + parentId);
|
||||||
|
var currentTd = $(event.target);
|
||||||
|
var tdIndex = currentTd.index();
|
||||||
|
|
||||||
|
// mileage calculation
|
||||||
|
consumption = currentTd.text();
|
||||||
|
runningHrs = tr.find('td:eq(' + (tdIndex + 1) + ')').text();
|
||||||
|
result = consumption / runningHrs;
|
||||||
|
if (result != NaN && result != Infinity)
|
||||||
|
tr.find('td:eq(' + (tdIndex + 2) + ')').text(result.toFixed(2));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function calculateTotalFillingDiesel(parentId, textContent) {
|
||||||
|
|
||||||
|
var tr = $('#' + parentId);
|
||||||
|
totalFillingDiesel = 0;
|
||||||
|
|
||||||
|
tr.children('td').each(function(index, td) {
|
||||||
|
|
||||||
|
var value = parseFloat($(td).text()) || 0;
|
||||||
|
|
||||||
|
// var headerText = $('table thead th').eq(index).text();
|
||||||
|
var headerText = $('table thead tr:eq(1) th').eq(index).text();
|
||||||
|
|
||||||
|
if (headerText == 'Filling Diesel') {
|
||||||
|
totalFillingDiesel += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
tr.find('td:eq(' + (3) + ')').text(totalFillingDiesel.toFixed(2));
|
||||||
|
|
||||||
|
// Balance Stock calculation
|
||||||
|
openingStock = tr.find('td:eq(' + (1) + ')').text();
|
||||||
|
purchaseDiesel = tr.find('td:eq(' + (2) + ')').text();
|
||||||
|
fillingDiesel = tr.find('td:eq(' + (3) + ')').text();
|
||||||
|
|
||||||
|
balanceStock = (parseFloat(openingStock) + parseFloat(purchaseDiesel)) - parseFloat(fillingDiesel);
|
||||||
|
if (balanceStock != NaN && balanceStock != Infinity)
|
||||||
|
tr.find('td:eq(' + (4) + ')').text(balanceStock.toFixed(2));
|
||||||
|
|
||||||
|
//next opening stock
|
||||||
|
nextTrIndex = parseInt(parentId, 10) + 1
|
||||||
|
var nexttr = $('#' + nextTrIndex);
|
||||||
|
nexttr.find('td:eq(' + (1) + ')').text(balanceStock.toFixed(2));
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateBalanceStock(parentId, textContent) {
|
||||||
|
|
||||||
|
var tr = $('#' + parentId);
|
||||||
|
var currentTd = $(event.target);
|
||||||
|
var tdIndex = currentTd.index();
|
||||||
|
|
||||||
|
// Balance Stock calculation
|
||||||
|
openingStock = tr.find('td:eq(' + (tdIndex - 1) + ')').text();
|
||||||
|
purchaseDiesel = currentTd.text();
|
||||||
|
fillingDiesel = tr.find('td:eq(' + (tdIndex + 1) + ')').text();
|
||||||
|
|
||||||
|
balanceStock = (parseFloat(openingStock) + parseFloat(purchaseDiesel)) - parseFloat(fillingDiesel);
|
||||||
|
if (balanceStock != NaN && balanceStock != Infinity)
|
||||||
|
tr.find('td:eq(' + (tdIndex + 2) + ')').text(balanceStock.toFixed(2));
|
||||||
|
|
||||||
|
//next opening stock
|
||||||
|
nextTrIndex = parseInt(parentId, 10) + 1
|
||||||
|
var nexttr = $('#' + nextTrIndex);
|
||||||
|
nexttr.find('td:eq(' + (1) + ')').text(balanceStock.toFixed(2));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function navigateToMachine() {
|
||||||
|
$('.close').click();
|
||||||
|
const machineDropdown = document.getElementById('machineDropdown');
|
||||||
|
const dateDropdown = document.getElementById('dateDropdown');
|
||||||
|
const selectedMachine = machineDropdown.value;
|
||||||
|
const selectedDate = dateDropdown.value;
|
||||||
|
|
||||||
|
const table = document.getElementById('dieselMachineTable');
|
||||||
|
const headerCells = table.querySelectorAll('thead tr:nth-child(1) th');
|
||||||
|
const rows = table.querySelectorAll('tbody tr');
|
||||||
|
|
||||||
|
let targetColumnIndex = -1;
|
||||||
|
headerCells.forEach((header, index) => {
|
||||||
|
if (header.getAttribute('data-id') === selectedMachine) {
|
||||||
|
targetColumnIndex = index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (targetColumnIndex === -1) {
|
||||||
|
console.log("Machine column not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let targetRow = null;
|
||||||
|
rows.forEach(row => {
|
||||||
|
const dateCell = row.querySelector('td:first-child');
|
||||||
|
if (dateCell && dateCell.textContent.trim() === selectedDate) {
|
||||||
|
targetRow = row;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!targetRow) {
|
||||||
|
console.log("Date row not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
targetColumnIndex = targetColumnIndex - 2;
|
||||||
|
targetColumnIndex = targetColumnIndex * 6;
|
||||||
|
targetColumnIndex = targetColumnIndex + 5;
|
||||||
|
|
||||||
|
targetRow.cells[targetColumnIndex].scrollIntoView({
|
||||||
|
behavior: 'smooth',
|
||||||
|
inline: 'center',
|
||||||
|
block: 'center'
|
||||||
|
});
|
||||||
|
|
||||||
|
const highlightDuration = 10000;
|
||||||
|
for (let i = targetColumnIndex; i < targetColumnIndex + 6; i++) {
|
||||||
|
const cell = targetRow.cells[i];
|
||||||
|
if (cell) {
|
||||||
|
|
||||||
|
// Scroll the table to ensure the highlighted cell is visible
|
||||||
|
// table.scrollTop = targetRow.offsetTop - table.clientHeight / 2; // Adjust vertical scroll
|
||||||
|
// table.scrollLeft = cell.offsetLeft - table.clientWidth / 2; // Adjust horizontal scroll
|
||||||
|
|
||||||
|
cell.style.transition = "background-color 0.5s";
|
||||||
|
cell.style.backgroundColor = "#df9675";
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
cell.style.backgroundColor = "";
|
||||||
|
}, highlightDuration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user