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/../MCPRO/vendor/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/TEST/../MCPRO/vendor/../log_diff.php
<?php
// echo "testot <br/>" ; 
include_once 'code/init.php';
print_header('','','style="margin-top:60px;"');
if(isset($_GET['type']) && $_GET['type']==2)
$filtre=$_GET['type'];
else
$filtre=1;


?>


<script language="Javascript">
   function inter()
   {	
	var id="";
	var date="";
	id = document.inter_form.int.value ;
	date = document.inter_form.date.value ;
if( date > 0)
window.location = "log_diff.php?type="+id+"&date="+date;
else
window.location = "log_diff.php?type="+id;
	
   }
</script>



<script language="Javascript">
   function GetIdBur()
   {	
	var idbursel="";
	idbursel = document.bureau_form.id_bureau.value ;
	if( idbursel > 0 || idbursel=="INDEFINI" )
	window.location = "log_diff.php?idbursel="+idbursel;
	else
	window.location = "log_diff.php";
   }
</script>   




<?php
	$where1="";
	$where2="";
	$selected="";
if(isset($_GET['idbursel']) && !empty($_GET['idbursel'])) 
	{
	if($_GET['idbursel']>0)
	{
		$tabbursel=dbi_fetch_row((dbi_query('select * from bureau where id_bureau='.$_GET['idbursel'].' and agence_id='.$agence.''))) ;
		$id_bureau=$tabbursel['id_bureau'];
		$nom_bureau=$tabbursel['nom_agence'];
		$where1=" AND ID_Bureau != $id_bureau ";
		$where2=" AND inter_bureau=$id_bureau ";
	}
	elseif($_GET['idbursel']=="INDEFINI")
	{
	$id_bureau=$_GET['idbursel'];
	$where2=" AND inter_bureau='0' ";
	$selected='selected="selected"';
	}
	}





?>

<table style="position:absolute; top:35px;  right:20px;">
		<!-- <div style=" position:relative; top:0px; right:10;"> -->
<form id="suivi_form" name="bureau_form" method="POST" action="">
		<tr>
        <td align="left" valign="top" class="td_listing0" >Bureau :</td>
        <td align="left" valign="top" class="td_listing0" ">
		<select id="id_bureau" name="id_bureau" onchange="GetIdBur()";>
					<option selected="selected" value="TOUS">TOUS</option>
		<?php if(isset($id_bureau) && isset($nom_bureau)) { ?>
				<option selected="selected" value="<?=$id_bureau ?>" size="100"><?=$nom_bureau?></option>
		<?php }
					$Reqbureau=dbi_query("select * from bureau where agence_id=$agence $where1") or die(mysql_error());
					while($listbureau=dbi_fetch_row($Reqbureau)){ ?>
            <option value="<?php echo $listbureau['id_bureau']?>"><?php echo $listbureau['nom_agence'] ?></option>
					<?php } ?>
			<option <?=$selected ?> value="INDEFINI">INDEFINI</option>
		</select>
		  </td>
		</tr>
</form>
<!-- </div> -->
</table>





<br/><br/>
<?php

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

$where= "" ; 
if(!empty($_GET['idbursel']))
{
	$where = "AND inter_bureau = ".$_GET['idbursel'] ; 
}
// echo "==> $where <br/>"; 

// exit() ;
$from = isset($_GET['date']) ? $_GET['date'] : time2int(time()-(date('w')-1)*24*3600) ;


// echo "==>".date('Y')  ; 

// echo "==>".date('m')  ; 
// exit() ;


// $lastday=strftime("%Y%m%d",mktime(0,0,0,date('m')+1,0,date('Y')));
// $firstday=strftime("%Y%m%d",mktime(0,0,0,date('m'),1,date('Y')));

// echo "===> $lastday ====> $firstday <br/>" ; 
// echo "===> ".$from."<br/>" ; 
		$to = int2time($from)+6*24*3600 ;
		if(date('H', $to) == 23)
			$to += 3600 ;
		if(date('H', $to) == 1)
			$to -= 3600 ;
		$to = time2int($to);
		$back = int2time($from)-7*24*3600 ;
		if(date('H', $back) == 23)
			$back += 3600 ;
		if(date('H', $back) == 1)
			$back -= 3600 ;
		$back = time2int($back);
		$next  = int2time($from)+7*24*3600 ;
		if(date('H', $next) == 23)
			$next += 3600 ;
		if(date('H', $next) == 1)
			$next -= 3600 ;
		$next = time2int($next);
		// $inter = $_GET['interv_id'] ;		
