CHANGES-in-vehicle,product-module-quickCreateForm:GWN

This commit is contained in:
bitbucket 2024-04-12 13:55:36 +05:30
parent 933b59e6b1
commit 5a043309fe
4 changed files with 96 additions and 68 deletions

View File

@ -313,10 +313,14 @@ public function save_model() {
]; ];
$BikemodelsModel->insert($modelData); $model_id = $BikemodelsModel->insert($modelData);
$modelData = $BikemodelsModel->where('make_id',$make_id)->findAll();
$response['success'] = true; $response['success'] = true;
$response['model_id'] = $model_id;
$response['model_value'] = $model;
} else { } else {
$response['success'] = false; $response['success'] = false;

View File

@ -122,6 +122,8 @@
<?php if(session()->get('logged_user_role') == 'Floor Manager' || <?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') { session()->get('logged_user_role') == 'Store Manager') {
@ -144,7 +146,7 @@
<a href="<?php echo base_url('vendor_index') ?>">Vendor</a> <a href="<?php echo base_url('vendor_index') ?>">Vendor</a>
</li> </li>
<li> <li>
<a href="<?php echo base_url('purchase_index') ?>">Purchase</a> <a href="<?php echo base_url('purchase_index') ?>">Purchase Order</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -157,17 +159,6 @@
<li class="menu-title">Masters</li>
<li>
<a href="<?php echo base_url('make_index') ?>">
<i class="fas fa-bicycle"></i>
<span> Make & Models</span>
</a>
</li>
<li> <li>
<a href="<?php echo base_url('spare_manufacturer_index') ?>"> <a href="<?php echo base_url('spare_manufacturer_index') ?>">
<i class="fas fa-cogs"></i> <i class="fas fa-cogs"></i>
@ -175,11 +166,14 @@
</a> </a>
</li> </li>
<li> <li>
<a href="<?php echo base_url('reorder_level_index') ?>"> <a href="<?php echo base_url('reorder_level_index') ?>">
<i class="fas fa-angle-double-up"></i> <i class="fas fa-angle-double-up"></i>
<span> Reorder Level Products </span> <span> Reorder Level Products </span>
</a> </a>
</li>
@ -200,6 +194,18 @@
<li> <a href="<?php echo base_url('business_index') ?>"><i class="ri-layout-line"></i><span> Business </span></a></li> <li> <a href="<?php echo base_url('business_index') ?>"><i class="ri-layout-line"></i><span> Business </span></a></li>
<?php } ?> <?php } ?>
<li class="menu-title">Masters</li>
<li>
<a href="<?php echo base_url('make_index') ?>">
<i class="fas fa-bicycle"></i>
<span> Make & Models</span>
</a>
</li>
</ul> </ul>
</div> </div>

View File

