Factory Diesel : GWM
This commit is contained in:
parent
141b0112a1
commit
d4eb290269
@ -22,7 +22,7 @@ class StockController extends BaseController
|
||||
protected $factoryMachine_model;
|
||||
protected $factoryVehicleDieselDetails_model;
|
||||
protected $factoryVehicleDieselStockSummary_model;
|
||||
protected $session;
|
||||
protected $session;
|
||||
protected $incomingSilicaSandDetails_model;
|
||||
protected $inwardGateRegister_model;
|
||||
protected $rawmaterialdetails_model;
|
||||
@ -32,6 +32,7 @@ class StockController extends BaseController
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->db = \Config\Database::connect();
|
||||
parent::__construct();
|
||||
$this->coatingMachineDetails_model = new CoatingMachineDetailsModel();
|
||||
$this->drierMachineDetails_model = new DrierMachineDetailsModel();
|
||||
@ -440,11 +441,56 @@ class StockController extends BaseController
|
||||
|
||||
public function factoryVehicleDieselDetails()
|
||||
{
|
||||
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y');
|
||||
|
||||
$monthData = $this->getMonthDatesFromInput($currentMonth);
|
||||
|
||||
$machine = $this->factoryMachine_model->where('energy_type', 'diesel')->where('is_active', 1)->findAll();
|
||||
$data['startDate'] = $monthData[0]['database'];
|
||||
$data['endDate'] = $monthData[count($monthData)-1]['database'];
|
||||
$data['datefordropdown'] = $currentMonth;
|
||||
|
||||
dd($machine);
|
||||
$data['machineDetails'] = $this->factoryMachine_model->where('energy_type', 'diesel')->where('is_active', 1)->findAll();
|
||||
|
||||
$data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model
|
||||
->where('date >=', $data['startDate'])
|
||||
->where('date <=', $data['endDate'])
|
||||
->findAll();
|
||||
|
||||
$data['dieselConsumptionDetails'] = $this->getDieselConsumptionPivot($data['machineDetails'] , $data['startDate'] , $data['endDate']);
|
||||
|
||||
$data['machineName'] = array_column($data['machineDetails'], 'machine_name');
|
||||
|
||||
$this->global['pageTitle'] = 'Drier Details';
|
||||
$this->loadViews("factoryDieselMachineDetails", $this->global, $data, NULL);
|
||||
|
||||
}
|
||||
|
||||
public function getDieselConsumptionPivot($machineDetails , $startDate , $endDeate)
|
||||
{
|
||||
$machineIds = array_column($machineDetails, 'id');
|
||||
|
||||
if (empty($machineIds)) { return []; }
|
||||
|
||||
$fields = ['opening_reading', 'closing_reading', 'filling_diesel', 'consumption', 'running_hours', 'mileage'];
|
||||
|
||||
$pivotColumns = [];
|
||||
foreach ($machineIds as $machineId) {
|
||||
foreach ($fields as $field) {
|
||||
$pivotColumns[] = "MAX(CASE WHEN machine_id = $machineId THEN $field ELSE 0 END) AS {$field}_{$machineId}";
|
||||
}
|
||||
}
|
||||
|
||||
$pivotColumnString = implode(", ", $pivotColumns);
|
||||
|
||||
$sql = "SELECT `date`, $pivotColumnString FROM `t_factoryVehicleDieselDetails`
|
||||
WHERE machine_id IN (" . implode(",", $machineIds) . ") AND `date` >= ? AND `date` <= ?
|
||||
GROUP BY `date`";
|
||||
|
||||
$query = $this->db->query($sql, [$startDate,$endDeate]);
|
||||
$result = $query->getResultArray();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
349
app/Views/factoryDieselMachineDetails.php
Normal file
349
app/Views/factoryDieselMachineDetails.php
Normal file
@ -0,0 +1,349 @@
|
||||
|
||||
|
||||
<?php
|
||||
$datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
||||
?>
|
||||
<style type="text/css">
|
||||
.num {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.fht-table,
|
||||
.fht-table thead,
|
||||
.fht-table tfoot,
|
||||
.fht-table tbody,
|
||||
.fht-table tr,
|
||||
.fht-table th,
|
||||
.fht-table td {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.fht-table td {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fht-table td:hover {
|
||||
background-color: #41a1c8;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.fht-table {
|
||||
border: 0 none;
|
||||
height: auto;
|
||||
width: auto;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
/*table-layout: fixed; Algoritmo de distribucion fijo */
|
||||
white-space:nowrap;
|
||||
}
|
||||
|
||||
.fht-table th,
|
||||
.fht-table td {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fht-table-wrapper,
|
||||
.fht-table-wrapper .fht-thead,
|
||||
.fht-table-wrapper .fht-tfoot,
|
||||
.fht-table-wrapper .fht-fixed-column .fht-tbody,
|
||||
.fht-table-wrapper .fht-fixed-body .fht-tbody,
|
||||
.fht-table-wrapper .fht-tbody {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.fht-table-wrapper .fht-fixed-body .fht-tbody,
|
||||
.fht-table-wrapper .fht-tbody {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.fht-table-wrapper .fht-table .fht-cell {
|
||||
overflow: hidden;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
.fht-table-wrapper .fht-fixed-column,
|
||||
.fht-table-wrapper .fht-fixed-body {
|
||||
top: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.fht-table-wrapper .fht-fixed-column {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.fht-fixed-body .fht-thead table {
|
||||
margin-right: 20px;
|
||||
border: 0 none;
|
||||
}
|
||||
|
||||
/*For Examples*/
|
||||
|
||||
.ContenedorTabla {
|
||||
height: 500px;
|
||||
margin: 0 auto;
|
||||
overflow: auto;
|
||||
width: auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.header,
|
||||
.main {
|
||||
display: inline-block;
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.titulosHeader {
|
||||
border-bottom: 1px solid #e8bb25;
|
||||
height: auto;
|
||||
margin-bottom: 10px;
|
||||
padding-bottom: 8px;
|
||||
padding-top: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.celda_encabezado_general {
|
||||
background-color: #c45151f5;
|
||||
border: 1px solid #ccc;
|
||||
color: #ffffff;
|
||||
font-weight: bold;
|
||||
padding: 2px 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
._Separador {
|
||||
background-color: #fff;
|
||||
height: 12px;
|
||||
border-left: 1px solid #ccc;
|
||||
border-right: 1px solid #ccc;
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
._Separador div {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
.celda_normal {
|
||||
border: 1px solid #ccc;
|
||||
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>
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Stocks</a></li>
|
||||
<li class="breadcrumb-item active">
|
||||
<h4 class="page-title">Diesel - Factory Vehicle Details</h4>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 text-right">
|
||||
<!-- Right-aligned buttons or links can be added here -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<form action="<?= base_url('factoryVehicleDieselDetails'); ?>" method="post">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-3">
|
||||
<?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">
|
||||
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<input type="submit" value="Change Month" class="btn btn-success" style="margin-top:0px;">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<!-- Add table-responsive for horizontal scroll -->
|
||||
<div class="table-responsive">
|
||||
<?php
|
||||
$columns = array_keys($dieselConsumptionDetails[0]);
|
||||
|
||||
function formatHeader($key)
|
||||
{
|
||||
$parts = explode('_', $key);
|
||||
if (is_numeric(end($parts))) { array_pop($parts); }
|
||||
return ucwords(implode(' ', $parts));
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<table id="drierTable" class="fht-table table-striped" style="font-size: small;">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="celda_encabezado_general" style="padding: 10px;"></th>
|
||||
<?php foreach ($machineName as $name): ?>
|
||||
<th class="celda_encabezado_general" colspan="6" style="padding: 10px;"><?= $name; ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ($columns as $column): ?>
|
||||
<th class="celda_encabezado_general" style="padding: 10px;"><?= formatHeader($column) ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($dieselConsumptionDetails as $row): ?>
|
||||
<tr>
|
||||
<?php foreach ($columns as $index => $column): ?>
|
||||
|
||||
<?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>
|
||||
<?php else : ?>
|
||||
<td class="celda_normal" contenteditable="true" style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
</div><!-- End table-responsive -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<input type="button" class="btn btn-success" id="save" value="save">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div> <!-- End card-body -->
|
||||
</div> <!-- End card -->
|
||||
</div> <!-- End col -->
|
||||
</div> <!-- End row -->
|
||||
</div>
|
||||
</div> <!-- End container-fluid -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
|
||||
$('.timeDropdown').select2({
|
||||
placeholder: "Select a time",
|
||||
});
|
||||
|
||||
$('#save').click(function() {
|
||||
|
||||
var alldata = $("#drierTable").tableToJSON();
|
||||
|
||||
|
||||
alldata = JSON.stringify(alldata);
|
||||
|
||||
$('#loader').show();
|
||||
$.ajax({
|
||||
data: {
|
||||
drierData: alldata,
|
||||
},
|
||||
type: "POST",
|
||||
url: "<?php echo base_url() ?>",
|
||||
|
||||
success: function(data) {
|
||||
if (data) {
|
||||
|
||||
$('#loader').hide();
|
||||
alert(data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user