Commit 6b418e2a by Etienne Freiss

Merge branch 'evolution_bdm' of…

Merge branch 'evolution_bdm' of https://gl.cooperatic.fr/cooperatic-foodcoops/third-party into ticket_1682
parents 2bef274f fdf11094
/static/
/outils/static/
\ No newline at end of file
......@@ -41,7 +41,7 @@ module.exports = {
"block-scoped-var": "off",
"block-spacing": "warn",
"brace-style": "warn",
"callback-return": "warn",
"callback-return": "off",
"camelcase": "off",
"capitalized-comments": "off",
"class-methods-use-this": "error",
......
......@@ -2,6 +2,7 @@
MAG_NAME = 'Cleme'
OFFICE_NAME = ''
MAX_BEGIN_HOUR = '19:00'
COMPANY_CODE = 'lacagette'
COMPANY_NAME = 'La Cagette'
WELCOME_ENTRANCE_MSG = 'Bienvenue à La Cagette !'
WELCOME_MAIL_SUBJECT = 'Dernière étape de votre inscription à la Cagette.'
......
......@@ -6,6 +6,7 @@ OPEN_ON_SUNDAY = True
MAG_NAME = ''
OFFICE_NAME = ''
COMPANY_CODE = 'lgds'
COMPANY_NAME = 'Les Grains de Sel'
MAX_BEGIN_HOUR = '19:00'
WELCOME_ENTRANCE_MSG = 'Bienvenue aux Grains de Sel!'
......
"""Company specific data values."""
COMPANY_CODE = 'supercafoutch'
"""Odoo coop specific constants ."""
EMAIL_DOMAIN = 'supercafoutch.fr'
......
......@@ -244,7 +244,7 @@ def get_makeups_members(request):
return JsonResponse({ 'res' : res })
def update_members_makeups(request):
""" Décrémente les rattrapages des membres passés dans la requête """
""" Met à jour les rattrapages des membres passés dans la requête """
res = {}
is_connected_user = CagetteUser.are_credentials_ok(request)
if is_connected_user is True:
......
......@@ -617,11 +617,16 @@ class CagetteMember(models.Model):
@staticmethod
def get_state_fr(coop_state):
"""Return french version of given coop_state."""
company = getattr(settings, 'COMPANY_CODE', '')
if coop_state == 'alert':
fr_state = 'En alerte'
elif coop_state == 'delay':
fr_state = 'Délai accordé'
elif coop_state == 'suspended':
if company == 'lacagette':
fr_state = 'Rattrapage'
else:
fr_state = 'Suspendu(e)'
elif coop_state == 'not_concerned':
fr_state = 'Non concerné(e)'
......
......@@ -43,7 +43,7 @@ h1 .member_name {font-weight: bold;}
{border:1px solid #000; border-radius: 5px; padding:5px; margin-bottom:15px;background:#FFF;}
.members_list {list-style: none;}
.members_list li {display:block;margin-bottom:5px;}
.members_list.late li {color: #de9b00;}
.members_list.late li {background-color: #de9b00; color: white}
.members_list li.btn--inverse {background: #449d44 !important; cursor:not-allowed; color: #FFF; }
#service_entry_success {font-size: x-large;}
......
......@@ -70,10 +70,42 @@
}
.decrement_makeup {
padding: 0.4rem 1.25rem;
margin-left: 10px;
}
.decrement_makeup, .increment_makeup {
padding: 0.4rem 1.25rem;
}
.select_member_cb {
cursor: pointer;
}
/* Search membres area */
#add_members_area {
margin-top: 30px;
}
#add_members_form_area {
display:flex;
align-items: center;
}
#search_member_form {
margin-left: 10px;
}
.search_member_results_area {
margin-top: 15px;
display: flex;
align-items: center;
}
.search_member_results {
display: flex;
flex-wrap: wrap;
}
.btn_possible_member {
margin: 0 1rem;
}
\ No newline at end of file
......@@ -152,6 +152,8 @@ function _really_save_new_coop(email, fname, lname, cap, pm, cn, bc, msex) {
return console.log(err);
}
return null;
});
delete coop._rev;
}
......@@ -411,6 +413,8 @@ function get_latest_odoo_coop_bb() {
return latest_odoo_coop_bb;
}
return null;
}
function generate_email() {
......
......@@ -409,6 +409,7 @@ if (coop_is_connected()) {
$('.item').click(display_possible_actions);
// dispatch_coops_in_boxes();
return null;
});
console.log(problematic_members);
......
var makeups_members_table = null,
makeups_members = null,
members_search_results = [],
selected_rows = []; // Contain members id
function switch_active_tab() {
......@@ -102,7 +103,10 @@ function display_makeups_members() {
render: function (data, type, full) {
return `<b>${data}</b>
<button class="decrement_makeup btn--primary" id="decrement_member_${full.id}">
<i class="fas fa-arrow-down"></i>
<i class="fas fa-minus"></i>
</button>
<button class="increment_makeup btn--primary" id="increment_member_${full.id}">
<i class="fas fa-plus"></i>
</button>`;
}
}
......@@ -120,7 +124,35 @@ function display_makeups_members() {
]
],
iDisplayLength: -1,
language: {url : '/static/js/datatables/french.json'}
oLanguage: {
"sProcessing": "Traitement en cours...",
"sSearch": "Rechercher dans le tableau",
"sLengthMenu": "Afficher _MENU_ &eacute;l&eacute;ments",
"sInfo": "Affichage de l'&eacute;l&eacute;ment _START_ &agrave; _END_ sur _TOTAL_ &eacute;l&eacute;ments",
"sInfoEmpty": "Affichage de l'&eacute;l&eacute;ment 0 &agrave; 0 sur 0 &eacute;l&eacute;ment",
"sInfoFiltered": "(filtr&eacute; de _MAX_ &eacute;l&eacute;ments au total)",
"sInfoPostFix": "",
"sLoadingRecords": "Chargement en cours...",
"sZeroRecords": "Aucun &eacute;l&eacute;ment &agrave; afficher",
"sEmptyTable": "Aucune donn&eacute;e disponible dans le tableau",
"oPaginate": {
"sFirst": "Premier",
"sPrevious": "Pr&eacute;c&eacute;dent",
"sNext": "Suivant",
"sLast": "Dernier"
},
"oAria": {
"sSortAscending": ": activer pour trier la colonne par ordre croissant",
"sSortDescending": ": activer pour trier la colonne par ordre d&eacute;croissant"
},
"select": {
"rows": {
"_": "%d lignes séléctionnées",
"0": "Aucune ligne séléctionnée",
"1": "1 ligne séléctionnée"
}
}
}
});
$('#makeups_members_table').on('click', 'tbody td .decrement_makeup', function () {
......@@ -140,6 +172,23 @@ function display_makeups_members() {
);
});
$('#makeups_members_table').on('click', 'tbody td .increment_makeup', function () {
const button_id = $(this).prop('id')
.split('_');
const member_id = button_id[button_id.length - 1];
const member = makeups_members.find(m => m.id == member_id);
openModal(
`Ajouter un rattrapage à ${member.name} ?`,
() => {
increment_makeups([member_id]);
},
"Confirmer",
false
);
});
$('#makeups_members_table').on('click', 'tbody td .select_member_cb', function () {
$(this).closest('tr')
.toggleClass('selected');
......@@ -208,17 +257,128 @@ function decrement_makeups(member_ids) {
closeModal();
},
error: function(data) {
err = {msg: "erreur serveur pour décrémenter les rattrapages", ctx: 'load_makeups_members'};
err = {msg: "erreur serveur pour décrémenter les rattrapages", ctx: 'decrement_makeups'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'orders');
report_JS_error(err, 'members_admin');
closeModal();
alert('Erreur serveur lors de la récupération des membres avec rattrapage. Ré-essayez plus tard.');
alert('Erreur serveur pour décrémenter les rattrapages. Ré-essayez plus tard.');
}
});
}
/**
* Send request to update members nb of makeups to do
* @param {Array} member_ids
*/
function increment_makeups(member_ids) {
openModal();
data = [];
for (mid of member_ids) {
member_index = makeups_members.findIndex(m => m.id == mid);
makeups_members[member_index].makeups_to_do += 1;
data.push({
member_id: mid,
target_makeups_nb: makeups_members[member_index].makeups_to_do
});
}
$.ajax({
type: 'POST',
url: "/members/update_members_makeups",
data: JSON.stringify(data),
dataType:"json",
traditional: true,
contentType: "application/json; charset=utf-8",
success: function() {
selected_rows = [];
display_makeups_members();
closeModal();
},
error: function(data) {
err = {msg: "erreur serveur pour incrémenter les rattrapages", ctx: 'increment_makeups'};
if (typeof data.responseJSON != 'undefined' && typeof data.responseJSON.error != 'undefined') {
err.msg += ' : ' + data.responseJSON.error;
}
report_JS_error(err, 'members_admin');
closeModal();
alert('Erreur serveur pour incrémenter les rattrapages. Ré-essayez plus tard.');
}
});
}
/**
* Display the members from the search result
*/
function display_possible_members() {
$('.search_member_results_area').show();
$('.search_member_results').empty();
let no_result = true;
if (members_search_results.length > 0) {
for (member of members_search_results) {
// Don't display members already in the table
if (makeups_members.find(m => m.id == member.id) != null) {
continue;
}
$(".search_results_text").show();
no_result = false;
// Display results (possible members) as buttons
var member_button = '<button class="btn--success btn_possible_member" member_id="'
+ member.id + '">'
+ member.barcode_base + ' - ' + member.name
+ '</button>';
$('.search_member_results').append(member_button);
// Set action on member button click
$('.btn_possible_member').on('click', function() {
for (member of members_search_results) {
if (member.id == $(this).attr('member_id')) {
if (makeups_members === null) {
makeups_members = [];
}
makeups_members.unshift({
id: member.id,
name: member.name,
makeups_to_do: 0
});
openModal(
`Ajouter un rattrapage à ${member.name} ?`,
() => {
increment_makeups([member.id]);
members_search_results = [];
$('#search_member_input').val('');
$('.search_member_results_area').hide();
$('.search_member_results').empty();
},
"Confirmer",
false
);
break;
}
}
});
}
}
if (no_result === true) {
$(".search_results_text").hide();
$('.search_member_results').html(`<p>
<i>Aucun résultat ! Vérifiez votre recherche, ou si le.la membre n'est pas déjà dans le tableau...</i>
</p>`);
}
}
$(document).ready(function() {
if (coop_is_connected()) {
......@@ -231,4 +391,37 @@ $(document).ready(function() {
} else {
$(".page_content").hide();
}
// Set action to search for the member
$('#search_member_form').submit(function() {
let search_str = $('#search_member_input').val();
$.ajax({
url: '/members/search/' + search_str,
dataType : 'json',
success: function(data) {
members_search_results = [];
for (member of data.res) {
if (member.is_member || member.is_associated_people) {
members_search_results.push(member);
}
}
display_possible_members();
},
error: function() {
err = {
msg: "erreur serveur lors de la recherche de membres",
ctx: 'confirm_movement.search_members'
};
report_JS_error(err, 'stock');
$.notify("Erreur lors de la recherche de membre, il faut ré-essayer plus tard...", {
globalPosition:"top right",
className: "error"
});
}
});
});
});
......@@ -550,6 +550,8 @@ function open_coop_form(e) {
console.error(error);
report_JS_error(error, 'prepa-odoo');
}
return null;
}
function ask_for_deletion() {
......@@ -692,6 +694,8 @@ function retrieve_all_coops() {
return b.timestamp - a.timestamp;
});
dispatch_coops_in_boxes();
return null;
});
} catch (err) {
error = {msg: err.name + ' : ' + err.message, ctx: 'retrieve_all_coops'};
......
const possible_cooperative_state = {
suspended: "Suspendu.e",
exempted: "Exempté.e",
alert: "En alerte",
up_to_date: "À jour",
unsubscribed: "Désinscrit.e",
delay: "En délai"
};
/**
* Request a 6 month delay
*/
......
......@@ -95,8 +95,6 @@ function init_history() {
$("#history").empty()
.text("Aucun historique... pour l'instant !");
} else {
let viewportWidth = $(window).width();
history_table = $('#history_table').DataTable({
data: partner_history,
columns: [
......
......@@ -359,6 +359,8 @@ function init_shifts_exchange() {
});
} else if (partner_data.cooperative_state === 'suspended'
&& partner_data.date_delay_stop === 'False') {
$("#suspended_content .makeups_nb").text(partner_data.makeups_to_do);
$("#suspended_content").show();
$(".select_makeups").on('click', () => {
......
......@@ -10,6 +10,15 @@ var base_location = null,
var date_options = {weekday: "long", year: "numeric", month: "long", day: "numeric"};
var time_options = {hour: '2-digit', minute:'2-digit'};
const possible_cooperative_state = {
suspended: "Rattrapage",
exempted: "Exempté.e",
alert: "En alerte",
up_to_date: "À jour",
unsubscribed: "Désinscrit.e",
delay: "En délai"
};
/* - Data */
/**
......
......@@ -22,6 +22,10 @@
Used to draw weeks planning
- COMPANY_NAME = 'lgds'
Used for company spesific code
- COMPANY_NAME = 'Les Grains de Sel'
- ADMIN_IDS = [13]
......
......@@ -28,6 +28,7 @@
</section>
<div id="tab_makeups_content" class="tab_content">
<div id="table_top_area">
<h3>Liste des membres devant effectuer un rattrapage</h3>
<div class="table_grouped_action">
......@@ -39,6 +40,21 @@
<div class="table_area">
<table id="makeups_members_table" class="display" cellspacing="0" width="100%"></table>
</div>
<div id="add_members_area">
<div id="add_members_form_area">
<h4>Ou, ajouter un rattrapage à un.e membre</h4>
<form id="search_member_form" action="javascript:;" method="post">
<input type="text" id="search_member_input" value="" placeholder="Nom ou numéro du coop..." required>
<button type="submit" class="btn--primary" id="search_member_button">Recherche</button>
</form>
</div>
<div class="search_member_results_area" style="display:none;">
<div class="search_results_text">
<p><i>Choisissez parmi les membres trouvés :</i></p>
</div>
<div class="search_member_results"></div>
</div>
</div>
</div>
</div>
......
......@@ -12,7 +12,13 @@
</a>
</div>
<div id="suspended_content" class="shifts_exchange_page_content">
<h3>Je suis suspendu.e, je dois sélectionner mes rattrapages pour pouvoir refaire mes courses.</h3>
<h3>
J'ai <span class="makeups_nb"></span> rattrapages à effectuer, je dois les sélectionner pour pouvoir refaire mes courses.
J'ai 6 mois de délai pour les rattraper.
</h3>
<h3>
Si besoin, je peux contacter le Bureau des membres via la rubrique "J'ai une demande" pour expliquer ma situation.
</h3>
<button type="button" class="btn--danger select_makeups">
Je sélectionne mes rattrapages
</button>
......
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