Add functionality to manage and display minimum ROAS for bestsellers; implement AJAX calls for retrieval and saving
This commit is contained in:
@@ -13,6 +13,12 @@
|
||||
<i class="arrow double"></i>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col-md-1 text-right">
|
||||
<label>Bestseller min ROAS</label>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<input type="text" id="bestseller_min_roas" name="bestseller_min_roas" class="form-control" placeholder="Minimalny ROAS bestsellerów" value="" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -59,6 +65,29 @@
|
||||
table = $( '#products' ).DataTable();
|
||||
table.destroy();
|
||||
|
||||
// get min client roas
|
||||
$.ajax({
|
||||
url: '/products/get_client_bestseller_min_roas/',
|
||||
type: 'POST',
|
||||
data: {
|
||||
client_id: client_id
|
||||
},
|
||||
success: function( response ) {
|
||||
data = JSON.parse(response);
|
||||
if ( data.status == 'ok' )
|
||||
{
|
||||
$( '#bestseller_min_roas' ).val( data.min_roas );
|
||||
}
|
||||
else
|
||||
{
|
||||
$( '#bestseller_min_roas' ).val( '' );
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
new DataTable( '#products', {
|
||||
ajax: {
|
||||
type: 'POST',
|
||||
@@ -225,5 +254,33 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'blur', '#bestseller_min_roas', function(){
|
||||
var min_roas = $( this ).val();
|
||||
var client_id = $( '#client_id' ).val();
|
||||
|
||||
$.ajax({
|
||||
url: '/products/save_client_bestseller_min_roas/',
|
||||
type: 'POST',
|
||||
data: {
|
||||
client_id: client_id,
|
||||
min_roas: min_roas
|
||||
},
|
||||
success: function( response ) {
|
||||
data = JSON.parse(response);
|
||||
if ( data.status == 'ok' )
|
||||
{
|
||||
$.alert( 'Minimalny ROAS bestsellerów został pomyślnie zapisany' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$.alert('Błąd: ' + response);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$.alert('Wystąpił błąd podczas zapisywania minimalnego ROAS. Spróbuj ponownie.');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user