New: Add label of project with ref on element pages

This commit is contained in:
eldy 2011-10-09 20:12:05 +02:00
parent e3b4e034bf
commit 02ebcdfed2
2 changed files with 14 additions and 10 deletions

View File

@ -2239,10 +2239,10 @@ class Form
/** /**
* Show a form to select a project * Show a form to select a project
* *
* @param page Page * @param int $page Page
* @param socid Id societe * @param int $socid Id third party
* @param selected Id projet pre-selectionne * @param int $selected Id pre-selected project
* @param htmlname Nom du formulaire select * @param string $htmlname Name of select field
* @return void * @return void
*/ */
function form_project($page, $socid, $selected='', $htmlname='projectid') function form_project($page, $socid, $selected='', $htmlname='projectid')
@ -2267,12 +2267,15 @@ class Form
} }
else else
{ {
if ($selected) { if ($selected)
{
$projet = new Project($this->db); $projet = new Project($this->db);
$projet->fetch($selected); $projet->fetch($selected);
//print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$selected.'">'.$projet->title.'</a>'; //print '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$selected.'">'.$projet->title.'</a>';
print $projet->getNomUrl(0); print $projet->getNomUrl(0,'',1);
} else { }
else
{
print "&nbsp;"; print "&nbsp;";
} }
} }

View File

@ -634,10 +634,11 @@ class Project extends CommonObject
* Renvoie nom clicable (avec eventuellement le picto) * Renvoie nom clicable (avec eventuellement le picto)
* *
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param string $option Variante ('', 'nolink') * @param string $option Variant ('', 'nolink')
* @param int $addlabel 0=Default, 1=Add label into string
* @return string Chaine avec URL * @return string Chaine avec URL
*/ */
function getNomUrl($withpicto=0,$option='') function getNomUrl($withpicto=0,$option='',$addlabel=0)
{ {
global $langs; global $langs;
@ -658,7 +659,7 @@ class Project extends CommonObject
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin.(($addlabel && $this->title)?' - '.$this->title:'');
return $result; return $result;
} }