|
|
@@ -57,19 +57,19 @@
|
|
|
}
|
|
|
|
|
|
function updateStock() {
|
|
|
- var min = parseInt($('#min_stock_general').val());
|
|
|
- var max = parseInt($('#max_stock_general').val());
|
|
|
- // checar por campos vacios
|
|
|
- if(!min || !max ) {
|
|
|
+ var min = parseInt($('#min_stock_general').val());
|
|
|
+ var max = parseInt($('#max_stock_general').val());
|
|
|
+ // checar por campos vacios
|
|
|
+ if(!min || !max ) {
|
|
|
toastr["error"]("Error, No pueden quedar vacios los campos de mínimo y máximo");
|
|
|
- } else {
|
|
|
- //maximo sea menor al minimo
|
|
|
- if( max < min) {
|
|
|
- toastr["error"]("Error, El máximo debe de ser mayor al mínimo");
|
|
|
- //almenos 1 producto seleccionado
|
|
|
- } else if(rows_selected.length == 0) {
|
|
|
- toastr["error"]("Error, Se debe seleccionar al menos un producto para actualizar");
|
|
|
} else {
|
|
|
+ //maximo sea menor al minimo
|
|
|
+ if( max < min) {
|
|
|
+ toastr["error"]("Error, El máximo debe de ser mayor al mínimo");
|
|
|
+ //almenos 1 producto seleccionado
|
|
|
+ } else if(rows_selected.length == 0) {
|
|
|
+ toastr["error"]("Error, Se debe seleccionar al menos un producto para actualizar");
|
|
|
+ } else {
|
|
|
$.ajax({
|
|
|
type: "PUT",
|
|
|
url: "/update_stock",
|
|
|
@@ -84,7 +84,6 @@
|
|
|
var rows = $(".stock-table").dataTable().fnGetNodes();
|
|
|
$.each(rows, function(i, row) {
|
|
|
var id = $(this).attr('id').substring($(this).attr('id').indexOf('_') + 1, $(this).attr('id').length);
|
|
|
-
|
|
|
if($.inArray(id, rows_selected) != -1) {
|
|
|
minInput = $(row).find("td:eq(6)")
|
|
|
minInput.text(min);
|
|
|
@@ -92,49 +91,49 @@
|
|
|
maxInput.text(max);
|
|
|
}
|
|
|
});
|
|
|
- $('#select-all').click();
|
|
|
- $('#min_stock_general').val("");
|
|
|
- $('#max_stock_general').val("");
|
|
|
- toastr["success"]("Stock mínimo y máximo actualizado.");
|
|
|
+ $('#select-all').click();
|
|
|
+ $('#min_stock_general').val("");
|
|
|
+ $('#max_stock_general').val("");
|
|
|
+ toastr["success"]("Stock mínimo y máximo actualizado.");
|
|
|
}
|
|
|
});
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
function initialStock() {
|
|
|
- var initialStock = parseInt($('#initial_stock_input').val());
|
|
|
- if (initialStock || initialStock == 0) {
|
|
|
- if(rows_selected.length > 0) {
|
|
|
- $.ajax({
|
|
|
- type: "PUT",
|
|
|
- url: "/set_initial_stock",
|
|
|
- dataType: "json",
|
|
|
- data: {
|
|
|
- ids: rows_selected,
|
|
|
- stock: initialStock
|
|
|
- },
|
|
|
- success: function(xhr, status, error) {
|
|
|
- var table = $('.stock-table').dataTable();
|
|
|
- var rows = $(".stock-table").dataTable().fnGetNodes();
|
|
|
- $.each(rows, function(i, row) {
|
|
|
- var id = $(this).attr('id').substring($(this).attr('id').indexOf('_') + 1, $(this).attr('id').length);
|
|
|
+ var initialStock = parseInt($('#initial_stock_input').val());
|
|
|
+ if (initialStock || initialStock == 0) {
|
|
|
+ if(rows_selected.length > 0) {
|
|
|
+ $.ajax({
|
|
|
+ type: "PUT",
|
|
|
+ url: "/set_initial_stock",
|
|
|
+ dataType: "json",
|
|
|
+ data: {
|
|
|
+ ids: rows_selected,
|
|
|
+ stock: initialStock
|
|
|
+ },
|
|
|
+ success: function(xhr, status, error) {
|
|
|
+ var table = $('.stock-table').dataTable();
|
|
|
+ var rows = $(".stock-table").dataTable().fnGetNodes();
|
|
|
+ $.each(rows, function(i, row) {
|
|
|
+ var id = $(this).attr('id').substring($(this).attr('id').indexOf('_') + 1, $(this).attr('id').length);
|
|
|
|
|
|
- if($.inArray(id, rows_selected) != -1) {
|
|
|
- initialStockInput = $(row).find("td:eq(6)");
|
|
|
- initialStockInput.text(initialStock);
|
|
|
- }
|
|
|
- });
|
|
|
+ if($.inArray(id, rows_selected) != -1) {
|
|
|
+ initialStockInput = $(row).find("td:eq(6)");
|
|
|
+ initialStockInput.text(initialStock);
|
|
|
+ }
|
|
|
+ });
|
|
|
$('#select-all').click();
|
|
|
$('#initial_stock').val("");
|
|
|
toastr["success"]("Stock inicial actualizado.");
|
|
|
- }
|
|
|
- });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ toastr["error"]("Error, Se debe seleccionar al menos un producto para actualizar");
|
|
|
+ }
|
|
|
} else {
|
|
|
- toastr["error"]("Error, Se debe seleccionar al menos un producto para actualizar");
|
|
|
+ toastr["error"]("Error, NO puede quedar vacío el campo de stock inicial");
|
|
|
}
|
|
|
- } else {
|
|
|
- toastr["error"]("Error, NO puede quedar vacio el campo de stock inicial");
|
|
|
- }
|
|
|
}
|
|
|
</script>
|