FEATURE_COMPLAINT_MODEL_CONTROLLER_VIEW : AADHAVAN
This commit is contained in:
parent
0dfb590319
commit
21c62c0cd5
@ -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");
|
||||
|
||||
103
app/Controllers/Complaint.php
Normal file
103
app/Controllers/Complaint.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\ComplaintModel;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
|
||||
|
||||
class Complaint extends BaseController
|
||||
{
|
||||
|
||||
public $session;
|
||||
use ResponseTrait;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->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]);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@ -50,54 +50,43 @@ class Users extends BaseController
|
||||
|
||||
// Get the query parameters
|
||||
$queryParams = $uri->getQuery();
|
||||
|
||||
// echo "<pre>";
|
||||
// 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();
|
||||
|
||||
9
app/Models/ComplaintModel.php
Normal file
9
app/Models/ComplaintModel.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use CodeIgniter\Model;
|
||||
class ComplaintModel extends Model
|
||||
{
|
||||
protected $table = 'complaints';
|
||||
protected $primaryKey = 'complaint_id';
|
||||
protected $allowedFields = ['complaint_id','name','labour_charge','isactive'];
|
||||
}
|
||||
161
app/Views/complaint_list.php
Normal file
161
app/Views/complaint_list.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php include('layout/header.php'); ?>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<h4 class="page-title">Complaints List</h4>
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class=""> <a href="#" data-toggle="modal" data-target="#complaint-add-modal" class="btn btn-primary waves-effect" onclick="clearDetials(this)"> <i class="ri-add-line"></i></a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100"
|
||||
style="width:100% !important;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> Name</th>
|
||||
<th>Labour Charge</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($complaint as $value) : ?>
|
||||
<tr>
|
||||
<td><?= $value['name']; ?></td>
|
||||
<td><?= $value['labour_charge']; ?></td>
|
||||
<td>
|
||||
<?php if($value['isactive'] == 1): ?>
|
||||
<span style="color:green">Active</span>
|
||||
<?php else: ?>
|
||||
<span style="color:red">Inactive</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a data-toggle="modal" data-target="#complaint-add-modal" data-value="<?php echo $value['complaint_id']; ?>" onclick="editComplaint(this)" class="delete-button"><i class="ri-pencil-line" style="font-size: 20px;"></i></a>
|
||||
<a href="<?= "delete_complaint/" . $value['complaint_id']; ?>" class="delete-button"><i class="ri-delete-bin-line" style="font-size: 20px;"></i></a>
|
||||
|
||||
</td>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end table-responsive-->
|
||||
|
||||
</div>
|
||||
</div> <!-- end card -->
|
||||
</div> <!-- end col -->
|
||||
</div>
|
||||
|
||||
<div id="complaint-add-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-body">
|
||||
<div class="text-center mt-2 mb-4">
|
||||
<h4 id="form_add_edit">Add Complaint</h4>
|
||||
</div>
|
||||
|
||||
<form id="model_form_data" class="px-3">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Name </label>
|
||||
<input class="form-control" type="text" id="complaint_id" hidden>
|
||||
<input class="form-control" type="text" id="name" required="" placeholder="Name....">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="labour_charge">Labour Charge </label>
|
||||
<input class="form-control" type="text" id="labour_charge" required="" placeholder="Labour Charge....">
|
||||
</div>
|
||||
|
||||
<div class="form-group text-center">
|
||||
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitComplaint(this)">Submit</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
<?php include('layout/footer.php'); ?>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
function submitComplaint(params) {
|
||||
|
||||
if (!$('#name').val() || !$('#labour_charge').val()) {
|
||||
return false;
|
||||
}
|
||||
var formData = {
|
||||
name: $('#name').val(),
|
||||
labour_charge: $('#labour_charge').val(),
|
||||
};
|
||||
|
||||
var complaint_id = $('#complaint_id').val();
|
||||
|
||||
if (!complaint_id) {
|
||||
complaint_id = 0;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo base_url()."create_complaint/"?>' + complaint_id,
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
// $('#bike_model_login-modal').modal('hide');
|
||||
$('#name').val('');
|
||||
$('#labour_charge').val('');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function editComplaint(params) {
|
||||
|
||||
var complaint_id = $(params).data('value');
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '<?php echo base_url()."edit_complaint/"?>' + complaint_id,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
$('#form_add_edit').html(response.page_name)
|
||||
$('#complaint_id').val(response.complaint[0].complaint_id);
|
||||
$('#name').val(response.complaint[0].name);
|
||||
$('#labour_charge').val(response.complaint[0].labour_charge);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function clearDetials(params) {
|
||||
$('#form_add_edit').text('Add Complaint');
|
||||
|
||||
}
|
||||
</script>
|
||||
@ -63,7 +63,7 @@
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="name">Name</label>
|
||||
<input type="text" class="form-control" id="name" value="<?php echo $users['name']; ?>">
|
||||
<input type="text" class="form-control" id="name" name="name" value="<?php echo $users['name']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
@ -218,9 +218,7 @@
|
||||
}else{
|
||||
toastr.success(response.message, 'Success');
|
||||
|
||||
$('#old_password').val('');
|
||||
$('#new_password').val('');
|
||||
$('#confirm_password').val('');
|
||||
window.location.href = "<?php echo base_url().'log_out' ?>";
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -259,6 +259,13 @@
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<li>
|
||||
<a href="<?php echo base_url('complaint_index') ?>">
|
||||
<i class="fas fa-exclamation-circle"></i>
|
||||
<span>Complaints</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">Password</label>
|
||||
<input type="password" class="form-control" name="password" placeholder="Password" required>
|
||||
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputAddress" class="col-form-label">Mobile</label>
|
||||
@ -105,8 +105,16 @@
|
||||
$("#branch").append("<option value=''>Select Branch</option>");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var user_id = "<?php echo $user_id; ?>";
|
||||
|
||||
|
||||
if (user_id) {
|
||||
$('#password').prop('required' ,false);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user