Viewing file: create.blade.php (4.57 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<script> $(document).ready(function(){ let timeSet = 1000; let typingTimer;
function fetchData(searchValue) { if(searchValue){ $.ajax({ url: '{{ route("blood.order.customer.search") }}', method: 'GET', data: { customer_name: searchValue }, success: function(response) { if (response.status == 'success') { $('.show-filtered-result').removeClass('d-none'); let html = '';
$.each(response.data, function (index, value) { html += `<div class="search-box-result-sec"> <a href="#" data-name="${value.name}" data-id="${value.id}" data-email="${value.email}" data-phone_number="${value.phone_number}" class="d-block each-filtered-result">${value.name}</a> </div>`; }); if (response.data.length <= 0) { $('.show-filtered-result').addClass('d-none'); return; } $('.show-filtered-result').html(html) } else { $('.show-filtered-result').addClass('d-none');
} }, error: function(xhr, status, error) { console.error(xhr.responseText); } }); }
}
function sendAjaxRequest(searchValue) { clearTimeout(typingTimer); typingTimer = setTimeout(function() { fetchData(searchValue); }, timeSet); }
$('.customer-search-blood-order').on('keyup', function() { var searchValue = $(this).val(); if(searchValue.length==0){ console.log('okkk '); $('#search-by-customer-name').val(); $('#search_by_customer_id').val(); $('#customer-email-address').val(); $('.customer-phone-number-search').val(); $('.customer-phone-number-search').text(); } sendAjaxRequest(searchValue); });
$(document).on('click', '.each-filtered-result', function (e) { e.preventDefault();
const name = $(this).attr('data-name'); const id = $(this).attr('data-id'); const phone_number = $(this).attr('data-phone_number'); const email = $(this).attr('data-email'); console.log(email); $('.show-filtered-result').addClass('d-none'); $('#search-by-customer-name').val(name); $('#search_by_customer_id').val(id); $('#customer-email-address').val(email); $('.customer-phone-number-search').val(phone_number); }); });
</script>
<style> .show-filtered-result{ margin-top: 3px; margin-bottom: 10px; background: #8d929914; padding: 9px 5px; border-radius: 5px; } </style>
{{ Form::open(array('url' => 'blood/order/store','enctype' => 'multipart/form-data')) }} <div class="modal-body"> <div class="row"> <input type="hidden" name="customer_id" id="search_by_customer_id"> <div class="form-group col-md-12 mb-0"> {{ Form::label('customer_name', __('Customer Name'),['class'=>'form-label']) }} {{ Form::text('name', '', array('class' => 'form-control customer-search-blood-order','id' =>'search-by-customer-name','required'=>'required')) }} </div> <div class="col-md-12"> <div class="show-filtered-result d-none">
</div> </div> <div class="form-group col-md-12"> {{Form::label('phone_number',__('Phone Number'),array('class'=>'form-label')) }} {{ Form::number('phone_number', '', array('class' => 'form-control customer-phone-number-search','required'=>'required')) }} </div> <div class="form-group col-md-12"> {{Form::label('email',__('Email'),array('class'=>'form-label')) }} {{ Form::email('email', '', array('class' => 'form-control', 'id'=>'customer-email-address','required'=>'required')) }} </div> <div class="form-group col-md-12"> {{ Form::label('address', __('Address'),['class'=>'form-label']) }} {{ Form::text('address', '', array('class' => 'form-control','required'=>'required')) }} </div> <div class="form-group col-md-12"> {{Form::label('file_upload',__('File Upload'),array('class'=>'form-label')) }} <br> {{Form::file('file_upload',null,array('class'=>'form-control'))}} </div> </div> </div> <div class="modal-footer"> <input type="button" value="{{__('Cancel')}}" class="btn btn-light" data-bs-dismiss="modal"> <input type="submit" value="{{__('Create')}}" class="btn btn-primary"> </div> {{ Form::close() }}
|