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

This commit is contained in:
Gowtham M 2025-01-10 16:04:36 +05:30
commit 354c5ee850
4 changed files with 333 additions and 21 deletions

View File

@ -1,4 +1,55 @@
// $routes->match(['GET', 'POST'], 'trpProductionDetails', 'StockController::trpProductionDetails');
GET http://localhost/ci4/ria/trpProductionDetails
GET http://localhost/ci4/ria/trpProductionDetails
// $routes->post('updateTrpProductionDetails', 'StockController::updateTrpProductionDetails');
# POST http://localhost/ci4/ria/updateTrpProductionDetails
# Content-Type: application/json
# {
# "updateTrpProductionDetails": [
# {
# "Date": "01-11-2024",
# "openingTime": "08:00",
# "closingTime": "17:00",
# "totalHours": 9,
# "coldStart": 0,
# "breakdownHours": 1,
# "burnerFiringHours": 8,
# "sandFeedingHours": 7,
# "workingPersonEngineers": 3,
# "workingPersonSupervisiors": 2,
# "workingPersonOperators": 4,
# "rollerDrivers": 1,
# "natureOfMaintenance": "Routine Check",
# "location": "Plant A",
# "description": "Routine operational maintenance",
# "gasReceiptBg": 500,
# "gasReceiptPg": 300,
# "physicalGasConsumption": 700,
# "trpPlusDrierGasConsumption": 600,
# "trpPhysicalGasPerTon": 5,
# "panelGasConsumption": 200,
# "panelGasPerTon": 2,
# "edRunningHours": 9,
# "edProduction": 100,
# "edUsage": 90,
# "trpProduction": 80,
# "trpProductionPerHour": 10,
# "waterReceipt": 1000,
# "waterConsumption": 800,
# "ebReading": 1200,
# "ebReadingPerUnitTon": 15,
# "msSeperation": 10,
# "edWaste": 5,
# "coolerBags": 3,
# "edPlus20Waste": 2,
# "cycloneWaste": 1
# }
# ]
# }

View File

