product
This commit is contained in:
parent
92bafab52d
commit
dc2dc02d8f
@ -172,7 +172,6 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<<<<<<< HEAD
|
||||
<li>
|
||||
<a href="<?php echo base_url('spare_manufacturer_index') ?>">
|
||||
<i class="fas fa-cogs"></i>
|
||||
|
||||
@ -60,13 +60,13 @@
|
||||
<select class="form-control" id="vendor" name="vendor" required>
|
||||
<!-- Placeholder option -->
|
||||
<option value="">Select Vendor</option>
|
||||
<?php if (isset($vendors) && !empty($vendors)): ?>
|
||||
|
||||
<?php foreach ($vendors as $vendor): ?>
|
||||
<option value="<?= $vendor['vendor_id'] ?>" <?= isset($products['vendor']) && $products['vendor'] == $vendor['vendor_id'] ? 'selected' : '' ?>>
|
||||
<?= $vendor['vendor_name'] ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
@ -133,13 +133,18 @@
|
||||
<h4 class="header-title">Stock Information :</h4><br>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" name="qty_in_stock" placeholder="Qty in Stock" value="<?= isset($products['qty_stock']) ? $products['qty_stock'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" name="purchase_order_level" placeholder="Purchase Order Level" value="<?= isset($products['purchase_order_level']) ? $products['purchase_order_level'] : '' ?>" required>
|
||||
</div>
|
||||
<label for="inputPassword4" class="col-form-label">Qty in Stock<span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" id="qty_in_stock" name="qty_in_stock" placeholder="Qty in Stock" value="<?= isset($products['qty_stock']) ? $products['qty_stock'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="purchase_order_level" name="purchase_order_level" placeholder="Purchase Order Level" value="<?= isset($products['purchase_order_level']) ? $products['purchase_order_level'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="inputPassword4" class="col-form-label">Purchase Re-Order Level<span class="text-danger"></span></label>
|
||||
<input type="number" class="form-control" id="purchase_reorder_level" name="purchase_reorder_level" placeholder="Purchase Re-Order Level" value="<?= isset($products['purchase_reorder_level']) ? $products['purchase_reorder_level'] : '' ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4" hidden>
|
||||
<label for="inputPassword4" class="col-form-label">Qty in Demand</label>
|
||||
<input type="number" class="form-control" name="qty_in_demand" placeholder="Qty in Demand" value="<?= isset($products['qty_in_demand']) ? $products['qty_in_demand'] : '' ?>" >
|
||||
@ -236,45 +241,28 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const qtyInStockInput = document.getElementById('qty_in_stock');
|
||||
const purchaseOrderLevelInput = document.getElementById('purchase_order_level');
|
||||
const purchaseReorderLevelInput = document.getElementById('purchase_reorder_level');
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#model').change(function() {
|
||||
// Listen for the keyup event on qty in stock input
|
||||
qtyInStockInput.addEventListener('keyup', function() {
|
||||
const qtyInStock = parseFloat(qtyInStockInput.value);
|
||||
const purchaseorderLevel = qtyInStock / 2; // Calculate the purchase reorder level (half of qty in stock)
|
||||
|
||||
var model_ids = $('#model').val(); // Get the selected model IDs
|
||||
var make_id = $('#make').val();
|
||||
console.log(model_ids);
|
||||
|
||||
// AJAX request to get vendors based on the selected model ID
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_vendors_by_model') ?>', // URL to your CodeIgniter controller method
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { model_ids: model_ids , make_id : make_id }, // Send the selected make ID and model IDs to the controller
|
||||
success: function(response) {
|
||||
// Update vendor dropdown based on the response
|
||||
if (response) {
|
||||
// Clear existing options
|
||||
$('#vendor').empty();
|
||||
// Append new options
|
||||
$('#vendor').append('<option value>Select Vendor</option>');
|
||||
$.each(response, function(index, vendor) {
|
||||
$('#vendor').append('<option value="' + vendor.vendor_id + '">' + vendor.vendor_name + '</option>');
|
||||
});
|
||||
} else {
|
||||
// Handle case when no vendors are found for the selected model
|
||||
console.log('No vendors found for the selected model');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
// Update the value of purchase reorder level input
|
||||
purchaseOrderLevelInput.value = isNaN(purchaseorderLevel) ? '' : purchaseorderLevel;
|
||||
purchaseReorderLevelInput.value = isNaN(qtyInStock) ? '' : qtyInStock;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
.select2-container .select2-selection--multiple .select2-selection__choice{
|
||||
padding: 5px 7px 5px 0 !important;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user