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/www/wp-content/../../../MC/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/logmcpe/www/TEST/www/wp-content/../../../MC/tableeeeEcartAA.php
<?php
include_once 'code/init.php';
// exit() ; 

/////////////////////////////////////////////////
///////////////////////////  Crea d'attestations
// echo"eeeee" ; 
// global $agence ;
 // echo "<pre>" ; 
  // print_r($_POST) ; 
  // echo "</pre>" ;
  
  $du = "20150101" ; 
  $au ="20151231" ; 
  ?>
        <table border="1px" width="400">
            <tr>
              <td width="150">client</td>
              <td> somme paiements </td>
			  <td> totale reglement</td>
			  <td> ecart</td>
            </tr>
  	  <?
	    function get_clients_drop_down_attestation($name = '', $param = '', $value ='', $choose = 'auto', $clients_seulement = false, $clients_facture = false)
     {
	global $agence ;
	  $du = "20150101" ; 
	  $au ="20151231" ; 
	
	
	if(!is_array($value))
		$value = array($value) ;
	$ret = "<select name=\"$name\" $param>".((in_array('', $value) || in_array('0', $value)) && count($value) == 1 && $choose == 'auto' || $choose === true ? '<option value="" selected>-- Choisir un client --</option>' : '') ;
	//  afficher les cli actif ou tous
	$q = dbi_query("SELECT client_id id, client_nom,client_pnom , client_prospect, IF(client_genre='SERENA',1,0) as serena, IF(client_genre='FORMATION',1,0) as formation FROM ".TABLE_CLIENT." where agence_id=$agence ".( $_SESSION['client_actif']=='off' ? "" : "AND client_actif='0'")." ".( $clients_seulement ? " AND client_genre != 'FORMATION' AND client_prospect != '1'" : "")." order by ".($clients_facture?' client_fmail,':'')." formation, client_prospect, serena, client_nom, client_pnom") ;
	//echo "SELECT client_id id, concat(client_nom, ' ', client_pnom) civ FROM ".TABLE_CLIENT." where agence_id=$agence ".( $_SESSION['client_actif']=='off' ? "" : "AND client_actif='0'")." order by client_nom, client_pnom";
	while($res = dbi_fetch_row($q)) {
		$cId = $res['id'] ; 
		
			  list($reglement) = dbi_fetch_row(dbi_query("SELECT SUM(p.montant) FROM ".TABLE_PAIEMENT." p INNER JOIN ".TABLE_FACT." f ON f.fact_id = p.fact_id WHERE p.client_id='$cId' AND p.agence_id=$agence and p.date >= '$du' and p.date <= '$au'")) ;
	
	$reglement=round($reglement, 2);	
	 
	 list($summ) = dbi_fetch_row(dbi_query("SELECT sum(totale) FROM fiscal_valide WHERE client_id = $cId and agence_id= $agence")) ;
	  $summ=round($summ, 2);
	  
	  // echo "---hhh $summ -----jjj $reglement" ; 
	  
	    // echo "---hhh $summ -----jjj $reglement------$difff  <br/>" ; 
      
	  $difff=$summ - $reglement ;
	  

		     // echo "$cId--- $summ ----- $reglement------$difff  <br/>" ;
		   
		    // if($summ != $reglement)
	  // {
		  
		   if(($difff > '1') or ($difff < '-1') )
	  {
		  	  ?>
	        
            <tr>
			 <td><?= $res['client_nom']?></td>
			 <td><?= $summ ?></td>
              <td><?= $reglement ?></td>
              <td><?=$difff ?></td>
            </tr>
	<tr>
	 <?
		// echo "kk $summ  <br/>" ; 
	  
	  // echo " ss $reglement <br/> " ; 
	  // $difff = $difff + 10 ; 
	  
	    // echo "$cId--- $summ ----- $reglement------$difff  <br/>" ;
		$prospect=$res['client_prospect'];
		$serena=$res['serena'];
		$formation=$res['formation'];
		// if (($prospect)&&!($prospectp)) $ret .= '<option value="" disabled style="font-weight:bold">Prospects</option>';
		// if (($serena)&&!($serenap)) $ret .= '<option value="" disabled style="font-weight:bold">Serena</option>';
		// if (($formation)&&!($formationp)) $ret .= '<option value="" disabled style="font-weight:bold">Formation</option>';
		// $ret .= sprintf('<option value="%s"%s>%s</option>', $res['id'], in_array($res['id'], $value) ? ' selected' : '', $res['civ'] ) ;
		// $prospectp=$res['client_prospect'];
		// $serenap=$res['serena'];
		// $formationp=$res['formation'];
		//echo $ret;
		}
	}
	
   }
 
  
  if (isset($_POST['duyear'], $_POST['client_id'], $_POST['type'])&&($_POST['type']=='attestation'))
{
	
	$reglement = 0;
	$avoir = 0;
	$attestation = 0;
	$cpt = 0;

	if (isset($_POST['duyear']))
	{
		$client_id = $_POST['client_id'] ;
		$annee = $_POST['duyear'];

		$du = sprintf("%04d%02d%02d", $_POST['duyear'], $_POST['dumonth'], $_POST['duday']) ;
		$au = sprintf("%04d%02d%02d", $_POST['auyear'], $_POST['aumonth'], $_POST['auday']) ;
	}
	else
		$annee = date("Y") ;

	$fromyear = $_POST['fromyear'] ;
	$emission = $_POST['emission'] ;

	$factures = array() ;
	include 'includes/nvattestation3.php' ;

		  
	foreach($_POST['client_id'] as $client_id)
	{
		 list($tst) = dbi_fetch_row(dbi_query("SELECT validite FROM `fiscal_valide` WHERE client_id=$client_id limit 1")) ;
	
		 // if($tst!=0)
		 // {
	if (!is_dir("attestations"))
		{
			mkdir("attestations", 0755) ;
			chmod("attestations", 0755) ;
		}
		if (!is_dir("attestations/$client_id"))
		{
			mkdir("attestations/$client_id", 0755) ;
			chmod("attestations/$client_id", 0755) ;
		}
		if(($fact_id = creerAttestation($client_id, $du, $au, $f, $fromyear, $emission)) && ($fact_id!='')) {
			$f->Output("attestations/$client_id/$annee-$fact_id.pdf", 'F') ;
			$factures[] = "attestations/$client_id/$annee-$fact_id.pdf" ;
			$cpt++;
		} else {
			//echo "<!--Erreur facture fact=$fact_id-->" ;
		}
		
	// }
	}
	$fichier_pdf = "attestations/$agence-".date('d-m-Y-H:i').".pdf";
	pdf_concatene($factures, $fichier_pdf) ;

print_header ();
	$i = 0 ;
	if ($cpt) {
	?>

<fieldset>
<legend>Attestations fiscales cr&eacute;&eacute;s</legend>
<table class="td_normal">
  <?
		foreach($factures as $f)
			printf('<tr><td class="td_listing%2$d"><a href="%1$s" target="_blank">%1$s</a></td></tr>', $f, $i++%2) ;
		printf('<tr><td class="td_listing%2$d"><a href="%1$s" target="_blank">%3$s</a></td></tr>', $fichier_pdf, $i++%2, 'Toutes les attestations g&eacute;n&eacute;r&eacute;es') ;
		echo '</table></fieldset>';
	} else echo '<h3 style="color:red">Aucune attestation générée</h3>';
}
/////////////////////////////////////////////////
/////////////////////////// Crea de facturations

