Qual: Utilisation des methodes communes plutot que code en dur

This commit is contained in:
Laurent Destailleur 2006-10-24 23:47:57 +00:00
parent 5edbacef75
commit 5ed391df02
2 changed files with 38 additions and 29 deletions

View File

@ -33,6 +33,7 @@ require_once("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
if ($conf->contrat->enabled) require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php");
@ -68,13 +69,16 @@ if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0
}
}
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="nom";
/*
* Actions
*/
if ($_GET["action"] == 'attribute_prefix' && $user->rights->societe->creer)
{
$societe = new Societe($db, $_GET["socid"]);
@ -167,14 +171,18 @@ if ($mode == 'search') {
llxHeader('',$langs->trans('CustomerCard'));
/*********************************************************************************
*
* Mode fiche
*
*********************************************************************************/
llxHeader('',$langs->trans('CustomerCard'));
$actionstatic=new ActionComm($db);
$facturestatic=new Facture($db);
$contactstatic = new Contact($db);
if ($socid > 0)
{
// On recupere les donnees societes par l'objet
@ -696,10 +704,10 @@ if ($socid > 0)
$var = !$var;
print "<tr $bc[$var]>";
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->idp.'">';
print img_object($langs->trans("Show"),"contact");
print '&nbsp;'.$obj->firstname.' '. $obj->name.'</a>&nbsp;';
$contactstatic->id=$obj->idp;
$contactstatic->name=$obj->name;
$contactstatic->firstname=$obj->firstname;
print '<td>'.$contactstatic->getNomUrl(1).'</td>';
if (trim($obj->note))
{
@ -737,8 +745,6 @@ if ($socid > 0)
print "<br>";
$actionstatic=new ActionComm($db);
/*
* Listes des actions a faire
*
@ -819,20 +825,22 @@ if ($socid > 0)
}
else
{
print '<td><a href="action/fiche.php?id='.$obj->id.'">'.img_object($langs->trans("ShowAction"),"task");
$transcode=$langs->trans("Action".$obj->acode);
$libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle);
print $libelle;
print '</a></td>';
$actionstatic->code=$obj->acode;
$actionstatic->libelle=$obj->libelle;
$actionstatic->id=$obj->id;
print '<td>'.$actionstatic->getNomUrl(1,16).'</td>';
}
print '<td colspan="2">'.$obj->label.'</td>';
// Contact pour cette action
if ($obj->fk_contact) {
if ($obj->fk_contact > 0)
{
$contact = new Contact($db);
$contact->fetch($obj->fk_contact);
print '<td><a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$contact->id.'">'.img_object($langs->trans("ShowContact"),"contact").' '.$contact->fullname.'</a></td>';
} else {
print '<td>'.$contact->getNomUrl(1).'</td>';
}
else
{
print '<td>&nbsp;</td>';
}
@ -890,7 +898,7 @@ if ($socid > 0)
$oldyear='';
$oldmonth='';
$var=true;
while ($i < $num)
{
$var = !$var;
@ -929,11 +937,10 @@ if ($socid > 0)
// Action
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$obj->id.'">'.img_object($langs->trans("ShowTask"),"task");
$transcode=$langs->trans("Action".$obj->acode);
$libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle);
print $libelle;
print '</a>';
$actionstatic->code=$obj->acode;
$actionstatic->libelle=$obj->libelle;
$actionstatic->id=$obj->id;
print $actionstatic->getNomUrl(1,16);
print '</td>';
// Objet lié
@ -946,9 +953,10 @@ if ($socid > 0)
}
if ($obj->fk_facture)
{
print '<a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->fk_facture.'">'.img_object($langs->trans("ShowBill"),"bill");
print $langs->trans("Invoice");
print '</a>';
$facturestatic->ref=$langs->trans("Invoice");
$facturestatic->id=$obj->rowid;
$facturestatic->type=$obj->type;
print $facturestatic->getNomUrl(1,'compta');
}
else print '&nbsp;';
print '</td>';
@ -957,11 +965,11 @@ if ($socid > 0)
print "<td>$obj->label</td>";
// Contact pour cette action
if ($obj->fk_contact)
if ($obj->fk_contact > 0)
{
$contact = new Contact($db);
$contact->fetch($obj->fk_contact);
print '<td><a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$contact->id.'">'.img_object($langs->trans("ShowContact"),"contact").' '.$contact->fullname.'</a></td>';
print '<td>'.$contact->getNomUrl(1).'</td>';
}
else
{

View File

@ -756,6 +756,7 @@ class Contact
* \param withpicto Inclut le picto dans le lien
* \param option Sur quoi pointe le lien
* \return string Chaine avec URL
* \remarks Utilise $this->id, $this->name et $this->firstname
*/
function getNomUrl($withpicto=0,$option='')
{