<script type='text/javascript' >
$( function() {
// Multiple select
$( "#multi_autocomplete" ).autocomplete({
source: function( request, response ) {
var searchText = extractLast(request.term);
$.ajax({
url: "/fetch/achat",
type: 'post',
dataType: "json",
data: {
search: searchText,
type: 2,
},
success: function( data ) {
response( data );
$.each(data, function(index, element) {
$('#ville').html(element.name);
$('#nbr').html(element.nbr);
$('#moyenne').html(element.moyenne);
$('#prixmini').html(element.prixmini);
$('#prixmax').html(element.prixmax);
});
}
});
},
select: function( event, ui ) {
var terms = split( $('#multi_autocomplete').val() );
terms.pop();
terms.push( ui.item.label );
terms.push( "" );
$('#multi_autocomplete').val(terms.join( " " ));
// Id
var terms = split( $('#selectuser_ids').val() );
terms.pop();
terms.push( ui.item.value );
terms.push( "" );
$('#selectuser_ids').val(terms.join( ", " ));
return false;
}
});
});
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
</script>
<script type='text/javascript' >
$( function() {
// Multiple select
$( "#multi_autocomplete-loc" ).autocomplete({
source: function( request, response ) {
var searchText = extractLast(request.term);
$.ajax({
url: "/fetch/location",
type: 'post',
dataType: "json",
data: {
search: searchText,
type: 1,
},
success: function( data ) {
response( data );
$.each(data, function(index, element) {
$('#villeloc').html(element.name);
$('#nbrloc').html(element.nbr);
$('#moyenneloc').html(element.moyenne);
$('#prixminiloc').html(element.prixmini);
$('#prixmaxloc').html(element.prixmax);
});
}
});
},
select: function( event, ui ) {
var terms = split( $('#multi_autocomplete-loc').val() );
terms.pop();
terms.push( ui.item.label );
terms.push( "" );
$('#multi_autocomplete-loc').val(terms.join( " " ));
// Id
var terms = split( $('#selectuser_ids-loc').val() );
terms.pop();
terms.push( ui.item.value );
terms.push( "" );
$('#selectuser_ids').val(terms.join( ", " ));
return false;
}
});
});
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
</script>
<script type='text/javascript' >
$( function() {
// Multiple select
$( "#multi_autocomplete-sejour" ).autocomplete({
source: function( request, response ) {
var searchText = extractLast(request.term);
$.ajax({
url: "/fetch/sejour",
type: 'post',
dataType: "json",
data: {
search: searchText,
type: 1,
},
success: function( data ) {
response( data );
$.each(data, function(index, element) {
$('#villesejour').html(element.name);
$('#nbrsejour').html(element.nbr);
$('#moyennesejour').html(element.moyenne);
$('#prixminisejour').html(element.prixmini);
$('#prixmaxsejour').html(element.prixmax);
});
}
});
},
select: function( event, ui ) {
var terms = split( $('#multi_autocomplete-sejour').val() );
terms.pop();
terms.push( ui.item.label );
terms.push( "" );
$('#multi_autocomplete-sejour').val(terms.join( " " ));
// Id
var terms = split( $('#selectuser_ids-sejour').val() );
terms.pop();
terms.push( ui.item.value );
terms.push( "" );
$('#selectuser_ids').val(terms.join( ", " ));
return false;
}
});
});
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
return split( term ).pop();
}
</script>