From 8fabb7888a33006e5f7480b9c35a4293a346a5c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Fri, 23 Jun 2006 19:40:28 +0000 Subject: [PATCH] Qual: Mise en facteur des methodes fetch_client et fetch_projet --- htdocs/commande/commande.class.php | 17 +++-------- htdocs/commonobject.class.php | 21 +++++++++++++ htdocs/compta/facture/facture-rec.class.php | 22 +++++--------- htdocs/facture.class.php | 21 ++++--------- htdocs/fichinter/fiche.php | 2 +- htdocs/fichinter/fichinter.class.php | 30 ++++--------------- .../modules/facture/modules_facture.php | 1 - htdocs/project.class.php | 11 ++++--- htdocs/propal.class.php | 17 +++-------- 9 files changed, 54 insertions(+), 88 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 1084a0deb2f..1e9ca3343d1 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -44,9 +44,12 @@ class Commande extends CommonObject var $element='commande'; var $id ; + + var $socidp; // Id client + var $client; // Objet societe client (� charger par fetch_client) + var $ref; var $ref_client; - var $socidp; var $contactid; var $projet_id; var $statut; @@ -934,18 +937,6 @@ class Commande extends CommonObject * */ - function fetch_client() - { - $client = new Societe($this->db); - $client->fetch($this->socidp); - $this->client = $client; - } - - /** - * - * - */ - function fetch_adresse_livraison($id) { $idadresse = $id; diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php index 5a19181d63f..da8b5e682e4 100644 --- a/htdocs/commonobject.class.php +++ b/htdocs/commonobject.class.php @@ -333,6 +333,27 @@ class CommonObject $this->contact = $contact; } + /* + * \brief Charge l'objet client depuis la base + */ + function fetch_client() + { + $client = new Societe($this->db); + $client->fetch($this->societe_id); + $this->client = $client; + } + + /* + * \brief Charge l'objet projet depuis la base + * + */ + function fetch_projet() + { + $projet = new Project($this->db); + $projet->fetch($this->projet_id); + $this->projet = $projet; + } + } ?> diff --git a/htdocs/compta/facture/facture-rec.class.php b/htdocs/compta/facture/facture-rec.class.php index 99eef0730ab..8a55222339f 100644 --- a/htdocs/compta/facture/facture-rec.class.php +++ b/htdocs/compta/facture/facture-rec.class.php @@ -38,9 +38,14 @@ require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); */ class FactureRec extends Facture { - var $id; - var $db; - var $socidp; + var $db ; + var $element='commande'; + + var $id ; + + var $socidp; // Id client + var $client; // Objet societe client (� charger par fetch_client) + var $number; var $author; var $date; @@ -239,17 +244,6 @@ class FactureRec extends Facture } } - /** - * Recup�re l'objet client li� � la facture - */ - function fetch_client() - { - $client = new Societe($this->db); - $client->fetch($this->socidp); - $this->client = $client; - - } - /** * Valide la facture */ diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 4c6fe314962..19d2776f607 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -71,12 +71,12 @@ class Facture extends CommonObject var $mode_reglement_id; var $mode_reglement_code; - // Pour board - var $nbtodo; - var $nbtodolate; - + // Pour board + var $nbtodo; + var $nbtodolate; + var $specimen; - var $error; + var $error; /** @@ -468,17 +468,6 @@ class Facture extends CommonObject } } - /** - * \brief Recup�re l'objet client li� � la facture - * - */ - function fetch_client() - { - $client = new Client($this->db); - $client->fetch($this->socidp); - $this->client = $client; - } - /** * \brief Classe la facture dans un projet diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 60d5c684f62..0bd18c8b00f 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -330,7 +330,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit') if ($conf->projet->enabled) { $fichinter->fetch_projet(); - print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>'.$fichinter->projet.'</td></tr>'; + print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>'.$fichinter->projet->title.'</td></tr>'; } // Statut diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php index d2fe1bd9223..8fbb2e6994e 100644 --- a/htdocs/fichinter/fichinter.class.php +++ b/htdocs/fichinter/fichinter.class.php @@ -35,10 +35,14 @@ require_once(DOL_DOCUMENT_ROOT ."/notify.class.php"); */ class Fichinter extends CommonObject { - var $id; var $db; + var $element='ficheinter'; + + var $id; - var $socidp; + var $socidp; // Id client + var $client; // Objet societe client (� charger par fetch_client) + var $author; var $ref; var $date; @@ -273,28 +277,6 @@ class Fichinter extends CommonObject } - /* - * \brief Charge la liste des clients depuis la base - */ - function fetch_client() - { - $client = new Societe($this->db); - $client->fetch($this->societe_id); - $this->client = $client; - } - - /* - * \brief Charge les infos du projet depuis la base - * - */ - function fetch_projet() - { - $projet = new Project($this->db); - $projet->fetch($this->projet_id); - $this->projet = $projet->title; - } - - /** * \brief Retourne le libell� du statut de l'intervantion * \return string Libell� diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php index 0ce11cd22cb..cd431f80a06 100644 --- a/htdocs/includes/modules/facture/modules_facture.php +++ b/htdocs/includes/modules/facture/modules_facture.php @@ -269,7 +269,6 @@ function facture_delete_preview($db, $facid) $fac = new Facture($db,"",$facid); $fac->fetch($facid); - $fac->fetch_client(); if ($conf->facture->dir_output) { diff --git a/htdocs/project.class.php b/htdocs/project.class.php index 5ca9587d4c6..716ad039d47 100644 --- a/htdocs/project.class.php +++ b/htdocs/project.class.php @@ -1,6 +1,6 @@ <?php /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +18,6 @@ * * $Id$ * $Source$ - * */ /** @@ -29,11 +28,11 @@ */ /** - \class Project - \brief Classe permettant la gestion des projets + \class Project + \brief Classe permettant la gestion des projets */ - -class Project { +class Project +{ var $id; var $db; var $ref; diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php index bf943cc62e6..5a95a2951f9 100644 --- a/htdocs/propal.class.php +++ b/htdocs/propal.class.php @@ -49,7 +49,10 @@ class Propal extends CommonObject var $element='propal'; var $id; - var $socidp; + + var $socidp; // Id client + var $client; // Objet societe client (� charger par fetch_client) + var $contactid; var $projetidp; var $author; @@ -349,18 +352,6 @@ class Propal extends CommonObject } - /** - * - * - */ - function fetch_client() - { - $client = new Societe($this->db); - $client->fetch($this->socidp); - $this->client = $client; - } - - /** * * -- GitLab