From 6c814b32bdfdf093b9d2bb4543fa2b3959785455 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Sep 2018 15:58:33 +0200 Subject: [PATCH] Standardize cod --- htdocs/comm/mailing/class/mailing.class.php | 75 +++++++++++++++++++++ htdocs/comm/mailing/list.php | 16 ++++- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 7a0d758ae17..bb6ac93d1c2 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -530,6 +530,81 @@ class Mailing extends CommonObject } + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $db, $conf, $langs, $hookmanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("ShowEmailing") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowEmailing"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + + /* + $hookmanager->initHooks(array('myobjectdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action; + $hookmanager->initHooks(array('emailingdao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; + + return $result; + } + /** * Return label of status of emailing (draft, validated, ...) * diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 5087698b9ab..489ddc8f95d 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -169,16 +169,22 @@ if ($result) { $obj = $db->fetch_object($result); - + $email->id = $obj->rowid; + $email->ref = $obj->rowid; print ""; - print ''; - print img_object($langs->trans("ShowEMail"),"email").' '.stripslashes($obj->rowid).''; + + print ''; + print $email->getNomUrl(1); + print ''; + print ''.$obj->titre.''; // Date creation + print ''; print dol_print_date($db->jdate($obj->datec),'day'); print ''; + // Nb of email if (! $filteremail) { @@ -196,9 +202,11 @@ if ($result) print $nbemail; print ''; } + // Last send print ''.dol_print_date($db->jdate($obj->date_envoi),'day').''; print ''; + // Status print ''; if ($filteremail) @@ -210,7 +218,9 @@ if ($result) print $email->LibStatut($obj->statut,5); } print ''; + print ''; + print "\n"; $i++; }