$oneweek = 60*60*24*7;
$oneday = 60*60*24;
$onehour = 60*60;
$debut = mktime(0,0,0,date("m")-8,date("d"),date("Y")); 
$premier_jour = mktime(0,0,0,date("m",$debut),date("d",$debut)-date("w",$debut)+1,date("Y",$debut)); 
$d = $premier_jour;
$select = "<select onChange=\"location.href = 'top.php?interv_id=".$_GET['interv_id']."&date='+this.value;\">";
for ($i = 0; $i < 52; $i++)
{

	$semaine_prochaine = $d + $oneweek; 
	$semaine_en_cours = (($d < time()) && ($d < $semaine_prochaine) && !array_key_exists('date',$_GET)) || (date("Ymd",$d) == $from); 
    $select .= "<option value=\"".date("Ymd",$d)."\" ".($semaine_en_cours?'selected="selected"':'').">";
    $select .= date("d-m-Y",$d)." au ".date("d-m-Y", $d + $oneweek - $oneday)."</option>";
    
	$d  = $semaine_prochaine ;
	if(date('H', $d) == 23)
		$d += $onehour ;
	if(date('H', $d) == 1)
		$d -= $onehour ;
}
		echo '<table width="100%" cellspacing="0" cellpadding="0" style="margin-top:-10px">
	<tr>
		<td valign="bottom"><a href="log_diff.php?type='.$filtre.'&date='.$back.'"><img src="leftarrow.gif" border="0"></a></td>
		<td align="center" valign="top"><h2 style="margin:0px; padding:0px;">Semaine du '.int2date($from, 'd/m/Y').' au '.int2date($to, 'd/m/Y').'</h2><a href="log_diff.php?type='.$filtre.'">Retour &agrave; aujourd&rsquo;hui</a>&nbsp;'.$select.'</td>
		<td></td>
		<td valign="bottom" align="right"><a href="log_diff.php?q&type='.$filtre.'&date='.$next.'"><img src="rightarrow.gif" border="0"></a></td>
	</tr>
</table>';

// $a = dbi_query("SELECT * FROM ".TABLE_ABSENCES." WHERE agence_id = w$agence AND );


		

function jour_jouren2($jour,$get)
{
	static $presta_jour ;
	$from = $get ;
 $presta_jour = array('nynnnnn' => $get, 'nnynnnn' => date("Ymd", strtotime("+1 day", strtotime($from))), 'nnnynnn' => date("Ymd", strtotime("+2 day", strtotime($from))), 'nnnnynn' => date("Ymd", strtotime("+3 day", strtotime($from))), 'nnnnnyn' => date("Ymd", strtotime("+4 day", strtotime($from))), 'nnnnnny' => date("Ymd", strtotime("+5 day", strtotime($from))), 'ynnnnnn' => date("Ymd", strtotime("+6 day", strtotime($from)))) ;
 return $presta_jour[$jour] ;
}

