diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index d2f1d64eafb..d279f92150a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1744,6 +1744,21 @@ else $facreplaced->fetch($fac->fk_facture_source); print ' ('.$langs->transnoentities("CorrectInvoice",$facreplaced->getNomUrl(1)).')'; } + $facidavoir=$fac->getIdAvoirInvoice(); + if (sizeof($facidavoir) > 0) + { + print ' ('.$langs->transnoentities("InvoiceHasAvoir"); + $i=0; + foreach($facidavoir as $id) + { + if ($i==0) print ' '; + else print ','; + $facavoir=new Facture($db); + $facavoir->fetch($id); + print $facavoir->getNomUrl(1); + } + print ')'; + } $facidnext=$fac->getIdReplacingInvoice(); if ($facidnext > 0) { diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index cc73168308f..7a1a768a197 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -87,6 +87,8 @@ if (isset($_GET["action"]) && $_GET["action"] == 'del_bookmark') * */ +$facturestatic=new Facture($db); + llxHeader("",$langs->trans("AccountancyTreasuryArea")); print_fiche_titre($langs->trans("AccountancyTreasuryArea")); @@ -147,7 +149,11 @@ if ($conf->facture->enabled && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); $var=!$var; - print ''.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.''; + print ''; + $facturestatic->ref=$obj->facnumber; + $facturestatic->id=$obj->idp; + print $facturestatic->getNomUrl(1,''); + print ''; print ''.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,16).''; print ''.price($obj->total_ttc).''; print ''; @@ -391,7 +397,10 @@ if ($conf->facture->enabled && $user->rights->facture->lire) { $var=!$var; print ''; - print ''.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.''; + print ''; + $facturestatic->ref=$obj->facnumber; + $facturestatic->id=$obj->rowid; + print $facturestatic->getNomUrl(1,''); if ($obj->datelimite < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late")); print ''; print ''.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,44).''; @@ -465,7 +474,11 @@ if ($conf->facture->enabled && $user->rights->facture->lire) { $obj = $db->fetch_object($resql); $var = !$var; - print ''.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.''; + print ''; + $facstatic->ref=$obj->facnumber; + $facstatic->id=$obj->rowid; + print $facstatic->getNomUrl(1,''); + print ''; print ''.img_object($langs->trans("ShowSupplier"),"company").' '.dolibarr_trunc($obj->nom,44).''; if ($conf->global->MAIN_SHOW_HT_ON_SUMMARY) print ''.price($obj->total_ht).''; print ''.price($obj->total_ttc).''; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 88fd3d1ea69..29e37fa3fdc 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1752,6 +1752,35 @@ class Facture extends CommonObject } } + /** + * \brief Renvoie tableau des ids de facture avoir issus de la facture + * \return array Tableau d'id de factures avoirs + */ + function getIdAvoirInvoice() + { + $idarray=array(); + + $sql = 'SELECT rowid'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'facture'; + $sql.= ' WHERE fk_facture_source = '.$this->id; + $sql.= ' AND type = 2'; + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($obj) + { + // Si il y en a + $idarray[]=$obj->rowid; + } + } + else + { + dolibarr_print_error($this->db); + } + return $idarray; + } + /** * \brief Renvoie l'id de la facture qui la remplace * \return int <0 si ko, 0 si aucune facture ne remplace, id facture sinon @@ -1761,7 +1790,7 @@ class Facture extends CommonObject $sql = 'SELECT rowid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture'; $sql.= ' WHERE fk_facture_source = '.$this->id; - $sql.= ' AND fk_statut > 0'; + $sql.= ' AND type < 2'; $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php index 8054cb475f6..94ceaaa74c0 100644 --- a/htdocs/fourn/fournisseur.facture.class.php +++ b/htdocs/fourn/fournisseur.facture.class.php @@ -569,5 +569,26 @@ class FactureFournisseur extends Facture } } + + /** + * \brief Renvoie nom clicable (avec eventuellement le picto) + * \param withpicto Inclut le picto dans le lien + * \param option Sur quoi pointe le lien + * \return string Chaine avec URL + */ + function getNomUrl($withpicto=0,$option='') + { + global $langs; + + $result=''; + + $lien = ''; + $lienfin=''; + + if ($withpicto) $result.=($lien.img_object($langs->trans("ShowInvoice"),'bill').$lienfin.' '); + $result.=$lien.$this->ref.$lienfin; + return $result; + } + } ?> diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 1f199df3143..022821bd295 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -22,6 +22,7 @@ ReplacedByInvoice=Replaced by invoice %s CorrectInvoice=Correct invoice %s NoReplacableInvoice=No replacable invoices NoInvoiceToCorrect=No invoice to correct +InvoiceHasAvoir=Corrected by one or several invoices CardBill=Invoice card Invoice=Invoice Invoices=Invoices diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 4275687d77a..c15630c822c 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -22,6 +22,7 @@ ReplacedByInvoice=Remplac CorrectInvoice=Corrige facture %s NoReplacableInvoice=Pas de factures remplacables NoInvoiceToCorrect=Pas de factures à corriger +InvoiceHasAvoir=Corrigée par un ou plusieurs avoirs CardBill=Fiche facture Invoice=Facture Invoices=Factures