File "listing_mois_new.php"
Full Path: /home/analogde/www/MassageProd/listing_mois_new.php
File size: 47.91 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 "<pre>";
//print_r($_SESSION);
//echo "</pre>";
//$_SESSION['table_gestion'] = "gestion_v3";
echo "---> " .$_SESSION['table_gestion'];
//echo " Improvement .....05" ."<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( $_SESSION['mode_debug'] == "yes" )
{
$debug = true; //$_SESSION['mode_debug'];
}
else
{
$debug = false;
}
//$debug = false; //$_SESSION['mode_debug'];
//echo " Mode : " .$debug;
if (!isset($_SESSION['nom']) && !isset($_SESSION['password']))
{
header("Location: login.php");
}
$mois = $_GET['mois'];
$utilisateur = $_SESSION['nom']; // .' ' .$_SESSION['prenom'];
$table = $_SESSION['table_gestion'];
//echo "Utilisateur " .$utilisateur;
//echo "<br>";
//$user = $_SESSION['nom'] .' ' .$_SESSION['prenom'] ;
//echo $user;
//echo "<br>";
echo '
<p id="demo">Click the button to delete my HTML content (innerHTML).</p>';
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']);
$champs = explode('&',$url);
if($debug)
{
echo $url;
echo "<pre>";
print_r($champs);
echo "</pre>";
echo "<br>";
}
for( $i=1; $i < count($champs)-2 ; $i++)
{
if($utilisateur == "admin")
{
// format
//DELPY+Patrice*05-01-2023*26-12-2022_11:09:32*4-5=Non encaissé
$tab = explode('*', $champs[$i]);
$client = str_replace('+', ' ', $tab[0]);
$jour = $tab[1];
$inscription = str_replace('_', ' ', $tab[2]);
if($debug)
{
echo " ---> " .$client ."<br>";
echo " ---> " .$jour ."<br>";
echo " ---> " .$inscription ."<br>";
echo " ---> " .$tab[3] ."<br>";
}
$tab02 = explode('=', $tab[3]);
//if( $tab02[1] == "Payé" || $tab02[1] == "Non encaissé")
//{
if($debug)
{
print_r($tab02);
echo " ---> " .$tab02[0] ."<br>";
}
$position = strpos($tab02[0], "-");
if ($position == true)
{
$tab_double = explode('-', $tab02[0]);
$seance1 = $tab_double[0];
$seance2 = $tab_double[1];
enregistre($client, $jour, $inscription , $seance1 , $tab02[1] );
enregistre($client, $jour, $inscription , $seance2 , $tab02[1] );
if($debug)
{
echo "Double ---> " .$seance1 ." & " .$seance2 ."<br>";
echo "Datas enregistrées";
echo '<br><br>';
}
}
else
{
$seance_unique = $tab02[0];
enregistre($client, $jour, $inscription , $seance_unique , $tab02[1] );
if($debug)
{
echo " Unique ---> " .$seance_unique ."<br>";
echo "Datas enregistrées";
echo '<br><br>';
}
}
//}
/*else
{
echo " Pas pris en compte car " .$tab02[1] ."<br>";
}*/
}
}
// https://www.oujood.com/how/systeme-paiement-PayPal.php
// https://contrib.spip.net/Transaction-creer-des-formulaires-avec-paiement-en
// MeyClub : solution de billetterie CSE
// https://www.paiementpro.net/api-java-script
// planificateur de rendez-vous
// https://phpsources.net/code/php/date-heure/1094_fractionner-un-creneau-horaire-entre-l-heure-de-debut-et-l-heure-de-fin
$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());
}
}
echo "Datas enregistrées";
echo '<br><br>';
*/
}
?>
<?php
function enregistre($client, $jour, $inscription , $seance , $statut)
{
$connexion = DB();
$table = $_SESSION['table_gestion'];
$sql = "UPDATE " .$table ." SET statut = '$statut' WHERE jour = '$jour' AND date_inscription = '$inscription' AND client = '$client' AND seance = '$seance' ";
if($debug)
{
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());
}
}
?>
<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_disabled {
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;
}
.checkout-button {
width: 130px;
height: 35px;
background: #333;
border: none;
vertical-align: top;
margin-left: 35px;
cursor: pointer;
color: #fff;
}
.checkout-button:disabled {
background: #999;
color: #555;
cursor: not-allowed;
}
.disabled {
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;
pointer-events: none;
.isDisabled {
color: currentColor;
cursor: not-allowed;
opacity: 0.5;
text-decoration: none;
}
<!-- pointer-events: none;
cursor: default;
text-decoration: none;
color: #000000; -->
}
<!--
.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>
<script>
function redirection()
{
//alert(" Redirection vers le site du CSE, ouverture d'une noubelle fenêtre de votre navigateur.");
alert(" Redirection " );
//window.open("https://www.cseonsemi.fr/com/page/574");
//document.getElementById('myImage').src='pouce_yes.png';
//document.getElementById('lui').src='pouce_yes.png';
}
function redirectionbis(val)
{
//var text = '--->' + ' ' + 'val';
alert("text");
}
function maFonction(val)
{
document.getElementById("demo").innerHTML = val;
//alert("Trace " + val );
//window.open("https://www.cseonsemi.fr/com/page/574");
//document.getElementById('lui').src='pouce_yes.png';
//document.getElementById(val).src='pouce_yes.png';
}
function info(text, ctr) {
const myArray = text.split("*");
document.getElementById("demo").innerHTML = text;
let val = myArray[0];
let client = myArray[1];
let jour = myArray[2];
let inscription = myArray[3];
let seance = myArray[4];
let tarif = myArray[5];
/*
let mess = 'Info ' +' ' +val +' ' +client +' ' +jour +' ' +inscription +' ' +horaire +' ' +tarif );
*/
//alert('Info = '+val +' '+client +jour +' '+inscription +horaire +' '+tarif);
//alert('Info = '+name +' '+ctr);
var xhr = getXhr();
xhr.onreadystatechange = function()
{
// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
if(xhr.readyState == 4 && xhr.status == 200)
{
retour = xhr.responseText;
alert(retour);
//location.reload();
}
}
xhr.open("POST","ajax_update_statut.php",true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
var the_data = 'val='+val+ '&client='+client+ '&jour='+jour+ '&inscription='+inscription + '&seance='+seance + '&tarif='+tarif ;
xhr.send(the_data);
}//function showMapsInfo
function getXhr()
{
var xhr = null;
if(window.XMLHttpRequest) // Firefox et autres
xhr = new XMLHttpRequest();
else if(window.ActiveXObject)
{ // Internet Explorer
try
{
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else
{
// XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
return xhr;
}
function change(num)
{
var xhr = getXhr();
xhr.onreadystatechange = function()
{
// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
if(xhr.readyState == 4 && xhr.status == 200)
{
retour = xhr.responseText;
//alert(retour);
location.reload();
}
}
xhr.open("POST","ajax_update_statut.php",true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
var year = num.value;
xhr.send("year="+year);
}
</script>
</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_v3 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 ";
// $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];
$arrayClient = getClient($annee,$mois,"courte",$debug);
$arrayObjReservation = creation($annee, $mois, $array_horaire_court, $arrayClient, $debug );
?>
<!-- -->
<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="2%">Redirection</th>
<!--
<th align="center" width="6%">Chéque</th>
<th align="center" width="6%">Banque</th>
-->
</tr>
<?php
$cpt = 1;
for ($i=0; $i < count($arrayObjReservation) ; $i++)
{
$jour = $arrayObjReservation[$i]->getJour();
$client = $arrayObjReservation[$i]->getClient();
$inscription = $arrayObjReservation[$i]->getInscription();
$formule = $arrayObjReservation[$i]->getFormule();
$horaire = $arrayObjReservation[$i]->getHoraire();
$seance = $arrayObjReservation[$i]->getSeance();
$tarif = $arrayObjReservation[$i]->getTarif();
$statut = $arrayObjReservation[$i]->getStatut();
if($debug)
{
echo $jour ."<br>";
echo $client ."<br>";
echo $inscription ."<br>";
echo $formule ."<br>";
echo $horaire ."<br>";
echo $seance ."<br>";
echo $tarif ."<br>";
echo $statut ."<br>";
echo "*************************************" ."<br>";
}
$client_format = str_replace(' ', '+', $client);
$inscription_format = str_replace(' ', '_', $inscription);
$tag = $client_format ."*" .$jour ."*" .$inscription_format ."*" .$seance;
if($utilisateur == "admin")
{
if ($i%2 == 1)
{
$propriete = "impair";
$prop = "#02E9FA";
}
else
{
$propriete = "impair";
$prop = "#0CC2F5";
}
echo '<tr>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$cpt .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$client .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$jour .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$inscription .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$formule .'</th>';
$id = $datas['id'];
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$horaire .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$tarif . '€' .'</th>';
$select_objet = 'select' .$id;
echo '<th align="center"' .'bgcolor=' .$prop .'>';
//echo '<select name=' .$select_objet .'>';
echo '<select name=' .$tag .'>';
//echo '<select disabled>';
//$_SESSION['nom'] .' ' .$_SESSION['prenom']
// https://www.geeksforgeeks.org/html-select-disabled-attribute/
//if($datas['statut'] == "Payé")
if( $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é")
if( $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" />-->
<!--
OKKKKK
<a href="gatewayCB.php" class="button"><img src="euro.png" width="32" height="32" title= "Réglement CB"></a>
-->
<!--
<a href="gatewayCB.php?client=lulu" class="button"><img src="euro.png" width="32" height="32" title= "Réglement CB"></a>
-->
<?php
$double = explode('-', $horaire);
//echo "<a href=\"gatewayCB.php?client=$client&jour=$jour&horaire=$horaire&tarif=$tarif\" class=\"button\" \"> <img src=\"euro.png\" width=\"32\" height=\"32\" title= \"Réglement CB\"> </a>";
//<a href="javascript:toto()">cliquez ici</a>
// redirection
//echo "<a href=\"https://www.cseonsemi.fr/com/page/574\" class=\"button\" \"> <img src=\"euro.png\" width=\"32\" height=\"32\" title= \"Réglement CB\"> </a>";
echo "<a href=\"javascript:redirection()\" class=\"button\" \"> <img src=\"euro.png\" width=\"32\" height=\"32\" title= \"Réglement CB\"> </a>";
?>
<!--
<a href="gatewayCB.php?client="<?php $client ?>"&jour="<?php $jour ?>" class="button"><img src="euro.png" width="32" height="32" title= "Réglement CB"></a>
-->
<?php
//echo "<a href=\"gatewayCB.php/?client=$client&jour=$jour\"></a>";
?>
<!-- <input type="text" name="<?php echo "toto"; ?>" value="plouf"> -->
</th>
<?php
//https://stackoverflow.com/questions/15757750/how-can-i-call-php-functions-by-javascript
echo '<th align="center"' .'bgcolor=' .$prop .'>';
echo '<img src="pouce_no.png" id="myImage" width="32" height="32" ></th>';
echo '</tr>';
$cpt++;
} // administrateur
else
{
if ($i%2 == 1)
{
$propriete = "impair";
$prop = "#02E9FA";
}
else
{
$propriete = "impair";
$prop = "#0CC2F5";
}
$user = $_SESSION['nom'] .' ' .$_SESSION['prenom'] ;
// edition possible
if($client == $user)
{
$val = $cpt; // ."*";
}
else
{
$val = $cpt; // ."0";
}
echo '<tr>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$val .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$client .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$jour .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$inscription .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$formule .'</th>';
//$id = $datas['id'];
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$horaire .'</th>';
echo '<th align="center"' .'bgcolor=' .$prop .'>' .$tarif . '€' .'</th>';
$select_objet = 'select' .$id;
echo '<th align="center"' .'bgcolor=' .$prop .'>';
//echo '<select name=' .$select_objet .'>';
/*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>';
$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 .'>';
//$client
if( $client == $user )
{
echo '<select name=' .$tag .'>';
}
else
{
//echo '<select disabled>';
//echo '<select name=' .$tag .' disabled title="Reservé à l\'administrateur">';
echo '<select name=' .$tag .' disabled title="Non disponible">';
}
//if($datas['statut'] == "Payé")
if( $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é")
if( $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; ?>">
<!--<button onclick="window.location.href='https://w3docs.com';"> -->
<!-- <input type="button" onclick="window.location.href='https://www.w3docs.com';" value="w3docs" />-->
<?php
// ghcgthcg
if( $client == $user )
{
$a = "moi ";
$b = "aqw ";
//$val = "un de jhjk gf";
//echo $val;
$element = $val;
//enregistre($client, $jour, $inscription , $seance1 , $tab02[1] );
//enregistre($client, $jour, $inscription , $seance2 , $tab02[1] );
$element = "aaa";
//echo '<a href=javascript:void(0); onclick=maFonction(' ."4" .')>Lien</a>';
$maps_name = "blase";
$ctr = "lulu";
$element = $val ."*" .$client ."*" .$jour ."*" .$inscription ."*" .$horaire ."*" .$tarif;
//echo('<button type="button" id="button'.$ctr.'" onClick="info(\''.str_replace("'", "\\'", $maps_name).'\', \''.str_replace("'", "\\'", $ctr).'\');"><img src="euro.png"></button><br/>');
echo('<button type="button" id="button'.$ctr.'" onClick="info(\''.str_replace("'", "\\'", $element).'\', \''.str_replace("'", "\\'", $client).'\');"><img src="euro.png"></button><br/>');
?>
<!--
<a href="https://www.w3docs.com/" class="button"><img src="atm-card.png" width="32" height="32" title= "Réglement CB"></a>
-->
<!--
<a href="page?nom_var=val_var">bla, bla, bla</al>
-->
<!--
<a href=javascript:void(0); onclick=maFonction("<?php echo $element; ?>")>Lien</a>
-->
<!--
<a href="javascript:redirectionbis(bob")" class="button" > <img src="euro.png" width="32" height="32" title= "Réglement CB"> </a>
-->
<!--
echo "<a href=\"javascript:redirection()\" class=\"button\" \"> <img src=\"euro.png\" width=\"32\" height=\"32\" title= \"Réglement CB\"> </a>";
-->
</th>
<?php
echo '<th align="center"' .'bgcolor=' .$prop .'>';
echo '<img src="pouce_no.png" id=' .$element .' width="32" height="32" ></th>';
?>
<?php }
else
{
?>
<!--
<a href="https://www.w3docs.com/" class="disabled"><img src="atm-card.png" width="32" height="32" title= "Réglement CB"></a>
-->
<!--
<a href="#" class="button"><img src="atm-card.png" width="32" height="32" title= "Réglement CB"></a>
-->
<!--
<a href="javascript:void(0)" class="button_disabled"><img src="atm-card.png" width="32" height="32" title= "Non disponible"></a>
-->
<a href="javascript:void(0)" class="button "> <img src="euro.png" width="32" height="32" title= "Non acceesible !"> </a>
<?php
echo '<th align="center"' .'bgcolor=' .$prop .'>';
echo '<img src="pouce_no.png" id="aaa" width="32" height="32" ></th>';
?>
<!--javascript:void(0)-->
</th>
<?php
// ghcgthcg
// echo '<th align="center"' .'bgcolor=' .$prop .'>';
// echo '<img src="pouce_no.png" id="myImage" width="32" height="32" ></th>';
?>
<?php
}
?>
<?php
echo '</tr>';
$cpt++;
}
} // for
$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>
</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;
private $statut;
private $connexion;
// 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++;
}
/****/
public function SetStatut($val)
{
$this->statut = $val;
}
/*****/
public function getStatut()
{
return $this->statut;
}
/****/
/****/
public function SetConnexion($val)
{
$this->connexion = $val;
}
/*****/
public function getConnexion()
{
return $connexion->connexion;
}
/****/
}
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, $debug)
{
$connexion = DB();
$table = $_SESSION['table_reservation'];
$sql = "SELECT * FROM " .$table ." WHERE annee ='$annee' and mode = 'actif' and formule = '$formule' and mois = '$mois' ";
if($debug)
{
echo $sql;
echo "<br>";
echo "<br>";
}
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_record [] = $seance1;
}
if(strlen($seance2) != 0 && $seance2 != "unselect")
{
$tab_client_record [] = $seance2;
}
if(strlen($seance3) != 0 && $seance3 != "unselect")
{
$tab_client_record [] = $seance3;
}
if(strlen($seance4) != 0 && $seance4 != "unselect")
{
$tab_client_record [] = $seance4;
}
if(strlen($seance5) != 0 && $seance5 != "unselect")
{
$tab_client_record [] = $seance5;
}
if(strlen($seance6) != 0&& $seance6 != "unselect")
{
$tab_client_record [] = $seance6;
}
if(strlen($seance7) != 0 && $seance7 != "unselect")
{
$tab_client_record [] = $seance7;
}
if(strlen($seance8) != 0 && $seance8 != "unselect")
{
$tab_client_record [] = $seance8;
}
$record[$cpt] = $tab_client_record ;
$cpt++;
}
if($debug)
{
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];
}
}
if($debug)
{
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];
}
}
if($debug)
{
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;
if($debug)
{
echo "Supprime les doublons";
echo "<BR>";
echo "<pre>";
print_r($all_client_month_no_doublons);
echo "<BR>";
echo "<pre>";
echo "<BR>";
}
return $all_client_month_no_doublons;
}
?>
<?php
function creation($annee, $mois , $array_horaire_court , $arrayClient, $debug)
{
$connexion = DB();
$table = $_SESSION['table_reservation'];
$formule = "courte";
$actif = "actif";
$arrayObjReservation = array();
if($debug)
{
echo "/////////////////////////////////////////////////////////////////////" ."<br>";
echo "<=== SCAN DE TOUTES LES RESERVATIONS ====>" ."<br>";
echo "/////////////////////////////////////////////////////////////////////" ."<br>";
}
for( $i=0; $i < count($arrayClient) ; $i++)
{
if($debug)
{
echo "----> " .$arrayClient[$i] ."<br>";
}
$sql = "SELECT * FROM gestion_v3 WHERE annee ='$annee' AND mois = '$mois' and formule = '$formule' and mode = '$actif' and client ='$arrayClient[$i]' order by seance ASC ";
//$sql = "SELECT * FROM " .$_SESSION['table_gestion'] ." WHERE annee ='$annee' AND mois = '$mois' and formule = '$formule' and mode = '$actif' and client ='$arrayClient[$i]' order by seance ASC ";
if($debug)
{
echo $sql ."<br>";
}
mysqli_query($connexion, "SET NAMES 'utf8'");
$result = mysqli_query($connexion, $sql );
$nbre_enregistrements = mysqli_num_rows($result);
if($debug)
{
echo "----> " .$nbre_enregistrements;
echo "<br><br>";
}
$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'];
$statut = $datas['statut'];
$connexion = $datas['connexion'];
$tmp[] = $jour;
$tmp[] = $date_inscription;
$tmp[] = $client;
$tmp[] = $formule;
$tmp[] = $seance;
$timestamp = strtotime($jour);
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;
if($debug)
{
echo "Jour : " .$jour ." seance : " .$horaire .' ' .$seance ."<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;
$tmp[] = $statut;
//$tmp[] = $connexion;
$arrayDataClient[] = $tmp;
$arrayTsSceance[] = $ts_sceance;
}
if($debug)
{
echo "DATA Client " ."<br>";
print_r($arrayDataClient);
echo "Classement " ."<br>";
}
sort($arrayTsSceance);
if($debug)
{
for( $j=0; $j < count($arrayTsSceance) ; $j++)
{
echo date('d/m/Y H:i:s', $arrayTsSceance[$j]) ." " .$arrayTsSceance[$j] ."<br>";
}
}
$arrayOrderDataClient = array();
for( $j=0; $j < count($arrayTsSceance) ; $j++)
{
for( $k=0; $k < count($arrayDataClient) ; $k++)
{
if( $arrayTsSceance[$j] == $arrayDataClient[$k][7] )
{
$arrayOrderDataClient[] = $arrayDataClient[$k];
}
}
}
if($debug)
{
echo "blabla " ."<br>";
print_r($arrayOrderDataClient);
}
// re-affectation
unset($arrayDataClient);
$arrayDataClient = $arrayOrderDataClient;
if($debug)
{
echo "Timestamp sorted " ."<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( $j=0; $j <= count($arrayDataClient)-2 ; $j++) // Attention au débordement !!
{
$diffTS = $arrayDataClient[$j+1][7] - $arrayDataClient[$j][7];
if($debug)
{
echo "Compare : " .$arrayDataClient[$j][7] ." " .$arrayDataClient[$j+1][7] ."<br>";
echo "val " .$j ." " .$diffTS ."<br>";
}
if( $diffTS == $ecart_seance )
{
$ts = $arrayDataClient[$j][7];
$premiere = date('H:i', $ts);
$fin = $ts + 25 * 60 * 1;
$seconde = date('H:i', $fin);
if($debug)
{
echo "TS " .$j ." " .$ts ."<br>";
echo " 2 seances consécutives " ."<br>";
echo "Debut " .$premiere ." & puis " .$seconde ."<br>";
}
$jour = $arrayDataClient[$j][0];
$inscription = $arrayDataClient[$j][1];
$client = $arrayDataClient[$j][2];
$formule = $arrayDataClient[$j][3];
$seance = $arrayDataClient[$j][4];
$statut = $arrayDataClient[$j][8];
//$connexion = $arrayDataClient[$j][9];
$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);
$p1->setStatut($statut);
//$p1->setConnexion($connexion);
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[$j][2] = "none";
$arrayDataClient[$j+1][2] = "none";
}
}
if($debug)
{
echo "******************************************************************" ."<br>";
echo "DATA Client " ."<br>";
print_r($arrayDataClient);
echo "Nombre de reservation " ."<br>";
echo " ------> " .count($arrayObjReservation) ."<br>";
echo "Contenu de la reservation" ."<br>";
print_r($arrayObjReservation);
print_r($store);
echo "******************************************************************" ."<br>";
echo " SUPPRIMER LES DOUBLES RESERVATIONS " ."<br>";
}
$rebuild = array();
for( $j=0; $j < count($arrayDataClient) ; $j++)
{
if( $arrayDataClient[$j][2] != "none" )
{
$rebuild[] = $arrayDataClient[$j];
}
}
if( !empty($rebuild) )
{
if($debug)
{
print_r($rebuild);
}
for( $j=0; $j < count($rebuild) ; $j++)
{
$ts = $rebuild[$j][7];
$premiere = date('H:i', $ts);
if($debug)
{
echo " Seance unique " ."<br>";
echo "Debut " .$premiere ."<br>";
}
$jour = $arrayDataClient[$j][0];
$inscription = $arrayDataClient[$j][1];
$client = $arrayDataClient[$j][2];
$formule = $arrayDataClient[$j][3];
$seance = $arrayDataClient[$j][4];
$statut = $arrayDataClient[$j][8];
//$connexion = $arrayDataClient[$j][9];
$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);
$p1->setStatut($statut);
//$p1->setConnexion($connexion);
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");
}
}
if($debug)
{
print_r($arrayObjReservation);
print_r($store);
}
}
else
{
if($debug)
{
echo " PAS CRENEAUX UNIQUE" ."<br>";
}
}
if($debug)
{
echo " ----- SUIVANTE -----" ."<br>";
}
}
if($debug)
{
echo " BILAN " ."<br>";
print_r($arrayObjReservation);
}
return $arrayObjReservation;
}
?>
</body>
</html>