Commit d0a2c6e6 authored by thejoelinux's avatar thejoelinux

transformation liste des membres en sapin de noël + bouton créer compte dans la fiche adhérent

parent 6df150c2
......@@ -236,7 +236,8 @@ class Member extends Record {
$members = array();
// SQL SELECT lud_members subscriptions
$sql = "SELECT m.id, m.lastname, m.firstname, m.po_town,
CONCAT(m.firstname, ' ', m.lastname) AS full_name,
CONCAT(m.firstname, ' ', m.lastname) AS full_name,
account_id,
s.id AS subscription_id, MAX(s.end_date) AS subscription_end_date,
CASE WHEN s.id IS NULL
THEN 'Non trouvée'
......@@ -245,9 +246,11 @@ class Member extends Record {
THEN 'Expirée'
ELSE 'Valide'
END
END AS subscription_status
END AS subscription_status,
COUNT(l.id) AS num_loans
FROM ".Member::$table." m
LEFT OUTER JOIN ".Subscription::$table." s ON (s.member_id = m.id)
LEFT OUTER JOIN ".Loan::$table." l ON (l.member_id = m.id AND l.is_back = 0)
GROUP BY m.id
ORDER BY m.lastname";
$GLOBALS["data"]->select($sql, $members, "Member");
......
{% if member.account_id == 0 %}
<button type="button" class="btn btn-danger btn-md account_create_button"
data-id="{{ member.id }}" style="float: right; margin-right:0.25em">
<i class="glyphicon glyphicon-plus"></i>
<span>Créer le compte !</span>
</button>&nbsp;
{% else %}
<span class="label label-info"
style="float: right; margin-right:0.25em; font-size: 150%;">Compte #{{ member.account_id }}</span>
{% endif %}
<script>
$(document).ready(function () {
$('.account_create_button').on('click', function(e) {
var button = $(e.currentTarget);
$.post('api.php', { o: 'members', a: 'create_account',
i: button.data('id')
})
.done(function(data) {
alert('Compte créé : #' + data.account_id);
window.location.href = 'index.php?o=members&a=' + $('#a').val() + '&i=' + $('#i').val();
})
.fail(function(data) {
alert('Erreur lors de la création du compte');
});
});
});
</script>
......@@ -5,14 +5,16 @@
{% block content %}
<div class="panel panel-default">
<div class="panel-heading">
<h4><span class="glyphicon glyphicon-user" style="margin-right: 10px" ></span>
<span style="font-size: 150%; font-weight: bold">
<span class="glyphicon glyphicon-user" style="margin-right: 10px" ></span>
{% if member.id %}
{{ member.lastname }} {{ member.firstname }}
{% if member.reservations %}
<span class="label label-info">Réservations en cours</span>
{% endif %}
{% else %} Nouvel adhérent {% endif %}
</h4>
</span>
{% include 'members/account_info.html' %}
</div>
<div class="panel-body">
......
......@@ -27,7 +27,7 @@
<tr>
<th>Nom</th>
<th>Ville</th>
<th>Adhésion</th>
<th>Adhésion / Prêts en cours / Compte</th>
</tr>
</thead>
<tbody>
......@@ -40,8 +40,21 @@
{{ val.po_town }}
</td>
<td>
<span style="margin:0.25em;" class="label
{% if val.subscription_status == 'Non trouvée' %}
label-warning
{% else %}
{% if val.subscription_status == 'Expirée' %} label-danger {% else %} label-primary {% endif %}
{% endif %}">
{{ val.subscription_status }}
{{ val.subscription_end_date }}
</span>
{% if val.num_loans %}
<span class="label label-default" style="margin:0.25em;">{{ val.num_loans }} prêt(s) en cours</span>
{% endif %}
{% if val.account_id %}
<span class="label label-info" style="margin:0.25em;">Compte #{{ val.account_id }}</span>
{% endif %}
</td>
</tr>
{% endfor %}
......
......@@ -14,16 +14,7 @@
<i class="glyphicon glyphicon-plus"></i>
<span>Nouvelle adhésion...</span>
</button>
{% if member.account_id == 0 %}
<button type="button" class="btn btn-danger btn-md account_create_button"
data-id="{{ member.id }}" style="float: right; margin-right:0.25em">
<i class="glyphicon glyphicon-plus"></i>
<span>Créer le compte !</span>
</button>&nbsp;
{% else %}
<span class="label label-info "
style="float: right; margin-right:0.25em; font-size: 150%;">Compte #{{ member.account_id }}</span>
{% endif %}
{% include 'members/account_info.html' %}
</div>
<div class="panel-body">
......@@ -120,19 +111,6 @@ $(document).ready(function () {
}).on("hidden.bs.modal", function(e) {
$(this).find(".modal-content").empty();
});
$('.account_create_button').on('click', function(e) {
var button = $(e.currentTarget);
$.post('api.php', { o: 'members', a: 'create_account',
i: button.data('id')
})
.done(function(data) {
alert('Compte créé : #' + data.account_id);
window.location.href = 'index.php?o=members&a=subscriptions&i=' + $('#i').val();
})
.fail(function(data) {
alert('Erreur lors de la création du compte');
});
});
$('#object_list').on('click', '.button_delete', function(e){
if(confirm('Êtes vous sur ?')) {
var button = $(e.currentTarget);
......
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