Commit f1d1d307 authored by thejoelinux's avatar thejoelinux

ajouter du bouton export liste des membres

parent e1f7614e
......@@ -26,7 +26,30 @@ class Member extends Record {
$this->subscriptions = array();
$this->loans = array();
$this->reservations = array();
}
}
public static function fetch_all_export(&$members) {
$members = array();
// SQL SELECT lud_members subscriptions
$sql = "SELECT m.id, m.lastname, m.firstname, m.email,
m.address, m.po_town,
MAX(s.end_date) AS subscription_end_date,
CASE WHEN s.id IS NULL
THEN 'Non trouvée'
ELSE
CASE WHEN MAX(s.end_date) < curdate()
THEN 'Expirée'
ELSE 'Valide'
END
END AS subscription_status
FROM ".Member::$table." m
LEFT OUTER JOIN ".Subscription::$table." s ON (s.member_id = m.id)
GROUP BY m.id
ORDER BY m.lastname";
$GLOBALS["data"]->select($sql, $members, "Member");
return sizeof($members);
}
public static function get_family_link_name($id = 0) {
$family_links = array(
......
......@@ -44,6 +44,32 @@ class MembersController extends AppController {
return Parent::_create("edit");
}
function _export() {
// TODO : export via a form to choose different criteria
// like: sorting, order, and so on
// return("members/export");
// for the moment, just export a list w some fields like
// first name last name email adress and expiration date for the
// subscription
try {
Member::fetch_all_export($members);
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=export.csv");
header("Pragma: no-cache");
header("Expires: 0");
while(list($key, $val) = each($members)) {
echo
'"'.$val->subscription_end_date.'";"'.$val->subscription_status.'";"'.
$val->firstname.'";"'.$val->lastname.'";"'.
$val->address.'";"'.$val->po_town.'";"'.$val->email.'"';
echo "\n";
}
exit(); // no further rendering needed
} catch(data_exception $e) {
return "data_exception";
}
}
function _edit() {
try {
$member = Member::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
......
{% extends "base.html" %}
{% block title %}Liste des adhérents{% endblock %}
{% block content %}
<div class="panel panel-default">
<div class="panel-heading">
<span style="font-size: 150%;" class="glyphicon glyphicon-user"></span>
<span style="font-size: 150%; font-weight: bold">
Export de la liste des adhérents
</div>
</div>
<div class="panel-body">
{% include 'ihm_messages.html' %}
<div class="col-sm-12" align="center">
Mettre en place les différents critéres pour l'export de la liste.›
</div>
</div>
</div>
<script>
$(document).ready(function() {
});
</script>
{% endblock %}
......@@ -6,6 +6,10 @@
<span style="font-size: 150%;" class="glyphicon glyphicon-user"></span>
<span style="font-size: 150%; font-weight: bold">
Adhérents
<span class="btn btn-success btn-md" id="export_button">
<i class="glyphicon glyphicon-th-list"></i>
<span>Exporter la liste des adhérents</span>
</span>
<span class="btn btn-success btn-md" style="float: right" id="new_button">
<i class="glyphicon glyphicon-plus"></i>
<span>Nouvel adhérent...</span>
......@@ -62,6 +66,10 @@ $(document).ready(function() {
$('#a').val('new');
defaultform.submit();
});
$('#export_button').click(function(){
$('#a').val('export');
defaultform.submit();
});
});
/* FIXME : translation of the table
see https://datatables.net/plug-ins/i18n/French
......
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