FIX_CHANGE_CONFLICT_CODE_MERAGE:AADHAVAN
This commit is contained in:
commit
426409cc9e
@ -42,6 +42,9 @@ $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");
|
||||
$routes->get("get_makes", "Products::get_makes");
|
||||
$routes->post("save_make", "Products::save_make");
|
||||
$routes->post("save_model", "Products::save_model");
|
||||
//end products//
|
||||
|
||||
//Sales order //
|
||||
@ -120,3 +123,5 @@ $routes->get("new_purchase/(:any)", "Purchase::new_purchase/$1");
|
||||
$routes->get('get_vendor/(:any)', 'Purchase::get_vendor/$1');
|
||||
$routes->post("add_purchase", "Purchase::add_purchase");
|
||||
$routes->get("delete_purchase/(:any)", "Purchase::delete_purchase/$1");
|
||||
// Reorder Level//
|
||||
$routes->get('reorder_level_index', 'Reorderlevel::reorder_level_index');
|
||||
|
||||
@ -124,6 +124,7 @@ class Client extends BaseController
|
||||
$data = [
|
||||
'client_name' => $this->request->getPost('client_name'),
|
||||
'mobile_no' => $this->request->getPost('mobile_no'),
|
||||
'client_type' => $this->request->getPost('client_type'),
|
||||
'branch_id'=> $this->session->get('logged_user_branch_id'),
|
||||
'city'=>'Chennai',
|
||||
'state'=>'Tamil Nadu',
|
||||
|
||||
@ -68,6 +68,7 @@ class Products extends BaseController
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data['manufacturers']=$ManufacturerModel->findAll();
|
||||
$data['page_name']="Add Product";
|
||||
$data['vendorsProduct'] =[];
|
||||
} else if ($product_id !== '0') {
|
||||
$data['page_name']="Edit Product";
|
||||
$ProductModel = new ProductModel();
|
||||
@ -87,6 +88,18 @@ class Products extends BaseController
|
||||
$data['vendors']=$VendorModel->findAll();
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data['manufacturers']=$ManufacturerModel->findAll();
|
||||
$vendorIds = json_decode($products['vendor'], true);
|
||||
$vendors = [];
|
||||
$VendorModel = new VendorModel();
|
||||
foreach ($vendorIds as $vendorId) {
|
||||
$vendor = $VendorModel->find($vendorId);
|
||||
if ($vendor) {
|
||||
$vendors[] = ['id' => $vendor['vendor_id'], 'name' => $vendor['vendor_name']];
|
||||
}
|
||||
}
|
||||
$data['vendorsProduct'] = $vendors;
|
||||
// print_r($data['vendors']);die;
|
||||
|
||||
$preferredVendorId = $products['prefered_vendor'];
|
||||
// Pass the preferred vendor ID to the view
|
||||
$data['preferredVendorId'] = $preferredVendorId; // print_r($data);die;
|
||||
@ -239,4 +252,77 @@ public function get_models()
|
||||
return $this->response->setJSON($models);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function save_make() {
|
||||
$response = []; // Initialize an empty array to hold the response data
|
||||
|
||||
// Assuming BikemakeModel and BikemodelsModel are properly defined
|
||||
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$BikemodelsModel = new BikemodelsModel();
|
||||
|
||||
$make = $this->request->getPost('make');
|
||||
$model = $this->request->getPost('model');
|
||||
|
||||
// Check if both make and model are provided
|
||||
if (!empty($make) && !empty($model)) {
|
||||
$data = [
|
||||
'make' => $make
|
||||
];
|
||||
|
||||
// Insert the make into the database
|
||||
$BikemakeModel->insert($data);
|
||||
$make_id = $BikemakeModel->getInsertID();
|
||||
|
||||
$modelData = [
|
||||
'model_name' => $model,
|
||||
'make_id' => $make_id,
|
||||
];
|
||||
|
||||
// Insert the model into the database
|
||||
$BikemodelsModel->insert($modelData);
|
||||
|
||||
// Set success status in the response
|
||||
$response['success'] = true;
|
||||
} else {
|
||||
// If make or model is empty, set success status to false
|
||||
$response['success'] = false;
|
||||
}
|
||||
|
||||
// Send JSON response back to the client
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
public function get_makes()
|
||||
{
|
||||
$BikeMakeModel = new BikeMakeModel(); // Adjust this according to your actual model name
|
||||
$makes = $BikeMakeModel->findAll();
|
||||
return $this->response->setJSON($makes);
|
||||
}
|
||||
public function save_model() {
|
||||
$response = [];
|
||||
$BikemodelsModel = new BikemodelsModel();
|
||||
|
||||
$make_id = $this->request->getPost('make_id');
|
||||
$model = $this->request->getPost('modelvalue');
|
||||
if (!empty($make_id) && !empty($model)) {
|
||||
$modelData = [
|
||||
'model_name' => $model,
|
||||
'make_id' => $make_id,
|
||||
];
|
||||
|
||||
|
||||
$BikemodelsModel->insert($modelData);
|
||||
|
||||
|
||||
$response['success'] = true;
|
||||
} else {
|
||||
|
||||
$response['success'] = false;
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
}
|
||||
32
app/Controllers/Reorderlevel.php
Normal file
32
app/Controllers/Reorderlevel.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\ProductModel;
|
||||
|
||||
|
||||
class Reorderlevel extends BaseController
|
||||
{
|
||||
|
||||
public $session;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->session = session();
|
||||
|
||||
}
|
||||
|
||||
public function reorder_level_index()
|
||||
{
|
||||
|
||||
$productModel = new ProductModel();
|
||||
$reorder = $productModel->where('qty_stock <= purchase_order_level')->findAll();
|
||||
|
||||
// print_r($reorder);die;
|
||||
$data['reorder']=$reorder;
|
||||
|
||||
return view('reorder_level_list',$data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -6,7 +6,8 @@ use App\Models\SalesOrderModel;
|
||||
use App\Models\SalesOrderProductModel;
|
||||
use App\Models\ProductModel;
|
||||
use App\Models\ClientModel;
|
||||
use App\Models\BikeMakeModel;
|
||||
use App\Models\BikemodelsModel;
|
||||
use App\Models\BikemakeModel;
|
||||
use App\Models\VehicleModel;
|
||||
use Mpdf\Mpdf;
|
||||
class Sales extends BaseController
|
||||
@ -16,8 +17,10 @@ class Sales extends BaseController
|
||||
{
|
||||
|
||||
$this->session = session();
|
||||
$this->BikemodelsModel = new BikemodelsModel();
|
||||
$this->BikemakeModel = new BikemakeModel();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function sales_order_index()
|
||||
{
|
||||
@ -322,13 +325,38 @@ public function delete_sales_product()
|
||||
// Load ClientModel
|
||||
$VehicleModel = new VehicleModel();
|
||||
|
||||
// Validate inputs
|
||||
|
||||
|
||||
// If validation passes, proceed to save the client
|
||||
if($this->request->getPost('formType') == 'create')
|
||||
{
|
||||
$ClientModel = new ClientModel();
|
||||
|
||||
$client['client_name'] = $this->request->getPost('createclientName');
|
||||
$client['mobile_no'] = $this->request->getPost('createclientMobile');
|
||||
$client['client_type'] = $this->request->getPost('createclientType');
|
||||
$client['branch_id'] = $this->session->get('logged_user_branch_id');
|
||||
|
||||
$client_id = $ClientModel->insert($client);
|
||||
|
||||
if($client_id){
|
||||
|
||||
$data = [
|
||||
'client_id' => $client_id,
|
||||
'mobile_no' => $this->request->getPost('createclientMobile'),
|
||||
'reg_no' => $this->request->getPost('reg_no'),
|
||||
'model' => $this->request->getPost('model'),
|
||||
'make' => $this->request->getPost('make'),
|
||||
'branch_id'=> $this->session->get('logged_user_branch_id'),
|
||||
'city'=>'Chennai',
|
||||
'state'=>'Tamil Nadu',
|
||||
'isactive' => 1
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$data = [
|
||||
'client_id' => $this->request->getPost('client_id'),
|
||||
|
||||
'mobile_no' => $this->request->getPost('mobile_no'),
|
||||
'reg_no' => $this->request->getPost('reg_no'),
|
||||
'model' => $this->request->getPost('model'),
|
||||
@ -338,6 +366,12 @@ public function delete_sales_product()
|
||||
'state'=>'Tamil Nadu',
|
||||
'isactive' => 1
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Attempt to insert the client data
|
||||
$id = $VehicleModel->insert($data);
|
||||
@ -359,7 +393,7 @@ public function get_vehicle_products(){
|
||||
|
||||
|
||||
|
||||
public function getProducts()
|
||||
public function getProducts()
|
||||
{
|
||||
// Retrieve make_id and model_id from the request
|
||||
$makeId = $this->request->getPost('make_id');
|
||||
@ -376,13 +410,14 @@ public function get_vehicle_products(){
|
||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
->findAll();
|
||||
|
||||
|
||||
if($product){
|
||||
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
|
||||
$makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;
|
||||
if($product){
|
||||
// Send JSON response
|
||||
return $this->response->setJSON($product);
|
||||
return $this->response->setJSON(['product'=>$product , 'modelName'=>$modelName ,'makeName'=>$makeName] );
|
||||
} else {
|
||||
// If product is not found, return an empty response or appropriate message
|
||||
return $this->response->setJSON([]);
|
||||
return $this->response->setJSON(['product'=>[] , 'modelName'=>$modelName ,'makeName'=>$makeName]);
|
||||
}
|
||||
}
|
||||
// Check if product exists
|
||||
|
||||
@ -7,6 +7,7 @@ use App\Models\VendorModel;
|
||||
use App\Models\UsersModel;
|
||||
use App\Models\BikemakeModel;
|
||||
use App\Models\BikemodelsModel;
|
||||
use App\Models\ManufacturerModel;
|
||||
|
||||
|
||||
class Vendor extends BaseController
|
||||
@ -36,10 +37,13 @@ class Vendor extends BaseController
|
||||
if ($vendor_id === '0') {
|
||||
$data['vendor'] = [];
|
||||
$data['page_name'] = "Add Vendor";
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data['manufacturers']=$ManufacturerModel->findAll();
|
||||
} else {
|
||||
$VendorModel = new VendorModel();
|
||||
$vendor = $VendorModel->where('vendor_id', $vendor_id)->get()->getRowArray();
|
||||
|
||||
$ManufacturerModel = new ManufacturerModel();
|
||||
$data['manufacturers']=$ManufacturerModel->findAll();
|
||||
$data['vendor'] = $vendor;
|
||||
$data['page_name'] = "Edit Vendor";
|
||||
|
||||
@ -66,6 +70,7 @@ class Vendor extends BaseController
|
||||
'state' => $this->request->getPost('state'),
|
||||
'postal_code' => $this->request->getPost('postalcode'),
|
||||
'country' => $this->request->getPost('country'),
|
||||
'vendortype' => $this->request->getPost('vendortype'),
|
||||
'category' => $this->request->getPost('category'),
|
||||
'contact_person_name1' => $this->request->getPost('contact_person_name1'),
|
||||
'contact_person_name2' => $this->request->getPost('contact_person_name2'),
|
||||
@ -73,9 +78,10 @@ class Vendor extends BaseController
|
||||
'contact_person_mobile1' => $this->request->getPost('contact_person_mobile1'),
|
||||
'contact_person_mobile2' => $this->request->getPost('contact_person_mobile2'),
|
||||
'contact_person_mobile3' => $this->request->getPost('contact_person_mobile3'),
|
||||
'contact_person_resignation1' => $this->request->getPost('contact_person_resignation1'),
|
||||
'contact_person_resignation2' => $this->request->getPost('contact_person_resignation2'),
|
||||
'contact_person_resignation3' => $this->request->getPost('contact_person_resignation3'),
|
||||
'contact_person_designation1' => $this->request->getPost('contact_person_designation1'),
|
||||
'contact_person_designation2' => $this->request->getPost('contact_person_designation2'),
|
||||
'contact_person_designation3' => $this->request->getPost('contact_person_designation3'),
|
||||
'manufacturer_id' => json_encode($this->request->getPost('manufacturer')),
|
||||
'isactive' => 1 ,
|
||||
'branch_id' => $this->session->get('logged_user_branch_id'),
|
||||
];
|
||||
|
||||
@ -174,6 +174,13 @@
|
||||
<span> Manufacturer </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo base_url('reorder_level_index') ?>">
|
||||
<i class="fas fa-angle-double-up"></i>
|
||||
<span> Reorder Level Products </span>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php if(session()->get('logged_user_role') == 'Floor Manager' ||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php include('layout/header.php'); ?>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
@ -25,7 +25,8 @@
|
||||
<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>
|
||||
|
||||
<label for="make" class="col-form-label">Make<span class="text-danger">*</span><i type="button" class="fe-plus-circle" id="addMakeModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addMakeModal" title="Add Client"></i></label>
|
||||
<select class="form-control SelExample" id="make" name="make" required>
|
||||
<option value="">Select a Make</option>
|
||||
|
||||
@ -38,7 +39,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<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><i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Client"></i></label>
|
||||
<select class="form-control SelExample" id="model" name="model[]" required multiple>
|
||||
<!-- Options for model will be populated dynamically via AJAX -->
|
||||
<?php if(isset($models) && !empty($models)): ?>
|
||||
@ -95,9 +96,9 @@
|
||||
<label for="preferred_vendor" class="col-form-label">Preferred Vendor<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="preferred_vendor" name="prefered_vendor" required>
|
||||
<!-- Loop through vendors and set selected attribute if ID matches preferredVendorId -->
|
||||
<?php foreach ($vendors as $vendor): ?>
|
||||
<option value="<?= $vendor['vendor_id'] ?>" <?= ( $vendor['vendor_id'] == $preferredVendorId) ? 'selected' : '' ?>>
|
||||
<?= $vendor['vendor_name'] ?>
|
||||
<?php foreach ($vendorsProduct as $vendor): ?>
|
||||
<option value="<?= $vendor['id'] ?>" <?= (isset($preferredVendorId) && $vendor['id'] == $preferredVendorId) ? 'selected' : '' ?>>
|
||||
<?= $vendor['name'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@ -187,6 +188,66 @@
|
||||
</div>
|
||||
</div>
|
||||
<?php include('layout/footer.php'); ?>
|
||||
<!-- Make popup -->
|
||||
<div class="modal fade" id="addMakeModal" tabindex="-1" role="dialog" aria-labelledby="addMakeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addMakeModalLabel">Add New Make</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">Make</label>
|
||||
<input type="text" class="form-control" id="makes" placeholder="Enter Make"required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="clientMobile">Model</label>
|
||||
<input type="text" class="form-control" id="models" placeholder="Enter Model"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="saveMakeBtn">Save Make</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal popup -->
|
||||
<div class="modal fade" id="addModelModal" tabindex="-1" role="dialog" aria-labelledby="addModelModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addModelModalLabel">Add New Model</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="addModelForm">
|
||||
<div class="form-group">
|
||||
<label for="makeSelect">Make</label>
|
||||
<select class="form-control" id="makeSelect" required>
|
||||
<!-- Options will be populated dynamically via JavaScript -->
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="modelInput">Model</label>
|
||||
<input type="text" class="form-control" id="modelInput" placeholder="Enter Model" 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="saveModelBtn">Save Model</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
@ -364,14 +425,14 @@ function updatePreferredVendorDropdown() {
|
||||
// Populate preferred vendor options based on selected vendors
|
||||
selectedVendors.forEach(function(vendorId) {
|
||||
var vendorName = $('#vendor option[value="' + vendorId + '"]').text();
|
||||
$('#preferred_vendor').append('<option value="' + vendorId + '" >' + vendorName + '</option>');
|
||||
$('#preferred_vendor').append('<option value="' + vendorId + '" selected>' + vendorName + '</option>');
|
||||
});
|
||||
}
|
||||
|
||||
// Call the function initially
|
||||
$(document).ready(function() {
|
||||
// Update the preferred vendor dropdown initially
|
||||
updatePreferredVendorDropdown();
|
||||
// updatePreferredVendorDropdown();
|
||||
|
||||
// Update the preferred vendor dropdown when vendors selection changes
|
||||
$('#vendor').change(function() {
|
||||
@ -381,3 +442,111 @@ $(document).ready(function() {
|
||||
|
||||
|
||||
</script>
|
||||
<!-- Save a make and model fun -->
|
||||
<script>
|
||||
$('#saveMakeBtn').click(function() {
|
||||
var make = $('#makes').val();
|
||||
var model = $('#models').val();
|
||||
|
||||
if (make != '' && model != '') {
|
||||
$.ajax({
|
||||
url: '<?php echo base_url().'save_make'?>',
|
||||
method: 'POST',
|
||||
data: {
|
||||
make: make,
|
||||
model: model
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$('#addMakeModalButton').modal('hide');
|
||||
// Handle success here, e.g., show a success message
|
||||
toastr.success("Make and model saved successfully");
|
||||
window.location.reload();
|
||||
} else {
|
||||
// Handle failure here, e.g., show an error message
|
||||
toastr.error("Failed to save make and model");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error occurred while saving make and model:', error);
|
||||
toastr.error("Failed to save make and model. Please try again");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastr.warning("Please fill in both make and model fields");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<!-- Save Modal Funxtion -->
|
||||
<script>
|
||||
// Populate make dropdown in the add model modal
|
||||
function populateMakeDropdown() {
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_makes') ?>', // URL to your CodeIgniter controller method to fetch makes
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
$('#makeSelect').empty().append('<option value="">Select Make</option>');
|
||||
response.forEach(function(make) {
|
||||
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
|
||||
});
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Call the function to populate make dropdown initially
|
||||
$(document).ready(function() {
|
||||
populateMakeDropdown();
|
||||
});
|
||||
|
||||
// Save model function
|
||||
$('#saveModelBtn').click(function() {
|
||||
var makeId = $('#makeSelect').val();
|
||||
var model = $('#modelInput').val();
|
||||
console.log(model);
|
||||
if (makeId != '' && model != '') {
|
||||
$.ajax({
|
||||
url: '<?php echo base_url().'save_model'?>',
|
||||
method: 'POST',
|
||||
data: {
|
||||
make_id: makeId,
|
||||
modelvalue: model
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$('#addModelModal').modal('hide');
|
||||
toastr.success("Model saved successfully");
|
||||
window.location.reload();
|
||||
} else {
|
||||
toastr.error("Failed to save model");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error occurred while saving model:', error);
|
||||
toastr.error("Failed to save model. Please try again");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastr.warning("Please fill in both make and model fields");
|
||||
}
|
||||
});
|
||||
</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>
|
||||
73
app/Views/reorder_level_list.php
Normal file
73
app/Views/reorder_level_list.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?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">Product List </h4>
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<!-- <h4 class="header-title">Business List</h4> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100"
|
||||
style="width:100% !important;">
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
|
||||
<th>Product Name</th>
|
||||
<th>Unit Price</th>
|
||||
<th>Qty in Stock</th>
|
||||
<th>Purchase Order Level</th>
|
||||
<th>Purchase Re-Order Level</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($reorder as $value) :
|
||||
?>
|
||||
<tr>
|
||||
<td><?= $value['product_name']; ?></td>
|
||||
<td><?= number_format($value['unit_price']); ?></td>
|
||||
<td><?= $value['qty_stock']; ?></td>
|
||||
<td><?= $value['purchase_order_level']; ?></td>
|
||||
<td><?= $value['reorder_level']; ?></td>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Call the model method -->
|
||||
|
||||
<td>
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- end table-responsive-->
|
||||
|
||||
</div>
|
||||
</div> <!-- end card -->
|
||||
</div> <!-- end col -->
|
||||
|
||||
</div>
|
||||
<?php include('layout/footer.php'); ?>
|
||||
@ -28,37 +28,43 @@
|
||||
<label for="inputEmail4" class="col-form-label">Vehicle<span class="text-danger">*</span></label>
|
||||
<?= isset($sales['vehicle_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addVehicleModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addVehicleModal" title="Add Client"></i>' ?>
|
||||
|
||||
|
||||
<select class="form-control vehicle-select SelExample" name="vehicle_id" <?= isset($sales['vehicle_id']) ? '' : 'required' ?>>
|
||||
|
||||
<?= isset($sales['vehicle_id']) ? '' : '<option value="">Select a vehicle</option>' ?>
|
||||
<?php foreach ($vehicle as $value) : ?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["vehicle_id"] ?>" <?= isset($sales['vehicle_id']) && $sales['vehicle_id'] == $value["vehicle_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["reg_no"]?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?= isset($sales['vehicle_id']) ? '' : '<option value="">Select a vehicle</option>' ?>
|
||||
<?php foreach ($vehicle as $value) : ?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["vehicle_id"] ?>" <?= isset($sales['vehicle_id']) && $sales['vehicle_id'] == $value["vehicle_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["reg_no"]?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">Make and Model</label>
|
||||
<input type="text" class="form-control" id="makeAndModel" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Client Name<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" name="client_id" placeholder="Client"value="<?= isset($sales['client_name']) ? $sales['client_name'] : '' ?>" readonly>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Mobile No<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile" value="<?= isset($sales['mobile_no']) ? $sales['mobile_no'] : '' ?>" maxlength="10" minlength="10" onkeypress = "return onlyNumbers(event)" readonly>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">Status<span class="text-danger">*</span></label>
|
||||
<select class="form-control status-select" name="status" required data-toggle="select2" >
|
||||
<!-- <option value="">Select a Status</option> -->
|
||||
<option value="Created" <?= isset($sales['status']) && $sales['status'] === 'Created' ? 'selected' : '' ?>>Created</option>
|
||||
<option value="Paid" <?= isset($sales['status']) && $sales['status'] === 'Paid' ? 'selected' : '' ?>>Paid</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Status<span class="text-danger">*</span></label>
|
||||
<select class="form-control status-select" name="status" required data-toggle="select2" >
|
||||
<!-- <option value="">Select a Status</option> -->
|
||||
<option value="Created" <?= isset($sales['status']) && $sales['status'] === 'Created' ? 'selected' : '' ?>>Created</option>
|
||||
<option value="Paid" <?= isset($sales['status']) && $sales['status'] === 'Paid' ? 'selected' : '' ?>>Paid</option>
|
||||
</select>
|
||||
</div>
|
||||
</div><br>
|
||||
|
||||
|
||||
</div><br>
|
||||
<h4 class="header-title">Billing Address Details :</h4><br>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
@ -228,63 +234,90 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="addClientForm">
|
||||
<form >
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<!-- <div class="form-group"> -->
|
||||
|
||||
<label for="inputPassword4" class="col-form-label">Make</label>
|
||||
<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>
|
||||
<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-6">
|
||||
<label for="inputPassword4" class="col-form-label">Model</label>
|
||||
<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>
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="inputPassword4" class="col-form-label">Reg Number</label>
|
||||
<input type="text" class="form-control" name="reg_no" id="reg_no" placeholder="Reg Number"value="<?= isset($vehicle['reg_no']) ? $vehicle['reg_no'] : '' ?>" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<!-- <div class="form-group"> -->
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">Model</label>
|
||||
<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>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="inputPassword4" class="col-form-label">Reg Number</label>
|
||||
<input type="text" class="form-control" name="reg_no" id="reg_no" placeholder="Reg Number"value="<?= isset($vehicle['reg_no']) ? $vehicle['reg_no'] : '' ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<input type="text" value="select" id="formType" hidden>
|
||||
|
||||
<div class="form-group col-md-12 select">
|
||||
<label for="clientName">Client Name</label>
|
||||
<select class="form-control cleint-select SelExample" name="client_id" id=clientName <?= isset($sales['client_id']) ? '' : 'required' ?>>
|
||||
<i type="button" class="fe-user-plus" id="createClient" style="font-size: 18px;" ></i>
|
||||
<select class="form-control cleint-select SelExample" id="clientName" required>
|
||||
<option value="">Select a Client</option>
|
||||
<?php foreach ($client as $value) : ?>
|
||||
<option value="<?= $value["client_id"] ?>">
|
||||
<?= $value["mobile_no"] .' - '. $value["client_name"]; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<?= isset($sales['client_id']) ? '' : '<option value="">Select a Client</option>' ?>
|
||||
<?php foreach ($client as $value) : ?>
|
||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||
<option value="<?= $value["client_id"] ?>" <?= isset($sales['client_id']) && $sales['client_id'] == $value["client_id"] ? 'selected' : '' ?>>
|
||||
<?= $value["client_name"]; ?>
|
||||
</option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<div class="form-group col-md-12 select">
|
||||
<label for="clientMobile">Mobile</label>
|
||||
<input type="text" class="form-control" id="mobile" name="mobile"placeholder="Enter mobile number" maxlength="10" minlength="10"onkeypress = "return onlyNumbers(event)"required>
|
||||
<input type="text" class="form-control" id="clientMobile" placeholder="Enter mobile number" maxlength="10" minlength="10"onkeypress = "return onlyNumbers(event)"required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="form-group col-md-12 create" style="display:none;">
|
||||
<label for="create-clientName">Client Name</label>
|
||||
<i type="button" class="fe-user-check" id="selectClient" style="font-size: 18px;" ></i>
|
||||
<input type="text" class="form-control" id="create-clientName" placeholder="Enter client name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6 create" style="display:none;">
|
||||
<label for="create-clientMobile">Mobile</label>
|
||||
<input type="text" class="form-control" id="create-clientMobile" placeholder="Enter mobile number" maxlength="10" minlength="10"onkeypress = "return onlyNumbers(event)"required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6 create" style="display:none;">
|
||||
<label for="create-clientType">Client Type</label>
|
||||
<select class="form-control status-select" id="create-clientType" required >
|
||||
<option value="">Select a Type</option>
|
||||
<option value="Direct" >Direct</option>
|
||||
<option value="Mechanic" >Mechanic</option>
|
||||
<option value="Exp" >Exp</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -329,7 +362,10 @@ $(document).ready(function() {
|
||||
vehicle_id: vehicleId
|
||||
},
|
||||
success: function(response) {
|
||||
productarray = response;
|
||||
console.log(response);
|
||||
productarray = response.product;
|
||||
makeAndModel = response.makeName+' '+response.modelName;
|
||||
$('#makeAndModel').val(makeAndModel);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error
|
||||
@ -547,14 +583,13 @@ $(document).ready(function() {
|
||||
$('.vehicle-select').change(function() {
|
||||
|
||||
var vehicleId = $(this).val();
|
||||
// console.log(vehicleId);
|
||||
if (vehicleId !== '') {
|
||||
// Find the selected client in the client data
|
||||
var selectedClient = vehicles.find(function(vehicle) {
|
||||
return vehicle.vehicle_id == vehicleId;
|
||||
});
|
||||
// console.log(selectedClient);
|
||||
// Populate the billing address, city, state, country, and postal code fields
|
||||
|
||||
|
||||
|
||||
$('input[name="client_id"]').val(selectedClient.client_name);
|
||||
$('input[name="billing_address"]').val(selectedClient.address);
|
||||
@ -581,11 +616,11 @@ $(document).ready(function() {
|
||||
var selectedClients = clients.find(function(client) {
|
||||
return client.client_id == clientId;
|
||||
});
|
||||
console.log(selectedClients);
|
||||
|
||||
// Populate the billing address, city, state, country, and postal code fields
|
||||
|
||||
|
||||
$('input[name="mobile"]').val(selectedClients.mobile_no);
|
||||
$('input[id="clientMobile"]').val(selectedClients.mobile_no);
|
||||
|
||||
}
|
||||
});
|
||||
@ -625,13 +660,30 @@ $(document).ready(function() {
|
||||
// AJAX request to save client
|
||||
$('#saveVehcileBtn').click(function() {
|
||||
|
||||
var formType = $('#formType').val();
|
||||
console.log(formType);
|
||||
|
||||
var clientName = $('#clientName').val();
|
||||
var clientMobile = $('#mobile').val();
|
||||
var reg_no = $('#reg_no').val();
|
||||
var model = $('#model').val();
|
||||
var make = $('#make').val();
|
||||
if(clientName != '' && clientMobile != ''&®_no != '' && model != '' && make != ''){
|
||||
|
||||
var clientName = $('#clientName').val();
|
||||
var clientMobile = $('#clientMobile').val();
|
||||
|
||||
var createclientName = $('#create-clientName').val();
|
||||
var createclientMobile = $('#create-clientMobile').val();
|
||||
var createclientType = $('#create-clientType').val();
|
||||
|
||||
if (formType == 'select')
|
||||
{
|
||||
var ifStatementCondition = "clientName !== '' && clientMobile !== '' && reg_no !== '' && model !== '' && make !== ''";
|
||||
} else {
|
||||
var ifStatementCondition = "createclientName !== '' && createclientMobile !== '' && createclientType !== '' && reg_no !== '' && model !== '' && make !== ''";
|
||||
}
|
||||
|
||||
console.log(ifStatementCondition);
|
||||
|
||||
if( eval(ifStatementCondition) ){
|
||||
|
||||
// Send AJAX request to save the client
|
||||
$.ajax({
|
||||
@ -642,24 +694,24 @@ $(document).ready(function() {
|
||||
mobile_no: clientMobile,
|
||||
reg_no:reg_no,
|
||||
model:model,
|
||||
make:make
|
||||
make:make,
|
||||
createclientName:createclientName,
|
||||
createclientMobile:createclientMobile,
|
||||
createclientType:createclientType,
|
||||
formType:formType,
|
||||
|
||||
},
|
||||
success: function(response) {
|
||||
// Check if the operation was successful
|
||||
if (response.success) {
|
||||
// Client saved successfully, close the modal and do any additional actions
|
||||
$('#addVehicleModal').modal('hide');
|
||||
// Optionally, you can update the client dropdown or show a success message
|
||||
toastr.success("Vehicle saved successfully!");
|
||||
window.location.reload(); // Reload the page
|
||||
window.location.reload();
|
||||
|
||||
} else {
|
||||
// Client save operation failed, display error message
|
||||
toastr.warning("Failed to save vehicle. Please try again");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// AJAX request failed, display error message
|
||||
console.error('Error occurred while saving vehicle:', error);
|
||||
toastr.warning("Failed to save vehicle. Please try again");
|
||||
}
|
||||
@ -712,7 +764,27 @@ document.getElementById('reg_no').addEventListener('input', function(event) {
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(document).on('click', '#createClient', function() {
|
||||
$('.create').show();
|
||||
$('.select').hide();
|
||||
$('#formType').val('create');
|
||||
|
||||
$('#clientName').val('');
|
||||
$('#clientMobile').val('');
|
||||
|
||||
|
||||
});
|
||||
$(document).on('click', '#selectClient', function() {
|
||||
$('.select').show();
|
||||
$('.create').hide();
|
||||
$('#formType').val('select');
|
||||
|
||||
$('#create-clientName').val('');
|
||||
$('#create-clientMobile').val('');
|
||||
$('#create-clientType').val('');
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<h4 class="header-title">Vehicle Details :</h4>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span></label>
|
||||
<label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span><i type="button" class="fe-plus-circle" id="addMakeModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addMakeModal" title="Add Client"></i></label>
|
||||
<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) : ?>
|
||||
@ -36,7 +36,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Model<span class="text-danger">*</span></label>
|
||||
<label for="inputPassword4" class="col-form-label">Model<span class="text-danger">*</span><i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Client"></i></label>
|
||||
<select class="form-control SelExample" name="model" id="model" <?= isset($vehicle['model']) ? '' : 'required' ?>>
|
||||
<?php if (isset($vehicle["model_name"])) : ?>
|
||||
<option value="<?= $vehicle["model"] ?>" >
|
||||
@ -119,7 +119,36 @@
|
||||
|
||||
<?php include('layout/footer.php'); ?>
|
||||
</div>
|
||||
|
||||
<!-- ADD MAKE -->
|
||||
<div class="modal fade" id="addMakeModal" tabindex="-1" role="dialog" aria-labelledby="addMakeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addMakeModalLabel">Add New Make</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">Make</label>
|
||||
<input type="text" class="form-control" id="makes" placeholder="Enter Make"required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="clientMobile">Model</label>
|
||||
<input type="text" class="form-control" id="models" placeholder="Enter Model"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="saveMakeBtn">Save Make</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Client Modal -->
|
||||
<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">
|
||||
@ -137,7 +166,16 @@
|
||||
</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>
|
||||
<input type="text" class="form-control" id="clientMobile" placeholder="Enter mobile number" maxlength="10" minlength="10" onkeypress = "return onlyNumbers(event)" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="clientType">Client Type</label>
|
||||
<select class="form-control status-select" id="clientType" required >
|
||||
<option value="">Select a Type</option>
|
||||
<option value="Direct" >Direct</option>
|
||||
<option value="Mechanic" >Mechanic</option>
|
||||
<option value="Exp" >Exp</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -148,6 +186,37 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal popup -->
|
||||
<div class="modal fade" id="addModelModal" tabindex="-1" role="dialog" aria-labelledby="addModelModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="addModelModalLabel">Add New Model</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="addModelForm">
|
||||
<div class="form-group">
|
||||
<label for="makeSelect">Make</label>
|
||||
<select class="form-control" id="makeSelect" required>
|
||||
<!-- Options will be populated dynamically via JavaScript -->
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="modelInput">Model</label>
|
||||
<input type="text" class="form-control" id="modelInput" placeholder="Enter Model" 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="saveModelBtn">Save Model</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>
|
||||
@ -225,7 +294,8 @@ $(document).ready(function() {
|
||||
|
||||
var clientName = $('#clientName').val();
|
||||
var clientMobile = $('#clientMobile').val();
|
||||
if(clientName != '' && clientMobile != ''){
|
||||
var clientType = $('#clientType').val();
|
||||
if(clientName != '' && clientMobile != '' && clientType != ''){
|
||||
|
||||
// Send AJAX request to save the client
|
||||
$.ajax({
|
||||
@ -233,7 +303,8 @@ $(document).ready(function() {
|
||||
method: 'POST',
|
||||
data: {
|
||||
client_name: clientName,
|
||||
mobile_no: clientMobile
|
||||
mobile_no: clientMobile,
|
||||
client_type : clientType,
|
||||
},
|
||||
success: function(response) {
|
||||
// Check if the operation was successful
|
||||
@ -259,7 +330,7 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
}else{
|
||||
toastr.warning("Please Fill Name and Mobile data");
|
||||
toastr.warning("Please Fill All Datas");
|
||||
}
|
||||
|
||||
|
||||
@ -269,7 +340,98 @@ $(document).ready(function() {
|
||||
// Define the clients array and populate it with data
|
||||
var clients = <?php echo json_encode($client); ?>;
|
||||
</script>
|
||||
<!-- Mkae Modal ajax -->
|
||||
<script>
|
||||
$('#saveMakeBtn').click(function() {
|
||||
var make = $('#makes').val();
|
||||
var model = $('#models').val();
|
||||
|
||||
if (make != '' && model != '') {
|
||||
$.ajax({
|
||||
url: '<?php echo base_url().'save_make'?>',
|
||||
method: 'POST',
|
||||
data: {
|
||||
make: make,
|
||||
model: model
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$('#addMakeModalButton').modal('hide');
|
||||
// Handle success here, e.g., show a success message
|
||||
toastr.success("Make and model saved successfully");
|
||||
window.location.reload();
|
||||
} else {
|
||||
// Handle failure here, e.g., show an error message
|
||||
toastr.error("Failed to save make and model");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error occurred while saving make and model:', error);
|
||||
toastr.error("Failed to save make and model. Please try again");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastr.warning("Please fill in both make and model fields");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<!-- aDD MODEL FUNCTION -->
|
||||
<script>
|
||||
// Populate make dropdown in the add model modal
|
||||
function populateMakeDropdown() {
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_makes') ?>', // URL to your CodeIgniter controller method to fetch makes
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
$('#makeSelect').empty().append('<option value="">Select Make</option>');
|
||||
response.forEach(function(make) {
|
||||
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
|
||||
});
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Call the function to populate make dropdown initially
|
||||
$(document).ready(function() {
|
||||
populateMakeDropdown();
|
||||
});
|
||||
|
||||
// Save model function
|
||||
$('#saveModelBtn').click(function() {
|
||||
var makeId = $('#makeSelect').val();
|
||||
var model = $('#modelInput').val();
|
||||
console.log(model);
|
||||
if (makeId != '' && model != '') {
|
||||
$.ajax({
|
||||
url: '<?php echo base_url().'save_model'?>',
|
||||
method: 'POST',
|
||||
data: {
|
||||
make_id: makeId,
|
||||
modelvalue: model
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$('#addModelModal').modal('hide');
|
||||
toastr.success("Model saved successfully");
|
||||
window.location.reload();
|
||||
} else {
|
||||
toastr.error("Failed to save model");
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error occurred while saving model:', error);
|
||||
toastr.error("Failed to save model. Please try again");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toastr.warning("Please fill in both make and model fields");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||
color:#ffffff;
|
||||
|
||||
@ -55,10 +55,22 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="manufacturer" class="col-form-label">Manufacturer<span class="text-danger">*</span></label>
|
||||
<select class="form-control SelExample" id="manufacturer" name="manufacturer[]" required multiple>
|
||||
<option value="">Select a Manufacturer</option>
|
||||
<?php if(isset($manufacturers) && !empty($manufacturers)): ?>
|
||||
<?php foreach($manufacturers as $value): ?>
|
||||
<option value="<?= $value['manufacturer_id'] ?>" <?= isset($vendor['manufacturer_id']) && in_array($value['manufacturer_id'], json_decode($vendor['manufacturer_id'], true)) ? 'selected' : '' ?>>
|
||||
<?= $value['manufacturer_name'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<br>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user