diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 861406c1..e7814a96 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -426,6 +426,7 @@ $routes->post('updateCoatingMachineDetails','StockController::updateCoatingMachi
$routes->get('deleteCoatingMachineDetails' , 'StockController::deleteCoatingMachineDetails');
-$routes->get('drierMachineDetails' , 'StockController::drierMachineDetails');
+$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'drierMachineDetails', 'StockController::drierMachineDetails');
+$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'addOrEditdrierMachineDetails', 'StockController::addOrEditdrierMachineDetails');
diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php
index de98451a..aa0dcd83 100644
--- a/app/Controllers/StockController.php
+++ b/app/Controllers/StockController.php
@@ -123,4 +123,155 @@ class StockController extends BaseController
// --------------------------------------------gwm----------------------------------------------
+
+
+ function getMonthDatesFromInput($monthYear) {
+
+ $date = DateTime::createFromFormat('M-Y', $monthYear);
+
+ if (!$date) {
+ return "Invalid date format. Use 'M-yyyy' format.";
+ }
+
+ $year = $date->format('Y');
+ $month = $date->format('m');
+
+ $totalDays = cal_days_in_month(CAL_GREGORIAN, $month, $year);
+
+ $dates = [];
+ for ($day = 1; $day <= $totalDays; $day++) {
+
+ $currentDate = DateTime::createFromFormat('Y-m-d', "$year-$month-$day");
+
+ $dates[] = [
+ 'readable' => $currentDate->format('d-m-Y'),
+ 'database' => $currentDate->format('Y-m-d')
+ ];
+ }
+
+ return $dates;
+ }
+
+ function fillMissingDates($monthData, $drierDetails) {
+
+ $filledDetails = [];
+
+ $drierDetailsByDate = [];
+ foreach ($drierDetails as $detail) {
+ $drierDetailsByDate[$detail['date']] = $detail;
+ }
+
+ foreach ($monthData as $day) {
+ $date = $day['database'];
+
+ if (isset($drierDetailsByDate[$date])) {
+ $filledDetails[] = $drierDetailsByDate[$date];
+ } else {
+ $filledDetails[] = [
+ 'id' => null,
+ 'date' => $date,
+ 'drier_on_time' => null,
+ 'drier_off_time' => null,
+ 'drier_running_hours' => '0.00',
+ 'supplier_name' => null,
+ 'input_sand_moisture' => '0.00',
+ 'total_gas_consumption' => '0.00',
+ 'gas_per_ton' => '0.00',
+ 'input_sand_qty' => '0.00',
+ 'moisture_loss_qty' => '0.00',
+ 'sand_dried_qty' => '0.00',
+ 'qty_per_hours' => '0.00',
+ 'dust_qty' => '0.00',
+ 'customer_name' => null,
+ 'created_at' => null,
+ 'updated_at' => null
+ ];
+ }
+ }
+ return $filledDetails;
+ }
+
+ function generateTimeOptions() {
+ $times = [];
+ $start = strtotime('00:00'); // Start at midnight (12:00 AM)
+ $end = strtotime('23:45'); // End at 11:45 PM
+
+ while ($start <= $end) {
+ $timeValue = date('H:i', $start); // 24-hour format for value
+ $timeLabel = date('h:i A', $start); // 12-hour format with AM/PM for display
+ $times[$timeValue] = $timeLabel; // Store time in associative array
+ $start = strtotime('+15 minutes', $start); // Increment by 15 minutes
+ }
+
+ return $times;
+ }
+
+ function drierMachineDetails()
+ {
+
+
+ $currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y');
+
+ $monthData = $this->getMonthDatesFromInput($currentMonth);
+
+ $data['startDate'] = $monthData[0]['database'];
+ $data['endDate'] = $monthData[count($monthData)-1]['database'];
+ $data['timeDropdown'] = $this->generateTimeOptions();
+
+ $data['drierDetails'] = $this->drierMachineDetails_model
+ ->where('date >=', $data['startDate'])
+ ->where('date <=', $data['endDate'])
+ ->findAll();
+ $data['datefordropdown'] = $currentMonth;
+
+ $data['data'] = $this->fillMissingDates($monthData, $data['drierDetails']);
+
+
+ $this->global['pageTitle'] = 'Drier Details';
+ $this->loadViews("drierMachineDetails", $this->global, $data, NULL);
+ }
+
+ public function addOrEditdrierMachineDetails()
+ {
+ $drierData = json_decode($this->request->getPost('drierData'), true);
+
+ if (empty($drierData)) {
+ echo "No data received.";
+ return;
+ }
+
+ foreach ($drierData as $row) {
+ $data = [
+ 'date' => DateTime::createFromFormat('d-m-Y', $row['Date'])->format('Y-m-d'),
+ 'drier_on_time' => $row['Drier On Time'],
+ 'drier_off_time' => $row['Drier Off Time'],
+ 'drier_running_hours' => $row['Running Hrs'],
+ 'supplier_name' => $row['Supplier Name'],
+ 'input_sand_moisture' => $row['i/p Sand Moisture(%)'],
+ 'total_gas_consumption'=> $row['Tot Gas Consumption'],
+ 'gas_per_ton' => $row['Gas Pre Ton'],
+ 'input_sand_qty' => $row['i/p Sand Qty'],
+ 'moisture_loss_qty' => $row['Moisture Loss Qty'],
+ 'sand_dried_qty' => $row['Sand Dried Qty'],
+ 'qty_per_hours' => $row['Qty Per Hrs'],
+ 'dust_qty' => $row['Dust Qty'],
+ 'customer_name' => $row['Customer Name']
+ ];
+
+ // Check if a row with the same date already exists
+ $existingRow = $this->drierMachineDetails_model->where('date', $data['date'])->first();
+
+
+ if ($existingRow) {
+ // If exists, update the row
+ $this->drierMachineDetails_model->update($existingRow['id'], $data);
+ } else {
+ // If not, insert a new row
+ $this->drierMachineDetails_model->insert($data);
+ }
+ }
+
+ echo "Data successfully saved.";
+ }
+
}
diff --git a/app/Views/drierMachineDetails.php b/app/Views/drierMachineDetails.php
new file mode 100644
index 00000000..5af417c1
--- /dev/null
+++ b/app/Views/drierMachineDetails.php
@@ -0,0 +1,535 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Stocks
+ -
+
10 Ton Drier Details
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | S.NO |
+ Date |
+ Drier On Time |
+ Drier Off Time |
+ Running Hrs |
+ Supplier Name |
+ i/p Sand Moisture(%) |
+ Tot Gas Consumption |
+ Gas Pre Ton |
+ i/p Sand Qty |
+ Moisture Loss Qty |
+ Sand Dried Qty |
+ Qty Per Hrs |
+ Dust Qty |
+ Customer Name |
+
+
+
+
+
+
+
+
+
+ |
+ format('d-m-Y'); ?> |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file