AnonSec Team
Server IP : 10.128.40.6  /  Your IP : 216.73.216.233
Web Server : Apache
System : Linux webd006.cluster128.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : logmcpe ( 111175)
PHP Version : 7.3.33
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/logmcpe/www/mcg/pages/feuillesroute/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/mcg/pages/feuillesroute/../Prestation_Newf2.php
<?php
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
$pagemenu = basename($_SERVER["PHP_SELF"]) ;
$now   = time();

function dateDifference($strtDate , $endDate )
{
$startDateWeekCnt = round(floor( date('d',strtotime($strtDate)) / 7)) ;
$endDateWeekCnt = round(ceil( date('d',strtotime($endDate)) / 7)) ;
$datediff = strtotime(date('Y-m',strtotime($endDate))."-01") - strtotime(date('Y-m',strtotime($strtDate))."-01");
$totalnoOfWeek = round(floor($datediff/(60*60*24)) / 7) + $endDateWeekCnt - $startDateWeekCnt ;
    return $totalnoOfWeek;
}
// jj function dateDifference($date1, $date2)
// {
    // $first = DateTime::createFromFormat('m/d/Y', $date1);
    // $second = DateTime::createFromFormat('m/d/Y', $date2);
    // if($date1 > $date2) return week_between_two_dates($date2, $date1);
    // return floor($first->diff($second)->days/7);
// }

