Changes in product module : GWM

This commit is contained in:
Gowtham M 2024-11-21 11:41:11 +05:30
parent 04bcd4b694
commit 690780e4b2
6 changed files with 140 additions and 28 deletions

View File

@ -73,6 +73,7 @@ $routes->post("save_manufacturer", "Products::save_manufacturer");
$routes->get("product_list_for_service", "Products::product_list_for_service");
$routes->post('status_product', 'Products::status_product');
$routes->get('delete_product_name/(:any)', 'Products::delete_product_name/$1');
$routes->get('get_product_addtional_details/(:any)', 'Products::get_product_addtional_details/$1');
//end products//
//Sales order //

View File

@ -571,5 +571,27 @@ class Products extends BaseController
return redirect()->to('new_product/' . $product_id);
}
public function get_product_addtional_details($product_id)
{
$ProductModel = new ProductModel();
$products = $ProductModel->where('product_id', $product_id)->get()->getRowArray();
$products['models_id'] = json_decode($products['models_id'], true);
$BikemodelsModel = new BikemodelsModel();
$models = [];
if( $products['models_id'] != null) {
foreach ($products['models_id'] as $model_id) {
$model = $BikemodelsModel->select('model_name')->where('model_id', $model_id)->get()->getRow();
array_push($models,$model);
}
}
$data['modelNames'] = $models;
$data['additionalNames'] = $this->additionalProductNameModal->select('additional_product_name')->where('product_id', $product_id)->findAll();
return json_encode($data);
}
}

View File

@ -17,7 +17,7 @@
<div class="card">
<div class="card-body">
<h4 class="header-title"></h4>
<form action="<?= base_url() . "add_product"; ?>" method="post">
<form action="<?= base_url() . "add_product"; ?>" id="productForm" method="post">
<h4 class="header-title">Product Details :</h4><br>
<div class="form-row">
<div class="form-group col-md-4">
@ -144,9 +144,14 @@
<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>
<div class="form-row">
<div class="form-group col-md-3">
<!-- <div class="form-group col-md-3">
<label class="col-form-label">Purchase Cost<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="purchase_cost" placeholder="Purchase Cost"value="<?= isset($products['purchase_cost']) ? $products['purchase_cost'] : '' ?>" required>
</div> -->
<div class="form-group col-md-3">
<label class="col-form-label">Unit Price (Including Tax)<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="total_amount" placeholder="Total Price" value="<?= isset($products['total_amount']) ? $products['total_amount'] : '' ?>" required >
</div>
<div class="form-group col-md-3">
@ -162,10 +167,9 @@
<option value="28" <?= ($tax == 28) ? 'selected' : '' ?>>28%</option>
</select>
</div>
<div class="form-group col-md-3">
<label class="col-form-label">Unit Price + Tax<span class="text-danger">*</span></label>
<input type="number" class="form-control" name="total_amount" placeholder="Total Price" value="<?= isset($products['total_amount']) ? $products['total_amount'] : '' ?>" required >
</div>
<div class="form-group col-md-3">
<label class="col-form-label">Unit Price<span class="text-danger">*</span></label>
<input type="test" class="form-control" name="unit_price" placeholder="Price" value="<?= isset($products['unit_price']) ? $products['unit_price'] : '' ?>" required readonly>
@ -235,7 +239,7 @@
</div><br>
<h4 class="header-title">Additional Product Names :</h4><br>
<div id="dynamic-form-container"></div>
<button type="submit" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-primary" style="float:right;">Submit</button>
</form>
</div>
</div>
@ -938,5 +942,12 @@ function deleteProductName(data) {
}
}
// Prevent multiple submissions by disabling the button on first click
document.querySelector('#productForm').addEventListener('submit', function (e) {
const submitButton = this.querySelector('button[type="submit"]');
submitButton.disabled = true; // Disable the button
submitButton.textContent = 'Processing...'; // Optional: Show loading text
});
</script>

View File