@ -26,53 +26,56 @@
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<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> <label for="make" class="col-form-label">Make<span class="text-danger">*</span></label>
<?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addMakeModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addMakeModal" title="Add Client"></i>' ?>
<select class="form-control SelExample" id="make" name="make" required> <select class="form-control SelExample" id="make" name="make" required>
<option value="">Select a Make</option> <option value="">Select a Make</option>
<!-- Options for make --> <!-- Options for make -->
<?php foreach ($make as $value): ?> <?php foreach ($make as $value): ?>
<option value="<?= $value['make_id'] ?>" <?= isset($products['make_id']) && $products['make_id'] == $value['make_id'] ? 'selected' : '' ?>> <option value="<?= $value['make_id'] ?>" <?= isset($products['make_id']) && $products['make_id'] == $value['make_id'] ? 'selected' : '' ?>>
<?= $value['make'] ?> <?= $value['make'] ?>
</option> </option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<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> <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> <?= isset($products['product_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Client"></i>'; ?>
<!-- Options for model will be populated dynamically via AJAX --> <select class="form-control SelExample" id="model" name="model[]" required multiple>
<?php if(isset($models) && !empty($models)): ?> <!-- Options for model will be populated dynamically via AJAX -->
<?php foreach($models as $model): ?> <?php if(isset($models) && !empty($models)): ?>
<option value="<?= $model['model_id'] ?>" <?= isset($products['models_id']) && in_array($model['model_id'], json_decode($products['models_id'], true)) ? 'selected' : '' ?>> <?php foreach($models as $model): ?>
<?= $model['model_name'] ?> <option value="<?= $model['model_id'] ?>" <?= isset($products['models_id']) && in_array($model['model_id'], json_decode($products['models_id'], true)) ? 'selected' : '' ?>>
</option> <?= $model['model_name'] ?>
<?php endforeach; ?> </option>
<?php endif; ?> <?php endforeach; ?>
</select> <?php endif; ?>
</div> </select>
</div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputEmail4" class="col-form-label">Product Name<span class="text-danger">*</span></label> <label for="inputEmail4" class="col-form-label">Product Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="productname" placeholder="Product Name" value="<?= isset($products['product_name']) ? $products['product_name'] : '' ?>" required> <input type="text" class="form-control" name="productname" placeholder="Product Name" value="<?= isset($products['product_name']) ? $products['product_name'] : '' ?>" required>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="manufacturer" class="col-form-label">Manufacturer<span class="text-danger">*</span></label> <label for="manufacturer" class="col-form-label">Manufacturer<span class="text-danger">*</span></label>
<select class="form-control SelExample" id="manufacturer" name="manufacturer" required> <select class="form-control SelExample" id="manufacturer" name="manufacturer" required>
<option value="">Select a Manufacturer</option> <option value="">Select a Manufacturer</option>
<?php foreach ($manufacturers as $value): ?> <?php foreach ($manufacturers as $value): ?>
<option value="<?= $value['manufacturer_id'] ?>" <?= isset($products['manufacturer_id']) && $products['manufacturer_id'] == $value['manufacturer_id'] ? 'selected' : '' ?>> <option value="<?= $value['manufacturer_id'] ?>" <?= isset($products['manufacturer_id']) && $products['manufacturer_id'] == $value['manufacturer_id'] ? 'selected' : '' ?>>
<?= $value['manufacturer_name'] ?> <?= $value['manufacturer_name'] ?>
</option> </option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="quality" class="col-form-label">Quality<span class="text-danger">*</span></label> <label for="quality" class="col-form-label">Quality<span class="text-danger">*</span></label>
<select class="form-control" name="quality" id="quality" required data-toggle="select2"> <select class="form-control" name="quality" id="quality" required data-toggle="select2">
<!-- Options for quality will be populated dynamically via JavaScript --> <!-- Options for quality will be populated dynamically via JavaScript -->
</select> </select>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="inputAddress" class="col-form-label">Manfacturer Part Number</label> <label for="inputAddress" class="col-form-label">Manfacturer Part Number</label>
@ -139,9 +142,9 @@
$tax = $sgst + $cgst; // Total tax (sum of SGST and CGST) $tax = $sgst + $cgst; // Total tax (sum of SGST and CGST)
?> ?>
<option value="0" <?= ($tax == 0) ? 'selected' : '' ?>>0%</option> <option value="0" <?= ($tax == 0) ? 'selected' : '' ?>>0%</option>
<option value="18" <?= ($tax == 18) ?'selected' : '' ?>>18%</option> <option value="5" <?= ($tax == 5) ? 'selected' : '' ?>>5%</option>
<option value="5" <?= ($tax == 5) ? 'selected' : '' ?>>5%</option>
<option value="12" <?= ($tax == 12) ? 'selected' : '' ?>>12%</option> <option value="12" <?= ($tax == 12) ? 'selected' : '' ?>>12%</option>
<option value="18" <?= ($tax == 18) ?'selected' : '' ?>>18%</option>
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option> <option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
</select> </select>
</div> </div>
@ -230,9 +233,9 @@
<div class="modal-body"> <div class="modal-body">
<form id="addModelForm"> <form id="addModelForm">
<div class="form-group"> <div class="form-group">
<label for="makeSelect">Make</label> <label for="makeSelect">Make</label><span id="makeSelectMessage" style="color: red;font-size: 12px; padding-left: 10px;"> (Please select Make from Product Form)</span>
<select class="form-control" id="makeSelect" required> <select class="form-control" id="makeSelect" required>
<!-- Options will be populated dynamically via JavaScript -->
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -293,6 +296,10 @@ $(document).ready(function(){
$(document).ready(function() { $(document).ready(function() {
$('#make').change(function() { $('#make').change(function() {
var make_id = $(this).val(); // Get the selected make ID var make_id = $(this).val(); // Get the selected make ID
make_value = $('option:selected', this).text();
$('#makeSelect').empty();
$('#makeSelect').append('<option value="' + make_id + '">' + make_value + '</option>');
$('#makeSelectMessage').hide();
// AJAX request to get models based on the selected make ID // AJAX request to get models based on the selected make ID
$.ajax({ $.ajax({
@ -486,7 +493,8 @@ function populateMakeDropdown() {
type: 'GET', type: 'GET',
dataType: 'json', dataType: 'json',
success: function(response) { success: function(response) {
$('#makeSelect').empty().append('<option value="">Select Make</option>'); $('#makeSelect').empty();
$('#makeSelect').append('<option value="">Select Make</option>');
response.forEach(function(make) { response.forEach(function(make) {
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>'); $('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
}); });
@ -499,7 +507,7 @@ function populateMakeDropdown() {
// Call the function to populate make dropdown initially // Call the function to populate make dropdown initially
$(document).ready(function() { $(document).ready(function() {
populateMakeDropdown(); // populateMakeDropdown();
}); });
// Save model function // Save model function
@ -519,7 +527,9 @@ console.log(model);
if (response.success) { if (response.success) {
$('#addModelModal').modal('hide'); $('#addModelModal').modal('hide');
toastr.success("Model saved successfully"); toastr.success("Model saved successfully");
window.location.reload();
$('#model').append('<option value="' + response.model_id + '">' + response.model_value + '</option>');
} else { } else {
toastr.error("Failed to save model"); toastr.error("Failed to save model");
} }

View File

@ -23,7 +23,8 @@
<h4 class="header-title">Vehicle Details :</h4> <h4 class="header-title">Vehicle Details :</h4>
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<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> <label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span></label>
<?= isset($vehicle['client_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addMakeModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addMakeModal" title="Add Client"></i>' ?>
<select class="form-control SelExample" name="make" id="make" <?= isset($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>' ?> <?= isset($vehicle['make']) ? '' : '<option value="">Select a Make</option>' ?>
<?php foreach ($makeData as $value) : ?> <?php foreach ($makeData as $value) : ?>
@ -36,7 +37,8 @@
</select> </select>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<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> <label for="inputPassword4" class="col-form-label">Model<span class="text-danger">*</span></label>
<?= isset($vehicle['client_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addModelModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addModelModal" title="Add Client"></i>' ?>
<select class="form-control SelExample" name="model" id="model" <?= isset($vehicle['model']) ? '' : 'required' ?>> <select class="form-control SelExample" name="model" id="model" <?= isset($vehicle['model']) ? '' : 'required' ?>>
<?php if (isset($vehicle["model_name"])) : ?> <?php if (isset($vehicle["model_name"])) : ?>
<option value="<?= $vehicle["model"] ?>" > <option value="<?= $vehicle["model"] ?>" >
@ -199,9 +201,9 @@
<div class="modal-body"> <div class="modal-body">
<form id="addModelForm"> <form id="addModelForm">
<div class="form-group"> <div class="form-group">
<label for="makeSelect">Make</label> <label for="makeSelect">Make</label><span id="makeSelectMessage" style="color: red;font-size: 12px; padding-left: 10px;"> (Please select Make from Product Form)</span>
<select class="form-control" id="makeSelect" required> <select class="form-control" id="makeSelect" required>
<!-- Options will be populated dynamically via JavaScript -->
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -249,6 +251,10 @@ $(document).ready(function() {
// Event listener for change in make select dropdown // Event listener for change in make select dropdown
$("#make").on('change', function() { $("#make").on('change', function() {
var selected_makes = $(this).val(); // Get an array of selected make IDs var selected_makes = $(this).val(); // Get an array of selected make IDs
make_value = $('option:selected', this).text();
$('#makeSelect').empty();
$('#makeSelect').append('<option value="' + selected_makes + '">' + make_value + '</option>');
$('#makeSelectMessage').hide();
// AJAX request to fetch models based on selected make IDs // AJAX request to fetch models based on selected make IDs
$.ajax({ $.ajax({
url: '<?= base_url("fetch_models") ?>', // URL to your controller method for fetching models url: '<?= base_url("fetch_models") ?>', // URL to your controller method for fetching models
@ -316,7 +322,8 @@ $(document).ready(function() {
console.log(response.clientData); console.log(response.clientData);
$("#clientData").append('<option value="' + response.clientData.client_id + '">' + response.clientData.client_name + '</option>'); $("#clientData").append('<option value="' + response.clientData.client_id + '">' + response.clientData.client_name + '</option>');
// Manually select the newly added option // Manually select the newly added option
$("#clientData").val(response.clientData.client_id).trigger('change'); $("#clientData").val(response.clientData.client_id);
$('input[name="mobile_no"]').val(response.clientData.mobile_no);
} else { } else {
// Client save operation failed, display error message // Client save operation failed, display error message
toastr.warning("Failed to save client. Please try again"); toastr.warning("Failed to save client. Please try again");
@ -384,7 +391,8 @@ function populateMakeDropdown() {
type: 'GET', type: 'GET',
dataType: 'json', dataType: 'json',
success: function(response) { success: function(response) {
$('#makeSelect').empty().append('<option value="">Select Make</option>'); $('#makeSelect').empty();
$('#makeSelect').append('<option value="">Select Make</option>');
response.forEach(function(make) { response.forEach(function(make) {
$('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>'); $('#makeSelect').append('<option value="' + make.make_id + '">' + make.make + '</option>');
}); });
@ -397,7 +405,7 @@ function populateMakeDropdown() {
// Call the function to populate make dropdown initially // Call the function to populate make dropdown initially
$(document).ready(function() { $(document).ready(function() {
populateMakeDropdown(); //populateMakeDropdown();
}); });
// Save model function // Save model function
@ -417,7 +425,7 @@ console.log(model);
if (response.success) { if (response.success) {
$('#addModelModal').modal('hide'); $('#addModelModal').modal('hide');
toastr.success("Model saved successfully"); toastr.success("Model saved successfully");
window.location.reload(); $('#model').append('<option value="' + response.model_id + '">' + response.model_value + '</option>');
} else { } else {
toastr.error("Failed to save model"); toastr.error("Failed to save model");
} }