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 (0755) :  /home/logmcpe/www/TMCPRO/pages/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/TMCPRO/pages/calendar2_bien_05_04_2024.php
<?php
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
$_SESSION['page_name']= basename($_SERVER['PHP_SELF']);
	// echo "<pre>";
	// print_r($_POST);
	// echo "</pre>";

	// echo "*****l*********kk*********************<br/>" ;

 include('file_tache.php');
if(!empty($_POST['livraisonn'])){

		// echo "<pre>";
	// print_r($_POST);
	// echo "</pre>";
	// exit();

	// if($_POST['salarie_id_Old'] == )

		$chantier_id		= $_POST['chantier_id'];
		$salarie_id			= $_POST['salarie_id'];
		$presta_date_fin    = dateformaint($_POST['presta_date_debut']);
        $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 	= 0;
		$presta_sem 	= 1;
		$prestation_motif 	= $_POST['prestation_motif'];


// prestation_type
dbi_query(" UPDATE PRESTATIONS SET prestation_type = '5' , salarie_id = '$salarie_id',presta_date_debut = '$presta_date_debut',presta_date_fin = '$presta_date_fin',presta_jour = '$presta_jour',
presta_Hdeb=$presta_Hdeb,presta_Hduree=$presta_Hduree,presta_forfait=$presta_forfait,presta_sem=$presta_sem WHERE presta_id = ".$_POST['presta_id']."  ");
header('Location:calendar2.php?msg=upt&salarie_id='.$salarie_id.'&date='.$_POST['presta_date_debut'].' ');
}
function count_week_days($__date_from, $__date_to, $__holidays_between=array(), $__weekend_days=array()) {
   $total_days_count = $__date_to > $__date_from ? round(($__date_to - $__date_from)/(24*3600)) : 0;
   $full_weeks_count = floor($total_days_count/7);
   $weekend_days_count = $full_weeks_count*count($__weekend_days);
   $days_left_uncovered = $total_days_count - $full_weeks_count*7;
   for($i = 0; $i < $days_left_uncovered; $i++) {
      $date_to_check = $i ? strtotime("+{$i} day", $__date_from) : $__date_from;
      if(in_array(date('N', $date_to_check), $__weekend_days)) {
         $weekend_days_count++;
      }
   }
   $week_days_count = $total_days_count - $weekend_days_count - count($__holidays_between);
   return $week_days_count;
}


 if(isset($_POST['InsPr']) && isset($_POST['salarie_iid']) && $_POST['salarie_iid'] > 0  )
	{

		// echo ""
		$client_id 			= $_POST['client_id'];
		$chantier_id		= $_POST['chantier_id'];
		$salarie_id			= $_POST['salarie_iid'];
        $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 	= 0;
		$presta_sem 	= 1;
		$prestation_motif 	= $_POST['prestation_motif'];

		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_motif)
			VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,'$prestation_motif')";
		}
		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_motif)
			VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut',NULL,'$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,'$prestation_motif')";
		// echo $sql;
		dbi_query($sql);
		// $_POST['presta_date_debut']
		header('Location:calendar2.php?msg=upt&salarie_id='.$salarie_id.'&date='.$_POST['presta_date_debut'].' ');
		exit;
	}
	 if(isset($_POST['InsPrPonct']) && isset($_POST['salarie_iid']) && $_POST['salarie_iid'] > 0 )
	{
		$client_id 			= $_POST['client_id'];
		$chantier_id		= $_POST['chantier_id'];
		$salarie_id			= $_POST['salarie_iid'];

        $presta_date_debut	= dateformaint($_POST['presta_date_debut']);
		$presta_date_fin	= $presta_date_debut;
		$presta_jour = date("w", strtotime( int2date_autre_format($date)));
		// $presta_jour		= $_POST['presta_jour'];
		$presta_Hdeb		= heure2int($_POST['presta_Hdeb']);
		$presta_Hduree		= calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']);
		$presta_forfait 	= 0;
		$presta_sem 	= 1;
		$prestation_motif 	= $_POST['prestation_motif'];
		$information 	= addslashes($_POST['information']);
		$livraison = 0 ;
		if(!empty($_POST['livraison']))
		{
			$livraison = 1;
			$prestation_type = 5  ;
		}

		if(!empty($_POST['controle']))
		{
			$livraison = 1;
			$prestation_type = 6  ;
		}
		
		
		if(!empty($_POST['RDV_Propsect']))
		{
			$livraison = 1;
			$prestation_type = 8  ;
		}
		
		if(!empty($_POST['Mise_Place']))
		{
			$livraison = 1;
			$prestation_type = 9  ;
		}
		
		if(!empty($_POST['Briefing']))
		{
			$livraison = 1;
			$prestation_type = 10  ;
		}


		$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_motif,livraison,prestation_type,information)
			VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,'$prestation_motif','$livraison','$prestation_type','$information')";
		// echo $sql;
		dbi_query($sql);
		header('Location:calendar2.php?msg=upt&salarie_id='.$salarie_id.'&date='.$_POST['presta_date_debut'].' ');
		exit;
	}




 if(isset($_POST['UptPrDate']) && isset($_POST['salarie_id']) && $_POST['salarie_id'] > 0)
	{
		// fecho '<pre>';
		// print_r($_POST);
		// echo '</pre>';

		// presta_id
		// if($_POST['presta_id_old'] > 0 )
		// $presta_id_old 			= $_POST['presta_id_old'];
		// else
		if(isset($_POST['prestation_motif']))
			$prestation_motif = $_POST['prestation_motif'];
		else
			$prestation_motif = '';
		$presta_id 			= $_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;

		if( $presta_Hdeb != $_POST['presta_Hdeb_Old'] OR $_POST['salarie_id_Old'] != $salarie_id  OR $_POST['date_presta'] != $_POST['presta_date_debut'] OR $presta_Hduree != $_POST['presta_Hduree_Old'] )
		{

		$q = dbi_query("SELECT * FROM PRESTATIONS WHERE  presta_id = ".$presta_id) ;
		$prest = dbi_fetch_row($q);
		$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$presta_id." order by start, modif_id ") ;
		while (($m = dbi_fetch_row($q1)) && $presta_date_debut >= $m['start'])
		{
			$prest['presta_sem'] = $m['presta_sem'] === NULL ? $prest['presta_sem'] : $m['presta_sem'] ;
			$prest['presta_jour'] = $m['presta_jour'] === NULL ? $prest['presta_jour'] : $m['presta_jour'] ;
			$prest['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $prest['presta_Hdeb'] : $m['presta_Hdeb'] ;
			$prest['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $prest['presta_Hduree'] : $m['presta_Hduree'] ;
			$prest['salarie_id'] = $m['salarie_id'] === NULL ? $prest['salarie_id'] : $m['salarie_id'] ;
			$prest['chantier_id'] = $m['chantier_id'] === NULL ? $prest['chantier_id'] : $m['chantier_id'] ;
			$prest['presta_forfait'] = $m['presta_forfait'] === NULL ? $prest['presta_forfait'] : $m['presta_forfait'] ;
		}
		$facture = $ad = $ded = 0;
		$presta_Hduree_Old = 0;

		if($_POST['facture'] ==  1 )
		{
				// echo $presta_Hduree.' $$ '.$_POST['presta_Hduree_Old'] ;
				$facture = 1;
				if($presta_Hduree > $prest['presta_Hduree']  )
				{
					$ad = 1;
					$presta_Hduree_Old = $presta_Hduree - $prest['presta_Hduree']  ;
				}
				elseif($presta_Hduree < $prest['presta_Hduree']  )
				{
					$ded = 1;
					$presta_Hduree_Old = $prest['presta_Hduree'] - $presta_Hduree ;
				}

		}
		if( $prest['presta_recur']  == NULL )
		{
				$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,presta_recur,prestation_motif)
						 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,$presta_id,'$prestation_motif')";
				dbi_query($sql);
				$last_id = mysqli_insert_id($conn);
				dbi_query("INSERT INTO EXCEPTIONS(presta_id, date_presta, new_presta_id,facture,ad,ded,en_cours,Hduree) VALUES (".$presta_id.", ".dateformaint($_POST['date_presta']).", ".$last_id.", '".$facture."', '".$ad."', '".$ded."','1' ,'".$presta_Hduree_Old."')") ;
		}
		else
		{
			dbi_query(" UPDATE PRESTATIONS SET prestation_motif = '$prestation_motif' ,salarie_id = '$salarie_id',presta_date_debut = '$presta_date_debut',presta_date_fin = '$presta_date_fin',presta_jour = '$presta_jour',presta_Hdeb=$presta_Hdeb,presta_Hduree=$presta_Hduree,presta_forfait=$presta_forfait,presta_sem=$presta_sem WHERE presta_id = ".$_POST['presta_id']."  ");
			dbi_query(" UPDATE EXCEPTIONS SET date_presta = ".dateformaint($_POST['date_presta'])." ,facture = '".$facture."',ad = '".$ad."',ded = '".$ded."',Hduree = '".$presta_Hduree_Old."' WHERE new_presta_id = ".$_POST['presta_id']." ");
		// echo " UPDATE EXCEPTIONS SET date_presta = ".dateformaint($_POST['date_presta'])." ,facture = '".$facture."',ad = '".$ad."',ded = '".$ded."',Hduree = '".$presta_Hduree_Old."' WHERE new_presta_id = ".$_POST['presta_id']." ";
		}




	// echo ' $$$$$$$$$ '.$sql;
			// $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;

				// echo "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,en_cours) VALUES (".$_POST['presta_id'].", ".dateformaint($_POST['date_presta']).",NULL,'".$presta_id_old."','".$last_id_EXP."','1' )") ;
				// 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." )") ;


		}
		else
		$erreur = 3;
