Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic
This commit is contained in:
commit
4029e4e1e4
@ -85,7 +85,7 @@ $routes->get('dashboard', 'Users::dashboard');
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------- Make And Model // Service
|
//---------------------- Make And Model | Service | Spare Manufacturer and Category
|
||||||
// Make
|
// Make
|
||||||
$routes->get('make_index', 'Make::index');
|
$routes->get('make_index', 'Make::index');
|
||||||
$routes->post('create_make', 'Make::create_make');
|
$routes->post('create_make', 'Make::create_make');
|
||||||
@ -103,3 +103,16 @@ $routes->get("new_service/(:any)", "Service::new_service/$1");
|
|||||||
$routes->post("add_service", "Service::add_service");
|
$routes->post("add_service", "Service::add_service");
|
||||||
$routes->post("get_models_service", "Service::get_models");
|
$routes->post("get_models_service", "Service::get_models");
|
||||||
$routes->get("delete_service/(:any)", "Service::delete_service/$1");
|
$routes->get("delete_service/(:any)", "Service::delete_service/$1");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Spare manufacturer
|
||||||
|
|
||||||
|
$routes->get('spare_manufacturer_index', 'SpareManufacturer::index');
|
||||||
|
$routes->post('create_spare_manufacturer', 'SpareManufacturer::create_make');
|
||||||
|
|
||||||
|
//Spare category
|
||||||
|
|
||||||
|
$routes->get('spare_category_index/(:any)', 'SpareCategory::index/$1');
|
||||||
|
$routes->post('create_model', 'SpareCategory::create_model');
|
||||||
|
$routes->post('status_model', 'SpareCategory::status_model');
|
||||||
@ -44,14 +44,24 @@ class Products extends BaseController
|
|||||||
$data['page_name']="Add Product";
|
$data['page_name']="Add Product";
|
||||||
} else if ($product_id !== '0') {
|
} else if ($product_id !== '0') {
|
||||||
$data['page_name']="Edit Product";
|
$data['page_name']="Edit Product";
|
||||||
|
$ProductModel = new ProductModel();
|
||||||
|
$products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
|
||||||
|
|
||||||
|
$data['products']=$products;
|
||||||
|
|
||||||
$BikemakeModel = new BikemakeModel();
|
$BikemakeModel = new BikemakeModel();
|
||||||
$data['make'] = $BikemakeModel->findAll();
|
$data['make'] = $BikemakeModel->findAll();
|
||||||
$ProductModel = new ProductModel();
|
$BikemodelsModel = new BikemodelsModel();
|
||||||
|
$make_id = $products['make_id'];
|
||||||
|
$data['models'] = $BikemodelsModel->where('make_id', $make_id)->findAll();
|
||||||
|
|
||||||
$tax=$ProductModel->getTax();
|
$tax=$ProductModel->getTax();
|
||||||
$data['tax']=$tax;
|
$data['tax']=$tax;
|
||||||
|
$VendorModel = new VendorModel();
|
||||||
|
$data['vendors']=$VendorModel->findAll();
|
||||||
|
|
||||||
$products=$ProductModel->where('product_id', $product_id)->get()->getRowArray();
|
|
||||||
$data['products']=$products;
|
// print_r($data);die;
|
||||||
}
|
}
|
||||||
$data['product_id'] = $product_id;
|
$data['product_id'] = $product_id;
|
||||||
|
|
||||||
|
|||||||
@ -71,7 +71,7 @@ $vehicles = $VehicleModel->where('isactive',1)->where('vehicle_id',$sales['vehic
|
|||||||
->where('branch_id',$this->session->get('logged_user_branch_id'))
|
->where('branch_id',$this->session->get('logged_user_branch_id'))
|
||||||
->first();
|
->first();
|
||||||
$makeId = $vehicles['make'];
|
$makeId = $vehicles['make'];
|
||||||
$modelId = $vehicles['model'];
|
$modelId = $vehicle['model'];
|
||||||
|
|
||||||
// Encode the modelId before searching
|
// Encode the modelId before searching
|
||||||
$encodedModelId = json_encode([$modelId]);
|
$encodedModelId = json_encode([$modelId]);
|
||||||
|
|||||||
55
app/Controllers/SpareManufacturer.php
Normal file
55
app/Controllers/SpareManufacturer.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers;
|
||||||
|
|
||||||
|
use App\Models\SpareManufacturerModel;
|
||||||
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
|
|
||||||
|
class SpareManufacturer extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
public $session;
|
||||||
|
use ResponseTrait;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->session = session();
|
||||||
|
$this->SpareManufacturerModel = new SpareManufacturerModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
|
||||||
|
$SpareManufacturerModel = new SpareManufacturerModel();
|
||||||
|
$spare_manufacturer = $SpareManufacturerModel->findAll();
|
||||||
|
$data['spare_manufacturer']=$spare_manufacturer;
|
||||||
|
|
||||||
|
return view('spare_manufacturer_list',$data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function create_make()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$make_name = $this->request->getPost('makename');
|
||||||
|
$SpareManufacturerModel = new SpareManufacturerModel();
|
||||||
|
$data = [
|
||||||
|
'make' => $make_name
|
||||||
|
];
|
||||||
|
$inserted = $SpareManufacturerModel->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);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
11
app/Models/SpareManufacturerModel.php
Normal file
11
app/Models/SpareManufacturerModel.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Models;
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
class SpareManufacturerModel extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'spare_manufacturer';
|
||||||
|
protected $primaryKey = 'spare_manufacturer_id';
|
||||||
|
protected $allowedFields = ['spare_manufacturer_id','manufacturer_name','isactive','quantity'];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -165,6 +165,13 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
<li>
|
||||||
|
<a href="<?php echo base_url('spare_manufacturer_index') ?>">
|
||||||
|
<i class="fas fa-cogs"></i>
|
||||||
|
<span> Spare </span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
<?php if(session()->get('logged_user_role') == 'Floor Manager' ||
|
<?php if(session()->get('logged_user_role') == 'Floor Manager' ||
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php include('layout/header.php'); ?>
|
<?php include('layout/header.php'); ?>
|
||||||
|
|
||||||
<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">
|
||||||
@ -27,9 +28,12 @@
|
|||||||
<label for="make" class="col-form-label">Make<span class="text-danger">*</span></label>
|
<label for="make" class="col-form-label">Make<span class="text-danger">*</span></label>
|
||||||
<select class="form-control SelExample" id="make" name="make" required>
|
<select class="form-control SelExample" id="make" name="make" required>
|
||||||
<option value="">Select a Make</option>
|
<option value="">Select a Make</option>
|
||||||
|
|
||||||
<!-- Options for make -->
|
<!-- Options for make -->
|
||||||
<?php foreach ($make as $value): ?>
|
<?php foreach ($make as $value): ?>
|
||||||
<option value="<?= $value['make_id'] ?>" <?= isset($vendor['make_ids']) && in_array($value['make_id'], $vendor['make_ids']) ? 'selected' : '' ?>><?= $value['make'] ?></option>
|
<option value="<?= $value['make_id'] ?>" <?= isset($products['make_id']) && $products['make_id'] == $value['make_id'] ? 'selected' : '' ?>>
|
||||||
|
<?= $value['make'] ?>
|
||||||
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -37,8 +41,16 @@
|
|||||||
<label for="model" class="col-form-label">Model<span class="text-danger">*</span></label>
|
<label for="model" class="col-form-label">Model<span class="text-danger">*</span></label>
|
||||||
<select class="form-control SelExample" id="model" name="model[]" required multiple>
|
<select class="form-control SelExample" id="model" name="model[]" required multiple>
|
||||||
<!-- Options for model will be populated dynamically via AJAX -->
|
<!-- Options for model will be populated dynamically via AJAX -->
|
||||||
|
<?php if(isset($models) && !empty($models)): ?>
|
||||||
|
<?php foreach($models as $model): ?>
|
||||||
|
<option value="<?= $model['model_id'] ?>" <?= isset($products['models_id']) && in_array($model['model_id'], json_decode($products['models_id'], true)) ? 'selected' : '' ?>>
|
||||||
|
<?= $model['model_name'] ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputEmail4" class="col-form-label">Product Name<span class="text-danger">*</span></label>
|
<label for="inputEmail4" class="col-form-label">Product Name<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" name="productname" placeholder="Product Name" value="<?= isset($products['product_name']) ? $products['product_name'] : '' ?>" required>
|
<input type="text" class="form-control" name="productname" placeholder="Product Name" value="<?= isset($products['product_name']) ? $products['product_name'] : '' ?>" required>
|
||||||
@ -48,6 +60,13 @@
|
|||||||
<select class="form-control" id="vendor" name="vendor" required>
|
<select class="form-control" id="vendor" name="vendor" required>
|
||||||
<!-- Placeholder option -->
|
<!-- Placeholder option -->
|
||||||
<option value="">Select Vendor</option>
|
<option value="">Select Vendor</option>
|
||||||
|
<?php if (isset($vendors) && !empty($vendors)): ?>
|
||||||
|
<?php foreach ($vendors as $vendor): ?>
|
||||||
|
<option value="<?= $vendor['vendor_id'] ?>" <?= isset($products['vendor']) && $products['vendor'] == $vendor['vendor_id'] ? 'selected' : '' ?>>
|
||||||
|
<?= $vendor['vendor_name'] ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
|
|||||||
179
app/Views/spare_manufacturer_list.php
Normal file
179
app/Views/spare_manufacturer_list.php
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
<?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">Spare Manufacturer List</h4>
|
||||||
|
<div class="page-title-right">
|
||||||
|
<ol class="breadcrumb m-0">
|
||||||
|
<li class="">
|
||||||
|
<a href="#" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect">
|
||||||
|
<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;text-align: center;width: 100%;">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Spare Manufacturer </th>
|
||||||
|
<th>Quantity</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($spare_manufacturer as $item): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $item['manufacturer_name']; ?></td>
|
||||||
|
<td><?php echo $item['quantity']; ?></td>
|
||||||
|
<td>
|
||||||
|
<a href="#" data-toggle="modal" data-target="#bike_model_login-modal" 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>
|
||||||
|
</a>
|
||||||
|
<a href="<?= "bike_model_index/" . $item['make_id']; ?>" class="view-list-button" title="Model List" style="margin-left: 16px;">
|
||||||
|
<i class="ri-list-check-2 icon-large"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Start Bike Make Create Pop-UP -->
|
||||||
|
<div id="bike_make_login-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>Add Bike Make</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="model_form_data" class="px-3">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="makename">Make Name </label>
|
||||||
|
<input class="form-control" type="text" id="bike_make_name" required="" placeholder="Make Name....">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group text-center">
|
||||||
|
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitMake(this)">Submit</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
|
<!-- End Bike Make Create Pop-UP -->
|
||||||
|
|
||||||
|
<!-- Start Bike Model Create Pop-UP -->
|
||||||
|
<div id="bike_model_login-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>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="" placeholder="Make Name...." style="display:none;">
|
||||||
|
<label for="makename">Make Name </label>
|
||||||
|
<input class="form-control" type="text" id="makename" required="" 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">
|
||||||
|
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitModel(this)">Submit</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
|
<!-- End Bike Model Create Pop-UP -->
|
||||||
|
|
||||||
|
|
||||||
|
<?php include('layout/footer.php'); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
function setMakeName(params) {
|
||||||
|
|
||||||
|
$('#make_id').val(params.getAttribute('data-id'));
|
||||||
|
$('#makename').val(params.getAttribute('data-value'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function submitModel(params) {
|
||||||
|
console.log( $('#modelname').val());
|
||||||
|
var formData = {
|
||||||
|
make_id: $('#make_id').val(),
|
||||||
|
modelname: $('#modelname').val()
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: 'create_model',
|
||||||
|
data: formData,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(response) {
|
||||||
|
// Handle success response here
|
||||||
|
console.log(response);
|
||||||
|
$('#bike_model_login-modal').modal('hide');
|
||||||
|
$('#modelname').val('');
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
// Handle error response here
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function submitMake(params) {
|
||||||
|
var formData = {
|
||||||
|
makename: $('#bike_make_name').val()
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: 'create_make',
|
||||||
|
data: formData,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(response) {
|
||||||
|
console.log(response);
|
||||||
|
$('#bike_model_login-modal').modal('hide');
|
||||||
|
$('#bike_make_name').val('');
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
// Handle error response here
|
||||||
|
console.error(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user