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/MCPRO/code/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/MCPRO/code/chant2.php
<?php
include_once 'code/init.php';
print_header();
print_r($_POST);
$sem = array ('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi') ;
?>
<script type="text/javascript">

function Confirme(URL)
{
   if (confirm("Etes-vous certain de vouloir supprimer cette entrée ?"))
   {
       window.location = URL;
   }
}
</script>
<?php
// print_r($_GET);
if($_GET['client_id'])
$client_id = @(int)$_GET['client_id'];
elseif($_POST['client_id'])
$client_id = @(int)$_POST['client_id'];


if ( isset( $_GET['action']) && $_GET['action'] == 'sup' )
{
if (isset( $_GET['chantier_id']) && !empty( $_GET['chantier_id']))
	dbi_query("DELETE FROM ".fact_chantier." WHERE ID = '".$_GET['chantier_id']."'") ;
}


if (isset($_POST['Chantier_designation']))
{
	$client_id=@(int)$_POST['client_id'];
	$chantier = dbi_fetch_row(dbi_query("SELECT * FROM ".chantier." WHERE client_id = $client_id")) ;
	if($chantier['Chantier_ID'] > 0)
	{
		$Chantier_ID=$chantier['Chantier_ID'];
	}
	else
	{
		dbi_query ( "INSERT INTO ".chantier." (`Chantier_ID` ,`client_id`,`agence_id`) 	VALUES ('','$client_id','$agence')");
		$Chantier_ID=mysql_insert_id();
	}
		
		
	$Chantier_designation=mysql_real_escape_string(ucwords(strtolower(getPostValue('Chantier_designation'))));
	$Chantier_forfaitmensuel=str_replace(',', '.', getPostValue('Chantier_forfaitmensuel'));
	$Chantier_TVA=str_replace(',', '.', getPostValue('Chantier_tva'));

	$datedebut=date2int($_POST['datedebday'],$_POST['datedebmonth'],$_POST['datedebyear']);
	if(  isset($_POST['connu']) )
	$datefin=date2int($_POST['datefinday'],$_POST['datefinmonth'],$_POST['datefinyear']);
	else
		$datefin=NULL;
	
	$Chantier_debut=$datedebut;
	$Chantier_fin=$datefin;
	$chant_type=$_POST['chant_type'];
	$facture=$_POST['facture'];
	if(isset($_POST['ID']))
	{
	// echo $_POST['ID'].' // ';
	$ID=$_POST['ID'];
	$sqlupdate = "UPDATE fact_chantier SET Chantier_designation="."'$Chantier_designation'"." , Chantier_TVA="."'$Chantier_TVA'".", Chantier_forfaitmensuel="."'$Chantier_forfaitmensuel'"." , Chantier_debut="."'$Chantier_debut'".", Chantier_recur="."'$chant_type'".", Chantier_fact="."'$facture'".", Chantier_fin="."'$Chantier_fin'"." where ID="."'$ID'";
	// echo $sqlupdate;
	}
	else
	{
		if($_POST['chant_type']==1)
		{
				$sqlupdate = "INSERT INTO ".fact_chantier." (`ID` ,`Chantier_ID`,`Chantier_designation` , `Chantier_forfaitmensuel`  ,`Chantier_TVA`, `Chantier_debut`  , `Chantier_fin`, `Chantier_recur`  , `Chantier_fact`) 
		VALUES ('','$Chantier_ID','$Chantier_designation' , '$Chantier_forfaitmensuel', '$Chantier_TVA' ,'$Chantier_debut', '$Chantier_fin','$chant_type','$facture')";
		}
		else
			$sqlupdate = "INSERT INTO ".fact_chantier." (`ID` ,`Chantier_ID`,`Chantier_designation` , `Chantier_forfaitmensuel`  ,`Chantier_TVA`, `Chantier_debut`  , `Chantier_fin`) 
		VALUES ('','$Chantier_ID','$Chantier_designation' , '$Chantier_forfaitmensuel', '$Chantier_TVA' ,'$Chantier_debut', '$Chantier_fin')";
	}

	dbi_query ( $sqlupdate );

	$_GET['client_id'] = @(int)$_POST['client_id'];

}

if (!empty($_GET['id'] ))
{
$ID = $_GET['id'] ;
	$chantier = $ID ? dbi_fetch_row(dbi_query("SELECT * FROM fact_chantier WHERE ID = $ID")) : array() ;
	$Chantier_desig=$chantier['Chantier_designation'];
	$Chantier_forfaitmens=$chantier['Chantier_forfaitmensuel'];
	// $Chantier_tauxhoraire=$chantier['Chantier_tauxhoraire'];
	$datededebut=$chantier['Chantier_debut'];
	$datedefin=$chantier['Chantier_fin'];
	$Chantiertva=$chantier['Chantier_TVA'];
	$Chantier_type=$chantier['Chantier_recur'];
	$facture=$chantier['Chantier_fact'];
	if(!empty($datedefin))
	$connue=1;
	// if($Chantier_type==1)
	// {
// $style="style.display = 'inline'";
	// }
}
if ( isset( $_GET['action']) && $_GET['action'] == 'sup' )
{
if (isset( $_GET['chantier_id']) && !empty( $_GET['chantier_id']))
	dbi_query("DELETE FROM ".fact_chantier." WHERE ID = '".$_GET['chantier_id']."'") ;
}
?>
<table style="width:90%;text-align:center;" align="center">
<tr>
<td class="tdl">

<div id="sb" >
<form  method="post" action="" > 
    <?=$client_id ? '<input type="hidden" name="client_id" value="'.$client_id .'">' : ''?>
	<?=$Chantier_ID ?  '<input type="hidden" name="Chantier_ID" value="'.$chantier['Chantier_ID'].'">' : ''?>
	<?=$_GET['id'] ?  '<input type="hidden" name="ID" value="'.$_GET['id'].'">' : ''?>
<h3>DESIGNATION</h3>
    <table style="width:100%;" >
    <tr>
        <td class="td2"><b>Designation  :</b></td>
        <td class="td2" colspan="5" >
<textarea name="Chantier_designation"rows="3" class="field required"><?php if(isset($Chantier_desig)) echo $Chantier_desig;?> </textarea></td>
    </tr>
	<tr>
        <td class="td2"><b>Type :</b></td>
		<td class="td2" >		
			<select id="chant_type" name="chant_type"  onChange="change()" style="width:100%" class="field required">
				<option value="0" <?php if( $Chantier_type == 0) echo 'selected="selected"'; ?>>Chantier régulier</option>
				<option value="1" <?php if( $Chantier_type == 1) echo 'selected="selected"'; ?>>Chantier ponctuel</option>
			</select>
		</td>
        <td class="td2"><b>Montant HT :</b></td>
		<td class="td2"><input type="text" name="Chantier_forfaitmensuel" value="<?=$Chantier_forfaitmens?>" size="25" maxlength="60" class="field required" /></td>
        <td class="td2"><b>TVA :</b></td>
		<td class="td2"><input type="text" name="Chantier_tva" value="<?=$Chantiertva?>" size="25" maxlength="60" class="field required"/></td>
	</tr>
	
	<tr>
	  	<?php	if(isset($datededebut))	$dated=$datededebut;		?>
        <td class="td2" ><b>Date de début :</b></td>
        <td class="td2" colspan="2"><?php print_date_selection2('datedeb',(isset($datededebut)?$dated:$datedeb))?></td>      
	  	<?php	if(isset($datedefin))	$datef=$datedefin;	?>
        <td class="td2"><input type="checkbox" name="connu"<?=$connue ? ' checked="checked"' : ''?> onclick="var f = this.form ; f.datefinday.disabled = f.datefinmonth.disabled = f.datefinyear.disabled = f.datefinbutton.disabled = this.checked;"><b>Date de fin :</b></td>
        <td class="td2" colspan="2"><?php print_date_selection2('datefin',(isset($datedefin)?$datef:$datefin),$connu)?></td> 
      </tr>
    
</table>  
<input name="valider" type="submit" value=" Enregistrer " style="float:right;margin-right:100px;margin-top:40px;" class="blubutton"  />
</form>
</div>

</td>
</tr>
</table>



<br/>
  
  <?php
	$chant=dbi_query("SELECT * FROM chantier c, fact_chantier fc WHERE agence_id=".$agence." AND client_id=".$client_id." AND c.Chantier_ID=fc.Chantier_ID ORDER BY fc.Chantier_designation ");
?>

<div id="tab"  >
	<table >
	<caption style="font-weight:bold"> CHANTIERS <caption> 
		<tr>
			<th>Designation</th>
			<th>Montant HT</th>
		    <th>Début</th>		
			<th>Fin</th>
			<th>Action</th>
			<th>Prestation</th>	
			
		</tr>
<?php
$inc=' (  ';
$k=0;
 while($listchantier=dbi_fetch_row($chant)){ 
$tauxtva=$listchantier['Chantier_forfaitmensuel']*($listchantier['Chantier_TVA']/100);
?>
		<TR>
			<TD><?=$listchantier['Chantier_designation']; ?></TD>
			<TD><?=number_format($listchantier['Chantier_forfaitmensuel'], 2, ', ', ' '); ?></TD>
			<TD><?=int2date($listchantier['Chantier_debut']); ?></TD>
			<TD><?php if($listchantier['Chantier_fin']) echo int2date($listchantier['Chantier_fin']); ?></TD>
			<TD align="center"><a href="?action=edit&client_id=<?=$client_id;?>&id=<?=$listchantier['ID'];?>"><img src="images/edit.png" alt="edit" /></a> &nbsp;&nbsp;&nbsp;
			

			
			<a href="?action=sup&chantier_id=<?=$listchantier['ID'];?>&client_id=<?=$client_id?>" onclick="Confirme('chant.php?action=sup&chantier_id=<?=$listchantier['ID']?>&client_id=<?=$client_id?>'); return false;"><img src="images/sup.png" alt="sup" /></a>
			</TD>
		    <TD align="center">	<a rel="{handler:'iframe',size:{x:700,y:480}}" class="modal" href="aac11.php?id=<?=$listchantier['ID'];?>&client_id=<?=$client_id?>"><input name="Ajouter une prestation" type="button" value="Ajouter une prestation" style="float:left;margin-left:100px;" class="blubutton"  /></a></TD> 
		</TR>
<?php 
if($k==0)
$inc.=' '.$listchantier['ID'];
else
$inc.=' , '.$listchantier['ID'];
$k++;
}
$inc.=' ) ';

 ?>
		

</TABLE>



<br/><br/>


<table>
<?php  
if($k>0) {

	$q = dbi_query("SELECT *, IF((p.presta_date_fin is NULL OR p.presta_date_fin >= CURDATE()+0 OR EXISTS (SELECT * from ".TABLE_EXCEPT." e, ".TABLE_PREST." pe WHERE e.presta_id = p.presta_id AND e.new_presta_id = pe.presta_id AND pe.presta_date_debut >= CURDATE()+0 AND e.en_cours = '1' AND agence_id=$agence)),0,1) as finie FROM ".TABLE_PREST." p where p.agence_id=$agence AND client_id=".$client_id." AND chantier_id IN $inc AND p.presta_id NOT IN (select new_presta_id from ".TABLE_EXCEPT." WHERE new_presta_id IS not null) AND (p.presta_date_fin is NULL OR p.presta_date_fin >= SUBDATE(CURDATE()+0, INTERVAL 1 YEAR) OR EXISTS (SELECT * from ".TABLE_EXCEPT." e, ".TABLE_PREST." pe WHERE e.presta_id = p.presta_id AND e.new_presta_id = pe.presta_id AND pe.presta_date_debut >= CURDATE()+0 AND e.en_cours = '1' AND agence_id=$agence)) AND presta_recur = '1' ORDER BY finie, presta_recur DESC, presta_jour DESC, presta_date_debut, presta_date_fin");
$print_p_r = (mysql_num_rows($q)>0);
if ($print_p_r) {
?>
	<caption style="font-weight:bold"> Prestations r&eacute;guli&egrave;res </caption> 
	<tr> 
		<th>Jour</th>
		<th>H début</th>
		<th>H fin</th>
		<th>Type</th>
		<th>Intervenant</th> 
		<th>Infos complémentaires</th> 
		<th>Date fin</th> 			
		<th>Modifier</th>		
	</tr>		
<?php
	$jour = date('w') ;
	$time = time() ;
	while($jour != 0)
	{
		$jour = ++$jour %7 ;
		$time += 24*3600 ;
	}
	$date = time2int($time) ;
	while($prest = dbi_fetch_row($q))
	{
		$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`") ;
		while (($m = dbi_fetch_row($q1)) && $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'] ;
		}
		$inter = dbi_fetch_row(dbi_query("SELECT * FROM ".TABLE_INTERV." WHERE inter_id = '".$data['inter']."' AND agence_id = $agence")) ;
		$type = dbi_fetch_row(dbi_query("SELECT prestation_type_intitul FROM ".prestation_type." WHERE prestation_type_id = '".$prest['prestation_type']."'")) ;
		$jour = '' ;
		foreach($sem as $i => $s)
			if($data['jour'][$i] == 'y')
				$jour .= $s ;

			
?>
	<tr>   
		<td><b><?=$jour?><b/></td>
		<td><b><?=int2heure($data['deb'])?></b></td>
		<td><b><?=int2heure(addDuree($data['deb'], $data['duree']))?></b></td>
		<td><b><?=$type['prestation_type_intitul']?><b/></td>
		<td><b><?=($inter ? sprintf("%s %s %s", $inter['inter_genre'], $inter['inter_nom'], $inter['inter_pnom']) : '<span style="color:red;">Pas d\'intervenant choisi</span>')?></b></td>
		<td><?=$prest['presta_desc']?></td>
		<td><?=$prest['presta_date_fin'] ? '<b style="color:red">'.int2date($prest['presta_date_fin']).'</b>' : 'Pas de date de fin'?></td>
		<td><a rel="{handler:'iframe',size:{x:700,y:500}}" class="modal" href="aac2.php?presta_id=<?=$prest['presta_id']?>"><img src="images/edit.png" alt="edit" /></a>	</td>
	</tr>
		<?php		
	}
	echo '</table><br/><br/>';



}
	$q = dbi_query("SELECT * FROM ".TABLE_PREST." p LEFT JOIN ".TABLE_INTERV." i on p.inter_id = i.inter_id where presta_recur = '' AND p.agence_id=$agence AND client_id=".$client_id." AND chantier_id IN $inc AND p.presta_id NOT IN (select new_presta_id from ".TABLE_EXCEPT." WHERE new_presta_id IS not null) ORDER BY presta_date_debut");
$print_p = (mysql_num_rows($q)>0);
if ($print_p) {
?>
<br/>


<table>
<caption style="font-weight:bold"> Prestations ponctuelles </caption> 
	<tr> 
		<th>Jour</th>
		<th>H début</th>
		<th>H fin</th>
		<th>Type</th>
		<th>Intervenant</th> 
		<th>Infos complémentaires</th> 
		<th>Date fin</th> 			
		<th>Modifier</th>		
	</tr>
<?php
	while($prest = dbi_fetch_row($q))
	{
			$type = dbi_fetch_row(dbi_query("SELECT prestation_type_intitul FROM ".prestation_type." WHERE prestation_type_id = '".$prest['prestation_type']."'")) ;
$frdate=int2date($prest['presta_date_debut']);
list($jour, $mois, $annee) = explode('/', $frdate);
$timestamp = mktime (0, 0, 0, $mois, $jour, $annee);


	?>
	<tr>   
		<td><b><?=$sem[date("w",$timestamp)]; ?><b/></td>
		<td><b><?=int2heure($prest['presta_Hdeb'])?></b></td>
		<td><b><?=int2heure(addDuree($prest['presta_Hdeb'], $prest['presta_Hduree']))?></b></td>
		<td><b><?=$type['prestation_type_intitul']?><b/></td>
		<td><b><?=$prest['inter_nom'] ? sprintf("%s %s %s", $prest['inter_genre'], $prest['inter_nom'], $prest['inter_pnom']) : '<span style="color:red;">Pas d\'intervenant choisi</span>'?></b></td>
		<td><?=$prest['presta_desc']?></td>
		<td><?=$prest['presta_date_fin'] ? '<b style="color:red">'.int2date($prest['presta_date_fin']).'</b>' : 'Pas de date de fin'?></td>
		<td><a rel="{handler:'iframe',size:{x:700,y:500}}" class="modal" href="aac2.php?presta_id=<?=$prest['presta_id']?>"><img src="images/edit.png" alt="edit" /></a>	</td>	
	</tr>
		<?php
	}
}

echo '</table><br/><br/>';
echo (!$print_p && !$print_p_r) ? '<h2 align="center">Aucune prestation future</h2>' : '' ;
}


 

?>


</div>
<br/><br/>


AnonSec - 2021