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/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/mcg/pages/splanning2_31_07_2024.php
<?php
// $from = '2020-04-01';
// $to   = '2020-04-01';
// exit();
// $_GET['salarie_id'] =  2557 ; 
// $_GET['date'] =  '2023-10-01' ; 
if(isset($_GET['salarie_id']))
	$salarie_id = $_GET['salarie_id'];
else
$salarie_id = 2722;
$TMCPROCLIENTID = 10824;
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 type_pre_GET ($value =12)
{
	$tab = array(10 => 'Viste medicale', 11 => 'Entretien',  12 => 'Autre ');
	return $tab[$value] ;
}
   // echo $salarie_id;
   
// functidon dateDifference($strtDate , $endDate )
// {
// $startDateWeekCnt = round(floor( date('d',strtotime($strtDate)) / 7)) ;
// $endDateWeekCnt = round(ceil( date('d',strtotime($endDate)) / 7)) ;
// $datediff = strtotime(date('Y-m',strtotime($endDate))."-01") - strtotime(date('Y-m',strtotime($strtDate))."-01");
// $totalnoOfWeek = round(floor($datediff/(60*60*24)) / 7) + $endDateWeekCnt - $startDateWeekCnt ;
    // return $totalnoOfWeek;
// }
// function dateDifference($date1, $date2)
// {
    // $first = DateTime::createFromFormat('m/d/Y', $date1);
    // $second = DateTime::createFromFormat('m/d/Y', $date2);
    // if($date1 > $date2) return week_between_two_dates($date2, $date1);
    // return floor($first->diff($second)->days/7);
// }
// function dateDifference($date1, $date2)
// {
    // $first = DateTime::createFromFormat('m/d/Y', $date1);
    // $second = DateTime::createFromFormat('m/d/Y', $date2);
    // if($date1 > $date2) return week_between_two_dates($date2, $date1);
    // return floor($first->diff($second)->days/7);
// }
function convertToHoursMins($time, $format = '%02d:%02d') {
    if ($time < 1) {
        return;
    }
    $hours = floor($time / 60);
    $minutes = ($time % 60);
    return sprintf($format, $hours, $minutes);
}
// echo ' OK '.dateDifference($from,$to).'<br>';	
// echo ' OK '.$totalnoOfWeek .'<br>';
// function dateDifference($date_1 , $date_2 , $differenceFormat = '%a' )
// {
    // $datetime1 = date_create($date_1);
    // $datetime2 = date_create($date_2);
   
    // $interval = date_diff($datetime1, $datetime2);
   
    // return $interval->format($differenceFormat);
   
// }
// echo ' OK '.dateDifference($strtDate,$endDate).'<br>';	
 // if(isset($_GET['date'])){
	