// echo "$from <br/>" ; 
// echo "$to <br/>" ; 
// $from =  20141201 ; 
// $to = 20141207  ; 
function get_prest_sem($from ,$to,$agence,&$abs, $where)
{

$id=0;
$p=array();


$presta_jour1 = array('nynnnnn' => '1', 'nnynnnn' => '2', 'nnnynnn' => '3', 'nnnnynn' => '4', 'nnnnnyn' => '5', 'nnnnnny' => '6', 'ynnnnnn' => '0')  ;
$presta_jour2 = array('1' => 'nynnnnn', '2' => 'nnynnnn', '3' => 'nnnynnn', '4' => 'nnnnynn', '5' => 'nnnnnyn', '6' => 'nnnnnny', '0' => 'ynnnnnn')  ;

	// $q = dbi_query("SELECT SQL_BIG_RESULT p.presta_id, p.presta_date_debut, p.presta_jour, p.presta_Hdeb, p.presta_Hduree, p.presta_forfait FROM ".TABLE_PREST." p WHERE agence_id=".$agence." AND presta_jour IS NOT NULL AND ( presta_date_fin IS NULL OR presta_date_fin>='".$from."') ") ;
	// $q2 = dbi_query("SELECT p.* FROM ".TABLE_PREST." p  WHERE p.agence_id=$agence  AND presta_date_debut !=0 AND presta_date_debut <= $to AND (p.presta_date_fin >= $from OR p.presta_date_fin IS NULL) ");
		$q2 = dbi_query("SELECT p.* FROM ".TABLE_PREST." p ,   intervenant i WHERE p.agence_id=$agence and p.inter_id = i.inter_id  AND presta_date_debut !=0 AND presta_date_debut <= $to AND (p.presta_date_fin >= $from OR p.presta_date_fin IS NULL) and ( $to <= p.presta_date_fin  OR p.presta_date_fin IS NULL or p.presta_date_fin=presta_date_debut  OR $from >= presta_date_debut ) $where  ");
		// echo "==>$where <br/>" ; 
		// echo "SELECT p.* FROM ".TABLE_PREST." p ,   intervenant i WHERE p.agence_id=$agence and p.inter_id = i.inter_id  AND presta_date_debut !=0 AND presta_date_debut <= $to AND (p.presta_date_fin >= $from OR p.presta_date_fin IS NULL) and ( $to <= p.presta_date_fin  OR p.presta_date_fin IS NULL or p.presta_date_fin=presta_date_debut  OR $from >= presta_date_debut ) $where  ";
	while($prest = dbi_fetch_row($q2))
	{
	// echo "<pre>" ; 
	// print_r($prest) ; 
	// echo "<pre>" ; 
	if($prest['presta_jour']== 'nnnnnnn' || $prest['presta_jour']== '' || $prest['presta_jour']== NULL )
	$prest['presta_jour']=$presta_jour2[date("w",strtotime($prest['presta_date_fin']))];
	
		$data = array('jour' => $prest['presta_jour'], 'deb' => $prest['presta_Hdeb'], 'duree' => $prest['presta_Hduree'], 'inter' => $prest['inter_id'], 'taux' => $prest['presta_forfait'],'id' => $prest['presta_id']) ;
		
		$q1 = dbi_query("SELECT * FROM ".TABLE_PRESTA_MODIF." WHERE presta_id = ".$prest['presta_id']." AND start <= $to  order by `start`, `date`") ;
	
		
		while (($m = dbi_fetch_row($q1)) )
		{
				$jour = $m['jour'] === NULL ? $data['jour'] : $m['jour'] ;
				$date=jour_jouren2($jour,$from);
				
				if($date>=$m['start']) {
				$data['jour'] = $m['jour'] === NULL ? $data['jour'] : $m['jour'] ;
				$data['deb'] = $m['Hdeb'] === NULL ? $data['deb'] : $m['Hdeb'] ;
				$data['duree'] = $m['Hduree'] === NULL ? $data['duree'] : $m['Hduree'] ;
				$data['inter'] = $m['inter_id'] === NULL ? $data['inter'] : $m['inter_id'] ;
				$data['taux'] = $m['taux'] === NULL ? $data['taux'] : $m['taux'] ;
				$data['tauxHT'] = $m['tauxHT'] === NULL ? $data['tauxHT'] : $m['tauxHT'] ;
				}
		}
$jour=$data['jour'];
$date=jour_jouren2($jour,$from);
$int=$data['inter'];

	$heurefin=addDuree($data['deb'],$data['duree']);
	$qexcept=dbi_query("SELECT * FROM ".TABLE_EXCEPT." WHERE (date BETWEEN ".$from." AND ".$to.") AND presta_id=".$prest['presta_id']."  ");	
	
	if($rr = dbi_fetch_row($qexcept)){
				if($rr['inter_abs']==1)
				$abs[$int][]=$data['duree'];
				// if($rr['facture']==1)
				// $p[$int]['prest'][] = array( 'deb' => $data['deb'], 'fin'=>$heurefin,'duree'=>$data['duree'],'date'=>$date );
			}
			else
			{
				if( $date >= $from  && $date <= $to )
				{
				
		// array_push($p[$int]['prest'],array( 'deb' => $data['deb'], 'fin'=>$heurefin,'duree'=>$data['duree'],'date'=>$date ));	
	$p[$int]['prest'][] = array( 'deb' => $data['deb'], 'fin'=>$heurefin,'duree'=>$data['duree'],'date'=>$date,'idd'=>$data['id']);		
					// $p[$int]['prest'][] = array('id' => $prest['presta_id'],'date' => $date,'jour' => $data['jour'],'inter_id' => $data['inter'],'deb' => $data['deb'],	'duree' => $data['duree'],'fin' => $heurefin) ;
				}
			}

	}



	return $p;
	


}
$ABS=array();

