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/Controle_mensuel_salari.php
<?php




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








function add_heures($heure1,$heure2){
	$secondes1=heure_to_secondes($heure1);
	$secondes2=heure_to_secondes($heure2);
	$somme=$secondes1+$secondes2;
	//transfo en h:i:s
	$s=$somme % 60; //reste de la division en minutes => secondes
	$m1=($somme-$s) / 60; //minutes totales
	$m=$m1 % 60;//reste de la division en heures => minutes
	$h=($m1-$m) / 60; //heures
	$resultat=$h.":".$m.":".$s;
	return $resultat;
}
// exit();
function heure_to_secondes($heure){
	$array_heure=explode(":",$heure);
	$secondes=3600*$array_heure[0]+60*$array_heure[1]+$array_heure[2];
	return $secondes;
}

$heure_1='00:00:00';
$heure_2='00:14:57';
// echo 'La somme de '.$heure_1.' et de '.$heure_2.' est: '.add_heures($heure_1,$heure_2);

// exit() ;
	// require __DIR__ . '/vendor_sms_recu/autoload.php';
	// include 'includes_sms_recu/ovhhh.php';

include 'includes/config_tmcpro.php' ;
	include 'includes/stable_functions_tmcpro.php' ;

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





$ecart_total =  0 ;


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


// $date_jour = date('Ymd');
// echo int2date($date_jour );
if(isset($_POST['date_jour']))
{
	$_SESSION['datej'] = dateformaint($_POST['date_jour']);
}



$date_jour = $_SESSION['datej'] ;


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

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


// Start the session




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;

    }


	 // $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 `client_id` IS NULL") ;
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' ")) ;

// 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'); ?>
</head>

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



<!-- Site wrapper -->
<div class="wrapper">

				<!-- TOP MENU -->
												<nav class="main-header navbar navbar-expand navbar-white navbar-light">
													<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>
                        <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>


  																				 <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 = "Controle_mensuel_salari.php?id_etab="+id_etab;
												else
											window.location = "Controle_mensuel_salari.php";
										   }
										</script>

										<?php


										$_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 etablissement_id = ".$_SESSION["id_etab"] ;
										}

									   ?>



 <!-- 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>Contrôle Mensuel par Salarié</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">Contrôle Mensuel par Salarié </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">


											<?php

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


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

	$jour = substr($_GET['date'],8,2);
	$an= substr($_GET['date'],0,4); ;
	$mois =  substr($_GET['date'],4,2);
		// echo "===>".$an."<br/>" ;
	// echo "===>".$mois."<br/>";
// $ismai = $_POST['ans']."".$_POST['mois']  ;
$ismai =  $an."".$mois."01" ;
$salarie_iddd=$_GET['salarie_id'] ;
	// echo "===>".$salarie_iddd."<br/>";
	// exit() ;
}


