File "generation_timing.php"

Full Path: /home/analogde/www/MassageProd/generation_timing.php
File size: 2.02 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/*
	$heure_debut = "12H20";

	$dure_massage = 20; // 25 , 30
	
	
	$val_heure = 12;
	$val_min = 0;
	
	$total_min = (12 * 60) + $val_min; 
	
	$tab_horaire = array(); 
	
	$tab_horaire[0] = $total_min;
	
	for ($i=1; $i<=7; $i++) // soit 8 scéances possibles
	{
		$tab_horaire[$i] = $total_min + ($i * 20);
		
		$tab_horaire[$i] / 60;
		
		$x = $tab_horaire[$i]; 
		$y = 60;
		
		$q = intval($x / $y);
		$r = fmod($x, $y);
		
		
		$heure = strval($q) ."H" ;
		$min = strval($r) ;
		
		if( $min == "0")
		{
			$min = "00";
		}
		
		echo " -+- " .$heure .$min; 
		echo '<br>';
		
		//echo " Reste " .$q . "  " .$r; 
		//echo '<br>';

	}
	
	// l
	
	var_dump($tab_horaire);
	
	for ($i=1; $i<=7; $i++) // soit 8 scéances possibles
	{
		$tab_horaire[$i] = $total_min + ($i * 20);
		
		
	}
*/	

function generation_timing($start_horaire, $temps_massage, $temps_sanitaire)
{

	$pieces = explode("H", $start_horaire);
	//echo $pieces[0]; 
	//echo '<br>';
	//echo $pieces[1]; 
	//echo '<br>';
	
	$int_heure = (int)$pieces[0];
	$int_min = (int)$pieces[1];
	$total_min = ($int_heure * 60) + $int_min; 
	
	//echo " Start : " .$total_min;
	//echo '<br>';
	
	$tab_horaire = array(); 
	
	$tab_horaire[0] = $start_horaire;
	
	$duration = $temps_massage + $temps_sanitaire;
	
	for ($i=1; $i<=7; $i++) // soit 8 scéances possibles
	{
		$nb_min = $total_min + ($i * $duration);
		
		//echo " NB minute " . $nb_min;
		
		$q = intval($nb_min / 60);
		$r = fmod($nb_min, 60);
		
		//echo " -+- " .$q ." " .$r; 
		
		$heure = strval($q) ."H" ;
		$min = strval($r) ;
		
		//echo " -+- " .$heure .$min; 
		
		// correction
		if( $min == "0")
		{
			$min = "00";
		}
		
		// 14H5 done 14H05
		if( strlen($min) == 1 )
		{
		   $min = "0" .$min;
		}
		
		//echo " -+- " .$heure .$min; 
		//echo '<br>';
		
		$tab_horaire[$i] = $heure .$min;

	}
	
	return($tab_horaire);
	
}

	//$arr = generation_timing("12H20", 20, 5);
	//var_dump($arr);
	
	
/*	echo '<br>';
	generation_timing("12H20", 25);
	echo '<br>';
	generation_timing("12H30", 20);
	echo '<br>';
	generation_timing("12H30", 25);*/
	
?>