// ?date=2021-02-01&salarie_id=2543

 $salarie_id = $_POST['salarie_id_Old'] ; 

		header('Location:calendar2.php?msg=upt&salarie_id='.$salarie_id.'&date='.$_POST['presta_date_debut'].' ');


	}
 // if(isset($_POST['UptPrDate']))
	// {

		// $new_presta_id 			= $_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;
		// if( $presta_Hdeb != $_POST['presta_Hdeb_Old'] OR $_POST['salarie_id_Old'] != $salarie_id  OR $_POST['date_presta'] != $_POST['presta_date_debut'] OR $presta_Hduree != $_POST['presta_Hduree_Old'] )
		// {
			// $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,new_presta_id,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,$new_presta_id,$prestation_type)";
			// dbi_query($sql);
			// dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id) VALUES (".$_POST['presta_id'].", ".dateformaint($_POST['date_presta']).", LAST_INSERT_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");
	// $facture = '';
	// if($_POST['facture']) $facture = 1;
	// dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture) VALUES (".$_POST['presta_id'].", ".dateformaint($_POST['date_presta']).", NULL,'".$facture."' )") ;

	header('Location:calendar2.php?msg=del&salarie_id='.$_POST['salarie_id'].'&date='.$_POST['date_presta'].' ');
	}

// echo date('Ymd');
$salarie_id = 2557;
$annee = $year = date('Y');
$mois = $month = date('m');


$months = array(
     1 => 'Janvier',
     2 => 'Février',
     3 => 'Mars',
     4 => 'Avril',
     5 => 'Mai',
     6 => 'Juin',
     7 => 'Juillet',
     8 => 'Août',
     9=> 'Septembre',
    10=> 'Octobre',
    11 => 'Novembre',
    12 => 'Décembre'
);

if(isset($_GET['salarie_id']))
	$salarie_id = $_GET['salarie_id'];
if(isset($_POST['salarie_id']))
	$salarie_id = $_POST['salarie_id'];


 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');


$annee = $year;
$mois = $month ;
 }
else
	$datecal = date('Y-m-01');




if(isset($_POST['mois']) && isset($_POST['annee'])){
	$datecal = $_POST['annee'].'-'.$_POST['mois'].'-01';
	$annee = $_POST['annee'];
	$mois = $_POST['mois'];
}

