|
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 ] |
|---|
<html>
<body>
<script type="text/javascript" src="jquery.min.js"></script>
<script>
function modifier(id,duree,hdebut,hfin,com){
//window.location.replace("annexe.php?id=test");
window.location.replace("annexe_CDD.php?id="+id.value+"&duree="+duree.value+"&hdebut="+hdebut.value+"&hfin="+hfin.value+"&com="+com.value);
// &duree.value & hdebut=hdebut.value & hfin=hfin.value & com=com.value
//alert( id.value+duree.value + hdebut.value + hfin.value + com.value);
}
</script>
<?php
include_once 'code/init.php';
function heure2int( $str ) { // Convertir 3h30 => 210 minutes
$th = split('[hH]', $str);
$h = $th[0];
$m = $th[1];
return $h*10000+$m*100;
}
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] ;
}
function get_prest_sem( $interdispo,$from ,$to,$agence)
{
$id=0;
$p=array();
$db=debutsem(date('Y', strtotime($from)),date('m', strtotime($from)),date('d', strtotime($from)));
$dbto=debutsem(date('Y', strtotime($to)),date('m', strtotime($to)),date('d', strtotime($to)));
$fin=date('Ymd',int2time($dbto)+6*24*3600 );
while($db < $fin )
{
$and = date('Ymd',int2time($db)+6*24*3600 );
$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') ;
// echo " ---> $db // $id \n ";
$q2 = dbi_query("SELECT p.* FROM ".TABLE_PREST." p, ".TABLE_CLIENT." c WHERE p.client_id=c.client_id and p.agence_id=$agence AND presta_date_debut <= $and AND (p.presta_date_fin >= $db OR p.presta_date_fin IS NULL) ");
while($prest = dbi_fetch_row($q2))
{
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']) ;
// $q1 = dbi_query("SELECT * FROM ".TABLE_PRESTA_MODIF." WHERE presta_id = ".$prest['presta_id']." order by `start`, `date`") ;
$q1 = dbi_query("SELECT * FROM ".TABLE_PRESTA_MODIF." WHERE presta_id = ".$prest['presta_id']." AND start <= $and order by `start`, `date`") ;
// echo $prest['presta_jour'].' !! ';
while (($m = dbi_fetch_row($q1)) )
{
// if($m['start'] <= $to)
// {
$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'] ;
// }
}
$jour=$data['jour'];
// echo $jour.' ++++ ';
if (in_array($data['inter'], $interdispo)) {
$heurefin=addDuree($data['deb'],$data['duree']);
// $qexcept=dbi_query("SELECT * FROM ".TABLE_EXCEPT." WHERE (date BETWEEN ".$from." AND ".$to.") AND date <= ".jour_jouren2($presta_jour1[$jour],$from)." AND presta_id=".$prest['presta_id']." ");
$qexcept=dbi_query("SELECT * FROM ".TABLE_EXCEPT." WHERE (date BETWEEN ".$db." AND ".$and.") AND presta_id=".$prest['presta_id']." ");
if($rr = dbi_fetch_row($qexcept)){
}
else{
// echo "!! ".$data['jour']." / $db !!";
$presta=array("presta_id" => $prest['presta_id'],"presta_desc" => $prest['presta_desc'] , "presta_date_debut" => $prest['presta_date_debut'] , "presta_Hdeb" => $data['deb'] , "presta_Hduree" => $data['duree'] , "presta_recur" => $prest['presta_recur'] , "presta_date_fin" => $prest['presta_date_fin'] , "presta_jour" => $jour , "presta_forfait" => $prest['presta_jour'] , "presta_forfaitHT" => $prest['presta_forfaitHT'], "presta_status" => $prest['presta_status'] , "presta_sem" => $prest['presta_sem'] , "client_id" => $prest['client_id'] , "inter_id" => $data['inter'] , "agence_id" => $prest['agence_id'], "date" => jour_jouren2($jour,$db));
$p[$id]= $presta;
++$id;
// array_push($p['id'],$id);
// array_push($p['deb'],$data['deb']);
// array_push($p['fin'],$heurefin);
// array_push($p['cli'],$prest['client_id']);
// array_push($p['duree'],$data['duree']);
// array_push($p['jour'],$data['jour']);
// array_push($p['inter'],$data['inter']);
}
}
}
// $inters[$db]=$inter;
// echo " ++ $db ---> $and // ";
// get_prest_sem( $interdispo ,$interjour, $inters[$db],$db ,$agence);
$db = date('Ymd',int2time($db)+7*24*3600 );
}
// $to = time2int(int2time($from)+6*24*3600) ;
// echo " $from --> $to // "
// echo " !!!!!!!!!!!!!!!!! ";
// echo '<pre>';
// print_r($p);
// echo '</pre>';
return $p;
/*for( $numint=0 ; $numint < count($inters) ; $numint++ )
{
$inters[$numint]['presta']=array();
// echo $inters[$numint]['id'].' +++ ';
$interv=$inters[$numint]['id'];
$heures_contrat='';
$total=0;
for ( $j = 0 ; $j < count($p['id']);$j++)
{
if($p['inter'][$j]==$interv )
{
if( in_array($p['jour'][$j], $jourdispo))
{
// echo ' +++++++ '.$p['jour'][$j].' ! ';
// print_r($jourdispo);
// echo ' +++++++ '.$p['jour'][$j];
$debP=$p['deb'][$j];
$finP=$p['fin'][$j];
$client_idP=$p['cli'][$j];
$jourP=$presta_jour1[$p['jour'][$j]];
array_push($inters[$numint]['presta'],array( 'deb' => $debP, 'fin'=>$finP, 'cli' => array( '0' => $client_idP ),'jour'=>$jourP ));
}
$total+=$p['duree'][$j];
}
}
$heures_contrat=0;
$sql="SELECT contrat_heure FROM ".TABLE_CONTRAT." WHERE inter_id = ".$interv." 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));
$inters[$numint]['total']=$total/60;
$inters[$numint]['hcontrat']=$heures_contrat;
}*/
}
$pre=array();
$from = getPostDate('from') ;
$to = getPostDate('to') ;
$a = array() ;
$a[0]= $_POST['interv_id'] ;
$pre=get_prest_sem( $a,$from,$to ,$agence);
// print_r($_POST['inter']);
// echo " $from ++++++++ $to ";
// echo '<pre>';
// print_r($pre);
// echo '</pre>';
// echo '<pre>';
// print_r($pre);
// echo '</pre>';
if(isset($_GET['id'])&& isset($_GET['hfin']))
{
// echo "<pre>" ;
// print_r($_GET) ;
// echo "</pre>" ;
$Hdebb =heure2int($_GET['hdebut']) ;
// echo "---->".$_GET['hdebut']."br/" ;
// echo "---> $Hdebb <br/>" ;
$idd= $_GET['id'] ;
$duree=$_GET['duree']*60 ;
// echo "---> $duree <br/>" ;
$comnt =$_GET['com'] ;
// dbi_query ("UPDATE SET yassin presta_Hdeb=$Hdebb , presta_Hduree=$duree , Adresse3_Chantier="."'$Adresse3_Chantier'"." where id=$idd=");
dbi_query ("UPDATE annexeCDD SET presta_Hdeb=$Hdebb , presta_Hduree=$duree,commentaire='$comnt' where id=$idd");
}
$intero= $_POST['interv_id'] ;
$_POST['tmp']="annexe_CDD";
if(isset($_POST['PDF']))
{
// echo "<pre>" ;
// print_r($_POST) ;
// echo "</pre>" ;
$array = array_keys($_POST);
foreach ($array as $value)
{
// echo $value; echo '<br />';
//
if($value != "interv_id" AND $value != "ID" AND $value != "dure" AND $value != "Hdeb" AND $value != "Hfin" AND $value != "COMT" AND $value!= "PDF" AND $value!= "tmp" )
{
$cheek[] = $value ;
}
}
// print_r($cheek) ;
// "<br/>" ;
$taille=count($cheek) ;
$page = " where id != 222 " ;
for($i=0 ; $i<$taille ; $i++)
{
if(is_numeric($cheek[$i]))
{
$page .= " and id != ".$cheek[$i] ;
}
// echo "--dd->".$cheek[$i]."<br/>" ;
}
// echo "$page <br/>" ;
// exit() ;
dbi_query ("DELETE FROM annexeCDD $page ");
if (!is_dir("templates"))
{
mkdir("templates", 0755) ;
chmod("templates", 0755) ;
}
if (!is_dir("templates/".$_POST['tmp']))
{
mkdir("templates/".$_POST['tmp'], 0755) ;
chmod("templates/".$_POST['tmp'], 0755) ;
}
$intero= $_POST['interv_id'] ;
include_once 'includes/tmp_annexCDD_pdf.php' ;
if(isset($_POST['tmp'])) {include 'template_'.$_POST['tmp'].'.php';}
$pdf = new Template ($lecontenu,$letitre,$lecour);
$nompdf=$_POST['interv_id'];
$path = "templates/".$_POST['tmp']."/".$nompdf.".pdf";
$pdf->Output($path, 'F') ;
//header("Content-disposition: attachment; filename=".$_POST['tmp']."-$nom_inter-".$_POST['contrat_id'].".pdf");
header("Content-Disposition: attachment;location:templates/".$_POST['tmp']."/".$nompdf.".pdf" );
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("location:templates/".$_POST['tmp']."/".$nompdf.".pdf" );
header("Content-Length: ".filesize($path));
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
readfile($path);
}
if(isset ($_POST['Ajouter']))
{
dbi_query("DROP TABLE IF EXISTS annexeCDD") ;
dbi_query("CREATE TABLE IF NOT EXISTS annexeCDD (`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,`agence_id` INT ,`client_bureau` INT,`inter_bureau` INT,`inter_id` INT ,`inter_genre` TEXT ,`inter_nom` TEXT ,`client_id` INT ,`client_nom` TEXT ,`presta_id` INT ,`presta_Hdeb` INT ,`presta_Hduree` INT ,`presta_jour` VARCHAR( 20 ) NOT NULL ,`presta_forfait` DECIMAL( 5,2 ),`commentaire` TEXT ) ENGINE = MYISAM ;");
$q4 = dbi_query("SELECT * FROM ".TABLE_CLIENT." where agence_id=$agence AND client_actif='0' ");
// echo "-----> $date <br/>" ;
// exit() ;
$date = date('Ymd');
// partie client ..................
// $q = dbi_query("SELECT * FROM ".TABLE_PREST." p where p.client_id=".$clien['client_id']." AND p.agence_id=$agence AND (p.presta_date_fin > $date or p.presta_date_fin is NULL) ");
// $q = dbi_query("SELECT * FROM ".TABLE_PREST." p where inter_id = $intero AND p.agence_id=$agence AND (p.presta_date_fin > $date or p.presta_date_fin is NULL) ");
// $date = time2int($time) ;
for($i=0 ; $i<count($pre) ; $i++)
{
$agence = $pre[$i]['agence_id'] ;
$inter = dbi_fetch_row(dbi_query("SELECT * FROM ".TABLE_INTERV." WHERE inter_id = '".$pre[$i]['inter_id']."' AND agence_id = $agence")) ;
$clien = dbi_fetch_row(dbi_query("SELECT * FROM ".TABLE_CLIENT." WHERE client_id = '".$pre[$i]['client_id']."' AND agence_id = $agence")) ;
$client_id=$clien['client_id'];
$client_bureau=$clien['client_bureau'];
$inter_bureau=$inter['inter_bureau'];
$client_nom=addslashes($clien['client_nom'].' '.$clien['client_pnom']);
$inter_id=$inter['inter_id'] ;
$inter_nom=addslashes($inter['inter_nom'].' '. $inter['inter_pnom']);
$inter_genre=$inter['inter_genre'];
$inter_bureau=$inter['inter_bureau'];
$presta_id = $pre[$i]['presta_id'] ;
$jour=$pre[$i]['date'];
$Hdeb=$pre[$i]['presta_Hdeb'];
$Hduree=$pre[$i]['presta_Hduree'];
$taux=$pre[$i]['presta_forfait'];
$sqlinsert = "INSERT INTO annexeCDD VALUES ('','$agence', '$client_bureau', '$inter_bureau', '$inter_id', '$inter_genre', '".$inter_nom."', '$client_id', '".$client_nom."', '$presta_id', '$Hdeb', '$Hduree', '$jour', '$taux', '')";
dbi_query ( $sqlinsert );
}
}
if( isset($_POST['Modifier']) or !empty($intero) or isset($_GET['id']))
{
?>
<table class="td_normal" BORDER="1" cellpadding="4">
<thead>
<tr >
<th rowspan=2 class="td_normal" scope="col">client</th>
<th rowspan=2 scope="col">adresse</th>
<th rowspan=2 scope="col">jour</th>
<th rowspan=2 scope="col">Durée</th>
<th rowspan=2 scope="col">H debut</th>
<th rowspan=2 scope="col">H fin</th>
<th rowspan=2 scope="col">Commentaire </th>
<td style="white-space : nowrap;">check </td>
<td style="white-space : nowrap;">action </td>
</tr>
</thead>
<tbody>
<?
//---------------------------------------------
$sql .="SELECT * FROM annexeCDD ";
$req = dbi_query($sql);
$tmp = 0 ;
?>
<form action="" method="post" class="td_normal" >
<?
while($info = dbi_fetch_row($req))
{
list($adr1,$adr2,$adr3,$cp,$ville) = dbi_fetch_row(dbi_query(" SELECT client_adr1,client_adr2,client_adr3,client_cp,client_ville FROM client WHERE client_id = ".$info['client_id'])) ;
$adress = $adr1." ".$adr2." ".$adr3." ".$cp." ".$ville ;
$tmp++ ;
echo '<tr>';
?>
<tr >
<input type="hidden" name="interv_id" value="<?=$intero?>" style="width:50px;">
<input type="hidden" name="ID" value="<?=$tmp?>" style="width:50px;">
<td style="white-space : nowrap;"><A href="top.php?link=client&page=aaa&id=<?=$info['client_id'] ?>"><?=ucwords($info['client_nom'])?></A></td>
<td style="white-space : nowrap;"><?=$adress?></td>
<td class="td_normal" style="white-space : nowrap;"><?=int2date($info['presta_jour'])?></td>
<td style="white-space : nowrap;"><input type="text" name=<?="dureedd".$info['id']?> value="<?=$info['presta_Hduree']/60?>" > </td>
<td style="white-space : nowrap;"><input type="text" name=<?="Hdeb".$info['id']?> value="<?=int2heure($info['presta_Hdeb'])?>" > </td>
<td ><input type="text" name=<?="Hfin".$info['id']?> value="<?=int2heure(addDuree($info['presta_Hdeb'], $info['presta_Hduree']))?>" > </td>
<td style="white-space : nowrap;"><input type="text" name=<?="COMT".$info['id']?> value="<?=$info['commentaire']?>" > </td>
<td style="white-space : nowrap;"><input type="checkbox" name="<?=$tmp?>" value="<?=$tmp?>" > </td>
<input type="hidden" name=<?="id".$info['id']?> value="<?=$info['id']?>" >
<td colspan="4" align="right" class="td_listing1"><input type="button" name="Modifier" onClick="modifier(<?="id".$info['id']?>,<?="dureedd".$info['id']?>,<?="Hdeb".$info['id']?>,<?="Hfin".$info['id']?>,<?="COMT".$info['id']?>);" value="Modifier" class="big" ></td>
</tr>
<?php
}
?>
<input type="hidden" name="interv_id" value="<?=$intero?>" style="width:50px;">
<td colspan="8" align="center" class="td_listing1"><input type="submit" name="PDF" value="PDF" class="bigbutton" ></td>
</form>
<?
}
session_start();
if(isset($_POST['interv_id'], $_POST['nbh']) && !isset($_POST['contrat_id']))
{
//exit('-------->'.$_POST['duree_h']);
$nb = dbi_fetch_row(dbi_query("select count(*) nb from ".TABLE_INTERV." where agence_id=$agence AND inter_id = ".$_POST['interv_id'])) ;
}
print_header ('','','style="margin-top:15px; padding:20px;"');
if(!isset($_POST['Ajouter']) AND !isset($_POST['Modifier']) AND !isset($_GET['id']))
{
?>
<form action="" method="post">
<input type="hidden" name="Ajouter" style="width:50px;">
<input type="hidden" name="" value=""/>
<table class="td_normal" cellpadding="4">
<tr>
<td>Du : </td>
<td colspan="2"><?php print_date_selection('from', $route_du) ;?></td>
</tr>
<tr>
<td>Au : </td>
<td colspan="2"><?php print_date_selection('to', $route_au) ;?></td>
</tr>
<tr>
<td>
intervenantsss :
</td>
<td>
<?
$intervenant = dbi_query("SELECT * FROM intervenant where agence_id = $agence and inter_actif = '0' ORDER BY `intervenant`.`inter_nom` ASC ");
?>
<select name="interv_id">
<?
while($inter=dbi_fetch_row($intervenant))
{
?>
<option value="<?=$inter['inter_id']?>"> <?=$inter['inter_nom']."".$inter['inter_pnom']?></option>
<?}?>
</select>
</td>
<td colspan="2" align="right" class="td_listing1"><input type="submit" value="Ajouter" class="bigbutton" onClick="this.disabled=true;this.form.submit();"></td>
</tr>
</table>
</form><br /><br />
<?
}
// dbi_query("DROP TABLE IF EXISTS prest_temp_".$agence."");
?>
</body></html>