elseif (isset($_POST['fduyear']))
{
	$fdu = sprintf("%04d%02d%02d", $_POST['fduyear'], $_POST['fdumonth'], $_POST['fduday']) ;
	$fau = sprintf("%04d%02d%02d", $_POST['fauyear'], $_POST['faumonth'], $_POST['fauday']) ;

	include 'includes/facturation.php' ;

	if (!is_dir("facturations"))
	{
		mkdir("facturations", 0755) ;
		chmod("facturations", 0755) ;
	}
	creerFacturation( $fdu, $fau, $f);

	$f->Output("facturations/du-$fdu-au-$fau.pdf", 'F') ;

	?>
  <a href="facturations/du-<?=$fdu?>-au-<?=$fau?>.pdf" target="_blank">/du-
  <?=$fdu?>
  -au-
  <?=$fau?>
  .pdf</a>
  <?
}

if (isset($_POST['client_id'])&&isset($_POST['type'])&&($_POST['type']=='entete'))
{
	$reglement = 0;
	$avoir = 0;
	$attestation = 0;
	$cpt = 0;

	$client_id = $_POST['client_id'] ;

	$factures = array() ;
	include 'includes/entete.php' ;

	foreach($_POST['client_id'] as $client_id)
	{
	if (!is_dir("templates/entete"))
		{
			mkdir("templates/entete", 0755) ;
			chmod("templates/entete", 0755) ;
		}
		if(($fact_id = creerEntete($client_id, $du, $au, $f)) && ($fact_id!='')) {
			$f->Output("templates/entete/$client_id.pdf", 'F') ;
			$factures[] = "templates/entete/$client_id.pdf" ;
			$cpt++;
		} else {
			echo "<!--Erreur facture fact=$fact_id-->" ;
		}
	}
	$fichier_pdf = "templates/entete/$agence-".date('d-m-Y-H:i').".pdf";
	pdf_concatene($factures, $fichier_pdf) ;

	$i = 0 ;
	if ($cpt) {
	?>
  <fieldset>

  <legend>Entetes de courrier g&eacute;n&eacute;r&eacute;s</legend>
  <table class="td_normal">
    <?
		foreach($factures as $f)
			printf('<tr><td class="td_listing%2$d"><a href="%1$s" target="_blank">%1$s</a></td></tr>', $f, $i++%2) ;
		printf('<tr><td class="td_listing%2$d"><a href="%1$s" target="_blank">%3$s</a></td></tr>', $fichier_pdf, $i++%2, 'Tous les entetes de courrier g&eacute;n&eacute;r&eacute;s') ;
		echo '</table></fieldset>';
	} else echo '<h3 style="color:red">Aucun entete de courrier généré</h3>';
}

  
  
  
  // echo "$agence <br/>" ; 
  
   $cline= dbi_query("SELECT  client_id  FROM  client  WHERE  agence_id = $agence AND  client_actif = '0'")  ; 
   
   while($c= dbi_fetch_row($cline))
   {
	  $tb_clin[] = $c['client_id'] ; 
   }
   
   
    // echo "<pre>" ; 
  // print_r($tb_clin) ; 
  // echo "</pre>" ;
   

  if(isset($_POST['client_id']) or isset($_POST['mod']))
  {
	  
	  	if (isset($_POST['duyear']))
	{
		$client_id = $_POST['client_id'] ;
		$annee = $_POST['duyear'];

		$du = sprintf("%04d%02d%02d", $_POST['duyear'], $_POST['dumonth'], $_POST['duday']) ;
		$au = sprintf("%04d%02d%02d", $_POST['auyear'], $_POST['aumonth'], $_POST['auday']) ;
	}
	  
	  // echo "$au" ; 
	  
  foreach($tb_clin as $cId)
	{

			                  // list($conteur)= dbi_fetch_row(dbi_query("select count(*) from fiscal_valide where agence_id = $agence and client_id= $cId ")) ; 
							     
								 			  if($agence==9)
				  {
					  // dbi_query("INSERT INTO fiscal_valide_neuf VALUES ('','$client_id', '$inter_id','$mois','$annee','$nbh_mois','$taux','$totale','$validite','$agence')"); 
				 list($conteur)= dbi_fetch_row(dbi_query("select count(*) from fiscal_valide_neuf where agence_id = $agence and client_id= $cId ")) ;
				  }
				  else
				  {
					   list($conteur)= dbi_fetch_row(dbi_query("select count(*) from fiscal_valide where agence_id = $agence and client_id= $cId ")) ;
				  }
								 
								  $conteur = 10 ;
							  // echo "------ $conteur" ; 
              if($conteur <1)
			  {
				    	$rr = dbi_query("SELECT * ,COUNT( p.fact_id ) AS kk FROM ".TABLE_PAIEMENT." p , ".TABLE_FACT." f   WHERE f.fact_id = p.fact_id and p.client_id='$cId' AND p.agence_id=$agence AND p.date >= '$du' AND p.date <= '$au' GROUP BY p.fact_id HAVING COUNT( p.fact_id ) =1") ;
    $rro = dbi_query("SELECT * ,COUNT( p.fact_id ) AS kk FROM ".TABLE_PAIEMENT." p , ".TABLE_FACT." f   WHERE f.fact_id = p.fact_id and p.client_id='$cId' AND p.agence_id=$agence AND p.date >= '$du' AND p.date <= '$au' GROUP BY p.fact_id HAVING COUNT( p.fact_id ) >1") ;
 
				  
				  $maxau= dbi_fetch_row(dbi_query("SELECT max(f.date_fin) FROM ".TABLE_FACT." f INNER JOIN ".TABLE_PAIEMENT." p ON f.fact_id=p.fact_id WHERE p.client_id='$cId' and p.agence_id=$agence and p.date>='$du' and p.date<='$au'"));
    $mindu=dbi_fetch_row(dbi_query("SELECT min(f.date_debut) FROM ".TABLE_FACT." f INNER JOIN ".TABLE_PAIEMENT." p ON f.fact_id=p.fact_id WHERE p.client_id='$cId' and p.agence_id=$agence and p.date>='$du' and p.date<='$au'"));

	$q = dbi_query("SELECT * FROM ".TABLE_PREST." p WHERE client_id = '$cId' AND agence_id='$agence' AND presta_id NOT In (SELECT new_presta_id FROM ".TABLE_EXCEPT." WHERE new_presta_id is not null)") ;
	$inter = array() ;
	$tmps = 0 ;
   $i = 0 ; 
 	
	while($p = dbi_fetch_row($q))
	{

        $date = get_occurence($p['presta_id'], 0, $mindu[0]);
				
		$current = 0 ;
		$offset = 0 ;

		while($date !== false && $date['date'] <= $maxau[0])
		{

		$pp[$i] = $date ; 
	     $i++ ; 
		   // echo "-date--->".$date['date']."<br/>" ;
			$inter[] = $date['inter'] ;
			$tmps += $date['duree'] ;
			 // echo "-$j->".$p['presta_Hdeb']."  ".$p['presta_Hduree']."  <br/>" ; 
			if($current == $date['date'])
				$offset ++ ;
			else
				$offset = 0 ;
			$current = $date['date'] ;
			$date = get_occurence($p['presta_id'], 1+$offset, $date['date']) ;
		}
	}

	$intervenants = array_unique($inter) ;
	$tmps = ($tmps/60);
	$attdata = array();
	

	

	$attdata_inter = array();
$a=0 ;
				  
				  	for($i=0;$i<sizeof($pp);$i++)
	{
		$inter = $pp[$i]['inter'] ; 
		$duree =  $pp[$i]['duree'] /60; 
		$taux = $pp[$i]['taux'] ; 
		$date  = int2date($pp[$i]['date'], 'm') ;
		$do  = $pp[$i]['date'] ;
		
				$aaaaaa= 100 ; 
				// echo "ddddd" ;

		dbi_query("INSERT INTO fiscal VALUES ('','$inter', '$duree','$taux','$date','$aaaaaa','$do')"); 
		
	}
			while($ppp = dbi_fetch_row($rr))
			 {
				 $k = 0 ;
				 list($dataa, $factures, $acompte, $attdataa, $option) = unserialize($ppp['data']) ;
					for($i=0 ; $i<sizeof($dataa);$i++)
					{
										// echo "<pre>" ; 
										 // print_r($dataa) ; 
										// echo "</pre>" ;
																			
						  $duree = $dataa[$i]['nbH'];						   
						   $taux = $dataa[$i]['taux']; 
						 
	                       $date  = int2date($dataa[$i]['date'], 'm') ;
						 $aaaaaa = $taux* $duree ;
						   $do = $dataa[$i]['date']; 
						   
						   $doo =$dataa[$i]['date']; 
						   // echo"--ffff-->".$dataa['montantHT']."<br/>" ; 
						     							$doo = int2date($doo ) ;
							$date_explosee = explode("/", $doo);
                              
							  
							
							  
					      $annee = $date_explosee[2];  
						  if(empty($dataa['montantHT']))
						  {
						   list($intrr)=dbi_fetch_row(dbi_query(" select inter from fiscal where dateprest= $do "));
						dbi_query("INSERT INTO fiscalll VALUES ('','$intrr', '$duree','$taux','$date','$aaaaaa','$annee','$cId')"); 
						  }
		
					}
					
			}
			
			unset($ppp) ;


			
							 while($ppp = dbi_fetch_row($rro))
			 {
				 $k = 0 ;
				 list($dataa, $factures, $acompte, $attdataa, $option) = unserialize($ppp['data']) ;
					for($i=0 ; $i<sizeof($dataa);$i++)
					{
						             // echo "<pre>" ; 
										 // print_r($dataa) ; 
										// echo "</pre>" ; 
					       $duree = $dataa[$i]['nbH'];						   
						   $taux = $dataa[$i]['taux']; 
						 
	                       $date  = int2date($dataa[$i]['date'], 'm') ;
						 $aaaaaa = $taux* $duree ;
						   $do = $dataa[$i]['date']; 
						   
						   
						   
						   						   $doo =$dataa[$i]['date']; 
						     							$doo = int2date($doo ) ;
							$date_explosee = explode("/", $doo);

					      $annee = $date_explosee[2];
						   
						   
						   // echo "----   <br/>" ;
						   list($intrr)=dbi_fetch_row(dbi_query(" select inter from fiscal where dateprest= $do "));
						dbi_query("INSERT INTO fiscalll VALUES ('','$intrr', '$duree','$taux','$date','$aaaaaa','$annee','$cId')"); 
		
					}
					
			}
			
	
			
			$b=dbi_query(" SELECT inter,date,taux,dateprest,sum(duree) as tt FROM fiscalll where dateee != 200 and client_id = $cId group by inter,date,taux   ORDER BY  date; ") ;
	 
	 $reg = dbi_query("SELECT total , date_fact  FROM ".TABLE_FACT."  p  WHERE p.client_id='$cId' AND p.agence_id=$agence and p.date_fact >= '$du' and p.date_fact <= '$au'") ;

 list($tot) = dbi_fetch_row(dbi_query("SELECT sum(total)   FROM ".TABLE_FACT."  p  WHERE p.client_id='$cId' AND p.agence_id=$agence and p.date_fact >= '$du' and p.date_fact <= '$au'")) ;

				while($aav=dbi_fetch_row($reg))
			{
				
				$total = $aav['total']; 
				$mois  = int2date($aav['date_fact'], 'm') ;
				dbi_query("INSERT INTO fiscall VALUES ('','$mois', '$total')"); 
			}


			$somme = 0 ;
			$sommemois= 0 ;  
			
			
					if($agence==9)
				  {
					  // dbi_query("INSERT INTO fiscal_valide_neuf VALUES ('','$client_id', '$inter_id','$mois','$annee','$nbh_mois','$taux','$totale','$validite','$agence')"); 
				list($tets)= dbi_fetch_row(dbi_query("select count(*) from fiscal_valide_neuf where client_id= $cId and agence_id=$agence")) ;
				  }
				  else
				  {
					  // dbi_query("INSERT INTO fiscal_valide VALUES ('','$client_id', '$inter_id','$mois','$annee','$nbh_mois','$taux','$totale','$validite','$agence')"); 
				list($tets)= dbi_fetch_row(dbi_query("select count(*) from fiscal_valide where client_id= $cId and agence_id=$agence")) ;
				  }
				  
            if($tets <1)
			{				
			while($aa=dbi_fetch_row($b))
			{
				
				 $client_id = $cId ; 
				 $inter_id = $aa['inter']; 
				 $mois=  $aa['date']  ; 
				 $annee=  $aa['dateprest']  ; 
				 $nbh_mois= $aa['tt'] ; 
				 $taux=  $aa['taux']  ;
				 $totale= $aa['taux']*$aa['tt'] ;
				 $validite= 1 ;
				
				// echo "-----$validite <br/>" ; 
				  // dbi_query('') ; 
				  if($agence==9)
				  {
					  dbi_query("INSERT INTO fiscal_valide_neuf VALUES ('','$client_id', '$inter_id','$mois','$annee','$nbh_mois','$taux','$totale','$validite','$agence')"); 
				
				  }
				  else
				  {
					  dbi_query("INSERT INTO fiscal_valide VALUES ('','$client_id', '$inter_id','$mois','$annee','$nbh_mois','$taux','$totale','$validite','$agence')"); 
				
				  }
				 
			}
			}

			   dbi_query("TRUNCATE TABLE fiscal ") ; 
			   dbi_query("TRUNCATE TABLE fiscall ") ; 

			
			
			
			 }
	

	
  
  
  
	}
  
  
  
 
  
  // echo "--- $idfisc <br/>" ; 
  
   $b= sizeof($_POST) ; 
       // echo "<pre>" ; 
  // print_r($_POST) ; 
  // echo "</pre>" ;
  		 if(isset($_POST['client_id'][0]))
	   {
		   
		   $ccl = $_POST['client_id'][0] ; 
	   }
	   else
	   {
		  $ccl = $_POST['client_idd'] ;  
		   
	   }
    if(isset($_POST['mod']))
	 {
		 
		 
		 
		  if($agence==9)
   {
	   $ah= "fiscal_valide_neuf" ;
	    // echo "--$ah"; 
   }
   else
   {
	   $ah = "fiscal_valide" ; 
	    // echo "--$ah"; 
   }   
   
		  list($idfisc)= dbi_fetch_row(dbi_query(" select min(id_fiscal) from ".$ah." where client_id =".$_POST['client_idd']." and agence_id = $agence")) ; 
   
   
   
   // fiscal_valide_neuf
   
   if($agence==9)
   {
	   $ah= "fiscal_valide_neuf" ;
	    // echo "--$ah"; 
   }
   else
   {
	   $ah = "fiscal_valide" ; 
	    // echo "--$ah"; 
   }
   for($i=1 ; $i<sizeof($_POST)-2 ;$i++)
   {
	   $nbmoi=$_POST[$i] ;
	   list($tx)= dbi_fetch_row(dbi_query(" select taux from ".$ah." where id_fiscal= $idfisc and agence_id = $agence")) ;
        // echo "--$nbmoi----$idfisc <br/> " ;	   
	   dbi_query( " UPDATE ".$ah." SET  nbh_mois = $nbmoi WHERE id_fiscal= $idfisc and agence_id=$agence ") ;
	   $sm = $tx * $nbmoi ; 
	  $p= dbi_query( " UPDATE ".$ah." SET  totale = $sm WHERE id_fiscal= $idfisc and agence_id=$agence ") ;
	   // echo " ---- ".$p; 
	   $idfisc ++ ; 
   }
      
   }
  if($agence==9)
   {
	   $ah= "fiscal_valide_neuf" ;
	    // echo "--$ah"; 
   }
   else
   {
	   $ah = "fiscal_valide" ; 
	    // echo "--$ah"; 
   }
   // echo "--$ah gg"; 
   $boo=dbi_query(" SELECT client_id ,inter_id ,mois,annee,nbh_mois,taux ,totale FROM ".$ah." WHERE  client_id =  $ccl and agence_id = $agence") ;
	 
	                      $ko=$_POST['client_id'][0] ; 

		
   
  				  
	 
	                  ?>
	   
            <form action="" method="post"> 
           	<input type="hidden" name="client_idd" value="<?=$ccl?>">
			 <input type="hidden" name="reg" value="<?=$_POST['reg']?>">
						<table BORDER="1px">
		
              <tr>
			  <td colspan="6" bgcolor="#A5DF00" ><?=$nomc." ".$pnomc ?> </td>
			 </tr>
			 <tr>
			 <th>id </th>
			 <th> NOM </th>
			 <th> Mois  </th>
			  <th> annee  </th>
			 <th> Nbh mois  </th>
			 <th> Taux  </th>
			 <th> Totale  </th>
			
	
			 
			 </tr> 
			 <?
			 $g =0 ; 
			while($aab=dbi_fetch_row($boo))
			{
				 
				$g++ ; 
				$aav=dbi_fetch_row($reg) ; 
				$totale= $aab['taux']*$aab['nbh_mois'] ; 
				$somme =$totale + $somme ; 
				
				$sommemois =$aa['tt'] + $sommemois ; 
	
				list($nom,$prenom)=dbi_fetch_row(dbi_query("SELECT inter_nom ,inter_pnom FROM intervenant  WHERE  `inter_id` =".$aab['inter_id'] )) ; 
				$nom= $nom."  ".$prenom ;
			?>
		     <tr>
			  <td><?=$aab['inter_id']  ?> </td>
			  <td><?= $nom  ?>  </td>
			   <td><?=$aab['mois']  ?>  </td>
			   <td><?=$aab['annee']  ?>  </td>
			  <td> <input type="text" name="<?=$g ?>" value="<?=$aab['nbh_mois'] ?>"> </td>
			  <td><?=$aab['taux']  ?>  </td>
			   <td><?=$totale ?> </td>
			  
			 </tr>

			 
<?	
			}
			   dbi_query("TRUNCATE TABLE fiscal ") ; 
			   dbi_query("TRUNCATE TABLE fiscall ") ; 
			  // dbi_query("TRUNCATE TABLE fiscalll ") ;  
			    list($reglement) = dbi_fetch_row(dbi_query("SELECT SUM(p.montant) FROM ".TABLE_PAIEMENT." p INNER JOIN ".TABLE_FACT." f ON f.fact_id = p.fact_id WHERE p.client_id='$ccl' AND p.agence_id=$agence and p.date >= '$du' and p.date <= '$au'")) ;
	             $reglement=round($reglement, 2);
				  $somme=round($somme, 2);
			 
		?>	 
			 
			 <tr bgcolor="#E13658" >
			  <td colspan="3"> SOMME </td>
			
			   <td colspan="3" > <?=$somme ?>  </td>
			  
			 </tr>
			 

			 
			 						 <tr bgcolor="#E13658" >
			  <td colspan="3"> SOMME paiment  </td>
			
			

			   <td colspan="3" > <?=$reglement ?>  </td>
			  
			 </tr>
			 <tr> 
	    <td colspan="3" ><input type="submit" name="mod"value="modifier">	</td>
	     
	
	         </tr>
		     	   </form > 
				   
   <?
  }
  
  
    if(isset($_POST['valider']))
  {
  // echo "<pre>" ; 
  // print_r($_POST) ; 
  // echo "</pre>" ;
 
  list($idfisc)= dbi_fetch_row(dbi_query(" select min(id_fiscal) from fiscal_valide where client_id =".$_POST['client_idd']." and agence_id=$agence")) ; 
  
  	   			  if($agence==9)
				  {
					  // dbi_query("INSERT INTO fiscal_valide_neuf VALUES ('','$client_id', '$inter_id','$mois','$annee','$nbh_mois','$taux','$totale','$validite','$agence')"); 
				     // dbi_query( " UPDATE fiscal_valide_neuf SET  validite = 1 WHERE id_fiscal= $idfisc and agence_id=$agence ") ;
					   list($idfisc)= dbi_fetch_row(dbi_query(" select min(id_fiscal) from fiscal_valide_neuf where client_id =".$_POST['client_idd']." and agence_id=$agence")) ; 
				  }
				  else
				  {
					    list($idfisc)= dbi_fetch_row(dbi_query(" select min(id_fiscal) from fiscal_valide where client_id =".$_POST['client_idd']." and agence_id=$agence")) ; 
					  // dbi_query("INSERT INTO fiscal_valide VALUES ('','$client_id', '$inter_id','$mois','$annee','$nbh_mois','$taux','$totale','$validite','$agence')"); 
				      // dbi_query( " UPDATE fiscal_valide SET  validite = 1 WHERE id_fiscal= $idfisc and agence_id=$agence ") ;
				  }
  
  
  // echo "--- $idfisc <br/>" ; 
  
   $b= sizeof($_POST) ; 

   for($i=1 ; $i<sizeof($_POST)-2 ;$i++)
   {
	   $nbmoi=$_POST[$i] ;
	   dbi_query( " UPDATE fiscal_valide SET  validite = 1 WHERE id_fiscal= $idfisc and agence_id=$agence ") ;
	   
	   			  if($agence==9)
				  {
					  // dbi_query("INSERT INTO fiscal_valide_neuf VALUES ('','$client_id', '$inter_id','$mois','$annee','$nbh_mois','$taux','$totale','$validite','$agence')"); 
				     dbi_query( " UPDATE fiscal_valide_neuf SET  validite = 1 WHERE id_fiscal= $idfisc and agence_id=$agence ") ;
				  }
				  else
				  {
					  // dbi_query("INSERT INTO fiscal_valide VALUES ('','$client_id', '$inter_id','$mois','$annee','$nbh_mois','$taux','$totale','$validite','$agence')"); 
				      dbi_query( " UPDATE fiscal_valide SET  validite = 1 WHERE id_fiscal= $idfisc and agence_id=$agence ") ;
				  }
				  
	   $idfisc ++ ; 
   }
   
  }
 

  




