diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index da6173e8266..69990b1aca6 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -1353,9 +1353,9 @@ else
if ($month > 0)
$sql .= " AND date_format(f.datef, '%m') = $month";
- if ($filtre)
+ if ($_GET["filtre"])
{
- $filtrearr = split(",", $filtre);
+ $filtrearr = split(",", $_GET["filtre"]);
foreach ($filtrearr as $fil)
{
$filt = split(":", $fil);
@@ -1404,7 +1404,7 @@ else
print_liste_field_titre("Montant TTC",$PHP_SELF,"f.total_ttc","","&socidp=$socidp");
print '
';
print_liste_field_titre("Reçu",$PHP_SELF,"am","","&socidp=$socidp");
- print ' | ';
+ print ' | ';
print_liste_field_titre("Statut",$PHP_SELF,"fk_statut,paye","","&socidp=$socidp");
print ' | ';
print "\n";
diff --git a/htdocs/facturefourn.class.php b/htdocs/facturefourn.class.php
index 7e847670bad..94de20e9363 100644
--- a/htdocs/facturefourn.class.php
+++ b/htdocs/facturefourn.class.php
@@ -423,6 +423,24 @@ class FactureFourn
{
}
+
+ /**
+ * Renvoi un libellé du statut
+ *
+ */
+ Function LibStatut($paye,$statut)
+ {
+ if (! $paye)
+ {
+ if ($statut == 0) return 'Brouillon (à valider)';
+ if ($statut == 3) return 'Annulée';
+ return 'Validée (à payer)';
+ }
+ else
+ {
+ return 'Payée';
+ }
+ }
}
?>
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 058d144223e..2aecfc32e77 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -420,6 +420,7 @@ else
$authorfullname=$author->fullname;
}
print "| Auteur | $authorfullname | ";
+ print "
| Statut: | ".$fac->LibStatut($fac->paye,$fac->statut)." |
";
print "".'|   | Total HT | '.price($fac->total_ht)." | ";
print 'TVA | '.price($fac->total_tva)." |
";
diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php
index 85cfd090e75..12bbb7f581e 100644
--- a/htdocs/fourn/facture/index.php
+++ b/htdocs/fourn/facture/index.php
@@ -22,6 +22,7 @@
*/
require("./pre.inc.php");
require("../../contact.class.php");
+require("../../facturefourn.class.php");
llxHeader();
@@ -34,12 +35,6 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
-if ($action == 'note')
-{
- $sql = "UPDATE societe SET note='$note' WHERE idp=$socid";
- $result = $db->query($sql);
-}
-
if ($action == 'delete')
{
$fac = new FactureFourn($db);
@@ -94,7 +89,7 @@ if ($sortfield == "")
}
-$sql = "SELECT s.idp as socid, s.nom, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, s.prefix_comm, fac.total_ht, fac.total_ttc, fac.paye, fac.libelle, ".$db->pdate("fac.datef")." as datef, fac.rowid as facid, fac.facnumber";
+$sql = "SELECT s.idp as socid, s.nom, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, s.prefix_comm, fac.total_ht, fac.total_ttc, fac.paye as paye, fac.fk_statut as fk_statut, fac.libelle, ".$db->pdate("fac.datef")." as datef, fac.rowid as facid, fac.facnumber";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as fac ";
$sql .= " WHERE fac.fk_soc = s.idp";
@@ -102,6 +97,15 @@ if ($socid)
{
$sql .= " AND s.idp = $socid";
}
+if ($_GET["filtre"])
+ {
+ $filtrearr = split(",", $_GET["filtre"]);
+ foreach ($filtrearr as $fil)
+ {
+ $filt = split(":", $fil);
+ $sql .= " AND " . $filt[0] . " = " . $filt[1];
+ }
+ }
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit+1, $offset);
@@ -116,23 +120,27 @@ if ($result)
print '';
- print '';
- print '| Numéro | ';
- print '';
+ print ' |
';
+ print '| ';
+ print_liste_field_titre("Numéro",$PHP_SELF,"facnumber");
+ print ' | ';
+ print '';
print_liste_field_titre("Date",$PHP_SELF,"fac.datef");
- print ' | ';
- print 'Libellé | ';
+ print '';
+ print 'Libellé | ';
print '';
print_liste_field_titre("Société",$PHP_SELF,"s.nom");
print ' | ';
- print '';
+ print ' | ';
print_liste_field_titre("Montant HT",$PHP_SELF,"fac.total_ht");
print ' | ';
- print '';
+ print ' | ';
print_liste_field_titre("Montant TTC",$PHP_SELF,"fac.total_ttc");
print ' | ';
- print 'Payé | ';
- print "
\n";
+ print '';
+ print_liste_field_titre("Statut",$PHP_SELF,"fk_statut,paye");
+ print ' | ';
+ print "\n";
$var=True;
while ($i < min($num,$limit))
{
@@ -145,15 +153,48 @@ if ($result)
print "".strftime("%d %b %Y",$obj->datef)." | \n";
print ''.stripslashes("$obj->libelle").' | ';
print "socid\">$obj->nom | \n";
- print ''.price($obj->total_ht).' | ';
+ print ''.price($obj->total_ht).' | ';
print ''.price($obj->total_ttc).' | ';
- print ''.($obj->paye||$obj->total_ht==0?"":"").($obj->total_ht==0?"brouillon":$yn[$obj->paye]).($obj->paye||$obj->total_ht==0?"":"").' | ';
+ // Affiche statut de la facture
+ if ($obj->paye)
+ {
+ $class = "normal";
+ }
+ else
+ {
+ if ($obj->fk_statut == 0)
+ {
+ $class = "normal";
+ }
+ else
+ {
+ $class = "impayee";
+ }
+ }
+ if (! $obj->paye)
+ {
+ if ($obj->fk_statut == 0)
+ {
+ print 'brouillon | ';
+ }
+ elseif ($obj->fk_statut == 3)
+ {
+ print 'annulée | ';
+ }
+ else
+ {
+ print ''.($obj->am?"commencé":"impayée").' | ';
+ }
+ }
+ else
+ {
+ print 'payée | ';
+ }
-
- print "\n";
+ print "\n";
$i++;
}
- print "
";
+ print "";
$db->free();
}
else