function GET_type_pre ($name = '', $param = '',$value =1)
{
	if(!is_array($value))
		$value = array($value) ;
	$tab = array(1 => 'Nettoyage courant régulier', 2 => 'Prestation de Vitrerie ',  3 => 'Shampoing Moquette ',  4 => 'Autre prestation spécifique');
	$ret = "<select name=\"$name\" $param>";
	foreach ($tab as $key => $val) {
	$ret .= sprintf('<option value="%s"%s>%s </option>', $key, in_array($key , $value) ? ' selected' : '', $val) ;
	}
	return $ret."</select>" ;
}
// $days = array(0 s=> 'sunday', 1 => 'monday',  2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday');
if(isset($_GET['prt'])){
	dbi_query("delete FROM PRESTATIONS_MODIF where modif_id = ".$_GET['prt']);	
}
if(isset($_GET['exp']))
{
	$EXPprdt = dbi_fetch_row(dbi_query("SELECT * FROM EXCEPTIONS WHERE excpt_id = '".$_GET['exp']."' ")) ;

	if($EXPprdt)
	{
		// echo "SELECT * FROM EXCEPTIONS where excpt_id > '".$EXPprdt['excpt_id']."' AND presta_id = '".$EXPprdt['presta_id']."' AND exp_id_mere  = '0' ORDER BY excpt_id ASC LIMIT 1";
		
		$test = dbi_fetch_row(dbi_query("SELECT * FROM EXCEPTIONS where excpt_id > '".$EXPprdt['excpt_id']."' AND presta_id = '".$EXPprdt['presta_id']."' AND exp_id_mere  = '0' ORDER BY excpt_id DESC LIMIT 1")) ;
		// echo '<pre>';
		// print_r($test);
		// echo '</pre>';
		
		dbi_query("delete FROM EXCEPTIONS where excpt_id = ".$EXPprdt['excpt_id']);	
		dbi_query("delete FROM EXCEPTIONS where exp_id_mere = '".$EXPprdt['excpt_id']."' " );
		if($EXPprdt['new_presta_id'] > 0){
		dbi_query("delete FROM PRESTATIONS where presta_id = ".$EXPprdt['new_presta_id']);
		
		}
		
		
		
		
			
		if($test)
		dbi_query("UPDATE EXCEPTIONS SET date_presta= '".$EXPprdt['date_presta']."' where excpt_id = ".$test['excpt_id']." OR  exp_id_mere = ".$test['excpt_id']." ");
			
		 
		
	}
	
}
function days ($value = 0)
{
$tab = array(0 => 'sunday', 1 => 'monday',  2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday');
	 return $tab[$value];
}
function daysfr ($value = 0)
{
$tab = array(0 => 'Dimanche', 1 => 'Lundi',  2 => 'Mardi', 3 => 'Mercredi', 4 => 'Jeudi', 5 => 'Vendredi', 6 => 'Samedi');
	 return $tab[$value];
}
// echo date('Ymd');
 if(isset($_GET['date']))
 {
	 $year = $month =  $day = 0;
	list($year ,$month, $day) = explode("-", $_GET['date']);
	if( $year >= 1900 and $year <= (date('Y')+1) and $month >=1 and $month <=12  )
		$datecal = "$year-$month-01";
	else
		$datecal = date('Y-m-01');
 }
else
	$datecal = date('Y-m-01');
// echo ' $$$$$ '.$datecal;
$client_id = $_SESSION["client_id"] ; 
 $q= dbi_fetch_row(dbi_query("SELECT * FROM client where client_id = ".$client_id)) ;
 if(isset($_POST['DelPrDate']))
	{
				$facture = $ad = $ded = 0;
		if($presta_Hduree <  1 )
		{
			$facture = 1;
			$ded = 1;	
			
		}
	// echo "<pre>";
	// print_r($_POST);
	// echo "</pre>";
	$facture = '';
	if($_POST['facture']) $facture = 1;
	dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture,ad,ded) VALUES (".$_POST['presta_id'].", ".dateformaint($_POST['date_presta']).", NULL,'".$facture."','".$ad."','".$ded."')" ) ;
	// header("Refresh:0; url=Prestation_New.php");
	}
	
	
 if(isset($_POST['upt2date']))
	{
			$presta_id = $_POST['presta_id'];
			$date_debut = dateformaint($_POST['date_debut']);
			$date_fin = dateformaint($_POST['date_fin']);  
			$j = $h = $d = $s = $f = $ch = $sl = 'NULL' ;
			$j = $_POST['presta_jour'] ;			
			$h = heure2int($_POST['presta_Hdeb']) ;
			$d =  calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']); 
			$f = $_POST['presta_forfait'] ;
			$sl = $_POST['salarie_id'] ;
			$ch = $_POST['chantier_id'] ;
			
			$prest = dbi_fetch_row(dbi_query("SELECT * FROM PRESTATIONS WHERE  presta_id = $presta_id ")) ;
			// echo $prest['salarie_id'].' ***** ';
			$data = array('presta_jour' => $prest['presta_jour'], 'presta_Hdeb' => $prest['presta_Hdeb'], 'presta_Hduree' => $prest['presta_Hduree'],
			'salarie_id' => $prest['salarie_id'], 'presta_forfait' => $prest['presta_forfait'], 'presta_sem' => $prest['presta_sem'], 'chantier_id' => $prest['chantier_id']) ;
			$q = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$prest['presta_id']." order by start, modif_id") ;
			while (($m = dbi_fetch_row($q)) && $date_fin >= $m['start'])
				{
					$data['presta_jour'] = $m['presta_jour'] === NULL ? $data['presta_jour'] : $m['presta_jour'] ;
					$data['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $data['presta_Hdeb'] : $m['presta_Hdeb'] ;
					$data['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $data['presta_Hduree'] : $m['presta_Hduree'] ;
					$data['salarie_id'] = $m['salarie_id'] === NULL ? $data['salarie_id'] : $m['salarie_id'] ;
					$data['presta_forfait'] = $m['presta_forfait'] === NULL ? $data['presta_forfait'] : $m['presta_forfait'] ;
				}
			// echo '<pre>';
			// print_r($data);			
			// echo '</pre>';

				dbi_query("delete FROM PRESTATIONS_MODIF WHERE presta_id = '".$presta_id."' AND  START BETWEEN  '".$date_debut."' AND '".$date_fin."'  ");
				dbi_query("delete FROM PRESTATIONS WHERE client_id = '".$client_id."' AND  presta_date_debut  BETWEEN  '".$date_debut."' AND '".$date_fin."' AND presta_date_debut = presta_date_fin ");
				// dbi_query("UPDATE PRESTATIONS_MODIF SET salarie_id = '".$sl."', presta_jour'".$j."', presta_Hdeb'".$h."', presta_Hduree'".$d."',presta_forfait'".$f."' WHERE   WHERE  presta_id = $presta_id  AND START BETWEEN  '".$date_debut."' AND '".$date_fin."'  ");
				$sql = "INSERT INTO PRESTATIONS_MODIF (presta_id, start, salarie_id, presta_jour, presta_Hdeb, presta_Hduree, presta_forfait) 
															VALUES (".$presta_id.", $date_debut, $sl,$j, $h, $d, $f)";
				dbi_query($sql);
			
			$j = $data['presta_jour'] ;			
			$h = $data['presta_Hdeb'] ;
			$d = $data['presta_Hduree'] ;
			$f = $data['presta_forfait'] ;
			$sl = $data['salarie_id'] ;
			$date_fin =  date("Ymd", strtotime("+1 day", strtotime($date_fin)));
				$sql = "INSERT INTO PRESTATIONS_MODIF (presta_id, start, salarie_id, presta_jour, presta_Hdeb, presta_Hduree,presta_forfait) 
															VALUES (".$presta_id.", $date_fin, $sl,$j, $h, $d, $f)";
				dbi_query($sql);
			// echo '<pre>';
			// print_r($data);			
			// echo '</pre>';		

	}		
 if(isset($_POST['del2date']))
	{
		$date_debut = dateformaint($_POST['date_debut']);
		$date_fin = dateformaint($_POST['date_fin']);
		$facture = '';
		if($_POST['facture']) $facture = 1;
			while ($date_debut <= $date_fin )
		{
			$q1 = dbi_query("SELECT * FROM PRESTATIONS WHERE presta_id = '".$_POST['presta_id']."'");
			$prest1 = dbi_fetch_row($q1);		
				$q2 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$prest1['presta_id']." order by start, modif_id ") ;
					while (($m2 = dbi_fetch_row($q2)) && $date_debut >= $m2['start'])
						{
							$prest1['presta_jour'] = $m2['presta_jour'] === NULL ? $prest1['presta_jour'] : $m2['presta_jour'] ;
						}			
			$day = date("w", strtotime( int2date_autre_format($date_debut)));
			if( $day == $prest1['presta_jour'])
			{
				   $EXP = dbi_fetch_row(dbi_query("SELECT date_presta FROM EXCEPTIONS WHERE presta_id = ".$prest1['presta_id']." AND date_presta = ".$date_debut." " )) ;	   ;
				   if($EXP ){}   else {
						if( $prest1['presta_sem'] == 1 )
						{
							// echo $date_debut.' ** '. $prest1['presta_jour'].' == '.$day.'<br/>';	
							dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture) VALUES (".$_POST['presta_id'].", ".$date_debut.", NULL,'".$facture."' )") ;

						}
						else
						{
							$nbre = dateDifference(int2date_autre_format($prest1['presta_date_debut']),int2date_autre_format($date_debut)) - 1;
							if( $nbre % $prest1['presta_sem'] == 0) {
								// echo $date_debut.' ** '. $prest1['presta_jour'].' == '.$day.'<br/>';	
								dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture) VALUES (".$_POST['presta_id'].", ".$date_debut.", NULL,'".$facture."' )") ;
							}
							
						}	

				   }
				
				
				
			}	
			// echo $date_debut.' ** '. $prest1['presta_jour'].' == '.$day.'<br/>';			

			
		$date_debut =  date("Ymd", strtotime("+1 day", strtotime($date_debut)));
		}
			
			

		// dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture) VALUES (".$_POST['presta_id'].", ".$date_prest.", NULL,'".$facture."' )") ;
		// header("Refresh:0; url=Prestation_New.php");
	
	}
	
 if(isset($_POST['UptPrDate']))
	{
		if($_POST['presta_id_old'] > 0 )
		$presta_id_old 			= $_POST['presta_id_old'];
	else
		$presta_id_old 			= $_POST['presta_id'];
	
		$client_id 			= $_POST['client_id'];
		$chantier_id		= $_POST['chantier_id'];
		$salarie_id			= $_POST['salarie_id'];
        $presta_date_debut	= dateformaint($_POST['presta_date_debut']);
		$presta_jour		= date("w", strtotime($_POST['presta_date_debut']));  
		$presta_Hdeb		= heure2int($_POST['presta_Hdeb']);
		$presta_Hduree		= calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']);    
		$presta_forfait 	= $_POST['presta_forfait'];
		$presta_sem 	= 1;
		$presta_date_fin	= dateformaint($_POST['presta_date_debut']);
		if($_POST['prestation_type'] > 0 ) 		$prestation_type 	= $_POST['prestation_type']; else $prestation_type = 4;
		
		$facture = $ad = $ded = 0;
		if($_POST['facture'] <  1 )
		{
			$facture = 1;
			if($presta_Hduree > $_POST['presta_Hduree_Old'] )
				$ad = 1;
			else
			if($presta_Hduree < $_POST['presta_Hduree_Old'] )
				$ded = 1;	
			
		}	
				$sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,presta_id_old,prestation_type)
			VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,$presta_id_old,$prestation_type)";

		// $sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,presta_id_old,prestation_type,facture,ad,ded)
			// VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour','$presta_Hdeb','$presta_Hduree','$presta_forfait','$presta_sem','$presta_id_old','$prestation_type','$facture','$ad','$ded')";
			// echo $sql;
			dbi_query($sql);
			$last_id = mysqli_insert_id($conn);
			dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture,ad,ded) VALUES (".$presta_id_old.", ".dateformaint($_POST['date_presta']).", ".$last_id.", ".$facture.", ".$ad.", ".$ded." )") ;
			$last_id_EXP = mysqli_insert_id($conn);			
			if($_POST['presta_id_old'] > 0 ) 
			dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id, presta_id_mere,exp_id_mere) VALUES (".$_POST['presta_id'].", ".dateformaint($_POST['date_presta']).",NULL,'".$presta_id_old."','".$last_id_EXP."')") ;	
			// dbi_query("INSERT INTO EXCEPTIONS (presta_id,presta_id_mere, date_presta, new_presta_id) VALUES (".$_POST['presta_id'].",".$presta_id_old.", ".dateformaint($_POST['date_presta']).", ".$last_id." )") ;
	}		
	
	
	
	
 if(isset($_POST['InsPr']))
	{
		$client_id 			= $_POST['client_id'];
		$chantier_id		= $_POST['chantier_id'];
		$salarie_id			= $_POST['salarie_id'];
        $presta_date_debut	= dateformaint($_POST['presta_date_debut']);
		$presta_jour		= $_POST['presta_jour'];
		$presta_Hdeb		= heure2int($_POST['presta_Hdeb']);
		$presta_Hduree		= calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']);    
		$presta_forfait 	= $_POST['presta_forfait'];
		$presta_sem 	= $_POST['presta_sem'];
		$prestation_type 	= $_POST['prestation_type'];
		
		if(!empty($_POST['presta_date_fin'])) 
		{
		$presta_date_fin	= dateformaint($_POST['presta_date_fin']);
		$sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,prestation_type)
			VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,$prestation_type)";
		}
		else
		$sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,prestation_type)
			VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut',NULL,'$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,$prestation_type)";
		// echo $sql;
		dbi_query($sql);
	}
		function create_upt ($presta_id,$client_id,$presta_date_debut,$presta_date_fin,$presta_sem,$presta_jour, $presta_Hdeb,$presta_Hduree , $presta_forfait , $chantier_id ,$salarie_id,$start ,$prestation_type )
{
			if(empty($presta_date_fin)) 
			$update = dbi_query("UPDATE PRESTATIONS SET presta_date_debut=$presta_date_debut, presta_date_fin=NULL ,prestation_type=$prestation_type WHERE  presta_id = $presta_id ") ;	
				else
			$update = dbi_query("UPDATE PRESTATIONS SET presta_date_debut=$presta_date_debut, presta_date_fin=$presta_date_fin ,prestation_type=$prestation_type WHERE  presta_id = $presta_id ") ;
			$j = $h = $d = $s = $f = $ch = $sl = 'NULL' ;
			
			$prest = dbi_fetch_row(dbi_query("SELECT * FROM PRESTATIONS WHERE  presta_id = $presta_id ")) ;
			$data = array('presta_jour' => $prest['presta_jour'], 'presta_Hdeb' => $prest['presta_Hdeb'], 'presta_Hduree' => $prest['presta_Hduree'],
			'salarie_id' => $prest['salarie_id'], 'presta_forfait' => $prest['presta_forfait'], 'presta_sem' => $prest['presta_sem'], 'chantier_id' => $prest['chantier_id']) ;
			$q = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$prest['presta_id']." order by start, modif_id") ;
			while (($m = dbi_fetch_row($q)) && $start >= $m['start'])
				{
					$data['presta_jour'] = $m['presta_jour'] === NULL ? $data['presta_jour'] : $m['presta_jour'] ;
					$data['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $data['presta_Hdeb'] : $m['presta_Hdeb'] ;
					$data['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $data['presta_Hduree'] : $m['presta_Hduree'] ;
					$data['salarie_id'] = $m['salarie_id'] === NULL ? $data['salarie_id'] : $m['salarie_id'] ;
					$data['presta_forfait'] = $m['presta_forfait'] === NULL ? $data['presta_forfait'] : $m['presta_forfait'] ;
					$data['presta_sem'] = $m['presta_sem'] === NULL ? $data['presta_sem'] : $m['presta_sem'] ;
					$data['chantier_id'] = $m['chantier_id'] === NULL ? $data['chantier_id'] : $m['chantier_id'] ;
				}
				if($presta_jour  != $data['presta_jour'])						$j = $presta_jour ;
				if($presta_sem != $data['presta_sem'])           		$s = $presta_sem ;
				if($presta_Hdeb != $data['presta_Hdeb'])          		$h = $presta_Hdeb ;
				if($presta_Hduree != $data['presta_Hduree'])          	$d = $presta_Hduree ;
				if($presta_forfait != $data['presta_forfait'])          $f = $presta_forfait ;
				if($salarie_id != $data['salarie_id'])                  $sl = $salarie_id ;
				if($chantier_id != $data['chantier_id'])          	    $ch = $chantier_id ;
				
				if($j != 'NULL' || $j != 'NULL' || $s != 'NULL' || $h != 'NULL' || $d != 'NULL' || $f != 'NULL' || $sl != 'NULL' || $ch != 'NULL')
				{
					$sql = "INSERT INTO PRESTATIONS_MODIF (presta_id, start, salarie_id, presta_jour, presta_Hdeb, presta_Hduree,presta_sem, presta_forfait,chantier_id) 
															VALUES (".$presta_id.", $start, $sl,$j, $h, $d, $s, $f, $ch)";
														
														// echo $sql;
					$update += dbi_query($sql) ;
					
					
									if($j != 'NULL')
														{
																		$qex = dbi_query("SELECT * FROM EXCEPTIONS WHERE presta_id = ".$prest['presta_id']." AND date_presta >= $start ") ;
																		while ($mex = dbi_fetch_row($qex))
																			{
																				$date_presta = 	$mex['date_presta'];
																				$day = days($j);
																				$d1 = new DateTime("$day this week ".$date_presta);
																				$date_presta2 = $d1->format('Ymd');
																				dbi_query("UPDATE EXCEPTIONS SET date_presta=$date_presta2 WHERE excpt_id = ".$mex['excpt_id']." ") ;
																			}
														}
				}
}
 if(isset($_POST['UptPr']))
	{
		$presta_Hdeb		= heure2int($_POST['presta_Hdeb']);
		$presta_Hduree		= calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']); 
		if(!empty($_POST['presta_date_fin'])) 	 $presta_date_fin = dateformaint($_POST['presta_date_fin']);	else  $presta_date_fin = NULL ;	
create_upt($_POST['presta_id'],$_POST['client_id'],dateformaint($_POST['presta_date_debut']),$presta_date_fin,$_POST['presta_sem'],$_POST['presta_jour'],$presta_Hdeb,$presta_Hduree,$_POST['presta_forfait'],$_POST['chantier_id'],$_POST['salarie_id'],dateformaint($_POST['start']),$_POST['prestation_type']);
	}
	// echo "<pre>";
	// print_r($_POST);
	// echo "</pre>";
?>

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>LogMCPRO | Prestations</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  
    <!-- Select2 -->
  <link rel="stylesheet" href="../plugins/select2/css/select2.min.css">
  <link rel="stylesheet" href="../plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
  <!-- fullCalendar -->
  <link rel="stylesheet" href="../plugins/fullcalendar/main.min.css">
  <link rel="stylesheet" href="../plugins/fullcalendar-daygrid/main.min.css">
  <link rel="stylesheet" href="../plugins/fullcalendar-timegrid/main.min.css">
  <link rel="stylesheet" href="../plugins/fullcalendar-bootstrap/main.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../dist/css/adminlte.min.css">
  <!-- Google Font: Source Sans Pro -->
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head> 
<body class="hold-transition sidebar-mini">	
<!-- Site wrapper -->
<div class="wrapper">

<!-- TOP MENU -->
  <nav class="main-header navbar navbar-expand navbar-white navbar-light">
 <!-- Menu extensible -->
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
      </li>
<!-- liens TOP MENU GAUCHE-->
      <li>
             <h3><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-nouvelleprestation"> NOUVELLE PRESTATION</button></h3>
         </li><!-- /.col -->
    </ul>

 <!-- liens TOP MENU DROITE -->
    <ul class="navbar-nav ml-auto">
     <!-- Placer ici l'élément à positionner à droite du TOP MENU -->
    </ul>
  
  </nav>  <!-- fin du TOP MENU -->
  
  
<!-- BARRE DE NAVIGATION -->

 <!-- Couleur et caracteristiques de la barre de navigation-->
 
 
 	<?php include('menu.php'); ?>
 <!-- Ne pas toucher au dessus / fin de la BARRE DE NAVIGATION-->	




 <!-- DEMARRAGE DE LA PAGE PRINCIPALE -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
         
			<div class="modal fade" id="modal-nouvelleprestation">
				<div class="modal-dialog modal-lg">
				  <div class="modal-content">
					<div class="modal-header">
					  <h4 class="modal-title">Nouvelle Prestation</h4>
					  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					  </button>
					</div>
					<div class="modal-body">
							<div class="card-body">
								<form action="" method="POST">
									<input type="hidden" id="client_id" name="client_id" value="<?php echo $client_id ;?>"/>							
									<div class="form-row">
									
										<div class="form-group col-md-4">
											<label>Date de D&#233;but (start)</label>
											<div class="input-group">
												<div class="input-group-prepend"> <span class="input-group-text"><i class="far fa-calendar-alt"></i></span></div>
												<input type="date" class="form-control" id="presta_date_debut" name="presta_date_debut" placeholder="jj/mm/aaaa"/>
											</div>
										</div>							
										<div class="form-group col-md-4">
											<label>Date de fin (end) </label>
											<div class="input-group">
												<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt"></i></span></div>
												<input type="date" class="form-control" id="presta_date_fin" name="presta_date_fin" >
											</div>
										</div>
										
										<div class="form-group col-md-4">
											<label>Nombre semaine </label>
											<div class="input-group">
												<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt"></i></span></div>
												<select class="form-control" name="presta_sem"  id="presta_sem">
													<option value="1" > 1 </option>
													<option value="2" > 2 </option>
													<option value="3" > 3 </option>
													<option value="4" > 4 </option>
													<option value="5" > 5 </option>
													<option value="6" > 6 </option>
													<option value="7" > 7 </option>
													<option value="8" > 8 </option>
													<option value="9" > 9 </option>
													<option value="10"> 10</option>
													<option value="11"> 11 </option>
													<option value="12"> 12</option>
												</select>
											 </div>
										</div>
										
										<div class="form-group col-md-2">
											<label for="inputAddresse">Heure D&#233;but</label>
											<input type="time" id="appt"   min="05:00" max="22:00" class="form-control" name="presta_Hdeb"  value= "<?php echo int2heure($prest['presta_Hdeb']) ; ?>" required>
										</div>
	  
										<div class="form-group col-md-2">
										  <label for="inputsociete">Heure  fin</label>
										  <input type="time" id="appt"  min="05:00" max="22:00" class="form-control" name="presta_Hfin"  value= "<?php echo int2heure($prest['presta_Hfin']) ; ?>"  required>
										</div>
										
										<div class="form-group col-md-4"> 
												<label>Jour de prestation</label>
												<select class="form-control" name="presta_jour"  id="presta_jour">
													<option selected="selected" value="1"> lundi  </option>
													<option value="2" >mardi </option>
													<option value="3" >mercredi  </option>
													<option value="4" >jeudi   </option>
													<option value="5" >vendredi   </option>
													<option value="6" >samedi  </option>
													<option value="0" >dimanche  </option>
												</select>
										</div>
										
									   <div class="form-group col-md-4"><!-- Liste déroulante jour -->  
											<label>Salarier </label>
											<select class="form-control select2" style="width: 100%;" name="salarie_id" id="salarie_id2">
												<?php $req =dbi_query("SELECT * FROM salarie WHERE salarie_statut = '1' ORDER BY `salarie`.`salarie_nom` ASC") ;
												while(  $sal=dbi_fetch_row($req)) { ?>
													<option value="<?php echo $sal['salarie_id'] ; ?>"  ><?php echo $sal['salarie_nom']." ".$sal['salarie_prenom']; ?></option>
													<?php   }	?>
											</select>
										</div>


									   <div class="form-group col-md-4"><!-- Liste déroulante jour -->  
											<label>Chantier </label>
											<select class="form-control" name="chantier_id" id="chantier_id">
												<?php $req1 =dbi_query("SELECT *  FROM chantier WHERE `client_id` = $client_id ") ; 
												while(  $chant=dbi_fetch_row($req1)) { ?>
													<option value="<?php echo $chant['chantier_ID'] ; ?>"  ><?php echo $chant['chantier_designation']; ?></option>
													<?php   }	?>
											</select>
										</div>
	   
										<div class="form-group col-md-4">
											<label for="inputsociete">Taux</label>
											<input type="text"	 class="form-control" name="presta_forfait"  required>
										</div>
										<div class="form-group col-md-4">
											<label for="inputsociete">Type prestation</label>
											<?php  echo GET_type_pre('prestation_type','id="prestation_type" class="form-control" ' ,1 )  ; ?>
										</div>

									</div>  
							</div>
					</div>
					<div class="modal-footer justify-content-between">
										<button type="button" class="btn btn-primary" data-dismiss="modal">Fermer</button>
										<button type="submit" name="InsPr" class="btn btn-primary">Enregistrer</button>
								</form>
					</div>
			  </div>
			  <!-- /.modal-content -->
				</div>
			<!-- /.modal-dialog -->
			</div>
			<div  class="modal fade" id="myModal" role="dialog" class="modal fade task-modal-single in" tabindex="-1"  aria-labelledby="myLargeModalLabel" >
					  <div class="modal-dialog modal-lg">
						<div class="modal-content data">
							<div id="fetch" ></div>
							
							   
							</div>
						</div>
			</div>
			<div  class="modal fade" id="myModal1" role="dialog" class="modal fade task-modal-single in" tabindex="-1"  aria-labelledby="myLargeModalLabel" >
					  <div class="modal-dialog modal-lg">
						<div class="modal-content data">
							<div id="fetch1" ></div>
							
							   
							</div>
						</div>
			</div>			
			<div  class="modal fade" id="PrestUpt" role="dialog" class="modal fade task-modal-single in" tabindex="-1"  aria-labelledby="myLargeModalLabel" >
					  <div class="modal-dialog modal-lg">
						<div class="modal-content data">
							<div id="jalil" ></div>
							
							   
							</div>
						</div>
			</div>
         <!--  <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Accueil</a></li>
              <li class="breadcrumb-item active">Prestations</li>
            </ol>
          </div> -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- PAGE PRINCIPALE -->
    <div class="content">
      <div class="container-fluid">
        <div class="row">
	  <!-- DEFINITION DES COLONNES -->	
			<div class="col-lg-3">
			<?php  $q= dbi_fetch_row(dbi_query("SELECT * FROM client where client_id = ".$client_id)) ; ?>
				<?php include('widget_client.php'); ?>
		 <!-- BARRE DE NAVIGATION DU CLIENT -->		  
				<?php include('menu_client.php'); ?>
				
				<div class="card bg-light">
					  <span class="mr-2">&nbsp;&nbsp;&nbsp;&nbsp;<i class="fas fa-square text-primary"></i> Nettoyage courant régulier</span><br/>
					  <span class="mr-2">&nbsp;&nbsp;&nbsp;&nbsp;<i class="fas fa-square text-success"></i> Prestation de Vitrerie</span><br/>
					  <span class="mr-2">&nbsp;&nbsp;&nbsp;&nbsp;<i class="fas fa-square text-warning"></i> Shampoing Moquette</span><br/>
					  <span>&nbsp;&nbsp;&nbsp;&nbsp;<i class="fas fa-square text-pink"> </i>  Autre prestation spécifique </span>			 
				</div>
			</div>
          
          <!-- PASSAGE A LA COLONNE DE DROITE-->
		  
		  
		            <!-- /.col -->
          <div class="col-lg-9">
           <div class="card bg-light">	
              <div class="card-body p-0">
			  			<?php  
							   $i = 1;
							   $date = date('Ymd'); ;
							   $sql= "SELECT * FROM PRESTATIONS WHERE  client_id=".$client_id."  AND ((presta_date_debut != presta_date_fin &&  presta_date_fin >= '".$date."')  OR presta_date_fin IS NULL ) ORDER BY presta_date_debut";
								$q = dbi_query($sql);
								// echo $sql.'<br>';
								$rowcount=mysqli_num_rows($q);
								// echo $rowcount.' iiii ';
								if($rowcount > 0)
								{
								?>
			  
						<table id="example1" class="table table-bordered table-striped">
							<thead>
								<tr>
								  <th>Prestations en cours</th>
								  <th></th>								  
								  <th>Modifier</th>
								  <th style="white-space: nowrap;">Modifier Période</th>
								</tr>
							</thead>
							<tbody>	
									<?php while($LPr=dbi_fetch_row($q)) { 
										
										$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start, modif_id ") ;
										while (($m = dbi_fetch_row($q1)) && $date >= $m['start'])
										{
											$LPr['presta_jour'] = $m['presta_jour'] === NULL ? $LPr['presta_jour'] : $m['presta_jour'] ;
											$LPr['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $LPr['presta_Hdeb'] : $m['presta_Hdeb'] ;
											$LPr['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $LPr['presta_Hduree'] : $m['presta_Hduree'] ;
											$LPr['salarie_id'] = $m['salarie_id'] === NULL ? $LPr['salarie_id'] : $m['salarie_id'] ;
											$LPr['presta_forfait'] = $m['presta_forfait'] === NULL ? $LPr['presta_forfait'] : $m['presta_forfait'] ;	
										}
											if($LPr['salarie_id'] !== NULL)
															$salarie = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) as salarie FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;	
										
											// if($LPr['salarie_id'] !== NULL)
															// list($LPr['salarie_id']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;	
									?>	
								<tr>
									<td>
									<?php echo $i." -  Début : <strong>".int2date($LPr['presta_date_debut'])."</strong> Jour : <strong>".daysfr($LPr['presta_jour']);?></strong>
									, H Début : <strong><?php echo int2heure($LPr['presta_Hdeb']);?></strong> H Fin : <strong><?php echo int2heure(addDuree($LPr['presta_Hdeb'], $LPr['presta_Hduree']) );?> </strong> Salarié : <strong><?php echo $salarie['salarie'];?></strong> Taux : <strong><?php echo $LPr['presta_forfait'];?></strong>,
									<?php if ( $LPr['presta_date_fin'] == NULL ) echo '<b style="color:red">Pas date de fin </b>'; else echo " Fin :  ".int2date($LPr['presta_date_fin']); ?>
									</td>	
									<td align="center" style=" white-space: nowrap;"> <a class="btn btn-primary btn-sm" data-toggle="collapse" href="#prst<?php echo $LPr['presta_id']; ?>" role="button" aria-expanded="false" aria-controls="prst<?php echo $LPr['presta_id']; ?>">Voir Les Modifications </a></td>	
									<td align="center"><?php echo '<a class="btn btn-info btn-sm" href="#myModal"  id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'">Modifer</a>';?></td>
									<td align="center"><?php echo '<a class="btn btn-info btn-sm" href="#myModal1"  id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'">Modifier Période </a>';?></td>										
								</tr>
								<tr>
									<td colspan="4">
										<div class="collapse" id="prst<?php echo $LPr['presta_id']; ?>">
											<div class="card card-body ">
											<span style="	display: inline;	">
											
											<?php
											$sqlo= "SELECT * FROM PRESTATIONS Pr LEFT JOIN salarie Sl  on Pr.salarie_id = Sl.salarie_id where  Pr.presta_id = '".$LPr['presta_id']."'";
											$qo = dbi_query($sqlo);
											$LPro=dbi_fetch_row($qo);
											echo  "La prestation d'origine a lieu le <strong>".daysfr($LPro['presta_jour']);?></strong>
											, de <strong><?php echo int2heure($LPro['presta_Hdeb']);?></strong> à <strong><?php echo int2heure(addDuree($LPro['presta_Hdeb'], $LPro['presta_Hduree']) );?> </strong> avec <strong><?php echo $LPro['salarie_nom'].' '.$LPro['salarie_prenom'];?></strong> au taux <strong><?php echo $LPro['presta_forfait'];?></strong>
											
									
											
												<?  // if (mysql_num_rows($q1))
																	// {
													$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start") ;
												?>
													<br/><b>Modifications</b><br/>
													
												<?php
													while ($m = dbi_fetch_row($q1))
													{
														if($m['salarie_id'] !== NULL)
															list($m['salarie']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$m['salarie_id']."' ")) ;								
														// if($m['salarie_id'] !== NULL)
												?>
											
											
											<a class="btn btn-danger btn-sm" href="?prt=<?php echo $m['modif_id'];?>" >Supprimer</a> 
												 A partir du <?php echo int2date($m['start']);?>, la prestation <?php echo ($m['presta_jour'] != NULL || $m['presta_Hdeb'] != NULL || $m['presta_Hduree'] != NULL ? 'a lieu '.($m['presta_jour'] === NULL ? '' : 'le '.daysfr($m['presta_jour'])).($m['presta_Hdeb'] === NULL ? '' : ' de '.int2heure($m['presta_Hdeb'])).($m['presta_Hduree'] === NULL ? '' : ' a '.int2heure(addDuree($m['presta_Hdeb'], $m['presta_Hduree']))).($m['inter'] === NULL ? '' :' et ') : '').(($m['salarie'] === NULL ? '' : ' se fera avec '.$m['salarie'])).(($m['presta_forfait'] === NULL ? '' : ' au taux '.$m['presta_forfait']))?><br/>						
												<?php
													}
													// }
													// if (mysql_num_rows($q2))
													// {
														
															$q2 = dbi_query("
															SELECT * FROM EXCEPTIONS e 
															LEFT JOIN PRESTATIONS p ON new_presta_id is not null 
															and new_presta_id = p.presta_id WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, en_cours, excpt_id") ;	
													// $q2 = dbi_query("SELECT excpt_id,e.new_presta_id  AS new_presta_id,salarie_id,e.date_presta,presta_date_debut,presta_Hdeb,presta_Hduree,presta_forfait,inter_abs ,facture
													// FROM  EXCEPTIONS e LEFT JOIN PRESTATIONS p ON  e.new_presta_id = p.presta_id and e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id") ;
													// echo "SELECT excpt_id,e.new_presta_id  AS new_presta_id,salarie_id,e.date_presta,presta_date_debut,presta_Hdeb,presta_Hduree,presta_forfait,inter_abs ,facture
													// FROM  EXCEPTIONS e LEFT JOIN PRESTATIONS p ON  e.presta_id = p.presta_id and e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id";
													// echo "SELECT * FROM  EXCEPTIONS e LEFT JOIN PRESTATIONS p ON  e.presta_id = p.presta_id and e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id";
													// echo "SELECT * FROM  EXCEPTIONS e LEFT JOIN PRESTATIONS p ON  e.presta_id = p.presta_id e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id";
												?>	
											
														<b>Exceptions</b><br/>
												<?php
													while($e = dbi_fetch_row($q2)){
													$inter = '' ;
													if($e['new_presta_id'] !== NULL)
													list($inter) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id  = '".$e['salarie_id']."' ")) ;
												?>
																						<!-- v2 -->
													<a href="?exp=<?php echo $e['excpt_id'];?>" >Supprimer</a> 
													<?php // echo $e['presta_date_debut'].' ** '.$e['date_presta'].' ** ';?>
													La prestation du <?=int2date($e['date_presta']).($e['presta_date_debut'] != NULL && $e['date_presta'] != $e['presta_date_debut'] ? ' est d&eacute;plac&eacute;e au '.int2date($e['presta_date_debut']).' et ' : ' est annul&eacute;e').($e['presta_Hdeb'] === NULL ? '' : ' aura lieu de '.int2heure($e['presta_Hdeb'])).($e['presta_Hdeb'] === NULL ? '' : ' &agrave; ' . int2heure(addDuree($e['presta_Hdeb'], $e['presta_Hduree']))) . ($e['salarie_id'] === NULL ? '' : ' avec ' . $inter) . ($e['presta_forfait'] === NULL ? '' : ' au taux ' . $e['presta_forfait']) . ($e['inter_abs'] == 1 ? ' (absence de l\'intervenant)' : '').($e['facture'] != 1 ? '' : ' (prestation d&rsquo;origine factur&eacute;e au client)')?><br/>							
												<?php
													} 
													// }
												?>
												</span>	
											</div>
										</div>  
									</td>				   
								</tr>

									<?php ++$i;} ?>
							</tbody>
						</table>
								<?php  } ?>
                <!-- THE CALENDAR -->
                <div id="calendar"></div>
				
				
				
<?php
$sql= "SELECT * FROM PRESTATIONS WHERE  client_id=".$client_id."  AND presta_date_debut != presta_date_fin &&  presta_date_fin < '".$date."'   ORDER BY presta_date_debut";
$q = dbi_query($sql);
$rowcount=mysqli_num_rows($q);
	if($rowcount > 0)
		{
?>
						<table id="example1" class="table table-bordered table-striped">
							<thead>
								<tr>
								  <th>Anciennes  Prestations</th>
								  <th></th>								  
								  <th>Modifier</th>
								  <th style="white-space: nowrap;">entre 2 dates</th>
								</tr>
							</thead>
							<tbody>	
									<?php 
							  
									while($LPr=dbi_fetch_row($q)) { 
										
										$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start, modif_id ") ;
										while (($m = dbi_fetch_row($q1)) && $date >= $m['start'])
										{
											$LPr['presta_jour'] = $m['presta_jour'] === NULL ? $LPr['presta_jour'] : $m['presta_jour'] ;
											$LPr['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $LPr['presta_Hdeb'] : $m['presta_Hdeb'] ;
											$LPr['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $LPr['presta_Hduree'] : $m['presta_Hduree'] ;
											$LPr['salarie_id'] = $m['salarie_id'] === NULL ? $LPr['salarie_id'] : $m['salarie_id'] ;
											$LPr['presta_forfait'] = $m['presta_forfait'] === NULL ? $LPr['presta_forfait'] : $m['presta_forfait'] ;	
										}
											if($LPr['salarie_id'] !== NULL)
															$salarie = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) as salarie FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;	
										
											// if($LPr['salarie_id'] !== NULL)
															// list($LPr['salarie_id']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;	
									?>	
										<tr>
											<td>
											<?php echo $i." -  La prestation Débute le  <strong>".int2date($LPr['presta_date_debut'])."</strong> a lieu le <strong>".daysfr($LPr['presta_jour']);?></strong>
											, de <strong><?php echo int2heure($LPr['presta_Hdeb']);?></strong> à <strong><?php echo int2heure(addDuree($LPr['presta_Hdeb'], $LPr['presta_Hduree']) );?> </strong> avec <strong><?php echo $salarie['salarie'];?></strong> au taux <strong><?php echo $LPr['presta_forfait'];?></strong>,
											<?php if ( $LPr['presta_date_fin'] == NULL ) echo '<b style="color:red">Pas date de fin </b>'; else echo " finit le  ".int2date($LPr['presta_date_fin']); ?>
											</td>	
											<td align="center" style=" white-space: nowrap;"> <a class="btn btn-primary" data-toggle="collapse" href="#prst<?php echo $LPr['presta_id']; ?>" role="button" aria-expanded="false" aria-controls="prst<?php echo $LPr['presta_id']; ?>">Voir Les Modifications </a></td>	
											<td align="center"><?php echo '<a class="btn btn-info btn-sm" href="#myModal"  id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'"><i class="fas fa-pencil-alt"></i></a>';?></td>
											<td align="center"><?php echo '<a class="btn btn-info btn-sm" href="#myModal1"  id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'"><i class="fa fa-calendar"></i></a>';?></td>										
										</tr>
										<tr>
											<td colspan="4">
												<div class="collapse" id="prst<?php echo $LPr['presta_id']; ?>">
													<div class="card card-body ">
													<span style="	display: inline;	">
													
													<?php
													$sqlo= "SELECT * FROM PRESTATIONS Pr LEFT JOIN salarie Sl  on Pr.salarie_id = Sl.salarie_id where  Pr.presta_id = '".$LPr['presta_id']."'";
													$qo = dbi_query($sqlo);
													$LPro=dbi_fetch_row($qo);
													echo  "La prestation d'origine a lieu le <strong>".daysfr($LPro['presta_jour']);?></strong>
													, de <strong><?php echo int2heure($LPro['presta_Hdeb']);?></strong> à <strong><?php echo int2heure(addDuree($LPro['presta_Hdeb'], $LPro['presta_Hduree']) );?> </strong> avec <strong><?php echo $LPro['salarie_nom'].' '.$LPro['salarie_prenom'];?></strong> au taux <strong><?php echo $LPro['presta_forfait'];?></strong>
													
											
													
														<?  // if (mysql_num_rows($q1))
																			// {
															$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start") ;
														?>
															<br/><b>Modifications</b><br/>
															
														<?php
															while ($m = dbi_fetch_row($q1))
															{
																if($m['salarie_id'] !== NULL)
																	list($m['salarie']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$m['salarie_id']."' ")) ;								
																// if($m['salarie_id'] !== NULL)
														?>
													
													
													<a href="?prt=<?php echo $m['modif_id'];?>" >Supprimer</a> 
														 A partir du <?php echo int2date($m['start']);?>, la prestation <?php echo ($m['presta_jour'] != NULL || $m['presta_Hdeb'] != NULL || $m['presta_Hduree'] != NULL ? 'a lieu '.($m['presta_jour'] === NULL ? '' : 'le '.daysfr($m['presta_jour'])).($m['presta_Hdeb'] === NULL ? '' : ' de '.int2heure($m['presta_Hdeb'])).($m['presta_Hduree'] === NULL ? '' : ' a '.int2heure(addDuree($m['presta_Hdeb'], $m['presta_Hduree']))).($m['inter'] === NULL ? '' :' et ') : '').(($m['salarie'] === NULL ? '' : ' se fera avec '.$m['salarie'])).(($m['presta_forfait'] === NULL ? '' : ' au taux '.$m['presta_forfait']))?><br/>						
														<?php
															}
															// }
															// if (mysql_num_rows($q2))
															// {
															$q2 = dbi_query("SELECT * FROM  EXCEPTIONS e LEFT JOIN PRESTATIONS p ON  e.presta_id = p.presta_id and e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id") ;	
															// echo "SELECT * FROM  EXCEPTIONS e LEFT JOIN PRESTATIONS p ON  e.presta_id = p.presta_id e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id";
														?>	
													
																<b>Exceptions</b><br/>
														<?php
															while($e = dbi_fetch_row($q2)){
															$inter = '' ;
															if($e['new_presta_id'] !== NULL)
															list($inter) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id  = '".$e['salarie_id']."' ")) ;
														?>
																								<!-- v2 -->
															<a href="?exp=<?php echo $e['excpt_id'];?>" >Supprimer</a> 
															La prestation du <?=int2date($e['date_presta']).($e['presta_date_debut'] != NULL && $e['date_presta'] != $e['presta_date_debut'] ? ' est d&eacute;plac&eacute;e au '.int2date($e['presta_date_debut']).' et ' : ' est annul&eacute;e').($e['presta_Hdeb'] === NULL ? '' : ' aura lieu de '.int2heure($e['presta_Hdeb'])).($e['presta_Hdeb'] === NULL ? '' : ' &agrave; ' . int2heure(addDuree($e['presta_Hdeb'], $e['presta_Hduree']))) . ($e['salarie_id'] === NULL ? '' : ' avec ' . $inter) . ($e['presta_forfait'] === NULL ? '' : ' au taux ' . $e['presta_forfait']) . ($e['inter_abs'] == 1 ? ' (absence de l\'intervenant)' : '').($e['facture'] != 1 ? '' : ' (prestation d&rsquo;origine factur&eacute;e au client)')?><br/>							
														<?php
															} 
															// }
														?>
														</span>	
													</div>
												</div>  
											</td>				   
										</tr>

									<?php ++$i;
									}
?>

							</tbody>
						</table>
<?php				}					?>						
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
		  
		  

              </div>
            </div>
          </div>
          <!-- /.col-md-6 -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content -->
  </div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Post Event</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body result">
        
      </div>
    </div>
  </div>
</div>
 
  <!-- /.content-wrapper -->

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
    <div class="p-3">
      <h5>Title</h5>
      <p>Sidebar content</p>
    </div>
  </aside>
  <!-- /.control-sidebar -->
  <footer class="main-footer">
    <div class="float-right d-none d-sm-block">
      <b>Version</b> 3.0.1
    </div>
    <strong>Copyright &copy; 2014-2019 <a href="http://adminlte.io">AdminLTE.io</a>.</strong> All rights
    reserved.
  </footer>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- SweetAlert2 -->
<script src="../plugins/sweetalert2/sweetalert2.min.js"></script>
<!-- Toastr -->
<script src="../plugins/toastr/toastr.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>

<!-- jQuery UI -->
<script src="../plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>

<!-- Select2 -->
<script src="../plugins/select2/js/select2.full.min.js"></script>


<!-- fullCalendar 2.2.5 -->
<script src="../plugins/moment/moment.min.js"></script>
<script src="../plugins/fullcalendar/main.min.js"></script>
<script src="../plugins/fullcalendar-daygrid/main.min.js"></script>
<script src="../plugins/fullcalendar-timegrid/main.min.js"></script>
<script src="../plugins/fullcalendar-interaction/main.min.js"></script>
<script src="../plugins/fullcalendar-bootstrap/main.min.js"></script>
<script src='../plugins/fullcalendar/locales/fr.js'></script>

<!-- Page script -->

<!-- Page specific script -->
<script>
  $(document).ready(function() {
	  var datecal = "<?php echo $datecal; ?>";
	  var salarie_id = "<?php echo $salarie_id; ?>";
		let calendarEl = document.getElementById('calendar');
		let calendar = new FullCalendar.Calendar(calendarEl, {
		locale: 'fr',
        plugins: [ 'bootstrap', 'interaction', 'dayGrid', 'timeGrid' ],
		firstDay: 1,
		defaultDate: datecal,
		showNonCurrentDates: false,
		fixedWeekCount: false,
		 header    : {
        left  : 'prev,next today',
        center: 'title',
        right : 'dayGridMonth,timeGridWeek,timeGridDay'
      },
	  
	  businessHours: {
  daysOfWeek: [ 0,1, 2, 3, 4,5,6 ], // Monday - Thursday
  startTime: '06:00', // a start time (10am in this example)
  endTime: '19:00', // an end time (6pm in this example)
},

	  events: 'planning.php?date='+datecal+'&salarie_id='+salarie_id,
	  
    selectable:true,
    selectHelper:true,
    editable:false,
	eventClick: function(info) {
		var idpr = info.event.id;
		var datepr = info.event.start.toLocaleDateString();
		// alert(idpr);
		datepr = datepr.substr(6, 4)+ '' +datepr.substr(3, 2)+ '' +datepr.substr(0, 2);
		$.ajax({
            type : 'post',
            url : 'Prestation_Upt_Date.php', //Here you will fetch records 
            data :  'idp='+idpr+'&date='+datepr, //Pass $id
            success : function(data){
            $('#jalil').html(data);//Show fetched data from database
			jQuery("#PrestUpt").modal('show');
            }
        });
		    // alert('Event: ' + datepr);
    // alert('Coordinates: ' + info.jsEvent.pageX + ',' + info.jsEvent.pageY);
    // alert('View: ' + info.event.start.toLocaleDateString());
		// str = JSON.stringify(info);
		// console.log(str); // Logs output to dev tools console.
		// alert(str);
		// console.log('My object : ' + info);
		// var idpevnt = info.event.id;
		// var dateevent = info.event.date;
    // alert('Event: ' + dateevent);
    // alert('Coordinates: ' + info.jsEvent.pageX + ',' + info.jsEvent.pageY);
    // alert('View: ' + info.activeStart);

    // change the border color just for fun
    // info.el.style.borderColor = 'red';
	}
	// eventClick:function(event)
    // {
		  // alert('Event: ' + event.event.title);
		// var idp = event.id;
		// var datec = event.date;
		// alert(event.start);
		    // $.ajax({
            // type : 'post',
            // url : 'Prestation_Upt_Date.php', //Here you will fetch records 
            // data :  'idp='+idp+'&date='+date, //Pass $id
            // success : function(data){
            // $('#jalil').html(data);//Show fetched data from database
			// jQuery("#PrestUpt").modal('show');
            // }
        // });
		 // alert(date);
	// }
	

    });
	calendar.setOption('locale', 'fr');
	calendar.render();


$('.fc-prev-button').click(function(){
			var date = calendar.getDate().toLocaleDateString();
			var date1 = date.substr(6, 4)+ date.substr(3, 2);
			var date2 = datecal.substr(0, 4)+ datecal.substr(5, 2);
			if(date1 != date2)
			{
				var datec = date.substr(6, 4)+ '-' +date.substr(3, 2)+ '-' +date.substr(0, 2);
				window.location.href = "Prestation_New.php?date="+datec;
			}
});			
$('.fc-today-button').click(function(){
			var date = calendar.getDate().toLocaleDateString();
			var date1 = date.substr(6, 4)+ date.substr(3, 2);
			var date2 = datecal.substr(0, 4)+ datecal.substr(5, 2);
			if(date1 != date2)
			{
				var datec = date.substr(6, 4)+ '-' +date.substr(3, 2)+ '-' +date.substr(0, 2);
				window.location.href = "Prestation_New.php?date="+datec;
			}
});
$('.fc-next-button').click(function(){
			var date = calendar.getDate().toLocaleDateString();
			var date1 = date.substr(6, 4)+ date.substr(3, 2);
			var date2 = datecal.substr(0, 4)+ datecal.substr(5, 2);
			if(date1 != date2)
			{
				var datec = date.substr(6, 4)+ '-' +date.substr(3, 2)+ '-' +date.substr(0, 2);
				window.location.href = "Prestation_New.php?date="+datec;
			}
});	
// $('#salarie_id').on('change',function(){
		 // $('form').submit();
// });
// $('#annee').on('change',function(){
		 // $('form').submit();
// });
// $('#mois').on('change',function(){
		 // $('form').submit();
// });
   });
</script>

<script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })

    //Datemask dd/mm/yyyy
    $('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
    //Datemask2 mm/dd/yyyy
    $('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
    //Money Euro
    $('[data-mask]').inputmask()

    //Date range picker
    $('#reservation').daterangepicker()
    //Date range picker with time picker
    $('#reservationtime').daterangepicker({
      timePicker: true,
      timePickerIncrement: 30,
      locale: {
        format: 'MM/DD/YYYY hh:mm A'
      }
    })
    //Date range as a button
    $('#daterange-btn').daterangepicker(
      {
        ranges   : {
          'Today'       : [moment(), moment()],
          'Yesterday'   : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
          'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
          'Last 30 Days': [moment().subtract(29, 'days'), moment()],
          'This Month'  : [moment().startOf('month'), moment().endOf('month')],
          'Last Month'  : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        },
        startDate: moment().subtract(29, 'days'),
        endDate  : moment()
      },
      function (start, end) {
        $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
      }
    )

    //Timepicker
    $('#timepicker').datetimepicker({
      format: 'LT'
    })
    
    //Bootstrap Duallistbox
    $('.duallistbox').bootstrapDualListbox()

    //Colorpicker
    $('.my-colorpicker1').colorpicker()
    //color picker with addon
    $('.my-colorpicker2').colorpicker()

    $('.my-colorpicker2').on('colorpickerChange', function(event) {
      $('.my-colorpicker2 .fa-square').css('color', event.color.toString());
    });

    $("input[data-bootstrap-switch]").each(function(){
      $(this).bootstrapSwitch('state', $(this).prop('checked'));
    });

  })