?>
       <h1>Attestations fiscales</h1>
          <form action="" method="post">
            <input type="hidden" name="type" value="attestation" />
            <table width="400">
 
     
	<tr>
	
		<td><?php
		echo "<select name=\"fromyear\" id=\"fromyear\">\n";
	for ($i = (-5) ; $i < 10 ; $i++) {
		$y = $year + $i;
		echo "<option value=\"$y\"".($y == ($year-1) ? " selected=\"selected\" style=\"font-weight:bold\"" : "").">$y</option>\n";
	}
	echo "</select>";
		?></td>
	</tr>
        
            <tr>
              <td valign="top">Clients : </td>
              <td valign="top"><?=get_clients_drop_down_attestation('client_id[]', 'multiple', @$_POST['client_id'], false)?>
              </td>
              <?php
if(!isset($_POST['client_id']))
	$_POST['client_id'] = array() ;
	?>
<?php
if ( empty ( $PHP_SELF ) && ! empty ( $_SERVER ) &&
  ! empty ( $_SERVER['PHP_SELF'] ) ) {
  $PHP_SELF = $_SERVER['PHP_SELF'];
}
if ( ! empty ( $PHP_SELF ) && preg_match ( "/\/includes\//", $PHP_SELF ) ) {
    die ( "You can't access this file directly!" );
}
?>
</body>
</html>

AnonSec - 2021