Commit ac8536c7 by François C.

After ESLint --fix on last merge

parent cbdc67e4
Pipeline #1103 passed with stage
in 1 minute 41 seconds
...@@ -7,10 +7,10 @@ function init_datatable() { ...@@ -7,10 +7,10 @@ function init_datatable() {
// For a smooth migration... // For a smooth migration...
for (const i in lists) { for (const i in lists) {
if (('partners' in lists[i]) === false) { if (('partners' in lists[i]) === false) {
lists[i]['partners'] = [lists[i]['partner']] lists[i]['partners'] = [lists[i]['partner']];
} }
} }
return $('#lists').DataTable({ return $('#lists').DataTable({
data: lists, // data passed at page loading data: lists, // data passed at page loading
rowId: 'id', rowId: 'id',
...@@ -31,6 +31,7 @@ function init_datatable() { ...@@ -31,6 +31,7 @@ function init_datatable() {
for (const i in data) { for (const i in data) {
res += `${data[i]}<br/>`; res += `${data[i]}<br/>`;
} }
return res; return res;
} }
}, },
......
...@@ -258,21 +258,21 @@ function save_current_coop(callback) { ...@@ -258,21 +258,21 @@ function save_current_coop(callback) {
sex_error = false; sex_error = false;
if (/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/.exec(birthdate)) { if (/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/.exec(birthdate)) {
try{ try {
var jj = RegExp.$1, var jj = RegExp.$1,
mm = RegExp.$2, mm = RegExp.$2,
aaaa = RegExp.$3; aaaa = RegExp.$3;
let tmp_date = aaaa + "-" + mm + "-" + jj; let tmp_date = aaaa + "-" + mm + "-" + jj;
// try to create a date object // try to create a date object
date_test = new Date(tmp_date); date_test = new Date(tmp_date);
// if date is invalid a correction is apply in date object. Check it // if date is invalid a correction is apply in date object. Check it
// january start at 0, so we add + 1 for the month // january start at 0, so we add + 1 for the month
if ((date_test.getDate() !== parseInt(jj)) || ((date_test.getMonth()+1) !== parseInt(mm)) || (date_test.getFullYear() !== parseInt(aaaa)) || !date_test.isValid()) if ((date_test.getDate() !== parseInt(jj)) || ((date_test.getMonth()+1) !== parseInt(mm)) || (date_test.getFullYear() !== parseInt(aaaa)) || !date_test.isValid()) {
{
birthdate_error = true; birthdate_error = true;
} }
}catch(Exception){ } catch (Exception) {
birthdate_error = true; birthdate_error = true;
} }
......
...@@ -9,7 +9,7 @@ var suppliers_list = [], ...@@ -9,7 +9,7 @@ var suppliers_list = [],
_id: null, _id: null,
last_update : { last_update : {
timestamp: null, timestamp: null,
fingerprint: null, fingerprint: null
}, },
products: [], products: [],
selected_suppliers: [], selected_suppliers: [],
...@@ -31,7 +31,7 @@ function reset_data() { ...@@ -31,7 +31,7 @@ function reset_data() {
_id: null, _id: null,
last_update : { last_update : {
timestamp: null, timestamp: null,
fingerprint: null, fingerprint: null
}, },
products: [], products: [],
selected_suppliers: [] selected_suppliers: []
...@@ -40,26 +40,26 @@ function reset_data() { ...@@ -40,26 +40,26 @@ function reset_data() {
/** /**
* Difference between two dates * Difference between two dates
* @param {Date} date1 * @param {Date} date1
* @param {Date} date2 * @param {Date} date2
* @returns difference object * @returns difference object
*/ */
function dates_diff(date1, date2) { function dates_diff(date1, date2) {
var diff = {} var diff = {};
var tmp = date2 - date1; var tmp = date2 - date1;
tmp = Math.floor(tmp/1000); tmp = Math.floor(tmp/1000);
diff.sec = tmp % 60; diff.sec = tmp % 60;
tmp = Math.floor((tmp-diff.sec)/60); tmp = Math.floor((tmp-diff.sec)/60);
diff.min = tmp % 60; diff.min = tmp % 60;
tmp = Math.floor((tmp-diff.min)/60); tmp = Math.floor((tmp-diff.min)/60);
diff.hours = tmp % 24; diff.hours = tmp % 24;
tmp = Math.floor((tmp-diff.hours)/24); tmp = Math.floor((tmp-diff.hours)/24);
diff.days = tmp; diff.days = tmp;
return diff; return diff;
} }
...@@ -676,6 +676,7 @@ function update_order_selection_screen() { ...@@ -676,6 +676,7 @@ function update_order_selection_screen() {
$(".order_pill").off(); $(".order_pill").off();
let existing_orders_container = $("#existing_orders"); let existing_orders_container = $("#existing_orders");
existing_orders_container.empty(); existing_orders_container.empty();
dbc.allDocs({ dbc.allDocs({
...@@ -686,8 +687,9 @@ function update_order_selection_screen() { ...@@ -686,8 +687,9 @@ function update_order_selection_screen() {
} else { } else {
for (let row of result.rows) { for (let row of result.rows) {
let template = $("#templates #order_pill_template"); let template = $("#templates #order_pill_template");
template.find(".pill_order_name").text(row.id); template.find(".pill_order_name").text(row.id);
existing_orders_container.append(template.html()); existing_orders_container.append(template.html());
} }
...@@ -739,7 +741,7 @@ function goto_main_screen(doc) { ...@@ -739,7 +741,7 @@ function goto_main_screen(doc) {
products = order_doc.products; products = order_doc.products;
selected_suppliers = order_doc.selected_suppliers; selected_suppliers = order_doc.selected_suppliers;
update_order() update_order();
update_main_screen(); update_main_screen();
switch_screen(); switch_screen();
} }
...@@ -749,9 +751,9 @@ function back() { ...@@ -749,9 +751,9 @@ function back() {
update_order_selection_screen(); update_order_selection_screen();
switch_screen('order_selection'); switch_screen('order_selection');
} }
/** /**
* Event fct: on click on an order button * Event fct: on click on an order button
*/ */
function order_pill_on_click() { function order_pill_on_click() {
let order_name_container = $(this).find('.pill_order_name'); let order_name_container = $(this).find('.pill_order_name');
...@@ -759,38 +761,39 @@ function order_pill_on_click() { ...@@ -759,38 +761,39 @@ function order_pill_on_click() {
dbc.get(doc_id).then((doc) => { dbc.get(doc_id).then((doc) => {
if (doc.last_update.fingerprint !== fingerprint) { if (doc.last_update.fingerprint !== fingerprint) {
time_diff = dates_diff(new Date(doc.last_update.timestamp), new Date()) time_diff = dates_diff(new Date(doc.last_update.timestamp), new Date());
diff_str = `` diff_str = ``;
if (time_diff.days !== 0) { if (time_diff.days !== 0) {
diff_str += `${time_diff.days} jour(s), ` diff_str += `${time_diff.days} jour(s), `;
} }
if (time_diff.hours !== 0) { if (time_diff.hours !== 0) {
diff_str += `${time_diff.hours} heure(s), ` diff_str += `${time_diff.hours} heure(s), `;
} }
if (time_diff.min !== 0) { if (time_diff.min !== 0) {
diff_str += `${time_diff.min} min, ` diff_str += `${time_diff.min} min, `;
} }
diff_str += `${time_diff.sec}s` diff_str += `${time_diff.sec}s`;
let modal_order_access = $('#templates #modal_order_access'); let modal_order_access = $('#templates #modal_order_access');
modal_order_access.find(".order_last_update").text(diff_str); modal_order_access.find(".order_last_update").text(diff_str);
openModal( openModal(
modal_order_access.html(), modal_order_access.html(),
() => { () => {
goto_main_screen(doc) goto_main_screen(doc);
}, },
'Valider' 'Valider'
); );
} else { } else {
goto_main_screen(doc) goto_main_screen(doc);
} }
}) })
.catch(function (err) { .catch(function (err) {
alert('Erreur lors de la récupération de la commande. Si l\'erreur persiste, contactez un administrateur svp.'); alert('Erreur lors de la récupération de la commande. Si l\'erreur persiste, contactez un administrateur svp.');
console.log(err); console.log(err);
}); });
} }
/** /**
...@@ -823,7 +826,7 @@ function update_order() { ...@@ -823,7 +826,7 @@ function update_order() {
// Save that current user last updated the order // Save that current user last updated the order
order_doc.last_update = { order_doc.last_update = {
timestamp: Date.now(), timestamp: Date.now(),
fingerprint: fingerprint, fingerprint: fingerprint
}; };
dbc.put(order_doc, function callback(err, result) { dbc.put(order_doc, function callback(err, result) {
...@@ -872,7 +875,7 @@ $(document).ready(function() { ...@@ -872,7 +875,7 @@ $(document).ready(function() {
if (err.status === 409) { if (err.status === 409) {
alert("Une erreur de synchronisation s'est produite, la commande a sûrement été modifiée sur un autre navigateur. Vous allez être redirigé.e."); alert("Une erreur de synchronisation s'est produite, la commande a sûrement été modifiée sur un autre navigateur. Vous allez être redirigé.e.");
back(); back();
} }
console.log('erreur sync'); console.log('erreur sync');
console.log(err); console.log(err);
}); });
......
...@@ -37,6 +37,7 @@ IFCBarcodes = { ...@@ -37,6 +37,7 @@ IFCBarcodes = {
try { try {
let price = parseFloat(value); let price = parseFloat(value);
if (currency == 'FF') if (currency == 'FF')
price = price / 6.55957; price = price / 6.55957;
...@@ -131,6 +132,7 @@ IFCBarcodes = { ...@@ -131,6 +132,7 @@ IFCBarcodes = {
if (product_data !== null) { if (product_data !== null) {
p_uom = (this.uoms)[product_data[this.keys.uom_id]]; p_uom = (this.uoms)[product_data[this.keys.uom_id]];
let qty = 1; let qty = 1;
if (encoded_value.length > 0 && !isNaN(encoded_value)) { if (encoded_value.length > 0 && !isNaN(encoded_value)) {
qty = 0; //if no rule is found it will advise user that there is a problem qty = 0; //if no rule is found it will advise user that there is a problem
/* /*
...@@ -149,7 +151,8 @@ IFCBarcodes = { ...@@ -149,7 +151,8 @@ IFCBarcodes = {
} else { } else {
let list_price = product_data[this.keys.list_price]; let list_price = product_data[this.keys.list_price];
let currency = null; let currency = null;
if (pattern_type == 'FF_price_to_weight') currency = 'FF'
if (pattern_type == 'FF_price_to_weight') currency = 'FF';
qty = parseFloat(this.get_quantity_eq_to_encoded_price(encoded_value, list_price, currency)); qty = parseFloat(this.get_quantity_eq_to_encoded_price(encoded_value, list_price, currency));
} }
......
...@@ -376,34 +376,34 @@ $(document).ready(function() { ...@@ -376,34 +376,34 @@ $(document).ready(function() {
render: function (data) { render: function (data) {
switch (data) { switch (data) {
case 'qty_valid': case 'qty_valid':
return "<span class='btn--success'>Mettre à jour les prix</span>"; return "<span class='btn--success'>Mettre à jour les prix</span>";
case 'br_valid': case 'br_valid':
return "<span class='btn'><i class='far fa-check-circle'></i> Réception OK</span>"; return "<span class='btn'><i class='far fa-check-circle'></i> Réception OK</span>";
case 'False': case 'False':
return "<span class='btn--primary'>Compter les produits</span>"; return "<span class='btn--primary'>Compter les produits</span>";
case 'done': case 'done':
return "<span class='btn'><i class='far fa-check-circle'></i> Terminé</span>"; return "<span class='btn'><i class='far fa-check-circle'></i> Terminé</span>";
case 'uprice_valid': case 'uprice_valid':
return "<span class='btn--primary'>Mise à jour du prix OK</span>"; return "<span class='btn--primary'>Mise à jour du prix OK</span>";
case "valid_pending": case "valid_pending":
return "<span class='btn--info'>En attente de validation</span>"; return "<span class='btn--info'>En attente de validation</span>";
case 'legacy': case 'legacy':
return "<span class='btn--success'>Legacy</span>"; return "<span class='btn--success'>Legacy</span>";
case 'error_pack_op': case 'error_pack_op':
return "<span class='btn--danger'>Erreur pack operations</span>"; return "<span class='btn--danger'>Erreur pack operations</span>";
case 'error_transfer': case 'error_transfer':
return "<span class='btn--danger'>Erreur de transfert</span>"; return "<span class='btn--danger'>Erreur de transfert</span>";
case 'error_picking': case 'error_picking':
return "<span class='btn--danger'>Erreur validation quantité</span>"; return "<span class='btn--danger'>Erreur validation quantité</span>";
case '/error_uprice': case '/error_uprice':
return "<span class='btn--danger'>Erreur mise à jour du prix</span>"; return "<span class='btn--danger'>Erreur mise à jour du prix</span>";
default: default:
return "<span class='btn--warning'>Status inconnu : " + data + "</span>"; return "<span class='btn--warning'>Status inconnu : " + data + "</span>";
} }
}, },
width: "20%" width: "20%"
......
...@@ -330,8 +330,13 @@ function initLists() { ...@@ -330,8 +330,13 @@ function initLists() {
className:"dt-head-center dt-body-center", className:"dt-head-center dt-body-center",
visible: (reception_status == "False"), visible: (reception_status == "False"),
render: function (data, type, full) { render: function (data, type, full) {
let disp = [full.product_qty, (full.old_qty !== undefined)?full.old_qty:full.product_qty].join("/"); let disp = [
return disp; full.product_qty,
(full.old_qty !== undefined)?full.old_qty:full.product_qty
].join("/");
return disp;
}, },
orderable: false orderable: false
}, },
...@@ -1346,6 +1351,7 @@ function openErrorReport() { ...@@ -1346,6 +1351,7 @@ function openErrorReport() {
// this is necessary because default behavior is overwritten by the listener defined in jquery.pos.js; // this is necessary because default behavior is overwritten by the listener defined in jquery.pos.js;
$("#error_report").keypress(function(e) { $("#error_report").keypress(function(e) {
var key = e.keyCode; var key = e.keyCode;
if (key === 13) { if (key === 13) {
this.value += "\n"; this.value += "\n";
} }
......
...@@ -63,10 +63,12 @@ function display_orders(orders) { ...@@ -63,10 +63,12 @@ function display_orders(orders) {
orderable: false, orderable: false,
render: function (data) { render: function (data) {
let res = '<ul>'; let res = '<ul>';
for (p of data) { for (p of data) {
res += `<li>${p.journal_id[1]} : ${p.amount} €</li>` res += `<li>${p.journal_id[1]} : ${p.amount} €</li>`;
} }
res += "</ul>" res += "</ul>";
return res; return res;
} }
} }
...@@ -97,6 +99,7 @@ function get_sales() { ...@@ -97,6 +99,7 @@ function get_sales() {
openModal(); openModal();
var url = "/sales/get_sales"; var url = "/sales/get_sales";
url += '?from=' + encodeURIComponent(from_datepicker.val()); url += '?from=' + encodeURIComponent(from_datepicker.val());
url += '&to=' + encodeURIComponent(to_datepicker.val()); url += '&to=' + encodeURIComponent(to_datepicker.val());
...@@ -189,7 +192,7 @@ $(document).ready(function() { ...@@ -189,7 +192,7 @@ $(document).ready(function() {
enable_validation(); enable_validation();
}); });
$( "#sales_form" ).submit(function( event ) { $("#sales_form").submit(function(event) {
event.preventDefault(); event.preventDefault();
get_sales(); get_sales();
}); });
......
...@@ -1067,16 +1067,18 @@ var shouldCategoryBeShown = function (cat_id) { ...@@ -1067,16 +1067,18 @@ var shouldCategoryBeShown = function (cat_id) {
answer = false; answer = false;
} }
if (typeof cat_nb_pdts != "undefined") { if (typeof cat_nb_pdts != "undefined") {
let list = cat_nb_pdts.list; let list = cat_nb_pdts.list;
let cat_ids = Object.keys(list).map(x => parseInt(x,10)); let cat_ids = Object.keys(list).map(x => parseInt(x, 10));
//cat_ids is now an array of category ids which have product //cat_ids is now an array of category ids which have product
if (cat_ids.indexOf(cat_id) < 0) { if (cat_ids.indexOf(cat_id) < 0) {
// cat_id is corresponding to a category which have no product // cat_id is corresponding to a category which have no product
answer = false; answer = false;
} }
} }
return answer; return answer;
} };
var appendChildrenCatToMenu = function (catdiv, children) { var appendChildrenCatToMenu = function (catdiv, children) {
var ul = catdiv.find('ul'); var ul = catdiv.find('ul');
...@@ -1400,28 +1402,29 @@ var showSentCart = function() { ...@@ -1400,28 +1402,29 @@ var showSentCart = function() {
content = $('<div>'), content = $('<div>'),
table = $('<table>'); table = $('<table>');
let header = $('<tr><th>Article</th><th>Qté</th><th>Prix Total (T.T.C)</th></tr>'); let header = $('<tr><th>Article</th><th>Qté</th><th>Prix Total (T.T.C)</th></tr>');
let bottom_msg = $('<p>').html("<em>Contenu non modifiable.</em>") let bottom_msg = $('<p>').html("<em>Contenu non modifiable.</em>");
table.append(header); table.append(header);
$.each(my_sent_orders, function(i,e) { $.each(my_sent_orders, function(i, e) {
if (e._id == id) { if (e._id == id) {
$.each(e.products, function (j,p) { $.each(e.products, function (j, p) {
let tr = $('<tr>'), let tr = $('<tr>'),
name = $('<td>').text(p.name), name = $('<td>').text(p.name),
qty = $('<td>').text(p.qty), qty = $('<td>').text(p.qty),
total = $('<td>').text(p.total) total = $('<td>').text(p.total);
tr.append(name); tr.append(name);
tr.append(qty); tr.append(qty);
tr.append(total); tr.append(total);
table.append(tr); table.append(tr);
}) });
} }
}) });
content.append(table); content.append(table);
content.append(bottom_msg); content.append(bottom_msg);
displayMsg(content.html()); displayMsg(content.html());
} };
var destroySentCart = function() { var destroySentCart = function() {
var clicked = $(this); var clicked = $(this);
......
...@@ -318,6 +318,7 @@ function fetch_product_from_bc(barcode) { ...@@ -318,6 +318,7 @@ function fetch_product_from_bc(barcode) {
if (p_existing !== null) { if (p_existing !== null) {
without_consent_update_product(p_existing, product.qty); without_consent_update_product(p_existing, product.qty);
return 0; return 0;
} else { } else {
add_product(product); add_product(product);
......
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