diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index d633ac15be6..4a98d1b47ae 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -372,7 +372,7 @@ if ($_GET["propalid"])
print '
| '.$langs->trans("AmountTTC").' | '.price($propal->total_ttc).' | ';
print ''.$conf->monnaie.' |
';
- print '| '.$langs->trans("Status").' | '.$propal->get_libstatut().' |
';
+ print '| '.$langs->trans("Status").' | '.$propal->getLibStatut().' |
';
print "
";
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index cdb4d5a30ac..7ddceeea1b7 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -994,7 +994,7 @@ else
print '| '.$langs->trans("AmountTTC").' | '.price($fac->total_ttc).' | ';
print ''.$conf->monnaie.' |
';
- print '| '.$langs->trans("Status").' | '.($fac->get_libstatut()).' |
';
+ print '| '.$langs->trans("Status").' | '.($fac->getLibStatut()).' |
';
if ($fac->note)
{
diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php
index 26ea81db8ba..5400f249092 100644
--- a/htdocs/contrat/contrat.class.php
+++ b/htdocs/contrat/contrat.class.php
@@ -361,7 +361,7 @@ class Contrat
* \brief Retourne le libellé du statut du contrat
* \return string Libellé
*/
- function get_libstatut()
+ function getLibStatut()
{
return $this->LibStatut($this->statut);
}
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 7d564443b85..b9f0dc389d4 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -1062,29 +1062,20 @@ class Facture
}
}
- /**
- * \todo RODO
- *
- */
- function pdf()
- {
-
- }
-
/**
* \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
* \return string Libellé
*/
- function get_libstatut()
+ function getLibStatut()
{
return $this->LibStatut($this->paye,$this->statut);
}
/**
- * \brief Renvoi le libellé d'un statut donné
+ * \brief Renvoi le libellé long d'un statut donné
* \param paye etat paye
* \param statut id statut
- * \return string Libellé
+ * \return string Libellé long du statut
*/
function LibStatut($paye,$statut)
{
@@ -1102,6 +1093,30 @@ class Facture
}
}
+ /**
+ * \brief Renvoi le libellé court d'un statut donné
+ * \param paye etat paye
+ * \param statut id statut
+ * \param amount amount already payed
+ * \return string Libellé court du statut
+ */
+ function PayedLibStatut($paye,$statut,$amount=0)
+ {
+ global $langs;
+ $langs->load("bills");
+ if (! $paye)
+ {
+ if ($statut == 0) return $langs->trans("BillShortStatusDraft");
+ if ($statut == 3) return $langs->trans("BillStatusCanceled");
+ if ($amount) return $langs->trans("BillStatusStarted");
+ return $langs->trans("BillStatusNotPayed");
+ }
+ else
+ {
+ return $langs->trans("BillStatusPayed");
+ }
+ }
+
/**
* \brief Mets à jour les commentaires
diff --git a/htdocs/facturefourn.class.php b/htdocs/facturefourn.class.php
index 3c73fa4c811..80c0baeebe0 100644
--- a/htdocs/facturefourn.class.php
+++ b/htdocs/facturefourn.class.php
@@ -22,15 +22,17 @@
*
*/
-/*! \file htdocs/facturefourn.class.php
+/**
+ \file htdocs/facturefourn.class.php
\ingroup facture
\brief Fichier de la classe des factures fournisseurs
\version $Revision$
*/
-/*! \class FactureFourn
- \brief Classe permettant la gestion des factures fournisseurs
+/**
+ \class FactureFourn
+ \brief Classe permettant la gestion des factures fournisseurs
*/
class FactureFourn
@@ -39,6 +41,8 @@ class FactureFourn
var $db;
var $socid;
var $number;
+ var $statut;
+ var $paye;
var $author;
var $libelle;
var $date;
@@ -422,19 +426,21 @@ class FactureFourn
}
}
+
/**
- * \todo RODO
- *
+ * \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
+ * \return string Libellé
*/
- function pdf()
+ function getLibStatut()
{
-
+ return $this->LibStatut($this->paye,$this->statut);
}
/**
- * \brief Renvoi un libellé du statut
- * \param paye etat paye
- * \param statut id statut
+ * \brief Renvoi le libellé long d'un statut donné
+ * \param paye etat paye
+ * \param statut id statut
+ * \return string Libellé long du statut
*/
function LibStatut($paye,$statut)
{
@@ -451,6 +457,30 @@ class FactureFourn
return $langs->trans("BillStatusPayed");
}
}
+
+ /**
+ * \brief Renvoi le libellé court d'un statut donné
+ * \param paye etat paye
+ * \param statut id statut
+ * \param amount amount already payed
+ * \return string Libellé court du statut
+ */
+ function PayedLibStatut($paye,$statut,$amount=0)
+ {
+ global $langs;
+ $langs->load("bills");
+ if (! $paye)
+ {
+ if ($statut == 0) return $langs->trans("BillShortStatusDraft");
+ if ($statut == 3) return $langs->trans("BillStatusCanceled");
+ if ($amount) return $langs->trans("BillStatusStarted");
+ return $langs->trans("BillStatusNotPayed");
+ }
+ else
+ {
+ return $langs->trans("BillStatusPayed");
+ }
+ }
}
?>
diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php
index a2d0f77a94f..dbbfd83c915 100644
--- a/htdocs/fourn/facture/index.php
+++ b/htdocs/fourn/facture/index.php
@@ -21,7 +21,8 @@
*
*/
-/** \file htdocs/fourn/facture/index.php
+/**
+ \file htdocs/fourn/facture/index.php
\ingroup fournisseur,facture
\brief Lsite des factures fournisseurs
\version $Revision$
@@ -53,14 +54,16 @@ if ($_GET["action"] == 'delete')
}
$page=$_GET["page"];
-$sortorder=$_GET["sortorder"];
-$sortfield=$_GET["sortfield"];
-
+$sortorder = $_GET["sortorder"];
+$sortfield = $_GET["sortfield"];
+
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
+if (! $sortorder) $sortorder="DESC";
+if (! $sortfield) $sortfield="fac.datef";
/*
@@ -91,20 +94,7 @@ if ($_POST["mode"] == 'search')
*
*/
-$sortorder = $_GET["sortorder"];
-$sortfield = $_GET["sortfield"];
-
-if ($sortorder == "")
-{
- $sortorder="DESC";
-}
-if ($sortfield == "")
-{
- $sortfield="fac.datef";
-}
-
-
-$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 = "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";
@@ -153,7 +143,7 @@ $result = $db->query($sql);
if ($result)
{
- $num = $db->num_rows();
+ $num = $db->num_rows($result);
$i = 0;
if ($socid) {
@@ -195,22 +185,23 @@ if ($result)
print "\n";
print '';
- $var=True;
+ $fac = new FactureFourn($db);
+
+ $var=true;
while ($i < min($num,$limit))
{
$obj = $db->fetch_object();
$var=!$var;
print "";
- print "| facid\">".img_object($langs->trans("ShowBill"),"bill")."\n";
- print " facid\">$obj->facnumber | \n";
- print "".strftime("%d %b %Y",$obj->datef)." | \n";
+ print "facid\">".img_object($langs->trans("ShowBill"),"bill")." ".$obj->facnumber." | \n";
+ print "".strftime("%d %b %Y",$obj->datef)." | \n";
print ''.stripslashes("$obj->libelle").' | ';
print '';
- print ''.img_object($langs->trans("ShowSupplier"),"company").'';
- print ' '.$obj->nom.'';
+ print ''.img_object($langs->trans("ShowSupplier"),"company").' '.$obj->nom.'';
print ' | '.price($obj->total_ht).' | ';
print ''.price($obj->total_ttc).' | ';
+
// Affiche statut de la facture
if ($obj->paye)
{
@@ -227,28 +218,33 @@ if ($result)
$class = "impayee";
}
}
- if (! $obj->paye)
+
+ print '';
+ if (! $obj->paye)
+ {
+ if ($obj->fk_statut == 0)
{
- if ($obj->fk_statut == 0)
- {
- print ' | brouillon | ';
- }
- elseif ($obj->fk_statut == 3)
- {
- print 'annulée | ';
- }
- else
- {
- print ''.($obj->am?"commencé":"impayée").' | ';
- }
+ print $fac->PayedLibStatut($obj->paye,$obj->fk_statut);
+ }
+ elseif ($obj->fk_statut == 3)
+ {
+ print $fac->PayedLibStatut($obj->paye,$obj->fk_statut);
}
else
{
- print 'payée | ';
+ // \todo le montant deja payé obj->am n'est pas définie
+ print ''.($fac->PayedLibStatut($obj->paye,$obj->fk_statut,$obj->am)).'';
}
+ }
+ else
+ {
+ print $fac->PayedLibStatut($obj->paye,$obj->fk_statut);
+ }
+ print '';
- print "
\n";
- $i++;
+ print "\n";
+ $i++;
+
}
print "";
$db->free();
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index cca7be2c41f..22d900466ad 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -845,7 +845,7 @@ class Propal
* \brief Retourne le libellé du statut d'une propale (brouillon, validée, ...)
* \return string Libellé
*/
- function get_libstatut()
+ function getLibStatut()
{
return $this->LibStatut($this->statut);
}