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/TEST/www/wp-content/../../../TMCPRO/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/TEST/www/wp-content/../../../TMCPRO/Pres_jours2_new.php
<?php
	// require __DIR__ . '/vendor_sms_recu/autoload.php';
	// include 'includes_sms_recu/ovhhh.php';

include 'includes/config_tmcpro.php' ;
	include 'includes/stable_functions_tmcpro.php' ;
	
	
	
	echo "<pre>" ;
	print_r($_POST) ; 
	echo "</pre>"
	
	
	// print_r($_GET) ; 
	
	function diff_time($t1 , $t2){
     //Heures au format (hh:mm:ss) la plus grande puis le plus petite

       $tab=explode(":", $t1);
       $tab2=explode(":", $t2);

       $h=$tab[0];
       $m=$tab[1];
       $s=$tab[2];
       $h2=$tab2[0];
       $m2=$tab2[1];
       $s2=$tab2[2];

       if ($h2>$h) {
       $h=$h+24;
       }
       if ($m2>$m) {
       $m=$m+60;
       $h2++;
       }
       if ($s2>$s) {
       $s=$s+60;
       $m2++;
       }

       $ht=$h-$h2;
       $mt=$m-$m2;
       $st=$s-$s2;
       if (strlen($ht)==1) {
       $ht="0".$ht;
       }
       if (strlen($mt)==1) {
       $mt="0".$mt;
       }
       if (strlen($st)==1) {
       $st="0".$st;
       }
       return $ht.":".$mt.":".$st;

    }


	
	
	// echo "<pre>" ;
// print_r($_SESSION) ;
// echo "</pre>" ;

// echo "------------------ <br/>" ;


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

	// echo "yyyyyyyyyy <br/>" ;

// if(!empty($_POST) and $_POST['validerr'] == "Valider")
// {
		// echo "<pre>" ; 
	// print_r($_POST) ;
	// echo "</pre>" ; 
	 // echo "test <br/>" ;
	// exit() ; 
// }

