salesentry filters
This commit is contained in:
@ -80,7 +80,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row gy-1 my-2">
|
||||
<div class="row gy-1 my-2 mb-4">
|
||||
<h5 class="text-primary text-center">Payment Details</h5>
|
||||
<div class="border border-dashed"></div>
|
||||
|
||||
@ -102,7 +102,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mb-4 text-end">
|
||||
<div class="mb-4 mt-4 text-end">
|
||||
<button type="submit" class="btn btn-success w-sm">Save</button>
|
||||
</div>
|
||||
|
||||
@ -117,12 +117,11 @@
|
||||
numberInc = $('.product-card').length
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '{{ url('clone-sales-product') }}',
|
||||
|
||||
url: '{{ route('salesEntry.cloneSalesProduct') }}',
|
||||
data: {
|
||||
numberInc: numberInc
|
||||
},
|
||||
success: function(response) {
|
||||
success: function(response) {
|
||||
$('.appendProductCard').append(response.view)
|
||||
// $('#salesEntry-container').html(response.view).fadeIn()
|
||||
},
|
||||
@ -143,6 +142,11 @@
|
||||
recalculate();
|
||||
})
|
||||
|
||||
function validateNumericInput(input) {
|
||||
// Allow only numbers and remove any non-numeric input
|
||||
input.value = input.value.replace(/[^0-9]/g, '');
|
||||
}
|
||||
|
||||
|
||||
function amountKeyup() {
|
||||
$("body").on('keyup', '.product-price', function() {
|
||||
@ -187,8 +191,10 @@
|
||||
// $("#shipping").val(shipping.toFixed(2));
|
||||
$("#total").val(subtotal.toFixed(2));
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.product_id').prop('disabled', true);
|
||||
$('.stock_id').prop('disabled', true);
|
||||
$('body').on('change', '.product_id', function() {
|
||||
var selectedId = $(this).find(':selected').val();
|
||||
var formRow = $(this).closest('.row');
|
||||
@ -214,6 +220,72 @@
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// When category is selected, load products dynamically
|
||||
$('body').on('change', '.category_id', function () {
|
||||
var categoryId = $(this).val();
|
||||
var formRow = $(this).closest('.row');
|
||||
var productSelect = formRow.find('.product_id');
|
||||
var stockSelect = formRow.find('.stock_id');
|
||||
|
||||
// Reset stock field
|
||||
|
||||
if (categoryId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '{{ route('products-by-category') }}', // Route to get products by category
|
||||
data: {category_id:categoryId},
|
||||
success: function (response) {
|
||||
productSelect.empty().append('<option value="">Select Product</option>');
|
||||
productSelect.prop('disabled', false);
|
||||
|
||||
$.each(response.products, function (id, name) {
|
||||
productSelect.append('<option value="' + id + '">' + name + '</option>');
|
||||
});
|
||||
},
|
||||
error: function (xhr) {
|
||||
// Handle error
|
||||
}
|
||||
});
|
||||
stockSelect.empty().prop('disabled', true);
|
||||
|
||||
} else {
|
||||
productSelect.prop('disabled', true);
|
||||
}
|
||||
});
|
||||
|
||||
// When product is selected, load stocks dynamically
|
||||
$('body').on('change', '.product_id', function () {
|
||||
var productId = $(this).val();
|
||||
var formRow = $(this).closest('.row');
|
||||
var productSelect = formRow.find('.product_id');
|
||||
var stockSelect = formRow.find('.stock_id');
|
||||
|
||||
|
||||
if (productId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '{{ route('stocks-by-product') }}', // Route to get stocks by product
|
||||
data: {product_id:productId},
|
||||
success: function (response) {
|
||||
stockSelect.empty().append('<option value="">Select Stock</option>');
|
||||
stockSelect.prop('disabled', false);
|
||||
|
||||
$.each(response.stocks, function (id, title) {
|
||||
stockSelect.append('<option value="' + id + '">' + title + '</option>');
|
||||
});
|
||||
},
|
||||
error: function (xhr) {
|
||||
// Handle error
|
||||
}
|
||||
});
|
||||
} else {
|
||||
stockSelect.prop('disabled', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
Reference in New Issue
Block a user