salesentry filters

This commit is contained in:
Sampanna Rimal
2024-09-17 16:34:40 +05:45
parent afb2c202d6
commit 0b438e302d
19 changed files with 303 additions and 50 deletions

View File

@ -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

View File

@ -0,0 +1,74 @@
<div class="card">
<div class="card-body">
<div class="row g-2">
<div class="col-sm-12">
{{ html()->form('GET')->route('salesEntry.index')->open() }}
<div class="row g-8">
{{-- <div class="col-xl-3">
<div class="search-box">
{{ html()->text('search')->class('form-control search')->value(request('search'))->placeholder('Search...') }}
<i class="ri-search-line search-icon"></i>
</div>
</div> --}}
<div class="col-sm-3">
<div class="">
{{ html()->text('date')->class('form-control')->value(request('date'))->placeholder('Date Range')->attributes([
'id' => 'datepicker-range',
'data-provider' => 'flatpickr',
'data-date-format' => 'Y-m-d',
'data-range-date' => 'true',
]) }}
</div>
</div>
<div class="col-sm-2">
<div class="search-box">
{{ html()->select('category_id', $categoryList)->class('form-control select2')->value(request('category_id'))->placeholder('By Category') }}
</div>
</div>
<div class="col-sm-2">
<div class="search-box">
{{ html()->select('stock_id', $stockList)->class('form-control select2')->value(request('stock_id'))->placeholder('By Stock') }}
</div>
</div>
<div class="col-sm-2">
<div class="search-box">
{{ html()->select('product_id', $productList)->class('form-control select2')->value(request('product_id'))->placeholder('By Product') }}
</div>
</div>
<!--end col-->
{{-- <div class="align-item-right"> --}}
<div class="col-sm-1 offset-lg-1">
<div>
<button type="submit" class="btn btn-primary">
<i class="ri-equalizer-fill me-2"></i>Filters</button>
{{-- <a href="{{ route('task.index') }}" class="btn btn-danger">
<i class="ri-bin-fill me-2"></i>Reset</a> --}}
</div>
</div>
<div class="col-sm-1">
<div>
<a href="{{ route('salesEntry.index') }}" class="btn btn-primary">
<i class="ri-loop-right-line me-2"></i>Reset</a>
{{-- <a href="{{ route('task.index') }}" class="btn btn-danger">
<i class="ri-bin-fill me-2"></i>Reset</a> --}}
</div>
</div>
{{-- </div> --}}
<!--end col-->
</div>
<!--end row-->
{{ html()->form()->close() }}
</div>
<!--end col-->
</div>
<!--end row-->
</div>
</div>
<script>
</script>