Commit 94eefeab by François C.

Lintjs

parent 2e70b732
Pipeline #1260 passed with stage
in 1 minute 25 seconds
...@@ -716,7 +716,7 @@ function generate_inventory() { ...@@ -716,7 +716,7 @@ function generate_inventory() {
"Inventaire créé !", "Inventaire créé !",
{ {
elementPosition:"bottom center", elementPosition:"bottom center",
className: "success", className: "success"
} }
); );
}, 200); }, 200);
...@@ -833,7 +833,7 @@ function create_cdb_order() { ...@@ -833,7 +833,7 @@ function create_cdb_order() {
/** /**
* Update order data of an existing order in couchdb * Update order data of an existing order in couchdb
* *
* @returns Promise resolved after update is complete * @returns Promise resolved after update is complete
*/ */
function update_cdb_order() { function update_cdb_order() {
...@@ -864,7 +864,7 @@ function update_cdb_order() { ...@@ -864,7 +864,7 @@ function update_cdb_order() {
/** /**
* Delete an order in couchdb. * Delete an order in couchdb.
* *
* @returns Promise resolved after delete is complete * @returns Promise resolved after delete is complete
*/ */
function delete_cdb_order() { function delete_cdb_order() {
...@@ -878,7 +878,7 @@ function delete_cdb_order() { ...@@ -878,7 +878,7 @@ function delete_cdb_order() {
alert("Erreur lors de la suppression de la commande... Si l'erreur persiste contactez un administrateur svp."); alert("Erreur lors de la suppression de la commande... Si l'erreur persiste contactez un administrateur svp.");
console.log(err); console.log(err);
reject(); reject(new Error("Error while deleting order"));
} }
}); });
}); });
...@@ -1642,7 +1642,7 @@ function display_products(params) { ...@@ -1642,7 +1642,7 @@ function display_products(params) {
*/ */
function unselect_all_rows() { function unselect_all_rows() {
$("#select_all_products_cb").prop("checked", false); $("#select_all_products_cb").prop("checked", false);
products_table.rows().every(function() { products_table.rows().every(function() {
const node = $(this.node()); const node = $(this.node());
...@@ -1753,10 +1753,11 @@ function update_order_selection_screen() { ...@@ -1753,10 +1753,11 @@ function update_order_selection_screen() {
e.stopImmediatePropagation(); e.stopImmediatePropagation();
order_name_container = $(this).prev()[0]; order_name_container = $(this).prev()[0];
let order_id = $(order_name_container).text(); let order_id = $(order_name_container).text();
let modal_remove_order = $('#templates #modal_remove_order'); let modal_remove_order = $('#templates #modal_remove_order');
modal_remove_order.find(".remove_order_name").text(order_id); modal_remove_order.find(".remove_order_name").text(order_id);
openModal( openModal(
modal_remove_order.html(), modal_remove_order.html(),
() => { () => {
...@@ -1777,9 +1778,9 @@ function update_order_selection_screen() { ...@@ -1777,9 +1778,9 @@ function update_order_selection_screen() {
}, 500); }, 500);
}); });
}) })
.catch(() => { .catch(() => {
console.log("error deleting order"); console.log("error deleting order");
}); });
}); });
} }
}, },
...@@ -1933,7 +1934,7 @@ $(document).ready(function() { ...@@ -1933,7 +1934,7 @@ $(document).ready(function() {
}); });
// Close dropdown menu on click outside // Close dropdown menu on click outside
$(document).click(function(event) { $(document).click(function(event) {
let target = $(event.target); let target = $(event.target);
if ( if (
...@@ -1943,7 +1944,7 @@ $(document).ready(function() { ...@@ -1943,7 +1944,7 @@ $(document).ready(function() {
$('#actions_buttons_container').hide(); $('#actions_buttons_container').hide();
$('.toggle_action_buttons_icon').empty() $('.toggle_action_buttons_icon').empty()
.append('<i class="fas fa-chevron-down"></i>'); .append('<i class="fas fa-chevron-down"></i>');
} }
}); });
$("#supplier_form").on("submit", function(e) { $("#supplier_form").on("submit", function(e) {
...@@ -1985,6 +1986,7 @@ $(document).ready(function() { ...@@ -1985,6 +1986,7 @@ $(document).ready(function() {
$("#delete_order_button").on("click", function(e) { $("#delete_order_button").on("click", function(e) {
if (is_time_to('press_delete_order_button', 1000)) { if (is_time_to('press_delete_order_button', 1000)) {
let modal_remove_order = $('#templates #modal_remove_order'); let modal_remove_order = $('#templates #modal_remove_order');
modal_remove_order.find(".remove_order_name").text(order_doc._id); modal_remove_order.find(".remove_order_name").text(order_doc._id);
openModal( openModal(
...@@ -2006,15 +2008,15 @@ $(document).ready(function() { ...@@ -2006,15 +2008,15 @@ $(document).ready(function() {
}, 500); }, 500);
}); });
}) })
.catch(() => { .catch(() => {
console.log("error deleting order"); console.log("error deleting order");
}); });
} }
}, },
'Valider' 'Valider'
); );
} }
}); });
$('#back_to_order_selection_from_main').on('click', function() { $('#back_to_order_selection_from_main').on('click', function() {
......
...@@ -355,7 +355,7 @@ function display_orders_table() { ...@@ -355,7 +355,7 @@ function display_orders_table() {
$('#orders').empty(); $('#orders').empty();
} }
for (let j in orders) { for (let j in orders) {
console.log(orders[j].id) console.log(orders[j].id);
} }
table_orders = $('#orders').DataTable({ table_orders = $('#orders').DataTable({
data: orders, data: orders,
......
...@@ -166,6 +166,7 @@ function init_datatable() { ...@@ -166,6 +166,7 @@ function init_datatable() {
let data = row.data(); let data = row.data();
let validated_data = qty_validation(qty, data.uom.id); let validated_data = qty_validation(qty, data.uom.id);
if (validated_data >= 0) { if (validated_data >= 0) {
data.qty = validated_data; data.qty = validated_data;
row.remove().draw(); row.remove().draw();
...@@ -423,28 +424,33 @@ var update_existing_product = function(product, added_qty, undo_option = false) ...@@ -423,28 +424,33 @@ var update_existing_product = function(product, added_qty, undo_option = false)
function qty_validation(qty, uom_id) { function qty_validation(qty, uom_id) {
if (qty == null || qty == '') { if (qty == null || qty == '') {
$.notify("Il n'y a pas de quantité indiquée, ou ce n'est pas un nombre", { $.notify("Il n'y a pas de quantité indiquée, ou ce n'est pas un nombre", {
globalPosition:"top right", globalPosition:"top right",
className: "error"}); className: "error"});
return -1; return -1;
} }
if (uom_id == 1) { if (uom_id == 1) {
if (qty/parseInt(qty) != 1 && qty != 0){ if (qty/parseInt(qty) != 1 && qty != 0) {
$.notify("Une quantité avec décimale est indiquée alors que c'est un article à l'unité", { $.notify("Une quantité avec décimale est indiquée alors que c'est un article à l'unité", {
globalPosition:"top right", globalPosition:"top right",
className: "error"}); className: "error"});
return -2;}
return -2;
}
qty = parseInt(qty); // product by unit qty = parseInt(qty); // product by unit
} else { } else {
qty = parseFloat(qty).toFixed(2); qty = parseFloat(qty).toFixed(2);
} }
if (isNaN(qty)){ if (isNaN(qty)) {
$.notify("Une quantité n'est pas un nombre", { $.notify("Une quantité n'est pas un nombre", {
globalPosition:"top right", globalPosition:"top right",
className: "error"}); className: "error"});
return -3;}
return -3;
}
return qty; return qty;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment