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/MC/temp/../

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/MC/temp/../stats3.php
<?php
include_once 'code/init.php';
include_once 'function-news.php';
$TVA=7;	
// print_r($_POST);
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($from ,$to,$agence,&$clients)
{
$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 );
$fin = date("Ymd", strtotime("+6 day", strtotime($dbto)));
while($db < $fin )
	{
	// $and = date('Ymd',int2time($db)+6*24*3600 );
	$and = date("Ymd", strtotime("+6 day", strtotime($db)));
	// $and = date("Ymd", strtotime("+6 day", strtotime($db)));
	// echo "$db / $and <br/>";
$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 * FROM ".TABLE_PREST." p  WHERE 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']." AND start <= $and  order by `start`, `date`") ;
	
		
		while (($m = dbi_fetch_row($q1)) )
		{
				$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,$db);

	$heurefin=addDuree($data['deb'],$data['duree']);
	$qexcept=dbi_query("SELECT * FROM ".TABLE_EXCEPT." WHERE (date BETWEEN ".$db." AND ".$and.") AND presta_id=".$prest['presta_id']." AND new_presta_id IS NULL");	
	
	if($rr = dbi_fetch_row($qexcept)){
		if(  (($rr['new_presta_id'] == NULL	|| $rr['en_cours'] = '1')  || ($rr['new_presta_id'] != NULL	&&	$rr['en_cours'] = '')) && $rr['facture'] == '1'  )
					{			
						$p[] = array(
						'id' => $prest['presta_id'],
						'excpt_id' => $rr['excpt_id'],
						'client_id' => $prest['client_id'],
						'nbH' => '',
						'taux' => $data['taux'],
						'tauxHT' => $data['tauxHT'],
						'type' => 'e',
						'date' => $date,
						'jour' => $data['jour'],
						'inter_id' => $data['inter'],
						'deb' => $data['deb'],
						'typepre' => $prest['presta_recur'],
						'duree' => $data['duree'],
						'fin' => $heurefin) ;	
						if (!in_array($prest['client_id'],$clients)) $clients[]=$prest['client_id'];
						// echo $rr['date'].' !! '. $data['duree']/60 . ' / '. $data['taux'].' ?? '.'<br>';
					}
			}
			else
			{
				if( $date >= $from  && $date <= $to )
				{
					$p[] = array(
					'id' => $prest['presta_id'],
					'client_id' => $prest['client_id'],
					'nbH' => '',
					'taux' => $data['taux'],
					'tauxHT' => $data['tauxHT'],
					'type' => 'p',
					'date' => $date,
					'jour' => $data['jour'],
					'inter_id' => $data['inter'],
					'deb' => $data['deb'],
					'typepre' => $prest['presta_recur'],
					'duree' => $data['duree'],
					'fin' => $heurefin) ;
					if (!in_array($prest['client_id'],$clients)) $clients[]=$prest['client_id'];
					}
			}

	}

	// $db = date('Ymd',int2time($db)+7*24*3600 );
	$timed=$db;
	$db = date("Ymd", strtotime("+7 day", strtotime($timed)));
	}

	return $p;
	


}
//track();
// print_r($_POST);
// echo ' -------- ';
// print_r($_GET);
global $content, $graphx;
$tauxtva=1.055;
$le_mois_dernier = sprintf("%04d%02d%02d", date('Y'), date('m')-1, date('d'));
$ce_mois_ci = sprintf("%04d%02d%02d", date('Y'), date('m'), date('d'));
$debut_de_ce_mois = sprintf("%04d%02d%02d", date('Y'), date('m'), 1);
$fin_de_ce_mois = sprintf("%04d%02d%02d", date('Y'), date('m'), date('t'));
// echo " $debut_de_ce_mois ! $fin_de_ce_mois ";
// echo " $from  / $to ";
if(!empty($_POST))
{
 // [debutmonth] => 4 [debutyear] => 2013 [finmonth] => 4 [finyear] => 2013 )
	// $from = 20130401 ;
	// $to = 20130430 ;
	$from = getPostDate('debut') ;
	// $to = getPostDate('fin') ;
	$moisd=$_POST['debutmonth'];
	$anneed=$_POST['debutyear'];
	$moisd=$_POST['finmonth'];

	$nb_jour = date('t',mktime(0, 0, 0, $moisd, 1, $anneed)); 
	$to = sprintf("%04d%02d%02d", $anneed, $moisd, $nb_jour ) ;

		
} else {
	$from = $debut_de_ce_mois ;
	$to = $fin_de_ce_mois ;
	
}
		
	$facture = array() ;
	$clients=array();
	$pre=get_prest_sem( $from,$to ,$agence,$clients);
	// echo '<pre>';
	// print_r($pre);
    // echo '</pre>';
print_header() ;


 

$inc='( 0  ';
		for ($i = 0 ; $i < count($clients) ; $i++)
		{
			$inc.=' , '.$clients[$i];
		}
$inc.=') '	;

$TOTAL=0;
$TOTALHT=0;
$TOTALTVA=0;
$green="border:3px solid gray";
$rc = dbi_query("SELECT client_id,client_genre genre, client_nom nom, client_pnom prenom, concat_ws('\n', if(client_adr1 = '', NULL, client_adr1), if(client_adr2 = '', NULL, client_adr2), if(client_adr3 = '', NULL, client_adr3)) adresse, client_cp cp, client_ville ville, client_reglement reglement FROM ".TABLE_CLIENT." WHERE agence_id = '$agence' AND client_id IN $inc ORDER BY client_nom,client_pnom") ;	

