From 93089e14827ac03811c429874c371711bb8be19d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2007 21:19:15 +0000 Subject: [PATCH] Qual: Uniformisation du code: Suppression de la fonction img_statut au profit des methodes getLibStatut plus completes --- htdocs/comm/propal/contact.php | 17 ++++---- htdocs/commande/contact.php | 13 +++--- htdocs/compta/facture/contact.php | 13 +++--- htdocs/contact.class.php | 70 ++++++++++++++++++++++++++++++- htdocs/contrat/contact.php | 23 ++++++---- htdocs/contrat/contrat.class.php | 12 +++--- htdocs/contrat/fiche.php | 7 ++-- htdocs/contrat/ligne.php | 9 +++- htdocs/lib/functions.inc.php | 18 -------- htdocs/lib/webcal.class.php | 2 +- 10 files changed, 120 insertions(+), 64 deletions(-) diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 28254ea69e6..bf97bd28739 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2006 Destailleur Laurent + * Copyright (C) 2005-2007 Destailleur Laurent * * 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 @@ -205,14 +205,16 @@ if ($_GET["action"] == 'deleteline' && $user->rights->propale->creer) llxHeader('', $langs->trans("Proposal"), "Propal"); $html = new Form($db); +$contactstatic=new Contact($db); + /* *************************************************************************** */ /* */ /* Mode vue et edition */ /* */ /* *************************************************************************** */ -if ( isset($mesg)) - print $mesg; +if (isset($mesg)) print $mesg; + $id = $_GET["propalid"]; if ($id > 0) { @@ -397,12 +399,9 @@ if ($id > 0) // Statut print ''; // Activation desativation du contact - if ($propal->statut >= 0) - print ''; - print img_statut($tab[$i]['status']); - - if ($propal->statut >= 0) - print ''; + if ($propal->statut >= 0) print ''; + print $contactstatic->LibStatut($tab[$i]['status'],3); + if ($propal->statut >= 0) print ''; print ''; // Icon update et delete diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 035f353ede0..e964b5ace65 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2006 Destailleur Laurent + * Copyright (C) 2005-2007 Destailleur Laurent * * 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 @@ -205,6 +205,8 @@ if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer) llxHeader('', $langs->trans("Order"), "Commande"); $html = new Form($db); +$contactstatic=new Contact($db); + /* *************************************************************************** */ /* */ @@ -408,12 +410,9 @@ if ($id > 0) // Statut print ''; // Activation desativation du contact - if ($commande->statut >= 0) - print ''; - print img_statut($tab[$i]['status']); - - if ($commande->statut >= 0) - print ''; + if ($commande->statut >= 0) print ''; + print $contactstatic->LibStatut($tab[$i]['status'],3); + if ($commande->statut >= 0) print ''; print ''; // Icon update et delete diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index d9fc67ab01f..b954c311a36 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2006 Destailleur Laurent + * Copyright (C) 2005-2007 Destailleur Laurent * * 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 @@ -206,6 +206,8 @@ if ($_GET["action"] == 'deleteline' && $user->rights->facture->creer) llxHeader('', $langs->trans("Bill"), "Facture"); $html = new Form($db); +$contactstatic=new Contact($db); + /* *************************************************************************** */ /* */ @@ -391,12 +393,9 @@ if ($id > 0) // Statut print ''; // Activation desativation du contact - if ($facture->statut >= 0) - print ''; - print img_statut($tab[$i]['status']); - - if ($facture->statut >= 0) - print ''; + if ($facture->statut >= 0) print ''; + print $contactstatic->LibStatut($tab[$i]['status'],3); + if ($facture->statut >= 0) print ''; print ''; // Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé) diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 2a7ddc69ec8..2a769f96598 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * @@ -55,7 +55,8 @@ class Contact var $ville; var $fk_pays; var $socid; // fk_soc - + var $status; // 0=brouillon, 1=4=actif, 5=inactif + var $code; var $email; var $birthday; @@ -670,6 +671,71 @@ class Contact } + /** + * \brief Retourne le libellé du statut du contact + * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto + * \return string Libellé + */ + function getLibStatut($mode) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * \brief Renvoi le libellé d'un statut donné + * \param statut Id statut + * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto + * \return string Libellé + */ + function LibStatut($statut,$mode) + { + global $langs; + + if ($mode == 0) + { + if ($statut==0) return $langs->trans('StatusContactDraft'); + if ($statut==1) return $langs->trans('StatusContactValidated'); + if ($statut==4) return $langs->trans('StatusContactValidated'); + if ($statut==5) return $langs->trans('StatusContactValidated'); + } + if ($mode == 1) + { + if ($statut==0) return $langs->trans('StatusContactDraftShort'); + if ($statut==1) return $langs->trans('StatusContactValidatedShort'); + if ($statut==4) return $langs->trans('StatusContactValidatedShort'); + if ($statut==5) return $langs->trans('StatusContactValidatedShort'); + } + if ($mode == 2) + { + if ($statut==0) return img_picto($langs->trans('StatusContactDraftShort'),'statut0').' '.$langs->trans('StatusContactDraft'); + if ($statut==1) return img_picto($langs->trans('StatusContactValidatedShort'),'statut1').' '.$langs->trans('StatusContactValidated'); + if ($statut==4) return img_picto($langs->trans('StatusContactValidatedShort'),'statut4').' '.$langs->trans('StatusContactValidated'); + if ($statut==5) return img_picto($langs->trans('StatusContactValidatedShort'),'statut5').' '.$langs->trans('StatusContactValidated'); + } + if ($mode == 3) + { + if ($statut==0) return img_picto($langs->trans('StatusContactDraft'),'statut0'); + if ($statut==1) return img_picto($langs->trans('StatusContactValidated'),'statut1'); + if ($statut==4) return img_picto($langs->trans('StatusContactValidated'),'statut4'); + if ($statut==5) return img_picto($langs->trans('StatusContactValidated'),'statut5'); + } + if ($mode == 4) + { + if ($statut==0) return img_picto($langs->trans('StatusContactDraft'),'statut0').' '.$langs->trans('StatusContactDraft'); + if ($statut==1) return img_picto($langs->trans('StatusContactValidated'),'statut1').' '.$langs->trans('StatusContactValidated'); + if ($statut==4) return img_picto($langs->trans('StatusContactValidated'),'statut4').' '.$langs->trans('StatusContactValidated'); + if ($statut==5) return img_picto($langs->trans('StatusContactValidated'),'statut5').' '.$langs->trans('StatusContactValidated'); + } + if ($mode == 5) + { + if ($statut==0) return $langs->trans('StatusContactDraftShort').' '.img_picto($langs->trans('StatusContactDraftShort'),'statut0'); + if ($statut==1) return $langs->trans('StatusContactValidatedShort').' '.img_picto($langs->trans('StatusContactValidatedShort'),'statut1'); + if ($statut==4) return $langs->trans('StatusContactValidatedShort').' '.img_picto($langs->trans('StatusContactValidatedShort'),'statut4'); + if ($statut==5) return $langs->trans('StatusContactValidatedShort').' '.img_picto($langs->trans('StatusContactValidatedShort'),'statut5'); + } + } + + /** * \brief Initialise le contact avec valeurs fictives aléatoire */ diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index a794a2798fe..b4b679ff80e 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2006 Destailleur Laurent + * Copyright (C) 2005-2007 Destailleur Laurent * * 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 @@ -187,22 +187,27 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->contrat->creer) $contrat = new Contrat($db); if ($contrat->fetch($_GET["id"])) { + $db->begin(); + $contact = $contrat->detail_contact($_GET["ligne"]); $id_type_contact = $contact->fk_c_type_contact; + $statut = ($contact->statut == 4) ? 5 : 4; $result = $contrat->update_contact($_GET["ligne"], $statut, $id_type_contact); if ($result >= 0) { $db->commit(); - } else + } + else { dolibarr_print_error($db, "result=$result"); $db->rollback(); } - } else + } + else { - dolibarr_print_error($db); + dolibarr_print_error($db,$contrat->error); } } @@ -225,6 +230,8 @@ if ($_GET["action"] == 'deleteline' && $user->rights->contrat->creer) llxHeader('', $langs->trans("ContractCard"), "Contrat"); $html = new Form($db); +$contactstatic=new Contact($db); + /* *************************************************************************** */ /* */ @@ -429,11 +436,9 @@ if ($id > 0) // Statut print ''; // Activation desativation du contact - if ($contrat->statut >= 0) - print ''; - print img_statut($tab[$i]['status']); - if ($contrat->statut >= 0) - print ''; + if ($contrat->statut >= 0) print ''; + print $contactstatic->LibStatut($tab[$i]['status'],3); + if ($contrat->statut >= 0) print ''; print ''; // Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé) diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php index bbb7f5ee5ef..1cf691ea419 100644 --- a/htdocs/contrat/contrat.class.php +++ b/htdocs/contrat/contrat.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2004-2005 Destailleur Laurent - * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2004-2007 Destailleur Laurent + * Copyright (C) 2006 Andre Cianfarani * 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 * the Free Software Foundation; either version 2 of the License, or @@ -1200,10 +1200,10 @@ class ContratLigne } /** - * \brief Renvoi le libellé d'un statut donné - * \param statut id statut - * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto - * \return string Libellé + * \brief Renvoi le libellé d'un statut donné + * \param statut id statut + * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto + * \return string Libellé */ function LibStatut($statut,$mode) { diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index e8396c0a05e..bf8d4163e90 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -304,7 +304,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes') llxHeader('',$langs->trans("ContractCard"),"Contrat"); $html = new Form($db); - +$contratlignestatic=new ContratLigne($db); /********************************************************************* * @@ -748,9 +748,10 @@ else // Statut print ''; + // Activation desativation du contact if ($contrat->statut > 0) print '';; - print img_statut($objp->statut); - if ($contrat->statut > 0) print ''; + print $contratlignestatic->LibStatut($objp->statut,3); + if ($contrat->statut >= 0) print ''; print ''; print "\n"; diff --git a/htdocs/contrat/ligne.php b/htdocs/contrat/ligne.php index d5ff338b0ad..3e7bd96c0dd 100644 --- a/htdocs/contrat/ligne.php +++ b/htdocs/contrat/ligne.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2007 Laurent Destailleur * * 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 @@ -255,6 +255,9 @@ if ($id > 0) print ''.$langs->trans("Status").''; print "\n"; } + + $contratlignestatic = new ContratLigne($db); + $var=true; while ($i < $num) { @@ -297,7 +300,9 @@ if ($id > 0) print ' '; // Statut - print ''.img_statut($objp->statut,$langs->trans("ServiceStatusInitial")).''; + print ''; + print $contratlignestatic->LibStatut($objp->statut,3); + print ''; print "\n"; diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index a48ee14f100..0254d402297 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -743,24 +743,6 @@ function img_action($alt = "default", $numaction) return ''.$alt.''; } -/** - \brief Affiche logo statut - \param num Numéro statut - \param alt Texte a afficher sur alt - \return string Retourne tag img - \todo A virer et remplacer par entitestatic->LibStatut -*/ -function img_statut($num,$alt = "default") -{ - global $conf,$langs; - if ($alt=="default") { - if ($num == 0) $alt=$langs->trans("Draft"); - if ($num == 1) $alt=$langs->trans("Late"); - if ($num == 4) $alt=$langs->trans("Running"); - if ($num == 5) $alt=$langs->trans("Closed"); - } - return ''.$alt.''; -} /** \brief Affiche logo fichier diff --git a/htdocs/lib/webcal.class.php b/htdocs/lib/webcal.class.php index f6364c099ce..37133af51b9 100644 --- a/htdocs/lib/webcal.class.php +++ b/htdocs/lib/webcal.class.php @@ -40,7 +40,7 @@ class Webcal { var $localdb; var $date; - var $duree = 0; // Secondes + var $duree = 0; /* Secondes */ var $texte; var $desc;