Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic
This commit is contained in:
commit
048e291e8a
@ -36,6 +36,7 @@ $routes->get("delete_business/(:any)", "Business::delete_business/$1");
|
||||
|
||||
// Products//
|
||||
$routes->get('product_index/', 'Products::product_index');
|
||||
$routes->get('product_index/(:any)', 'Products::product_index/$1');
|
||||
$routes->post("add_product", "Products::add_product");
|
||||
$routes->get("new_product/(:any)", "Products::new_product/$1");
|
||||
$routes->get("delete_product/(:any)", "Products::delete_product/$1");
|
||||
@ -85,7 +86,7 @@ $routes->get('dashboard', 'Users::dashboard');
|
||||
|
||||
|
||||
|
||||
//---------------------- Make And Model | Service | Spare Manufacturer and Category
|
||||
//---------------------- Make And Model | Service | Manufacturer
|
||||
// Make
|
||||
$routes->get('make_index', 'Make::index');
|
||||
$routes->post('create_make', 'Make::create_make');
|
||||
@ -108,11 +109,6 @@ $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');
|
||||
$routes->get('spare_manufacturer_index', 'Manufacturer::index');
|
||||
$routes->post('create_manufacturer', 'Manufacturer::create_manufacturer');
|
||||
|
||||
//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');
|
||||
@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\SpareManufacturerModel;
|
||||
use App\Models\ManufacturerModel;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
|
||||
class SpareManufacturer extends BaseController
|
||||
class Manufacturer extends BaseController
|
||||
{
|
||||
|
||||
public $session;
|
||||
@ -16,30 +16,32 @@ class SpareManufacturer extends BaseController
|
||||
{
|
||||
|
||||
$this->session = session();
|
||||
$this->SpareManufacturerModel = new SpareManufacturerModel();
|
||||
$this->ManufacturerModel = new ManufacturerModel();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$SpareManufacturerModel = new SpareManufacturerModel();
|
||||
$spare_manufacturer = $SpareManufacturerModel->findAll();
|
||||
$data['spare_manufacturer']=$spare_manufacturer;
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$spare_manufacturer = $ManufacturerModel->findAll();
|
||||
$data['manufacturer']=$spare_manufacturer;
|
||||
|
||||
return view('spare_manufacturer_list',$data);
|
||||
return view('manufacturer_list',$data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function create_make()
|
||||
public function create_manufacturer()
|
||||
{
|
||||
try {
|
||||
$make_name = $this->request->getPost('makename');
|
||||
$SpareManufacturerModel = new SpareManufacturerModel();
|
||||
$manufacturer_name = $this->request->getPost('manufacturername');
|
||||
$quantity = $this->request->getPost('quantity');
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data = [
|
||||
'make' => $make_name
|
||||
'manufacturer_name' => $manufacturer_name,
|
||||
'quantity' => $quantity,
|
||||
];
|
||||
$inserted = $SpareManufacturerModel->insert($data);
|
||||
$inserted = $ManufacturerModel->insert($data);
|
||||
if ($inserted) {
|
||||
$result = $data;
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
@ -18,16 +18,33 @@ class Products extends BaseController
|
||||
$this->session = session();
|
||||
}
|
||||
|
||||
public function product_index()
|
||||
public function product_index($manufacturer_id = null)
|
||||
{
|
||||
|
||||
$ProductModel = new ProductModel();
|
||||
$products = $ProductModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['products']=$products;
|
||||
if ($manufacturer_id) {
|
||||
$ProductModel = new ProductModel();
|
||||
$products = $ProductModel->where('manufacturer_id',$manufacturer_id)->findAll();
|
||||
$data['products']=$products;
|
||||
$data['manufacturer_id'] = $manufacturer_id;
|
||||
|
||||
return view('product_list',$data);
|
||||
} else {
|
||||
$ProductModel = new ProductModel();
|
||||
$products = $ProductModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['products']=$products;
|
||||
$data['manufacturer_id'] = $manufacturer_id;
|
||||
|
||||
|
||||
return view('product_list',$data);
|
||||
}
|
||||
|
||||
|
||||
return view('product_list',$data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function new_product($product_id)
|
||||
{
|
||||
@ -41,6 +58,8 @@ class Products extends BaseController
|
||||
$data['tax']=$tax;
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$data['make'] = $BikemakeModel->findAll();
|
||||
$VendorModel = new VendorModel();
|
||||
$data['vendors']=$VendorModel->findAll();
|
||||
$data['page_name']="Add Product";
|
||||
} else if ($product_id !== '0') {
|
||||
$data['page_name']="Edit Product";
|
||||
@ -60,8 +79,8 @@ class Products extends BaseController
|
||||
$VendorModel = new VendorModel();
|
||||
$data['vendors']=$VendorModel->findAll();
|
||||
|
||||
|
||||
// print_r($data);die;
|
||||
// print_r($data);die;
|
||||
|
||||
}
|
||||
$data['product_id'] = $product_id;
|
||||
|
||||
@ -89,15 +108,16 @@ class Products extends BaseController
|
||||
'qty_stock'=> $this->request->getPost('qty_in_stock'),
|
||||
'qty_in_demand'=> $this->request->getPost('qty_in_demand'),
|
||||
'description' => $this->request->getPost('description'),
|
||||
'vendor' => $this->request->getPost('vendor'),
|
||||
'vendor' =>json_encode( $this->request->getPost('vendor')),
|
||||
'purchase_order_level' => $this->request->getPost('purchase_order_level'),
|
||||
'reorder_level' => $this->request->getPost('reorder_level'),
|
||||
'quality' => $this->request->getPost('quality'),
|
||||
'make_id' => $this->request->getPost('make'),
|
||||
'models_id' => json_encode($this->request->getPost('model')),
|
||||
'isactive' => 1 ,
|
||||
'branch_id' => $this->session->get('logged_user_branch_id')
|
||||
];
|
||||
// print_r($data);die;
|
||||
// print_r($data);die;
|
||||
|
||||
$product_id = $this->request->getPost('product_id');
|
||||
|
||||
@ -108,9 +128,13 @@ class Products extends BaseController
|
||||
} else {
|
||||
|
||||
$ProductModel->insert($data);
|
||||
$product_id = $ProductModel->getInsertID();
|
||||
}
|
||||
|
||||
|
||||
$orderNumber = 'SKU-' . date('md') . '-' . str_pad($product_id, 5, '0', STR_PAD_LEFT);
|
||||
// print_r($orderNumber);die;
|
||||
// Update sales order with generated order number
|
||||
$ProductModel->update($product_id, ['sku_id' => $orderNumber]);
|
||||
return redirect()->to('product_index');
|
||||
}
|
||||
|
||||
|
||||
11
app/Models/ManufacturerModel.php
Normal file
11
app/Models/ManufacturerModel.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use CodeIgniter\Model;
|
||||
class ManufacturerModel extends Model
|
||||
{
|
||||
protected $table = 'manufacturer';
|
||||
protected $primaryKey = 'manufacturer_id';
|
||||
protected $allowedFields = ['manufacturer_id','manufacturer_name','isactive','quantity'];
|
||||
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ class ProductModel extends Model
|
||||
{
|
||||
protected $table = 'products';
|
||||
protected $primaryKey = 'product_id';
|
||||
protected $allowedFields = ['product_id','make_id','models_id','quality','product_name','branch_id','search_tag','product_category','mfr_part_no','purchase_order_level','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive'];
|
||||
protected $allowedFields = ['sku_id','product_id','manufacturer_id','make_id','models_id','quality','product_name','branch_id','search_tag','product_category','mfr_part_no','purchase_order_level','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive'];
|
||||
|
||||
|
||||
public function getTax()
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?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,11 +165,10 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<<<<<<< HEAD
|
||||
<li>
|
||||
<a href="<?php echo base_url('spare_manufacturer_index') ?>">
|
||||
<i class="fas fa-cogs"></i>
|
||||
<span> Spare </span>
|
||||
<span> Manufacturer </span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
122
app/Views/manufacturer_list.php
Normal file
122
app/Views/manufacturer_list.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?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">Manufacturer List</h4>
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="">
|
||||
<a href="#" data-toggle="modal" data-target="#manufacturer_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>Manufacturer </th>
|
||||
<th>Quantity</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($manufacturer as $item): ?>
|
||||
<tr>
|
||||
<td><?php echo $item['manufacturer_name']; ?></td>
|
||||
<td><?php echo $item['quantity']; ?></td>
|
||||
<td>
|
||||
<a href="<?= "product_index/" . $item['manufacturer_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="manufacturer_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 Manufacturer</h4>
|
||||
</div>
|
||||
|
||||
<form id="model_form_data" class="px-3">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="manufacturername">Manufacturer Name </label>
|
||||
<input class="form-control" type="text" id="manufacturer_name" required="" placeholder="Make Name....">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="manufacturername">Quantity</label>
|
||||
<select name="quantity" id="quantity" class="form-control" style="border-color: lightgray;color: #6c757d;">
|
||||
<option value="0">Select Quantity</option>
|
||||
<option value="q1">Q1</option>
|
||||
<option value="q2">Q2</option>
|
||||
<option value="q3">Q3</option>
|
||||
<option value="q4">Q4</option>
|
||||
</select>
|
||||
</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 -->
|
||||
|
||||
<?php include('layout/footer.php'); ?>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
||||
function submitMake(params) {
|
||||
var formData = {
|
||||
manufacturername: $('#manufacturer_name').val(),
|
||||
quantity: $('#quantity').val()
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '<?php echo base_url()."create_manufacturer"?>',
|
||||
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>
|
||||
@ -57,16 +57,16 @@
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="vendor" class="col-form-label">Vendor<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="vendor" name="vendor" required>
|
||||
<select class="form-control SelExample" id="vendor" name="vendor[]" required multiple>
|
||||
<!-- Placeholder 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' : '' ?>>
|
||||
|
||||
<?php foreach ($vendors as $vendor): ?>
|
||||
<option value="<?= $vendor['vendor_id'] ?>" <?= isset($products['vendor']) && in_array($vendor['vendor_id'], json_decode($products['vendor'], true)) ? 'selected' : '' ?>>
|
||||
<?= $vendor['vendor_name'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
@ -133,13 +133,18 @@
|
||||
<h4 class="header-title">Stock Information :</h4><br>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" name="qty_in_stock" placeholder="Qty in Stock" value="<?= isset($products['qty_stock']) ? $products['qty_stock'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" name="purchase_order_level" placeholder="Purchase Order Level" value="<?= isset($products['purchase_order_level']) ? $products['purchase_order_level'] : '' ?>" required>
|
||||
</div>
|
||||
<label for="inputPassword4" class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" id="qty_in_stock" name="qty_in_stock" placeholder="Qty in Stock" value="<?= isset($products['qty_stock']) ? $products['qty_stock'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="purchase_order_level" name="purchase_order_level" placeholder="Purchase Order Level" value="<?= isset($products['purchase_order_level']) ? $products['purchase_order_level'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Re-Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="purchase_reorder_level" name="reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['reorder_level']) ? $products['reorder_level'] : '' ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4" hidden>
|
||||
<label for="inputPassword4" class="col-form-label">Qty in Demand</label>
|
||||
<input type="number" class="form-control" name="qty_in_demand" placeholder="Qty in Demand" value="<?= isset($products['qty_in_demand']) ? $products['qty_in_demand'] : '' ?>" >
|
||||
@ -236,45 +241,28 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const qtyInStockInput = document.getElementById('qty_in_stock');
|
||||
const purchaseOrderLevelInput = document.getElementById('purchase_order_level');
|
||||
const purchaseReorderLevelInput = document.getElementById('purchase_reorder_level');
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#model').change(function() {
|
||||
// Listen for the keyup event on qty in stock input
|
||||
qtyInStockInput.addEventListener('keyup', function() {
|
||||
const qtyInStock = parseFloat(qtyInStockInput.value);
|
||||
const purchaseorderLevel = qtyInStock / 2; // Calculate the purchase reorder level (half of qty in stock)
|
||||
|
||||
var model_ids = $('#model').val(); // Get the selected model IDs
|
||||
var make_id = $('#make').val();
|
||||
console.log(model_ids);
|
||||
|
||||
// AJAX request to get vendors based on the selected model ID
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_vendors_by_model') ?>', // URL to your CodeIgniter controller method
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { model_ids: model_ids , make_id : make_id }, // Send the selected make ID and model IDs to the controller
|
||||
success: function(response) {
|
||||
// Update vendor dropdown based on the response
|
||||
if (response) {
|
||||
// Clear existing options
|
||||
$('#vendor').empty();
|
||||
// Append new options
|
||||
$('#vendor').append('<option value>Select Vendor</option>');
|
||||
$.each(response, function(index, vendor) {
|
||||
$('#vendor').append('<option value="' + vendor.vendor_id + '">' + vendor.vendor_name + '</option>');
|
||||
});
|
||||
} else {
|
||||
// Handle case when no vendors are found for the selected model
|
||||
console.log('No vendors found for the selected model');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
// Update the value of purchase reorder level input
|
||||
purchaseOrderLevelInput.value = isNaN(purchaseorderLevel) ? '' : purchaseorderLevel;
|
||||
purchaseReorderLevelInput.value = isNaN(qtyInStock) ? '' : qtyInStock;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice{
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
|
||||
@ -6,9 +6,10 @@
|
||||
<h4 class="page-title">Product List</h4>
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<?php if(!$manufacturer_id) { ?>
|
||||
<li class=""> <a href="<?= base_url() . "new_product/0"; ?>" class="btn btn-primary waves-effect"> <i class="ri-add-line"></i></a>
|
||||
</li>
|
||||
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
@ -29,7 +30,6 @@
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
|
||||
<th>Product Name</th>
|
||||
<th>Category</th>
|
||||
<th>Serial Number</th>
|
||||
@ -37,10 +37,7 @@
|
||||
<th>Qty in Stock</th>
|
||||
<th>Sgst</th>
|
||||
<th>Cgst</th>
|
||||
|
||||
|
||||
<th>Actions</th>
|
||||
|
||||
<?php if(!$manufacturer_id) { ?><th>Actions</th><?php } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -50,7 +47,7 @@
|
||||
if ($value['isactive'] == 1) : ?>
|
||||
<tr>
|
||||
<td><?= $value['product_name']; ?></td>
|
||||
<td><?= $value['product_category']; ?></td>
|
||||
<td><?= $value['product_category']; ?></td>
|
||||
<td><?= $value['serial_no']; ?></td>
|
||||
<td><?= number_format($value['unit_price']); ?></td>
|
||||
<td><?= $value['qty_stock']; ?></td>
|
||||
@ -58,13 +55,14 @@
|
||||
<td><?= $value['sgst']; ?>%</td>
|
||||
|
||||
<!-- Call the model method -->
|
||||
<td>
|
||||
<a href="<?= "new_product/" . $value['product_id']; ?>" class="edit-button"><i
|
||||
class="ri-pencil-line"></i></a>
|
||||
<a href="<?= "delete_product/" . $value['product_id']; ?>"
|
||||
class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
||||
</td>
|
||||
|
||||
<?php if(!$manufacturer_id) { ?>
|
||||
<td>
|
||||
<a href="<?= "new_product/" . $value['product_id']; ?>" class="edit-button"><i
|
||||
class="ri-pencil-line"></i></a>
|
||||
<a href="<?= "delete_product/" . $value['product_id']; ?>"
|
||||
class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php endif?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
@ -1,179 +0,0 @@
|
||||
<?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