</script>




<!-- page script -->
<script>
  $(function () {
    $("#example1").DataTable();
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false
    });
  });
</script>
	 
































  <!--
<script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Datemask dd/mm/yyyy
    $('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
    //Datemask2 mm/dd/yyyy
    $('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
    //Money Euro
    $('[data-mask]').inputmask()

    //Date range picker
    $('#reservation').daterangepicker()
    //Date range picker with time picker
    $('#reservationtime').daterangepicker({ timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A' })
    //Date range as a button
    $('#daterange-btn').daterangepicker(
      {
        ranges   : {
          'Today'       : [moment(), moment()],
          'Yesterday'   : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
          'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
          'Last 30 Days': [moment().subtract(29, 'days'), moment()],
          'This Month'  : [moment().startOf('month'), moment().endOf('month')],
          'Last Month'  : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        },
        startDate: moment().subtract(29, 'days'),
        endDate  : moment()
      },
      function (start, end) {
        $('#daterange-btn span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
      }
    )

    //Date picker
    $('#datepicker').datepicker({
      autoclose: true
    })

    //iCheck for checkbox and radio inputs
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
      checkboxClass: 'icheckbox_minimal-blue',
      radioClass   : 'iradio_minimal-blue'
    })
    //Red color scheme for iCheck
    $('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
      checkboxClass: 'icheckbox_minimal-red',
      radioClass   : 'iradio_minimal-red'
    })
    //Flat red color scheme for iCheck
    $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
      checkboxClass: 'icheckbox_flat-green',
      radioClass   : 'iradio_flat-green'
    })

    //Colorpicker
    $('.my-colorpicker1').colorpicker()
    //color picker with addon
    $('.my-colorpicker2').colorpicker()

    //Timepicker
    $('.timepicker').timepicker({
      showInputs: false
    })
  })</script>
 jQuery 3 --
