Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
Design
/
fileman
/
Fusion
/
Table
:
create_table02.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<!DOCTYPE html> <html> <style> <!-- table, th, td { border:1px solid black; } --> table { <!-- margin-left: auto; margin-right: auto; --> font-size: 20px; height: 100%; table-layout: fixed; } td { border: 1px solid black; text-align: center; padding: 1px; } tr:nth-child(even) { background-color: #00cf45; } </style> <body> </body> <html> <?php //ISO week number // https://jqueryui.com/datepicker/#date-range // https://makitweb.com/jquery-datepicker-to-filter-records-with-php-mysql/ // https://cdynamicprogramming.blogspot.com/p/blog-page_96.html include("calendrier_generation.php"); //30-12-2024 LUN //31-12-2024 MAR // ++++++++++++ a voir //https://phpsources.net/code/php/date-heure/929_numero-de-semaine-iso // https://blog.hubspot.com/website/php-date-time-functions $ts = strtotime("30-12-2024"); echo ">>>>> " .idate('W', $ts); echo "<br>"; echo ">>>>> " .strftime('%-V', $ts); echo "<br>"; $ddate = "2024-12-30"; $date = new DateTime($ddate); $week = $date->format("W"); echo "Week Number: $week"; echo "<br>"; echo ISOweek (2024, 12, 29); echo "<br>"; echo ISOweek (2024, 12, 30); echo "<br>"; echo ISOweek (2024, 12, 31); echo "<br>"; echo ISOweek (2024, 01, 01); echo "<br>"; $site = $_SERVER["SERVER_NAME"]; if( ($site == "localhost") || ($site == "127.0.0.1") ) { echo "Mode local"; echo "<br>"; $hostdb = "localhost"; $userdb = "root"; $passdb = ""; $namedb = "task_manager"; } else { echo "Hebergeur"; echo "<br>"; $hostdb = "analogdepat.mysql.db"; $userdb = "analogdepat"; $passdb = "Un92pac007"; $namedb = "analogdepat"; } // connexion $conn = new mysqli($hostdb, $userdb, $passdb, $namedb); // gestion erreur de connexion if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // définir la date de début et de fin $date_debut = "02-04-2024"; $date_fin = "18-12-2026"; echo "Plage " .$date_debut ." " .$date_fin; echo "<br>"; // $pieces = explode("-", $date_debut); $annee_debut = $pieces[2]; unset($pieces); $pieces = explode("-", $date_fin); $annee_fin = $pieces[2]; unset($pieces); echo " >>>> " .$annee_debut . " " .$annee_fin ; echo "<br>"; // etalement du planning $etalement = array(); if( $annee_debut == $annee_fin) { $etalement[] = $annee_debut; echo "Sur la meme annee"; echo "<br>"; } else { // 2025 - 2024 = 1 sur 2 ans // 2026 - 2024 = 2 sur 3 ans //$etalement = ($annee_fin - $annee_debut) + 1; for( $i=$annee_debut; $i <= $annee_fin ; $i++) { $etalement[] = $i; } echo "Sur plusieurs annees"; echo "<br>"; echo "<pre>"; print_r($etalement); echo "</pre>"; } /* $AlldatesRange = getBetweenDates($date_debut, $date_fin); echo "<pre>"; print_r($AlldatesRange); echo "</pre>"; */ echo "<br>"; echo "---------------------------------------------------"; echo "<br>"; $listing_jours = array(); $listing_jours = generation($etalement); echo "<pre>"; print_r($listing_jours); echo "</pre>"; echo "<br>"; echo "------------------ +++++ ---------------------------------"; echo "<br>"; $allDates = array(); $flag = false; for( $i=0; $i <= count($listing_jours) ; $i++) { //echo "<pre>"; //print_r($listing_jours[$i]); //echo "</pre>"; $annee = $listing_jours[$i]; for( $j=0; $j < count($annee) ; $j++) { /*echo "<pre>"; print_r($annee[$j]); echo "</pre>";*/ $mois = $annee[$j]; for( $k=0; $k < count($mois) ; $k++) { $string = $mois[$k]; $pieces = explode( "_", $string); echo " ++++ " .$pieces[0] . " " .$date_debut ." " .gettype($pieces[0]) . " " .gettype($date_debut); echo "<br>"; if( $pieces[0] == $date_debut ) { $flag = true; echo " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "; echo "<br>"; } if( $pieces[0] == $date_fin ) { $flag = false; $allDates[] = $mois[$k]; echo " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "; echo "<br>"; } if($flag) { $allDates[] = $mois[$k]; } } } } echo " &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& "; echo "<br>"; echo "<pre>"; print_r($allDates); echo "</pre>"; www($allDates); zzz($allDates); /* // nom de la table $table = "pipo"; $listing_jours = aaa(); echo " Toute l'annee "; echo "<br>"; echo "<pre>"; print_r($listing_jours); echo "</pre>"; // on prends le 3 mois echo " On prends le 3ieme mois "; echo "<br>"; echo "<pre>"; print_r($listing_jours[2]); echo "</pre>"; // $nb_elements = count($listing_jours[2]); $DateArray = array(); for( $i=0; $i < $nb_elements ; $i++) { $pieces = explode("_", $listing_jours[2][$i]); //echo " ++++ " .gettype($pieces[0]); //echo "<br>"; ////str_replace("-","_",$pieces[0]); //$DateArray[] = //$titi = str_replace("-","/", $listing_jours[0][$i]); //echo " >>>> " .$titi; //echo "<br>"; $DateArray[] = $pieces[2]; //$startdate = strtotime("03/11/2024"); //str_replace("-","", $listing_jours[0][$i] ); //$DateArray[] = strtotime($pieces[0]); } echo "Liste des dates" ."<br>"; echo "<pre>"; print_r($DateArray); echo "</pre>"; $RandomNumber = array(); for( $i=0; $i < $nb_elements ; $i++) { $RandomNumber[] = rand(10,250); } echo "Liste des valeurs (aléatoire)" ."<br>"; echo "<pre>"; print_r($RandomNumber); echo "</pre>"; $table = "chart_table"; //create_table($conn,$table); //insertion($conn,$table,$DateArray,$RandomNumber); function getBetweenDates($startDate, $endDate) { $rangArray = []; $startDate = strtotime($startDate); $endDate = strtotime($endDate); for ($currentDate = $startDate; $currentDate <= $endDate; $currentDate += (86400)) { $date = date('d-m-Y', $currentDate); $rangArray[] = $date; } return $rangArray; } */ /**********************************************************/ function ISOWeek($y , $m , $d){ $week=strftime("%W", mktime(0, 0, 0, $m, $d, $y)); $dow0101=getdate(mktime(0, 0, 0, 1, 1, $y)); if ($dow0101["wday"]>1 && $dow0101["wday"]<5) $week++; elseif ($week==0) $week=53; return(substr("00" . $week, -2)); } /**********************************************************/ function www($AllDates) { echo " <table border='2px' > <tr>"; for ($i = 0; $i < count($AllDates); $i++) { $pieces = explode("_", $AllDates[$i]); $indice = $i + 1; $jour = substr($pieces[1], 0, 3); $jour = ucfirst($jour); echo '<th>' .$pieces[0] ." " .$jour ." " .$indice .'</th>'; } echo '</tr>'; echo '<tr>'; for($row=0;$row<7;$row++) { echo '<tr>'; for($col=0;$col < count($AllDates);$col++) { $indice_row = $row+1; $indice_col = $col+1; $indice = "col".$indice_col ."-" ."row".$indice_row ; echo ' <td><input type="text" name = "<?php echo $indice; ?>" id="<?php echo $indice; ?>" onblur="blabla(this.id)" /></td> '; } echo '</tr>'; } echo '</table>'; } /**********************************************************/ function zzz($AllDates) { $array_val = array(" DATE ", " JOUR ", "SEMAINE" , "C"); echo " <table border='1px' > <tr style='color:white; background-color:black;' >"; for ($i = 0; $i < 4; $i++) { echo "<th> ".$array_val[$i] ."</th>"; } echo '</tr>'; echo '<tr>'; for($row=0;$row< count($AllDates) ;$row++) { echo '<tr>'; for($col=0;$col < 4 ;$col++) { $indice_row = $row+1; $indice_col = $col+1; $indice = "col".$indice_col ."-" ."row".$indice_row ; if( $col == 0 ) { $pieces = explode("_", $AllDates[$row]); echo "<td width='400px' >$pieces[0]</td>"; } else if( $col == 1) { $pieces = explode("_", $AllDates[$row]); $indice = $i + 1; $jour = substr($pieces[1], 0, 3); $jour = ucfirst($jour); echo "<td width='400px'>$jour</td>"; } else if( $col == 2) { $week = getWeek($pieces[0]); echo "<td width='400px'> $week</td>"; } else { echo ' <td width="400px" ><input type="text" name = "<?php echo $indice; ?>" id="<?php echo $indice; ?>" onblur="blabla(this.id)" /></td> '; } } echo '</tr>'; } echo '</table>'; } /**********************************************************/ function generation($tab_annee) { //echo "plouf...aaaa"; //print_r($tab_annee); //$liste_annee = array("2024"); $allDates = array(); for( $i=0; $i < count($tab_annee) ; $i++) { echo " <<<< >>>> " .$tab_annee[$i]; echo "<br>"; //blabla_calendrier($tab_annee[$i]); $listing_jours = calendrier($tab_annee[$i]); $allDates[] = $listing_jours; unset($listing_jours); } //echo "<pre>"; //print_r($allDates); //echo "</pre>"; return $allDates; } /**********************************************************/ function blabla_calendrier($aaaa) { echo "++++++ " .$aaaa; echo "<br>"; /*$listing_jours = calendrier($annee); echo "<pre>"; print_r($listing_jours); echo "</pre>";*/ } /**********************************************************/ function convert_date_to_timestamp() { } /**********************************************************/ function create_table($conn,$table) { $result = $conn->query("SHOW TABLES LIKE '$table'"); if ($result->num_rows > 0) { echo ">>>>> Table : " .$table ." exists !!!!"; } else { echo "Table does not exist."; $sql = "CREATE TABLE $table ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, champ_date VARCHAR(30) NOT NULL, champ_valeur VARCHAR(30) NOT NULL )"; if ($conn->query($sql) === TRUE) { echo "Table was created successfully"; } else { echo "Error creating table: " . $conn->error; } } } /**********************************************************/ function insertion($conn,$table,$DateArray,$RandomNumber) { for( $i=0; $i < count($DateArray) ; $i++) { $sql = "INSERT INTO $table (champ_date, champ_valeur) VALUES ( $DateArray[$i], $RandomNumber[$i] )"; //echo " ++++ " .$sql; //echo "<br>"; if ($conn->query($sql) === TRUE) { //echo "New record created successfully"; $ok = True; echo "Insert OK : " . $sql . "<br>" ; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } //$sql = "INSERT INTO $table (firstname, lastname, email) //VALUES ('John', 'Doe', 'john@example.com')"; } /**********************************************************/ ?>