diff --git a/app.zip b/app.zip
new file mode 100644
index 00000000..08b67b87
Binary files /dev/null and b/app.zip differ
diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php
index ea126722..6852a264 100644
--- a/app/Controllers/StockController.php
+++ b/app/Controllers/StockController.php
@@ -588,25 +588,62 @@ class StockController extends BaseController
$data['endDate'] = $monthData[count($monthData)-1]['database'];
$data['datefordropdown'] = $currentMonth;
+ //Machine Details
$data['machineDetails'] = $this->factoryMachine_model->where('energy_type', 'diesel')->where('is_active', 1)->findAll();
+ if(!count([$data['machineDetails']]))
+ {
+ return $this->response->setBody("");
+ }
- $data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model
- ->where('date >=', $data['startDate'])
- ->where('date <=', $data['endDate'])
- ->findAll();
+ //Diesel Stock Summary Details
+ $data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model->select('date,opening_stock as opening_stock_0,purchase_diesel as purchase_diesel_0,total_filling_diesel as total_filling_diesel_0,balance_stock as balance_stock_0')->where('date >=', $data['startDate'])->where('date <=', $data['endDate'])->findAll();
if(!count($data['summaryDetails']))
{
-
+ //insert empty data
+ $tempInsert = [];
+ foreach ($monthData as $key => $value) {
+ array_push($tempInsert,[ 'date'=>$value['database'] ]);
+ }
+ $this->factoryVehicleDieselStockSummary_model->insertBatch($tempInsert);
+
+ $data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model->where('date >=', $data['startDate'])->where('date <=', $data['endDate'])->findAll();
}
-
- $data['dieselConsumptionDetails'] = $this->getDieselConsumptionPivot($data['machineDetails'] , $data['startDate'] , $data['endDate']);
+ //Diesel Consumption Details
+ $data['dieselConsumptionDetails'] = $this->getDieselConsumptionPivot($data['machineDetails'] , $data['startDate'] , $data['endDate']);
+ if(!count($data['dieselConsumptionDetails']))
+ {
+ //insert empty data
+ $tempInsert = [];
+ foreach ($monthData as $key => $value) {
+ array_push($tempInsert,['date'=>$value['database'] , 'machine_id'=>$data['machineDetails'][0]['id'] ]);
+ }
+ $this->factoryVehicleDieselDetails_model->insertBatch($tempInsert);
+
+ $data['dieselConsumptionDetails'] = $this->getDieselConsumptionPivot($data['machineDetails'] , $data['startDate'] , $data['endDate']);
+ }
+
+
+ $mergedArray = [];
+
+ // Loop through the first array
+ foreach ($data['summaryDetails'] as $item1) {
+ $date = $item1["date"];
+
+ // Find the matching item in the second array by date
+ foreach ($data['dieselConsumptionDetails'] as $item2) {
+ if ($item2["date"] === $date) {
+ // Merge the two arrays
+ $mergedArray[] = array_merge($item1, $item2);
+ break; // Stop once the matching date is found
+ }
+ }
+ }
+ $data['dieselConsumptionDetails'] = $mergedArray;
+
$data['machineName'] = array_column($data['machineDetails'], 'machine_name');
$this->global['pageTitle'] = 'Drier Details';
- // this is a code that i want to see in $this->global aiyo pakurane ena nu solrathu
-
-
$this->loadViews("factoryDieselMachineDetails", $this->global, $data, NULL);
}
@@ -637,6 +674,66 @@ class StockController extends BaseController
return $result;
}
+
+ public function addOrEditfactoryVehicleDieselDetails()
+ {
+ $dieselMachineTableData = json_decode($this->request->getPost('dieselMachineTableData'), true);
+
+ $transformedData = [];
+ foreach ($dieselMachineTableData as $entry) {
+ $date = $entry['date'];
+
+ foreach ($entry as $key => $value) {
+
+ if ($key === 'date') { continue; }
+
+ preg_match('/(.*?)_(\d+)$/', $key, $matches);
+
+ if (count($matches) === 3) {
+ $field = $matches[1];
+ $machineId = $matches[2];
+
+ $insertKey = "{$date}_{$machineId}";
+ if (!isset($transformedData[$insertKey])) {
+ $transformedData[$insertKey] = [
+ 'date' => DateTime::createFromFormat('d-m-Y', $date)->format('Y-m-d'),
+ 'machine_id' => $machineId,
+ 'opening_reading' => 0.00,
+ 'closing_reading' => 0.00,
+ 'filling_diesel' => 0.00,
+ 'consumption' => 0.00,
+ 'running_hours' => 0.00,
+ 'mileage' => 0.00,
+ ];
+ }
+
+ $transformedData[$insertKey][$field] = (float) $value;
+ }
+ }
+ }
+
+
+
+ foreach ($transformedData as $row) {
+
+
+ // Check if a row with the same date already exists
+ $existingRow = $this->factoryVehicleDieselDetails_model->where('date', $row['date'])->where('machine_id', $row['machine_id'])->first();
+
+
+ if ($existingRow) {
+ // If exists, update the row
+ $this->factoryVehicleDieselDetails_model->update($existingRow['id'], $row);
+ } else {
+ // If not, insert a new row
+ $this->factoryVehicleDieselDetails_model->insert($row);
+ }
+ }
+
+
+ echo "Data successfully saved.";
+
+ }
}
diff --git a/app/Models/FactoryVehicleDieselStockSummaryModel.php b/app/Models/FactoryVehicleDieselStockSummaryModel.php
index b3b37486..98462a36 100644
--- a/app/Models/FactoryVehicleDieselStockSummaryModel.php
+++ b/app/Models/FactoryVehicleDieselStockSummaryModel.php
@@ -11,9 +11,9 @@ class FactoryVehicleDieselStockSummaryModel extends Model
protected $allowedFields = [
'date',
- 'opening',
+ 'opening_stock',
'purchase_diesel',
- 'filling_diesel',
+ 'total_filling_diesel',
'balance_stock'
];
diff --git a/app/Views/attendance.php b/app/Views/attendance.php
index f40922c6..de4c5678 100755
--- a/app/Views/attendance.php
+++ b/app/Views/attendance.php
@@ -177,6 +177,21 @@ $currentday = date('d');
.modal {
padding-right: 30% ! important;
}
+
+/* .fht-table th:nth-child(1),
+.fht-table td:nth-child(1),
+.fht-table th:nth-child(2),
+.fht-table td:nth-child(2),
+.fht-table th:nth-child(3),
+.fht-table td:nth-child(3)
+{
+ position: sticky;
+ left: 0;
+ background-color: #00a65a;
+ z-index: 2;
+ border-right: 2px solid #ddd;
+ color: #ffffff;
+} */
diff --git a/app/Views/factoryDieselMachineDetails.php b/app/Views/factoryDieselMachineDetails.php
index d0f7e101..46d456c9 100644
--- a/app/Views/factoryDieselMachineDetails.php
+++ b/app/Views/factoryDieselMachineDetails.php
@@ -1,176 +1,228 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -180,11 +232,11 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
-
+
- Stocks
-
-
Diesel - Factory Vehicle Details
+ Diesel - Factory Vehicle Details
@@ -201,28 +253,55 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
+
+
-
-
+
+
+
+
+
-
-
-
+
+
-
-
-
-
- |
-
- = $name; ?> |
-
-
-
+
-
-
-
- | = formatHeader($column) ?> |
-
-
-
+
+
+ |
+
+ Total Diesel |
+
+ = $name; ?> |
+
+
+
-
-
-
- $column): ?>
+
+
+
+ | = formatHeader($column) ?> |
+
+
+
+
+
+ $row): ?>
+
+ $column): ?>
- | format('d-m-Y'); ?> |
+
+ format('d-m-Y'); ?>
+ |
+
+
+ style="padding: 5px;">= $row[$column] ?? 'N/A' ?> |
+
+ = $row[$column] ?? 'N/A' ?> |
+
+ = $row[$column] ?? 'N/A' ?> |
+
+ = $row[$column] ?? 'N/A' ?> |
+
+
+ = $row[$column] ?? 'N/A' ?> |
+
+
+ = $row[$column] ?? 'N/A' ?> |
+
+
+ style="padding: 5px;">= $row[$column] ?? 'N/A' ?> |
+
+ = $row[$column] ?? 'N/A' ?> |
- = $row[$column] ?? 'N/A' ?> |
+
+ = $row[$column] ?? 'N/A' ?> |
+
+
-
-
-
+
-
+
-
+
-
-
+
@@ -301,49 +417,232 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
+
\ No newline at end of file