<script src="../../bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 --
<script src="../../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Select2 --
<script src="../../bower_components/select2/dist/js/select2.full.min.js"></script>
<!-- InputMask --
<script src="../../plugins/input-mask/jquery.inputmask.js"></script>
<script src="../../plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="../../plugins/input-mask/jquery.inputmask.extensions.js"></script>
<!-- date-range-picker --
<script src="../../bower_components/moment/min/moment.min.js"></script>
<script src="../../bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap datepicker --
<script src="../../bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<!-- bootstrap color picker --
<script src="../../bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
<!-- bootstrap time picker --
<script src="../../plugins/timepicker/bootstrap-timepicker.min.js"></script>
<!-- SlimScroll --
<script src="../../bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- iCheck 1.0.1 --
<script src="../../plugins/iCheck/icheck.min.js"></script>
<!-- FastClick --
<script src="../../bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->

<!-- Page script 
<script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Datemask dd/mm/yyyy
    $('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
    //Datemask2 mm/dd/yyyy
    $('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
    //Money Euro
    $('[data-mask]').inputmask()

    //Date range picker
    $('#reservation').daterangepicker()
    //Date range picker with time picker
    $('#reservationtime').daterangepicker({ timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A' })
    //Date range as a button
    $('#daterange-btn').daterangepicker(
      {
        ranges   : {
          'Today'       : [moment(), moment()],
          'Yesterday'   : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
          'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
          'Last 30 Days': [moment().subtract(29, 'days'), moment()],
          'This Month'  : [moment().startOf('month'), moment().endOf('month')],
          'Last Month'  : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        },
        startDate: moment().subtract(29, 'days'),
        endDate  : moment()
      },
      function (start, end) {
        $('#daterange-btn span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
      }
    )

    //Date picker
    $('#datepicker').datepicker({
      autoclose: true
    })

    //iCheck for checkbox and radio inputs
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
      checkboxClass: 'icheckbox_minimal-blue',
      radioClass   : 'iradio_minimal-blue'
    })
    //Red color scheme for iCheck
    $('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
      checkboxClass: 'icheckbox_minimal-red',
      radioClass   : 'iradio_minimal-red'
    })
    //Flat red color scheme for iCheck
    $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
      checkboxClass: 'icheckbox_flat-green',
      radioClass   : 'iradio_flat-green'
    })

    //Colorpicker
    $('.my-colorpicker1').colorpicker()
    //color picker with addon
    $('.my-colorpicker2').colorpicker()

    //Timepicker
    $('.timepicker').timepicker({
      showInputs: false
    })
  })
</script>

 -->
<script type="text/javascript">
  $( document ).ready(function() {
    $("#salarie_mutuelle").click(function () {
      val=$(this).val();
      if(val==1){
        $("#end").prop('disabled', false);
      }else{
        $("#end").prop('disabled', true);
      }
                                  
    });
	$('#myModal').on('show.bs.modal', function (e) {
        var rowid = $(e.relatedTarget).data('id');
		// alert(rowid);
        $.ajax({
            type : 'post',
            url : 'Prestation_Upt.php', //Here you will fetch records 
            data :  'rowid='+ rowid, //Pass $id
            success : function(data){
            $('#fetch').html(data);//Show fetched data from database
            }
        });
     });
	$('#myModal1').on('show.bs.modal', function (e) {
        var rowid = $(e.relatedTarget).data('id');
		// alert(rowid);
        $.ajax({
            type : 'post',
            url : 'Prestation_Upt1.php', //Here you will fetch records 
            data :  'rowid='+ rowid, //Pass $id
            success : function(data){
            $('#fetch1').html(data);//Show fetched data from database
            }
        });
     });
   
});


</script>
</body>

   
</html>

AnonSec - 2021