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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/mcg/pages/feuillesroute/../prestabs.php
<?php
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
$pagemenu = basename($_SERVER["PHP_SELF"]) ;
// exit() ;
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( isset($_POST['PrestaS']) && !empty($_POST['PrestaS']) ){
	foreach ($_POST['PrestaS'] as $num)
	{
		$presta_Hdeb 	   = 'presta_Hdeb'.$num;
		$presta_Hfin 	   = 'presta_Hfin'.$num;
		$presta_date_debut = 'presta_date_debut'.$num;
		$salarie_id 	   = 'sal'.$num;
		$presta_id_old 	   = 'presta_id'.$num;
		$chantier_id 	   = 'chantier_id'.$num;
		$date_presta 	   = 'presta_date'.$num;
		$presta_forfait    = 'presta_forfait'.$num;
		$prestation_type   = 'prestation_type'.$num;
		$client_id 		   = 'client_id'.$num;
		
		$presta_id_old 		= $_POST[$presta_id_old];
		$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];
		
		$date_presta  		= $_POST[$date_presta];
		$presta_sem 	= 1;
		$presta_date_fin	= $presta_date_debut;
		if($_POST[$prestation_type] > 0 ) 		$prestation_type 	= $_POST[$prestation_type]; else $prestation_type = 4;
		if($chantier_id >0 ) 	$chantier_id =  $chantier_id; 	else $chantier_id =  0; 
		$facture = $ad = $ded = 0;
		// if($_POST['facture'] <  1 )
		// {
			// $facture = 1;
			// if($presta_Hduree > $_POST['presta_Hduree_Old'] )
				// $ad = 1;
			// else
			// if($presta_Hduree < $_POST['presta_Hduree_Old'] )
				// $ded = 1;	
			
		// }	
		if(isset($salarie_id) && $salarie_id >0 ){
				$sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,presta_id_old,prestation_type)
			VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,$presta_id_old,$prestation_type)";

// echo $sql.'<br>';
			dbi_query($sql);
			$last_id = mysqli_insert_id($conn);
			dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture,ad,ded) VALUES (".$presta_id_old.", ".$date_presta.", ".$last_id.", ".$facture.", ".$ad.", ".$ded." )") ;
			// echo "INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture,ad,ded) VALUES (".$presta_id_old.", ".$date_presta.", ".$last_id.", ".$facture.", ".$ad.", ".$ded." )";
		}
			
		
		
		
		
	}
}	
// echo '<pre>';
// print_r($_POST);
// echo '</pre>';
// ini_set('display_errors','on');
// error_reporting(E_ALL);


// echo "SELECT salarie_nom,salarie_prenom,a.salarie_id,salarie_absence_date_debut,salarie_absence_date_fin FROM salarie_absence a 
// LEFT JOIN salarie s ON a.salarie_id = s.salarie_id
// WHERE salarie_absence_date_debut > 20200901 ";
// echo "SELECT a.salarie_id,salarie_absence_date_debut,salarie_absence_date_fin FROM salarie_absence a 
// LEFT JOIN salarie s ON a.salarie_id = s.salarie_id
// WHERE salarie_absence_date_debut > 20200901 ";
// echo "SELECT * FROM absence a 
// LEFT JOIN salarie s ON a.inter_id = s.salarie_id
// WHERE date_debut > '20200901' ";
?>
<!DOCTYPE html>
<html>

<head> 
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <!-- Enregistrer le titre de la page --><title> LogMCPRO | Client</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">

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



  </style>
  <!-- DataTables -->
  <link rel="stylesheet" href="../plugins/datatables-bs4/css/dataTables.bootstrap4.css">
  												<!-- overlayScrollbars -->
  <link rel="stylesheet" href="../dist/css/adminlte.min.css">
</head> 

