Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic
This commit is contained in:
commit
b0506e3efa
@ -39,6 +39,8 @@ $routes->get('product_index/', 'Products::product_index');
|
||||
$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");
|
||||
$routes->post("get_vendors_by_model", "Products::get_vendors_by_model");
|
||||
$routes->post("get_models", "Products::get_models");
|
||||
//end products//
|
||||
|
||||
//Sales order //
|
||||
@ -62,6 +64,7 @@ $routes->get('vendor_index/', 'Vendor::vendor_index');
|
||||
$routes->post("add_vendor", "Vendor::add_vendor");
|
||||
$routes->get("new_vendor/(:any)", "Vendor::new_vendor/$1");
|
||||
$routes->get("delete_vendor/(:any)", "Vendor::delete_vendor/$1");
|
||||
$routes->post("fetch_models", "Vendor::fetch_models");
|
||||
//end Vendor
|
||||
|
||||
//Vehicle//
|
||||
|
||||
@ -65,7 +65,8 @@ class Client extends BaseController
|
||||
'city' => $this->request->getPost('city'),
|
||||
'state' => $this->request->getPost('state'),
|
||||
'postal_code' => $this->request->getPost('postalcode'),
|
||||
|
||||
'gstnumber' => $this->request->getPost('gstnumber'),
|
||||
'client_type' => $this->request->getPost('clienttype'),
|
||||
'isactive' => 1 ,
|
||||
'branch_id' => $this->session->get('logged_user_branch_id')
|
||||
];
|
||||
|
||||
@ -3,7 +3,9 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\ProductModel;
|
||||
// use App\Models\RoleModel;
|
||||
use App\Models\BikemakeModel;
|
||||
use App\Models\VendorModel;
|
||||
use App\Models\BikemodelsModel;
|
||||
|
||||
|
||||
class Products extends BaseController
|
||||
@ -37,10 +39,13 @@ class Products extends BaseController
|
||||
$ProductModel = new ProductModel();
|
||||
$tax=$ProductModel->getTax();
|
||||
$data['tax']=$tax;
|
||||
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$data['make'] = $BikemakeModel->findAll();
|
||||
$data['page_name']="Add Product";
|
||||
} else if ($product_id !== '0') {
|
||||
$data['page_name']="Edit Product";
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$data['make'] = $BikemakeModel->findAll();
|
||||
$ProductModel = new ProductModel();
|
||||
$tax=$ProductModel->getTax();
|
||||
$data['tax']=$tax;
|
||||
@ -75,6 +80,8 @@ class Products extends BaseController
|
||||
'qty_in_demand'=> $this->request->getPost('qty_in_demand'),
|
||||
'description' => $this->request->getPost('description'),
|
||||
'vendor' => $this->request->getPost('vendor'),
|
||||
'purchase_order_level' => $this->request->getPost('purchase_order_level'),
|
||||
'quality' => $this->request->getPost('quality'),
|
||||
'isactive' => 1 ,
|
||||
'branch_id' => $this->session->get('logged_user_branch_id')
|
||||
];
|
||||
@ -113,5 +120,47 @@ class Products extends BaseController
|
||||
|
||||
return redirect()->to('product_index');
|
||||
}
|
||||
|
||||
// Retrieve the make_id from the AJAX request
|
||||
public function get_vendors_by_model()
|
||||
{
|
||||
$make_id = $this->request->getPost('make_id');
|
||||
$model_ids = $this->request->getPost('model_ids');
|
||||
// print_r( $model_ids);die;
|
||||
|
||||
// If make_id or model_ids is not provided, return an empty response
|
||||
|
||||
|
||||
// Create an instance of VendorModel
|
||||
$vendorModel = new VendorModel();
|
||||
|
||||
// Call the get_vendors_by_model method from the model
|
||||
$vendors = $vendorModel->get_vendors_by_model($make_id, $model_ids);
|
||||
// print_r($vendors);
|
||||
// Return the response as JSON
|
||||
// return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.']);
|
||||
if ($vendors) {
|
||||
// Return the retrieved vendors as JSON response
|
||||
return $this->response->setJSON($vendors);
|
||||
} else {
|
||||
// If no vendors were found, return an empty response or handle the error accordingly
|
||||
return $this->response->setJSON([]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function get_models()
|
||||
{
|
||||
$make_id = $this->request->getPost('make_id'); // Assuming you are sending make_id via POST
|
||||
|
||||
// Fetch models based on the selected make ID
|
||||
$BikemodelsModel = new BikemodelsModel(); // Adjust this according to your actual model name
|
||||
$models = $BikemodelsModel->where('make_id', $make_id)->findAll(); // Implement this method in your model
|
||||
// Return the model data as JSON
|
||||
return $this->response->setJSON($models);
|
||||
}
|
||||
|
||||
}
|
||||
@ -306,9 +306,12 @@ public function delete_sales_product()
|
||||
];
|
||||
|
||||
// Attempt to insert the client data
|
||||
if ($ClientModel->insert($data)) {
|
||||
$id = $ClientModel->insert($data);
|
||||
if ($id) {
|
||||
$clientData = $ClientModel->where('client_id',$id)->first();
|
||||
|
||||
// If insertion succeeds, return success response
|
||||
return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.']);
|
||||
return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.','clientData'=>$clientData]);
|
||||
} else {
|
||||
// If insertion fails, return error response
|
||||
return $this->response->setJSON(['success' => false, 'message' => 'Failed to save client.']);
|
||||
|
||||
@ -4,20 +4,33 @@ namespace App\Controllers;
|
||||
use App\Models\VehicleModel;
|
||||
use App\Models\ClientModel;
|
||||
use App\Models\RoleModel;
|
||||
use App\Models\BikemakeModel;
|
||||
use App\Models\BikemodelsModel;
|
||||
|
||||
|
||||
class Vehicle extends BaseController
|
||||
{
|
||||
|
||||
|
||||
public $session;
|
||||
public function __construct()
|
||||
{
|
||||
$this->session = session();
|
||||
$this->bikeMakeModel = new BikemakeModel();
|
||||
$this->bikeModelsModel = new BikemodelsModel();
|
||||
}
|
||||
|
||||
public function vehicle_index()
|
||||
{
|
||||
|
||||
$VehicleModel = new VehicleModel();
|
||||
$vehicle=$VehicleModel->getCustomerandVehicle();
|
||||
$data['vehicle']=$vehicle;
|
||||
$vehicle = $VehicleModel->getCustomerandVehicle($this->session->get('logged_user_branch_id'));
|
||||
$data['vehicle'] = $vehicle;
|
||||
|
||||
$ClientModel = new ClientModel();
|
||||
$client=$ClientModel->findAll();
|
||||
$client = $ClientModel->where('branch_id', $this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['client']=$client;
|
||||
|
||||
return view('vehicle_list',$data);
|
||||
}
|
||||
|
||||
@ -30,19 +43,25 @@ class Vehicle extends BaseController
|
||||
$ClientModel = new ClientModel();
|
||||
$data['vehicle'] = [];
|
||||
$data['page_name']="Add vehicle";
|
||||
$client=$ClientModel->findAll();
|
||||
$client = $ClientModel->where('branch_id', $this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['client']=$client;
|
||||
|
||||
} else if ($vehicle_id !== '0') {
|
||||
|
||||
$data['page_name']="Edit vehicle";
|
||||
$VehicleModel = new VehicleModel();
|
||||
$vehicle=$VehicleModel->where('vehicle_id', $vehicle_id)->get()->getRowArray();
|
||||
$vehicle= $VehicleModel->select('vehicle.*, model.model_name as model_name')
|
||||
->join('model', 'model.model_id = vehicle.model')
|
||||
->where('vehicle.vehicle_id', $vehicle_id)
|
||||
->where('vehicle.branch_id', $this->session->get('logged_user_branch_id'))
|
||||
->get()->getRowArray();
|
||||
$data['vehicle']=$vehicle;
|
||||
$ClientModel = new ClientModel();
|
||||
$client=$ClientModel->findAll();
|
||||
$client=$ClientModel->where('branch_id', $this->session->get('logged_user_branch_id'))->findAll();
|
||||
$data['client']=$client;
|
||||
}
|
||||
$data['vehicle_id'] = $vehicle_id;
|
||||
$data['makeData'] =$this->bikeMakeModel->findAll();
|
||||
|
||||
return view('vehicle_form',$data);
|
||||
}
|
||||
@ -62,12 +81,12 @@ class Vehicle extends BaseController
|
||||
'city' => $this->request->getPost('city'),
|
||||
'state' => $this->request->getPost('state'),
|
||||
'postal_code' => $this->request->getPost('postalcode'),
|
||||
'country' => $this->request->getPost('country'),
|
||||
'make' => $this->request->getPost('make'),
|
||||
'model' => $this->request->getPost('model'),
|
||||
'reg_no' => $this->request->getPost('regno'),
|
||||
'colour' => $this->request->getPost('colour'),
|
||||
|
||||
'year_of_manufacturing' => $this->request->getPost('year_of_manufacturing'),
|
||||
'branch_id' => $this->session->get('logged_user_branch_id'),
|
||||
'isactive' => 1 // Assuming this is a default value or handled separately
|
||||
];
|
||||
// print_r($data);die;
|
||||
|
||||
@ -5,6 +5,8 @@ namespace App\Controllers;
|
||||
use App\Models\VendorModel;
|
||||
|
||||
use App\Models\UsersModel;
|
||||
use App\Models\BikemakeModel;
|
||||
use App\Models\BikemodelsModel;
|
||||
|
||||
|
||||
class Vendor extends BaseController
|
||||
@ -31,34 +33,55 @@ class Vendor extends BaseController
|
||||
|
||||
public function new_vendor($vendor_id)
|
||||
{
|
||||
|
||||
|
||||
if ($vendor_id === '0') {
|
||||
|
||||
$data['vendor'] = [];
|
||||
$data['page_name']="Add Vendor";
|
||||
} else if ($vendor_id !== '0') {
|
||||
$data['page_name']="Edit Vendor";
|
||||
$data['vendor'] = [];
|
||||
$data['page_name'] = "Add Vendor";
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$data['make'] = $BikemakeModel->findAll();
|
||||
$data['models'] = []; // Initialize models array for the view
|
||||
} else {
|
||||
$VendorModel = new VendorModel();
|
||||
|
||||
$vendor=$VendorModel->where('vendor_id', $vendor_id)->get()->getRowArray();
|
||||
|
||||
$data['vendor']=$vendor;
|
||||
$vendor = $VendorModel->where('vendor_id', $vendor_id)->get()->getRowArray();
|
||||
$vendor['model_ids'] = json_decode($vendor['model'], true);
|
||||
$vendor['make_ids'] = json_decode($vendor['make'], true);
|
||||
|
||||
$data['vendor'] = $vendor;
|
||||
$data['page_name'] = "Edit Vendor";
|
||||
|
||||
// Load models based on the selected make IDs
|
||||
$BikemodelModel = new BikemodelsModel();
|
||||
$models = [];
|
||||
foreach ($vendor['make_ids'] as $make_id) {
|
||||
$models[] = $BikemodelModel->where('make_id', $make_id)->findAll();
|
||||
}
|
||||
$data['models'] = $models; // Pass models array to the view
|
||||
|
||||
// Load make data
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$data['make'] = $BikemakeModel->findAll();
|
||||
}
|
||||
|
||||
$data['vendor_id'] = $vendor_id;
|
||||
|
||||
return view('vendor_form',$data);
|
||||
|
||||
return view('vendor_form', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function add_vendor()
|
||||
{
|
||||
|
||||
$VendorModel = new VendorModel();
|
||||
|
||||
|
||||
// Retrieve the selected make IDs and model IDs from the form
|
||||
$make_ids = $this->request->getPost('make');
|
||||
$model_ids = $this->request->getPost('model');
|
||||
|
||||
// Convert model IDs to JSON format
|
||||
$model_json = json_encode($model_ids);
|
||||
$make_json=json_encode($make_ids);
|
||||
$data = [
|
||||
'vendor_name' => $this->request->getPost('vendor_name'),
|
||||
'contact_name' => $this->request->getPost('contact_name'),
|
||||
'gstnumber' => $this->request->getPost('gstnumber'),
|
||||
'vendor_email' => $this->request->getPost('email'),
|
||||
'address' => $this->request->getPost('address'),
|
||||
'vendor_mobile' => $this->request->getPost('mobile'),
|
||||
@ -69,24 +92,22 @@ class Vendor extends BaseController
|
||||
'category' => $this->request->getPost('category'),
|
||||
'website' => $this->request->getPost('website'),
|
||||
'isactive' => 1 ,
|
||||
'branch_id' => $this->session->get('logged_user_branch_id')
|
||||
'branch_id' => $this->session->get('logged_user_branch_id'),
|
||||
'make' => $make_json, // Store the selected make IDs
|
||||
'model' => $model_json, // Store the selected model IDs in JSON format
|
||||
];
|
||||
// print_r($data);die;
|
||||
|
||||
|
||||
$vendor_id = $this->request->getPost('vendor_id');
|
||||
|
||||
|
||||
if (!empty($vendor_id)) {
|
||||
|
||||
$VendorModel->update($vendor_id, $data);
|
||||
} else {
|
||||
|
||||
$VendorModel->insert($data);
|
||||
}
|
||||
|
||||
|
||||
return redirect()->to('vendor_index');
|
||||
}
|
||||
|
||||
public function delete_vendor($vendor_id)
|
||||
{
|
||||
$model = new VendorModel();
|
||||
@ -105,5 +126,40 @@ class Vendor extends BaseController
|
||||
|
||||
return redirect()->to('vendor_index');
|
||||
}
|
||||
public function fetch_models()
|
||||
{
|
||||
// Retrieve the selected make IDs from the AJAX request
|
||||
$selected_makes = $this->request->getPost('selected_makes');
|
||||
|
||||
// Load the BikemakeModel to fetch models
|
||||
$BikemodelModel = new BikemodelsModel();
|
||||
|
||||
// Initialize an empty array to store formatted model data
|
||||
$formatted_models = [];
|
||||
|
||||
// Iterate over each selected make ID
|
||||
foreach ($selected_makes as $make_id) {
|
||||
// Fetch models based on the selected make ID
|
||||
$models = $BikemodelModel->where('make_id', $make_id)->findAll();
|
||||
|
||||
// Iterate over each fetched model and format it as needed
|
||||
foreach ($models as $model) {
|
||||
// Create an associative array with 'model_id' and 'model_name' properties
|
||||
$formatted_model = [
|
||||
'model_id' => $model['model_id'],
|
||||
'model_name' => $model['model_name']
|
||||
// Add other properties if needed
|
||||
];
|
||||
|
||||
// Push the formatted model into the array
|
||||
$formatted_models[] = $formatted_model;
|
||||
}
|
||||
}
|
||||
|
||||
// Send the formatted models as JSON response back to the client
|
||||
return $this->response->setJSON($formatted_models);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ class ClientModel extends Model
|
||||
{
|
||||
protected $table = 'client';
|
||||
protected $primaryKey = 'client_id';
|
||||
protected $allowedFields = ['client_id','client_name','email','mobile_no','address','city','state','postal_code','country','description','isactive','branch_id'];
|
||||
protected $allowedFields = ['client_id','client_type','gstnumber','client_name','email','mobile_no','address','city','state','postal_code','country','description','isactive','branch_id'];
|
||||
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@ class ProductModel extends Model
|
||||
{
|
||||
protected $table = 'products';
|
||||
protected $primaryKey = 'product_id';
|
||||
protected $allowedFields = ['product_id','product_name','branch_id','search_tag','product_category','mfr_part_no','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 = ['product_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()
|
||||
|
||||
@ -3,16 +3,20 @@ namespace App\Models;
|
||||
use CodeIgniter\Model;
|
||||
class VehicleModel extends Model
|
||||
{
|
||||
|
||||
|
||||
protected $table = 'vehicle';
|
||||
protected $primaryKey = 'vehicle_id';
|
||||
protected $allowedFields = ['vehicle_id','make','model','reg_no','colour','client_id','address','country','state','city','email','postal_code','mobile_no','isactive'];
|
||||
protected $allowedFields = ['branch_id','vehicle_id','make','model','reg_no','year_of_manufacturing','colour','client_id','address','country','state','city','email','postal_code','mobile_no','isactive'];
|
||||
|
||||
public function getCustomerandVehicle()
|
||||
public function getCustomerandVehicle($branch_id)
|
||||
{
|
||||
// Select required fields from both tables
|
||||
$this->select('vehicle.*, client.client_name');
|
||||
$this->select('vehicle.*, client.client_name , make.make as make_name , model.model_name as model_name');
|
||||
$this->join('client', 'client.client_id = vehicle.client_id');
|
||||
// Add condition to fetch only active sales orders
|
||||
$this->join('make', 'make.make_id = vehicle.make');
|
||||
$this->join('model', 'model.model_id = vehicle.model');
|
||||
$this->where('vehicle.branch_id', $branch_id);
|
||||
$this->where('vehicle.isactive', 1);
|
||||
|
||||
// Get the results
|
||||
|
||||
@ -5,7 +5,25 @@ class VendorModel extends Model
|
||||
{
|
||||
protected $table = 'vendor';
|
||||
protected $primaryKey = 'vendor_id';
|
||||
protected $allowedFields = ['vendor_id','branch_id','vendor_name','vendor_email','vendor_mobile','website','gl_account','category','address','state','posta_code','city','country','description','isactive'];
|
||||
|
||||
protected $allowedFields = ['vendor_id','branch_id','vendor_name','vendor_email','vendor_mobile','contact_name','website','gstnumber','conatct_person','vendortype','make','model','category','address','state','postal_code','city','country','description','isactive'];
|
||||
|
||||
public function get_vendors_by_model($model_ids)
|
||||
{
|
||||
// Encode the model IDs array as JSON
|
||||
$json_model_ids = json_encode($model_ids);
|
||||
|
||||
// Query the database to retrieve vendors based on the model IDs
|
||||
$query = $this->query("SELECT * FROM vendor WHERE JSON_CONTAINS(model, '{$json_model_ids}')")->getResult();
|
||||
|
||||
// Check if any vendors are found
|
||||
if (!empty($query)) {
|
||||
return $query; // Return the result as an array of vendors
|
||||
} else {
|
||||
return array(); // Return an empty array if no vendors are found
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -34,6 +34,21 @@
|
||||
<label for="inputEmail4" class="col-form-label">Email</label>
|
||||
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($client['email']) ? $client['email'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputAddress" class="col-form-label">GST Number<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" name="gstnumber" placeholder="GST Number" value="<?= isset($client['gstnumber']) ? $client['gstnumber'] : '' ?>"pattern="[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[0-9]{1}[Z]{1}[0-9A-Z]{1}" title="Enter a valid GST Number" />
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">Client Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control status-select" name="clienttype" required data-toggle="select2" >
|
||||
<!-- <option value="">Select a Status</option> -->
|
||||
<option value="Direct" <?= isset($client['client_type']) && $client['client_type'] === 'Direct' ? 'selected' : '' ?>>Direct</option>
|
||||
<option value="Mechanic" <?= isset($client['client_type']) && $client['client_type'] === 'Mechanic' ? 'selected' : '' ?>>Mechanic</option>
|
||||
<option value="Exp" <?= isset($client['client_type']) && $client['client_type'] === 'Exp' ? 'selected' : '' ?>>Exp</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
<!-- /Right-bar -->
|
||||
|
||||
<!-- Right bar overlay-->
|
||||
<div class="rightbar-overlay"></div>
|
||||
|
||||
|
||||
<!-- Vendor js -->
|
||||
<script src="<?php echo base_url(); ?>/assets/js/vendor.min.js"></script>
|
||||
|
||||
@ -103,10 +103,11 @@
|
||||
<?php } ?>
|
||||
|
||||
<?php if(session()->get('logged_user_role') == 'Floor Manager' ||
|
||||
session()->get('logged_user_role') == 'Job Card Manager') { ?>
|
||||
session()->get('logged_user_role') == 'Job Card Manager' ||
|
||||
session()->get('logged_user_role') == 'Store Manager') { ?>
|
||||
<li>
|
||||
<a href="<?php echo base_url('vehicle_index') ?>">
|
||||
<i class="ri-message-2-line"></i>
|
||||
<i class="mdi mdi-motorbike"></i>
|
||||
<span> Vehicle </span>
|
||||
</a>
|
||||
</li>
|
||||
@ -126,9 +127,9 @@
|
||||
<li>
|
||||
<a href="<?php echo base_url('sales_order_index') ?>">Sales Order</a>
|
||||
</li>
|
||||
<!-- <li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('vendor_index') ?>">Vendor</a>
|
||||
</li> -->
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@ -23,15 +23,43 @@
|
||||
<form action="<?= base_url() . "add_product"; ?>" method="post">
|
||||
<h4 class="header-title">Product Details :</h4><br>
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="make" class="col-form-label">Make<span class="text-danger">*</span></label>
|
||||
<select class="form-control SelExample" id="make" name="make" required>
|
||||
<!-- Options for make -->
|
||||
<?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>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<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>
|
||||
<!-- Options for model will be populated dynamically via AJAX -->
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<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>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">Product Category<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="productcategory" placeholder="Product Category" value="<?= isset($products['product_category']) ? $products['product_category'] : '' ?>" required>
|
||||
</div>
|
||||
<label for="vendor" class="col-form-label">Vendor<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="vendor" name="vendor" required>
|
||||
<!-- Placeholder option -->
|
||||
<option value="">Select Vendor</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="vendor" class="col-form-label">Quality<span class="text-danger">*</span></label>
|
||||
<select class="form-control " name="quality" required data-toggle="select2" >
|
||||
<!-- <option value="">Select a Status</option> -->
|
||||
<option value="Q1" <?= isset($products['quality']) && $products['quality'] === 'Q1' ? 'selected' : '' ?>>Q1</option>
|
||||
<option value="Q2" <?= isset($products['quality']) && $products['quality'] === 'Q2' ? 'selected' : '' ?>>Q2 </option>
|
||||
<option value="Q3" <?= isset($products['quality']) && $products['quality'] === 'Q3' ? 'selected' : '' ?>>Q3</option>
|
||||
<option value="Q4" <?= isset($products['quality']) && $products['quality'] === 'Q4' ? 'selected' : '' ?>>Q4</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputAddress" class="col-form-label">Manfacturer Part Number</label>
|
||||
<input type="text" class="form-control" name="mfr_part_no" placeholder="Manfacturer Part Number" value="<?= isset($products['mfr_part_no']) ? $products['mfr_part_no'] : '' ?>" >
|
||||
@ -41,9 +69,10 @@
|
||||
<input type="text" class="form-control" name="serial_no" placeholder="Serial Number"value="<?= isset($products['serial_no']) ? $products['serial_no'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Vendor<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="vendor" placeholder="Vendor"value="<?= isset($products['vendor']) ? $products['vendor'] : '' ?>" required>
|
||||
<label for="inputEmail4" class="col-form-label">Product Category<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="productcategory" placeholder="Product Category" value="<?= isset($products['product_category']) ? $products['product_category'] : '' ?>" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<input type="hidden" id="product_id" name="product_id" value="<?= isset($products['product_id']) ? $products['product_id'] : '' ?>"><br>
|
||||
<h4 class="header-title">Pricing Information :</h4><br>
|
||||
@ -87,6 +116,10 @@
|
||||
<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>
|
||||
<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'] : '' ?>" >
|
||||
@ -139,4 +172,104 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
// Initialize select2
|
||||
$(".SelExample").select2();
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#make').change(function() {
|
||||
var make_id = $(this).val(); // Get the selected make ID
|
||||
|
||||
// AJAX request to get models based on the selected make ID
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_models') ?>', // URL to your CodeIgniter controller method
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { make_id: make_id }, // Send the selected make ID to the controller
|
||||
success: function(response) {
|
||||
// Update models dropdown based on the response
|
||||
if (response.length > 0) {
|
||||
// Clear existing options
|
||||
$('#model').empty();
|
||||
// Append new options
|
||||
$.each(response, function(index, model) {
|
||||
$('#model').append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
||||
});
|
||||
} else {
|
||||
// Handle case when no models are found
|
||||
$('#model').empty().append('<option value="">No models found</option>');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#model').change(function() {
|
||||
var make_id = $(this).val(); // Get the selected make ID
|
||||
var model_ids = $('#model').val(); // Get the selected model IDs
|
||||
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: { make_id: make_id, model_ids: model_ids }, // 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>"hello"</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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice{
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
color: #000000;
|
||||
|
||||
}
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||
color:#ffffff;
|
||||
background-color: #526dee;
|
||||
}
|
||||
.select2-container--default .select2-results__option{
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
.select2-container--default .select2-results__option[aria-selected=true]{
|
||||
color: #000000;
|
||||
background-color: #3efba4;
|
||||
font-weight: 500;
|
||||
border-bottom: 1px solid #747474;
|
||||
}
|
||||
</style>
|
||||
@ -487,10 +487,6 @@ function initializeSelect2() {
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Show the modal when the "add-circle-button" is clicked
|
||||
$('#add-circle-button').click(function() {
|
||||
$('#addClientModal').modal('show');
|
||||
});
|
||||
|
||||
// AJAX request to save client
|
||||
$('#saveClientBtn').click(function() {
|
||||
|
||||
@ -4,9 +4,8 @@
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<h4 class="page-title"><?php echo $page_name?></h4>
|
||||
<div class="page-title-right">
|
||||
<a href="<?= base_url() . "vehicle_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
<ol class="breadcrumb m-0">
|
||||
|
||||
</li>
|
||||
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Tables</a></li>
|
||||
<li class="breadcrumb-item active">Datatables</li> -->
|
||||
</ol>
|
||||
@ -25,15 +24,34 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Make</label>
|
||||
<input type="text" class="form-control" name="make" placeholder="Make"value="<?= isset($vehicle['make']) ? $vehicle['make'] : '' ?>" required>
|
||||
<select class="form-control SelExample" name="make" id="make" <?= isset($vehicle['make']) ? '' : 'required' ?>>
|
||||
<?= isset($vehicle['make']) ? '' : '<option value="">Select a Make</option>' ?>
|
||||
<?php foreach ($makeData as $value) : ?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["make_id"] ?>" <?= isset($vehicle['make']) && $vehicle['make'] == $value["make_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["make"]; ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Model</label>
|
||||
<input type="text" class="form-control" name="model" placeholder="Model"value="<?= isset($vehicle['model']) ? $vehicle['model'] : '' ?>" required>
|
||||
<select class="form-control SelExample" name="model" id="model" <?= isset($vehicle['model']) ? '' : 'required' ?>>
|
||||
<?php if (isset($vehicle["model_name"])) : ?>
|
||||
<option value="<?= $vehicle["model"] ?>" >
|
||||
<?= $vehicle["model_name"]; ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Reg Number</label>
|
||||
<input type="text" class="form-control" name="regno" placeholder="Reg Number"value="<?= isset($vehicle['reg_no']) ? $vehicle['reg_no'] : '' ?>" required>
|
||||
<input type="text" class="form-control" name="regno" id="regno" placeholder="Reg Number"value="<?= isset($vehicle['reg_no']) ? $vehicle['reg_no'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Year of Manufacturing</label>
|
||||
<input type="text" class="form-control" name="year_of_manufacturing" placeholder="Manufacturing Year" value="<?= isset($vehicle['year_of_manufacturing']) ? $vehicle['year_of_manufacturing'] : '' ?>" maxlength="4" minlength="4"onkeypress = "return onlyNumbers(event)">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Colour</label>
|
||||
@ -44,7 +62,8 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">Client Name</label>
|
||||
<select class="form-control cleint-select" name="client_name" required data-toggle="select2" >
|
||||
<?= isset($vehicle['client_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addClientModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addClientModal" title="Add Client"></i>' ?>
|
||||
<select class="form-control cleint-select SelExample" id="clientData" name="client_name" required data-toggle="select2" >
|
||||
<option value="">Select a Client</option>
|
||||
<?php foreach ($client as $value) : ?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
@ -53,39 +72,35 @@
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">Email</label>
|
||||
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($vehicle['email']) ? $vehicle['email'] : '' ?>" readonly>
|
||||
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($vehicle['email']) ? $vehicle['email'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputAddress" class="col-form-label">Mobile</label>
|
||||
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile" value="<?= isset($vehicle['mobile_no']) ? $vehicle['mobile_no'] : '' ?>" required maxlength="10" minlength="10"readonly>
|
||||
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile" value="<?= isset($vehicle['mobile_no']) ? $vehicle['mobile_no'] : '' ?>" required maxlength="10" minlength="10">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Address</label>
|
||||
<input type="text" class="form-control" name="address" placeholder="Address"value="<?= isset($vehicle['address']) ? $vehicle['address'] : '' ?>" readonly>
|
||||
<input type="text" class="form-control" name="address" placeholder="Address"value="<?= isset($vehicle['address']) ? $vehicle['address'] : '' ?>" >
|
||||
</div>
|
||||
|
||||
|
||||
<input type="hidden" id="vehicle_id" name="vehicle_id" value="<?= isset($vehicle['vehicle_id']) ? $vehicle['vehicle_id'] : '' ?>"readonly>
|
||||
<input type="hidden" id="vehicle_id" name="vehicle_id" value="<?= isset($vehicle['vehicle_id']) ? $vehicle['vehicle_id'] : '' ?>">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">City</label>
|
||||
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($vehicle['city']) ? $vehicle['city'] : '' ?>" readonly>
|
||||
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($vehicle['city']) ? $vehicle['city'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">State</label>
|
||||
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($vehicle['state']) ? $vehicle['state'] : '' ?>" readonly>
|
||||
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($vehicle['state']) ? $vehicle['state'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Postal Code</label>
|
||||
<input type="text" class="form-control" name="postalcode" placeholder="Postal Code"value="<?= isset($vehicle['postal_code']) ? $vehicle['postal_code'] : '' ?>" readonly maxlength="6" minlength="6">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Country</label>
|
||||
<input type="text" class="form-control" name="country" placeholder="Country"value="<?= isset($vehicle['country']) ? $vehicle['country'] : '' ?>" readonly>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="inputPassword4" class="col-form-label">Pin Code</label>
|
||||
<input type="text" class="form-control" name="postalcode" placeholder="Pin Code"value="<?= isset($vehicle['postal_code']) ? $vehicle['postal_code'] : '' ?>" maxlength="6" minlength="6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -98,6 +113,37 @@
|
||||
|
||||
<?php include('layout/footer.php'); ?>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="addClientModal" tabindex="-1" role="dialog" aria-labelledby="addClientModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addClientModalLabel">Add New Client</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="addClientForm">
|
||||
<div class="form-group">
|
||||
<label for="clientName">Client Name</label>
|
||||
<input type="text" class="form-control" id="clientName" placeholder="Enter client name"required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="clientMobile">Mobile</label>
|
||||
<input type="text" class="form-control" id="clientMobile" placeholder="Enter mobile number" maxlength="10" minlength="10"onkeypress = "return onlyNumbers(event)"required>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary" id="saveClientBtn">Save Client</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
@ -115,16 +161,122 @@ $(document).ready(function() {
|
||||
$('input[name="address"]').val(selectedClient.address);
|
||||
$('input[name="city"]').val(selectedClient.city);
|
||||
$('input[name="state"]').val(selectedClient.state);
|
||||
$('input[name="country"]').val(selectedClient.country);
|
||||
$('input[name="mobile_no"]').val(selectedClient.mobile_no);
|
||||
$('input[name="email"]').val(selectedClient.email);
|
||||
$('input[name="postalcode"]').val(selectedClient.postal_code);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$(".SelExample").select2();
|
||||
|
||||
// Event listener for change in make select dropdown
|
||||
$("#make").on('change', function() {
|
||||
var selected_makes = $(this).val(); // Get an array of selected make IDs
|
||||
// AJAX request to fetch models based on selected make IDs
|
||||
$.ajax({
|
||||
url: '<?= base_url("fetch_models") ?>', // URL to your controller method for fetching models
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { selected_makes: [selected_makes] },
|
||||
success: function(response) {
|
||||
// Clear existing options in model select dropdown
|
||||
$("#model").empty();
|
||||
$("#model").append('<option value=""> Select a Model </option>');
|
||||
// Populate model select dropdown with fetched models
|
||||
$.each(response, function(index, model) {
|
||||
$("#model").append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
||||
});
|
||||
|
||||
// Refresh select2 to reflect changes
|
||||
$("#model").trigger('change');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error); // Log any errors to the console
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
document.getElementById('regno').addEventListener('input', function(event) {
|
||||
var inputText = event.target.value;
|
||||
event.target.value = inputText.toUpperCase();
|
||||
});
|
||||
|
||||
function onlyNumbers(event){
|
||||
var charcode;
|
||||
charcode = event.which || event.keyCode;
|
||||
if(charcode>= 48 && charcode <= 57)return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$('#saveClientBtn').click(function() {
|
||||
|
||||
|
||||
var clientName = $('#clientName').val();
|
||||
var clientMobile = $('#clientMobile').val();
|
||||
if(clientName != '' && clientMobile != ''){
|
||||
|
||||
// Send AJAX request to save the client
|
||||
$.ajax({
|
||||
url: '<?php echo base_url().'save_client'?>', // URL to your save_client method
|
||||
method: 'POST',
|
||||
data: {
|
||||
client_name: clientName,
|
||||
mobile_no: clientMobile
|
||||
},
|
||||
success: function(response) {
|
||||
// Check if the operation was successful
|
||||
if (response.success) {
|
||||
// Client saved successfully, close the modal and do any additional actions
|
||||
$('#addClientModal').modal('hide');
|
||||
// Optionally, you can update the client dropdown or show a success message
|
||||
toastr.success("Client saved successfully!");
|
||||
console.log(response.clientData);
|
||||
$("#clientData").append('<option value="' + response.clientData.client_id + '">' + response.clientData.client_name + '</option>');
|
||||
// Manually select the newly added option
|
||||
$("#clientData").val(response.clientData.client_id).trigger('change');
|
||||
} else {
|
||||
// Client save operation failed, display error message
|
||||
toastr.warning("Failed to save client. Please try again");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// AJAX request failed, display error message
|
||||
console.error('Error occurred while saving client:', error);
|
||||
toastr.warning("Failed to save client. Please try again");
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
toastr.warning("Please Fill Name and Mobile data");
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// Define the clients array and populate it with data
|
||||
var clients = <?php echo json_encode($client); ?>;
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||
color:#ffffff;
|
||||
background: #526dee!important;
|
||||
}
|
||||
.select2-container .select2-selection--single{
|
||||
height: 36px;
|
||||
border:1px solid #ced4da;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||
line-height: 36px;
|
||||
}
|
||||
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||
top:4px;
|
||||
}
|
||||
</style>
|
||||
@ -29,14 +29,12 @@
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
|
||||
<th>Client Name</th>
|
||||
<th>Mobile</th>
|
||||
<th>Email</th>
|
||||
<th>Make</th>
|
||||
<th>Model</th>
|
||||
<th>Reg No</th>
|
||||
<th>Colour</th>
|
||||
<th>Make & Model</th>
|
||||
<th>Manf Year</th>
|
||||
<th>Colour</th>
|
||||
<th>Client Name</th>
|
||||
<th>Mobile</th>
|
||||
<th>Actions</th>
|
||||
|
||||
</tr>
|
||||
@ -47,14 +45,12 @@
|
||||
<?php foreach ($vehicle as $value) :
|
||||
if ($value['isactive'] == 1) : ?>
|
||||
<tr>
|
||||
<td><?= $value['reg_no']; ?></td>
|
||||
<td><?= $value['make_name'].' '.$value['model_name']; ?></td>
|
||||
<td><?= $value['year_of_manufacturing']; ?></td>
|
||||
<td><?= $value['colour']; ?></td>
|
||||
<td><?= $value['client_name']; ?></td>
|
||||
<td><?= $value['mobile_no']; ?></td>
|
||||
<td><?= $value['email']; ?></td>
|
||||
<td><?= $value['make']; ?></td>
|
||||
<td><?= $value['model']; ?></td>
|
||||
|
||||
<td><?= $value['reg_no']; ?></td>
|
||||
<td><?= $value['colour']; ?></td>
|
||||
<td>
|
||||
<a href="<?= "new_vehicle/" . $value['vehicle_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
||||
<a href="<?= "delete_vehicle/" . $value['vehicle_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
||||
|
||||
@ -27,10 +27,7 @@
|
||||
<label for="inputEmail4" class="col-form-label">Vendor Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="vendor_name" placeholder="Vendor Name" value="<?= isset($vendor['vendor_name']) ? $vendor['vendor_name'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputAddress" class="col-form-label">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="mobile" placeholder="Mobile" value="<?= isset($vendor['vendor_mobile']) ? $vendor['vendor_mobile'] : '' ?>" maxlength="10" minlength="10" onkeypress = "return onlyNumbers(event)" required/>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">Email</label>
|
||||
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($vendor['vendor_email']) ? $vendor['vendor_email'] : '' ?>" >
|
||||
@ -44,8 +41,57 @@
|
||||
<label for="inputEmail4" class="col-form-label">Category<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" name="category" placeholder="Category" value="<?= isset($vendor['category']) ? $vendor['category'] : '' ?>" >
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">GST Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="gstnumber" placeholder="GST Number" value="<?= isset($vendor['gstnumber']) ? $vendor['gstnumber'] : '' ?>" pattern="[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[0-9]{1}[Z]{1}[0-9A-Z]{1}" title="Enter a valid GST Number">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Vendor Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control " name="vendortype" required data-toggle="select2" >
|
||||
<!-- <option value="">Select a Status</option> -->
|
||||
<option value="Retailer" <?= isset($vendor['vendortype']) && $vendor['vendortype'] === 'Retailer' ? 'selected' : '' ?>>Retailer</option>
|
||||
<option value="Authorised Dealer" <?= isset($vendor['vendortype']) && $vendor['vendortype'] === 'Authorised Dealer' ? 'selected' : '' ?>>Authorised Dealer</option>
|
||||
<option value="Wholesale Dealer" <?= isset($vendor['vendortype']) && $vendor['vendortype'] === 'Wholesale Dealer' ? 'selected' : '' ?>>Wholesale Dealer</option>
|
||||
<option value="Wholesale OEM Dealer" <?= isset($vendor['vendortype']) && $vendor['vendortype'] === 'Wholesale OEM Dealer' ? 'selected' : '' ?>>Wholesale OEM Dealer</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span></label>
|
||||
<select class="form-control SelExample" id="make" name="make[]" required multiple>
|
||||
<!-- Options for make -->
|
||||
<?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>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">Model<span class="text-danger">*</span></label>
|
||||
<select class="form-control status-select" id="model" name="model[]" required data-toggle="select2" multiple>
|
||||
<!-- Options for models -->
|
||||
<?php foreach ($models as $make_models): ?>
|
||||
<?php foreach ($make_models as $model): ?>
|
||||
<option value="<?= $model['model_id'] ?>" <?= isset($vendor['model_ids']) && in_array($model['model_id'], $vendor['model_ids']) ? 'selected' : '' ?>><?= $model['model_name'] ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<h4 class="header-title">Contact Person Details :</h4>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputEmail4" class="col-form-label">Contact Person Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="contact_name" placeholder="Contactt Name" value="<?= isset($vendor['contact_name']) ? $vendor['contact_name'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputAddress" class="col-form-label">Contact Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="mobile" placeholder="Mobile" value="<?= isset($vendor['vendor_mobile']) ? $vendor['vendor_mobile'] : '' ?>" maxlength="10" minlength="10" onkeypress = "return onlyNumbers(event)" required/>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="vendor_id" name="vendor_id" value="<?= isset($vendor['vendor_id']) ? $vendor['vendor_id'] : '' ?>">
|
||||
<h4 class="header-title">Address Information :</h4>
|
||||
<div class="form-row">
|
||||
@ -86,4 +132,75 @@
|
||||
if(charcode>= 48 && charcode <= 57)return true;
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
// Initialize select2
|
||||
$(".SelExample").select2();
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.status-select').select2({
|
||||
placeholder: "Select vendor types",
|
||||
allowClear: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Initialize select2 for the make select dropdown
|
||||
$(".SelExample").select2();
|
||||
|
||||
// Event listener for change in make select dropdown
|
||||
$("#make").on('change', function() {
|
||||
var selected_makes = $(this).val(); // Get an array of selected make IDs
|
||||
|
||||
// AJAX request to fetch models based on selected make IDs
|
||||
$.ajax({
|
||||
url: '<?= base_url("fetch_models") ?>', // URL to your controller method for fetching models
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { selected_makes: selected_makes },
|
||||
success: function(response) {
|
||||
// Clear existing options in model select dropdown
|
||||
$("#model").empty();
|
||||
|
||||
// Populate model select dropdown with fetched models
|
||||
$.each(response, function(index, model) {
|
||||
$("#model").append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
||||
});
|
||||
|
||||
// Refresh select2 to reflect changes
|
||||
$("#model").trigger('change');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(error); // Log any errors to the console
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice{
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
color: #000000;
|
||||
|
||||
}
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||
color:#ffffff;
|
||||
background-color: #526dee;
|
||||
}
|
||||
.select2-container--default .select2-results__option{
|
||||
border-bottom: 1px solid #dddddd;
|
||||
}
|
||||
.select2-container--default .select2-results__option[aria-selected=true]{
|
||||
color: #000000;
|
||||
background-color: #3efba4;
|
||||
font-weight: 500;
|
||||
border-bottom: 1px solid #747474;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user