while($client = dbi_fetch_row($rc))
{
$client_id=$client['client_id'];
$TOTAL_CL=0;
$TOTALHT_CL=0;
$TOTALTVA_CL=0;
?>

<table cellspacing="0" cellpadding="0"  border="1"  style="<?=$green;?>" align="midle" class="td_normal"><tbody>
<tr>  <td align="center" class="td_listing1b" colspan="6"><?=sprintf("%s %s %s", $client['genre'], strtoupper($client['nom']), ucwords(strtolower($client['prenom']))) ;?></td>    </tr>
<tr>  <td align="center" class="td_listing1b" width="30%"></td><td align="center" class="td_listing1b" width="10%">Exception</td><td align="center" class="td_listing1b" width="10%">Montant HT</td><td align="center" class="td_listing1b" width="10%">TVA</td><td align="center" class="td_listing1b" width="10%">Taux TVA</td><td align="center" class="td_listing1b" width="10%">TTC</td>  </tr>
<?php						for($j=0;$j<count($pre);$j++)
				{
				
				$HTPR=0;
				$TTCPR=0;
				$TAUXPR=0;
				// echo $client_id.' ! ';
						if(($pre[$j]['type']=='p' || $pre[$j]['type']=='e' )&& $pre[$j]['client_id']==$client_id)
					{
					// echo " T ".$pre[$j]['type'];
								$nbH = $pre[$j]['duree'] / 60 ;
								$taux = $pre[$j]['taux'] ;
								
								$TTCPR = $nbH*$taux;
								
								$HTPR = $TTCPR / (1+($TVA/100));
								$TAUXPR = $TTCPR-$HTPR;
								
								$TOTAL+=$TTCPR;
								$TOTALHT+=$HTPR;
								$TOTALTVA+=$TAUXPR;
								
								$TOTAL_CL+=$TTCPR;
								$TOTALHT_CL+=$HTPR;
								$TOTALTVA_CL+=$TAUXPR;
					
?>
<tr>   
    <td width="30%" align="left" class="td_listing1"><?=$client_id.' / '.$pre[$j]['client_id'].' !! '.$pre[$j]['id'].' Prestation du '.ucfirst(presta_jour2jour($pre[$j]['jour'])).' ('.int2heure($pre[$j]['deb']).'-'.int2heure(addDuree($pre[$j]['deb'], $pre[$j]['duree'])).') '.'Intervention du '.int2date($pre[$j]['date']);?></td>
	<td width="10%" align="center" class="td_listing1"><?php if($pre[$j]['type']=='e' ) echo "<b>X</b>";?></td>
	<td width="10%" align="center" class="td_listing1"><?=number_format( $HTPR , 2 , ",", " ").' &euro;';?></td>
	<td width="10%" align="center" class="td_listing1"><?=number_format( $TAUXPR , 2 , ",", " ").' &euro;';?></td>
	<td width="10%" align="center" class="td_listing1"><?=$TVA.' % '?></td>
	<td width="10%" align="center" class="td_listing1"><?=number_format( $TTCPR, 2, ",", " " ).' &euro;';?></td>
</tr>
<?php
					
					
					}
				}	
					
?>					
<tr>   
    <td width="30%" align="center" class="td_listing1b">TOTAL</td>
	<td width="10%" align="center" class="td_listing1b"></td>
	<td width="10%" align="center" class="td_listing1b"><?=number_format( $TOTALHT_CL, 2, ",", " " ).' &euro;';?></td>
	<td width="10%" align="center" class="td_listing1b"><?=number_format( $TOTALTVA_CL, 2 , ",", " ").' &euro;';?></td>
	<td width="10%" align="center" class="td_listing1b"></td>
	<td width="10%" align="center" class="td_listing1b"><?=number_format( $TOTAL_CL, 2, ",", " " ).' &euro;';?></td>
</tr>
</table> 
<br/><br/>
<?php
}
$green="border:3px solid green";
?>
<br/><br/><br/><br/>
<table cellspacing="0" cellpadding="0"  border="1"  style="<?=$green;?>" align="midle" class="td_normal"><tbody>
<tr>  <td align="center" class="td_listing1b" width="30%"></td><td align="center" class="td_listing1b" width="10%">CA HT</td><td align="center" class="td_listing1b" width="10%">TVA</td><td align="center" class="td_listing1b" width="10%">Taux TVA</td><td align="center" class="td_listing1b" width="10%">CA TTC</td>  </tr>
<tr>   
    <td width="30%" align="center" class="td_listing1b">TOTAL</td>
	<td width="10%" align="center" class="td_listing1b"><h2><?=number_format( $TOTALHT, 2 , ",", " ").' &euro;';?></h2></td>
	<td width="10%" align="center" class="td_listing1b"><h2><?=number_format( $TOTALTVA, 2, ",", " ").' &euro;';?></h2></td>
	<td width="10%" align="center" class="td_listing1b"></td>
	<td width="10%" align="center" class="td_listing1b"><h2><?=number_format($TOTAL, 2, ",", " ").' &euro;';?></h2></td>
</tr>
</table> 

AnonSec - 2021