Qual: Uniformisation du code: Suppression de la fonction img_statut au profit des methodes getLibStatut plus completes

This commit is contained in:
Laurent Destailleur 2007-05-04 21:19:15 +00:00
parent 897f40d763
commit 93089e1482
10 changed files with 120 additions and 64 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net> /* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2006 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2005-2007 Destailleur Laurent <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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"); llxHeader('', $langs->trans("Proposal"), "Propal");
$html = new Form($db); $html = new Form($db);
$contactstatic=new Contact($db);
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
/* Mode vue et edition */ /* Mode vue et edition */
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ( isset($mesg)) if (isset($mesg)) print $mesg;
print $mesg;
$id = $_GET["propalid"]; $id = $_GET["propalid"];
if ($id > 0) if ($id > 0)
{ {
@ -397,12 +399,9 @@ if ($id > 0)
// Statut // Statut
print '<td align="center">'; print '<td align="center">';
// Activation desativation du contact // Activation desativation du contact
if ($propal->statut >= 0) if ($propal->statut >= 0) print '<a href="contact.php?propalid='.$propal->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
print '<a href="contact.php?propalid='.$propal->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">'; print $contactstatic->LibStatut($tab[$i]['status'],3);
print img_statut($tab[$i]['status']); if ($propal->statut >= 0) print '</a>';
if ($propal->statut >= 0)
print '</a>';
print '</td>'; print '</td>';
// Icon update et delete // Icon update et delete

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net> /* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2006 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2005-2007 Destailleur Laurent <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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"); llxHeader('', $langs->trans("Order"), "Commande");
$html = new Form($db); $html = new Form($db);
$contactstatic=new Contact($db);
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
@ -408,12 +410,9 @@ if ($id > 0)
// Statut // Statut
print '<td align="center">'; print '<td align="center">';
// Activation desativation du contact // Activation desativation du contact
if ($commande->statut >= 0) if ($commande->statut >= 0) print '<a href="contact.php?id='.$commande->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
print '<a href="contact.php?id='.$commande->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">'; print $contactstatic->LibStatut($tab[$i]['status'],3);
print img_statut($tab[$i]['status']); if ($commande->statut >= 0) print '</a>';
if ($commande->statut >= 0)
print '</a>';
print '</td>'; print '</td>';
// Icon update et delete // Icon update et delete

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net> /* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2006 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2005-2007 Destailleur Laurent <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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"); llxHeader('', $langs->trans("Bill"), "Facture");
$html = new Form($db); $html = new Form($db);
$contactstatic=new Contact($db);
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
@ -391,12 +393,9 @@ if ($id > 0)
// Statut // Statut
print '<td align="center">'; print '<td align="center">';
// Activation desativation du contact // Activation desativation du contact
if ($facture->statut >= 0) if ($facture->statut >= 0) print '<a href="contact.php?facid='.$facture->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
print '<a href="contact.php?facid='.$facture->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">'; print $contactstatic->LibStatut($tab[$i]['status'],3);
print img_statut($tab[$i]['status']); if ($facture->statut >= 0) print '</a>';
if ($facture->statut >= 0)
print '</a>';
print '</td>'; print '</td>';
// Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé) // Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé)

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
* *
@ -55,6 +55,7 @@ class Contact
var $ville; var $ville;
var $fk_pays; var $fk_pays;
var $socid; // fk_soc var $socid; // fk_soc
var $status; // 0=brouillon, 1=4=actif, 5=inactif
var $code; var $code;
var $email; var $email;
@ -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 * \brief Initialise le contact avec valeurs fictives aléatoire
*/ */

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net> /* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2006 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2005-2007 Destailleur Laurent <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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); $contrat = new Contrat($db);
if ($contrat->fetch($_GET["id"])) if ($contrat->fetch($_GET["id"]))
{ {
$db->begin();
$contact = $contrat->detail_contact($_GET["ligne"]); $contact = $contrat->detail_contact($_GET["ligne"]);
$id_type_contact = $contact->fk_c_type_contact; $id_type_contact = $contact->fk_c_type_contact;
$statut = ($contact->statut == 4) ? 5 : 4; $statut = ($contact->statut == 4) ? 5 : 4;
$result = $contrat->update_contact($_GET["ligne"], $statut, $id_type_contact); $result = $contrat->update_contact($_GET["ligne"], $statut, $id_type_contact);
if ($result >= 0) if ($result >= 0)
{ {
$db->commit(); $db->commit();
} else }
else
{ {
dolibarr_print_error($db, "result=$result"); dolibarr_print_error($db, "result=$result");
$db->rollback(); $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"); llxHeader('', $langs->trans("ContractCard"), "Contrat");
$html = new Form($db); $html = new Form($db);
$contactstatic=new Contact($db);
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
@ -429,11 +436,9 @@ if ($id > 0)
// Statut // Statut
print '<td align="center">'; print '<td align="center">';
// Activation desativation du contact // Activation desativation du contact
if ($contrat->statut >= 0) if ($contrat->statut >= 0) print '<a href="'.DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
print '<a href="'.DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">'; print $contactstatic->LibStatut($tab[$i]['status'],3);
print img_statut($tab[$i]['status']); if ($contrat->statut >= 0) print '</a>';
if ($contrat->statut >= 0)
print '</a>';
print '</td>'; print '</td>';
// Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé) // Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé)

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * 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é * \brief Renvoi le libellé d'un statut donné
* \param statut id statut * \param statut id statut
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto * \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é * \return string Libellé
*/ */
function LibStatut($statut,$mode) function LibStatut($statut,$mode)
{ {

View File

@ -304,7 +304,7 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
llxHeader('',$langs->trans("ContractCard"),"Contrat"); llxHeader('',$langs->trans("ContractCard"),"Contrat");
$html = new Form($db); $html = new Form($db);
$contratlignestatic=new ContratLigne($db);
/********************************************************************* /*********************************************************************
* *
@ -748,9 +748,10 @@ else
// Statut // Statut
print '<td align="center">'; print '<td align="center">';
// Activation desativation du contact
if ($contrat->statut > 0) print '<a href="'.DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id.'&amp;ligne='.$objp->rowid.'">';; if ($contrat->statut > 0) print '<a href="'.DOL_URL_ROOT.'/contrat/ligne.php?id='.$contrat->id.'&amp;ligne='.$objp->rowid.'">';;
print img_statut($objp->statut); print $contratlignestatic->LibStatut($objp->statut,3);
if ($contrat->statut > 0) print '</a>'; if ($contrat->statut >= 0) print '</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -255,6 +255,9 @@ if ($id > 0)
print '<td width="30" align="center">'.$langs->trans("Status").'</td>'; print '<td width="30" align="center">'.$langs->trans("Status").'</td>';
print "</tr>\n"; print "</tr>\n";
} }
$contratlignestatic = new ContratLigne($db);
$var=true; $var=true;
while ($i < $num) while ($i < $num)
{ {
@ -297,7 +300,9 @@ if ($id > 0)
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
// Statut // Statut
print '<td align="center">'.img_statut($objp->statut,$langs->trans("ServiceStatusInitial")).'</td>'; print '<td align="center">';
print $contratlignestatic->LibStatut($objp->statut,3);
print '</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -743,24 +743,6 @@ function img_action($alt = "default", $numaction)
return '<img align="absmiddle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/stcomm'.$numaction.'.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; return '<img align="absmiddle" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/stcomm'.$numaction.'.png" border="0" alt="'.$alt.'" title="'.$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 '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/statut'.$num.'.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
}
/** /**
\brief Affiche logo fichier \brief Affiche logo fichier

View File

@ -40,7 +40,7 @@ class Webcal {
var $localdb; var $localdb;
var $date; var $date;
var $duree = 0; // Secondes var $duree = 0; /* Secondes */
var $texte; var $texte;
var $desc; var $desc;