@ -50,25 +50,25 @@
<thead>
<tr >
<td style="border: none;">
<input class="form-control form-control-sm" type="text" id="searchSKUId" placeholder="Search SKU Id">
<input class="form-control form-control-sm" type="text" id="searchSKUId" placeholder=" SKU Id">
</td>
<td style="border: none;">
<input class="form-control form-control-sm" type="text" id="searchProductName" placeholder="Search Product Name">
<input class="form-control form-control-sm" type="text" id="searchProductName" placeholder=" Product Name">
</td>
<td style="border: none;">
<input class="form-control form-control-sm" type="text" id="searchManufacturerName" placeholder="Search Manufacturer Name">
<input class="form-control form-control-sm" type="text" id="searchManufacturerName" placeholder=" Manufacturer Name">
</td>
<td>
<input class="form-control form-control-sm" type="text" id="searchCategory" placeholder="Search Category">
<input class="form-control form-control-sm" type="text" id="searchCategory" placeholder=" Category">
</td>
<td>
<input class="form-control form-control-sm" type="text" id="searchUnitPrice" placeholder="Search Unit Price">
<input class="form-control form-control-sm" type="text" id="searchUnitPrice" placeholder=" Unit Price">
</td>
<td>
<input class="form-control form-control-sm" type="text" id="searchQtyStock" placeholder="Search Qty in Stock">
<input class="form-control form-control-sm" type="text" id="searchQtyStock" placeholder=" Qty in Stock">
</td>
<td>
<input class="form-control form-control-sm" type="text" id="searchRackNo" placeholder="Search Rack No">
<input class="form-control form-control-sm" type="text" id="searchRackNo" placeholder=" Rack No">
</td>
</tr>
<tr>
@ -92,7 +92,12 @@
}?>
<tr class="product_tr_<?php echo $index+1; ?>" style="color:<?php echo $color; ?>" >
<td><?= $value['sku_id']; ?></td>
<td><?= $value['product_name']; ?></td>
<td>
<i class="ri-information-fill product_addtional_details" id="<?= $value['product_id']; ?>" ></i>
<?= $value['product_name']; ?>
</td>
<td><?= $value['manufacturer_name']; ?></td>
<td><?= $value['product_category']; ?></td>
<td><?= number_format($value['unit_price']); ?></td>
@ -124,6 +129,48 @@
</div> <!-- end card -->
</div> <!-- end col -->
</div>
<div id="accordion-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content p-0">
<div id="accordion">
<div class="card mb-0">
<div class="card-header" id="headingOne">
<h5 class="m-0">
<a href="#collapseOne" class="text-dark" data-toggle="collapse" aria-expanded="true" aria-controls="collapseOne">
Product supportiog Models
</a>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body" id="modelNames">
</div>
</div>
</div>
<div class="card mb-0">
<div class="card-header" id="headingTwo">
<h5 class="m-0">
<a href="#collapseTwo" class="collapsed text-dark" data-toggle="collapse" aria-expanded="false" aria-controls="collapseTwo">
Additional name of the products
</a>
</h5>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="card-body" id="additionalNames">
</div>
</div>
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<?php include('layout/footer.php'); ?>
<script>
@ -262,5 +309,40 @@
}
$('.product_addtional_details').click(function () {
var product_id = $(this).attr('id');
$.ajax({
url: '<?php echo base_url()."get_product_addtional_details/"?>'+product_id,
method: 'GET',
success: function(response) {
var data = JSON.parse(response);
if (data) {
var modelNames = '';
data.modelNames.forEach(function(name) {
modelNames += name.model_name+' , ';
});
$("#modelNames").html(modelNames);
var additionalNames = '';
data.additionalNames.forEach(function(name) {
additionalNames += name.additional_product_name+' , ';
});
$("#additionalNames").html(additionalNames);
$('#accordion-modal').modal('show');
}
},
error: function(xhr, status, error) {
console.error('Error occurred while deleting the item:', error);
}
});
})
</script>

View File

@ -49,18 +49,15 @@
<table id="datatable-sales-order" class="table table-striped dt-responsive nowrap w-100"
style="width:100% !important;">
<thead>
<tr>
<th>Order Number</th>
<th>Reg No</th>
<th>Client Name</th>
<th>Items</th>
<th>Qty</th>
<th>Total</th>
<th>Status</th>
<th>Actions</th>
<th>Reg No</th>
<th>Client Name</th>
<th>Items</th>
<th>Qty</th>
<th>Total</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
@ -86,8 +83,7 @@
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a href="<?= "new_sale/" . $value['sales_order_id']; ?>" class="dropdown-item edit-button" onclick="datatableSalesOrder('sale_tr_<?php echo $index+1; ?>')"><i class="ri-pencil-line mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a href="<?= "delete_sale/" . $value['sales_order_id']; ?>" class="dropdown-item delete-button" onclick="datatableSalesOrder('sale_tr_<?php echo $index+1; ?>')"><i class="ri-delete-bin-line mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<!-- <a href="<?= "download_invoice/" . $value['sales_order_id']; ?>" class="dropdown-item edit-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download</a> -->
<!-- <a href="<?= "delete_sale/" . $value['sales_order_id']; ?>" class="dropdown-item delete-button" onclick="datatableSalesOrder('sale_tr_<?php echo $index+1; ?>')"><i class="ri-delete-bin-line mr-2 text-muted font-18 vertical-middle"></i>Delete</a> -->
<a href="#" data-sales-order-id="<?= $value['sales_order_id']; ?>" class="dropdown-item preview-invoice" href="#" title="Preview Invoice"><i class="ri-book-read-line mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
</div>
</div>

View File

@ -569,7 +569,7 @@ $(document).ready(function() {
// Event listener for product selection
$(document).on('change', 'select[name="item_details[]"]', function() {
var productId = $(this).val();
alert(productId);
var quantity = $(this).closest('tr').find('.item-quantity').val(1);