Commit e94b0ad6 by Damien Moulard

login in aide à la commande

parent 52f20d7a
Pipeline #1146 passed with stage
in 1 minute 22 seconds
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
position: relative; position: relative;
} }
.page_content { .page_content, .login_area {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
......
...@@ -1638,243 +1638,250 @@ function init_pouchdb_sync() { ...@@ -1638,243 +1638,250 @@ function init_pouchdb_sync() {
$(document).ready(function() { $(document).ready(function() {
fingerprint = new Fingerprint({canvas: true}).get(); if (coop_is_connected()) {
$.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } }); $('#new_order_form').show();
$('#existing_orders_area').show();
openModal(); fingerprint = new Fingerprint({canvas: true}).get();
$.ajaxSetup({ headers: { "X-CSRFToken": getCookie('csrftoken') } });
init_pouchdb_sync(); openModal();
// Main screen init_pouchdb_sync();
$("#coverage_form").on("submit", function(e) {
e.preventDefault(); // Main screen
if (is_time_to('submit_coverage_form', 1000)) { $("#coverage_form").on("submit", function(e) {
let val = $("#coverage_days_input").val(); e.preventDefault();
if (is_time_to('submit_coverage_form', 1000)) {
val = parseInt(val); let val = $("#coverage_days_input").val();
if (!isNaN(val)) { val = parseInt(val);
order_doc.coverage_days = val;
compute_products_coverage_qties(); if (!isNaN(val)) {
update_cdb_order(); order_doc.coverage_days = val;
update_main_screen(); compute_products_coverage_qties();
} else { update_cdb_order();
$("#coverage_days_input").val(order_doc.coverage_days); update_main_screen();
alert(`Valeur non valide pour le nombre de jours de couverture !`); } else {
$("#coverage_days_input").val(order_doc.coverage_days);
alert(`Valeur non valide pour le nombre de jours de couverture !`);
}
} }
} });
});
$("#supplier_form").on("submit", function(e) { $("#supplier_form").on("submit", function(e) {
e.preventDefault(); e.preventDefault();
if (is_time_to('add_product', 1000)) { if (is_time_to('add_product', 1000)) {
add_supplier(); add_supplier();
} }
}); });
$("#product_form").on("submit", function(e) { $("#product_form").on("submit", function(e) {
e.preventDefault(); e.preventDefault();
if (is_time_to('add_product', 1000)) { if (is_time_to('add_product', 1000)) {
add_product(); add_product();
} }
}); });
$("#do_inventory").on("click", function() { $("#do_inventory").on("click", function() {
if (is_time_to('generate_inventory', 1000)) { if (is_time_to('generate_inventory', 1000)) {
generate_inventory(); generate_inventory();
} }
}); });
$('#back_to_order_selection_from_main').on('click', function() { $('#back_to_order_selection_from_main').on('click', function() {
if (is_time_to('back_to_order_selection_from_main', 1000)) { if (is_time_to('back_to_order_selection_from_main', 1000)) {
back(); back();
} }
}); });
$('#create_orders').on('click', function() { $('#create_orders').on('click', function() {
if (is_time_to('create_orders', 1000)) { if (is_time_to('create_orders', 1000)) {
let modal_create_order = $('#templates #modal_create_order'); let modal_create_order = $('#templates #modal_create_order');
modal_create_order.find('.suppliers_date_planned_area').empty(); modal_create_order.find('.suppliers_date_planned_area').empty();
for (let supplier of selected_suppliers) {
let supplier_date_planned_template = $('#templates #modal_create_order__supplier_date_planned');
supplier_date_planned_template.find(".supplier_name").text(supplier.display_name); for (let supplier of selected_suppliers) {
supplier_date_planned_template.find(".modal_input_container").attr('id', `container_date_planned_supplier_${supplier.id}`); let supplier_date_planned_template = $('#templates #modal_create_order__supplier_date_planned');
modal_create_order.find('.suppliers_date_planned_area').append(supplier_date_planned_template.html());
}
openModal(
modal_create_order.html(),
() => {
if (is_time_to('validate_create_orders')) {
create_orders();
}
},
'Valider',
false
);
// Add id to input once modal is displayed
for (let supplier of selected_suppliers) {
$(`#modal #container_date_planned_supplier_${supplier.id}`).find(".supplier_date_planned").attr('id', `date_planned_supplier_${supplier.id}`);
}
$("#modal .supplier_date_planned")
.datepicker({
defaultDate: "+1d",
minDate: new Date()
})
.on('change', function() {
try {
// When date input changes, try to read date
$.datepicker.parseDate(date_format, $(this).val());
} catch {
alert('Date invalide');
$(this).val('');
}
});
}
return 0; supplier_date_planned_template.find(".supplier_name").text(supplier.display_name);
}); supplier_date_planned_template.find(".modal_input_container").attr('id', `container_date_planned_supplier_${supplier.id}`);
modal_create_order.find('.suppliers_date_planned_area').append(supplier_date_planned_template.html());
}
openModal(
modal_create_order.html(),
() => {
if (is_time_to('validate_create_orders')) {
create_orders();
}
},
'Valider',
false
);
// Add id to input once modal is displayed
for (let supplier of selected_suppliers) {
$(`#modal #container_date_planned_supplier_${supplier.id}`).find(".supplier_date_planned").attr('id', `date_planned_supplier_${supplier.id}`);
}
$("#modal .supplier_date_planned")
.datepicker({
defaultDate: "+1d",
minDate: new Date()
})
.on('change', function() {
try {
// When date input changes, try to read date
$.datepicker.parseDate(date_format, $(this).val());
} catch {
alert('Date invalide');
$(this).val('');
}
});
}
return 0;
});
$.datepicker.regional['fr'] = { $.datepicker.regional['fr'] = {
monthNames: [ monthNames: [
'Janvier', 'Janvier',
'Fevrier', 'Fevrier',
'Mars', 'Mars',
'Avril', 'Avril',
'Mai', 'Mai',
'Juin', 'Juin',
'Juillet', 'Juillet',
'Aout', 'Aout',
'Septembre', 'Septembre',
'Octobre', 'Octobre',
'Novembre', 'Novembre',
'Decembre' 'Decembre'
], ],
dayNamesMin: [ dayNamesMin: [
'Di', 'Di',
'Lu', 'Lu',
'Ma', 'Ma',
'Me', 'Me',
'Je', 'Je',
'Ve', 'Ve',
'Sa' 'Sa'
], ],
dateFormat: date_format dateFormat: date_format
}; };
$.datepicker.setDefaults($.datepicker.regional['fr']); $.datepicker.setDefaults($.datepicker.regional['fr']);
// Order selection screen // Order selection screen
update_order_selection_screen(); update_order_selection_screen();
$("#new_order_form").on("submit", function(e) { $("#new_order_form").on("submit", function(e) {
e.preventDefault(); e.preventDefault();
if (is_time_to('submit_new_order_form', 1000)) { if (is_time_to('submit_new_order_form', 1000)) {
create_cdb_order(); create_cdb_order();
} }
}); });
// Orders created screen // Orders created screen
$('#back_to_order_selection_from_orders_created').on('click', function() { $('#back_to_order_selection_from_orders_created').on('click', function() {
if (is_time_to('back_to_order_selection_from_orders_created', 1000)) { if (is_time_to('back_to_order_selection_from_orders_created', 1000)) {
switch_screen('order_selection', 'orders_created'); switch_screen('order_selection', 'orders_created');
} }
}); });
// Get suppliers // Get suppliers
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: "/orders/get_suppliers", url: "/orders/get_suppliers",
dataType:"json", dataType:"json",
traditional: true, traditional: true,
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
success: function(data) { success: function(data) {
suppliers_list = data.res; suppliers_list = data.res;
// Set up autocomplete on supplier input // Set up autocomplete on supplier input
$("#supplier_input").autocomplete({ $("#supplier_input").autocomplete({
source: suppliers_list.map(a => a.display_name) source: suppliers_list.map(a => a.display_name)
}); });
}, },
error: function(data) { error: function(data) {
err = {msg: "erreur serveur lors de la récupération des fournisseurs", ctx: 'get_suppliers'}; err = {msg: "erreur serveur lors de la récupération des fournisseurs", ctx: 'get_suppliers'};
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');
closeModal();
alert('Erreur lors de la récupération des fournisseurs, rechargez la page plus tard');
} }
report_JS_error(err, 'orders'); });
closeModal(); //Get products
alert('Erreur lors de la récupération des fournisseurs, rechargez la page plus tard'); var accentMap = {
} "á": "a",
}); "à": "a",
"â": "a",
"é": "e",
"è": "e",
"ê": "e",
"ë": "e",
"ç": "c",
"ù": "u",
"ü": "u",
"ö": "o"
};
//Get products var normalize = function(term) {
var accentMap = { var ret = "";
"á": "a",
"à": "a",
"â": "a",
"é": "e",
"è": "e",
"ê": "e",
"ë": "e",
"ç": "c",
"ù": "u",
"ü": "u",
"ö": "o"
};
var normalize = function(term) { for (var i = 0; i < term.length; i++) {
var ret = ""; ret += accentMap[ term.charAt(i) ] || term.charAt(i);
}
for (var i = 0; i < term.length; i++) { return ret;
ret += accentMap[ term.charAt(i) ] || term.charAt(i); };
}
return ret; $.ajax({
}; type: 'GET',
url: "/products/simple_list",
dataType:"json",
traditional: true,
contentType: "application/json; charset=utf-8",
success: function(data) {
products_list = data.list;
$.ajax({ // Set up autocomplete on product input
type: 'GET', $("#product_input").autocomplete({
url: "/products/simple_list", source: function(request, response) {
dataType:"json", var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
traditional: true,
contentType: "application/json; charset=utf-8",
success: function(data) {
products_list = data.list;
// Set up autocomplete on product input response($.grep(products_list.map(a => a.display_name), function(value) {
$("#product_input").autocomplete({ value = value.label || value.value || value;
source: function(request, response) {
var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
response($.grep(products_list.map(a => a.display_name), function(value) { return matcher.test(value) || matcher.test(normalize(value));
value = value.label || value.value || value; }));
},
position: {collision: "flip" }
});
return matcher.test(value) || matcher.test(normalize(value)); closeModal();
})); },
}, error: function(data) {
position: {collision: "flip" } err = {msg: "erreur serveur lors de la récupération des articles", ctx: 'get_products'};
}); if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
closeModal(); closeModal();
}, alert('Erreur lors de la récupération des articles, rechargez la page plus tard');
error: function(data) {
err = {msg: "erreur serveur lors de la récupération des articles", ctx: 'get_products'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
} }
report_JS_error(err, 'orders'); });
} else {
closeModal(); $('#not_connected_content').show();
alert('Erreur lors de la récupération des articles, rechargez la page plus tard'); }
}
});
}); });
...@@ -16,14 +16,20 @@ ...@@ -16,14 +16,20 @@
{% block content %} {% block content %}
<div class="page_body"> <div class="page_body">
<div id="select_order_content" class="page_content txtcenter"> <div id="select_order_content" class="page_content txtcenter">
<div class="login_area">
{% include "common/conn_admin.html" %}
</div>
<div id="new_order_area"> <div id="new_order_area">
<h2>Créer une nouvelle commande</h2> <h2>Créer une nouvelle commande</h2>
<form id="new_order_form"> <div class="txtcenter" id="not_connected_content" style="display:none;">
<p>Vous devez vous connecter avec un compte Odoo pour accéder au module d'aide à la commande.</p>
</div>
<form id="new_order_form" style="display:none;">
<input type="text" id="new_order_name" placeholder="Nom de la commande..."> <input type="text" id="new_order_name" placeholder="Nom de la commande...">
<button type="submit" class="btn btn--primary">C'est parti !</button> <button type="submit" class="btn btn--primary">C'est parti !</button>
</form> </form>
</div> </div>
<div id="existing_orders_area"> <div id="existing_orders_area" style="display:none;">
<h2>Ou, continuer une commande en cours de création</h2> <h2>Ou, continuer une commande en cours de création</h2>
<div id="existing_orders"></div> <div id="existing_orders"></div>
</div> </div>
...@@ -34,9 +40,11 @@ ...@@ -34,9 +40,11 @@
<button type="button" class="btn--danger" id="back_to_order_selection_from_main"> <button type="button" class="btn--danger" id="back_to_order_selection_from_main">
<i class="fas fa-arrow-left"></i>&nbsp; Retour <i class="fas fa-arrow-left"></i>&nbsp; Retour
</button> </button>
<button type="button" class='btn--primary' id="do_inventory" style="display:none;"> <div class="rights_buttons">
Faire un inventaire <button type="button" class='btn--primary' id="do_inventory" style="display:none;">
</button> Faire un inventaire
</button>
</div>
</div> </div>
<div class="header txtcenter"> <div class="header txtcenter">
......
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