if(!empty($_POST) and $_POST['validerr'] == "Valider")
{

	
	if(!empty($_POST["heure_debut_manuel"]) AND !empty($_POST["heure_fin_manuel"]) ){
		
		
		$heure_debut_manuel=$_POST['heure_debut_manuel'].":00" ;
		$heure_fin_manuel=$_POST['heure_fin_manuel'].":00" ;
		
		
		
							                                                                    $durepointage = diff_time($heure_fin_manuel , $heure_debut_manuel)."<br/>";
																								$prestfin = $_POST['pres_heure_fin'].":00" ;
																								$prestdebut= $_POST['pres_heure_debut'].":00" ;
																								$durepresta = diff_time($prestfin , $prestdebut);
																								$a=0 ;
																								
																												$dpoint= mktime($durepointage);
																												$dpre= mktime($durepresta);
																												if($durepresta >= $durepointage)
																												{
																												$ecart = diff_time($durepresta , $durepointage) ;
																												$a= 1 ;
																												$statu_ecart = 1 ;  // ecart négatif
																												}
																												else
																												{
																													// echo "mmm <br/>" ;
																												$ecart = diff_time($durepointage,$durepresta) ;
																												$a=2 ;
																												$statu_ecart = 2  ;// ecart positif
																												}
																								
																								
																								if($ecart == "")
																								{
																									$ecart ="NULL" ;
																									$statu_ecart = 0  ;// ecart positif
																								}
		
		dbi_query("INSERT INTO `pointage_rapport` (`pointage_rapport_id`, `client_id`, `salarie_id`, `pres_heure_debut`, `pres_heure_fin`, `point_heure_debut`, `point_heure_fin`, `ecart`, `prest_id`, `id_pDD`, `id_pFF` , `statu_ecart` , date_pointage) VALUES
	 (NULL, '".$_POST['client_id']."', '".$_POST['salarie_id']."', '".$_POST['pres_heure_debut']."', '".$_POST['pres_heure_fin']."', '".$heure_debut_manuel."', '".$heure_fin_manuel."', '".$ecart."', '".$_POST['presta_iddd']."', '".$id_pDD."', '".$id_pFF."' , '".$statu_ecart."' , '".$_SESSION['datej']."')") ; 
		
		
		// echo "les deux <br/>" ; 
	}
	
	
	
	if(!empty($_POST['point_heure_debut'])){ // dans le cas ou l'utilisateur saisi le pointage de fin
		
		// echo "point_heure_debut <br/>" ;
		
		
		
		$heure_debut_manuel=$_POST['point_heure_debut'].":00" ;
		$heure_fin_manuel=$_POST['heure_fin_manuel'].":00" ;
		
		
		
							                                                                    $durepointage = diff_time($heure_fin_manuel , $heure_debut_manuel)."<br/>";
																								$prestfin = $_POST['pres_heure_fin'].":00" ;
																								$prestdebut= $_POST['pres_heure_debut'].":00" ;
																								$durepresta = diff_time($prestfin , $prestdebut);
																								$a=0 ;
																								
																												$dpoint= mktime($durepointage);
																												$dpre= mktime($durepresta);
																												if($durepresta >= $durepointage)
																												{
																												$ecart = diff_time($durepresta , $durepointage) ;
																												$a= 1 ;
																												$statu_ecart = 1 ;  // ecart négatif
																												}
																												else
																												{
																													// echo "mmm <br/>" ;
																												$ecart = diff_time($durepointage,$durepresta) ;
																												$a=2 ;
																												$statu_ecart = 2  ;// ecart positif
																												}
																								if($ecart == "")
																								{
																									$ecart ="NULL" ;
																									$statu_ecart = 0  ;// ecart positif
																								}
		
		dbi_query("INSERT INTO `pointage_rapport` (`pointage_rapport_id`, `client_id`, `salarie_id`, `pres_heure_debut`, `pres_heure_fin`, `point_heure_debut`, `point_heure_fin`, `ecart`, `prest_id`, `id_pDD`, `id_pFF` , `statu_ecart` , date_pointage) VALUES
	 (NULL, '".$_POST['client_id']."', '".$_POST['salarie_id']."', '".$_POST['pres_heure_debut']."', '".$_POST['pres_heure_fin']."', '".$heure_debut_manuel."', '".$heure_fin_manuel."', '".$ecart."', '".$_POST['presta_iddd']."', '".$id_pDD."', '".$id_pFF."' , '".$statu_ecart."' , '".$_SESSION['datej']."')") ; 

		
		// dbi_query("INSERT INTO `pointage_rapport` (`pointage_rapport_id`, `client_id`, `salarie_id`, `pres_heure_debut`, `pres_heure_fin`, `point_heure_debut`, `point_heure_fin`, `ecart`, `prest_id`, `id_pDD`, `id_pFF` , `statu_ecart`) VALUES
																										// (NULL, '".$prest['client_id']."', '".$prest["salarie_id"]."', '".int2heure($prest['presta_Hdeb'])."', '".int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree']))."', '".$pointage_deb['heure']."', '".$pointage_fin['heure']."', '".$ecart."', '".$prest['presta_id']."', '".$id_pDD."', '".$id_pFF."' , '".$statu_ecart."')") ; 
	}

	if(!empty($_POST['point_heure_fin'])){  // dans le cas ou l'utilisateur saisi le point départ
		
		
		$heure_debut_manuel=$_POST['heure_debut_manuel'].":00" ;
		$heure_fin_manuel=$_POST['point_heure_fin'].":00" ;
		
		
		
							                                                                    $durepointage = diff_time($heure_fin_manuel , $heure_debut_manuel)."<br/>";
																								$prestfin = $_POST['pres_heure_fin'].":00" ;
																								$prestdebut= $_POST['pres_heure_debut'].":00" ;
																								$durepresta = diff_time($prestfin , $prestdebut);
																								$a=0 ;
																								
																												$dpoint= mktime($durepointage);
																												$dpre= mktime($durepresta);

																												if($durepresta >= $durepointage)
																												{
																												$ecart = diff_time($durepresta , $durepointage) ;
																												$a= 1 ;
																												$statu_ecart = 1 ;  // ecart négatif
																												}
																												else
																												{
																												$ecart = diff_time($durepointage,$durepresta) ;
																												$a=2 ;
																												$statu_ecart = 2  ;// ecart positif
																												}
																								
																								
																								if($ecart == "")
																								{
																									$ecart ="NULL" ;
																									$statu_ecart = 0  ;// ecart positif
																								}
		
		dbi_query("INSERT INTO `pointage_rapport` (`pointage_rapport_id`, `client_id`, `salarie_id`, `pres_heure_debut`, `pres_heure_fin`, `point_heure_debut`, `point_heure_fin`, `ecart`, `prest_id`, `id_pDD`, `id_pFF` , `statu_ecart` , date_pointage) VALUES
	 (NULL, '".$_POST['client_id']."', '".$_POST['salarie_id']."', '".$_POST['pres_heure_debut']."', '".$_POST['pres_heure_fin']."', '".$heure_debut_manuel."', '".$heure_fin_manuel."', '".$ecart."', '".$_POST['presta_iddd']."', '".$id_pDD."', '".$id_pFF."' , '".$statu_ecart."' , '".$_SESSION['datej']."')") ; 
		
		
		
		
	}
	
	
	// exit() ; 
	
	 list($tele1,$tele2,$tele3,$tele4,$tele5) = dbi_fetch_row(dbi_query(" SELECT 	tele1,	tele2, tele3 , tele4, tele5  FROM `client` WHERE `client_id` = ".$_POST['client_id'])) ; 
	// echo "aaaa <br/>" ;
	$num_tele = $tele1  ; 
	if($tele1 == ""){
		$num_tele = $tele2 ; } ;
	if($tele1 == "" and $tele2=="" ){$num_tele = $tele3 ; } ;
	if($tele1 == "" and $tele2=="" and $tele3=="" ){$num_tele = $tele4 ;} ;
	if($tele1 == "" and $tele2=="" and $tele3=="" and $tele4=="" ){$num_tele = $tele5 ;} ;
	
	
	
																										
	
	
	
	
	
	if(!empty($_POST["heure_debut_manuel"])){
		// echo "valider debut <br/>" ; 
		// print_r($_POST) ;
	  dbi_query("INSERT INTO `telepointage` (`id_p`, `agence`, `jour`, `heure`, `telephone`, `matricule`, `action`, `test`, `test2`, `client_id`, `pointage_valider`, `presta_id`) VALUES
	  (NULL, '', '".$_SESSION['datej']."', '".$_POST['heure_debut_manuel']."', '".$num_tele."', '".$_POST['salarie_id']."', 'DEBUT', NULL, NULL, '".$_POST['client_id']."', '1', '".$_POST['presta_iddd']."')");
	}

	if(!empty($_POST["heure_fin_manuel"])){
		
		  dbi_query("INSERT INTO `telepointage` (`id_p`, `agence`, `jour`, `heure`, `telephone`, `matricule`, `action`, `test`, `test2`, `client_id`, `pointage_valider`, `presta_id`) VALUES
	  (NULL, '', '".$_SESSION['datej']."', '".$_POST['heure_fin_manuel']."', '".$num_tele."', '".$_POST['salarie_id']."', 'FIN', NULL, NULL, '".$_POST['client_id']."', '1', '".$_POST['presta_iddd']."')");
	
	}
	
	if(!empty($_POST["deux_prest_par_jour"])){
		
		
				list($heure_debut_manuel)=  dbi_fetch_row(dbi_query("SELECT heure FROM `telepointage` WHERE `id_p` = ".$_POST['id_p_debut']));
		       list( $heure_fin_manuel)=    dbi_fetch_row(dbi_query("SELECT heure FROM `telepointage` WHERE `id_p` = ".$_POST['id_p_fin']));
		
		
		
							                                                                    $durepointage = diff_time($heure_fin_manuel , $heure_debut_manuel)."<br/>";
																								$prestfin = $_POST['pres_heure_fin'].":00" ;
																								$prestdebut= $_POST['pres_heure_debut'].":00" ;
																								$durepresta = diff_time($prestfin , $prestdebut);
																								$a=0 ;
																								
																												$dpoint= mktime($durepointage);
																												$dpre= mktime($durepresta);
																												if($durepresta >= $durepointage)
																												{
																												$ecart = diff_time($durepresta , $durepointage) ;
																												$a= 1 ;
																												$statu_ecart = 1 ;  // ecart négatif
																												}
																												else
																												{
																													// echo "mmm <br/>" ;
																												$ecart = diff_time($durepointage,$durepresta) ;
																												$a=2 ;
																												$statu_ecart = 2  ;// ecart positif
																												}
																								
																								
																								if($ecart == "")
																								{
																									$ecart ="NULL" ;
																									$statu_ecart = 0  ;// ecart positif
																								}
		
		dbi_query("INSERT INTO `pointage_rapport` (`pointage_rapport_id`, `client_id`, `salarie_id`, `pres_heure_debut`, `pres_heure_fin`, `point_heure_debut`, `point_heure_fin`, `ecart`, `prest_id`, `id_pDD`, `id_pFF` , `statu_ecart` , date_pointage) VALUES 
	 (NULL, '".$_POST['client_id']."', '".$_POST['salarie_id']."', '".$_POST['pres_heure_debut']."', '".$_POST['pres_heure_fin']."', '".$heure_debut_manuel."', '".$heure_fin_manuel."', '".$ecart."', '".$_POST['presta_iddd']."', '".$id_pDD."', '".$id_pFF."' , '".$statu_ecart."' , '".$_SESSION['datej']."')") ; 
		
		
	dbi_query(" UPDATE `telepointage`  SET `pointage_valider` = '1' ,  presta_id =".$_POST['presta_iddd']." WHERE `telepointage`.`id_p` = ".$_POST['id_p_debut']." and action LIKE 'DEBUT' ") ;
	dbi_query(" UPDATE `telepointage` SET `pointage_valider` = '1' ,  presta_id =".$_POST['presta_iddd']." WHERE `telepointage`.`id_p` = ".$_POST['id_p_fin']." and action LIKE 'FIN' ") ;
	}
	// exit() ; 
}


session_start();
// $a= gmdate("01:00:00", s);
//l echo "==> $a <br/>" ;
// exit(l)l ;



										$_SESSION["id_etab"]= 111 ;



										if(!empty( $_GET["id_etab"]))
										{
										$_SESSION["id_etab"] = $_GET["id_etab"];
										}


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


if(empty($_SESSION['datej'])){$_SESSION['datej'] = date('Ymd');}


// exit() ; // $date_jour = date('Ymd');
// echo int2date($date_jour );

if(isset($_GET['date_j']))
{
	$_SESSION['datej'] = $_GET['date_j'];
	
}


if(isset($_POST['date_jour']))
{
	$_SESSION['datej'] = dateformaint($_POST['date_jour']);
}



$date_jour = $_SESSION['datej'] ;


// echo  "===>".$date_jour."<br/>" ; 
// echo  "===>".$_SESSION['datej']."<br/>" ; 


// echo "<pre>" ;
// print_r($_SESSION) ;
// echo "</pre>" ;

// echo "========> ".$date_jour."<br/>" ;


// Start the session





	 // $uuu = diff_time('06:04:00' , '06:00:00') ;

	// echo "$uuu<br/>" ;
	// exit() ;


// mise a jour de la table télépoinatage ( ajout de id client pour chaqur pointage)


$qo =dbi_query("SELECT *  FROM `telepointage` WHERE jour >= 20210801 AND (`client_id` IS NULL OR client_id = 0 )") ;
while($j= dbi_fetch_row($qo))
{

    $telephone= $j['telephone'] ;

	list($client_id) = dbi_fetch_row(dbi_query("SELECT client_id FROM `client` WHERE `tele1` LIKE '$telephone'  or `tele2` LIKE '$telephone' or `tele3` LIKE '$telephone' or `tele4` LIKE '$telephone' or `tele5` LIKE '$telephone' ")) ;

// echo "$telephone ==> $client_id	<br/>" ;

 dbi_query("UPDATE `telepointage` SET `client_id` = '$client_id' WHERE `id_p` = ".$j['id_p'] );



}

// echo $date_jour ;
?>
<html>
<head>
<?php include('header.php'); ?>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css">
    <script type='text/javascript' src='jquery-3.6.0.min.js'></script>
</head>

<body class="hold-transition sidebar-mini">

<div class="wrapper">


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


													</ul>
												</nav>


<!-- BARRE DE NAVIGATION -->

<aside class="main-sidebar sidebar-dark-primary elevation-4">

	<!-- Brand Logo -->
	<a href="index3.html" class="brand-link">
		<img src="dist/img/logomcpro.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
				 style="opacity: .8">
		<span class="brand-text font-weight-light">MC PRO</span>
	</a>

	<!-- Sidebar -->
	<div class="sidebar">
		<!-- Sidebar user panel (optional) -->
		<div class="user-panel mt-3 pb-3 mb-3 d-flex">
			<div class="image">
				<img src="dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image">
			</div>
			<div class="info">
				<a href="#" class="d-block">Steeven ROBLOT</a>
			</div>
		</div>

	<?php include('menu.php'); ?>

		<!-- Sidebar Menu -->

	</div>
	<!-- /.sidebar -->
</aside>


 <!-- DEMARRAGE DE LA PAGE PRINCIPALE -->
  <div class="content-wrapper">

		<section class="content-header">
		 <div class="container-fluid">
			 <div class="row mb-2">
				 <div class="col-sm-6">
					 <h1>Validation des pointages </h1>
				 </div>
				 <div class="col-sm-6">
					 <ol class="breadcrumb float-sm-right">
						 <li class="breadcrumb-item"><a href="index.php">Accueil</a></li>
						 <li class="breadcrumb-item"><a href="indexpointages3.php">Pointages</a></li>
						 <li class="breadcrumb-item active">Validation Pointages </li>
					 </ol>
				 </div>
			 </div>
		 </div><!-- /.container-fluid -->
		</section>

    <!-- Content Header (Page header) -->

													<div class="row mb-2">
																			<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><!-- /.row -->

												<!-- /.content-header -->





				<section class="content">
					<div class="row">
						<div class="col-12">
							<div class="card">

									<div class="card-body">
                                      <h3>  <?=int2date($_SESSION['datej'])?> </h3>

											<?php

// if(!empty($_POST))
// {
// echo "<pre>" ;
// print_r($_POST) ;
// echo "<pre>" ;
// }

if(!empty($_POST))
{

	$an= $_POST['ans'] ;
	$mois =  $_POST['mois'] ;
// $ismai = $_POST['ans']."".$_POST['mois']  ;
$ismai =  $an."".$mois ;
$salarie_id=$_POST['salarie_id'] ;
// $qa = dbi_query(" SELECT * FROM `telepointage` where matricule = $salarie_id and `jour` LIKE '$ismai%' ORDER BY `telepointage`.`jour` DESC ,heure DESC ") ;


}





// echo "ppp=> $an <br/>" ;

// $a = dbi_query("SELEC * FROM `etablissement` $where1")

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

// if(!empty($_POST))
// {
// echo "<pre>" ;
// print_r($_POST) ;
// echo "</pre>" ;

// }

$var_fom = 6 ;

if($var_fom == 7) // bach may2afiche formulaire de date
{

 ?>













							<form id="bureau_mois" name="mois_form" method="POST" action="">
							  <div class="form-row">

								<div class="form-group col-md-4">
									 <div class="input-group">
										<label></label>
								   </div>
								</div>

								<div class="form-group col-md-3">
									<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="date_jour" name="date_jour" value='<?php echo int2date_autre_format($date_jour); ?>' placeholder="jj/mm/aaaa"/>
									</div>
								</div>





								<div class="form-group col-md-2">
									 <div class="input-group">
											<button type="submit" name="Afficher" class="btn btn-primary">Afficher </button>
								   </div>
								</div>
						</div>
						</form>

<?}?>



										<div class="onglet_dotted">
											<div style="width:100%; float:left; vertical-align:top" class="header_ray">
												<div id="tab">
													<div class="box-body">
														<table id="example1" class="table table-bordered table-striped">
															<thead>
																<TR>
																  <th align="center">Client</th>
																  <th align="center">Début</th>
																  <th align="center">Fin</th>
																  <th align="center">Salarié</th>
																    <th align="center">Arrivée</th>
																  <th align="center">Départ</th>
																  <th align="center">Statu pointage</th>
																  <th align="center"> Écart</th>
																  
																  <th align="center"> Valider </th>

																</TR>
															</thead>
                                                            <tbody>

                                                            <?php
															// $date_jour = "20200716" ;
															// $ab =  dbi_query(" SELECT *  FROM telepointage WHERE jour LIKE $date_jour ") ;

															// while($c=dbi_fetch_row($ab))
																// {
																	// if($i<10)
																	  // $date_jour=  $ismai."0".$i ;
																	// else
																	// $date_jour=  $ismai."".$i ;

															 // $chaine ='' ;
															 // $sqlah = " SELECT *  FROM telepointage WHERE jour LIKE '".$date_jour."' and matricule = '".$c['matricule']."' ";
															 // $ah = dbi_query($sqlah) ;


                                                             $number_ligne = 0 ; 

																// $salarie_id = $c['matricule'];

																$date = $date_jour;
																$i = 1;
																$q = dbi_query("
																	SELECT * FROM PRESTATIONS p,client c  where c.client_id=p.client_id AND client_statut = '1' AND client_acces_pointage ='2' AND presta_date_debut <= $date AND (p.presta_date_fin >= $date OR p.presta_date_fin IS NULL) $where_etablissement_id ORDER BY presta_Hdeb ASC

																");
																$chaine ="" ;
																	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_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['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'] ;
																		}
																				// if( $prest['salarie_id'] == $salarie_id ) {
																					$day = date("w", strtotime( int2date_autre_format($date)));
																					// if( $day == $prest['presta_jour']){
																					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 )
																							{
																								$SAL = dbi_fetch_row(dbi_query("SELECT * FROM salarie WHERE salarie_id = ".$prest['salarie_id'] ." " )) ;
																								   // $Clt = dbi_fetch_row(dbi_query("SELECT * FROM client WHERE client_id = ".$prest['client_id'] ." " )) ;
																									// $chaine =  " $i".' -La prestation Débute avec <strong>'.$prest["client_nom"]."</strong> de <strong>".int2heure($prest['presta_Hdeb'])."</strong> à <strong>".int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree']))."</strong> ** ".$SAL["salarie_nom"]." ** <br/>";

																								// echo "==> ".$prest['salarie_id']."  ==> ".$prest['client_id']."<br/>" ;

																									list($cmpt_heureD) = dbi_fetch_row( dbi_query("SELECT count(heure) FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'DEBUT'  AND pointage_valider = 0 ")) ;
																								    list($cmpt_heureF) = dbi_fetch_row(dbi_query("SELECT count(heure) FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'FIN'  AND pointage_valider = 0 "    )) ;
                                                                                                  
																								 list($heureD,$id_pDD , $presta_idDD , $pointage_valider_debut) = dbi_fetch_row(dbi_query("SELECT heure , id_p, presta_id , pointage_valider  FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'DEBUT' and (presta_id = ".$prest['presta_id']." OR presta_id = 0) ")) ;
																								 // echo "SELECT heure , id_p, presta_id , pointage_valider  FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'DEBUT' and (presta_id = ".$prest['presta_id']." OR presta_id = 0) <br/>" ; 
																								 
																								 list($heureF,$id_pFF ,$presta_idFF , $pointage_valider_fin ) = dbi_fetch_row(dbi_query("SELECT heure , id_p, presta_id , pointage_valider  FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'FIN'   and (presta_id = ".$prest['presta_id']." OR presta_id = 0) ")) ;
                                                                                                  // echo "SELECT heure , id_p FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'DEBUT' and (presta_id = ".$prest['presta_id']." OR presta_id = 0) <br/>"  ;
																								    
																									$somme_hdeb_hfin =  $cmpt_heureD  + $cmpt_heureF ;  // cette ligne pour savoir la somme entre h_deb et h_fin  dans me cas de resultalt 2 donc il ya le début et le fin
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																									
																										$durepointage = diff_time($heureF , $heureD)."<br/>";
																								$prestfin = int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree'])).":00" ;
																								$prestdebut= int2heure($prest['presta_Hdeb']).":00" ;

																								// echo "$prestfin <==> $prestdebut <br/>" ;
																								$durepresta = diff_time($prestfin , $prestdebut);


																								// echo "===> $heureD === $heureF <br/>" ;
																								$a=0 ;
																								if($heureD != "" AND $heureF != "" )
																								{
																												$dpoint= mktime($durepointage);
																												$dpre= mktime($durepresta);


																												// if($dpre > $dpoint)
																												// {
																												// $ecart = diff_time($durepresta , $durepointage) ;
																												// $a= 1 ;
																												// }
																												// else
																												// {
																												// $ecart = diff_time($durepointage,$durepresta) ;
																												// $a=2 ;
																												// }


																												if($durepresta >= $durepointage)
																												{
																													// echo "ooo <br/>" ;
																												$ecart = diff_time($durepresta , $durepointage) ;
																												$a= 1 ;
																												$statu_ecart = 1 ;  // ecart négatif
																												}
																												else
																												{
																													// echo "mmm <br/>" ;
																												$ecart = diff_time($durepointage,$durepresta) ;
																												$a=2 ;
																												$statu_ecart = 2  ;// ecart positif
																												}
																								}
																								else
																								{
																									$ecart ="NULL" ;
																									$statu_ecart = 0  ;// ecart positif
																								}
																									
																									
																									
																									if($somme_hdeb_hfin == 2)
																									{ 
																										if(!empty($id_pDD)){
																										dbi_query("UPDATE `telepointage` SET `pointage_valider` = '1', `presta_id` = '".$prest['presta_id']."' WHERE `telepointage`.`id_p` = ".$id_pDD);
																										}
																										
																										if(!empty($id_pFF)){
																									    dbi_query("UPDATE `telepointage` SET `pointage_valider` = '1', `presta_id` = '".$prest['presta_id']."' WHERE `telepointage`.`id_p` = ".$id_pFF);
																										}
																										
																										$pointage_deb =dbi_fetch_row(dbi_query("SELECT * FROM `telepointage` WHERE `id_p`  = ".$id_pDD));
																										$pointage_fin =dbi_fetch_row(dbi_query("SELECT * FROM `telepointage` WHERE `id_p`  = ".$id_pFF));
																										dbi_query("INSERT INTO `pointage_rapport` (`pointage_rapport_id`, `client_id`, `salarie_id`, `pres_heure_debut`, `pres_heure_fin`, `point_heure_debut`, `point_heure_fin`, `ecart`, `prest_id`, `id_pDD`, `id_pFF` , `statu_ecart` , date_pointage ) VALUES
																										(NULL, '".$prest['client_id']."', '".$prest["salarie_id"]."', '".int2heure($prest['presta_Hdeb'])."', '".int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree']))."', '".$pointage_deb['heure']."', '".$pointage_fin['heure']."', '".$ecart."', '".$prest['presta_id']."', '".$id_pDD."', '".$id_pFF."' , '".$statu_ecart."'  , '".$_SESSION['datej']."')") ; 
																									
																									}
																									 list($presta_idDD) = dbi_fetch_row(dbi_query("SELECT presta_id FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'DEBUT'  AND `action` LIKE 'DEBUT' and (presta_id = ".$prest['presta_id']." OR presta_id = 0) ")) ;
																								     list($presta_idFF ) = dbi_fetch_row(dbi_query("SELECT presta_id FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'FIN'   AND `action` LIKE 'DEBUT' and (presta_id = ".$prest['presta_id']." OR presta_id = 0) ")) ;
                                                                                                  
																								   $q_heureD = dbi_query("SELECT heure , id_p FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'DEBUT'  ") ;
																								   $q_heureF = dbi_query("SELECT heure , id_p FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'FIN' ") ;
                                                                                                  
																								    
																							
																								// echo ""

																								// echo diff_time($int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree'])), int2heure($prest['presta_Hdeb']))."<br/>";
																								++$i;
																								 echo $chaine  ;
																								 $classe="btn btn-info btn-sm";
																								 list($presta_id_sms)=dbi_fetch_row(dbi_query("SELECT presta_id FROM sms_salarie_avertissement WHERE presta_id = ".$prest["presta_id"])) ;
																							  if($presta_id_sms!=""){ $classe="btn btn-block btn-default disabled"; ;}

																								 ?>
																								 <tr>
																								 <form name="inscription[]" method="post" action="">
																								 <?php $number_ligne ++  ?>
																								   <td> <?php echo $prest["client_nom"]." (".$prest["presta_id"]." )" ; ?> </td>
																								   <td> <?php echo int2heure($prest['presta_Hdeb']) ; ?> </td>
																								   <td> <?php echo int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree'])); ?> </td>
																								   <td> <?php echo $SAL["salarie_nom"]." ".$SAL["salarie_prenom"] ; ?> </td>
																								
																								  
																								    <td> 
																									
																									<input type="hidden" name="id_pDD" value="<?=$id_pDD ?>">
																									<input type="hidden" name="id_pFF" value="<?=$id_pFF ?>">
																									<input type="hidden" name="statu_ecart" value="<?=$statu_ecart ?>">
																									<input type="hidden" name="ecart" value="<?=$ecart ?>">
																									<input type="hidden" name="pres_heure_fin" value="<?=int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree'])); ?>">
																									 
																									<input type="hidden" name="pres_heure_debut" value="<?=int2heure($prest['presta_Hdeb']) ;?>">
																									 <input type="hidden" name="presta_iddd" value="<?=$prest["presta_id"]?>">
																									 <input type="hidden" name="salarie_id" value="<?=$prest["salarie_id"]?>">
																									 <input type="hidden" name="client_id" value="<?=$prest["client_id"]?>">
																									 
																									 <?php if($cmpt_heureD > 1) {?>
																									 <input type="hidden" name="deux_prest_par_jour" value="deux_prest_par_jour">
																									      <select name="id_p_debut" id="lang">
																										  <?php while($res_hd = dbi_fetch_row($q_heureD)) {?> 
																											<option value="<?=$res_hd["id_p"] ?>"><?php echo $res_hd["heure"] ; ?> </option>
																										  <?php }?> 
																											
																										  </select>
																									<?php }elseif($heureD == ""){
																									?>
																									 <input type="time"  name="heure_debut_manuel"   placeholder="00:00:00">
																									 <?
																									}else{ echo $heureD ;?>
																									
																									<input type="hidden" name="point_heure_debut" value="<?=$heureD ?>"> <!--inforùation utiliser  dans l'enregistriment dans la table  pointage_rapport (dans le cas ou le salarie pointe le debut on utilise cette information au lieu de heure_debut_manuel ) -->
																									<?
																									}  ?> 
																									</td>
																								   <td> 
																									 <?php if($cmpt_heureF > 1) {?>
																									       <select name="id_p_fin" id="lang">
																										  <?php while($res_hf = dbi_fetch_row($q_heureF)) {?> 
																											<option value="<?=$res_hf["id_p"] ?>"><?php echo $res_hf["heure"] ; ?> </option>
																										  <?php }?> 
																											
																										  </select>
																									<?php }elseif($heureF == ""){
																									 ?>
																									 <input type="time"  name="heure_fin_manuel"   placeholder="00:00:00">
																									 <?
																									}
																									else{ echo $heureF ; ?>
																									<input type="hidden" name="point_heure_fin" value="<?=$heureF ?>">
																									
																									<?}  ?> 
																									</td>
																									   
																									<?php  if($pointage_valider_debut == 1 OR $pointage_valider_fin== 1){ $valider_p = "valider" ; }else{$valider_p = "" ;}?>
																									<td> <?php echo $valider_p ; ?> </td>																								   <?php if($a==0){?><td> <?php echo $ecart ; ?> </td><?php }?>
																								   <?php if($a==1){?><td style="color:red;"> <?php echo "<strong>".$ecart."</strong>" ; ?> </td><?php }?>
																								   <?php if($a==2){?><td style="color:green;"> <?php echo "<strong>".$ecart."</strong>"  ; ?> </td><?php }?>

																								 <?php 

																								 $value['id_table_1'] = $SAL["salarie_id"]  ;
																								  // echo "==>.". $value['id_table_1']."<br/>" ;
																								     $id_table_one=$value['id_table_1'];
    $select_table2_data=dbi_query("SELECT COUNT(*) FROM `controle_pointage` WHERE `salarie_id`= ".$SAL["salarie_id"]);
     $ary_value=dbi_fetch_row($select_table2_data);
        if($ary_value[0] == 0){
           
            
        }
                                                                                                 echo " <td>" ;
                                                                                                 if($cmpt_heureD > 1 OR  $heureF == "" OR $heureD == "" ) {
																								 ?>
																							    <input type="submit"  name="validerr"  value="Valider" class="btn btn-info"> 
																								 <?php }?> 
																								</td>
																						   </form>	
                       																						   
																								</tr>
																								<?
																							}

																						}

																					}
																				// }
																}

															// echo $client_nom."  --- ".$tel['heure']." --- ".$tel['action'];






            // echo "===>".$number_ligne."<br/>" ;  
			// echo "==k=>".$date_jour."<br/>" ; 
			
			
			$nombre_pointage =  $number_ligne*2 ;
			
			

          list($nombre_validation) = dbi_fetch_row(dbi_query("SELECT count(*) FROM `telepointage` WHERE `jour` LIKE '$date_jour' and  pointage_valider = 1 ")) ;
          
     	  list($nombre_pointage_reel) = dbi_fetch_row(dbi_query("SELECT count(*) FROM `telepointage` WHERE `jour` LIKE '$date_jour' ")) ; 	  
		  
		  // echo "pointage reel==>".$nombre_pointage_reel."<br/>" ; 
		  // echo "pointage validé ==>".$nombre_validation."<br/>" ; 
		  // echo " nombre de prestation  ==>".$number_ligne."<br/>" ; 
		  
		  // echo "===OOO>".$nombre_validation."<br/>" ;
		  
		  if($nombre_validation == $nombre_pointage ){
			  
			  dbi_query("UPDATE `verification_pointage` SET `valide` = '1', `pointage_validee` = '".$nombre_validation."', `pointage_reel` = '".$nombre_pointage_reel."'  WHERE date = $date_jour ") ;
		  }
																// }
															?>






															</tbody>
														</table><!-- /.table -->
													</div><!-- /.box-body -->
												</div><!-- /.tab -->
											</div><!-- /.header_ray -->
										</div><!-- /.onglet_dotted -->
								    </div><!-- /.card-body -->
							    </div><!-- /.card card-primary card-outline -->
							</div> <!-- /.col-12 -->
						</div>  <!-- /.row -->
				</section> <!-- /.section -->




	</div>




<?php include('footerr.php'); ?>


<script>

        function insertdata(inid, element){

            $.ajax({
                url:"without_reloading.php",
                type:"GET",
                data:{
                    "inid":inid
                },
                success:function(data){
                    element.removeAttr('onclick');
                }
            });

        }
        function change(elements){
            elements.style.backgroundColor="brown";
            elements.style.color="white";
        }

</script>

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


</script>

<script type="text/javascript">
$(document).ready(function(){
    $('#myModal').on('show.bs.modal', function (e) {
        var rowid = $(e.relatedTarget).data('id');
		var rowid_type = $(e.relatedTarget).data('type');
		var rowid_presta_id = $(e.relatedTarget).data('presta_id');


        $.ajax({
            type : 'post',
            url : 'envioi_SMS_sal.php', //Here you will fetch records
            data :  'rowid='+ rowid +'&rowid_type='+ rowid_type +'&rowid_presta_id='+ rowid_presta_id, //Pass $id
            success : function(data){
            $('#fetch').html(data);//Show fetched data from database
            }
        });
     });
});


</script>



</body>
</html>

AnonSec - 2021