<body class="hold-transition sidebar-mini">
												<!-- Site wrapper -->
	<div class="wrapper">
	
		<nav class="main-header navbar navbar-expand navbar-white navbar-light">
			<!-- Menu extensible -->
			<ul class="navbar-nav">
				<li class="nav-item"><a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a></li>
				<li></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="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>
 
 <!-- Ne pas toucher au dessus / fin de la BARRE DE NAVIGATION-->	
 <!-- DEMARRAGE DE LA PAGE PRINCIPALE -->
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<div class="content-header">
			  <div class="container-fluid">
				<div class="row mb-2">
				  <div class="col-sm-6">
					<h1 class="m-0 text-dark"></h1>
				  </div><!-- /.col -->
				  <div class="col-sm-6">
					
				  </div><!-- /.col -->
				</div><!-- /.row -->
			  </div><!-- /.container-fluid -->
			</div>
			<!-- /.content-header -->





			<!-- PAGE PRINCIPALE -->
			<div class="content">
				<div class="container-fluid">
					<div class="row">
						<div class="col-lg-12">
							<div class="card">
								<div class="card-header"> <h5><i class="nav-icon fas fa-business-time"></i> GESTION DES PRESTATIONS POUR LES SALARIES ABSENCES</h5> </div>
								<br clear="all" />
									<div id="tab">
										<div class="box-body">
											<table id="example1" class="table table-bordered table-striped">
												<thead>
													<tr>
														<th style="text-align:center;">Date prestation</th>
														<th style="text-align:center;">Nom client</th>
														<th style="text-align:center;">L'heure de debut</th>
														<th style="text-align:center;">L'heure de fin</th>
														<th style="text-align:center;">Nom salarie</th>
														<th style="text-align:center;">Periode d'absence</th>
														<th style="text-align:center;">Decision</th> 
													</tr>
												</thead>	
												<tbody>
													<?php
													$qdisp = dbi_query("SELECT salarie_nom,salarie_prenom,a.salarie_id,salarie_absence_date_debut,salarie_absence_date_fin ,salarie_absence_heure_debut,salarie_absence_heure_fin FROM salarie_absence a 
													LEFT JOIN salarie s ON a.salarie_id = s.salarie_id
													WHERE salarie_absence_date_debut > 20200901 ") ;
													while($fdisp = dbi_fetch_row($qdisp))
													{
														
														// echo '<pre>';
														// print_r($f);
														// echo '</pre>';
														// echo ' **** '.$f['salarie_id'];
														$data = array();
														$salarie_id = $fdisp['salarie_id'];
														
														$start = $fdisp['salarie_absence_date_debut'];
														$end = $fdisp['salarie_absence_date_fin'];
														$ahstart = $fdisp['salarie_absence_heure_debut'].':00';
														$amend = $fdisp['salarie_absence_heure_fin'].':00';
														$date =  $start ;
														// echo $date.' ** <br/>';
														// while ( $date <= $end )
														// {
															
																// $date =  date("Ymd", strtotime("+1 day", strtotime($date)));
														// }
														// echo $salarie_id.' $$$ '.$date.'<br/>';
														// /*
														while ( $date <= $end )
														{
															
																$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 ) )
																");
																
																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'] OR  ( $date == $prest['presta_date_debut'] &&  $prest['presta_date_debut']	== $prest['presta_date_fin'] ) ){
																					$hstart = str_pad(round($prest['presta_Hdeb'] /  10000, 0) , 2, '0', STR_PAD_LEFT) ;
																					$mstart = str_pad(($prest['presta_Hdeb'] %  10000)/100  , 2, '0', STR_PAD_LEFT);
																					$hend = str_pad(round(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree']) /  10000, 0) , 2, '0', STR_PAD_LEFT) ;
																					$mend = str_pad((addDuree($prest['presta_Hdeb'], $prest['presta_Hduree']) %  10000)/100  , 2, '0', STR_PAD_LEFT);
																					$istart = $hstart.':'.$mstart.'';
																					$iend = $hend.':'.$mend.'';	
																					
																					$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 )
																						{
																							$d1 = $abdd = new DateTime(int2date($date,'Y-m-d').' '.$ahstart);
																							$d2 = $abdf = new DateTime(int2date($date,'Y-m-d').' '.$amend);
																							$d3 = $prdd = new DateTime(int2date($date,'Y-m-d').' '.$istart.':00');
																							$d4 = $prdf = new DateTime(int2date($date,'Y-m-d').' '.$iend.':00');
																							$interval1 = $prdd->getTimestamp() - $abdd->getTimestamp();
																							$interval2 = $prdd->getTimestamp() - $abdf->getTimestamp();
																							$interval3 = $prdf->getTimestamp() - $abdd->getTimestamp();
																							$interval4 = $prdf->getTimestamp() - $abdf->getTimestamp() ; 
																							// $interval = $d1->diff($d3); 
																							if(( $interval1 < 0 && $interval2 > 0 ) OR ( $interval3 > 0 && $interval4 < 0 ) ){
																							$Clt = dbi_fetch_row(dbi_query("SELECT * FROM client WHERE client_id = ".$prest['client_id'] ." " )) ;	    
																							$data[]= array($date,$Clt['client_nom'],$istart,$iend,$prest['presta_id'],$Clt['client_id'],$prest['presta_Hdeb'],$prest['presta_Hduree'],$prest['chantier_id'],$prest['presta_forfait'],$prest['prestation_type'],$Clt['etablissement_id']);
																							// ,$d1,$d2,$d3,$d4,$interval1,$interval2,$interval3,$interval4
																							}
																						}	 
																					}			
																		}	
																	}
																}
															$date =  date("Ymd", strtotime("+1 day", strtotime($date)));  
														}
														// */
														
														// echo "<pre>";
														// print_r($data);
														// echo "</pre>";
														$nbr = sizeof($data);
														// $dataString = serialize($data);
														if($nbr  > 0 ) {
															?>
															<tr>
															<form method='POST' action='prestadec.php'>
																<input type='hidden' name='salarie_id' value="<?php echo $fdisp['salarie_id']; ?>" />
																<input type='hidden' name='dataString' value="<?php echo htmlentities(serialize($data)); ?>" />
																<input type="hidden" name='presta_id' value="<?php echo $data[0][4] ;?>" />
																<input type="hidden" name='salarie_prenom' value="<?php echo $fdisp['salarie_nom'].' '.$fdisp['salarie_prenom'] ;?>" />
																<td style="text-align:center;">
																	
																		   
																			<?php for ($numero = 0; $numero < $nbr; $numero++){ 
																				echo ' <div class="icheck-primary d-inline ml-2">
																					   <input type="checkbox" value=" '.$numero.'" name="dates_prest[]"  />
																		               <label for="todoCheck2"></label>
																	                   </div>  <B> '.  int2date($data[$numero][0]).'</B></br>';}	?>
																	  
																
																</td>
																<td style="text-align:left;white-space:nowrap; "> <?php for ($numero = 0; $numero < $nbr; $numero++){echo $data[$numero][1].'</br>';}?></td>
																<td style="text-align:center;"> <?php for ($numero = 0; $numero < $nbr; $numero++){echo '<span class="badge bg-success">'.$data[$numero][2].'</span>'.'</br>';}?></td>
																<td style="text-align:center;"> <?php for ($numero = 0; $numero < $nbr; $numero++){echo '<span class="badge bg-info">'.$data[$numero][3].'</span>'.'</br>';}?></td> 
																<td style="text-align:center;vertical-align: middle;"><?php echo $fdisp['salarie_nom'].' '.$fdisp['salarie_prenom'];?></td>
																<td style="text-align:center;vertical-align: middle;"><?php echo int2date($fdisp['salarie_absence_date_debut']).' '.$fdisp['salarie_absence_heure_debut'].' - '.int2date($fdisp['salarie_absence_date_fin']).' '.$fdisp['salarie_absence_heure_fin'] ; ?></td> 
																<td style="text-align:center;vertical-align: middle;"><button type="submit" class="btn btn-primary">Remplacer</button></td>  
															</form>		
															</tr>
															<?php
														}
														
													}
													?>
												</tbody>
											</table>	
										</div>
												
									</div>				
							</div>
						</div>								
					</div>
				</div>

			</div>
				<!-- /.row -->
		</div><!-- /.container-fluid -->
    </div>


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

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





<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables -->
<script src="../plugins/datatables/jquery.dataTables.js"></script>
<script src="../plugins/datatables-bs4/js/dataTables.bootstrap4.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>

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

</script>

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

AnonSec - 2021