Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
Diabete
:
test_CB03.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php session_start (); include('database.php'); include('fonctions.php'); include('generation_timing.php'); error_reporting(0); DB_connexion(); $annee = 2022; $mois = "juin"; find($annee,$mois,"courte"); $record = array ( array("aaa","bbb"), array("BMW"), array("nnn","nnn","ppp"), array("un","deux","trois","trois" ), array("un","deux","trois","trois","quatre" ), array("un","deux","trois","trois","quatre", "lule" ), array("un","deux","trois","trois","quatre", "lule", "plouf" ), array("un","deux","trois","trois","quatre", "lule", "one", "two" ) ); $all_client_month = array(); /* concatenation de tous les clients qui ont fait une réservation dans le mois */ 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]; } } echo "<BR>"; echo "<pre>"; print_r($all_client_month); echo "<BR>"; echo "<pre>"; /* supprimer les doublons */ $all_client_month_no_doublons = array_unique($all_client_month); echo "<pre>"; print_r($all_client_month_no_doublons); echo "</pre>"; /* création des objets */ foreach ($all_client_month_no_doublons as $valeur) { $arrayObjClient[] = new Personne($valeur); } echo "<BR>"; echo "<pre>"; echo " ********* OBJECTS ***************"; echo "<BR>"; print_r($arrayObjClient); echo "</pre>"; echo " ************************"; echo "<BR>"; for( $k=0; $k < count($arrayObjClient) ; $k++) { echo $arrayObjClient[$k]->getNom() ."\n"; } $double = array(); for( $i=0; $i < count($record) ; $i++) { $arrayCurrentRecord = array(); $arrayCurrentRecord = $record[$i]; echo "<pre>"; print_r($arrayCurrentRecord); echo "</pre>"; $flag = false; // 0 1 2 3 < 4 for( $j=0; $j < count($arrayCurrentRecord) ; $j++) { if( count($arrayCurrentRecord) == 1 ) { echo(" ------------ " .$arrayCurrentRecord[$j] ."\n"); } if( $j <= count($arrayCurrentRecord) - 2 ) // 4 - 1 { // 0 1 // 1 2 // 2 3 //echo(" Compare " .$arrayCurrentRecord[$j] ." " .$arrayCurrentRecord[$j+1] ."\n"); $mess = " Compare " .$arrayCurrentRecord[$j] ." " .$arrayCurrentRecord[$j+1]; if($arrayCurrentRecord[$j] == $arrayCurrentRecord[$j+1]) { echo $mess ." --> Doublon " .$arrayCurrentRecord[$j] ."\n"; echo " Traitement " ."\n"; $flag = true; $double[] = $arrayCurrentRecord[$j]; for( $k=0; $k < count($arrayObjClient) ; $k++) { $mess = $arrayObjClient[$k]->getNom() ." ? " .$arrayCurrentRecord[$j]; if( $arrayObjClient[$k]->getNom() == $arrayCurrentRecord[$j] ) { echo $mess ." yes "; if( $arrayObjClient[$k]->getDoublePremiere() == 0) { $arrayObjClient[$k]->setDoublePremiere(1); echo " Premier \n"; } else //if( $arrayObjClient[$k]->getDoublePremiere() == 1) { $arrayObjClient[$k]->setDoubleAutre($arrayObjClient[$k]->getDoubleAutre() + 1); echo " Multiple \n"; //$arrayObjClient[$k]->incrementDoubleAutre(); } } else { echo $mess ."\n"; } } } else { echo $mess ."\n"; } } } if( $flag == false) { $double[] = "none"; } echo("-----------------------" . "\n"); } echo "<BR>"; echo "<pre>"; echo " ********* DOUBLE ***************"; echo "<BR>"; print_r($double); echo "</pre>"; echo " ************************"; echo "<BR>"; /****/ for( $i=0; $i < count($double) ; $i++) { if( $double[$i] != "none" ) { $arrayCurrentRecord = array(); $arrayCurrentRecord = $record[$i]; $loop = true; while ($loop) { if (($pos = array_search($double[$i] , $arrayCurrentRecord)) !== false) { unset($arrayCurrentRecord[$pos]); } else { $loop = false; $rebuild[] = $arrayCurrentRecord; } } } else { $rebuild[] = $record[$i]; //$arrayCurrentRecord; //print_r($record[$i]); } } echo "<BR>"; echo "<pre>"; echo " ********* REBUILD ***************"; echo "<BR>"; print_r($rebuild); echo "</pre>"; echo " ************************"; echo "<BR>"; $tabIndexed = array(); // probléme : ne se comporte pas comme prévu ???? ////$tabIndexed = array_values($rebuild); for( $i=0; $i < count($rebuild) ; $i++) { $chaine = implode(" ", $rebuild[$i]); echo "String " .$chaine ."\n"; $pieces = explode(" ", $chaine); $tabIndexed[] = $pieces; } echo "<BR>"; echo "<pre>"; echo " ********* Re-index ***************"; echo "<BR>"; print_r($tabIndexed); echo "</pre>"; echo " ************************"; echo "<BR>"; /*for( $i=0; $i < count($rebuild) ; $i++) { $tmp = array(); for( $j=0; $j < count($rebuild[$i]) ; $j++) { $tmp[] = $rebuild[$i][$j]; } $tabIndexed[] = $tmp; } print_r($tabIndexed);*/ for( $i=0; $i < count($tabIndexed) ; $i++) { $arrayCurrentRecord = array(); $arrayCurrentRecord = $tabIndexed[$i]; //print_r($reIndex[$i]); for( $j=0; $j < count($arrayCurrentRecord) ; $j++) { echo $rebuild[$i][$j]; for( $k=0; $k < count($arrayObjClient) ; $k++) { if( $arrayObjClient[$k]->getNom() == $arrayCurrentRecord[$j] ) { if( $arrayObjClient[$k]->getSimplePremiere() == 0) { $arrayObjClient[$k]->setSimplePremiere(1); echo " Premier \n"; } else //if( $arrayObjClient[$k]->getDoublePremiere() == 1) { $arrayObjClient[$k]->setSimpleAutre($arrayObjClient[$k]->getSimpleAutre() + 1); echo " Multiple \n"; //$arrayObjClient[$k]->incrementDoubleAutre(); } } } } } echo "<BR>"; echo "<pre>"; echo " ********* OBJECTS ***************"; echo "<BR>"; print_r($arrayObjClient); echo "</pre>"; echo " ************************"; echo "<BR>"; echo " ------------------------------------ \n"; echo " ------------------------------------ \n"; echo " ------------------------------------ \n"; echo " ------------------------------------ \n"; /* $rebuild = array(); /* Traitement des reservations simple */ /* for( $i=0; $i < count($record) ; $i++) { $arrayCurrentRecord = array(); $arrayCurrentRecord = $record[$i]; $vals = array_count_values($arrayCurrentRecord); echo " vvvvvvvvvvvvvvvvvvvvvvvvvvvvv " ."\n"; echo 'No. of NON Duplicate Items: '.count($vals).'<br><br>'; print_r($vals); $tmp = array(); $flag = false; foreach($vals as $key => $value) { //echo "key=" . $key . ", Valeur=" . $value; //echo "<br>"; if( $value == 1 ) { //$rebuild[] = $key;aaaa $tmp[] = $key; $flag = true; echo " --> " .$key ."\n"; } if( $value == 11) { echo "JOB" ."\n"; $loop = true; while ($loop) { if (($pos = array_search($key, $arrayCurrentRecord)) !== false) { unset($arrayCurrentRecord[$pos]); } else { $loop = false; $rebuild[] = $arrayCurrentRecord; } } } } //if( $flag == true ) if( ! empty($tmp) ) { //$rebuild[] = $tmp; //echo "<BR>"; //print_r($tmp); //echo "</pre>"; //echo "\n"; } } echo "<BR>"; echo "<pre>"; echo " ********* OBJECTS ***************"; echo "<BR>"; print_r($rebuild); echo "</pre>"; echo " ************************"; echo "<BR>"; /*$tab = array('world','hello','good','hello'); $element = 'hello'; unset($tab[array_search($element, $tab)]); echo "<BR>"; print_r($tab); echo "</pre>";*/ // php remove 2 consecutive word in string // https://www.geeksforgeeks.org/delete-consecutive-words-sequence/ //if (in_array("100", $marks)) ?> <?php class Personne { private $nom; private $simple_premiere = 0; private $simple_autre = 0; private $double_premiere = 0; private $double_autre = 0; public function __construct($nom) { $this->nom = $nom; } 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++; } /****/ } ?> <?php function find($annee,$mois,$formule) { $connexion = DB(); //$table = "reservation_dev" .$annee; $table = "reservation2022_v3"; //$_SESSION['table_reservation']; $sql = "SELECT * FROM " .$table ." WHERE annee ='$annee' and mode = 'actif' and formule = '$formule' and mois = '$mois' "; echo $sql; 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); // scanner toutes les dates dans le mois echo "Total " .$nbre_enregistrements; echo "<br>"; $cpt = 0; $tab_client = array(); $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 "<BR>"; echo "<pre>"; print_r($record); echo "<BR>"; echo "<pre>"; } ?>