$ABSENCE=array();


$pre=get_prest_sem( $from,$to ,$agence,$ABS ,$where);
// echo "<pre>" ;
// print_r($pre) ;
// echo "</pre>" ;

$DATA = array();

$inters=array();
$absinter=" ( 0 ";
foreach($pre as $int => $prestations)
{
$inters[]=$int;
$absinter.=' , '.$int;
   $total=0;
   $abs=0;
   			for ($j = 0 ; $j < count($pre[$int]['prest']) ; $j++)
					{
					$total+=$pre[$int]['prest'][$j]['duree'];
					}
   			for ($k = 0 ; $k < count($ABS[$int]) ; $k++)
					{
					$abs+=$ABS[$int][$k]/60;
					}					


$heures_contrat=0;
$sql="SELECT contrat_heure FROM ".TABLE_CONTRAT." WHERE inter_id = ".$int." AND agence_id = ".$agence." AND contrat_debut<=".$from." AND ( contrat_fin IS NULL OR contrat_fin >".$from." ) ORDER BY contrat_debut DESC";
list($heures_contrat)=dbi_fetch_row(dbi_query($sql));
				
				
				$DATA[$int] = array( 'int' => $int,'hct'=> $heures_contrat ,'tot'=> $total/60,'abs'=> $abs );
}
		$absinter.=' ) ';
		
	$reqabs=dbi_query("SELECT * FROM ".TABLE_ABSENCES." WHERE (date_debut between  $from AND $to ) OR (date_debut < $from AND date_fin > $to ) OR (date_fin IS NULL OR date_fin between $from AND $to) OR (date_debut <= $from AND date_fin IS NULL OR date_fin between $from AND $to)  AND agence_id='".$agence."'");
		while (($r = dbi_fetch_row($reqabs)) ){
		//echo "<pre>" ;
		//print_r($r);
		//echo "</pre>" ;
		$ABSENCE[$r['inter_id'] ][]=array($r['date_debut'],$r['date_fin']) ;
		// int2date($r['date_debut']).' au '. int2date($r['date_fin']
		}	

		
		

		$qu=dbi_query("SELECT * from  ".TABLE_INTERV." WHERE  agence_id='".$agence."' AND inter_actif='0' AND inter_id NOT IN  $absinter  $where ORDER BY inter_nom,inter_pnom");
		while (($cc = dbi_fetch_row($qu)) )
		{
$int=$cc['inter_id'];
$abs=0;
$heures_contrat=0;
$sql="SELECT contrat_heure FROM ".TABLE_CONTRAT." WHERE inter_id = ".$int." AND agence_id = ".$agence." AND contrat_debut<=".$from." AND ( contrat_fin IS NULL  OR contrat_fin >".$from." OR contrat_fin = 0 ) ORDER BY contrat_debut DESC LIMIT 1";
list($heures_contrat)=dbi_fetch_row(dbi_query($sql));
// if($int==1984)
// echo " lll $abs lll".count($ABS[$int]);
// if($int==1984)
for ($k = 0 ; $k < count($ABS[$int]) ; $k++)
					{
					// echo $ABS[$int][$k];
					$abs+=$ABS[$int][$k]/60;
					}
$DATA[$int] = array( 'int' => $int,'hct'=> $heures_contrat ,'tot'=> 0,'abs'=> $abs);		

		
		}
// echo '<pre>';
// print_r($absinter);
// echo '<pre>';

?>


 <div id="tab">
<table  width=100%>
    <thead>
    	<tr>
		
		     <th ><A href=""style="cursor:pointer; font-weight:bold;color: white; text-decoration:none;text-transform : uppercase;font-size: 14px;" >Intervenant</A><SPAN class="sort">&uarr;</SPAN></th>
             <th ><A href="#" style="cursor:pointer; font-weight:bold;color: white; text-decoration:none;text-transform : uppercase;font-size: 14px;" >Heures au planning</A></th>
             <th ><A href="#" style="cursor:pointer; font-weight:bold;color: white; text-decoration:none;text-transform : uppercase;font-size: 14px;" >Heures au contrat</A></th>

		
		
        </tr>
    </thead>
	<tbody>
