restaurant changes

This commit is contained in:
Sampanna Rimal
2024-09-19 18:33:08 +05:45
parent 0b438e302d
commit 2fa9d47a73
115 changed files with 3489 additions and 67 deletions

View File

@ -21,6 +21,7 @@ class SalesEntryDetail extends Model
'stock_id',
'size_id',
'unit',
'price',
'rate',
'quantity',
'amount',

View File

@ -3,7 +3,7 @@
namespace Modules\SalesEntry\Repositories;
use Illuminate\Http\Request;
interface SalesEntryInterface
{
public function findAll($filters);

View File

@ -71,15 +71,15 @@ class SalesEntryRepository implements SalesEntryInterface
$request->merge(['salesentry_id' => $salesEntryData->id]);
foreach ($salesEntryDetails['stock_id'] as $key => $stockId) {
foreach ($salesEntryDetails['product_id'] as $key => $productId) {
// dd($request->input('salesentry_id'));
$data = [
'salesentry_id' => $request->input('salesentry_id'),
'product_id' => $salesEntryDetails['product_id'][$key],
'category_id' => $salesEntryDetails['category_id'][$key],
'stock_id' => $salesEntryDetails['stock_id'][$key],
'size_id' => $salesEntryDetails['size_id'][$key],
'rate' => $salesEntryDetails['rate'][$key],
// 'stock_id' => $salesEntryDetails['stock_id'][$key],
// 'size_id' => $salesEntryDetails['size_id'][$key],
'rate' => $salesEntryDetails['price'][$key],
// 'unit' => $salesEntryDetails['unit'][$key],
'quantity' => $salesEntryDetails['qty'][$key],
'amount' => $salesEntryDetails['amt'][$key],
@ -112,7 +112,7 @@ class SalesEntryRepository implements SalesEntryInterface
'salesentry_id' => $SalesEntryId,
'product_id' => $productId,
'unit' => $data['unit'][$key],
'rate' => $data['rate'][$key],
'price' => $data['price'][$key],
'quantity' => $data['qty'][$key],
'amount' => $data['amt'][$key],
'desc' => $data['desc'][$key],

View File

@ -1,6 +1,6 @@
<div class="card card-body product-card card-border-secondary mb-2 border">
<div class="row gy-2 mb-2">
<div class="col-md-2">
<div class="col-md-3">
{{ html()->label('Category')->class('form-label') }}
@if (isset($editable) && $editable)
{{ html()->select('category_id[]', $categoryList, $item->category_id)->class('form-select category_id')->attributes(['id' => 'category_id'])->placeholder('Enter Category')->required() }}
@ -18,7 +18,7 @@
@endif
</div>
<div class="col-md-2">
{{-- <div class="col-md-2">
{{ html()->label('Stock')->class('form-label') }}
@if (isset($editable) && $editable)
{{ html()->select('stock_id[]', $stockList, $item->stock_id)->class('form-select stock_id')->attributes(['id' => 'stock_id'])->placeholder('')->required() }}
@ -26,18 +26,18 @@
{{ html()->select('stock_id[]', $stockList)->class('form-select stock_id')->attributes(['id' => 'stock_id'])->placeholder('')->required()->disabled() }}
@endif
</div>
<div class="col-md-1">
</div> --}}
{{-- <div class="col-md-1">
{{ html()->label('Size')->class('form-label') }}
{{ html()->select('size_id[]', $sizes)->class('form-select ')->placeholder('size') }}
</div> --}}
<div class="col-md-2">
{{ html()->label('Price')->class('form-label') }}
{{ html()->text('price[]', isset($editable) && $editable ? $item->price : null)->class('form-control product-price cleave-numeral rate~~')->placeholder('Enter Price')->attributes(['id' => 'rate', 'onkeyup' => 'validatePriceInput(this)']) }}
</div>
<div class="col-md-1">
{{ html()->label('Rate')->class('form-label') }}
{{ html()->text('rate[]', isset($editable) && $editable ? $item->rate : null)->class('form-control product-price cleave-numeral rate~~')->placeholder('Enter Rate')->attributes(['id' => 'rate', 'onkeyup' => 'validateNumericInput(this)']) }}
</div>
<div class="col-md-1">
<div class="col-md-2">
{{ html()->label('Quantity')->class('form-label') }}
{{ html()->text('qty[]', isset($editable) && $editable ? $item->quantity : null)->class('form-control product-quantity cleave-numeral qty')->placeholder('Enter QTY')->attributes(['id' => 'qty', 'onkeyup' => 'validateNumericInput(this)']) }}
</div>

View File

@ -194,7 +194,7 @@
$(document).ready(function() {
$('.product_id').prop('disabled', true);
$('.stock_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');
@ -227,7 +227,7 @@
var categoryId = $(this).val();
var formRow = $(this).closest('.row');
var productSelect = formRow.find('.product_id');
var stockSelect = formRow.find('.stock_id');
// var stockSelect = formRow.find('.stock_id');
// Reset stock field
@ -248,7 +248,7 @@
// Handle error
}
});
stockSelect.empty().prop('disabled', true);
// stockSelect.empty().prop('disabled', true);
} else {
productSelect.prop('disabled', true);
@ -256,36 +256,44 @@
});
// 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');
// $('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);
// 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);
}
});
// $.each(response.stocks, function (id, title) {
// stockSelect.append('<option value="' + id + '">' + title + '</option>');
// });
// },
// error: function (xhr) {
// // Handle error
// }
// });
// } else {
// stockSelect.prop('disabled', true);
// }
// });
});
</script>
<script>
function validateNumericInput(input) {
// Allow only numbers and remove any non-numeric input
input.value = input.value.replace(/[^0-9.]/g, '');
input.value = input.value.replace(/(\..*)\./g, '$1');
input.value = input.value.replace(/^(\d+)(\.\d{0,2})?.*/, '$1$2');
}
</script>
@endpush