@ -1294,8 +1294,11 @@ class StockController extends BaseController
$month = $formattedDate;
} else {
$month = date('Y-m');
}
$month = new DateTime('2024-11-01');
$month = $month->format('Y-m');
// $month = date('Y-m');
}
$data = [];
@ -1310,9 +1313,13 @@ class StockController extends BaseController
$data['trpProductionDetails'] = $this->TrpProduction_model->trpProductionDetails($startDate,$endDate);
// dd($data['trpProductionDetails']);
if(!empty($data['trpProductionDetails'])){
// $data['trpProductionDetails'] = $this->supplierArrangement($data['trpProductionDetails']);
}
// dd($this->db->getLastQuery());
// dd($data['trpProductionDetails']);
// dd($this->db->getLastQuery());
$date = DateTime::createFromFormat('Y-m', $month);
@ -1321,14 +1328,63 @@ class StockController extends BaseController
$data['month'] = $formattedDate;
// return $this->response->setJSON($data);
return $this->response->setJSON($data);
return $this->loadViews("trpProductionStockDetails", $this->global, $data, NULL);
// return $this->loadViews("trpProductionStockDetails", $this->global, $data, NULL);
}
private function supplierArrangement($dataArray)
{
foreach ($dataArray as $key => $data) {
$reclamationSuppliers = explode(',', $data['reclamationSuppliers']);
$TotalRsQuantities = explode(',', $data['TotalRsQuantities']);
$wasteCoreSuppliers = explode(',', $data['wasteCoreSuppliers']);
$TotalQuantities = explode(',', $data['TotalQuantities']);
$result = [];
$data['reclamationSuppliers'] = $this->mapSuppliersToQuantities($reclamationSuppliers, $TotalRsQuantities);
$data['wasteCoreSuppliers'] = $this->mapSuppliersToQuantities($wasteCoreSuppliers, $TotalQuantities);
unset($data['TotalRsQuantities'], $data['TotalQuantities']);
}
return $data;
}
private function mapSuppliersToQuantities($suppliers, $quantities)
{
$result = [];
foreach ($suppliers as $index => $supplier) {
$result[$supplier] = $quantities[$index];
}
return $result;
}
public function updateTrpProductionDetails() {
$postData = $this->request->getPost();

View File

@ -119,8 +119,11 @@ class TrpProductionModel extends Model
tsu.total_kgs as coating,
invItems.client_name as coreReclamationSupplier,
invItems.TotalRsQuantity,
tigrd.SupplierName as wasteCoreSupplier,
tigrd.TotalQuantityAsPerInvoice
@ -209,6 +212,95 @@ class TrpProductionModel extends Model
ORDER BY
tpmd.date ASC";
// "SELECT
// tpmd.date,
// tpmd.openingTime,
// tpmd.closingTime,
// tpmd.totalHours,
// tpmd.coldStart,
// tpmd.breakdownHours,
// tpmd.burnerFiringHours,
// tpmd.sandFeedingHours,
// tpmd.workingPersonEngineers,
// tpmd.workingPersonSupervisiors,
// tpmd.workingPersonOperators,
// tpmd.rollerDrivers,
// tpmd.natureOfMaintenance,
// tpmd.location,
// tpmd.description,
// tpd.gasReceiptBg,
// tpd.gasReceiptPg,
// tpd.physicalGasConsumption,
// tpd.trpPlusDrierGasConsumption,
// tpd.trpPhysicalGasPerTon,
// tpd.panelGasConsumption,
// tpd.panelGasPerTon,
// tpd.edRunningHours,
// tpd.edProduction,
// tpd.edUsage,
// tpd.trpProduction,
// tpd.trpProductionPerHour,
// tpd.waterReceipt,
// tpd.waterConsumption,
// tpd.ebReading,
// tpd.ebReadingPerUnitTon,
// tpwd.msSeperation,
// tpwd.edWaste,
// tpwd.coolerBags,
// tpwd.edPlus20Waste,
// tpwd.cycloneWaste,
// tcmd.totalGasConsumption AS coatingGasConsumption,
// tdmd.total_gas_consumption AS drierGasConsumption,
// tsu.total_kgs AS coating,
// -- Aggregated values for Reclaimed Sand
// (SELECT GROUP_CONCAT(CONCAT(clients.client_name, ':', invItems.item_quantity) SEPARATOR '; ')
// FROM ip_invoice_items invItems
// LEFT JOIN ip_invoices inv ON inv.invoice_id = invItems.invoice_id
// LEFT JOIN ip_clients clients ON clients.client_id = inv.client_id
// WHERE invItems.item_name = 'Core Sand Reclaimed' AND invItems.item_date_added = tpmd.date
// ) AS reclaimedSandDetails,
// -- Aggregated values for Waste Core
// (SELECT GROUP_CONCAT(CONCAT(ts.SupplierName, ':', tigrd.QuantityAsPerInvoice) SEPARATOR '; ')
// FROM t_igr_details tigrd
// LEFT JOIN t_igr_master tigm ON tigm.IGRNo = tigrd.IGRNo
// LEFT JOIN t_purchaseorder_master tpom ON tpom.PONO = tigm.PONO
// LEFT JOIN t_supplierdetailsn ts ON tpom.SupplierID = ts.SupplierID
// WHERE tigrd.MaterialCode IN ($materialCodesString) AND DATE(tigrd.CreatedDate) = tpmd.date
// ) AS wasteCoreDetails
// FROM
// t_trpProductionMaintenanceDetails tpmd
// JOIN
// t_trpProductionDetails tpd ON tpd.date = tpmd.date
// JOIN
// t_trpProductionWasteDetails tpwd ON tpwd.date = tpmd.date
// LEFT JOIN
// t_coatingMachineDetails tcmd ON tcmd.date = tpmd.date
// LEFT JOIN
// t_drierMachineDetails tdmd ON tdmd.date = tpmd.date
// LEFT JOIN
// t_trp_sand_use tsu ON tsu.date = tpmd.date
// WHERE
// tpmd.date >= ?
// AND
// tpmd.date <= ?
// ORDER BY
// tpmd.date ASC;
// "
// Execute the query
$query = $this->db->query($sql, [ $startDate, $endDate]);

View File

@ -1126,8 +1126,6 @@
let tr = $(tdElement).closest('tr');
let openingTime = tr.find('td:eq(1)').text().trim();
let closingTime = tr.find('td:eq(2)').text().trim();
let totalHours = tr.find('td:eq(3)').text().trim();
let coldStart = tr.find('td:eq(4)').text().trim();
let breakdownHours = tr.find('td:eq(5)').text().trim();
@ -1154,12 +1152,50 @@
let ebReading = tr.find('td:eq(37)').text().trim();
let ebReadingPerUnitTon = tr.find('td:eq(38)').text().trim();
let result = sandFeedingHours(totalHours,coldStart,breakdownHours,burnerFiringHours);
sandFeedingHours = result[0];
burnerFiringHours = result[1];
trpPlusDrierGasConsumption = parseInt( parseFloat(physicalGasConsumption) -
( parseFloat(drierGasConsumption) + parseFloat(coatingGasConsumption) ) );
trpPhysicalGasPerTon = parseFloat(trpPlusDrierGasConsumption) / (parseFloat(trpProduction)/1000) ;
panelGasPerTon = parseFloat(panelGasConsumption) / (parseFloat(trpProduction)/1000) ;
trpProductionPerHour = parseFloat(trpProduction) / parseFloat(sandFeedingHours) ;
ebReadingPerUnitTon = parseFloat(ebReading) / (parseFloat(trpProduction)/1000) ;
// Final updation of value into td
tr.find('td:eq(7)').text(sandFeedingHours);
tr.find('td:eq(6)').text(burnerFiringHours);
tr.find('td:eq(13)').text(trpPlusDrierGasConsumption);
tr.find('td:eq(14)').text(trpPhysicalGasPerTon);
tr.find('td:eq(15)').text(panelGasPerTon);
tr.find('td:eq(28)').text(trpProductionPerHour);
tr.find('td:eq(38)').text(ebReadingPerUnitTon);
} catch(error){
@ -1184,7 +1220,6 @@
$('.timeDropdown').change( function(){
console.log("working")
var tr = $(this).closest('tr');
@ -1202,16 +1237,27 @@
}
// Calculate the difference in milliseconds
const diffInMs = endDate - startDate;
const totalDiffInMs = endDate - startDate;
// Convert milliseconds to hours and minutes
const hours = Math.floor(diffInMs / (1000 * 60 * 60));
const minutes = Math.floor((diffInMs % (1000 * 60 * 60)) / (1000 * 60));
// Convert milliseconds to hours and minutes 3,600,000
const hours = parseInt(totalDiffInMs / (1000 * 60 * 60));
const totalHours = hours + (minutes / 60);
const hoursInMilliSeconds = hours * 60 * 60 * 1000;
const minutesInMilliseconds = totalDiffInMs - hoursInMilliSeconds;
const minutes = parseInt(minutesInMilliseconds / (1000 * 60));
const totalHours = hours +"."+ minutes;
tr.find('td:eq(3)').text(totalHours);
trpStockChange(this);
}
@ -1220,10 +1266,7 @@
);
})
console.log("working")
function convertTo24Hour(time) {
const [timePart, modifier] = time.split(" ");
@ -1247,6 +1290,76 @@
</script>
<script>
function sandFeedingHours(totalHours,coldStart,breakdownHours){
let [totalHoursF, coldStartF, breakdownHoursF] = [totalHours, coldStart, breakdownHours].map((time) => {
if (time === "" || time == null) return "0.00";
if (typeof time === "number") return time.toFixed(2);
if (!time.includes(".")) return `${time}.00`;
return time;
});
let sandFeedingHours = 0;
let totalHoursInt = milliSecondsFormat((totalHours));
let coldStartInt = milliSecondsFormat(coldStart);
let breakdownHoursInt = milliSecondsFormat(breakdownHours);
let burnerFiringHoursInt = totalHoursInt - breakdownHoursInt ;
sandFeedingHours = milliSecondsToHourMinuteFormat(burnerFiringHoursInt - coldStartInt);
burnerFiringHours = milliSecondsToHourMinuteFormat(burnerFiringHoursInt);
return [sandFeedingHours,burnerFiringHours];
}
function milliSecondsFormat(givenCustomHourMinuteFormat){
let hoursInMilliSeconds = givenCustomHourMinuteFormat.split(".")[0] * 60 * 60 * 1000;
let minutesInMilliseconds = givenCustomHourMinuteFormat.split(".")[1] * 60 * 1000;
totalMilliSeconds = hoursInMilliSeconds + minutesInMilliseconds;
return totalMilliSeconds;
}
function milliSecondsDifference(a,b){
return a > b ? a - b : b - a ;
}
function milliSecondsToHourMinuteFormat(givenMilliSeconds){
const hours = parseInt(givenMilliSeconds / (1000 * 60 * 60));
const hoursInMilliSeconds = hours * 60 * 60 * 1000;
const minutesInMilliseconds = givenMilliSeconds - hoursInMilliSeconds;
const minutes = parseInt(minutesInMilliseconds / (1000 * 60));
const totalHours = hours +"."+ minutes;
return totalHours;
}
</script>