From 6961a82dbff22f974807d276ee35f5185f193bdb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 15 Jan 2011 14:01:59 +0000 Subject: [PATCH] Fix: We try to create bank link record twice Fix: Bad url --- .../compta/paiement/class/paiement.class.php | 22 +++++++++---------- htdocs/compta/paiement/fiche.php | 14 ++++++++---- .../fourn/class/fournisseur.facture.class.php | 16 +++----------- htdocs/fourn/facture/document.php | 4 ++-- htdocs/fourn/facture/note.php | 4 ++-- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 57229ba81ee..9d82834baeb 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -376,32 +376,32 @@ class Paiement if (! $error) { $linkaddedforthirdparty=array(); - foreach ($this->amounts as $key => $value) + foreach ($this->amounts as $key => $value) // We should have always same third party but we loop in case of. { if ($mode == 'payment') { $fac = new Facture($this->db); $fac->fetch($key); - $fac->fetch_thirdparty(); // This should be always same third party but we loop in case of. - if (! in_array($fac->client->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty + $fac->fetch_thirdparty(); + if (! in_array($fac->thirdparty->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty { - $result=$acc->add_url_line($bank_line_id, $fac->client->id, - DOL_URL_ROOT.'/compta/fiche.php?socid=', $fac->client->nom, 'company'); + $result=$acc->add_url_line($bank_line_id, $fac->thirdparty->id, + DOL_URL_ROOT.'/compta/fiche.php?socid=', $fac->thirdparty->nom, 'company'); if ($result <= 0) dol_print_error($this->db); - $linkaddedforthirdparty[$fac->client->id]=$fac->client->id; // Mark as done for this thirdparty + $linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty } } if ($mode == 'payment_supplier') { $fac = new FactureFournisseur($this->db); $fac->fetch($key); - $fac->fetch_fournisseur(); // This should be always same third party but we loop in case of. - if (! in_array($fac->client->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty + $fac->fetch_thirdparty(); + if (! in_array($fac->thirdparty->id,$linkaddedforthirdparty)) // Not yet done for this thirdparty { - $result=$acc->add_url_line($bank_line_id, $fac->fournisseur->id, - DOL_URL_ROOT.'/fourn/fiche.php?socid=', $fac->fournisseur->nom, 'company'); + $result=$acc->add_url_line($bank_line_id, $fac->thirdparty->id, + DOL_URL_ROOT.'/fourn/fiche.php?socid=', $fac->thirdparty->nom, 'company'); if ($result <= 0) dol_print_error($this->db); - $linkaddedforthirdparty[$fac->fournisseur->id]=$fac->fournisseur->id; // Mark as done for this thirdparty + $linkaddedforthirdparty[$fac->thirdparty->id]=$fac->thirdparty->id; // Mark as done for this thirdparty } } } diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index d9e63c3c450..03d266e6d29 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2009 Regis Houssin * @@ -22,8 +22,8 @@ /** * \file htdocs/compta/paiement/fiche.php * \ingroup facture - * \brief Onglet paiement d'un paiement client - * \remarks Fichier presque identique a fournisseur/paiement/fiche.php + * \brief Page of a customer payment + * \remarks Nearly same file than fournisseur/paiement/fiche.php * \version $Id$ */ @@ -114,6 +114,8 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && llxHeader(); +$thirdpartystatic=new Societe($db); + $paiement = new Paiement($db); $result=$paiement->fetch($_GET['id']); if ($result <= 0) @@ -254,7 +256,11 @@ if ($resql) print "\n"; // Third party - print ''.img_object($langs->trans('ShowCompany'),'company').' '.$objp->nom.''; + print ''; + $thirdpartystatic->id=$objp->socid; + $thirdpartystatic->nom=$objp->nom; + print $thirdpartystatic->getNomUrl(1); + print ''; // Expected to pay print ''.price($objp->total_ttc).''; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d07f4dacd99..21559fccba9 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -381,19 +381,9 @@ class FactureFournisseur extends Facture /** - * \brief Load supplier - */ - function fetch_fournisseur() - { - $fournisseur = new Fournisseur($this->db); - $fournisseur->fetch($this->socid); - $this->fournisseur = $fournisseur; - } - - /** - * \brief Delete invoice in database - * \param rowid Id of invoice to delete - * \return int <0 if KO, >0 if OK + * Delete invoice from database + * @param rowid Id of invoice to delete + * @return int <0 if KO, >0 if OK */ function delete($rowid) { diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 593ee479db1..4e7c0a86161 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -128,7 +128,7 @@ if ($facid > 0) $facture = new FactureFournisseur($db); if ($facture->fetch($facid)) { - $facture->fetch_fournisseur(); + $facture->fetch_thirdparty(); $upload_dir = $conf->fournisseur->dir_output.'/facture/'.get_exdir($facture->id,2).$facture->id; @@ -158,7 +158,7 @@ if ($facid > 0) print "\n"; // Societe - print ''.$langs->trans('Supplier').''.$facture->fournisseur->getNomUrl(1).''; + print ''.$langs->trans('Supplier').''.$facture->thirdparty->getNomUrl(1).''; print ''.$langs->trans('NbOfAttachedFiles').''.sizeof($filearray).''; diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index 00e9e9d18b5..172a6ebf01b 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -92,7 +92,7 @@ llxHeader(); if ($_GET["facid"]) { - $fac->fetch_fournisseur(); + $fac->fetch_thirdparty(); $head = facturefourn_prepare_head($fac); $titre=$langs->trans('SupplierInvoice'); @@ -112,7 +112,7 @@ if ($_GET["facid"]) print "\n"; // Company - print ''.$langs->trans('Supplier').''.$fac->fournisseur->getNomUrl(1).''; + print ''.$langs->trans('Supplier').''.$fac->thirdparty->getNomUrl(1).''; // Note publique print ''.$langs->trans("NotePublic").' :';