if(!empty($_POST))
{

	$an= $_POST['ans'] ;
	$mois =  $_POST['mois'] ;
// $ismai = $_POST['ans']."".$_POST['mois']  ;
$ismai =  $an."".$mois."01" ;
$salarie_iddd=$_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 "==>$ismai== <>br/>" ;
// exit() ;
}





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




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



     <!--  6 ya3ni tous les clients / 4 ya3ni Clients inactifs / 2 Client actifs   -->
		                        <div class="form-group col-md-4">
								  <div class="input-group">
									<?php  $qa = dbi_query("SELECT * FROM `etablissement`") ;  ?>
								<select class="form-control select" style="width: 100%;" id="client_etab" name="client_etab" onchange="GetIdBureauB()"; >
									<?php  while($etab=dbi_fetch_row($qa))	{?>
									<option value="<?php echo $etab['etablissement_id'] ;?> " <?php if($etab['etablissement_id']==$_SESSION["id_etab"]){echo "selected"  ;} ?> ><?php echo $etab['etablissement_nom'] ;?></option>
									<?php } ?>
									<option value="111" <?php if($_SESSION["id_etab"]== 111 ){echo "selected"  ;} ?>  >Tous les Etablissements</option>
								</select>







									</div>
								</div>



						</div>
						</form>








			<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">
									<?php $qm = dbi_query("SELECT *  FROM `salarie` WHERE `salarie_statut` = '1' $where_etablissement_id ORDER BY `salarie`.`salarie_nom` ASC") ; ?>
										  <select class="form-control select2" style="width: 100%;" name="salarie_id" >
											<option selected="selected">selectionner un salari&#233; </option>
											<?php while($sala = dbi_fetch_row($qm)) { ?>
											<option  value='<?php echo $sala['salarie_id'] ;  ?>'><?php echo $sala['salarie_nom']." ".$sala['salarie_prenom']?></option>
											<?php }?>
										  </select>
								   </div>
							   </div>


								<div class="form-group col-md-3">
								  <div class="input-group">
									  <?php $qm = dbi_query("SELECT *  FROM `client` WHERE `client_statut` = '1'") ; ?>
											  <select class="form-control select" style="width: 100%;"  name="mois" onchange="GetIdmois()";>
												<option selected="selected">selectionner un mois  </option>
												<option  value='01' <?php if($mois=="01"){echo "selected" ; }?>> Janvier   </option>
												<option  value='02' <?php if($mois=="02"){echo "selected" ; }?> > F&#233;vrier   </option>
												<option  value='03' <?php if($mois=="03"){echo "selected" ; }?>> Mars   </option>
												<option  value='04' <?php if($mois=="04"){echo "selected" ; }?> > Avril   </option>
												<option  value='05' <?php if($mois=="05"){echo "selected" ; }?>> Mai   </option>
												<option  value='06' <?php if($mois=="06"){echo "selected" ; }?>> Juin   </option>
												<option  value='07' <?php if($mois=="07"){echo "selected" ; }?> > Juillet   </option>
												<option  value='08' <?php if($mois=="08"){echo "selected" ; }?>> Aout   </option>
												<option  value='09' <?php if($mois=="09"){echo "selected" ; }?> > Septembre   </option>
												<option  value='10' <?php if($mois=="10"){echo "selected" ; }?> > Octobre   </option>
												<option  value='11' <?php if($mois=="11"){echo "selected" ; }?>> Novembre   </option>
												<option  value='12' <?php if($mois=="12"){echo "selected" ; }?>> DF&#233;cembre   </option>
											  </select>
									</div>
								</div>



								<div class="form-group col-md-3">
									 <div class="input-group">
											  <select class="form-control select" style="width: 100%;"  name="ans" onchange="GetIdans()";>
												<option selected="selected">selectionner un ann&#233;e  </option>

													<option  value='2020' <?php if($an=="2020"){echo "selected" ; }?> > 2020   </option>
													<option  value='2021' <?php if($an=="2021"){echo "selected" ; }?>> 2021   </option>
													<option  value='2022' <?php if($an=="2022"){echo "selected" ; }?>> 2022   </option>
													<option  value='2023' <?php if($an=="2023"){echo "selected" ; }?>> 2023   </option>
													<option  value='2024' <?php if($an=="2024"){echo "selected" ; }?> > 2024   </option>
													<option  value='2025' <?php if($an=="2025"){echo "selected" ; }?> > 2025   </option>
													<option  value='2026' <?php if($an=="2026"){echo "selected" ; }?>> 2026   </option>
											  </select>
				                   </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"> Date </th>
																  <th align="center">Salarié </th>
																    <th align="center">Arrivée</th>
																  <th align="center">Départ </th>
																  <th align="center"> Écart</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) ;



 $_GET['date'] = $ismai ;
 // $_GET["client_id"] =
 // if(isset($_GET['date'])){
// include 'includes/config_tmcpro.php' ;
// include 'includes/stable_functions_tmcpro.php' ;
$data = array();
if(isset($_GET["client_id"]) && $_GET["client_id"] > 0)
$client_id=$_GET["client_id"] ;
else
$client_id=$_SESSION["client_id"] ;
$now = new DateTime();
$start = dateformaint($_GET['date']);
$end = date("Ymt", strtotime($_GET['date']));
// $end = $now -> format('Ymt');
$date =  $start ;
$i=0 ;
$date= $ismai ;
// echo "sshc $date <br/>" ;  echo "== $end <br/>" ;

// exit() ;

