diff --git a/app/Controllers/FactoryMachineController.php b/app/Controllers/FactoryMachineController.php index 0e6155e5..ba5025be 100644 --- a/app/Controllers/FactoryMachineController.php +++ b/app/Controllers/FactoryMachineController.php @@ -45,11 +45,9 @@ class FactoryMachineController extends BaseController $data = $this->factoryMachineMaster_model->insert($postData); - - - $this->readFactoryMachineMasterDetails(); + return redirect()->to('/readFactoryMachineMasterDetails'); - //check above data is successfully created. + @@ -83,16 +81,12 @@ class FactoryMachineController extends BaseController public function readFactoryMachineMasterDetails(){ - - - $this->global['pageTitle'] = 'Factory Machine Master Details '; + $this->global['pageTitle'] = 'Factory Machine Master Details'; $data['masterData'] = $this->factoryMachineMaster_model->where('is_active', 1)->findAll(); return $this->loadViews("factoryMachineMasterDetails", $this->global, $data, NULL); - - } public function readFactoryMachineMasterDetailsById(){ @@ -111,7 +105,7 @@ class FactoryMachineController extends BaseController $this->global['pageTitle'] = 'Edit Factory Machine Master Detail '; - $id = $this->request->getPost('id'); + $id = $this->request->getGet('id'); $postData=[ 'machine_name'=> $this->request->getPost('machineName'), @@ -119,9 +113,17 @@ class FactoryMachineController extends BaseController 'energy_type' => $this->request->getPost('energyType'), ]; - $data = $this->factoryMachineMaster_model->update($id,$postData); + $updated = $this->factoryMachineMaster_model->update($id,$postData); - $this->readFactoryMachineMasterDetails(); + + + if ($updated) { + // Set flashdata for success message + return redirect()->to('/readFactoryMachineMasterDetails')->with('success', 'Machine details updated successfully'); + } else { + // Set flashdata for error message + return redirect()->back()->with('error', 'Failed to update machine details'); + } diff --git a/app/Views/factoryMachineMasterDetailsCreate.php b/app/Views/factoryMachineMasterDetailsCreate.php index 4858a6ec..da538921 100644 --- a/app/Views/factoryMachineMasterDetailsCreate.php +++ b/app/Views/factoryMachineMasterDetailsCreate.php @@ -54,7 +54,7 @@ $energyType=$masterData['energy_type']??'';