Skip to content

Commit

Permalink
Mise en place d'un filtrage par jour de la semaine
Browse files Browse the repository at this point in the history
Mise en place d'un filtrage scanne "depuis"
  • Loading branch information
machine62 committed Aug 31, 2019
1 parent 2298801 commit ee351f2
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 7 deletions.
16 changes: 16 additions & 0 deletions functions/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ function roundtimestamp($value, $round = 900)
return $retour;
}

function weekdaylist()
{
$retour = array();
$retour[-1] = 'Auncun';

$retour[0] = 'Lundi';
$retour[1] = 'Mardi';
$retour[2] = 'Mercredi';
$retour[3] = 'Jeudi';
$retour[4] = 'Vendredi';
$retour[5] = 'Samedi';
$retour[6] = 'Dimanche';

return $retour;
}


function myFormatTime($timestamp)
{
Expand Down
31 changes: 26 additions & 5 deletions model/oversight.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,30 @@ function getCountALLInsert()



function getALLInsert($player_id)
function getALLInsert($player_id,$since, $weekday)
{
$player = "";
$player.= " WHERE `player_id` > 0 ";

if ($player_id!=0)
{
$player= " WHERE `player_id` =".$player_id;
$player.= " AND `player_id` =".$player_id;

}
$player.= " AND `datatime` > " .(int)(time() - $since * 24*60*60 );

if ($weekday!=-1)
{
$player.= " AND WEEKDAY(CAST(FROM_UNIXTIME(`datatime`) as date))= ".$weekday." ";


}

$query = "SELECT * FROM " . TABLE_OVERSIGHT . " ".$player;
$query = "SELECT * , WEEKDAY(CAST(FROM_UNIXTIME(`datatime`) as date)) as newdate FROM " . TABLE_OVERSIGHT . " ".$player;
return get_Insert($query);
}

function getMyInsert($player_id)
function getMyInsert($player_id,$since, $weekday)
{
global $user_data;
$user_id = $user_data["user_id"];
Expand All @@ -171,7 +182,16 @@ function getMyInsert($player_id)
{
$player .= " AND `player_id` =".$player_id;
}
$query = "SELECT * FROM " . TABLE_OVERSIGHT . " ".$player;
$player.= " AND `datatime` > " .(int)(time() - $since * 24*60*60 );
if ($weekday!=-1)
{
// $player.= " AND valeur_date = ".$weekday." ";
$player.= " AND WEEKDAY(CAST(FROM_UNIXTIME(`datatime`) as date))= ".$weekday." ";

}

$query = "SELECT * , WEEKDAY(CAST(FROM_UNIXTIME(`datatime`) as date)) as newdate FROM " . TABLE_OVERSIGHT . " ".$player;

return get_Insert($query);
}

Expand All @@ -184,6 +204,7 @@ function get_Insert($query)
$tRetour = array();

while ($tStatus = $db->sql_fetch_row($result)) {
;
$tRow = array();
$tRow["id"] = $tStatus["id"];
$tRow["coord"] = $tStatus["coord"];
Expand Down
9 changes: 7 additions & 2 deletions oversight.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,22 @@
case "analyse":
//datas communes
$data["players"] = getPlayer();
$data["daylist"] = weekdaylist();
//si filtre non défini
$data["nblastday"] = (isset($pub_nblastday)) ? (int)$pub_nblastday : 30 ; // par defaut 30 jour
$data["findday"] = (isset($pub_findday)) ? (int)$pub_findday : -1 ; // par defaut 30 jour

//-------Logique-----------
$data["menuactif"] = "analyse";
$data["player_id"] = (int)$pub_player_id;
$data["cssfile"] = FOLDER_CSS . "jscss.css";
if (isset($pub_all))
{
$data["insert"] = getALLInsert($data["player_id"]);
$data["insert"] = getALLInsert($data["player_id"],$data["nblastday"], $data["findday"] );
}
else
{
$data["insert"] = getMyInsert($data["player_id"]);
$data["insert"] = getMyInsert($data["player_id"],$data["nblastday"], $data["findday"] );
}
//-------------------------

Expand Down
34 changes: 34 additions & 0 deletions view/analyse.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,40 @@
<?php endif; ?>
</h2>

<table class="">
<form action="#" method="post">
<tr>
<td class="c">
Nombre de jour à afficher :
</td>
<th class="c">
<input type="text" value="<?php echo $data["nblastday"]?>" name="nblastday">
</th>
<th class="c" rowspan="2">
<input type="submit" value="Rechercher!">
</th>
</tr>
<tr>
<td class="c">
Chercher un jour en particulier :
</td>
<th class="c">
<select name="findday">
<?php foreach ($data["daylist"] as $index => $day ) : ?>
<option value="<?php echo $index ; ?>"
<?php if ($data["findday"]== $index) { echo " selected" ; }?>>
<?php echo $day ; ?>
</option>
<?php endforeach ; ?>
</select>
</th>
</tr>
</form>
</table>

<hr />


<table width="100%" class="oversight">
<?php foreach ($DisctinctDAte as $key => $value) : ?>
<?php echo getAnalyseHTMLTable($key, $tCoord, $tInsert); ?>
Expand Down

0 comments on commit ee351f2

Please sign in to comment.