$ecart_red = '00:00:00' ;
$ecart_green = '00:00:00';

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

	while ($date <= $end )
	{
																$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) 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'];

					if( $prest['presta_sem'] > 1 ) {
						if($m['presta_jour'] !== NULL && $date >= $m['start'])  {
							$date_presta_sem = $m['start'];
							$date_presta_sem = date("Ymd", strtotime('monday this week', strtotime(int2date_autre_format($date_presta_sem))));
						}
					}
					$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($heureD) = dbi_fetch_row(dbi_query("SELECT heure FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'DEBUT' ")) ;
																								 list($heureF) = dbi_fetch_row(dbi_query("SELECT heure FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE '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 ;
																												// $ecart_red = $ecart_red + $ecart  ;
																												}
																												else
																												{
																													// echo "mmm <br/>" ;
																												$ecart = diff_time($durepointage,$durepresta) ;
																												// $ecart_green = $ecart_green + $ecart  ;
																												$a=2 ;
																												}
																								}
																								else
																								{
																									$ecart ="NULL" ;
																								}
																								// 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"; ;}

																								 if($prest['salarie_id'] == $salarie_iddd )
																								 {
																								 ?>
																								 <tr>
																								   <td> <?php echo $prest["client_nom"] ; ?> </td>
																								   <td> <?php echo int2heure($prest['presta_Hdeb']) ; ?> </td>
																								   <td> <?php echo int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree'])); ?> </td>
																								    <td> <?php echo int2date($date) ; ?> </td>
																								    <td> <?php echo $SAL["salarie_nom"]." ".$SAL["salarie_prenom"] ; ?> </td>
																								   <td> <?php echo $heureD ;  ?> </td>
																								   <td> <?php echo $heureF ; ?> </td>



																								   <?php
																								   $ecart_total = $ecart_total + $ecart  ;

																								   ?>
																								   <?php if($a==0){?><td> <?php echo $ecart ; ?> </td><?php }?>
																								   <?php if($a==1){ $ecart_red =  add_heures($ecart_red,$ecart) ;  ?><td style="color:red;"> <?php echo "<strong>".$ecart."</strong>" ; ?> </td><?php }?>
																								   <?php if($a==2){ $ecart_green = add_heures($ecart_green,$ecart) ;  ;?><td style="color:green;"> <?php echo "<strong>".$ecart."</strong>"  ; ?> </td><?php }?>

																								<?php //echo " test ==========================================> ".$ecart_total  ; ?>

																								 </tr>
																								<?
																								 }
																							}
																								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)
																								{
																								$SAL = dbi_fetch_row(dbi_query("SELECT * FROM salarie WHERE salarie_id = ".$prest['salarie_id'] ." " )) ;


																								 list($heureD) = dbi_fetch_row(dbi_query("SELECT heure FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'DEBUT' ")) ;
																								 list($heureF) = dbi_fetch_row(dbi_query("SELECT heure FROM `telepointage` WHERE `jour` LIKE '$date' AND `matricule` =".$prest['salarie_id']." AND `client_id` = ".$prest['client_id']." AND `action` LIKE 'FIN' ")) ;

																								$durepointage = diff_time($heureF , $heureD)."<br/>";
																								$prestfin = int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree'])).":00" ;
																								$prestdebut= int2heure($prest['presta_Hdeb']).":00" ;


																								$durepresta = diff_time($prestfin , $prestdebut);



																								$a=0 ;
																								if($heureD != "" AND $heureF != "" )
																								{
																												$dpoint= mktime($durepointage);
																												$dpre= mktime($durepresta);

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

																												$ecart = diff_time($durepointage,$durepresta) ;
																												$a=2 ;
																												}
																								}
																								else
																								{
																									$ecart ="NULL" ;
																								}
																								++$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"; ;}

																								 if($prest['salarie_id'] == $salarie_iddd )
																								 {
																								 ?>
																								 <tr>
																								   <td> <?php echo $prest["client_nom"] ; ?> </td>
																								   <td> <?php echo int2heure($prest['presta_Hdeb']) ; ?> </td>
																								   <td> <?php echo int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree'])); ?> </td>
																								    <td> <?php echo int2date($date) ; ?> </td>
																								    <td> <?php echo $SAL["salarie_nom"]." ".$SAL["salarie_prenom"] ; ?> </td>
																								   <td> <?php echo $heureD ;  ?> </td>
																								   <td> <?php echo $heureF ; ?> </td>



																								   <?php
																								   $ecart_total = $ecart_total + $ecart  ;

																								   ?>
																								   <?php if($a==0){?><td> <?php echo $ecart ; ?> </td><?php }?>
																								   <?php if($a==1){ $ecart_red =  add_heures($ecart_red,$ecart) ;  ?><td style="color:red;"> <?php echo "<strong>".$ecart."</strong>" ; ?> </td><?php }?>
																								   <?php if($a==2){ $ecart_green = add_heures($ecart_green,$ecart) ;  ;?><td style="color:green;"> <?php echo "<strong>".$ecart."</strong>"  ; ?> </td><?php }?>


																								 </tr>
																								<?
																								 }

																								}
																							}








																						}

																					}
																				// }
																}

	$date =  date("Ymd", strtotime("+1 day", strtotime($date))); // incrémenter la date
	}

	}

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










																// }
															?>






															</tbody>
														</table><!-- /.table -->

												  <b style="color:red;">	<?php   echo " <   $ecart_red   >"?> </b>
												  <b style="color:green;">	<?php   echo " <   $ecart_green  >"?> </b>
													</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 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