function GET_type_pre ($name = '', $param = '',$value =1)
{
	if(!is_array($value))
		$value = array($value) ;
	$tab = array(10 => 'Viste medicale', 11 => 'Entretien',  12 => 'Autre ');
	$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>" ;
}
$TMCPROCLIENTID = 10824;
$TMCPROCHANTIER_ID = 4360;
?>
<!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">
      <style>
.myCollapse {
    display: none;
}
.myCollapse.in {
    display: block;
}
  .modal-header {
    padding: 15px;
    border-bottom: 1px solid #e5e5e5;
}
  .modal-header {
    background: #226faa;
    background: -webkit-gradient(linear,left top,right top,from(#226faa),color-stop(37%,#2989d8),to(#72c0d3));
    background: linear-gradient(to right,#226faa 0,#2989d8 37%,#72c0d3 100%);
    border-radius: 6px;
    color: #fff;
    padding: 18px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-color: transparent;
}

.modal-header .close {
    margin-top: -3px;
    font-size: 24px;
    font-weight: 400;
    color: #fff;
    opacity: .9;
    width: 28px;
    height: 28px;
    padding-bottom: 0;
    padding-left: 1px;
}
button.close {
    padding: 0;
    cursor: pointer;
    background: 0 0;
    border: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}


;

.bright {
  color: orange;
  font-family: Avenir;
}


.btn-rose {
  color: #FFFFFF ;
  background-color: #FF33AC;
  border-color: #FF33AC;
}


.btn-livraison {
  color: #FFFFFF ;
  background-color: #C0392B;
  border-color: #C0392B;
}

.btn-controle {
  color: #FFFFFF ;
  background-color: #8E44AD;
  border-color: #8E44AD;
}

.btn-RDV_Propsect {
  color: #FFFFFF ;
  background-color: #0AF3D7;
  border-color: #0AF3D7;
}
.btn-Mise_Place {
  color: #FFFFFF ;
  background-color: #FFA07A;
  border-color: #FFA07A;
}

.btn-Briefing {
  color: #FFFFFF ;
  background-color: #A9CCE3;
  border-color: #A9CCE3;
}


.btn-ponc {
  color: #007bff ;
  background-color: #FFFFFF;
  border-color: #007bff;
}
  </style>
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
<!-- TOP MENU -->
  <nav class="main-header navbar navbar-expand navbar-white navbar-light">
    <ul class="navbar-nav">
		<li class="nav-item">
			<a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
		</li>
		<li>
            <h3><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-nouvelleprestation"><i class="fas fa-plus"></i> TEMPS REGULIER PAYE </button></h3>
		</li>
		&nbsp
		<li>
            <h3><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-nouvelleprestationpoctuelle"><i class="fas fa-plus"></i> TEMPS PONCTUEL PAYE  </button></h3>
		</li>
		&nbsp
		<li>
            <h3><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-livraison"><i class="fas fa-plus"></i> LIVRAISON  </button></h3>
		</li>
        	&nbsp
		<li>
            <h3><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal-controle"><i class="fas fa-plus"></i> CONTRÔLE  </button></h3>
		</li>
        	&nbsp
	   <li>
		  <h3><a href="#myModal_tache_all"  id="custId" data-toggle="modal" >   <button type="button"  class="btn btn-primary" > NOUVELLE TACHE</button> </a></h3>
		</li>

    </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 -->

<?php include('menu.php'); ?>
<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="modal fade" id="myModal_tache_all" 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_tache_all" ></div>


        </div>
    </div>
</div>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
		<?php //echo " +++++++++++++ ".$salarie_id;?>
			<div class="modal fade" id="modal-nouvelleprestationpoctuelle">
				<div class="modal-dialog modal-lg">
				  <div class="modal-content">
					<div class="modal-header">
					  <h4 class="modal-title">TEMPS PAYE PONCTUEL </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="salarie_iid" name="salarie_iid" value="<?php echo $salarie_id ;?>"/>
									<input type="hidden" id="client_id" name="client_id" value="<?php echo $TMCPROCLIENTID ;?>"/>
									<input type="hidden" id="chantier_id" name="chantier_id" value="<?php echo $TMCPROCHANTIER_ID ;?>"/>
									<div class="form-row">

										<div class="form-group col-md-4">
											<label>Date</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 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= "" required>
										</div>

										<div class="form-group col-md-4">
										  <label for="inputsociete">Heure  fin</label>
										  <input type="time" id="appt"  min="05:00" max="22:00" class="form-control" name="presta_Hfin"  value= ""  required>
										</div>

										<div class="form-group col-md-4">
											<label for="inputsociete">Motif</label>
											 <input type="text" id="prestation_motif"  class="form-control" name="prestation_motif"  value= ""  required>
										</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="InsPrPonct" class="btn btn-primary">Enregistrer</button>
								</form>
					</div>
			  </div>
			  <!-- /.modal-content -->
				</div>
			<!-- /.modal-dialog -->
			</div>





            <div class="modal fade" id="modal-livraison">
				<div class="modal-dialog modal-lg">
				  <div class="modal-content">
					<div class="modal-header">
					  <h4 class="modal-title">Livraison </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="salarie_iid" name="salarie_iid" value="<?php echo $salarie_id ;?>"/>
									<input type="hidden" id="chantier_id" name="chantier_id" value="<?php echo $TMCPROCHANTIER_ID ;?>"/>
									<input type="hidden" id="livraison" name="livraison" value="1"/>
									<div class="form-row">

										<div class="form-group col-md-4">
											<label>Date</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-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= "" 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= ""  required>
										</div>

										 <div class="col-sm-4">
										  <div class="form-group">
											<label>Client</label>
											<select class="form-control select2" style="width: 100%;" name="client_id" id="client_id">
												<?php   $req =dbi_query("SELECT *  FROM `client` WHERE `client_statut` = '1'  ORDER BY `client`.`client_nom` ASC") ;
														while(  $sal=dbi_fetch_row($req)) { ?>
														<option value="<?php echo $sal['client_id'] ; ?>"  <?php if($sal['client_id'] == $salarie_id) echo "selected"; ?>><?php echo $sal['client_nom']; ?></option>
												<?php   }	?>
											</select>
										  </div>
										</div>


										<div class="form-group col-md-12">
										  <label for="inputsociete">Information</label>
										  <input type="text" class="form-control" name="information"  value= ""  required>
										</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="InsPrPonct" class="btn btn-primary">Enregistrer</button>
								</form>
					</div>
			  </div>
			  <!-- /.modal-content -->
				</div>
			<!-- /.modal-dialog -->
			</div>




            <div class="modal fade" id="modal-controle">
				<div class="modal-dialog modal-lg">
				  <div class="modal-content">
					<div class="modal-header">
					  <h4 class="modal-title">Contrôle </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="salarie_iid" name="salarie_iid" value="<?php echo $salarie_id ;?>"/>
									<input type="hidden" id="chantier_id" name="chantier_id" value="<?php echo $TMCPROCHANTIER_ID ;?>"/>
									<input type="hidden" id="controle" name="controle" value="1"/>
									<div class="form-row">

										<div class="form-group col-md-4">
											<label>Date</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-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= "" 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= ""  required>
										</div>

										 <div class="col-sm-4">
										  <div class="form-group">
											<label>Client</label>
											<select class="form-control select2" style="width: 100%;" name="client_id" id="client_id">
												<?php   $req =dbi_query("SELECT *  FROM `client` WHERE `client_statut` = '1'  ORDER BY `client`.`client_nom` ASC") ;
														while(  $sal=dbi_fetch_row($req)) { ?>
														<option value="<?php echo $sal['client_id'] ; ?>"  <?php if($sal['client_id'] == $salarie_id) echo "selected"; ?>><?php echo $sal['client_nom']; ?></option>
												<?php   }	?>
											</select>
										  </div>
										</div>


										<div class="form-group col-md-12">
										  <label for="inputsociete">Information</label>
										  <input type="text" class="form-control" name="information"  value= ""  required>
										</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="InsPrPonct" class="btn btn-primary">Enregistrer</button>
								</form>
					</div>
			  </div>
			  <!-- /.modal-content -->
				</div>
			<!-- /.modal-dialog -->
			</div>








          <div class="modal fade" id="modal-RDV_Propsect">
				<div class="modal-dialog modal-lg">
				  <div class="modal-content">
					<div class="modal-header">
					  <h4 class="modal-title">RDV Propsect </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="salarie_iid" name="salarie_iid" value="<?php echo $salarie_id ;?>"/>
									<input type="hidden" id="chantier_id" name="chantier_id" value="<?php echo $TMCPROCHANTIER_ID ;?>"/>
									<input type="hidden" id="RDV_Propsect" name="RDV_Propsect" value="8"/>
									<div class="form-row">

										<div class="form-group col-md-4">
											<label>Date</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-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= "" 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= ""  required>
										</div>

										 <div class="col-sm-4">
										  <div class="form-group">
											<label>Client</label>
											<select class="form-control select2" style="width: 100%;" name="client_id" id="client_id">
												<?php   $req =dbi_query("SELECT *  FROM `client` WHERE `client_statut` = '1'  ORDER BY `client`.`client_nom` ASC") ;
														while(  $sal=dbi_fetch_row($req)) { ?>
														<option value="<?php echo $sal['client_id'] ; ?>"  <?php if($sal['client_id'] == $salarie_id) echo "selected"; ?>><?php echo $sal['client_nom']; ?></option>
												<?php   }	?>
											</select>
										  </div>
										</div>


										<div class="form-group col-md-12">
										  <label for="inputsociete">Information</label>
										  <input type="text" class="form-control" name="information"  value= ""  required>
										</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="InsPrPonct" class="btn btn-primary">Enregistrer</button>
								</form>
					</div>
			  </div>
			  <!-- /.modal-content -->
				</div>
			<!-- /.modal-dialog -->
			</div>


  <div class="modal fade" id="modal-Mise_Place">
				<div class="modal-dialog modal-lg">
				  <div class="modal-content">
					<div class="modal-header">
					  <h4 class="modal-title">Mise en Place </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="salarie_iid" name="salarie_iid" value="<?php echo $salarie_id ;?>"/>
									<input type="hidden" id="chantier_id" name="chantier_id" value="<?php echo $TMCPROCHANTIER_ID ;?>"/>
									<input type="hidden" id="Mise_Place" name="Mise_Place" value="8"/>
									<div class="form-row">

										<div class="form-group col-md-4">
											<label>Date</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-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= "" 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= ""  required>
										</div>

										 <div class="col-sm-4">
										  <div class="form-group">
											<label>Client</label>
											<select class="form-control select2" style="width: 100%;" name="client_id" id="client_id">
												<?php   $req =dbi_query("SELECT *  FROM `client` WHERE `client_statut` = '1'   ORDER BY `client`.`client_nom` ASC") ;
														while(  $sal=dbi_fetch_row($req)) { ?>
														<option value="<?php echo $sal['client_id'] ; ?>"  <?php if($sal['client_id'] == $salarie_id) echo "selected"; ?>><?php echo $sal['client_nom']; ?></option>
												<?php   }	?>
											</select>
										  </div>
										</div>


										<div class="form-group col-md-12">
										  <label for="inputsociete">Information</label>
										  <input type="text" class="form-control" name="information"  value= ""  required>
										</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="InsPrPonct" class="btn btn-primary">Enregistrer</button>
								</form>
					</div>
			  </div>
			  <!-- /.modal-content -->
				</div>
			<!-- /.modal-dialog -->
			</div>


<div class="modal fade" id="modal-Briefing">
				<div class="modal-dialog modal-lg">
				  <div class="modal-content">
					<div class="modal-header">
					  <h4 class="modal-title">Briefing </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="salarie_iid" name="salarie_iid" value="<?php echo $salarie_id ;?>"/>
									<input type="hidden" id="chantier_id" name="chantier_id" value="<?php echo $TMCPROCHANTIER_ID ;?>"/>
									<input type="hidden" id="Briefing" name="Briefing" value="8"/>
									<div class="form-row">

										<div class="form-group col-md-4">
											<label>Date</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-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= "" 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= ""  required>
										</div>

										 <div class="col-sm-4">
										  <div class="form-group">
											<label>Client</label>
											<select class="form-control select2" style="width: 100%;" name="client_id" id="client_id">
												<?php   $req =dbi_query("SELECT *  FROM `client` WHERE `client_statut` = '1'   ORDER BY `client`.`client_nom` ASC") ;
														while(  $sal=dbi_fetch_row($req)) { ?>
														<option value="<?php echo $sal['client_id'] ; ?>"  <?php if($sal['client_id'] == $salarie_id) echo "selected"; ?>><?php echo $sal['client_nom']; ?></option>
												<?php   }	?>
											</select>
										  </div>
										</div>


										<div class="form-group col-md-12">
										  <label for="inputsociete">Information</label>
										  <input type="text" class="form-control" name="information"  value= ""  required>
										</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="InsPrPonct" class="btn btn-primary">Enregistrer</button>
								</form>
					</div>
			  </div>
			  <!-- /.modal-content -->
				</div>
			<!-- /.modal-dialog -->
			</div>





			<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">TEMPS REGULIER PAYE</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="salarie_iid" name="salarie_iid" value="<?php echo $salarie_id ;?>"/>
									<input type="hidden" id="client_id" name="client_id" value="<?php echo $TMCPROCLIENTID ;?>"/>
									<input type="hidden" id="chantier_id" name="chantier_id" value="<?php echo $TMCPROCHANTIER_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 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= "" required>
										</div>

										<div class="form-group col-md-4">
										  <label for="inputsociete">Heure  fin</label>
										  <input type="time" id="appt"  min="05:00" max="22:00" class="form-control" name="presta_Hfin"  value= ""  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">
											<label for="inputsociete">Motif</label>
											 <input type="text" id="prestation_motif"  class="form-control" name="prestation_motif"  value= ""  required>
										</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="col-sm-6">
            <ol class="breadcrumb float-sm-right">

            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>


    <!-- Main content -->
    <section class="content">
	   					  		  <?php

								  			      if(isset($_GET["msg"])&& $_GET["page"] == 'tache'){
        ?>
        <div class="alert alert-<?php echo $_GET["color"]; ?>  alert-dismissible col-12" role="alert">
          <strong><?php echo $_GET["color"].': '; ?></strong><?php echo $_GET["msg"]; ?>.
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <?php
		// exit();
        }



			      if(isset($erreur) && $erreur == 3){
        ?>
        <div class="alert alert-danger  alert-dismissible col-12" role="alert">
          <strong>attention : </strong>Aucune modification n'a été apportée à la prestation .
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <?php
        }
       ?>
      <div class="container-fluid">

	    <?php
			 if(isset($_GET["msg"]) && $_GET["msg"] == 'upt'){
        ?>
        <div class="alert alert-success alert-dismissible col-12" role="alert">
          <strong>Success:</strong>Préstation bien modifier.
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <?php
		} elseif(isset($_GET["msg"]) && $_GET["msg"] == 'del'){
        ?>
        <div class="alert alert-success alert-dismissible col-12" role="alert">
          <strong>Success:</strong>Préstation bien supprimer.
          <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <?php
		}


        ?>



					                   <script language="Javascript">
										   function GetIdBureauB()
										   {
												var id_etab="";
											  id_etab = document.client_statu_form.client_etab.value ;
											if( id_etab > 0 || id_etab=="INDEFINI" )
											  window.location = "calendar2.php?id_etab="+id_etab;
												else
											window.location = "calendar2.php";
										   }
										</script>
										<?php
										$_SESSION["id_etab"]= 111 ;

										// if(!empty( $_POST))
										// {

                                        // echo "<pre>" ;
										// print_r($_POST) ;
										// echo "<pre>" ;
										// }


										if(!empty( $_POST["etab"]))
										{
										$_SESSION["id_etab"] = $_POST["etab"];
										}
										 // $id_etab=  $_SESSION["id_etab"] ;
										// echo "==> ".$_POST["etab"]."<br/>" ;

                                     if($_SESSION["id_etab"]== 111){
											$where_etablissement_id="" ;
										}
										else{
										$where_etablissement_id = " AND etablissement_id = ".$_SESSION["id_etab"] ;
										}
										?>


        <div class="row">

          <div class="col-lg-12">
            <div class="card">


              <div class="card-body">

				<form id="client_statu_form" name="client_statu_form" method="POST"  action="">
			    <div class="row">


				  <div class="form-group col-md-3">
				  <label>Etablissementss</label>
								  <div class="input-group">
									<?php  $qa = dbi_query("SELECT * FROM `etablissement`") ;  ?>
								<select class="form-control select" style="width: 100%;" id="etab" name="etab"  >



									<option value="1"  <?php if($_SESSION["id_etab"]== 1 ){echo "selected"  ;} ?>  >PARIS</option>
									<option value="2"  <?php if($_SESSION["id_etab"]== 2 ){echo "selected"  ;} ?>  >MARSEILLE</option>
									<option value="3"  <?php if($_SESSION["id_etab"]== 3 ){echo "selected"  ;} ?>  >SIX FOURS</option>

									<option value="111" <?php if($_SESSION["id_etab"]== 111 ){echo "selected"  ;} ?>  >Tous les Etablissements</option>
								</select>







									</div>
								</div>



				<?php
				// echo "SELECT * FROM salarie  WHERE salarie_statut = '1' $where_etablissement_id  ORDER BY salarie_nom ASC" ;
				$_SESSION['page_name_return']= basename($_SERVER['PHP_SELF']);
				$_SESSION['salarie_name_return']=  $salarie_id;
				?>

                    <div class="col-sm-4">
                      <div class="form-group">
                        <label>Salarié</label>
						<select class="form-control select2" style="width: 100%;" name="salarie_id" id="salarie_id">
							<?php   $req =dbi_query("SELECT * FROM salarie  WHERE salarie_statut = '1' $where_etablissement_id  ORDER BY salarie_nom ASC") ;
									while(  $sal=dbi_fetch_row($req)) { ?>
									<option value="<?php echo $sal['salarie_id'] ; ?>"  <?php if($sal['salarie_id'] == $salarie_id) echo "selected"; ?>><?php echo $sal['salarie_id'].' '.$sal['salarie_nom']." ".$sal['salarie_prenom']; ?></option>
							<?php   }	?>
						</select>
                      </div>
                    </div>
                    <div class="col-sm-2">
                      <div class="form-group">
                        <label>Année</label>
                        <select name='annee' id='annee' class="form-control">
						<?php
							$earliest_year = 2018;
							foreach (range($year+3, $earliest_year) as $x) {
								print '<option value="'.$x.'"'.($x == $annee ? ' selected="selected"' : '').'>'.$x.'</option>';
							}
						?>
                        </select>
                      </div>
                    </div>
                    <div class="col-sm-3">
                      <div class="form-group">
                        <label>Mois</label>
                        <select name='mois' id='mois' class="form-control">
						<?php
						foreach ($months as $key => $value) {
							$key  = sprintf("%02d",$key );
							print '<option value="'.$key.'"'.($key == $mois ? ' selected="selected"' : '').'>'.$value.'</option>';
						}
						?>
                        </select>
                      </div>
                    </div>
                </div>
				<input name="date" type ="hidden" value='<?php echo $datecal; ?>' />
				</form>

                <div class="d-flex flex-row justify-content-end">





				   <button type="button" class="btn-xs btn-primary" >Nettoyage courant régulier  </button> &nbsp;
				   <button type="button" class="btn-xs btn-ponc" >Nettoyage courant ponctuel  </button> &nbsp;
				   <button type="button" class="btn-xs btn-success" >Prestation de Vitrerie  </button> &nbsp;
				  <button type="button" class="btn-xs btn-warning" >Shampoing Moquette  </button> &nbsp;
				  <button type="button" class=" btn-xs btn-rose" >Autre prestation spécifique </button> &nbsp;
				  <button type="button" class="btn-xs btn-secondary" >ABSENCES </button> &nbsp;
				  <button type="button" class=" btn-xs btn-livraison" data-toggle="modal" data-target="#modal-livraison">Livraison  </button> &nbsp;
				  <button type="button" class=" btn-xs btn-controle" data-toggle="modal" data-target="#modal-controle">RDV Client / Contrôle  </button> &nbsp;
				  
				  <button type="button" class=" btn-xs btn-RDV_Propsect " data-toggle="modal" data-target="#modal-RDV_Propsect">RDV Propsect  </button> &nbsp;
				  <button type="button" class=" btn-xs btn-Mise_Place" data-toggle="modal" data-target="#modal-Mise_Place">Mise en Place </button> &nbsp;
				  <button type="button" class=" btn-xs btn-Briefing" data-toggle="modal" data-target="#modal-Briefing">Doublon / Briefing  </button>
                </div>
              </div>
            </div>
            <!-- /.card -->


          </div>
          <!-- /.col-md-6 -->
		  <?php


		  						if(isset($_POST['mois']) && isset($_POST['annee']))
					{
						$crdebut = $_POST['annee'].'-'.$_POST['mois'].'-01';
						$annee = $_POST['annee'];
						$mois = $_POST['mois'];
					}
						elseif(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  )
							$crdebut = "$year-$month-01";
						else
							$crdebut = date('Y-m-01');
					}
					else
					$crdebut = date('Y-m-01');
					$ctend = date("Y-m-t", strtotime($crdebut));
		  ?>

          <!-- /.col -->
          <div class="col-md-12">
            <div class="card card-primary">




              <div class="card-body p-0">
                <!-- THE CALENDAR -->
                <div id="calendar"></div>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->

  <div class="col-md-12">
            <!-- TABLE: LATEST ORDERS -->
            <div class="card">
              <div class="card-header border-transparent">

                <div class="card-tools">
                  <button type="button" class="btn btn-tool" data-card-widget="collapse">
                    <i class="fas fa-minus"></i>
                  </button>

                </div>
              </div>
              <!-- /.card-header -->
              <div class="card-body p-0">

			  <?php
					// $ctdata = array();
					// $ctnow = new DateTime();
					// $ctstart = dateformaint($datecal) ;
					// $ctend = dateformaint(date("Ymt", strtotime($datecal )));
					// $end = time2int($debut+6*24*3600+3600) ;

				    // $salarie_id = $_POST['salarie_id'];
// echo $_POST['annee'];









					// $crdebut = strtotime("+7 day", $crdebut);
					// $week_start = date("Y-m-d", strtotime('monday this week', strtotime($crdebut)));
					// $week_end = date("Y-m-d", strtotime('sunday this week', strtotime($crdebut)));
					// echo $week_start .' **** '.$week_end .'<br>' ;
					// $crdebut = $ctstart ;
						// for ($i = 0 ; $crdebut <= $ctend ; $i++)
					// {



						// $crdebut = int2time($crdebut) ;
						// $ctend = time2int($crdebut + (8-(date("w", $crdebut) ? date("w", $crdebut) : 7))*24*3600+3600) ;




					// $date = '2020-12-12'; // monday
					// echo date("Y-m-d", strtotime('monday this week', strtotime($date))), "\n";
					// echo date("Y-m-d", strtotime('sunday this week', strtotime($date))), "\n";
					// $day = date('w');
					// $week_start = date('m-d-Y', strtotime('-'.$day.' days'));
					// $week_end = date('m-d-Y', strtotime('+'.(6-$day).' days'));


					// $crdebut = int2time($crdebut) ;
			// debut de la semaine suivante
					// $crdebut = time2int($crdebut + 7)*24*3600+3600 ;
					// $crdebut = int2time($crdebut) ;
					// $crdebut = time2int($crdebut );

					// echo date('Y-m-d', strtotime('Monday next week 2012-04-01'));
					// echo date('Y-m-d', strtotime('next Monday 2012-04-01'));
					// echo date('Y-m-d',$crdebut+( 0 - date('w'))*24*3600).' === ';



					// echo date('Y-m-d',$crdebut+( 8 - date('w'))*24*3600);
					// echo '</br>'.$crdebut ;
					// }

			  ?>
                <div class="table-responsive">
                  <table class="table m-0">
                    <thead>
                    <tr>
                      <th>Période</th>
                      <th>Contrat</th>
					  <th>ACH</th>
					  <th>Absences</th>
                      <th>Travaillées</th>
					  <th>Ecart</th>


                    </tr>
                    </thead>
                    <tbody>
					<?php
					
					echo "===>".$crdebut."<====>".$ctend."<br/>" ; 
					while ($crdebut <= $ctend )
					{
						$week_start = date("Ymd", strtotime('monday this week', strtotime($crdebut)));
						$week_end = date("Ymd", strtotime('sunday this week', strtotime($crdebut)));
						// echo $week_start .' **** '.$week_end .'<br>' ;
						$crdebut = date('Y-m-d', strtotime('+1 week', strtotime($crdebut)));
						// $sql2="SELECT contrat_heure  FROM ".TABLE_CONTRAT." WHERE inter_id = ".$salarie_id."  AND contrat_debut<=".dateformaint($crdebut)." AND ( contrat_fin IS NULL OR contrat_fin >".dateformaint($crdebut)." ) AND Contrat_type_ID = 12 ORDER BY contrat_id DESC";
						// $sql2 = "SELECT contrat_heure FROM ".TABLE_CONTRAT." WHERE contrat_debut <= $week_start  AND (contrat_fin IS NULL OR contrat_fin > $week_start OR contrat_fin=0) AND inter_id = $salarie_id ORDER BY contrat_debut DESC LIMIT 1" ;
						$sql2 = " SELECT salarie_contrat_duree_mensuelle  FROM `salarie_contrat`   WHERE salarie_contrat_date_debut <= $week_start  AND  (salarie_contrat_date_fin IS NULL OR salarie_contrat_date_fin > $week_start OR salarie_contrat_date_fin=0) AND  salarie_id = $salarie_id AND contrat_type_id NOT IN(10, 11) ORDER BY salarie_contrat_date_debut DESC LIMIT 1  " ;

						$sql22 = " SELECT hebdo_moyen_complement  FROM `salarie_contrat`
						WHERE

						salarie_id = $salarie_id AND contrat_type_id IN(10, 11)
						AND
						(
							( salarie_contrat_date_debut between $week_start  AND $week_end )
							OR
							( salarie_contrat_date_fin between $week_start  AND $week_end )
							OR
							( salarie_contrat_date_fin  >= $week_end AND salarie_contrat_date_debut <= $week_start  )
						)


						ORDER BY salarie_contrat_date_debut DESC LIMIT 1  " ;
						// echo $sql22.'<br>';

						// echo $sql2 ;
						list($heures_contrat_ACH)=dbi_fetch_row(dbi_query($sql2));
						$heures_contrat_ACH= round($heures_contrat_ACH/4.333 , 2);
						list($hebdo_moyen_complement)=dbi_fetch_row(dbi_query($sql22));


						// echo"==> ".$heures_contrat_ACH."<br/>" ;
						// $contrat = dbi_fetch_row(dbi_query("SELECT contrat_heure FROM ".TABLE_CONTRAT." WHERE contrat_debut <= $week_end AND agence_id=$agence AND (contrat_fin IS NULL OR contrat_fin > $week_start OR contrat_fin=0) AND inter_id = $salarie_id AND Contrat_type_ID != 12 ORDER BY contrat_debut DESC LIMIT 1")) ;
						// echo ;
						// echo  ;

						$date =  $week_start ;
						$presta_Hduree = 0;
							while ($date <= $week_end )
						{
							// echo "
							// SELECT * FROM PRESTATIONS p where presta_date_debut <= $date AND (p.presta_date_fin >= $date OR p.presta_date_fin IS NULL)
							// AND ( p.presta_id IN (select presta_id FROM PRESTATIONS WHERE salarie_id = $salarie_id   ) OR p.presta_id IN ( select presta_id FROM PRESTATIONS_MODIF WHERE salarie_id = $salarie_id ) )
							// ";
							$q = dbi_query("
							SELECT * FROM PRESTATIONS p where presta_date_debut <= $date AND (p.presta_date_fin >= $date OR p.presta_date_fin IS NULL)
							AND ( p.presta_id IN (select presta_id FROM PRESTATIONS WHERE salarie_id = $salarie_id   ) OR p.presta_id IN ( select presta_id FROM PRESTATIONS_MODIF WHERE salarie_id = $salarie_id ) )
							AND ( p.presta_recur IS NULL OR p.presta_recur NOT IN ( SELECT presta_id FROM PRESTATIONS where  presta_date_fin < $date ))
							");
								while($prest = dbi_fetch_row($q))
							{
									$date_presta_sem = $prest['presta_date_debut'] ;
									$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$prest['presta_id']." order by start, modif_id ") ;
									while (($m = dbi_fetch_row($q1)) && $date >= $m['start'])
									{
										if( $m['presta_sem'] != NULL ) $date_presta_sem = $m['start'];
										$prest['salarie_id'] = $m['salarie_id'] === NULL ? $prest['salarie_id'] : $m['salarie_id'] ;
										$prest['presta_sem'] = $m['presta_sem'] === NULL ? $prest['presta_sem'] : $m['presta_sem'] ;
										$prest['presta_jour'] = $m['presta_jour'] === NULL ? $prest['presta_jour'] : $m['presta_jour'] ;
										$prest['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $prest['presta_Hduree'] : $m['presta_Hduree'] ;
									}
									if( $prest['salarie_id'] == $salarie_id ) {


										// $nbre =count_week_days(strtotime(int2date_autre_format($date_presta_sem,'d.m.Y')), strtotime(int2date_autre_format($date,'d.m.Y')));
								// echo ' +++++++++++++++ ';
								$day = date("w", strtotime( int2date_autre_format($date)));
								if( $day == $prest['presta_jour'] OR  ( $date == $prest['presta_date_debut'] &&  $prest['presta_date_debut']	== $prest['presta_date_fin'] ) ){

									$EXP = dbi_fetch_row(dbi_query("SELECT date_presta FROM EXCEPTIONS WHERE presta_id = ".$prest['presta_id']." AND date_presta = ".$date." " )) ;	   ;
									if($EXP ){}   else {

									if( $prest['presta_sem'] == 1 )
										$presta_Hduree = $presta_Hduree + 	$prest['presta_Hduree'] ;
									else{
										$nbre =count_week_days(strtotime(int2date_autre_format($date_presta_sem,'d.m.Y')), strtotime(int2date_autre_format($date,'d.m.Y')));
										$modolo = $nbre % $prest['presta_sem'] ;
										if( $modolo == 0)
											$presta_Hduree = $presta_Hduree + 	$prest['presta_Hduree'] ;
									}
									}
									}
								}
							}


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

		// echo " $$$$$$$$$$$ ";
						// $presta_Hduree/= 60;
						$presta_Hduree /= 60 ;
						// $pour $p



						$badge = 'badge-success';
						if($presta_Hduree < ($heures_contrat_ACH + $hebdo_moyen_complement ))
						$badge = 'badge-danger';
						else
						$badge = 'badge-warning';
						// else($presta_Hduree > $heures_contrat_ACH)
						// $badge = 'badge-warning';
						echo
						"<tr>
							<td><b> ".int2date_autre_format($week_start,'d/m/Y')." </b>  au <b> ".int2date_autre_format($week_end,'d/m/Y')." </b> </td>
							<td> <b> ".number_format( $heures_contrat_ACH, 2, ',', ' ')."</b> </td>
							<td> <b> ".number_format( $hebdo_moyen_complement, 2, ',', ' ')."</b> </td>
							";
							$q= dbi_query("SELECT * FROM salarie_absence where salarie_id = '".$salarie_id."' AND ( salarie_absence_date_debut BETWEEN $week_start AND $week_end OR salarie_absence_date_fin BETWEEN $week_start AND $week_end

							OR ( salarie_absence_date_debut  <= $week_start &&  salarie_absence_date_fin  >= $week_end  )


							) " ) ;
							echo "<td>";
							while($cl=dbi_fetch_row($q))
							{
								 list($motif)= dbi_fetch_row(dbi_query("SELECT descr FROM cause_absence where cause_id =".$cl['absence_type_id'])) ;

								$fin = int2date($cl['salarie_absence_date_fin']);
								if( empty($cl["salarie_absence_date_fin"]) OR $cl["salarie_absence_date_fin"] ==0)
									$fin = ' Pas de Date Fin ';
								echo " $motif du <b> ".int2date($cl['salarie_absence_date_debut'])." </b>  au <b> ".$fin." </b> ( de ".$cl['salarie_absence_heure_debut']." á ".$cl['salarie_absence_heure_fin']." ) <br>";
							}
							echo "</td>";
							echo "<td><span class='badge ".$badge."'> ".number_format( $presta_Hduree, 2, ',', ' ')." </span></td>";
							$delta = ($presta_Hduree - $heures_contrat_ACH - $hebdo_moyen_complement );
							echo "<td><b> ".number_format( $delta, 2, ',', ' ')." </b></td>";
						echo "</tr>" ;

							// if($presta_Hduree<$heures_contrat_ACH )
							// {
								// echo "<td><div class='sparkbar' data-color='#FF3355' data-height='20'></div></td>" ;

							// }else
							// {

							// echo "<td><div class='sparkbar' data-color='#00a65a' data-height='20'></div></td>" ;

							// }
						// echo "";
					}
					?>


                    </tbody>
                  </table>
                </div>
                <!-- /.table-responsive -->
              </div>
              <!-- /.card-body -->

              <!-- /.card-footer -->
            </div>
            <!-- /.card -->
          </div>

        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <footer class="main-footer">
    <div class="float-right d-none d-sm-block">
      <b>Version</b> 3.0.2
    </div>
    <strong>Copyright &copy; 2020<a href="http://adminlte.io">TMCPRO</a>.</strong> All rights
    reserved.
  </footer>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- jQuery UI -->
<script src="../plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.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 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: 'splanning2.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();
		//
		datepr = datepr.substr(6, 4)+ '' +datepr.substr(3, 2)+ '' +datepr.substr(0, 2);
		// alert(datepr);
		$.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');
            }
        });
	}


    });
	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 = "calendar2.php?date="+datec+'&salarie_id='+salarie_id;
			}
});
$('.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 = "calendar2.php?date="+datec+'&salarie_id='+salarie_id;
			}
});
$('.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 = "calendar2.php?date="+datec+'&salarie_id='+salarie_id;
			}
});
$('#etab').on('change',function(){
		 $('form').submit();
});
$('#salarie_id').on('change',function(){
		 $('form').submit();
});
$('#annee').on('change',function(){
		 $('form').submit();
});
$('#mois').on('change',function(){
		 $('form').submit();
});
   });


   (function($) {
Drupal.fullcalendar.plugins.fullcalendar_fix = {
  options: function (fullcalendar, settings) {
    return {
      eventRender: function(event, element, view) {
        element.find('span.fc-event-title').html(element.find('span.fc-event-title').text());
      }
    };
  }
};
}(jQuery));
</script>
<script>
  $(function () {
    $('.select2').select2()

    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })

  })
</script>
<script type="text/javascript">
$(document).ready(function(){
    $('#myModal_tache_all').on('show.bs.modal', function (e) {
        var rowid = $(e.relatedTarget).data('id');
        $.ajax({
            type : 'post',
            url : 'tache_ajax_nv_all_pour_page_calendar.php', //Here you will fetch records
            data :  'rowid='+ rowid, //Pass $id
            success : function(data){
            $('#fetch_tache_all').html(data);//Show fetched data from database
            }
        });
     });
});


</script>

</body>
</html>

AnonSec - 2021