Commit 222fba83 authored by Denis S. Valdenaire's avatar Denis S. Valdenaire

avancée sur les reservations - on peut réserver depuis la fiche d'un jeu indisponible

parent e426d011
......@@ -52,6 +52,12 @@ class Game extends Record {
return sizeof($this->loans);
}
public function create_reservation() {
$reservation = new Reservation();
$reservation->create();
return $reservation->id;
}
public static function fetch_all(&$games) {
$games = array();
$where_clause = "";
......
<?php
class Reservation extends Record {
public $id, $game_id, $member_id;
public $id, $game_id, $member_id, $reservation_date;
public $created_at, $updated_at;
public $member_name;
......
......@@ -117,6 +117,21 @@ class GamesController extends AppController {
}
}
function _create_reservation() {
try {
$game = Game::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
if($game->id != 0) {
$game->create_reservation();
$this->set("game", $game);
$this->set_message("La réservation a été faite");
return "games/edit";
}
return "games/not_found";
} catch (data_exception $e) {
return "data_exception";
}
}
function _list() {
try {
Game::fetch_all($games);
......
......@@ -91,9 +91,11 @@
{% if global['debug'] %}
<pre>
REQUEST :
o : {{ request['o'] }}
a : {{ request['a'] }}
i : {{ request['i'] }}
{% for key, val in request %}
{% if val != "passwd" %}
{{ key }} : {{ val }}
{% endif %}
{% endfor %}
</pre>
{% endif %}
</footer>
......
......@@ -34,6 +34,8 @@
</div>
<div class="panel-body">
{% include 'ihm_messages.html' %}
<div class="form-group">
<label class="control-label col-sm-2" for="name">Nom</label>
<div class="col-sm-10">
......
......@@ -3,7 +3,7 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">
<span class="glyphicon glyphicon-list-alt" style="margin-right: 10px;" ></span>
{{ game.name }} - Réservations
{{ game.name }} - Réservation
</h4>
</div>
<div class="modal-body">
......@@ -66,12 +66,26 @@
</script>
</div>
</div>
{% endif %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
{% if game.reservation_id == 0 %}
<input type="hidden" name="game_id" id="game_id" value="{{ game.id }}">
<input type="button" class="btn btn-success" id="reservation_button" value="Enregistrer">
{% endif %}
</div>
</div>
<script>
// buttons events
$('#reservation_button').click(function(){
if(document.defaultform.member_id.value == 0) {
alert ("Vous n'avez pas saisi d'adhérent.");
return false;
}
$('#a').val('create_reservation');
document.defaultform.submit();
return true;
});
</script>
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