Commit ac8536c7 by François C.

After ESLint --fix on last merge

parent cbdc67e4
...@@ -7,7 +7,7 @@ function init_datatable() { ...@@ -7,7 +7,7 @@ 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']];
} }
} }
...@@ -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: []
...@@ -45,7 +45,7 @@ function reset_data() { ...@@ -45,7 +45,7 @@ function reset_data() {
* @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);
...@@ -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,6 +687,7 @@ function update_order_selection_screen() { ...@@ -686,6 +687,7 @@ 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();
} }
...@@ -759,32 +761,33 @@ function order_pill_on_click() { ...@@ -759,32 +761,33 @@ 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) {
...@@ -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) {
......
...@@ -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));
} }
......
...@@ -330,7 +330,12 @@ function initLists() { ...@@ -330,7 +330,12 @@ 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 = [
full.product_qty,
(full.old_qty !== undefined)?full.old_qty:full.product_qty
].join("/");
return disp; 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();
}); });
......
...@@ -1068,15 +1068,17 @@ var shouldCategoryBeShown = function (cat_id) { ...@@ -1068,15 +1068,17 @@ var shouldCategoryBeShown = function (cat_id) {
} }
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