$(function() {
	// Buscar e seleção de fornecedor e ou produto
	$('#search_by').on('keyup', function() {
		if($(this).val() != '') {
			let by = $('select[name="filter[by]"]').val();

			if(by == 'provider') {
				var serarchIn = 'searchprovider';
			} else if(by == 'product') {
				var serarchIn = 'searchproduct';
			}

			let text = $(this).val();		
			utils.searchRequestBy(serarchIn, text, 'searchresultall');
		} else {
			$('.searchresultall').hide();
		}
	});

	$(document).on('click', 'div.searchresultall ul li', function() {
		let clicked = parseInt($(this).attr('data-list'));
		let text = $(this).html();

		$('input[name="filter[by_selected]"]').val(clicked);
		$('input[name="filter[text]"]').val(text);
		$('div.searchresultall').hide(100);
	});

	$('select[name="filter[by]"]').on('change', function() {
		$('input[name="filter[by_selected]"]').val('');
		$('input[name="filter[text]"]').val('');
	});

	$('.origin-payment').on('click', function() {

		if($('.option-pay-form').css('display') != 'flex') {
			$('.option-pay-form').css('display', 'flex');
		} else {
			$('.option-pay-form').css('display', 'none');
		}
	});
});