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

This commit is contained in:
Gowtham M 2024-11-14 10:46:34 +05:30
commit 5f47c5e0fc
10 changed files with 1148 additions and 138 deletions

View File

@ -454,4 +454,8 @@ $routes->post('updateDustAndRoughStockDetails', 'StockController::updateDustAndR
//Resin stock details
$routes->match(['GET','POST'],'resinStockDetails', 'StockController::loadView_resinStockDetails');
$routes->post('updateResinStockDetails', 'StockController::updateResinStockDetails');
$routes->post('updateResinStockDetails', 'StockController::updateResinStockDetails');
//Gas stock details
$routes->match(['GET','POST'],'gasStockDetails', 'StockController::loadView_gasStockDetails');
$routes->post('updateGasStockDetails', 'StockController::updateGasStockDetails');

View File

@ -16,8 +16,11 @@ use App\Models\Rawmaterialdetails_model;
use App\Models\BagStockDetailsModel;
use App\Models\DustAndRoughModel;
use App\Models\ResinStockModel;
use App\Models\GasStockModel;
use CodeIgniter\HTTP\ResponseInterface;
use DateTime;
use DatePeriod;
use DateInterval;
class StockController extends BaseController
{
@ -37,6 +40,7 @@ class StockController extends BaseController
protected $Rawmaterialdetails_model;
protected $dustAndRoughStockDetails_model;
protected $resinStockDetails_model;
protected $gasStockDetails_model;
/**
* This is default constructor of the class
@ -71,6 +75,8 @@ class StockController extends BaseController
$this->dustAndRoughStockDetails_model = new DustAndRoughModel();
$this->resinStockDetails_model = new ResinStockModel() ;
$this->gasStockDetails_model = new GasStockModel() ;
$this->session = session();
@ -103,10 +109,14 @@ class StockController extends BaseController
$this->global['pageTitle'] = 'Coating Machine Details ';
$startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate));
$data['coatingMachineDetails']= $this->coatingMachineDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('is_active', 1)
->orderBy('created_at','DESC')
->like('created_at', $month, 'after')
->orderBy('date','asc')
->findAll();
$date = DateTime::createFromFormat('Y-m', $month);
@ -123,6 +133,21 @@ class StockController extends BaseController
$postData=$this->request->getPost();
$date = $postData['date'];
$shift = $postData['shift'];
$sameShiftOnDateExists = $this->coatingMachineDetails_model
->where('date',$date)
->where('shift',$shift)
->where('is_active',1)
->first();
if(!empty($sameShiftOnDateExists)){
return redirect()->back()->with('error', 'Already same shift exists on the same date ..!!');
}
$inserted= $this->coatingMachineDetails_model->insert($postData);
@ -391,6 +416,9 @@ class StockController extends BaseController
$updateBagStockDetailsData = json_decode($postData['updateBagStockDetails'], true);
$inserts = [];
$updates = [];
foreach($updateBagStockDetailsData as $data){
$date = $data['date'];
@ -413,20 +441,32 @@ class StockController extends BaseController
->first();
if(!empty($resultExists)){
$updated=$this->bagStockDetails_model
->where('date',$date)
->where('materialCode',$materialCode)
->set($dbData)
->update();
if(empty($resultExists)){
$inserts [] = $dbData;
}else{
$inserted = $this->bagStockDetails_model->insert($dbData);
}
}
$dbData['id']=$resultExists['id'];
$updates [] = $dbData;
}
}
if(!empty($inserts)){
$inserted = $this->bagStockDetails_model->insertBatch($inserts);
}
if(!empty($updates)){
$updateResult = $this->bagStockDetails_model->updateBatch($updates,'id');
if ($updateResult === FALSE) {
echo "Error during update";
} else {
echo "Data Updated Successfully";
return;
}
}
echo "Data Saved Successfully";
}
@ -485,15 +525,16 @@ class StockController extends BaseController
foreach($updateDustAndRoughStockDetailsData as $data){
$date = $data['date'];
$data['date'] = DateTime::createFromFormat('d-m-Y', $data['date'])->format('Y-m-d');
$date =$data['date'];
$dbData= [
'date' => $data['date'],
'finalRough' => $data['finalRough'],
'dust' => $data['dust'],
'total' => $data['total']
];
];
$resultExists=$this->dustAndRoughStockDetails_model
->where('date',$date)
@ -506,7 +547,7 @@ class StockController extends BaseController
} else {
$updates[] = $dbData;
}
}
}
if (!empty($inserts)) {
$this->dustAndRoughStockDetails_model->insertBatch($inserts);
@ -666,7 +707,8 @@ class StockController extends BaseController
if(empty($resultExists)){
$inserts[] = $dbData;
}else{
$updates[] = $dbData;
$dbData['id']=$resultExists['id'];
$updates[] = $dbData ;
}
}
@ -693,20 +735,184 @@ class StockController extends BaseController
}
//Gas Stock Details
public function loadView_gasStockDetails(){
if ($this->request->getMethod() === 'POST'){
$month = $this->request->getPost('month');
$date = DateTime::createFromFormat('M-Y', $month);
$formattedDate = $date->format('Y-m');
$month=$formattedDate;
}
else{
$month = date('Y-m');
}
$data=[];
$data['month']=$month;
$this->global['pageTitle'] = "Gas Stock Details";
$startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate));
$data['gasStockDetails'] = $this->gasStockDetails_model
->select('t_gasStockDetails.*,
t_drierMachineDetails.total_gas_consumption AS drierMachineGasConsumption,
t_drierMachineDetails.sand_dried_qty AS sandDried,
coating_summary.coatingMachineGasconsumption,
coating_summary.coatedSand'
)
// Subquery with early date filtering
->join(
'(SELECT date,
SUM(totalGasconsumption) AS coatingMachineGasconsumption,
SUM(totalCoatingSandInKg) / 1000 AS coatedSand
FROM t_coatingMachineDetails
WHERE is_active = 1
AND date >= ' . $this->db->escape($startDate) . '
AND date <= ' . $this->db->escape($endDate) . '
GROUP BY date
) AS coating_summary',
'coating_summary.date = t_gasStockDetails.date',
'left'
)
->join('t_drierMachineDetails',
't_drierMachineDetails.date = t_gasStockDetails.date
AND t_drierMachineDetails.date >= ' . $this->db->escape($startDate) . '
AND t_drierMachineDetails.date <= ' . $this->db->escape($endDate),
'left'
)
->where('t_gasStockDetails.date >=', $startDate)
->where('t_gasStockDetails.date <=', $endDate)
->groupBy('t_gasStockDetails.date')
->findAll();
$data['month'] = DateTime::createFromFormat('Y-m', $month)->format('M-Y');
return $this->loadViews("gasStockDetails", $this->global, $data, NULL);
}
public function updateGasStockDetails(){
$postData = $this->request->getPost();
$updateGasStockDetailsData = json_decode($postData['updateGasStockDetails'], true);
$updates = [];
$inserts = [];
foreach($updateGasStockDetailsData as $data){
$date = $data['date'];
$dbData = [
'date' =>$data['date'],
'opening' =>$data['opening'],
'purchaseBharath' =>$data['purchaseBharath'],
'purchaseIndian' =>$data['purchaseIndian'],
'total' =>$data['total'],
'consumption' =>$data['consumption'],
'balanceStock' =>$data['balanceStock'],
];
$resultExists = $this->gasStockDetails_model
->where('date',$date)
->first();
if(empty($resultExists)){
$inserts[] = $dbData;
}else{
$dbData['id']=$resultExists['id'];
$updates[] = $dbData ;
}
}
if (!empty($inserts)) {
$this->gasStockDetails_model->insertBatch($inserts);
}
if (!empty($updates)) {
$updateResult = $this->gasStockDetails_model->updateBatch($updates, 'id');
if ($updateResult === FALSE) {
echo "Error during update";
} else {
echo "Data Updated Successfully";
return;
}
}
echo "Data Saved Successfully";
}
private function updateGasStockConsumption($date , $consumption){
$resultExists = $this->gasStockDetails_model
->where('date',$date)
->first();
if($resultExists){
$resultExists['consumption'] = $resultExists['consumption']+($consumption);
$this->gasStockDetails_model->update($resultExists['id'],$resultExists);
}
else{
$startDate = DateTime::createFromFormat('Y-m-d', $date)->modify('first day of this month')->format('Y-m-d');
$endDate = DateTime::createFromFormat('Y-m-d', $date)->modify('last day of this month')->format('Y-m-d');
$datesInMonth = [];
$inserts = [];
$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 ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
$inserts[] = [
'date' => $dateInMonth,
'opening' => 0,
'purchaseBharath' => 0,
'purchaseIndian' => 0,
'total' => 0,
'consumption' => $dateInMonth == $date ? $consumption : 0 ,
'balanceStock' => 0
];
}
if(!empty($inserts)){
$this->gasStockDetails_model->insertBatch($inserts);
}
}
}
// --------------------------------------------gwm----------------------------------------------
@ -823,9 +1029,27 @@ class StockController extends BaseController
if ($existingRow) {
// If exists, update the row
//before updating the row update gas stock
$existingDrierGasConsumption = $existingRow['total_gas_consumption'];
$updatedDrierGasConsumption = $row['Tot Gas Consumption'];
if( $existingDrierGasConsumption != $updatedDrierGasConsumption ){
$changeInConsumption = $updatedDrierGasConsumption - $existingDrierGasConsumption;
$dateToBeUpdated = $existingRow['date'];
$this->updateGasStockConsumption($dateToBeUpdated , $changeInConsumption);
}
$this->drierMachineDetails_model->update($existingRow['id'], $data);
} else {
// If not, insert a new row
//before inserting the row update gas stock
$consumption = $row['Tot Gas Consumption'];
$dateToBeInserted = $data['date'];
$this->updateGasStockConsumption($dateToBeInserted , $consumption);
$this->drierMachineDetails_model->insert($data);
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class GasStockModel extends Model
{
protected $table = 't_gasStockDetails';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['date','opening','purchaseBharath','purchaseIndian',
'total','consumption','balanceStock'];
protected bool $allowEmptyInserts = false;
protected bool $updateOnlyChanged = true;
protected array $casts = [];
protected array $castHandlers = [];
// Dates
protected $useTimestamps = false;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
}

View File

@ -1,67 +1,170 @@
<style>
#datatable_filter {
float: inline-end;
<style type="text/css">
.num {
text-align: right;
}
#datatable_wrapper .row .col-sm-4 {
flex-basis: 50%;
float: inline-end;
.fht-table,
.fht-table thead,
.fht-table tfoot,
.fht-table tbody,
.fht-table tr,
.fht-table th,
.fht-table td {
margin: 0;
}
#datatable_paginate .pagination {
flex-basis: 50%;
float: inline-end;
margin: 0 0 15px;
.fht-table td {
text-align: center;
}
#datatable_wrapper .row:nth-child(3),
#datatable_wrapper .row:nth-child(1) {
padding: 0 15px;
.fht-table td:hover {
background-color: #00a65a;
color: #ffffff;
}
#datatable_info {
margin-top: 5px;
.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;
}
.dataTables_wrapper {
padding-bottom: 0;
.fht-table th,
.fht-table td {
overflow: hidden;
}
.Date-filter-form {
display: flex;
align-items: center;
gap: 10px;
/* Adjust the gap as needed */
.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;
}
.Date-filter-form input,
.Date-filter-form button {
padding: 5px;
font-size: 14px;
.fht-table-wrapper .fht-fixed-body .fht-tbody,
.fht-table-wrapper .fht-tbody {
overflow: auto;
}
.Date-filter-form button {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
.fht-table-wrapper .fht-table .fht-cell {
overflow: hidden;
height: 1px;
}
.Date-filter-form button:hover {
background-color: #0056b3;
.fht-table-wrapper .fht-fixed-column,
.fht-table-wrapper .fht-fixed-body {
top: 0;
left: 0;
position: absolute;
}
.icon-button {
background: none;
border: none;
cursor: pointer;
color: #007bff;
font-size: 18px;
.fht-table-wrapper .fht-fixed-column {
z-index: 1;
}
.icon-button:hover {
color: #0056b3;
.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: #00a65a;
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 {
/*background-color: #fff;*/
/* <!-- ad9271 into ffffff brown-light to green-light --> */
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;
}
#coatingMachineDetailTableId th:nth-child(1),
#coatingMachineDetailTableId td:nth-child(1) {
position: sticky;
left: 0;
background-color: #00a65a;
z-index: 2;
border-right: 2px solid #ddd;
color: #ffffff;
}
</style>
<div class="content-page">
@ -91,6 +194,11 @@
</div>
</div>
<?php if (session()->getFlashdata('error')): ?>
<div class="alert alert-danger">
<?= session()->getFlashdata('error'); ?>
</div>
<?php endif; ?>
<div class="row">
<div class="col-12">
@ -116,26 +224,26 @@
</div>
</form>
<table id="datatable" class="table table-hover table-bordered"
<div class="table-responsive">
<table id="coatingMachineDetailTableId" class="fht-table table-hover table-bordered"
style="background-color:#fff;">
<thead>
<tr>
<th style="text-align:center !important;">Date</th>
<th style="text-align:center !important;">Shift</th>
<th style="text-align:center !important;">Machine On Time</th>
<th style="text-align:center !important;">Machine Off Time</th>
<th style="text-align:center !important;">Machine Running(hr)</th>
<th style="text-align:center !important;">Total Coating</th>
<th style="text-align:center !important;">Total Coating Sand(kg)</th>
<th style="text-align:center !important;">Total Gas Consumption</th>
<th style="text-align:center !important;">Hour Gas</th>
<th style="text-align:center !important;">Hour QTY(kg)
<th class="celda_encabezado_general" style="padding: 10px;">Date</th>
<th class="celda_encabezado_general" style="padding: 10px;">Shift</th>
<th class="celda_encabezado_general" style="padding: 10px;">Machine On Time</th>
<th class="celda_encabezado_general" style="padding: 10px;">Machine Off Time</th>
<th class="celda_encabezado_general" style="padding: 10px;">Machine Running(hr)</th>
<th class="celda_encabezado_general" style="padding: 10px;">Total Coating</th>
<th class="celda_encabezado_general" style="padding: 10px;">Total Coating Sand(kg)</th>
<th class="celda_encabezado_general" style="padding: 10px;">Total Gas Consumption</th>
<th class="celda_encabezado_general" style="padding: 10px;">Hour Gas</th>
<th class="celda_encabezado_general" style="padding: 10px;">Hour QTY(kg)
</th>
<th style="text-align:center !important;">Customer Name</th>
<th style="text-align:center !important;">Action</th>
<th class="celda_encabezado_general" style="padding: 10px;">Customer Name</th>
<th class="celda_encabezado_general" style="padding: 10px;">Action</th>
</tr>
</thead>
<tbody>
@ -147,21 +255,25 @@
?>
<tr data-id="<?php echo $record['id']; ?>">
<td align="center"><?php echo $record['date'] ?></td>
<td align="center"><?php echo $record['shift'] ?></td>
<td align="center"><?php echo $record['machineOnTime'] ?></td>
<td align="center"><?php echo $record['machineOffTime'] ?></td>
<td align="center"><?php echo $record['machineRunningInHrs'] ?? '' ?></td>
<td align="center"><?php echo $record['totalCoating'] ?></td>
<td align="center"><?php echo $record['totalCoatingSandInKg'] ?></td>
<td align="center"><?php echo $record['totalGasConsumption'] ?></td>
<td align="center"><?php echo $record['perHourGasConsumption'] ?? '' ?></td>
<td align="center"><?php echo $record['perHourCoatingSandQTY'] ?? '' ?></td>
<td align="center"><?php echo $record['customerName']; ?></td>
<td align="center">
<?php
$date = DateTime::createFromFormat('Y-m-d', $record['date'])->format('d-m-Y');
?>
<td class="celda_normal"><?php echo $date ?></td>
<td class="celda_normal"><?php echo $record['shift'] ?></td>
<td class="celda_normal"><?php echo $record['machineOnTime'] ?></td>
<td class="celda_normal"><?php echo $record['machineOffTime'] ?></td>
<td class="celda_normal"><?php echo $record['machineRunningInHrs'] ?? '' ?></td>
<td class="celda_normal"><?php echo $record['totalCoating'] ?></td>
<td class="celda_normal"><?php echo $record['totalCoatingSandInKg'] ?></td>
<td class="celda_normal"><?php echo $record['totalGasConsumption'] ?></td>
<td class="celda_normal"><?php echo $record['perHourGasConsumption'] ?? '' ?></td>
<td class="celda_normal"><?php echo $record['perHourCoatingSandQTY'] ?? '' ?></td>
<td class="celda_normal"><?php echo $record['customerName']; ?></td>
<td class="celda_normal" style="background-color:white;">
<a data-toggle="tooltip" class="edit-btn"
data-target="editCoatingMachineDetailModal" data-toggle="modal"
style="cursor:pointer ;">
style="cursor:pointer;">
<i class="fa fa-pencil-alt"
title="Click here to Edit "></i>
&nbsp;&nbsp;&nbsp;
@ -188,6 +300,17 @@
</tbody>
</table>
</div>
<br>
<?php if(empty($coatingMachineDetails)){ ?>
<h5 align="center" style="color:grey;">
No Coating Machine Details present in this month
</h5>
<?php }?>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
@ -559,39 +682,7 @@
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
<script>
$(document).ready(function () {
$.fn.dataTable.ext.type.order['date-eu-pre'] = function (date) {
var dateSplit = date.split('-');
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
};
// Initialize the DataTable
var table = $('#datatable').DataTable({
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [
'csv', 'excel', 'pdf', // Export buttons
],
pageLength: 10, // Default rows per page
lengthMenu: [[10, 20, 30, 50, -1], [10, 20, 30, 50, "All"]], // Rows per page options
// responsive: true, // Responsive table
order: [], // Default ordering (column index 0, descending)
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
}
}
});
// Handle form submission
$("#DateRangeFilter").submit(function (e) {
e.preventDefault();
table.draw();
});
});
</script>
<script>
function confirmDelete(event) {
@ -620,13 +711,14 @@
<script>
$(document).ready(function () {
$('#datatable tbody').on('click', '.edit-btn', function () {
$('#coatingMachineDetailTableId tbody').on('click', '.edit-btn', function () {
var row = $(this).closest('tr');
// Get values from the row
var date = row.find('td:eq(0)').text();
var date = row.find('td:eq(0)').text().split('-');
date=`${date[2]}-${date[1]}-${date[0]}`;
var shift = row.find('td:eq(1)').text();
var machineOnTimeHr = row.find('td:eq(2)').text();
var machineOffTimeHr = row.find('td:eq(3)').text();
@ -641,9 +733,10 @@
// Fill the modal fields with the values
$('#editCoatingMachineDetailId').val(row.data('id'));
$('#editCustomerNameId').val(customerName);
$('#editDateId').val(date);
$('#editDateId').val(date);//convert this from d-m-y to Y-m-d in javascript
$('#editShiftId').val(shift);
$('#editMachineOnTimeHrId').val(machineOnTimeHr).change();
$('#editMachineOffTimeHrId').val(machineOffTimeHr).change();

View File

@ -156,6 +156,16 @@
height: 20px;
}
#bagStockDetailsTableId th:nth-child(1),
#bagStockDetailsTableId td:nth-child(1) {
position: sticky;
left: 0;
background-color: #00a65a;
z-index: 2;
border-right: 2px solid #ddd;
color: #ffffff;
}
.modal {
padding-right: 30% ! important;
}

View File

@ -156,6 +156,16 @@
height: 20px;
}
#dustAndRoughStockDetailsTableId th:nth-child(1),
#dustAndRoughStockDetailsTableId td:nth-child(1) {
position: sticky;
left: 0;
background-color: #00a65a;
z-index: 2;
border-right: 2px solid #ddd;
color: #ffffff;
}
.modal {
padding-right: 30% ! important;
}
@ -190,14 +200,14 @@
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="card-body" style="padding-left:300px;">
<form action="<?= base_url('dustAndRoughStockDetails'); ?>" method="post">
<div class="row">
<div class="row" >
<div class="col-3">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control mt-2" data-provide="datepicker"
data-date-format="M-yyyy" data-date-min-view-mode="1">
</div>
@ -210,12 +220,14 @@
<div class="table-responsive">
<table id="dustAndRoughStockDetailsTableId" class="fht-table table-striped">
<table style="width: 700px;" id="dustAndRoughStockDetailsTableId" class="fht-table table-striped">
<thead class="celda_encabezado_general" style="padding: 10px;">
<tr>
<th class="celda_encabezado_general" rowspan="2" colspan="1">Date </th>
<th
style="width: 100px;"
class="celda_encabezado_general" rowspan="2" colspan="1">Date </th>
<th class="celda_encabezado_general" colspan="1">Final Rough </th>
<th class="celda_encabezado_general" colspan="1">Dust </th>
<th class="celda_encabezado_general" rowspan="2" colspan="1">Total </th>

View File

@ -0,0 +1,600 @@
<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: #00a65a;
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: #00a65a;
border: 1px solid #ccc;
color: #ffffff;
font-weight: bold;
padding: 6px 10px;;
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 {
/*background-color: #fff;*/
/* <!-- ad9271 into ffffff brown-light to green-light --> */
text-align: center;
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;
}
#gasStockDetailsTableId th:nth-child(1),
#gasStockDetailsTableId td:nth-child(1),
{
position: sticky;
left: 0;
background-color: #00a65a;
z-index: 2;
border-right: 2px solid #ddd;
color: #ffffff;
}
.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">Gas Stock 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('gasStockDetails'); ?>" method="post">
<div class="row">
<div class="col-3">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control mt-2" data-provide="datepicker"
data-date-format="M-yyyy" data-date-min-view-mode="1">
</div>
<div class="form-group col-md-2">
<button type="submit" class="btn btn-success"> Change Month </button>
</div>
</div>
</form>
<div class="table-responsive">
<table id="gasStockDetailsTableId" class="fht-table table-striped">
<thead class="celda_encabezado_general" style="padding: 10px;">
<tr>
<th class="celda_encabezado_general" rowspan="2" colspan="2">RIPL </th>
<th class="celda_encabezado_general" colspan="12">SEP- GAS CONSUMPTION-422 & 425 kg </th>
</tr>
<tr>
<th class="celda_encabezado_general" colspan="5">Gas Stock </th>
<th class="celda_encabezado_general">10 Ton</th>
<th class="celda_encabezado_general">Sand Dried</th>
<th class="celda_encabezado_general">Coating Machine</th>
<th class="celda_encabezado_general">Sand Coated</th>
<th class="celda_encabezado_general">Trp Machine </th>
<th class="celda_encabezado_general">Sand TRP</th>
<th class="celda_encabezado_general">Rotary Drier </th>
</tr>
<tr>
<th class="celda_encabezado_general">Date </th>
<th class="celda_encabezado_general">Opening Stock</th>
<th class="celda_encabezado_general">Purchase(Bharath)</th>
<th class="celda_encabezado_general">Purchase(Indian)</th>
<th class="celda_encabezado_general">Total</th>
<th class="celda_encabezado_general">Consumption </th>
<th class="celda_encabezado_general">Balance Stock</th>
<th class="celda_encabezado_general">Consumption </th>
<th class="celda_encabezado_general">ton </th>
<th class="celda_encabezado_general">Consumption</th>
<th class="celda_encabezado_general">ton </th>
<th class="celda_encabezado_general">Consumption</th>
<th class="celda_encabezado_general">ton </th>
<th class="celda_encabezado_general">Consumption</th>
</tr>
</thead>
<tbody style="background-color: #fff;" >
<?php if(!empty($gasStockDetails)){
foreach($gasStockDetails as $index => $gasStockDetail){
$date = Datetime::createFromFormat('Y-m-d',$gasStockDetail['date'])->format('d-m-Y')
?>
<tr>
<td class="celda_normal"><?=$date??'-'?></td>
<!-- only setting opening stock editable for first day of the month -->
<td class="celda_normal openingStock"
<?php if($index==0){echo"contenteditable='true'";}?>
oninput="openingStockChange(this)"
data-id="<?=$gasStockDetail['date']?>"
><?=$gasStockDetail['opening']??'0'?></td>
<td class="celda_normal purchaseBharath"
oninput="purchaseBharathStockChange(this)"
data-id="<?=$gasStockDetail['date']?>"
contenteditable="true"><?=$gasStockDetail['purchaseBharath']??'0'?></td>
<td class="celda_normal purchaseIndian"
oninput="purchaseIndianStockChange(this)"
data-id="<?=$gasStockDetail['date']?>"
contenteditable="true"><?=$gasStockDetail['purchaseIndian']??'0'?></td>
<td class="celda_normal total"
data-id="<?=$gasStockDetail['date']?>"
><?=$gasStockDetail['total']??'0'?></td>
<td class="celda_normal consumption"
data-id="<?=$gasStockDetail['date']?>"
><?=$gasStockDetail['consumption']??'0'?></td>
<td class="celda_normal balanceStock"
data-id="<?=$gasStockDetail['date']?>"
><?=$gasStockDetail['balanceStock']??'0'?></td>
<td class="celda_normal"><?=$gasStockDetail['drierMachineGasConsumption']??'0'?></td>
<td class="celda_normal"><?=$gasStockDetail['sandDried']??'0'?></td>
<td class="celda_normal"><?=$gasStockDetail['coatingMachineGasconsumption']??'0'?></td>
<td class="celda_normal"><?=$gasStockDetail['coatedSand']??'0'?></td>
<td class="celda_normal"><?=$gasStockDetail['trpMachineGasconsumption']??'0'?></td>
<td class="celda_normal"><?=$gasStockDetail['sandTrp']??'0'?></td>
<td class="celda_normal"><?=$gasStockDetail['rotaryDrierMachineGasconsumption']??'0'?></td>
</tr>
<?php }
}else{
$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');
$datesInMonth = [];
$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 ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
$dateInMonthDmYFormat = Datetime::createFromFormat('Y-m-d',$dateInMonth)->format('d-m-Y')
?>
<tr>
<td class="celda_normal"><?=$dateInMonthDmYFormat??'-'?></td>
<!-- only setting opening stock editable for first day of the month -->
<td class="celda_normal openingStock"
<?php if($datesInMonthIndex==0){echo"contenteditable='true'";}?>
oninput="openingStockChange(this)"
data-id="<?=$dateInMonth?>"
>0</td>
<td class="celda_normal purchaseBharath"
oninput="purchaseBharathStockChange(this)"
data-id="<?=$dateInMonth?>"
contenteditable="true">0</td>
<td class="celda_normal purchaseIndian"
oninput="purchaseIndianStockChange(this)"
data-id="<?=$dateInMonth?>"
contenteditable="true">0</td>
<td class="celda_normal total"
data-id="<?=$dateInMonth?>"
>0</td>
<td class="celda_normal consumption"
data-id="<?=$dateInMonth?>"
contenteditable="true">0</td>
<td class="celda_normal balanceStock"
data-id="<?=$dateInMonth?>"
>0</td>
<td class="celda_normal">0</td>
<td class="celda_normal">0</td>
<td class="celda_normal">0</td>
<td class="celda_normal">0</td>
<td class="celda_normal">0</td>
<td class="celda_normal">0</td>
<td class="celda_normal">0</td>
</tr>
<?php }
}?>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-12 text-right">
<input type="button" class="btn btn-success" id="saveId" 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 () {
$('#saveId').click(function () {
//table to json function
var updateGasStockDetails = tableToJson();
alert('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updateGasStockDetails
},
type: "POST",
url: "<?php echo base_url() ?>updateGasStockDetails",
success: function (data) {
if (data) {
$('#loader').hide();
console.log(data);
alert(data);
window.location.reload();
}
},
error: function(xhr, status, error) {
alert("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();
}
});
});
});
</script>
<script>
function tableToJson() {
const table = $('#gasStockDetailsTableId');
const rows = [];
table.find('tbody tr').each(function() {
const rowCells = $(this).find('td');
let date = rowCells.eq(0).text().trim().split('-');
date=`${date[2]}-${date[1]}-${date[0]}`;
const rowData = {
date,
opening: rowCells.eq(1).text().trim()|| '0',
purchaseBharath: rowCells.eq(2).text().trim()|| '0',
purchaseIndian: rowCells.eq(3).text().trim()|| '0',
total: rowCells.eq(4).text().trim()|| '0',
consumption: rowCells.eq(5).text().trim()|| '0',
balanceStock: rowCells.eq(6).text().trim()|| '0'
};
rows.push(rowData);
});
return JSON.stringify(rows, null, 2);
}
</script>
<script>
function openingStockChange(tdElement) {
try{
let dataId = tdElement.getAttribute('data-id');
let date = dataId;
let openingStock = tdElement.innerText;
let purchaseBharathStock = document.querySelector(`td.purchaseBharath[data-id="${dataId}"]`).innerText;
let purchaseIndianStock = document.querySelector(`td.purchaseIndian[data-id="${dataId}"]`).innerText;
let toatalGasConsumption = document.querySelector(`td.consumption[data-id="${dataId}"]`).innerText;
let totalGas = (Number(openingStock) + Number(purchaseBharathStock)) + Number(purchaseIndianStock);
let currentBalanceStock = Number(totalGas) - Number(toatalGasConsumption);
document.querySelector(`td.total[data-id="${dataId}"]`).innerText=totalGas;
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText= currentBalanceStock;
updateStockValue( date,currentBalanceStock )
} catch(error){
console.error("There is an error updating stock ..!!" + error);
}
}
function purchaseBharathStockChange(tdElement) {
try{
let dataId = tdElement.getAttribute('data-id');
let date = dataId;
let openingStock = document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText;
let purchaseBharathStock = tdElement.innerText;
let purchaseIndianStock = document.querySelector(`td.purchaseIndian[data-id="${dataId}"]`).innerText;
let toatalGasConsumption = document.querySelector(`td.consumption[data-id="${dataId}"]`).innerText;
let totalGas = (Number(openingStock) + Number(purchaseBharathStock)) + Number(purchaseIndianStock);
let currentBalanceStock = Number(totalGas) - Number(toatalGasConsumption);
document.querySelector(`td.total[data-id="${dataId}"]`).innerText=totalGas;
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText= currentBalanceStock;
updateStockValue( date,currentBalanceStock )
} catch(error){
console.error("There is an error updating stock ..!!" + error);
}
}
function purchaseIndianStockChange(tdElement) {
try{
let dataId = tdElement.getAttribute('data-id');
let date = dataId;
let openingStock = document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText;
let purchaseBharathStock = document.querySelector(`td.purchaseBharath[data-id="${dataId}"]`).innerText;
let purchaseIndianStock = tdElement.innerText;
let toatalGasConsumption = document.querySelector(`td.consumption[data-id="${dataId}"]`).innerText;
let totalGas = (Number(openingStock) + Number(purchaseBharathStock)) + Number(purchaseIndianStock);
let currentBalanceStock = Number(totalGas) - Number(toatalGasConsumption);
document.querySelector(`td.total[data-id="${dataId}"]`).innerText = totalGas;
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
updateStockValue( date,currentBalanceStock )
} catch(error){
console.error("There is an error updating stock ..!!" + error);
}
}
</script>
<script>
function updateStockValue( date, currentBalanceStock ){
const table = $('#gasStockDetailsTableId');
const rows = [];
table.find('tbody tr').each(function() {
const rowCells = $(this).find('td');
let otherDate = rowCells.eq(0).text().trim().split('-');
otherDate=`${otherDate[2]}-${otherDate[1]}-${otherDate[0]}`;
if( new Date(otherDate) > new Date(date) ){ //other records present after it
let dataId = `${otherDate}`;
document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
let openingStock = currentBalanceStock ;
let purchaseBharathStock = document.querySelector(`td.purchaseBharath[data-id="${dataId}"]`).innerText;
let purchaseIndianStock = document.querySelector(`td.purchaseIndian[data-id="${dataId}"]`).innerText;
let toatalGasConsumption = document.querySelector(`td.consumption[data-id="${dataId}"]`).innerText;
let totalGas = (Number(openingStock) + Number(purchaseBharathStock)) + Number(purchaseIndianStock);
currentBalanceStock = Number(totalGas) - Number(toatalGasConsumption);
document.querySelector(`td.total[data-id="${dataId}"]`).innerText= totalGas;
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
}
})
}
</script>

View File

@ -767,22 +767,24 @@
<div class="dropdown-menu" aria-labelledby="topnav-stock">
<div class="">
<a href="<?php echo base_url(); ?>incomingSilicaSandDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>incoming silica sand Details</a>
<a href="<?php echo base_url(); ?>incomingSilicaSandDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Incoming Silica Sand Details</a>
<a href="<?php echo base_url(); ?>drierMachineDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>10 TON Drier Details</a>
<a href="<?php echo base_url(); ?>coatingMachineDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Coating Machine Details</a>
<a href="<?php echo base_url(); ?>gasStockDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Gas Stock Details</a>
<a href="<?php echo base_url(); ?>factoryVehicleDieselDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Diesel - Factory Vehicle </a>
<a href="<?php echo base_url(); ?>powerConsumptionDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Power Consumption </a>
<a href="<?php echo base_url(); ?>bagStockDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Bag Stock Details</a>
<a href="<?php echo base_url(); ?>dustAndRoughStockDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Dust And Rough Stock Details</a>
<a href="<?php echo base_url(); ?>resinStockDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Resin Stock Details</a>
<a href="<?php echo base_url(); ?>bagStockDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Bag Stock Details</a>
</div>
</div>
</li>

View File

@ -1,5 +1,5 @@
<style type="text/css">
<style type="text/css">
.num {
text-align: right;
}
@ -158,7 +158,7 @@
.modal {
padding-right: 30% ! important;
}
</style>
</style>
<div class="content-page">
<div class="content">
<!-- Start Content-->
@ -211,7 +211,7 @@
<!-- Add table-responsive for horizontal scroll -->
<div class="table-responsive">
<table id="incomingSilicaSandDetailsTable" class="fht-table table-striped" style="font-size: small;">
<table id="incomingSilicaSandDetailsTable" class="fht-table table table-striped " >
<thead>
<tr>
@ -266,7 +266,7 @@
<tr id="<?php echo $row; ?>">
<!-- 'td:eq(0)' -->
<td width="45" height="45" class="celda_normal"><?php echo $index; ?></td>
<td class="celda_normal"><?php echo $index; ?></td>
<!-- 'td:eq(1)' -->
<td class="celda_normal">
@ -470,13 +470,21 @@
</tr>
<?php } ?>
</tbody>
</table>
<br>
</div><!-- End table-responsive -->
<br>
<?php if(empty($igrDetails)){ ?>
<h5 align="center" style="color:grey;">
No Inward Gate Registry created for incoming silica sand in this month
</h5>
<?php }?>
<div class="row">
<div class="col-md-12 text-right">
<input type="button" class="btn btn-success" id="save" value="save">

View File

@ -156,6 +156,16 @@
height: 20px;
}
#resinStockDetailsTableId th:nth-child(1),
#resinStockDetailsTableId td:nth-child(1) {
position: sticky;
left: 0;
background-color: #00a65a;
z-index: 2;
border-right: 2px solid #ddd;
color: #ffffff;
}
.modal {
padding-right: 30% ! important;
}
@ -251,7 +261,7 @@
<?php if(!empty($groupedResinStockDetails))
{
//dd($groupedBagStockDetails);
//dd($groupedResinStockDetails);
foreach($groupedResinStockDetails as $groupedResinStockDetailsIndex => $resinStockDetails){
?>
<tr>