Commit e426d011 authored by Denis S. Valdenaire's avatar Denis S. Valdenaire

formulaire pour réservation ok, #38

parent 45514589
......@@ -22,11 +22,14 @@ class Game extends Record {
public static function fetch($id) {
// SQL SELECT games prets
$sql = "SELECT games.id, name, reference, maker, category, esar_category_id,
comments, maker_info, content_inventory, DATE_FORMAT(aquisition_date, '%m/%d/%Y') as aquisition_date,
comments, maker_info, content_inventory,
DATE_FORMAT(aquisition_date, '%m/%d/%Y') as aquisition_date,
price, players_min, players_max,
age_min, age_max, game_type, loans.id as loan_id, loans.end_date AS loan_end_date
age_min, age_max, game_type, loans.id as loan_id, loans.end_date AS loan_end_date,
r.id AS reservation_id
FROM games
LEFT OUTER JOIN loans ON (games.id = loans.game_id AND loans.is_back = 0)
LEFT OUTER JOIN reservations r ON (games.id = r.game_id)
WHERE games.id = ".$id;
$GLOBALS["data"]->select($sql, $game, "Game");
return $game;
......
......@@ -97,9 +97,21 @@ class GamesController extends AppController {
$game->fetch_loans();
$this->set("game", $game);
return "games/loans";
} else {
return "games/not_found";
}
return "games/not_found";
} catch (data_exception $e) {
return "data_exception";
}
}
function _reservations() {
try {
$game = Game::fetch($GLOBALS["data"]->db_escape_string($_REQUEST["i"]));
if($game->id != 0) {
$this->set("game", $game);
return "games/reservations";
}
return "games/not_found";
} catch (data_exception $e) {
return "data_exception";
}
......
......@@ -228,11 +228,6 @@ $(document).ready(function() {
// and if yes, ask for confirmation from the user.
window.location.href='index.php?o=games&a=list';
});
$('#reservation_button').click(function(){
$('#o').val('reservations');
$('#a').val('new');
document.defaultform.submit();
});
$("#editModal").on("show.bs.modal", function(e) {
var button = $(e.relatedTarget);
if(button.data('id') == 'loans') {
......
<div class="modal-content">
<div class="modal-header">
<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
</h4>
</div>
<div class="modal-body">
{% if game.reservation_id %}
Ce jeu est déjà réservé
{% else %}
<div class="form-group">
<label class="control-label col-sm-3" for="member_id">Adhérent</label>
<div class="col-sm-9">
<input type="hidden" name="member_id" id="member_id" value="">
<div id="search-members" >
<input class="typeahead form-control" style="font-size: 14px; height: 34px"
type="text" placeholder="Adhérent...">
</div>
</div>
</div>
<script>
$(document).ready(function () {
var members = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('full_name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: { url : 'api.php?o=members&a=name_list',
cache: false }
});
$('#search-members .typeahead').typeahead({
highlight: true
},
{
name: 'members',
display: 'full_name',
source: members
}).bind('typeahead:selected', function(obj, datum, name) {
$('#member_id').val(datum.id);
});
});
</script>
<div class="form-group">
<label class="control-label col-sm-3" for="reservation_date">Date</label>
<div class="col-sm-9">
<div class='input-group date' id='datetimepicker_res'>
<input type="text" id="reservation_date" name="reservation_date" class="form-control"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<script type="text/javascript">
$(document).ready(function () {
$(function () {
$('#datetimepicker_res').datetimepicker({
locale: 'fr',
format: 'DD-MM-YYYY',
defaultDate: new Date ()
})
.on('changeDate', function(ev){
$('#reservation_date') = ev.format();
});
});
});
</script>
</div>
</div>
{% endif %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</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