stock module latest today vadivel J 08-1-2025

This commit is contained in:
vadivelJ96 2025-01-09 18:19:01 +05:30
parent 50f425d464
commit 6f6a12d301
3 changed files with 206 additions and 7 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]);