Commit 7ba8f5d0 authored by Denis S. Valdenaire's avatar Denis S. Valdenaire

ajout de slider pour selectionner les jeux

parent 6e1d5b52
......@@ -71,7 +71,7 @@ class Game extends Record {
if(array_key_exists("filter", $_REQUEST) && $_REQUEST["filter"] == "available") {
$where_clause = "WHERE l.id IS NULL";
}
$sql = "SELECT g.id, g.name,
$sql = "SELECT g.id, g.name, g.age_min, g.age_max,
CONCAT (ec.label, ' - ', ec.name) AS label,
l.id as loan_status
FROM games g
......
......@@ -2,53 +2,53 @@
class Record {
public function create() {
$fields_sql = $datas_sql = "";
foreach(get_object_vars($this) as $var => $value) {
// check if there is a corresponding value in _REQUEST
// and the value is not empty AND is not an array
if(array_key_exists($var, $_REQUEST) && $_REQUEST[$var] != "" && !is_array($_REQUEST[$var])) {
if(strlen($var) > 5 && strrpos($var, "_date", -5)) { // search if the var is suffixed by date
$_REQUEST[$var] = date_format(date_create_from_format('d-m-Y', $_REQUEST[$var]),'m/d/Y');
}
$this->$var = $_REQUEST[$var];
if(strlen($var) > 5 && strrpos($var, "_date", -5)) {
$_REQUEST[$var] = date_format(date_create_from_format('m/d/Y', $_REQUEST[$var]),'Y-m-d');
}
$fields_sql .= " $var,";
$datas_sql .= " '".$GLOBALS["data"]->db_escape_string($_REQUEST[$var])."',";
}
}
// SQL INSERT record.table
$sql = " INSERT INTO ".$this->table." (".$fields_sql." created_at, updated_at)
VALUES (".$datas_sql." now(), now())";
return $this->id = $GLOBALS["data"]->insert($sql);
}
public function create() {
$fields_sql = $datas_sql = "";
foreach(get_object_vars($this) as $var => $value) {
// check if there is a corresponding value in _REQUEST
// and the value is not empty AND is not an array
if(array_key_exists($var, $_REQUEST) && $_REQUEST[$var] != "" && !is_array($_REQUEST[$var])) {
if(strlen($var) > 5 && strrpos($var, "_date", -5)) { // search if the var is suffixed by date
$_REQUEST[$var] = date_format(date_create_from_format('d-m-Y', $_REQUEST[$var]),'m/d/Y');
}
$this->$var = $_REQUEST[$var];
if(strlen($var) > 5 && strrpos($var, "_date", -5)) {
$_REQUEST[$var] = date_format(date_create_from_format('m/d/Y', $_REQUEST[$var]),'Y-m-d');
}
$fields_sql .= " $var,";
$datas_sql .= " '".$GLOBALS["data"]->db_escape_string($_REQUEST[$var])."',";
}
}
// SQL INSERT record.table
$sql = " INSERT INTO ".$this->table." (".$fields_sql." created_at, updated_at)
VALUES (".$datas_sql." now(), now())";
return $this->id = $GLOBALS["data"]->insert($sql);
}
public function update() {
$update_sql = "";
public function update() {
$update_sql = "";
foreach(get_object_vars($this) as $var => $value) {
// check if there is a corresponding value in _REQUEST
// and the value has really changed
if(!is_array($this->$var) && array_key_exists($var, $_REQUEST)) {
if(strlen($var) > 5 && strrpos($var, "_date", -5)) { // search if the var is suffixed by date
$_REQUEST[$var] = date_format(date_create_from_format('d-m-Y', $_REQUEST[$var]),'m/d/Y');
}
if($_REQUEST[$var] != $value) {
$this->$var = $_REQUEST[$var];
if(strlen($var) > 5 && strrpos($var, "_date", -5)) {
$_REQUEST[$var] = date_format(date_create_from_format('m/d/Y', $_REQUEST[$var]),'Y-m-d');
}
$update_sql .= " $var = '".$GLOBALS["data"]->db_escape_string($_REQUEST[$var])."',";
}
}
}
if($update_sql != "") {
// SQL UPDATE record.table
$sql = " UPDATE ".$this->table." SET ".$update_sql." updated_at = now()
WHERE id = ".$this->id;
return $GLOBALS["data"]->update($sql);
// check if there is a corresponding value in _REQUEST
// and the value has really changed
if(!is_array($this->$var) && array_key_exists($var, $_REQUEST)) {
if(strlen($var) > 5 && strrpos($var, "_date", -5)) { // search if the var is suffixed by date
$_REQUEST[$var] = date_format(date_create_from_format('d-m-Y', $_REQUEST[$var]),'m/d/Y');
}
if($_REQUEST[$var] != $value) {
$this->$var = $_REQUEST[$var];
if(strlen($var) > 5 && strrpos($var, "_date", -5)) {
$_REQUEST[$var] = date_format(date_create_from_format('m/d/Y', $_REQUEST[$var]),'Y-m-d');
}
$update_sql .= " $var = '".$GLOBALS["data"]->db_escape_string($_REQUEST[$var])."',";
}
}
}
if($update_sql != "") {
// SQL UPDATE record.table
$sql = " UPDATE ".$this->table." SET ".$update_sql." updated_at = now()
WHERE id = ".$this->id;
return $GLOBALS["data"]->update($sql);
}
}
}
}
/*! =======================================================
VERSION 5.3.7
========================================================= */
/*! =========================================================
* bootstrap-slider.js
*
* Maintainers:
* Kyle Kemp
* - Twitter: @seiyria
* - Github: seiyria
* Rohit Kalkur
* - Twitter: @Rovolutionary
* - Github: rovolution
*
* =========================================================
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================= */.slider{display:inline-block;vertical-align:middle;position:relative}.slider.slider-horizontal{width:210px;height:20px}.slider.slider-horizontal .slider-track{height:10px;width:100%;margin-top:-5px;top:50%;left:0}.slider.slider-horizontal .slider-selection,.slider.slider-horizontal .slider-track-low,.slider.slider-horizontal .slider-track-high{height:100%;top:0;bottom:0}.slider.slider-horizontal .slider-tick,.slider.slider-horizontal .slider-handle{margin-left:-10px;margin-top:-5px}.slider.slider-horizontal .slider-tick.triangle,.slider.slider-horizontal .slider-handle.triangle{border-width:0 10px 10px 10px;width:0;height:0;border-bottom-color:#0480be;margin-top:0}.slider.slider-horizontal .slider-tick-label-container{white-space:nowrap;margin-top:20px}.slider.slider-horizontal .slider-tick-label-container .slider-tick-label{padding-top:4px;display:inline-block;text-align:center}.slider.slider-vertical{height:210px;width:20px}.slider.slider-vertical .slider-track{width:10px;height:100%;margin-left:-5px;left:50%;top:0}.slider.slider-vertical .slider-selection{width:100%;left:0;top:0;bottom:0}.slider.slider-vertical .slider-track-low,.slider.slider-vertical .slider-track-high{width:100%;left:0;right:0}.slider.slider-vertical .slider-tick,.slider.slider-vertical .slider-handle{margin-left:-5px;margin-top:-10px}.slider.slider-vertical .slider-tick.triangle,.slider.slider-vertical .slider-handle.triangle{border-width:10px 0 10px 10px;width:1px;height:1px;border-left-color:#0480be;margin-left:0}.slider.slider-vertical .slider-tick-label-container{white-space:nowrap}.slider.slider-vertical .slider-tick-label-container .slider-tick-label{padding-left:4px}.slider.slider-disabled .slider-handle{background-image:-webkit-linear-gradient(top,#dfdfdf 0,#bebebe 100%);background-image:-o-linear-gradient(top,#dfdfdf 0,#bebebe 100%);background-image:linear-gradient(to bottom,#dfdfdf 0,#bebebe 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdfdfdf',endColorstr='#ffbebebe',GradientType=0)}.slider.slider-disabled .slider-track{background-image:-webkit-linear-gradient(top,#e5e5e5 0,#e9e9e9 100%);background-image:-o-linear-gradient(top,#e5e5e5 0,#e9e9e9 100%);background-image:linear-gradient(to bottom,#e5e5e5 0,#e9e9e9 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe5e5e5',endColorstr='#ffe9e9e9',GradientType=0);cursor:not-allowed}.slider input{display:none}.slider .tooltip.top{margin-top:-36px}.slider .tooltip-inner{white-space:nowrap}.slider .hide{display:none}.slider-track{position:absolute;cursor:pointer;background-image:-webkit-linear-gradient(top,#f5f5f5 0,#f9f9f9 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#f9f9f9 100%);background-image:linear-gradient(to bottom,#f5f5f5 0,#f9f9f9 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5',endColorstr='#fff9f9f9',GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);border-radius:4px}.slider-selection{position:absolute;background-image:-webkit-linear-gradient(top,#f9f9f9 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#f9f9f9 0,#f5f5f5 100%);background-image:linear-gradient(to bottom,#f9f9f9 0,#f5f5f5 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9f9f9',endColorstr='#fff5f5f5',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;border-radius:4px}.slider-selection.tick-slider-selection{background-image:-webkit-linear-gradient(top,#89cdef 0,#81bfde 100%);background-image:-o-linear-gradient(top,#89cdef 0,#81bfde 100%);background-image:linear-gradient(to bottom,#89cdef 0,#81bfde 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff89cdef',endColorstr='#ff81bfde',GradientType=0)}.slider-track-low,.slider-track-high{position:absolute;background:transparent;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;border-radius:4px}.slider-handle{position:absolute;width:20px;height:20px;background-color:#337ab7;background-image:-webkit-linear-gradient(top,#149bdf 0,#0480be 100%);background-image:-o-linear-gradient(top,#149bdf 0,#0480be 100%);background-image:linear-gradient(to bottom,#149bdf 0,#0480be 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf',endColorstr='#ff0480be',GradientType=0);filter:none;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);border:0 solid transparent}.slider-handle.round{border-radius:50%}.slider-handle.triangle{background:transparent none}.slider-handle.custom{background:transparent none}.slider-handle.custom::before{line-height:20px;font-size:20px;content:'\2605';color:#726204}.slider-tick{position:absolute;width:20px;height:20px;background-image:-webkit-linear-gradient(top,#f9f9f9 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#f9f9f9 0,#f5f5f5 100%);background-image:linear-gradient(to bottom,#f9f9f9 0,#f5f5f5 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9f9f9',endColorstr='#fff5f5f5',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;filter:none;opacity:.8;border:0 solid transparent}.slider-tick.round{border-radius:50%}.slider-tick.triangle{background:transparent none}.slider-tick.custom{background:transparent none}.slider-tick.custom::before{line-height:20px;font-size:20px;content:'\2605';color:#726204}.slider-tick.in-selection{background-image:-webkit-linear-gradient(top,#89cdef 0,#81bfde 100%);background-image:-o-linear-gradient(top,#89cdef 0,#81bfde 100%);background-image:linear-gradient(to bottom,#89cdef 0,#81bfde 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff89cdef',endColorstr='#ff81bfde',GradientType=0);opacity:1}
\ No newline at end of file
This diff is collapsed.
......@@ -11,6 +11,7 @@
<link rel="stylesheet" href="css/bootstrap-datetimepicker.css">
<link rel="stylesheet" href="css/bootstrap-switch.min.css">
<link rel="stylesheet" href="css/bootstrap-multiselect.css">
<link rel="stylesheet" href="css/bootstrap-slider.min.css">
<!-- link rel="stylesheet" href="css/datatables.min.css" -->
<link rel="stylesheet" href="css/styles.css">
<script src="js/jquery-2.1.4.min.js"></script>
......@@ -109,8 +110,8 @@ REQUEST :
<script src="js/moment-with-locales.min.js"></script>
<script src="js/bootstrap-datetimepicker.js"></script>
<script src="js/bootstrap-switch.min.js"></script>
<script src="js/bootstrap-multiselect.js"></script>
<script src="js/bootstrap-slider.min.js"></script>
{% if global['logged_user'].id %}
<script src="js/functions.js"></script>
{% endif %}
......
......@@ -16,13 +16,18 @@
</div>
<div class="panel-body">
Interval d'age
<b>3</b>
<input id="age_range" type="text" class="span2" value="" data-slider-min="3" data-slider-max="99" data-slider-step="5" data-slider-value="[3,20]"/>
<b>99</b>
<div class="col-sm-12" align="center">
<table id="list_jeu" style="display:none">
<table id="list_games" style="display:none">
<thead>
<tr>
<th>Nom</th>
<th>Age min.</th>
<th>Age max.</th>
<th>ESAR</th>
<th>Etat</th>
</tr>
......@@ -33,6 +38,8 @@
<td>
<a href="index.php?o=games&a=edit&i={{ val.id }}">{{ val.name }}</a>
</td>
<td>{{ val.age_min }}</td>
<td>{{ val.age_max }}</td>
<td>
{{ val.label }}
</td>
......@@ -54,7 +61,20 @@
</div>
<script>
$(document).ready(function() {
$('#list_jeu').DataTable({
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var min = parseInt( $('#age_range').getValue()[0], 10 );
var max = parseInt( $('#age_range').getValue()[1], 10 );
var min_age = parseInt( data[1] ) || 0; // use data for the age column
var max_age = parseInt( data[2] ) || 0; // use data for the age column
if ( max_age < max || min_age > min ) {
return true;
}
return false;
}
);
var table = $('#list_games').DataTable({
"autoWidth": false,
"fnDrawCallback": function() {
$(this).show();
......@@ -64,6 +84,11 @@ $(document).ready(function() {
$('#a').val('new');
defaultform.submit();
});
$("#age_range").slider({})
.on("change", function(obj) {
//console.log(obj);
table.draw();
});
});
/* 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