diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 8ee9346..30b618b 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -117,7 +117,7 @@ $routes->get('dashboard', 'Users::dashboard'); -//---------------------- Make And Model | Service | Manufacturer | Inventory->Purchase +//---------------------- Make And Model | Service | Manufacturer | Inventory->Purchase | Complaint // Make $routes->get('make_index', 'Make::index'); $routes->post('create_make', 'Make::create_make'); @@ -168,3 +168,11 @@ $routes->post("add_return_purchase", "ReturnOrder::add_return_purchase"); $routes->get('get_vendor/(:any)', 'Purchase::get_vendor/$1'); $routes->get('edit_return_order/(:any)', 'ReturnOrder::edit_return_order/$1'); + + + +// Complaint +$routes->get('complaint_index', 'Complaint::complaint_index'); +$routes->post('create_complaint/(:any)', 'Complaint::create_complaint/$1'); +$routes->get('edit_complaint/(:any)', 'Complaint::edit_complaint/$1'); +$routes->get("delete_complaint/(:any)", "Complaint::delete_complaint/$1"); diff --git a/app/Controllers/Complaint.php b/app/Controllers/Complaint.php new file mode 100644 index 0000000..bb1bf1a --- /dev/null +++ b/app/Controllers/Complaint.php @@ -0,0 +1,103 @@ +session = session(); + + } + + public function complaint_index() + { + if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } + + $ComplaintModel = new ComplaintModel(); + $complaint = $ComplaintModel->findAll(); + $data['complaint']=$complaint; + return view('complaint_list',$data); + } + + + public function create_complaint($complaint_id) + { + if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } + try { + if (!$complaint_id) { + $ComplaintModel = new ComplaintModel(); + $data = $this->request->getPost(); + $inserted = $ComplaintModel->insert($data); + if ($inserted) { + $result = $data; + return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } else { + $ComplaintModel = new ComplaintModel(); + $data = $this->request->getPost(); + $updated = $ComplaintModel->update($complaint_id,$data); + if ($updated) { + $result = $data; + return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500); + } + } + + + + public function edit_complaint($complaint_id) + { + + $data['page_name']= 'Edit Complaint'; + + $complaintModel = new ComplaintModel(); + + $complaint = $complaintModel->where('complaint_id',$complaint_id)->findAll(); + $data['complaint']=$complaint; + + return json_encode($data); + } + + + + public function delete_complaint($complaint_id) + { + + if (!empty($complaint_id)) { + $ComplaintModel = new ComplaintModel(); + $data['isactive'] = 0; + + if ($ComplaintModel->update($complaint_id, $data)) { + // Return success response + return redirect()->to('complaint_index'); + } + } + + // Return error response if deletion fails + return $this->response->setJSON(['success' => false]); +} + +} +?> \ No newline at end of file diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php index b56687d..4e2b591 100644 --- a/app/Controllers/Users.php +++ b/app/Controllers/Users.php @@ -50,54 +50,43 @@ class Users extends BaseController // Get the query parameters $queryParams = $uri->getQuery(); - - // echo "
";
- // print_r($queryParams);
- // die;
- // echo $user_id;die;
-
+
if ($user_id === '0') {
- $data['page_name'] = "Add User";
- $data['users'] = [];
$BusinessModel=new BusinessModel();
$BranchModel=new BranchModel();
$business=$BusinessModel->findAll();
$business_select = $BusinessModel->where('business_id',session()->get('logged_user_business_id'))->findAll();
-
$branch_list = $BranchModel->where('branch_id',session()->get('logged_user_branch_id'))->findAll();
- // print_r($business);die;
+
$rolemodel = new RoleModel();
-
$roles =$rolemodel->getRoles();
- // $data['business'] = $business;
+ $data['page_name'] = "Add User";
+ $data['users'] = [];
$data['business'] = $business_select;
$data['branch'] = $branch_list;
$data['roles'] = $roles;
} else if ($user_id !== '0') {
- $data['page_name'] = "Edit User";
+
$UsersModel = new UsersModel();
- $users=$UsersModel->getUserById($user_id);
- $BusinessModel=new BusinessModel();
- $BranchModel=new BranchModel();
- $business=$BusinessModel->findAll();
- $business_select = $BusinessModel->where('business_id',session()->get('logged_user_business_id'))->findAll();
-
+ $users=$UsersModel->getUserById($user_id);
+ $BusinessModel=new BusinessModel();
+ $BranchModel=new BranchModel();
+ $business=$BusinessModel->findAll();
+ $business_select = $BusinessModel->where('business_id',session()->get('logged_user_business_id'))->findAll();
+
+ $branch = $BranchModel->where('branch_id',$users['branch_id'])->findAll();
- $data['users']=$users;
+ $rolemodel = new RoleModel();
+ $roles =$rolemodel->getRoles();
- $branch = $BranchModel->where('branch_id',$users['branch_id'])->findAll();
-
- $data['branch'] = $branch;
- $data['business'] = $business_select;
- $rolemodel = new RoleModel();
-
- $roles =$rolemodel->getRoles();
-
- $data['roles'] = $roles;
-
+ $data['page_name'] = "Edit User";
+ $data['users']=$users;
+ $data['branch'] = $branch;
+ $data['business'] = $business_select;
+ $data['roles'] = $roles;
}
$data['user_id'] = $user_id;
@@ -280,10 +269,7 @@ class Users extends BaseController
$UsersModel = new UsersModel();
- $data = [
- 'email' => $this->request->getPost('email'),
- ];
-
+ $data = $this->request->getPost();
$UsersModel->update($user_id, $data);
$user_mail =$UsersModel->where('user_id',$user_id)->first();
diff --git a/app/Models/ComplaintModel.php b/app/Models/ComplaintModel.php
new file mode 100644
index 0000000..c427d0d
--- /dev/null
+++ b/app/Models/ComplaintModel.php
@@ -0,0 +1,9 @@
+
+
+
+
+
+ Complaints List
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Name
+ Labour Charge
+ Status
+ Actions
+
+
+
+
+
+
+ = $value['name']; ?>
+ = $value['labour_charge']; ?>
+
+
+ Active
+
+ Inactive
+
+
+
+
+ " class="delete-button">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/edit_account_form.php b/app/Views/edit_account_form.php
index b0ff460..335426a 100644
--- a/app/Views/edit_account_form.php
+++ b/app/Views/edit_account_form.php
@@ -63,7 +63,7 @@
-
+
@@ -218,9 +218,7 @@
}else{
toastr.success(response.message, 'Success');
- $('#old_password').val('');
- $('#new_password').val('');
- $('#confirm_password').val('');
+ window.location.href = "";
}
},
diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php
index abfb900..c581213 100644
--- a/app/Views/layout/header.php
+++ b/app/Views/layout/header.php
@@ -259,6 +259,13 @@
+
+
+
+
+ Complaints
+
+
diff --git a/app/Views/user_form.php b/app/Views/user_form.php
index a77c942..68aadb3 100644
--- a/app/Views/user_form.php
+++ b/app/Views/user_form.php
@@ -60,7 +60,7 @@
-
+
@@ -105,8 +105,16 @@
$("#branch").append("");
}
});
- });
+ });
+