CHNAGE_MAKE_EDIT : AADHAVAN

This commit is contained in:
aadhavan valli 2024-04-24 15:27:02 +05:30
parent 9da2c550b9
commit 0332f2c2dd
8 changed files with 171 additions and 190 deletions

View File

@ -117,62 +117,73 @@ $routes->get('dashboard', 'Users::dashboard');
//---------------------- Make And Model | Service | Manufacturer | Inventory->Purchase | Complaint
// Make
$routes->get('make_index', 'Make::index');
$routes->post('create_make', 'Make::create_make');
// Model
$routes->get('bike_model_index/(:any)', 'Model::index/$1');
$routes->post('create_model', 'Model::create_model');
$routes->post('status_model', 'Model::status_model');
// Service
$routes->get('service_index', 'Service::service_index');
$routes->get("new_service/(:any)", "Service::new_service/$1");
$routes->post("add_service", "Service::add_service");
$routes->post("get_models_service", "Service::get_models");
$routes->get("delete_service/(:any)", "Service::delete_service/$1");
//Spare manufacturer
$routes->get('spare_manufacturer_index', 'Manufacturer::index'); //---------------------- Make And Model | Service | Manufacturer | Inventory->Purchase
$routes->post('create_manufacturer', 'Manufacturer::create_manufacturer'); //---------------------- Reorder Level | Return Order | Complaint
// Make //
$routes->get('make_index', 'Make::index');
$routes->post('create_make/(:any)', 'Make::create_make/$1');
// Make End's //
// Purchase // Model //
$routes->get('bike_model_index/(:any)', 'Model::index/$1');
$routes->post('create_model', 'Model::create_model');
$routes->post('status_model', 'Model::status_model');
// Model End's//
// Service //
$routes->get('service_index', 'Service::service_index');
$routes->get("new_service/(:any)", "Service::new_service/$1");
$routes->post("add_service", "Service::add_service");
$routes->post("get_models_service", "Service::get_models");
$routes->get("delete_service/(:any)", "Service::delete_service/$1");
// Service End's//
//Spare manufacturer//
$routes->get('spare_manufacturer_index', 'Manufacturer::index');
$routes->post('create_manufacturer', 'Manufacturer::create_manufacturer');
//Spare manufacturer End's//
// Purchase//
$routes->get('purchase_index', 'Purchase::purchase_index');
$routes->get("new_purchase/(:any)", "Purchase::new_purchase/$1");
$routes->get('get_vendor/(:any)', 'Purchase::get_vendor/$1');
$routes->post("add_purchase", "Purchase::add_purchase");
$routes->get("delete_purchase/(:any)", "Purchase::delete_purchase/$1");
$routes->post("getVendorProducts", "Purchase::getVendorProducts");
$routes->post("delete_purchase_product", "Purchase::delete_purchase_product");
$routes->get("download_purchase_invoice/(:any)", "Purchase::download_purchase_invoice/$1");
$routes->get("reorder_purchase/(:any)", "Purchase::reorder_purchase/$1");
// Purchase End's//
$routes->get('purchase_index', 'Purchase::purchase_index');
$routes->get("new_purchase/(:any)", "Purchase::new_purchase/$1");
$routes->get('get_vendor/(:any)', 'Purchase::get_vendor/$1');
$routes->post("add_purchase", "Purchase::add_purchase");
$routes->get("delete_purchase/(:any)", "Purchase::delete_purchase/$1");
$routes->post("getVendorProducts", "Purchase::getVendorProducts");
$routes->post("delete_purchase_product", "Purchase::delete_purchase_product");
$routes->get("download_purchase_invoice/(:any)", "Purchase::download_purchase_invoice/$1");
$routes->get("reorder_purchase/(:any)", "Purchase::reorder_purchase/$1");
// Reorder Level// // Reorder Level//
$routes->get('reorder_level_index', 'Reorderlevel::reorder_level_index'); $routes->get('reorder_level_index', 'Reorderlevel::reorder_level_index');
$routes->get('rise_order/(:any)', 'Reorderlevel::rise_order/$1'); $routes->get('rise_order/(:any)', 'Reorderlevel::rise_order/$1');
// Reorder Level//
// Return Order// // Return Order//
$routes->get('return_order_index', 'ReturnOrder::return_order_index'); $routes->get('return_order_index', 'ReturnOrder::return_order_index');
$routes->get('return_order', 'ReturnOrder::return_order'); $routes->get('return_order', 'ReturnOrder::return_order');
$routes->get("new_return/(:any)", "ReturnOrder::new_return/$1"); $routes->get("new_return/(:any)", "ReturnOrder::new_return/$1");
$routes->post("add_return_purchase", "ReturnOrder::add_return_purchase"); $routes->post("add_return_purchase", "ReturnOrder::add_return_purchase");
$routes->get('get_vendor/(:any)', 'Purchase::get_vendor/$1'); $routes->get('get_vendor/(:any)', 'Purchase::get_vendor/$1');
$routes->get('edit_return_order/(:any)', 'ReturnOrder::edit_return_order/$1');
$routes->get('edit_return_order/(:any)', 'ReturnOrder::edit_return_order/$1'); // Return Order End's//
// Complaint // Complaint
$routes->get('complaint_index', 'Complaint::complaint_index'); $routes->get('complaint_index', 'Complaint::complaint_index');
$routes->post('create_complaint/(:any)', 'Complaint::create_complaint/$1'); $routes->post('create_complaint/(:any)', 'Complaint::create_complaint/$1');
$routes->get('edit_complaint/(:any)', 'Complaint::edit_complaint/$1'); $routes->get('edit_complaint/(:any)', 'Complaint::edit_complaint/$1');
$routes->get("delete_complaint/(:any)", "Complaint::delete_complaint/$1"); $routes->get("delete_complaint/(:any)", "Complaint::delete_complaint/$1");
// Complaint End's//