// [
// {"id":"100","title":"salarie : 3","start":"2020-03-01 06:00:00","end":"2020-03-01 07:00:00","date":"20200301"},
// {"id":"101","title":"salarie : 3","start":"2020-03-02 06:00:00","end":"2020-03-02 07:00:00","date":"20200302"}
  // ]
 // }
 if(isset($_GET['date'])){
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
$data = array();
$now = new DateTime();
$start = dateformaint($_GET['date']);
$end = date("Ymt", strtotime($_GET['date']));
// $end = $now -> format('Ymt');
$date =  $start ;
$i=0 ; 
	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_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 ) )

		");
		
		// 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 ) )
		// ".'<br>';
		// exit() ;
			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 ) {
				
			  // $information=$prest['information']  ; 
			  
			  // if(!empty($information))
			  // {
				// $chain_information = " : ".$information ; 
			  // }
				// if($date == '20200806')
					// echo $prest["presta_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'] ) ){
						
					// $istart = str_pad($prest['presta_Hdeb'] / 10000 , 2, '0', STR_PAD_LEFT) ;
					$hstart = str_pad((int)($prest['presta_Hdeb'] /  10000) , 2, '0', STR_PAD_LEFT) ;
					// $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 = int2date_autre_format($date).' '.$hstart.':'.$mstart.':00';
					$iend = int2date_autre_format($date).' '.$hend.':'.$mend.':00';	

	// int2date_autre_format($prest['presta_date_debut'])				
						// echo "<pre>";
						// print_r($prest);
						// echo "</pre>";
						// $iend = $prest['presta_Hduree'] ;
						// $istart =  $prest['	presta_Hdeb'] ;
						// $prestation_jour_heurd = date('Y-m-d', $i)." ".$_POST['prestation_jour_heurd'].":00" ; 						
					// echo $istart .' !! !! '.$iend .'<br>';	
					// $astart = int2date_autre_format($date).' '.'11:00:00';
					// if	($prest['presta_id'] == 32)
					// echo dateDifference(int2date_autre_format($prest['presta_date_debut']),int2date_autre_format($date)).' !! '. $prest['presta_sem'].' $$ '.dateDifference(int2date_autre_format($prest['presta_date_debut']),int2date_autre_format($date))% $prest['presta_sem'] .'<br>';
				   $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 )
						{
							   $Clt = dbi_fetch_row(dbi_query("SELECT * FROM client WHERE client_id = ".$prest['client_id'] ." " )) ;	    
							   $data[$i]['id']   = $prest["presta_id"];
								if($prest['client_id'] == $TMCPROCLIENTID)
									$data[$i]['title']   = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$prest['prestation_motif'];   
								else
							   $data[$i]['title']   = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$Clt["client_nom"];
							   // $data[$i]['title']   = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$Clt["client_nom"];
							   $data[$i]['start']  = $istart;
							   $data[$i]['end']   = $iend;
							   $data[$i]['date']   = $date;
								if( $prest['presta_date_debut'] ==  $prest['presta_date_fin'] )
								{  
									if( $prest['prestation_type'] == 1  ){
										   $data[$i]['backgroundColor']   = '#ffffff';
										   $data[$i]['borderColor']   = '#007bf';
										   $data[$i]['textColor']   = '#007bf';											   
									   
									}
									else if( $prest['prestation_type'] == 2  )
									{
										   $data[$i]['backgroundColor']   = '#ffffff';
										   $data[$i]['borderColor']   = '#28a745';
										   $data[$i]['textColor']   = '#28a745';											   
									}
									else if( $prest['prestation_type'] == 3  )
									{
										   $data[$i]['backgroundColor']   = '#ffffff';
										   $data[$i]['borderColor']   = '#ffc107';
										   $data[$i]['textColor']   = '#ffc107';											   
									}
									else if( $prest['prestation_type'] == 5  ){
										   $data[$i]['backgroundColor']   = '#C0392B';
										   $data[$i]['borderColor']   = '#C0392B';
										   $data[$i]['textColor']   = '#000000';											   
									   
									}
									else if( $prest['prestation_type'] == 6  ){
										   $data[$i]['backgroundColor']   = '#8E44AD';
										   $data[$i]['borderColor']   = '#8E44AD';
										   $data[$i]['textColor']   = '#000000';											   
									   
									}
									else if( $prest['prestation_type'] == 8  ){
										   $data[$i]['backgroundColor']   = '#0AF3D7';
										   $data[$i]['borderColor']   = '#0AF3D7';
										   $data[$i]['textColor']   = '#000000';											   
									   
									}
									else if( $prest['prestation_type'] == 9  ){
										   $data[$i]['backgroundColor']   = '#FFA07A';
										   $data[$i]['borderColor']   = '#FFA07A';
										   $data[$i]['textColor']   = '#000000';											   
									   
									}
									else if( $prest['prestation_type'] == 10  ){
										   $data[$i]['backgroundColor']   = '#A9CCE3';
										   $data[$i]['borderColor']   = '#A9CCE3';
										   $data[$i]['textColor']   = '#000000';											   
									   
									}
									else if( $prest['prestation_type'] == 10  ){
										   $data[$i]['backgroundColor']   = '#A9CCE3';
										   $data[$i]['borderColor']   = '#A9CCE3';
										   $data[$i]['textColor']   = '#000000';											   
									   
									}
									else if( $prest['prestation_type'] == 13  ){  // type ==> autre prestation spécifique 
										   $data[$i]['backgroundColor']   = '#FF33AC';
										   $data[$i]['borderColor']   = '#FF33AC';
										   $data[$i]['textColor']   = '#000000';											   
									   
									}
									else if( $prest['prestation_type'] == 14  ){  // type ==> trajet
										   $data[$i]['backgroundColor']   = '#86FF33';
										   $data[$i]['borderColor']   = '#86FF33';
										   $data[$i]['textColor']   = '#000000';											   
									   
									}
									else if( $prest['prestation_type'] == 15  ){  // type ==>  bureau
										   $data[$i]['backgroundColor']   = '#DAF7A6';
										   $data[$i]['borderColor']   = '#DAF7A6';
										   $data[$i]['textColor']   = '#000000';											   
									   
									}
									else
									{
										   $data[$i]['backgroundColor']   = '#ffffff';
										   $data[$i]['borderColor']   = '#e83e8c';
										   $data[$i]['textColor']   = '#e83e8c';												   
									}
								}
								else
								{
									if( $prest['prestation_type'] == 1  ){
										   $data[$i]['backgroundColor']   = '#007bf';
										   $data[$i]['borderColor']   = '#007bf';								   
									}
									else if( $prest['prestation_type'] == 2  )
									{
										   $data[$i]['backgroundColor']   = '#28a745';
										   $data[$i]['borderColor']   = '#28a745';								   
									}
									else if( $prest['prestation_type'] == 3  )
									{
										   $data[$i]['backgroundColor']   = '#ffc107';
										   $data[$i]['borderColor']   = '#ffc107';								   
									}
									else
									{
										   $data[$i]['backgroundColor']   = '#e83e8c';
										   $data[$i]['borderColor']   = '#e83e8c';								   
									}
								}
							   
							   // $data[$i]['textEscape']   = false ;
							   // $data[$i]['backgroundColor']   = '#00a65a';
							   // $data[$i]['backgroundColor']   = '#00a65a';									   
          // backgroundColor: '#00a65a', //Success (green)
          // borderColor    : '#00a65a' //Success (green)							   
							   ++$i;	
						}
						else
						{
							// 
							// $nbre = dateDifference(int2date_autre_format($prest['presta_date_debut']),int2date_autre_format($date)) - 1; 
							// $nbre = dateDifference(int2date_autre_format($date_presta_sem,'m/d/Y'),int2date_autre_format($date,'m/d/Y')) - 1;
							// $nbre = dateDifference(int2date_autre_format($date_presta_sem,'m/d/Y'),int2date_autre_format($date,'m/d/Y')) - 1;
							$nbre =count_week_days(strtotime(int2date_autre_format($date_presta_sem,'d.m.Y')), strtotime(int2date_autre_format($date,'d.m.Y')));
							// $nbre = dateDifference(int2date_autre_format($date_presta_sem,'m/d/Y'),int2date_autre_format($date,'m/d/Y'));
							$modolo = $nbre % $prest['presta_sem'] ;
							// ECHO $modolo.' ------> '.$date_presta_sem.' ****** '.$date.' $$$ '.$nbre.'<br>';
							if( $modolo == 0) {
							   $Clt = dbi_fetch_row(dbi_query("SELECT * FROM client WHERE client_id = ".$prest['client_id'] ." " )) ;	    
							   $data[$i]['id']   = $prest["presta_id"];
								if($prest['client_id'] == $TMCPROCLIENTID)
									$data[$i]['title']   = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$prest['prestation_motif'];   
								else
							   $data[$i]['title']   = '('. convertToHoursMins($prest['presta_Hduree'], '%01dh%02d').") ".$Clt["client_nom"]." ".$chain_information;
							   $data[$i]['start']  = $istart;
							   $data[$i]['end']   = $iend;
							   $data[$i]['date']   = $date;
								if( $prest['presta_date_debut'] ==  $prest['presta_date_fin'] )
								{  
									if( $prest['prestation_type'] == 1  ){
										   $data[$i]['backgroundColor']   = '#ffffff';
										   $data[$i]['borderColor']   = '#007bf';
										   $data[$i]['textColor']   = '#007bf';											   
									   
									}
									else if( $prest['prestation_type'] == 2  )
									{
										   $data[$i]['backgroundColor']   = '#ffffff';
										   $data[$i]['borderColor']   = '#28a745';
										   $data[$i]['textColor']   = '#28a745';											   
									}
									else if( $prest['prestation_type'] == 3  )
									{
										   $data[$i]['backgroundColor']   = '#ffffff';
										   $data[$i]['borderColor']   = '#ffc107';
										   $data[$i]['textColor']   = '#ffc107';											   
									}
									else
									{
										   $data[$i]['backgroundColor']   = '#ffffff';
										   $data[$i]['borderColor']   = '#e83e8c';
										   $data[$i]['textColor']   = '#e83e8c';												   
									}
								}
								else
								{
									if( $prest['prestation_type'] == 1  ){
										   $data[$i]['backgroundColor']   = '#007bf';
										   $data[$i]['borderColor']   = '#007bf';								   
									}
									else if( $prest['prestation_type'] == 2  )
									{
										   $data[$i]['backgroundColor']   = '#28a745';
										   $data[$i]['borderColor']   = '#28a745';								   
									}
									else if( $prest['prestation_type'] == 3  )
									{
										   $data[$i]['backgroundColor']   = '#ffc107';
										   $data[$i]['borderColor']   = '#ffc107';								   
									}
									else
									{
										   $data[$i]['backgroundColor']   = '#e83e8c';
										   $data[$i]['borderColor']   = '#e83e8c';								   
									}
								}
								 ++$i;
							}
							
						}	

				   }
				}
			}	
			// echo  date("Ymd", strtotime( int2date_autre_format($date))).' !! '.$prest['presta_id'].' $$ '.$prest['presta_jour'].'<br>';	
		}	
		
