changes in stock module 14-03-2025
This commit is contained in:
parent
27681a4fa1
commit
a4e2197602
@ -3119,111 +3119,143 @@ class StockController extends BaseController
|
||||
public function updateTrpProductionDetails($inserts = null, $freshEntry = false)
|
||||
{
|
||||
|
||||
|
||||
//getting values from post request
|
||||
$postData['updateTrpProductionDetails'] = json_decode($this->request->getPost('updateTrpProductionDetails'),true);
|
||||
|
||||
|
||||
|
||||
//checking if post data is empty data ?
|
||||
if (empty($postData['updateTrpProductionDetails'])) {
|
||||
|
||||
//if empty data , we still check for inserts data is available or not
|
||||
if (empty($inserts)) {
|
||||
|
||||
//if both fails return "no data found"
|
||||
return $this->response->setJSON(['error' => 'No data found to update']);
|
||||
|
||||
} else {
|
||||
|
||||
//if inserts data is available , then assign to post data
|
||||
$postData['updateTrpProductionDetails'] = $inserts;
|
||||
}
|
||||
}
|
||||
|
||||
$updateTrpProductionDetails = $postData['updateTrpProductionDetails'];
|
||||
|
||||
// Extract all dates from input data
|
||||
// Extract all dates from post data
|
||||
$dates = array_column($updateTrpProductionDetails, 'Date');
|
||||
|
||||
//format from "d-m-Y" to db "Y-m-d" format
|
||||
$formattedDates = array_map(fn($date) => $this->convertToDateWithFlexibleFormats($date, ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d"), $dates);
|
||||
|
||||
// Fetch all existing records in a single query per table
|
||||
|
||||
|
||||
// Fetch all existing maintenance , production and waste records for the given formatted dates
|
||||
|
||||
$existingMaintenance = $this->TrpProductionMaintenance_model->whereIn('date', $formattedDates)->findAll();
|
||||
|
||||
$existingProduction = $this->TrpProduction_model->whereIn('date', $formattedDates)->findAll();
|
||||
|
||||
$existingWaste = $this->TrpProductionWaste_model->whereIn('date', $formattedDates)->findAll();
|
||||
|
||||
// Map existing records by date for quick lookup
|
||||
$existingMaintenanceMap = array_column($existingMaintenance, null, 'date');
|
||||
$existingProductionMap = array_column($existingProduction, null, 'date');
|
||||
$existingWasteMap = array_column($existingWaste, null, 'date');
|
||||
|
||||
//getting list of existing dates of maintenance , production and waste records
|
||||
|
||||
$existingMaintenanceDateList = array_column($existingMaintenance, null, 'date');
|
||||
|
||||
$existingProductionDateList = array_column($existingProduction, null, 'date');
|
||||
|
||||
$existingWasteDateList = array_column($existingWaste, null, 'date');
|
||||
|
||||
$insertMaintenance = [];
|
||||
|
||||
$updateMaintenance = [];
|
||||
$insertProduction = [];
|
||||
$updateProduction = [];
|
||||
$insertWaste = [];
|
||||
$updateWaste = [];
|
||||
$updateProduction = [];
|
||||
$updateWaste = [];
|
||||
|
||||
|
||||
$insertMaintenance = [];
|
||||
$insertProduction = [];
|
||||
$insertWaste = [];
|
||||
|
||||
|
||||
foreach ($updateTrpProductionDetails as $data) {
|
||||
|
||||
$date = $this->convertToDateWithFlexibleFormats($data['Date'], ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d");
|
||||
|
||||
// Data arrays
|
||||
$dbDataTrpMaintenance = [
|
||||
'date' => $date,
|
||||
'openingTime' => $data['openingTime'],
|
||||
'closingTime' => $data['closingTime'],
|
||||
'totalHours' => $data['totalHours'],
|
||||
'coldStart' => $data['coldStart'],
|
||||
'breakdownHours' => $data['breakdownHours'],
|
||||
'burnerFiringHours' => $data['burnerFiringHours'],
|
||||
'sandFeedingHours' => $data['sandFeedingHours'],
|
||||
'workingPersonEngineers' => $data['workingPersonEngineers'],
|
||||
'workingPersonSupervisiors' => $data['workingPersonSupervisiors'],
|
||||
'workingPersonOperators' => $data['workingPersonOperators'],
|
||||
'rollerDrivers' => $data['rollerDrivers'],
|
||||
'natureOfMaintenance' => $data['natureOfMaintenance'],
|
||||
'location' => $data['location'],
|
||||
'description' => $data['description']
|
||||
'date' => $date,
|
||||
'openingTime' => $data['openingTime'],
|
||||
'closingTime' => $data['closingTime'],
|
||||
'totalHours' => $data['totalHours'],
|
||||
'coldStart' => $data['coldStart'],
|
||||
'breakdownHours' => $data['breakdownHours'],
|
||||
'burnerFiringHours' => $data['burnerFiringHours'],
|
||||
'sandFeedingHours' => $data['sandFeedingHours'],
|
||||
'workingPersonEngineers' => $data['workingPersonEngineers'],
|
||||
'workingPersonSupervisiors' => $data['workingPersonSupervisiors'],
|
||||
'workingPersonOperators' => $data['workingPersonOperators'],
|
||||
'rollerDrivers' => $data['rollerDrivers'],
|
||||
'natureOfMaintenance' => $data['natureOfMaintenance'],
|
||||
'location' => $data['location'],
|
||||
'description' => $data['description']
|
||||
];
|
||||
|
||||
$dbDataTrpProduction = [
|
||||
'date' => $date,
|
||||
'gasReceiptBg' => $data['gasReceiptBg'],
|
||||
'gasReceiptPg' => $data['gasReceiptPg'],
|
||||
'physicalGasConsumption' => $data['physicalGasConsumption'],
|
||||
'trpPlusDrierGasConsumption' => $data['trpPlusDrierGasConsumption'],
|
||||
'trpPhysicalGasPerTon' => $data['trpPhysicalGasPerTon'],
|
||||
'panelGasConsumption' => $data['panelGasConsumption'],
|
||||
'panelGasPerTon' => $data['panelGasPerTon'],
|
||||
'edRunningHours' => $data['edRunningHours'],
|
||||
'edProduction' => $data['edProduction'],
|
||||
'edUsage' => $data['edUsage'],
|
||||
'trpProduction' => $data['trpProduction'],
|
||||
'trpProductionPerHour' => $data['trpProductionPerHour'],
|
||||
'waterReceipt' => $data['waterReceipt'],
|
||||
'waterConsumption' => $data['waterConsumption'],
|
||||
'ebReading' => $data['ebReading'],
|
||||
'ebReadingPerUnitTon' => $data['ebReadingPerUnitTon'],
|
||||
'date' => $date,
|
||||
'gasReceiptBg' => $data['gasReceiptBg'],
|
||||
'gasReceiptPg' => $data['gasReceiptPg'],
|
||||
'physicalGasConsumption' => $data['physicalGasConsumption'],
|
||||
'trpPlusDrierGasConsumption' => $data['trpPlusDrierGasConsumption'],
|
||||
'trpPhysicalGasPerTon' => $data['trpPhysicalGasPerTon'],
|
||||
'panelGasConsumption' => $data['panelGasConsumption'],
|
||||
'panelGasPerTon' => $data['panelGasPerTon'],
|
||||
'edRunningHours' => $data['edRunningHours'],
|
||||
'edProduction' => $data['edProduction'],
|
||||
'edUsage' => $data['edUsage'],
|
||||
'trpProduction' => $data['trpProduction'],
|
||||
'trpProductionPerHour' => $data['trpProductionPerHour'],
|
||||
'waterReceipt' => $data['waterReceipt'],
|
||||
'waterConsumption' => $data['waterConsumption'],
|
||||
'ebReading' => $data['ebReading'],
|
||||
'ebReadingPerUnitTon' => $data['ebReadingPerUnitTon'],
|
||||
];
|
||||
|
||||
$dbDataTrpWaste = [
|
||||
'date' => $date,
|
||||
'msSeperation' => $data['msSeperation'],
|
||||
'edWaste' => $data['edWaste'],
|
||||
'coolerBags' => $data['coolerBags'],
|
||||
'edPlus20Waste' => $data['edPlus20Waste'],
|
||||
'cycloneWaste' => $data['cycloneWaste'],
|
||||
'date' => $date,
|
||||
'msSeperation' => $data['msSeperation'],
|
||||
'edWaste' => $data['edWaste'],
|
||||
'coolerBags' => $data['coolerBags'],
|
||||
'edPlus20Waste' => $data['edPlus20Waste'],
|
||||
'cycloneWaste' => $data['cycloneWaste'],
|
||||
];
|
||||
|
||||
// Check if data already exists
|
||||
if (isset($existingMaintenanceMap[$date])) {
|
||||
$dbDataTrpMaintenance['id'] = $existingMaintenanceMap[$date]['id'];
|
||||
if (isset($existingMaintenanceDateList[$date])) {
|
||||
|
||||
$dbDataTrpMaintenance['id'] = $existingMaintenanceDateList[$date]['id'];
|
||||
$updateMaintenance[] = $dbDataTrpMaintenance;
|
||||
|
||||
} else {
|
||||
|
||||
$insertMaintenance[] = $dbDataTrpMaintenance;
|
||||
|
||||
}
|
||||
|
||||
if (isset($existingProductionMap[$date])) {
|
||||
$dbDataTrpProduction['id'] = $existingProductionMap[$date]['id'];
|
||||
if (isset($existingProductionDateList[$date])) {
|
||||
|
||||
$dbDataTrpProduction['id'] = $existingProductionDateList[$date]['id'];
|
||||
$updateProduction[] = $dbDataTrpProduction;
|
||||
|
||||
} else {
|
||||
$insertProduction[] = $dbDataTrpProduction;
|
||||
}
|
||||
|
||||
if (isset($existingWasteMap[$date])) {
|
||||
$dbDataTrpWaste['id'] = $existingWasteMap[$date]['id'];
|
||||
if (isset($existingWasteDateList[$date])) {
|
||||
|
||||
$dbDataTrpWaste['id'] = $existingWasteDateList[$date]['id'];
|
||||
$updateWaste[] = $dbDataTrpWaste;
|
||||
|
||||
} else {
|
||||
$insertWaste[] = $dbDataTrpWaste;
|
||||
}
|
||||
@ -3233,6 +3265,15 @@ class StockController extends BaseController
|
||||
$this->db->transBegin();
|
||||
|
||||
try {
|
||||
|
||||
// dd($updateMaintenance);
|
||||
// dd($updateProduction);
|
||||
// dd($updateWaste);
|
||||
|
||||
// dd($insertMaintenance);
|
||||
// dd($insertProduction);
|
||||
// dd($insertWaste);
|
||||
|
||||
// Insert new records in batch
|
||||
if (!empty($insertMaintenance)) {
|
||||
$this->TrpProductionMaintenance_model->insertBatch($insertMaintenance);
|
||||
@ -3272,6 +3313,7 @@ class StockController extends BaseController
|
||||
|
||||
|
||||
public function updateAbstractDetails() {
|
||||
|
||||
$updateAbstractDetails = json_decode($this->request->getPost('updateAbstractDetails'), true);
|
||||
|
||||
if (empty($updateAbstractDetails)) {
|
||||
|
||||
@ -533,7 +533,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label>Select Supplier</label>
|
||||
<label>Select Supplier</label><span class="text-danger"> * </span>
|
||||
<?php
|
||||
if (!empty($Suplist)) {
|
||||
foreach ($Suplist as $SID):
|
||||
@ -578,7 +578,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<b><u>Select Delivery By</u></b>
|
||||
<b><u>Select Delivery By</u></b><span class="text-danger"> * </span>
|
||||
<div style="display:inline-flex;">
|
||||
<div class="centered">
|
||||
<div id="dispatchinternational" style="display:none;">
|
||||
@ -594,7 +594,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="Schedulediv" style="display:none;">
|
||||
<label>Schedule By </label>
|
||||
<label>Schedule By </label><span class="text-danger"> * </span>
|
||||
<input type="hidden" name="beforeSchedule" value="<?php echo $DeliverSchedule; ?>">
|
||||
<?php
|
||||
$data = array('name' => 'Scheduleby', 'value' => set_value('Scheduleby', $DeliverSchedule), 'id' => 'Scheduleby', 'class' => 'form-control', 'required' => 'true', 'rows' => '3', 'cols' => '40', 'maxlength' => '110');
|
||||
@ -647,7 +647,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
|
||||
target="_blank"><u>(Click here)</u></a>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="ExchangeRateOnDiv" style="display:none;">
|
||||
<label>Exchange Rate On</label>
|
||||
<label>Exchange Rate On</label><span class="text-danger"> * </span>
|
||||
|
||||
<?php
|
||||
$data = array('type' => 'date', 'name' => 'Exchangerateon', 'value' => set_value('Exchangerateon', $ExchangeRateOn), 'id' => 'Exchangerateon', 'class' => 'form-control num', 'required' => 'true', 'onkeypress' => 'return false;');
|
||||
@ -656,7 +656,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="ExchangeRateDiv" style="display:none;">
|
||||
<label id="CurrencySymbol">Exchange Rate </label>
|
||||
<label id="CurrencySymbol">Exchange Rate </label><span class="text-danger"> * </span>
|
||||
|
||||
<?php
|
||||
$data = array('name' => 'ExchangeRt', 'value' => set_value('ExchangeRt', $exchangeRate), 'id' => 'ExchangeRt', 'class' => 'form-control', 'onkeypress' => 'return isNumberKey(event);', 'style' => 'text-align:right');
|
||||
@ -666,7 +666,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="placeoforgin">
|
||||
<label>Place of Origin</label>
|
||||
<label>Place of Origin</label><span class="text-danger"> * </span>
|
||||
|
||||
<?php
|
||||
// $data = array('name' => 'PlaceOforigin','value' => set_value('PlaceOforigin'),'id'=>'PlaceOforigin', 'class' => 'form-control' ,'required' => 'true', 'onkeypress'=>'return false;');
|
||||
@ -755,7 +755,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
|
||||
</div>
|
||||
<div class="form-group col-md-3"><input type="hidden" name="beforePaymentmethod"
|
||||
id="beforePaymentmethod" value="<?php echo $PaymentTerms; ?>">
|
||||
<label for="payablefrom">Payable Terms</label>
|
||||
<label for="payablefrom">Payable Terms</label><span class="text-danger"> * </span>
|
||||
<?php
|
||||
foreach ($Payment as $rl):
|
||||
|
||||
@ -1648,7 +1648,7 @@ if (!empty($POItem) && $CapitalRange == '1') {
|
||||
<input type="reset" class="btn btn-success" value="Reset">
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label id="lbl_international">Total Order Value <?php echo "($INR)" ?> </label>
|
||||
|
||||
@ -151,14 +151,6 @@
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.celda_encabezado_total {
|
||||
background-color:#ffffff !important;
|
||||
border: 1px solid #ffffff;
|
||||
color: #ffffff !important;
|
||||
font-weight: bold;
|
||||
padding: 6px 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.celda_normal {
|
||||
/*background-color: #fff;*/
|
||||
@ -349,6 +341,7 @@ $timeOtions[] = "12:00 AM";
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
|
||||
<table id="trpProductionStockDetailsTableId" class="fht-table table-striped">
|
||||
|
||||
<thead class="celda_encabezado_general" style="padding: 10px;">
|
||||
@ -443,7 +436,7 @@ $timeOtions[] = "12:00 AM";
|
||||
|
||||
<?php foreach($wcsSupplierList as $supplier){ ?>
|
||||
|
||||
<th class="celda_encabezado_general"><?=$supplier?> </th>
|
||||
<th class="celda_encabezado_general" style="min-width:200px !important;" ><?=$supplier?> </th>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
@ -465,7 +458,7 @@ $timeOtions[] = "12:00 AM";
|
||||
|
||||
<?php foreach($crsClientList as $client){ ?>
|
||||
|
||||
<th class="celda_encabezado_general"><?=$client?> </th>
|
||||
<th class="celda_encabezado_general" style="min-width:200px !important;"><?=$client?> </th>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
@ -1277,7 +1270,7 @@ $timeOtions[] = "12:00 AM";
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
|
||||
|
||||
<?php } ?>
|
||||
@ -1303,7 +1296,7 @@ $timeOtions[] = "12:00 AM";
|
||||
|
||||
</div>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user