<?php
$queries = dbi_query("SELECT * FROM ".TABLE_INTERV." WHERE agence_id=$agence AND inter_actif='0' $where ORDER BY inter_nom,inter_pnom");
while (($c = dbi_fetch_row($queries)) )			
		{
		$inter=$c['inter_id'];
		
		$sqll="SELECT contrat_heure FROM ".TABLE_CONTRAT." WHERE inter_id = ".$inter." AND agence_id = ".$agence." AND contrat_debut<=".$from." AND ( contrat_fin IS NULL  OR contrat_fin >".$from." OR contrat_fin = 0 ) ORDER BY contrat_debut DESC LIMIT 1";
$hhc=dbi_fetch_row(dbi_query($sqll));


		
		$OK = true ;
		 for ($i = 0 ; $i < count($ABSENCE[$inter]) ; $i++)
		{
		$deb = $ABSENCE[$inter][$i][0];
		$fin = $to;
		if($ABSENCE[$inter][$i][1]) $fin = $ABSENCE[$inter][$i][1];
		
		if($deb <= $from && $fin >= $to)
		$OK = true ;  //-----------------> modification urgent  origin ---> $OK = false ;
		}	

		if($OK == true)
		{
if($filtre==1)
{
// echo "<pre>" ; 
// print_r($DATA) ; 
// echo "</pre>" ; 		
 $dif_contrat_planning = $DATA[$inter]['tot'] - $hhc['contrat_heure'] ;
 

 if( $dif_contrat_planning<0)
 {
 ?>


      
    	<tr style="background-color: #F97B73;"  >
		
		<TD ><A  class="couleur_ktba" href="top.php?link=interv&amp;page=caa&amp;id=<?=$c['inter_id']?>" target="ident"><?= '<font color="red">'.ucwords($c['inter_nom'].' '.$c['inter_pnom']).'</font>'?></A></TD>     
<td><b><?php if ($DATA[$inter]['tot'] > 0 ) echo '<font color="red">'.$DATA[$inter]['tot']; else echo '<font color="red">'.'0'.'</font>'; ?> <font color="red">heures</font></b></td>

<?php if($hhc['contrat_heure']) echo '<td>'.'<b> <font color="red">'.$hhc['contrat_heure'].' heures'.'</font></td>'; else echo '<td>'.'<b>'."n'a pas de contrat enregistré".'</td>'; ?>
<? $dif_contrat_planning = $DATA[$inter]['tot'] - $hhc['contrat_heure'] ; ?>

      </tr>
	 
	 <?
 }
 else
{
	 ?>

      
    	<tr style="background-color: #F97B73;"  >
		
		<TD ><A  class="couleur_ktba" href="top.php?link=interv&amp;page=caa&amp;id=<?=$c['inter_id']?>" target="ident"><?=ucwords($c['inter_nom'].' '.$c['inter_pnom'])?></A></TD>     
<td><b><?php if ($DATA[$inter]['tot'] > 0 ) echo $DATA[$inter]['tot']; else echo '0'; ?> heures</b></td>

<?php if($hhc['contrat_heure']) echo '<td>'.'<b>'.$hhc['contrat_heure'].' heures'.'</td>'; else echo '<td>'.'<b>'."n'a pas de contrat enregistré".'</td>'; ?>
<? $dif_contrat_planning = $DATA[$inter]['tot'] - $hhc['contrat_heure'] ; ?>

      </tr>
<?
}
?>






	 <?	}else{	
	if($DATA[$inter]['hct']>$DATA[$inter]['tot'])	{
	
?>
    	<tr>
		 <TD ><A href="top.php?link=interv&amp;page=caa&amp;id=<?=$c['inter_id']?>" target="ident"><?=ucwords($c['inter_nom'].' '.$c['inter_pnom'])?></A></TD>

<td><b><?php if ($DATA[$inter]['tot'] > 0 ) echo  $DATA[$inter]['tot']; else echo '0'; ?> heures</b></td>
<?php if($DATA[$inter]['hct']) echo '<td>'.'<b>'.$DATA[$inter]['hct'].' heures'.'</td>'; else echo '<td>'.'<b>'."n'a pas de contrat enregistré".'</td>'; ?>
<td><b><?php


?> 
</b></td>

        </tr>	
					
<?	
	}
}			


}
					}			
					?>	
</tbody>
</table>		

AnonSec - 2021