// $date = time2int($time) ;
		
		
		
		
		$date =  date("Ymd", strtotime("+1 day", strtotime($date)));
	}
 // 2020-05-01 11:00:00	
// $q = dbi_query(" SELECT * FROM prestation_jour pj , prestation p  where p.prestation_id =  pj.prestation_id and  p.client_id = $client_id  ") ; 

// $i=0 ; 
// while($row=dbi_fetch_row($q))
	// {
		
	// list($salarie_nom)=	dbi_fetch_row(dbi_query(" SELECT salarie_nom FROM `salarie` WHERE salarie_id = ".$row["salarie_id"])) ; 
    // $data[$i]['id']   = $row["prestation_jour_id"];
   // $data[$i]['title']   = "salarie : ".$salarie_nom;
   // $data[$i]['start']  = $row["prestation_jour_heurd"];
   // $data[$i]['end' ]   = $row["prestation_jour_heurf"]	;	
   
    // $data[$i]['salarie_id' ]   = $row["salarie_id"]	;	
// $i++; 
	// }
// SELECT salarie_absence_id,absence_motif_description,salarie_absence_date_debut,salarie_absence_heure_debut,salarie_absence_date_fin,salarie_absence_heure_fin
// FROM salarie_absence  sa
// left join absence_motif ab on sa.absence_type_id = ab.absence_motif_id
// where salarie_id = 2543
$qabs= dbi_query("SELECT * FROM salarie_absence 
where salarie_id = ".$salarie_id) ;
while ($Labs = dbi_fetch_row($qabs))
{
   // list($motif)= = dbi_fetch_row(dbi_query("SELECT absence_motif_description FROM absence_motif where absence_motif_id ='".$Labs['absence_type_id']."'")) ; 
   $descabs = dbi_query("SELECT absence_type_description FROM absence_type where absence_type_id ='".$Labs['absence_type_id']."'");  
   $motif = dbi_fetch_row($descabs) ; 
// echo ' <br> '.utf8_encode($motif['absence_motif_description']).' <br> ';   
   $data[$i]['id']      = $Labs["salarie_absence_id"];
	if(empty($Labs["salarie_absence_date_fin"]) OR $Labs["salarie_absence_date_fin"] ==0)
	{
		$data[$i]['title']   = $motif['absence_type_description'].' : '.int2date_autre_format($Labs["salarie_absence_date_debut"],'d/m/Y').' - Pas de Date Fin' ;  
		$data[$i]['end']     = int2date_autre_format($end).' 18:00:00';
	}		
	else    
	{
		$data[$i]['title']   = $motif['absence_type_description'].' : '.int2date_autre_format($Labs["salarie_absence_date_debut"],'d/m/Y').' - '.int2date_autre_format($Labs["salarie_absence_date_fin"],'d/m/Y') ;
		$data[$i]['end']     = int2date_autre_format($Labs["salarie_absence_date_fin"]).' '.$Labs["salarie_absence_heure_fin"].':00';
	}
   $data[$i]['start']   = int2date_autre_format($Labs["salarie_absence_date_debut"]).' '.$Labs["salarie_absence_heure_debut"].':00';
  
   $data[$i]['date']    = int2date_autre_format($Labs["salarie_absence_date_debut"]);	
   $data[$i]['backgroundColor']   = '#C0C0C0';
   $data[$i]['borderColor']   = '#C0C0C0';	   
		// echo '<pre>';
		// print_r($Labs);
		// echo '</pre>';
++$i;		
}
				

echo json_encode($data);
 }
?>

AnonSec - 2021