Commit 0166662c authored by Denis S. Valdenaire's avatar Denis S. Valdenaire

ajout des stats en home

parent d8780833
......@@ -46,13 +46,22 @@ class Member extends Record {
}
// SQL SELECT lud_members
$sql = "SELECT id, firstname, lastname, birth_date, address, po_town,
home_phone, work_phone, mobile_phone, fax_phone, comments, member_ref,
$sql = "SELECT m.id, firstname, lastname, birth_date, address, po_town,
home_phone, work_phone, mobile_phone, fax_phone, m.comments, member_ref,
email, newsletter, other_members, deposit, deposit_expiration_date,
DATEDIFF(deposit_expiration_date, curdate()) as remaining_deposit_days,
CONCAT(lastname, ' ', firstname) AS full_name, account_id
FROM ".Member::$table."
WHERE id = ".$id;
CONCAT(lastname, ' ', firstname) AS full_name, account_id,
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)
WHERE m.id = ".$id;
$GLOBALS["data"]->select($sql, $member, "Member");
return $member;
}
......
<?php
class Statistic extends Record {
public static $table = "lud_statistics";
public static function create_from_post() {
// SQL INSERT lud_statistics
$sql = "INSERT INTO ".Statistic::$table."
(stat_date, stat_time, num_adult, num_child, member_id)
VALUES
(curdate(), curtime(), ".
$GLOBALS["data"]->db_escape_string($_POST["num_adult"]).", ".
$GLOBALS["data"]->db_escape_string($_POST["num_child"]).", ".
$GLOBALS["data"]->db_escape_string($_POST["i"]).")";
return $GLOBALS["data"]->insert($sql);
}
}
......@@ -15,6 +15,24 @@ class MembersController extends AppController {
return $this->_list();
}
function _count() {
try {
$member = Member::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
if($member->id != 0) {
Statistic::create_from_post();
$member->fetch_subscriptions();
$member->fetch_loans();
$member->fetch_reservations();
$this->set("member", $member);
return "members/nutshell";
} else {
return "members/not_found"; // TODO
}
} catch(data_exception $e) {
return "data_exception";
}
}
function _create() {
// TODO : posted datas should be validated
// who is responsible for that ? i think
......
......@@ -19,10 +19,10 @@ $(document).ready(function () {
{
name: 'members',
display: 'full_name',
source: members,
source: members/*,
templates: {
header: '<h3 class="category-name">Adhérents</h3>'
}
}*/
});
$('#search-all .typeahead').typeahead({
......
......@@ -9,7 +9,7 @@
<h3>Prêts en cours</h3>
<p>
{% for key, val in loans %}
<a href="index.php?o=loans&a=edit&i={{ val.id }}">{{ val.game_name }}</a>,
<a href="index.php?o=games&a=edit&i={{ val.game_id }}">{{ val.game_name }}</a>,
retour le {{ val.end_date }}<br>
{% else %}
Aucun emprunt en cours.
......@@ -33,13 +33,74 @@
</div>
</div>
</div>
<div class="col-sm-4">
<!-- calendar -->
<div class="col-sm-4">
<div id="polyform" class="thumbnail form-inline">
<div class="caption" align="center">
<h3>Statistiques</h3>
<div class="form-group col-sm-12">
<input type="hidden" name="member_id" id="member_id" value="">
<div id="search-members" >
<input id="th_text" class="typeahead form-control col-sm-4" style="margin-left: 10px; font-size: 14px; height: 34px; width: 300px"
type="text" placeholder="Adhérent...">
</div>
</div>
<div class="form-group" style="margin-bottom: 15px">
<label class="control-label col-sm-3" for="num_adult">Adultes</label>
<select name="num_adult" id="num_adult" class="form-control col-sm-1">
{% for i in 1..10 %}
<option value="{{ i }}">{{ i }}</option>
{% endfor %}
</select>
<label class="control-label col-sm-3" for="num_child">Enfants</label>
<select name="num_child" id="num_child" class="form-control col-sm-1">
{% for i in 0..10 %}
<option value="{{ i }}">{{ i }}</option>
{% endfor %}
</select>
</div>
<div class="form-actions" align="center">
<button type="button" class="btn btn-primary btn-md" id="count_button" name="count_button">Enregistrer</button>
</div>
</div>
</div>
<div id="result_count" style="display: none">
</div>
<!-- calendar
<div id="main-calendar"></div>
-->
</div>
</div>
<script>
$(document).ready(function () {
$('#search-members .typeahead').bind('typeahead:selected', function(obj, datum, name) {
$('#member_id').val(datum.id);
});
$('#polyform').on('click', '#count_button', function(){
if($('#member_id').val() == '') {
alert('Vous devez saisir le nom d\'adhérent');
return false;
}
// gather the data
$.post('index.php', {
o: 'members', a: 'count',
i: $('#member_id').val(),
num_adult: $('#num_adult').val(),
num_child: $('#num_child').val()
})
.done(function(data) {
$('#polyform').hide();
$('#result_count').html(data).show();
});
return true;
});
$('#result_count').on('click', '#close_button', function(){
$('#th_text').val('');
$('#member_id').val('');
$('#polyform').show();
$('#result_count').hide();
return true;
});
/*
$("#main-calendar").zabuto_calendar({
language: "fr",
today: true,
......@@ -48,6 +109,7 @@ $(document).ready(function () {
modal : true
}
});
*/
});
</script>
{% endblock %}
<div class="panel panel-default">
<div class="panel-heading">
<h4><span class="glyphicon glyphicon-user" style="margin-right: 10px" ></span>
{{ member.lastname }} {{ member.firstname }}
{% if member.reservations %}
<span class="label label-info">Réservations en cours</span>
{% endif %}
</h4>
</div>
<div class="panel-body">
<p>
Adhésion :
{{ member.subscription_status }}
({{ member.subscription_text }})
</p>
<p>
Emprunts :
{{ member.loans_text }}
</p>
<p>
<div class="form-actions" align="center">
<button type="button" class="btn btn-primary btn-md" id="close_button" name="close_button">Suivant/Fermer</button>
</div>
</p>
</div>
</div>
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