File "listing_mois_CB.php"
Full Path: /home/analogde/www/MassageProd/listing_mois_CB.php
File size: 40.23 KB
MIME-type: text/x-php
Charset: utf-8
<?php
session_start ();
include('database.php');
include('fonctions.php');
include('generation_timing.php');
error_reporting(0);
DB_connexion();
echo " Improvement ....." ."<br>";
$array_horaire_court = generation_timing($_SESSION['debut_horaire_courte'], $_SESSION['temps_sceance_courte'], $_SESSION['temps_sanitaire']);
$array_horaire_long = generation_timing($_SESSION['debut_horaire_longue'], $_SESSION['temps_sceance_longue'], $_SESSION['temps_sanitaire']);
header( 'content-type: text/html; charset=utf-8' );
//header('Content-Type: text/html; charset=iso-8859-1');
if (!isset($_SESSION['nom']) && !isset($_SESSION['password']))
{
header("Location: login.php");
}
$mois = $_GET['mois'];
//$annee = date('Y'); maintenant on peut choisir l'année
$utilisateur = $_SESSION['nom']; // .' ' .$_SESSION['prenom'];
$table = $_SESSION['table_gestion'];
if(isset($_GET['submit']))
{
$indice = $_GET['indice'];
$mois = $_GET['mois'];
//echo $_SERVER['QUERY_STRING'];
//echo htmlspecialchars($_SERVER['QUERY_STRING']);
//echo htmlentities($_SERVER['QUERY_STRING']);
//echo utf8_encode($_SERVER['QUERY_STRING']);
//echo mb_detect_encoding($_SERVER['QUERY_STRING']);
$url = urldecode($_SERVER['QUERY_STRING']);
//echo $url;
$champs = explode('&',$url);
$nb_elements = count($champs) - 3 ; // ne pas prendre en compte: mois, indice et submit
$j = 1;
for( $i=1; $i <= $indice ; $i++)
{
if($utilisateur == "admin")
{
$tab1 = explode('=', $champs[$j]);
$tab2 = explode('=', $champs[$j+1]);
$tab3 = explode('=', $champs[$j+2]);
$id = substr($tab1[0],6);
$j = $j + 3;
$champ1 = $tab1[1];
$champ2 = $tab2[1];
$champ3 = $tab3[1];
$sql = "UPDATE " .$table ." SET statut = '$champ1' , cheque = '$champ2', banque = '$champ3' WHERE id ='$id' ";
//echo $sql;
//echo '<br>';
}
else
{
$tab1 = explode('=', $champs[$j]);
$tab2 = explode('=', $champs[$j+1]);
$id = substr($tab1[0],6);
// ne pas prendre en compte le champ statut qui n'est pas modifiable par un utilisateur
$j = $j + 2;
$champ1 = $tab1[1];
$champ2 = $tab2[1];
$sql = "UPDATE " .$table ." SET cheque = '$champ1', banque = '$champ2' WHERE id ='$id' ";
//echo $sql;
//echo '<br>';
}
mysqli_query($connexion, "SET NAMES 'utf8'");
$result = mysqli_query($connexion, $sql );
if(!$result)
{
die('Impossible d\'exécuter la requête :' . mysql_error());
}
}
// enregistre le statut
/*for( $i=1; $i <= $indice ; $i++)
{ $id_select = "select" .$i;
$id_cheque = "cheque" .$i;
$id_banque = "banque" .$i;
$champ1 = $_GET[$id_select];
$champ2 = $_GET[$id_cheque];
$champ3 = $_GET[$id_banque];
$sql = "UPDATE " .$mois_actif ." SET statut = '$champ1' , cheque = '$champ2', banque = '$champ3' WHERE id ='$i' ";
echo $sql;
mysqli_query($connexion, "SET NAMES 'utf8'");
$result = mysqli_query($connexion, $sql );
if(!$result)
{ die('Impossible d\'exécuter la requête :' . mysql_error());
}
}*/
echo "Datas enregistrées";
echo '<br><br>';
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Espace réservation</title>
<style>
.button {
background-color: #1c87c9;
border: none;
color: white;
padding: 10px 12px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 4px 2px;
cursor: pointer;
}
<!--
.button {
background-color: #1c87c9;
border: none;
color: white;
padding: 20px 34px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 20px;
margin: 4px 2px;
cursor: pointer;
}
-->
</style>
</head>
<link rel="stylesheet" href="menu_style.css" type="text/css">
<div id='cssmenu'>
<ul>
<li><a href='home.php'><span>Home</span></a></li>
<li><a href='selection_planning_mois.php'><span>Planning</span></a></li>
<li class='active'><a href='selection_gestion_mois.php'><span>Gestion</span></a></li>
<li><a href='selection_statistique_mois.php'><span>Statistiques</span></a></li>
<?php
if($_SESSION['nom'] == "admin")
{
echo '<li><a href="deplacer_un_rendezvous_admin.php"><span>Déplacer</span></a></li>';
echo '<li><a href="configuration.php"><span>Configuration</span></a></li>';
}
else
{
echo '<li><a href="deplacer_un_rendezvous_user.php"><span>Déplacer</span></a></li>';
}
?>
<li><a href='change_password.php'><span>Changer password</span></a></li>
<li><a href='logout.php'><span>Déconnexion</span></a></li>
<li><a href='#'><span><?php echo $_SESSION['nom'] .' ' .$_SESSION['prenom'] .' connecté' ?></span></a></li>
<li><a href='#'><span><?php echo $_SESSION['year']; ?></span></a></li>
</ul>
</div>
<br>
<br>
<br>
<body>
<style>
td {
padding: 8px;
height: 20px;
vertical-align: middle;
}
.titre {
margin-left:50px;
margin-top:50px;
font-size: 26px;
}
//#matable th:hover{
// background-color:red;
}
</style>
<?php
/*$tmp_table = $_SESSION['table_reservation'] = "reservation" .$_SESSION['year'] ."_v3";
echo $tmp_table;
if(!(mysql_query("SELECT * FROM $tmp_table")))
{
$str = " La database " .$_SESSION['year'] ." n'existe pas encors !";
die($str);
} */
/*
$sql = "SELECT * FROM " .$table;
$result = mysqli_query($connexion, $sql );
if($result == null)
{
$table_nom = substr( $table, 0, -3 );
$str = " La table " .$table_nom ." n'exite pas configurée!.";
echo "<p><font size='5'>";
die($str);
echo "</p>";
echo "<br>";
}
*/
$table = $_SESSION['table_reservation']; /// = "reservation" .$_SESSION['year'] ."_v3";
// echo $table;
if(!(mysqli_query($connexion, "SELECT * FROM $table")))
{
//$str = 'Arnold a dit : "I\'ll be back"';
echo "<div class ='titre' id ='titre'>";
$str = " La database " .$_SESSION['year'] ." n'existe pas encore !";
die($str);
echo "</div>";
}
$annee = $_SESSION['year'];
$actif = "actif";
//$sql = "SELECT * FROM gestion WHERE annee ='$annee' AND mois = '$mois' and mode = '$actif' ";
///// $sql = "SELECT * FROM gestion WHERE annee ='$annee' AND mois = '$mois' and mode = '$actif' order by client ASC ";
$sql = "SELECT * FROM gestion_v4 WHERE annee ='$annee' AND mois = '$mois' and mode = '$actif' order by client ASC ";
// $sql = "SELECT * FROM " .$_SESSION['table_gestion'] ." WHERE annee = " .$annee ." AND mois = " .$mois ." and mode = " .$actif ." order by client ASC ";
// echo $sql;
// echo "<br><br>";
//$sql = "SELECT * FROM " .$table ." annee ='$annee' AND mois = '$mois' and mode = '$actif' order by jour ASC ";
//SELECT * FROM ta_table ORDER BY champ ASC //ORDER BY moyenne ASC
//echo $sql;
mysqli_query($connexion, "SET NAMES 'utf8'");
$result = mysqli_query($connexion, $sql );
$nbre_enregistrements = mysqli_num_rows($result);
//echo $nbre_enregistrements;
if($nbre_enregistrements != 0)
{
echo ucfirst($mois) ." " .$annee;
echo '<br><br>';
if(!$result)
{ die('Impossible d\'exécuter la requête :' . mysql_error());
}
//$tarif_CE = 5.0;
//$tarif_plein = 12.67;
$i = 1;
$tab_retour_courte = statistiques($annee,$mois,"courte");
$tab_compteur_courte = $tab_retour_courte[0];
$tab_client_courte = $tab_retour_courte[1];
//echo '<pre>';
//print_r($tab_retour_courte);
//echo '</pre>';
//echo '<pre>';
//print_r($tab_compteur);
//echo '<pre>';
//print_r($tab_retour);
//echo '<pre>';
//print_r($tab_client); E6BA39 f1f3f5 d5d5d5 bgcolor="#1ddfff"
$tab_retour_longue = statistiques($annee,$mois,"longue");
$tab_compteur_longue = $tab_retour_longue[0];
$tab_client_longue = $tab_retour_longue[1];
//echo '<pre>';
//print_r($tab_client_longue);
//echo '</pre>';
//find($annee,$mois,"courte");
$arrayObjClient = getClient($annee,$mois,"courte");
creation($annee, $mois, $array_horaire_court );
?>
<form action="#" name ="form_gestion" method="get">
<input type="hidden" name="mois" id="mois" value="<?php echo $mois; ?>">
<div id="list">
<table id="matable" align="left" border="0" cellpadding="5" cellspacing="1" width="100%">
<tbody>
<tr bgcolor="#f1f3f5">
<th class="center" width="1%">Id</th>
<th align="center" width="10%">Utilisateur</th>
<th align="center" width="6%">Jour</th>
<th align="center" width="4%">Inscription</th>
<th align="center" width="4%">Formule</th>
<th align="center" width="4%">Seance</th>
<!--<th align="center" width="8%">Compteur</th>-->
<th align="center" width="4%">Montant</th>
<th align="center" width="1%">Réglement</th>
<th align="center" width="2%">Etat</th>
<th align="center" width="2%">Payer</th>
<th align="center" width="6%">Chéque</th>
<th align="center" width="6%">Banque</th>
</tr>
<?php
$datas = mysqli_fetch_assoc ($result);
//echo '<pre>';
//print_r($datas);
$result = mysqli_query($connexion, $sql );
while ($datas = mysqli_fetch_assoc ($result))
{
if($utilisateur == "admin")
{
$formule = $datas['formule'];
if($formule == "courte")
{
//echo "Admin";
$key_courte = array_search($datas['client'], $tab_client_courte);
//echo $key;
// une seule réservation
if($tab_compteur_courte[$key_courte] == 0)
{ $montant = $_SESSION['tarifnormal'];
//echo "step1";
}
if($tab_compteur_courte[$key_courte] == 1)
{ $montant = $_SESSION['tarifCE'];
//echo "step2";
}
// plusieures réservation
if($tab_compteur_courte[$key_courte] > 1)
{ $tab_compteur_courte[$key_courte] = 0;
$montant = $_SESSION['tarifCE'];
//echo "step3";
}
}
if($formule == "longue")
{
//echo "Admin";
$key_longue = array_search($datas['client'], $tab_client_longue);
//echo $key;
// une seule réservation
if($tab_compteur_longue[$key_longue] == 0)
{ $montant = $_SESSION['tarif30'];
//echo "step1";
}
if($tab_compteur_longue[$key_longue] == 1)
{ $montant = $_SESSION['tarif30'];
//echo "step2";
}
// plusieures réservation
if($tab_compteur_longue[$key_longue] > 1)
{ $tab_compteur_longue[$key_longue] = 0;
$montant = $_SESSION['tarif30'];
//echo "step3";
}
}
if ($i%2 == 1)
{
$propriete = "impair";
$prop = "#02E9FA";
}
else
{
$propriete = "impair";
$prop = "#0CC2F5";
}
echo '<tr>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$i .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$datas['client'] .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$datas['jour'] .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$datas['date_inscription'] .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$datas['formule'] .'</th>';
if($formule == "courte")
{
switch ($datas['seance'])
{
case "1":
$val = $array_horaire_court[0]; //"12H20";
break;
case "2":
$val = $array_horaire_court[1]; //"12H40";
break;
case "3":
$val = $array_horaire_court[2]; //"13H00";
break;
case "4":
$val = $array_horaire_court[3]; //"13H20";
break;
case "5":
$val = $array_horaire_court[4]; //"13H40";
break;
case "6":
$val = $array_horaire_court[5]; //"14H00";
break;
case "7":
$val = $array_horaire_court[6]; //"14H20";
break;
case "8":
$val = $array_horaire_court[7]; //"14H40";
break;
}
}
if($formule == "longue")
{
switch ($datas['seance'])
{
case "1":
$val = $array_horaire_long[0]; //"12H00";
break;
case "2":
$val = $array_horaire_long[1]; //"12H30";
break;
case "3":
$val = $array_horaire_long[2]; //"13H00";
break;
case "4":
$val = $array_horaire_long[3]; //"13H30";
break;
case "5":
$val = $array_horaire_long[4]; //"14H00";
break;
case "6":
$val = $array_horaire_long[5]; //"14H30";
break;
case "7":
$val = $array_horaire_long[6]; //"15H00";
break;
case "8":
$val = $array_horaire_long[7]; //"15H30";
break;
}
}
$id = $datas['id'];
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$val .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$montant . '€' .'</th>';
$select_objet = 'select' .$id;
echo '<th align="center"' .'bgcolor=' .$prop .'>';
echo '<select name=' .$select_objet .'>';
if($datas['statut'] == "Payé")
{
echo ' <option value="Payé" selected>Payé</option>
<option value="Non encaissé">Non encaissé</option></th>';
//echo ' </select><img src="yes.png" alt="Smiley face"></td></td> ';
echo '<th align="center"' .'bgcolor=' .$prop .'>';
echo '<img src="yes.png" alt="Icone"></th>';
}
if($datas['statut'] == "Non encaissé")
{
echo ' <option value="Non encaissé" selected>Non encaissé</option>
<option value="Payé" >Payé</option></th>';
//echo ' </select><img src="no.png" alt="Smiley face"></td></td> ';
echo '<th align="center"' .'bgcolor=' .$prop .'>';
echo '<img src="no.png" alt="Icone"></th>';
}
?>
<th align="center" bgcolor="<?php echo $prop; ?>">
<!--<button onclick="window.location.href='https://w3docs.com';"> -->
<!-- <input type="button" onclick="window.location.href='https://www.w3docs.com';" value="w3docs" />-->
<a href="https://www.w3docs.com/" class="button">Clic</a>
<!-- <input type="text" name="<?php echo "toto"; ?>" value="plouf"> -->
</th>
<?php
//echo '<td><img src="yes.png" alt="Smiley face"></td>';
$cheque_objet = 'cheque' .$id;
?>
<th align="center" bgcolor="<?php echo $prop; ?>"><input type="text" name="<?php echo $cheque_objet; ?>" value="<?php echo $datas['cheque']; ?>"></th>
<?php
$banque_objet = 'banque' .$id;
?>
<th align="center" bgcolor="<?php echo $prop; ?>"><input type="text" name="<?php echo $banque_objet; ?>" value="<?php echo $datas['banque']; ?>"></th>
<?php
//echo '
//</select></td> ';
echo '</tr>';
$i = $i + 1;
}
else {
//echo "Utilisateur";
$formule = $datas['formule'];
if($formule == "courte")
{
$key_courte = array_search($datas['client'], $tab_client_courte);
//echo $key;
// une seule réservation
if($tab_compteur_courte[$key_courte] == 0)
{ $montant = $_SESSION['tarifnormal'];
//echo "step1";
}
if($tab_compteur_courte[$key_courte] == 1)
{ $montant = $_SESSION['tarifCE'];
//echo "step2";
}
// plusieures réservation
if($tab_compteur_courte[$key_courte] > 1)
{ $tab_compteur_courte[$key_courte] = 0;
$montant = $_SESSION['tarifCE'];
//echo "step3";
}
}
if($formule == "longue")
{
//echo "Admin";
$key_longue = array_search($datas['client'], $tab_client_longue);
//echo $key;
// une seule réservation
if($tab_compteur_longue[$key_longue] == 0)
{ $montant = $_SESSION['tarif30'];
//echo "step1";
}
if($tab_compteur_longue[$key_longue] == 1)
{ $montant = $_SESSION['tarif30'];
//echo "step2";
}
// plusieures réservation
if($tab_compteur_longue[$key_longue] > 1)
{ $tab_compteur_longue[$key_longue] = 0;
$montant = $_SESSION['tarif30'];
//echo "step3";
}
}
if ($i%2 == 1)
{
$propriete = "impair";
$prop = "#02E9FA";
}
else
{
$propriete = "impair";
$prop = "#0CC2F5";
}
echo '<tr>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$i .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$datas['client'] .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$datas['jour'] .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$datas['date_inscription'] .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$datas['formule'] .'</th>';
$formule = $datas['formule'];
if($formule == "courte")
{
switch ($datas['seance'])
{
case "1":
$val = $array_horaire_court[0]; //"12H20";
break;
case "2":
$val = $array_horaire_court[1]; //"12H40";
break;
case "3":
$val = $array_horaire_court[2]; //"13H00";
break;
case "4":
$val = $array_horaire_court[3]; //"13H20";
break;
case "5":
$val = $array_horaire_court[4]; //"13H40";
break;
case "6":
$val = $array_horaire_court[5]; //"14H00";
break;
case "7":
$val = $array_horaire_court[6]; //"14H20";
break;
case "8":
$val = $array_horaire_court[7]; //"14H40";
break;
}
}
if($formule == "longue")
{
switch ($datas['seance'])
{
case "1":
$val = $array_horaire_long[0]; //"12H00";
break;
case "2":
$val = $array_horaire_long[1]; //"12H30";
break;
case "3":
$val = $array_horaire_long[2]; //"13H00";
break;
case "4":
$val = $array_horaire_long[3]; //"13H30";
break;
case "5":
$val = $array_horaire_long[4]; //"14H00";
break;
case "6":
$val = $array_horaire_long[5]; //"14H30";
break;
case "7":
$val = $array_horaire_long[6]; //"15H00";
break;
case "8":
$val = $array_horaire_long[7]; //"15H30";
break;
}
}
$id = $datas['id'];
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$val .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$montant . '€' .'</th>';
$select_objet = 'select' .$id;
echo '<th align="center"' .'bgcolor=' .$prop .'>';
//echo '<select name=' .$select_objet .'>';
echo '<select name=' .$select_objet .' disabled title="Reservé à l\'administrateur">';
if($datas['statut'] == "Payé")
{
echo ' <option value="Payé" selected>Payé</option>
<option value="Non encaissé">Non encaissé</option></th>';
//echo ' </select><img src="yes.png" alt="Smiley face"></td></td> ';
echo '<th align="center"' .'bgcolor=' .$prop .'>';
echo '<img src="yes.png" alt="Icone"></th>';
}
if($datas['statut'] == "Non encaissé")
{
echo ' <option value="Non encaissé" selected>Non encaissé</option>
<option value="Payé" >Payé</option></th>';
//echo ' </select><img src="no.png" alt="Smiley face"></td></td> ';
echo '<th align="center"' .'bgcolor=' .$prop .'>';
echo '<img src="no.png" alt="Icone"></th>';
}
//echo '<td><img src="yes.png" alt="Smiley face"></td>';
?>
<th align="center" bgcolor="<?php echo $prop; ?>"><input type="text" name="<?php echo "toto"; ?>" value="plouf"></th>
<?php
$cheque_objet = 'cheque' .$id;
// echo '<th align="center"' .'bgcolor=' .$prop .'><input type="text" name=' .$cheque_objet .' value = ' .$datas['cheque'] .'></th>';
//
?>
<th align="center" bgcolor="<?php echo $prop; ?>"><input type="text" name="<?php echo $cheque_objet; ?>" value="<?php echo $datas['cheque']; ?>"></th>
<?php
$banque_objet = 'banque' .$id;
//echo '<th align="center"' .'bgcolor=' .$prop .'><input type="text" name=' .$banque_objet .' value = ' .$datas['banque'] .'></th>';
?>
<th align="center" bgcolor="<?php echo $prop; ?>"><input type="text" name="<?php echo $banque_objet; ?>" value="<?php echo $datas['banque']; ?>"></th>
<?php
//echo '
//</select></td> ';
echo '</tr>';
$i = $i + 1;
//echo ' <th align="center"><select name=' .$select_objet .' disabled title="Reservé à l\'administrateur">';
//}
}
} // while
$indice = $i - 1;
?>
<tr bgcolor="#f1f3f5">
<td colspan="16" class="center"> </td>
</tr>
<tr bgcolor="#f1f3f5">
<td colspan="16" class="center"><input type="submit" name="submit" value="Enregistrer" /></td>
</tr>
</tbody>
</table>
</div>
<input type="hidden" name="indice" id="indice" value="<?php echo $indice; ?>">
<br>
<br>
<br>
<?php
/*if($_SESSION['nom'] == "admin")
{
echo '<input type="submit" name="submit" value="Enregistrer" />';
}
else
{
echo '<input type="submit" name="submit" disabled value="Enregistrer" />';
}*/
//echo '<input type="submit" name="submit" value="Enregistrer" />';
?>
</form>
<?php
}
else
{
echo "Aucunes entrées en " .ucfirst($mois) ;
}
//echo '<br><br><br>';
//echo '<a href="selection_gestion_mois.php">Retour ... </a>';
?>
<?php
class Personne
{
private $jour;
private $inscription;
private $client;
private $formule;
private $seance;
private $type;
private $horaire;
//private $simple_debut;
//private $double_debut;
//private $double_fin;
private $tarif;
private $nom;
// default
private $simple_premiere = 0;
private $simple_autre = 0;
private $double_premiere = 0;
private $double_autre = 0;
public function __construct($client)
{
$this->client = $client;
}
/**/
public function setJour($val)
{
$this->jour = $val;
}
public function getJour()
{
return $this->jour;
}
/**/
public function setInscription($val)
{
$this->inscription = $val;
}
public function getInscription()
{
return $this->inscription;
}
/**/
public function setClient($val)
{
$this->client = $val;
}
public function getClient()
{
return $this->client;
}
/**/
public function setFormule($val)
{
$this->formule = $val;
}
public function getFormule()
{
return $this->formule;
}
/**/
public function setSeance($val)
{
$this->seance = $val;
}
public function getSeance()
{
return $this->seance;
}
/**/
/**/
public function setType($val)
{
$this->type = $val;
}
public function getType()
{
return $this->type;
}
/**/
public function setHoraire($val)
{
$this->horaire = $val;
}
public function getHoraire()
{
return $this->horaire;
}
/**/
/*public function setSimpleDebut($val)
{
$this->simple_debut = $val;
}
public function getSimpleDebut()
{
return $this->simple_debut;
}*/
/**/
/*public function setDoubleDebut($val)
{
$this->double_debut = $val;
}
public function getDoubleDebut()
{
return $this->double_debut;
}*/
/**/
/*public function setDoubleFin($val)
{
$this->double_fin = $val;
}
public function getDoubleFin()
{
return $this->double_fin;
}*/
/**/
public function setTarif($val)
{
$this->tarif = $val;
}
public function getTarif()
{
return $this->tarif;
}
/**/
public function setNom($val)
{
$this->nom = $val;
}
public function getNom()
{
return $this->nom;
}
/****/
public function setSimplePremiere($val)
{
$this->simple_premiere = $val;
}
public function getSimplePremiere()
{
return $this->simple_premiere;
}
/****/
public function setSimpleAutre($val)
{
$this->simple_autre = $val;
}
public function getSimpleAutre()
{
return $this->simple_autre;
}
/****/
public function incrementSimpleAutre()
{
$simple_autre++;
}
/****/
public function setDoublePremiere($val)
{
$this->double_premiere = $val;
}
public function getDoublePremiere()
{
return $this->double_premiere;
}
/*****/
public function setDoubleAutre($val)
{
$this->double_autre = $val;
}
public function getDoubleAutre()
{
return $this->double_autre;
}
/*****/
public function incrementDoubleAutre()
{
$double_autre++;
}
/****/
}
class tarification
{
// default
private $simple_premiere = 0;
private $simple_autre = 0;
private $double_premiere = 0;
private $double_autre = 0;
/*public function __construct($client)
{
$this->client = $client;
}*/
/****/
public function setSimplePremiere($val)
{
$this->simple_premiere = $val;
}
public function getSimplePremiere()
{
return $this->simple_premiere;
}
/****/
public function setSimpleAutre($val)
{
$this->simple_autre = $val;
}
public function getSimpleAutre()
{
return $this->simple_autre;
}
/****/
public function setDoublePremiere($val)
{
$this->double_premiere = $val;
}
public function getDoublePremiere()
{
return $this->double_premiere;
}
/*****/
public function setDoubleAutre($val)
{
$this->double_autre = $val;
}
public function getDoubleAutre()
{
return $this->double_autre;
}
}
?>
<?php
function getClient($annee,$mois,$formule)
{
$connexion = DB();
$table = $_SESSION['table_reservation'];
$sql = "SELECT * FROM " .$table ." WHERE annee ='$annee' and mode = 'actif' and formule = '$formule' and mois = '$mois' ";
echo $sql;
echo "<br>";
echo "<br>";
//$sql="SELECT * FROM " .$mois_actif;
mysqli_query($connexion, "SET NAMES 'utf8'");
$query = mysqli_query($connexion, $sql );
if(!$query)
{ die('Impossible d\'exécuter la requête :' . mysql_error());
}
$nbre_enregistrements = mysqli_num_rows($query);
//echo "Total " .$nbre_enregistrements;
//echo "<br>";
$cpt = 0;
$record = array();
while ($datas = mysqli_fetch_assoc ($query))
{
$tab_client_record = array();
$annee = $datas['annee'];
$mois = $datas['mois'];
$rendezvous = $datas['rendezvous'];
$jour = $datas['jour'];
$seance1 = $datas['seance1'];
$seance2 = $datas['seance2'];
$seance3 = $datas['seance3'];
$seance4 = $datas['seance4'];
$seance5 = $datas['seance5'];
$seance6 = $datas['seance6'];
$seance7 = $datas['seance7'];
$seance8 = $datas['seance8'];
if(strlen($seance1) != 0 && $seance1 != "unselect")
{ //$tab_client[] = $seance1;
$tab_client_record [] = $seance1;
}
if(strlen($seance2) != 0 && $seance2 != "unselect")
{ //$tab_client[] = $seance2;
$tab_client_record [] = $seance2;
}
if(strlen($seance3) != 0 && $seance3 != "unselect")
{ //$tab_client[] = $seance3;
$tab_client_record [] = $seance3;
}
if(strlen($seance4) != 0 && $seance4 != "unselect")
{ //$tab_client[] = $seance4;
$tab_client_record [] = $seance4;
}
if(strlen($seance5) != 0 && $seance5 != "unselect")
{ //$tab_client[] = $seance5;
$tab_client_record [] = $seance5;
}
if(strlen($seance6) != 0&& $seance6 != "unselect")
{ //$tab_client[] = $seance6;
$tab_client_record [] = $seance6;
}
if(strlen($seance7) != 0 && $seance7 != "unselect")
{ //$tab_client[] = $seance7;
$tab_client_record [] = $seance7;
}
if(strlen($seance8) != 0 && $seance8 != "unselect")
{ //$tab_client[] = $seance8;
$tab_client_record [] = $seance8;
}
$record[$cpt] = $tab_client_record ;
$cpt++;
}
echo "Extraction des dates ouvertes sur le mois";
echo "<BR>";
echo "<pre>";
print_r($record);
echo "<BR>";
echo "<pre>";
echo "<BR>";
/*for( $i=0; $i < count($record) ; $i++)
{
$all_client_day = array();
$all_client_day = $record[$i];
for( $j=0; $j < count($all_client_day) ; $j++)
{
$all_client_month[] = $all_client_day[$j];
}
}*/
for( $i=0; $i < count($record) ; $i++)
{
$all_client_day = array();
$all_client_day = $record[$i];
for( $j=0; $j < count($record[$i]) ; $j++)
{
$all_client_month[] = $record[$i][$j];
}
}
echo "Concatenation des clients";
echo "<BR>";
echo "<pre>";
print_r($all_client_month);
echo "<BR>";
echo "<pre>";
echo "<BR>";
$all_client_month_clean = array();
for( $i=0; $i < count($all_client_month) ; $i++)
{
if (strcmp($all_client_month[$i], "creneau fermer") !== 0)
{
$all_client_month_clean[] = $all_client_month[$i];
}
}
echo "Nettoyage creneau fermer";
echo "<BR>";
echo "<pre>";
print_r($all_client_month_clean);
echo "<BR>";
echo "<pre>";
echo "<BR>";
/* supprimer les doublons */
$tmp_no_doublons = array();
for( $i=0; $i < count($all_client_month_clean) ; $i++)
{
if( !in_array($all_client_month_clean[$i], $tmp_no_doublons) )
{
$tmp_no_doublons[] = $all_client_month_clean[$i];
}
}
//$all_client_month_no_doublons = array_unique($all_client_month_clean);
$all_client_month_no_doublons = $tmp_no_doublons;
echo "Supprime les doublons";
echo "<BR>";
echo "<pre>";
print_r($all_client_month_no_doublons);
echo "<BR>";
echo "<pre>";
echo "<BR>";
// remise en forme du tableau
/*$tmp_classement = array();
echo "NB " .count($all_client_month_no_doublons) ."<br>";
for( $i=0; $i < count($all_client_month_no_doublons) ; $i++)
{
echo "---> " .$i ."<br>";
$tmp_classement[] = $all_client_month_no_doublons[$i];
}
echo "Nouvelle indexation";
echo "<BR>";
echo "<pre>";
print_r($tmp_classement);
echo "<BR>";
echo "<pre>";
echo "<BR>";*/
$arrayObjClient = array();
foreach ($all_client_month_no_doublons as $client)
{
//echo ($valeur . "\n");
$arrayObjClient[] = new Personne($client);
}
echo "<BR>";
echo "<pre>";
echo " ********* OBJECTS ***************";
echo "<BR>";
print_r($arrayObjClient);
echo "</pre>";
echo " ************************";
echo "<BR>";
return $arrayObjClient;
// attention - tri par date doit être évalué
}
?>
<?php
function creation($annee, $mois , $array_horaire_court )
{
$connexion = DB();
$table = $_SESSION['table_reservation'];
$formule = "courte";
$actif = "actif";
//print_r($array_horaire_court);
// $formule
$sql = "SELECT * FROM gestion_v4 WHERE annee ='$annee' AND mois = '$mois' and formule = '$formule' and mode = '$actif' order by client ASC ";
//echo $sql;
//echo "<br>";
mysqli_query($connexion, "SET NAMES 'utf8'");
$result = mysqli_query($connexion, $sql );
$nbre_enregistrements = mysqli_num_rows($result);
//echo "----> " .$nbre_enregistrements;
//echo "<br><br>";
$result = mysqli_query($connexion, $sql );
$arrayDataClient = array();
$arrayTsSceance = array();
while ($datas = mysqli_fetch_assoc ($result))
{
$tmp = array();
$jour = $datas['jour'];
$date_inscription = $datas['date_inscription'];
$client = $datas['client'];
$formule = $datas['formule'];
$seance = $datas['seance'];
$tmp[] = $jour;
$tmp[] = $date_inscription;
$tmp[] = $client;
$tmp[] = $formule;
$tmp[] = $seance;
$timestamp = strtotime($jour);
//$hour = substr($array_horaire_court[$seance], 0, 2);;
//$min = substr($array_horaire_court[$seance], -2);
//$ts_hour = $hour * 3600 ;
//$ts_min = $min * 60;
//$ts_sceance = $timestamp + $ts_hour + $ts_min;
//$horaire = $timestamp + $hour * 3600 + $min * 60;
switch ($datas['seance'])
{
case "1":
$horaire = $array_horaire_court[0];
break;
case "2":
$horaire = $array_horaire_court[1];
break;
case "3":
$horaire = $array_horaire_court[2];
break;
case "4":
$horaire = $array_horaire_court[3];
break;
case "5":
$horaire = $array_horaire_court[4];
break;
case "6":
$horaire = $array_horaire_court[5];
break;
case "7":
$horaire = $array_horaire_court[6];
break;
case "8":
$horaire = $array_horaire_court[7];
break;
}
$hour = substr($horaire, 0, 2);;
$min = substr($horaire, -2);
$ts_hour = $hour * 3600 ;
$ts_min = $min * 60;
$ts_sceance = $timestamp + $ts_hour + $ts_min;
echo "Jour : " .$jour ." seance : " .$horaire ."<br>";
echo "Split horaire : " .$hour ." " .$min ."<br>";
echo " **** " .$ts_hour . " " .$ts_min ."<br>";
echo date('d/m/Y H:i:s', $ts_sceance) ."<br>";
echo "-------------------------"."<br>";
$tmp[] = $hour;
$tmp[] = $min;
$tmp[] = $ts_sceance;
$arrayDataClient[] = $tmp;
$arrayTsSceance[] = $ts_sceance;
}
echo "DATA Client " ."<br>";
print_r($arrayDataClient);
print_r($arrayTsSceance);
echo "<br>";
$ecart_seance = 25 * 60; // 1500
/************************/
$arrayObjReservation = array();
$store = new Tarification();
$simple_premiere = 0;
$simple_autre = 0;
$double_premiere = 0;
$double_autre = 0;
for( $i=0; $i <= count($arrayDataClient)-2 ; $i++)
{
$j = $i;
$j++;
echo "Compare : " .$arrayDataClient[$i][7] ." " .$arrayDataClient[$i+1][7] ."<br>";
$diffTS = $arrayDataClient[$i+1][7] - $arrayDataClient[$i][7];
echo "val " .$i ." " .$diffTS ."<br>";
if( $diffTS == $ecart_seance )
{
$ts = $arrayDataClient[$i][7];
echo "TS " .$i ." " .$ts ."<br>";
$premiere = date('H:i', $ts);
$fin = $ts + 25 * 60 * 1;
$seconde = date('H:i', $fin);
echo " 2 seances consécutives " ."<br>";
echo "Debut " .$premiere ." & puis " .$seconde ."<br>";
$jour = $arrayDataClient[$i][0];
$inscription = $arrayDataClient[$i][1];
$client = $arrayDataClient[$i][2];
$formule = $arrayDataClient[$i][3];
$seance = $arrayDataClient[$i][4];
$type = "double";
$p1 = new Personne($client);
$arrayObjReservation[] = $p1;
$p1->setJour($jour);
$p1->setInscription($inscription);
$p1->setNom($client);
$p1->setFormule($formule);
$seance2 = $seance + 1;
$p1->setSeance($seance."-".$seance2);
//$p1->setDoubleDebut($double_debut);
//$p1->setDoubleFin($double_fin);
$p1->setHoraire($premiere."-".$seconde);
$p1->setType($type);
if( $double_premiere == 0 )
{
$double_premiere++;
$p1->setTarif("24");
$p1->setDoublePremiere($p1->getDoublePremiere()+1);
}
else
{
$double_autre++ ;
$p1->setTarif("32");
$p1->setDoubleAutre($p1->getDoubleAutre()+1);
}
if( $store->getDoublePremiere() == 0)
{
$store->setDoublePremiere($store->getDoublePremiere()+1);
//$store->setTarif("32");
}
else
{
$store->setDoubleAutre($store->getDoubleAutre()+1);
//$store->setTarif("24");
}
// préparation pour le bypass des doubles créneaux
$arrayDataClient[$i][2] = "none";
$arrayDataClient[$i+1][2] = "none";
}
}
echo "******************************************************************" ."<br>";
echo "DATA Client " ."<br>";
print_r($arrayDataClient);
echo " ------> " .count($arrayObjReservation) ."<br>";
print_r($arrayObjReservation);
print_r($store);
echo "******************************************************************" ."<br>";
echo " SUPPRIMER LES DOUBLES RESERVATIONS " ."<br>";
$rebuild = array();
for( $i=0; $i < count($arrayDataClient) ; $i++)
{
if( $arrayDataClient[$i][2] != "none" )
{
$rebuild[] = $arrayDataClient[$i];
}
}
print_r($rebuild);
for( $i=0; $i < count($rebuild) ; $i++)
{
$ts = $rebuild[$i][7];
$premiere = date('H:i', $ts);
echo " Seance unique " ."<br>";
echo "Debut " .$premiere ."<br>";
$jour = $arrayDataClient[$i][0];
$inscription = $arrayDataClient[$i][1];
$client = $arrayDataClient[$i][2];
$formule = $arrayDataClient[$i][3];
$seance = $arrayDataClient[$i][4];
$type = "simple";
$p1 = new Personne($client);
$arrayObjReservation[] = $p1;
$p1->setJour($jour);
$p1->setInscription($inscription);
$p1->setNom($client);
$p1->setFormule($formule);
$p1->setSeance($seance);
//$p1->setDoubleStart($double_debut);
//$p1->setDoubleFin($double_fin);
//$p1->setSimpleDebut($double_fin);
$p1->setHoraire($premiere);
$p1->setType($type);
if( $simple_premiere == 0 )
{
$simple_premiere++;
$p1->setTarif("8");
$p1->setSimplePremiere($p1->getSimplePremiere()+1);
}
else
{
$simple_autre++ ;
$p1->setTarif("16");
$p1->setSimpleAutre($p1->getSimpleAutre()+1);
}
if( $store->getSimplePremiere() == 0)
{
$store->setSimplePremiere($store->getSimplePremiere()+1);
//$p1->setTarif("16");
}
else
{
$store->setSimpleAutre($store->getSimpleAutre()+1);
//$p1->setTarif("8");
}
}
print_r($arrayObjReservation);
print_r($store);
}
class tarification
{
// default
private $simple_premiere = 0;
private $simple_autre = 0;
private $double_premiere = 0;
private $double_autre = 0;
/*public function __construct($client)
{
$this->client = $client;
}*/
/****/
public function setSimplePremiere($val)
{
$this->simple_premiere = $val;
}
public function getSimplePremiere()
{
return $this->simple_premiere;
}
/****/
public function setSimpleAutre($val)
{
$this->simple_autre = $val;
}
public function getSimpleAutre()
{
return $this->simple_autre;
}
/****/
public function setDoublePremiere($val)
{
$this->double_premiere = $val;
}
public function getDoublePremiere()
{
return $this->double_premiere;
}
/*****/
public function setDoubleAutre($val)
{
$this->double_autre = $val;
}
public function getDoubleAutre()
{
return $this->double_autre;
}
}
?>
</body>
</html>