Commit 9479e21d by Damien Moulard

linting

parent a91c4f18
Pipeline #2397 passed with stage
in 1 minute 28 seconds
...@@ -284,6 +284,7 @@ function create_pair(payload) { ...@@ -284,6 +284,7 @@ function create_pair(payload) {
data.responseJSON.errors.map(function(error) { data.responseJSON.errors.map(function(error) {
message += ('\n' + error); message += ('\n' + error);
return null; return null;
}); });
} }
......
...@@ -92,12 +92,12 @@ function new_coop_validation() { ...@@ -92,12 +92,12 @@ function new_coop_validation() {
coop_registration_details.find('.shift_template').text(st); coop_registration_details.find('.shift_template').text(st);
process_state.html(current_coop.firstname + ' ' +current_coop.lastname); process_state.html(current_coop.firstname + ' ' +current_coop.lastname);
coop_registration_details.find("#parentName").text("") coop_registration_details.find("#parentName").text("");
coop_registration_details.find("#parent").attr("hidden", true) coop_registration_details.find("#parent").attr("hidden", true);
if (current_coop.parent_name !== undefined) { if (current_coop.parent_name !== undefined) {
coop_registration_details.find("#parentName").text(current_coop.parent_name) coop_registration_details.find("#parentName").text(current_coop.parent_name);
coop_registration_details.find("#parent").removeAttr("hidden") coop_registration_details.find("#parent").removeAttr("hidden");
} }
if (current_coop.shift_template.data && current_coop.shift_template.data.id != ASSOCIATE_MEMBER_SHIFT) { if (current_coop.shift_template.data && current_coop.shift_template.data.id != ASSOCIATE_MEMBER_SHIFT) {
...@@ -126,7 +126,7 @@ function create_new_coop() { ...@@ -126,7 +126,7 @@ function create_new_coop() {
$('.chosen_associate').html(""); $('.chosen_associate').html("");
$('.chosen_associate_area').hide(); $('.chosen_associate_area').hide();
$('.member_choice').removeClass('choice_active'); $('.member_choice').removeClass('choice_active');
$(".remove_binome_icon").on("click", hide_chosen_associate) $(".remove_binome_icon").on("click", hide_chosen_associate);
local_in_process = getLocalInProcess(); local_in_process = getLocalInProcess();
if (getLocalInProcess().length > 0) { if (getLocalInProcess().length > 0) {
empty_waiting_local_processes(); empty_waiting_local_processes();
...@@ -271,11 +271,13 @@ function store_new_coop(event) { ...@@ -271,11 +271,13 @@ function store_new_coop(event) {
if (active_asso_area.length > 0) { if (active_asso_area.length > 0) {
// If user click as if a "binôme" is beeing created, data about parent member must exist // If user click as if a "binôme" is beeing created, data about parent member must exist
let associated_data_ok = false; let associated_data_ok = false;
if ( if (
($(active_asso_area[0]).attr('id') === "new_member_choice" && $('#new_member_input').val().trim().length > 0) ($(active_asso_area[0]).attr('id') === "new_member_choice" && $('#new_member_input').val()
.trim().length > 0)
|| ||
($(active_asso_area[0]).attr('id') === "existing_member_choice" && $('#existing_member_choice_action .chosen_associate div.member').length > 0) ($(active_asso_area[0]).attr('id') === "existing_member_choice" && $('#existing_member_choice_action .chosen_associate div.member').length > 0)
) { ) {
associated_data_ok = true; associated_data_ok = true;
} }
if (associated_data_ok === false) errors.push("Le membre 'titulaire' du binôme n'est pas défini"); if (associated_data_ok === false) errors.push("Le membre 'titulaire' du binôme n'est pas défini");
...@@ -318,7 +320,7 @@ function store_new_coop(event) { ...@@ -318,7 +320,7 @@ function store_new_coop(event) {
} }
} }
}); });
} }
...@@ -361,6 +363,7 @@ function modify_current_coop() { ...@@ -361,6 +363,7 @@ function modify_current_coop() {
$('#new_member_choice_action').hide(); $('#new_member_choice_action').hide();
$('#existing_member_choice').addClass('choice_active'); $('#existing_member_choice').addClass('choice_active');
var member_button = '<div>' + current_coop.parent_name + '</div>'; var member_button = '<div>' + current_coop.parent_name + '</div>';
$('.chosen_associate').html(member_button); $('.chosen_associate').html(member_button);
$('.chosen_associate_area').show(); $('.chosen_associate_area').show();
associated_old_choice = 'existing_member_choice'; associated_old_choice = 'existing_member_choice';
...@@ -726,7 +729,7 @@ function display_possible_members() { ...@@ -726,7 +729,7 @@ function display_possible_members() {
/** /**
* Search for members to associate a new member with an old one. * Search for members to associate a new member with an old one.
*/ */
function searchMembersForAssociate() { function searchMembersForAssociate() {
let search_str = $('#search_member_input').val(); let search_str = $('#search_member_input').val();
......
...@@ -75,7 +75,7 @@ var reset_shift_process_actions_zone = function() { ...@@ -75,7 +75,7 @@ var reset_shift_process_actions_zone = function() {
current_shift_process_data_actions.off('click', 'a'); current_shift_process_data_actions.off('click', 'a');
current_shift_process_data_actions.hide(); current_shift_process_data_actions.hide();
current_shift_process_data_actions.empty(); current_shift_process_data_actions.empty();
} };
function fill_member_slide(member) { function fill_member_slide(member) {
no_pict_msg.hide(); no_pict_msg.hide();
...@@ -329,38 +329,39 @@ function fill_service_entry(s) { ...@@ -329,38 +329,39 @@ function fill_service_entry(s) {
reset_shift_process_actions_zone(); reset_shift_process_actions_zone();
if (s.state == 'draft' || s.state == 'confirm') { if (s.state == 'draft' || s.state == 'confirm') {
let btn = $('<a>').addClass('btn btn--primary txtcenter') let btn = $('<a>').addClass('btn btn--primary txtcenter')
.text('Enregistrer les absences / présences') .text('Enregistrer les absences / présences')
.attr('id','record_shift_absences'); .attr('id', 'record_shift_absences');
current_shift_process_data_actions.append(btn); current_shift_process_data_actions.append(btn);
current_shift_process_data_actions.on('click', '#record_shift_absences', function(){ current_shift_process_data_actions.on('click', '#record_shift_absences', function() {
msg = "<p>Lancer le traitement des présences et absences de ce service</p>"; msg = "<p>Lancer le traitement des présences et absences de ce service</p>";
openModal(msg, function() { openModal(msg, function() {
btn.attr('disabled', 'true') btn.attr('disabled', 'true');
try { try {
$.ajax({ $.ajax({
url: '/members/record_shift_absences/' + s.id, url: '/members/record_shift_absences/' + s.id,
dataType : 'json' dataType : 'json'
}) })
.done(function(rData) { .done(function(rData) {
if (typeof rData.res.update !== "undefined" && rData.res.update == true) { if (typeof rData.res.update !== "undefined" && rData.res.update == true) {
enqueue_message_for_next_loading("Données de présences traitées."); enqueue_message_for_next_loading("Données de présences traitées.");
location.reload(); location.reload();
} else { } else {
closeModal(); closeModal();
btn.removeAttr('disabled'); btn.removeAttr('disabled');
alert(JSON.stringify(rData.res)); alert(JSON.stringify(rData.res));
} }
}); });
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
}, 'Confirmer'); }, 'Confirmer');
}); });
} else { } else {
current_shift_process_data_actions.append("<em>Traitement des présences : " + s.state + "</em>"); current_shift_process_data_actions.append("<em>Traitement des présences : " + s.state + "</em>");
} }
current_shift_process_data_actions.show(); current_shift_process_data_actions.show();
} }
rattrapage_ou_volant = null; rattrapage_ou_volant = null;
......
...@@ -25,7 +25,7 @@ function init_my_shifts_tile() { ...@@ -25,7 +25,7 @@ function init_my_shifts_tile() {
function process_asked_shift_template_change(shift_t_id) { function process_asked_shift_template_change(shift_t_id) {
var s_data = shift_templates[shift_t_id].data; var s_data = shift_templates[shift_t_id].data;
var shift_name = get_shift_name(s_data); var shift_name = get_shift_name(s_data);
let msg = 'Inscription au créneau ' + shift_name let msg = 'Inscription au créneau ' + shift_name;
openModal( openModal(
msg, msg,
...@@ -85,7 +85,7 @@ function process_asked_shift_template_change(shift_t_id) { ...@@ -85,7 +85,7 @@ function process_asked_shift_template_change(shift_t_id) {
} }
} }
}); });
}, },
'Valider', 'Valider',
true, // modal closes after validation true, // modal closes after validation
...@@ -94,8 +94,9 @@ function process_asked_shift_template_change(shift_t_id) { ...@@ -94,8 +94,9 @@ function process_asked_shift_template_change(shift_t_id) {
); );
} }
function edit_shift_template_registration(){ function edit_shift_template_registration() {
let external = true; let external = true;
if (calendar == null) calendar = $('#modal-calendar-choice').clone(); if (calendar == null) calendar = $('#modal-calendar-choice').clone();
if ($('#modal-calendar-choice').html().length > 0) { if ($('#modal-calendar-choice').html().length > 0) {
$('#modal-calendar-choice').empty(); $('#modal-calendar-choice').empty();
...@@ -103,9 +104,12 @@ function edit_shift_template_registration(){ ...@@ -103,9 +104,12 @@ function edit_shift_template_registration(){
} }
calendar.find('.oddeven_selector').empty(); calendar.find('.oddeven_selector').empty();
displayMsg(calendar.html()); displayMsg(calendar.html());
$('#week_types').find('input').change(()=>{filter_weeks(external)}); $('#week_types').find('input')
.change(() => {
filter_weeks(external);
});
retrieve_and_draw_shift_tempates(external); retrieve_and_draw_shift_tempates(external);
} }
...@@ -127,7 +131,8 @@ function init_home() { ...@@ -127,7 +131,8 @@ function init_home() {
}); });
$(".member_shift_name_area").on("click", ".fa-edit", (e) => { $(".member_shift_name_area").on("click", ".fa-edit", (e) => {
$('#week_types').find('input').change(filter_weeks); $('#week_types').find('input')
.change(filter_weeks);
e.preventDefault(); e.preventDefault();
edit_shift_template_registration(); edit_shift_template_registration();
}); });
......
...@@ -280,7 +280,7 @@ function offer_extra_shift() { ...@@ -280,7 +280,7 @@ function offer_extra_shift() {
timeout: 3000, timeout: 3000,
success: function() { success: function() {
partner_data.extra_shift_done -= 1; partner_data.extra_shift_done -= 1;
$("#can_delete_future_registrations_area").hide(); $("#can_delete_future_registrations_area").hide();
$(".delete_registration_button").off(); $(".delete_registration_button").off();
$(".delete_registration_button").hide(); $(".delete_registration_button").hide();
...@@ -599,6 +599,7 @@ function init_calendar_page() { ...@@ -599,6 +599,7 @@ function init_calendar_page() {
} else { } else {
// Display modal // Display modal
let modal_template = $("#modal_add_shift_template"); let modal_template = $("#modal_add_shift_template");
modal_template.find(".date_new_shift").text(new_shift_date); modal_template.find(".date_new_shift").text(new_shift_date);
modal_template.find(".time_new_shift").text(new_shift_time); modal_template.find(".time_new_shift").text(new_shift_time);
openModal( openModal(
...@@ -609,7 +610,7 @@ function init_calendar_page() { ...@@ -609,7 +610,7 @@ function init_calendar_page() {
"Valider" "Valider"
); );
} }
} else if (should_select_makeup()) { } else if (should_select_makeup()) {
/* choose a makeup service */ /* choose a makeup service */
// Check if selected new shift is in less than 6 months // Check if selected new shift is in less than 6 months
...@@ -757,14 +758,15 @@ function init_delete_registration_buttons() { ...@@ -757,14 +758,15 @@ function init_delete_registration_buttons() {
if (partner_data.extra_shift_done > 0) { if (partner_data.extra_shift_done > 0) {
$(".delete_registration_button").on("click", function() { $(".delete_registration_button").on("click", function() {
let shift_name = $(this).closest("div") let shift_name = $(this).closest("div")
.parent().parent() .parent()
.parent()
.find(".shift_line_date") .find(".shift_line_date")
.text() .text()
.trim(); .trim();
let shift_id = $(this).closest(".shift_line_container") let shift_id = $(this).closest(".shift_line_container")
.attr('id') .attr('id')
.split('_')[2]; .split('_')[2];
openModal( openModal(
`<p>Je m'apprête à supprimer ma présence au service du <b>${shift_name}</b></p>`, `<p>Je m'apprête à supprimer ma présence au service du <b>${shift_name}</b></p>`,
() => { () => {
...@@ -774,7 +776,7 @@ function init_delete_registration_buttons() { ...@@ -774,7 +776,7 @@ function init_delete_registration_buttons() {
false false
); );
}); });
$(".delete_registration_button").css('display', 'flex'); $(".delete_registration_button").css('display', 'flex');
} }
} }
...@@ -839,17 +841,17 @@ function init_shifts_exchange() { ...@@ -839,17 +841,17 @@ function init_shifts_exchange() {
} }
$('#start_adding_shift').click((c) => { $('#start_adding_shift').click((c) => {
openModal( openModal(
"<p>Je souhaite sélectionner un service supplémentaire.</p>", "<p>Je souhaite sélectionner un service supplémentaire.</p>",
() => { () => {
$(c.target).prop('disabled', true); $(c.target).prop('disabled', true);
adding_mode = true; adding_mode = true;
closeModal(); closeModal();
}, },
"Confirmer", "Confirmer",
false false
); );
}); });
$(window).smartresize(function() { $(window).smartresize(function() {
// only apply if a width threshold is passed // only apply if a width threshold is passed
......
...@@ -314,6 +314,7 @@ $(document).ready(function() { ...@@ -314,6 +314,7 @@ $(document).ready(function() {
// For associated people, their parent name is attached in their display name // For associated people, their parent name is attached in their display name
let partner_name_split = partner_data.name.split(', '); let partner_name_split = partner_data.name.split(', ');
partner_data.name = partner_name_split[partner_name_split.length - 1]; partner_data.name = partner_name_split[partner_name_split.length - 1];
base_location = (app_env === 'dev') ? '/members_space/' : '/'; base_location = (app_env === 'dev') ? '/members_space/' : '/';
......
...@@ -138,7 +138,7 @@ function debounceFunction(func, delay = 1000) { ...@@ -138,7 +138,7 @@ function debounceFunction(func, delay = 1000) {
*/ */
function handle_unauthorize() { function handle_unauthorize() {
alert("La session a expiré. Vous allez devoir vous reconnecter."); alert("La session a expiré. Vous allez devoir vous reconnecter.");
$( "#logout" ).trigger( "click" ); $("#logout").trigger("click");
} }
/* - PRODUCTS */ /* - PRODUCTS */
...@@ -310,10 +310,11 @@ function compute_and_affect_product_supplier_quantities(coeff, days) { ...@@ -310,10 +310,11 @@ function compute_and_affect_product_supplier_quantities(coeff, days) {
const daily_conso = product.daily_conso; const daily_conso = product.daily_conso;
let purchase_package_qty_for_coverage = compute_purchase_qty_for_coverage(product, coeff, stock, incoming_qty, daily_conso, days); let purchase_package_qty_for_coverage = compute_purchase_qty_for_coverage(product, coeff, stock, incoming_qty, daily_conso, days);
// Set qty to purchase for supplier with higher priority // Set qty to purchase for supplier with higher priority
let target_supplierinfo_index = 0; let target_supplierinfo_index = 0;
let min_sequence = Number.POSITIVE_INFINITY; // min sequence = higher priority let min_sequence = Number.POSITIVE_INFINITY; // min sequence = higher priority
for (let i in products[key].suppliersinfo) { for (let i in products[key].suppliersinfo) {
let suppliersinfo_sequence = products[key].suppliersinfo[i].sequence; let suppliersinfo_sequence = products[key].suppliersinfo[i].sequence;
...@@ -491,7 +492,7 @@ function check_products_data() { ...@@ -491,7 +492,7 @@ function check_products_data() {
} }
report_JS_error(err, 'orders'); report_JS_error(err, 'orders');
alert(`Erreur lors de la vérification des données des articles. Certaines données peuvent être erronées`); alert(`Erreur lors de la vérification des données des articles. Certaines données peuvent être erronées`);
$('.notifyjs-wrapper').trigger('notify-hide'); $('.notifyjs-wrapper').trigger('notify-hide');
// Don't block process if this call fails // Don't block process if this call fails
resolve(); resolve();
...@@ -559,15 +560,15 @@ function update_product_ref(input_el, p_id, p_index) { ...@@ -559,15 +560,15 @@ function update_product_ref(input_el, p_id, p_index) {
handle_unauthorize(); handle_unauthorize();
} else { } else {
let msg = "erreur serveur lors de la sauvegarde de la référence"; let msg = "erreur serveur lors de la sauvegarde de la référence";
msg += ` (product_tmpl_id: ${product.id}`; msg += ` (product_tmpl_id: ${product.id}`;
err = {msg: msg, ctx: 'update_product_ref'}; err = {msg: msg, ctx: 'update_product_ref'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') { if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error; err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'orders'); report_JS_error(err, 'orders');
alert('Erreur lors de la sauvegarde de la référence dans Odoo. Veuillez recharger la page et ré-essayer plus tard.'); alert('Erreur lors de la sauvegarde de la référence dans Odoo. Veuillez recharger la page et ré-essayer plus tard.');
} }
} }
...@@ -637,7 +638,7 @@ function add_supplier() { ...@@ -637,7 +638,7 @@ function add_supplier() {
err.msg += ' : ' + data.responseJSON.error; err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'orders'); report_JS_error(err, 'orders');
closeModal(); closeModal();
alert('Erreur lors de la récupération des produits, réessayer plus tard.'); alert('Erreur lors de la récupération des produits, réessayer plus tard.');
} }
...@@ -741,15 +742,15 @@ function save_supplier_product_association(product, supplier, cell) { ...@@ -741,15 +742,15 @@ function save_supplier_product_association(product, supplier, cell) {
handle_unauthorize(); handle_unauthorize();
} else { } else {
let msg = "erreur serveur lors de la sauvegarde de l'association product/supplier"; let msg = "erreur serveur lors de la sauvegarde de l'association product/supplier";
msg += ` (product_tmpl_id: ${product.id}; supplier_id: ${supplier.id})`; msg += ` (product_tmpl_id: ${product.id}; supplier_id: ${supplier.id})`;
err = {msg: msg, ctx: 'save_supplier_product_association'}; err = {msg: msg, ctx: 'save_supplier_product_association'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') { if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error; err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'orders'); report_JS_error(err, 'orders');
closeModal(); closeModal();
alert('Erreur lors de la sauvegarde de l\'association. Veuillez ré-essayer plus tard.'); alert('Erreur lors de la sauvegarde de l\'association. Veuillez ré-essayer plus tard.');
} }
...@@ -800,13 +801,13 @@ function end_supplier_product_association(product, supplier) { ...@@ -800,13 +801,13 @@ function end_supplier_product_association(product, supplier) {
} else { } else {
let msg = "erreur serveur lors de la suppression de l'association product/supplier". let msg = "erreur serveur lors de la suppression de l'association product/supplier".
msg += ` (product_tmpl_id: ${product.id}; supplier_id: ${supplier.id})`; msg += ` (product_tmpl_id: ${product.id}; supplier_id: ${supplier.id})`;
err = {msg: msg, ctx: 'end_supplier_product_association'}; err = {msg: msg, ctx: 'end_supplier_product_association'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') { if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error; err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'orders'); report_JS_error(err, 'orders');
closeModal(); closeModal();
alert('Erreur lors de la suppression de l\'association. Veuillez ré-essayer plus tard.'); alert('Erreur lors de la suppression de l\'association. Veuillez ré-essayer plus tard.');
} }
...@@ -980,13 +981,13 @@ function commit_actions_on_product(product, inputs) { ...@@ -980,13 +981,13 @@ function commit_actions_on_product(product, inputs) {
} else { } else {
let msg = "erreur serveur lors de la sauvegarde". let msg = "erreur serveur lors de la sauvegarde".
msg += ` (product_tmpl_id: ${product.id})`; msg += ` (product_tmpl_id: ${product.id})`;
err = {msg: msg, ctx: 'commit_actions_on_product'}; err = {msg: msg, ctx: 'commit_actions_on_product'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') { if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error; err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'orders'); report_JS_error(err, 'orders');
try { try {
if (data.responseJSON.code === "archiving_with_incoming_qty") { if (data.responseJSON.code === "archiving_with_incoming_qty") {
alert("Ce produit a des quantités entrantes, vous ne pouvez pas l'archiver."); alert("Ce produit a des quantités entrantes, vous ne pouvez pas l'archiver.");
...@@ -998,7 +999,7 @@ function commit_actions_on_product(product, inputs) { ...@@ -998,7 +999,7 @@ function commit_actions_on_product(product, inputs) {
} catch (error) { } catch (error) {
alert('Erreur lors de la sauvegarde des données. Veuillez ré-essayer plus tard.'); alert('Erreur lors de la sauvegarde des données. Veuillez ré-essayer plus tard.');
} }
check_products_data() check_products_data()
.then(() => { .then(() => {
update_cdb_order(); update_cdb_order();
...@@ -1081,12 +1082,12 @@ function generate_inventory() { ...@@ -1081,12 +1082,12 @@ function generate_inventory() {
.append(`Faire un inventaire`); .append(`Faire un inventaire`);
let msg = "erreur serveur lors de la création de l'inventaire", let msg = "erreur serveur lors de la création de l'inventaire",
err = {msg: msg, ctx: 'generate_inventory'}; err = {msg: msg, ctx: 'generate_inventory'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') { if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error; err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'orders'); report_JS_error(err, 'orders');
alert("Erreur lors de la création de l'inventaire. Réessayez plus tard."); alert("Erreur lors de la création de l'inventaire. Réessayez plus tard.");
} }
} }
...@@ -1362,13 +1363,13 @@ function create_orders() { ...@@ -1362,13 +1363,13 @@ function create_orders() {
handle_unauthorize(); handle_unauthorize();
} else { } else {
let msg = "erreur serveur lors de la création des product orders"; let msg = "erreur serveur lors de la création des product orders";
err = {msg: msg, ctx: 'save_supplier_product_association', data: orders_data}; err = {msg: msg, ctx: 'save_supplier_product_association', data: orders_data};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') { if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error; err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'orders'); report_JS_error(err, 'orders');
closeModal(); closeModal();
alert('Erreur lors de la création des commandes. Veuillez ré-essayer plus tard.'); alert('Erreur lors de la création des commandes. Veuillez ré-essayer plus tard.');
} }
...@@ -2826,7 +2827,7 @@ $(document).ready(function() { ...@@ -2826,7 +2827,7 @@ $(document).ready(function() {
err.msg += ' : ' + data.responseJSON.error; err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'orders'); report_JS_error(err, 'orders');
closeModal(); closeModal();
alert('Erreur lors de la récupération des fournisseurs, rechargez la page plus tard'); alert('Erreur lors de la récupération des fournisseurs, rechargez la page plus tard');
} }
......
...@@ -1979,10 +1979,12 @@ function add_products_action() { ...@@ -1979,10 +1979,12 @@ function add_products_action() {
for (let qty_input of qty_inputs) { for (let qty_input of qty_inputs) {
if ($(qty_input).val() === "") { if ($(qty_input).val() === "") {
has_empty_qty_input = true; has_empty_qty_input = true;
$(qty_input).closest(".product_qty").find(".product_qty_input_alert") $(qty_input).closest(".product_qty")
.find(".product_qty_input_alert")
.show(); .show();
} else { } else {
$(qty_input).closest(".product_qty").find(".product_qty_input_alert") $(qty_input).closest(".product_qty")
.find(".product_qty_input_alert")
.hide(); .hide();
} }
} }
...@@ -2024,8 +2026,10 @@ function create_orders() { ...@@ -2024,8 +2026,10 @@ function create_orders() {
for (let i = 0; i < add_products_lines.length; i++) { for (let i = 0; i < add_products_lines.length; i++) {
let line = add_products_lines[i]; let line = add_products_lines[i];
if ($(line).find(".product_name").text() === p.name) { if ($(line).find(".product_name")
product_uom = $(line).find(".product_uom").text(); .text() === p.name) {
product_uom = $(line).find(".product_uom")
.text();
if (product_uom.includes("kg")) { if (product_uom.includes("kg")) {
product_qty = parseFloat($(line).find(".product_qty_input") product_qty = parseFloat($(line).find(".product_qty_input")
...@@ -2045,15 +2049,16 @@ function create_orders() { ...@@ -2045,15 +2049,16 @@ function create_orders() {
// If package qty is > than input value, package qty will be used while creating order // If package qty is > than input value, package qty will be used while creating order
let package_qty = p_supplierinfo.package_qty; let package_qty = p_supplierinfo.package_qty;
if (product_qty < package_qty) { if (product_qty < package_qty) {
package_qty = product_qty; package_qty = product_qty;
} }
// Round differently for unit & kg products // Round differently for unit & kg products
if (product_uom.includes("kg") ) { if (product_uom.includes("kg")) {
item_qty_package = Math.round((product_qty / package_qty) * 1e2) / 1e2; item_qty_package = Math.round((product_qty / package_qty) * 1e2) / 1e2;
} else { } else {
item_qty_package = Math.round(product_qty / package_qty) item_qty_package = Math.round(product_qty / package_qty);
} }
orders_data.suppliers_data[supplier_id].lines.push({ orders_data.suppliers_data[supplier_id].lines.push({
......
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