View File

@ -5,33 +5,26 @@ namespace App\Controllers;
use App\Models\ComplaintModel; use App\Models\ComplaintModel;
use CodeIgniter\API\ResponseTrait; use CodeIgniter\API\ResponseTrait;
class Complaint extends BaseController class Complaint extends BaseController
{ {
public $session; public $session;
use ResponseTrait; use ResponseTrait;
public function __construct() public function __construct()
{ {
$this->session = session();
$this->session = session();
} }
public function complaint_index() public function complaint_index()
{ {
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
$ComplaintModel = new ComplaintModel(); $ComplaintModel = new ComplaintModel();
$complaint = $ComplaintModel->findAll(); $complaint = $ComplaintModel->findAll();
$data['complaint']=$complaint; $data['complaint']=$complaint;
return view('complaint_list',$data); return view('complaint_list',$data);
} }
public function create_complaint($complaint_id) public function create_complaint($complaint_id)
{ {
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
@ -65,39 +58,31 @@ class Complaint extends BaseController
} }
} }
public function edit_complaint($complaint_id) public function edit_complaint($complaint_id)
{ {
$data['page_name']= 'Edit Complaint';
$complaintModel = new ComplaintModel(); $complaintModel = new ComplaintModel();
$complaint = $complaintModel->where('complaint_id',$complaint_id)->findAll(); $complaint = $complaintModel->where('complaint_id',$complaint_id)->findAll();
$data['complaint']=$complaint;
$data['page_name']= 'Edit Complaint';
$data['complaint']=$complaint;
return json_encode($data); return json_encode($data);
} }
public function delete_complaint($complaint_id) public function delete_complaint($complaint_id)
{ {
if (!empty($complaint_id)) { if (!empty($complaint_id)) {
$ComplaintModel = new ComplaintModel(); $ComplaintModel = new ComplaintModel();
$data['isactive'] = 0; $data['isactive'] = 0;
if ($ComplaintModel->update($complaint_id, $data)) { if ($ComplaintModel->update($complaint_id, $data)) {
// Return success response // Return success response
return redirect()->to('complaint_index'); return redirect()->to('complaint_index');
}
} }
}
// Return error response if deletion fails // Return error response if deletion fails
return $this->response->setJSON(['success' => false]); return $this->response->setJSON(['success' => false]);
} }
} }
?> ?>

View File

@ -31,7 +31,7 @@ class Make extends BaseController
public function create_make() public function create_make($make_id)
{ {
try { try {
$make_name = $this->request->getPost('makename'); $make_name = $this->request->getPost('makename');
@ -39,13 +39,24 @@ class Make extends BaseController
$data = [ $data = [
'make' => $make_name 'make' => $make_name
]; ];
$inserted = $BikemakeModel->insert($data); if (!$make_id) {
if ($inserted) { $inserted = $BikemakeModel->insert($data);
$result = $data; if ($inserted) {
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); $result = $data;
} else { return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
$result = "No Match's"; } else {
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); $result = "No Match's";
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404);
}
}else{
$updated = $BikemakeModel->update($make_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) { } catch (\Exception $e) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500); return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500);

View File

@ -21,7 +21,6 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<!-- <h4 class="header-title">Business List</h4> --> <!-- <h4 class="header-title">Business List</h4> -->
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;text-align: center;width: 100%;"> <table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;text-align: center;width: 100%;">
<thead> <thead>
<tr> <tr>
@ -30,7 +29,6 @@
<th>Action</th> <th>Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($model as $item): ?> <?php foreach ($model as $item): ?>
<tr> <tr>
@ -55,9 +53,7 @@
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
</div> <!-- end table-responsive--> </div> <!-- end table-responsive-->
</div> </div>
</div> <!-- end card --> </div> <!-- end card -->
</div> <!-- end col --> </div> <!-- end col -->
@ -65,36 +61,35 @@
<!-- Start Bike Model Create Pop-UP -->
<!-- Start Bike Model Create Pop-UP --> <div id="bike_model_login-modal_1" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div id="bike_model_login-modal_1" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog">
<div class="modal-dialog"> <div class="modal-content">
<div class="modal-content"> <div class="modal-body">
<div class="modal-body"> <div class="text-center mt-2 mb-4">
<div class="text-center mt-2 mb-4"> <h4 id="form_add_edit">Add Models</h4>
<h4 id="form_add_edit">Add Models</h4> </div>
<form id="model_form_data" class="px-3">
<div class="form-group">
<input class="form-control" type="text" id="make_id" required="" value="<?php echo $make_id; ?>" placeholder="Make Name...." style="display:none;">
<label for="makename">Make Name </label>
<input class="form-control" type="text" id="makename" required="" value="<?php echo $make_name; ?>" placeholder="Make Name...." disabled>
<label for="modelname">Model Name </label>
<input class="form-control" type="text" id="modelname" required="" placeholder="Model Name....">
</div> </div>
<form id="model_form_data" class="px-3"> <div class="form-group text-center">
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitModels(this)">Submit</button>
</div>
<div class="form-group"> </form>
<input class="form-control" type="text" id="make_id" required="" value="<?php echo $make_id; ?>" placeholder="Make Name...." style="display:none;">
<label for="makename">Make Name </label>
<input class="form-control" type="text" id="makename" required="" value="<?php echo $make_name; ?>" placeholder="Make Name...." disabled>
<label for="modelname">Model Name </label>
<input class="form-control" type="text" id="modelname" required="" placeholder="Model Name....">
</div>
<div class="form-group text-center"> </div>
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitModels(this)">Submit</button> </div><!-- /.modal-content -->
</div> </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- End Bike Model Create Pop-UP --> <!-- End Bike Model Create Pop-UP -->
<?php include('layout/footer.php'); ?> <?php include('layout/footer.php'); ?>

View File

@ -1,13 +1,12 @@
<?php include('layout/header.php'); ?> <?php include('layout/header.php'); ?>
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="page-title-box page-title-box-alt"> <div class="page-title-box page-title-box-alt">
<h4 class="page-title">Complaints List</h4> <h4 class="page-title">Complaints List</h4>
<div class="page-title-right"> <div class="page-title-right">
<ol class="breadcrumb m-0"> <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 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>
</li>
</ol> </ol>
</div> </div>
</div> </div>
@ -17,8 +16,7 @@
<div class="col-lg-12"> <div class="col-lg-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100" <table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100" style="width:100% !important;">
style="width:100% !important;">
<thead> <thead>
<tr> <tr>
<th> Name</th> <th> Name</th>
@ -30,72 +28,60 @@
</thead> </thead>
<tbody> <tbody>
<?php foreach ($complaint as $value) : ?> <?php foreach ($complaint as $value) : ?>
<tr> <tr>
<td><?= $value['name']; ?></td> <td><?= $value['name']; ?></td>
<td><?= $value['labour_charge']; ?></td> <td><?= $value['labour_charge']; ?></td>
<td> <td>
<?php if($value['isactive'] == 1): ?> <?php if($value['isactive'] == 1): ?>
<span style="color:green">Active</span> <span style="color:green">Active</span>
<?php else: ?> <?php else: ?>
<span style="color:red">Inactive</span> <span style="color:red">Inactive</span>
<?php endif; ?> <?php endif; ?>
</td> </td>
<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="<?= "delete_complaint/" . $value['complaint_id']; ?>" class="delete-button"><i class="ri-delete-bin-line" style="font-size: 20px;"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="<?= "delete_complaint/" . $value['complaint_id']; ?>" class="delete-button"><i class="ri-delete-bin-line" style="font-size: 20px;"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</td>
<?php endforeach; ?> <?php endforeach; ?>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> <!-- end table-responsive--> </div> <!-- end table-responsive-->
</div> </div>
</div> <!-- end card --> </div> <!-- end card -->
</div> <!-- end col --> </div> <!-- end col -->
</div> </div>
<div id="complaint-add-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"> <!-- /.modal -->
<div class="modal-dialog"> <div id="complaint-add-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content"> <div class="modal-dialog">
<div class="modal-body"> <div class="modal-content">
<div class="text-center mt-2 mb-4"> <div class="modal-body">
<h4 id="form_add_edit">Add Complaint</h4> <div class="text-center mt-2 mb-4">
</div> <h4 id="form_add_edit">Add Complaint</h4>
<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>
</div><!-- /.modal-content --> <form id="model_form_data" class="px-3">
</div><!-- /.modal-dialog --> <div class="form-group">
</div><!-- /.modal --> <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'); ?> <?php include('layout/footer.php'); ?>
<script> <script>
function submitComplaint(params) { function submitComplaint(params) {
if (!$('#name').val() || !$('#labour_charge').val()) { if (!$('#name').val() || !$('#labour_charge').val()) {
return false; return false;
} }
@ -103,13 +89,10 @@
name: $('#name').val(), name: $('#name').val(),
labour_charge: $('#labour_charge').val(), labour_charge: $('#labour_charge').val(),
}; };
var complaint_id = $('#complaint_id').val(); var complaint_id = $('#complaint_id').val();
if (!complaint_id) { if (!complaint_id) {
complaint_id = 0; complaint_id = 0;
} }
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '<?php echo base_url()."create_complaint/"?>' + complaint_id, url: '<?php echo base_url()."create_complaint/"?>' + complaint_id,
@ -129,12 +112,8 @@
} }
function editComplaint(params) { function editComplaint(params) {
var complaint_id = $(params).data('value'); var complaint_id = $(params).data('value');
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '<?php echo base_url()."edit_complaint/"?>' + complaint_id, url: '<?php echo base_url()."edit_complaint/"?>' + complaint_id,
@ -156,6 +135,6 @@
function clearDetials(params) { function clearDetials(params) {
$('#form_add_edit').text('Add Complaint'); $('#form_add_edit').text('Add Complaint');
} }
</script> </script>

View File

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>Mechanic</title> <title>Mechanic</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">

View File

@ -34,7 +34,7 @@
<tr> <tr>
<td class="make"><?php echo $item['make']; ?></td> <td class="make"><?php echo $item['make']; ?></td>
<td> <td>
<a data-toggle="modal" data-target="#bike_make_login-modal" value="<?php echo $item['make_id']; ?>" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line"></i></a> <a data-toggle="modal" data-target="#bike_make_login-modal" data-value="<?php echo $item['make_id']; ?>" class="edit-button" onclick="editMake(this)"><i class="ri-pencil-line"></i></a>
<a href="#" data-toggle="modal" data-target="#bike_model_login-modal" style="margin-left: 12px;" class="add-button" title="Add" data-id="<?php echo $item['make_id']; ?>" data-value="<?php echo $item['make']; ?>" onclick="setMakeName(this)"> <a href="#" data-toggle="modal" data-target="#bike_model_login-modal" style="margin-left: 12px;" class="add-button" title="Add" data-id="<?php echo $item['make_id']; ?>" data-value="<?php echo $item['make']; ?>" onclick="setMakeName(this)">
<i class="ri-add-line icon-large"></i> <i class="ri-add-line icon-large"></i>
@ -66,6 +66,7 @@
<div class="form-group"> <div class="form-group">
<label for="makename">Make Name </label> <label for="makename">Make Name </label>
<input type="text" id="edit_make_id" hidden>
<input class="form-control" type="text" id="bike_make_name" required="" placeholder="Make Name...."> <input class="form-control" type="text" id="bike_make_name" required="" placeholder="Make Name....">
</div> </div>
@ -155,9 +156,15 @@
makename: $('#bike_make_name').val() makename: $('#bike_make_name').val()
}; };
var edit_make_id = $('#edit_make_id').val();
if (!edit_make_id) {
edit_make_id =0;
}
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: 'create_make', url: 'create_make/'+edit_make_id,
data: formData, data: formData,
dataType: 'json', dataType: 'json',
success: function(response) { success: function(response) {
@ -174,6 +181,8 @@
function editMake(params) { function editMake(params) {
$('#edit_make_id').val($(params).data('value'));
$('#form_add_edit').text('Edit Bike Make'); $('#form_add_edit').text('Edit Bike Make');
var full_div = $(params).parent().parent()[0]; var full_div = $(params).parent().parent()[0];

View File

@ -6,9 +6,7 @@
<h4 class="page-title">Vehicle List</h4> <h4 class="page-title">Vehicle List</h4>
<div class="page-title-right"> <div class="page-title-right">
<ol class="breadcrumb m-0"> <ol class="breadcrumb m-0">
<li class=""> <a href="<?= base_url() . "new_vehicle/0"; ?>" class="btn btn-primary waves-effect"> <i class="ri-add-line"></i></a> <li class=""> <a href="<?= base_url() . "new_vehicle/0"; ?>" class="btn btn-primary waves-effect"> <i class="ri-add-line"></i></a></li>
</li>
</ol> </ol>
</div> </div>
</div> </div>
@ -19,15 +17,9 @@
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<!-- <h4 class="header-title">Business List</h4> --> <!-- <h4 class="header-title">Business List</h4> -->
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100" <table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100"
style="width:100% !important;"> style="width:100% !important;">
<thead> <thead>
<tr> <tr>
<th>Reg No</th> <th>Reg No</th>
<th>Make & Model</th> <th>Make & Model</th>
@ -39,7 +31,6 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($vehicle as $value) : <?php foreach ($vehicle as $value) :
if ($value['isactive'] == 1) : ?> if ($value['isactive'] == 1) : ?>