From 151a9781051153b28651c40791ad5db80eaef744 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Jan 2020 11:25:51 +0100 Subject: [PATCH] Debug loan module --- htdocs/loan/class/loan.class.php | 55 +++++++++++++++++++++++++------- htdocs/loan/list.php | 6 ++-- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 6a724db9d87..586b6b59036 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -435,6 +435,7 @@ class Loan extends CommonObject // Load translation files required by the page $langs->loadLangs(array("customers","bills")); + unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; @@ -442,7 +443,7 @@ class Loan extends CommonObject $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid'); $this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid'); if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); - $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid'); $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled'); if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); } @@ -458,23 +459,53 @@ class Loan extends CommonObject /** * Return clicable name (with eventually the picto) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen Label max length - * @return string Chaine with URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen Label max length + * @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 Chaine with URL */ - public function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $langs; + global $conf, $langs; $result = ''; - $tooltip = ''.$langs->trans("ShowLoan").''; - if (!empty($this->ref)) - $tooltip .= '
'.$langs->trans('Ref').': '.$this->ref; - if (!empty($this->label)) - $tooltip .= '
'.$langs->trans('Label').': '.$this->label; + $label = ''.$langs->trans("ShowLoan").''; + if (!empty($this->ref)) { + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + } + if (!empty($this->label)) { + $label .= '
'.$langs->trans('Label').': '.$this->label; + } - $linkstart = ''; + $url = DOL_URL_ROOT.'/loan/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("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + + $linkstart = ''; $linkend = ''; $result .= $linkstart; diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index 912b95c643a..c26c8b5706b 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -184,7 +184,6 @@ if ($resql) print ' '; print ' '; print ''; - print ''; print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -216,6 +215,7 @@ if ($resql) $loan_static->id = $obj->rowid; $loan_static->ref = $obj->rowid; $loan_static->label = $obj->label; + $loan_static->paid = $obj->paid; print ''; @@ -234,7 +234,9 @@ if ($resql) // Date end print ''.dol_print_date($db->jdate($obj->dateend), 'day').''; - print ''.$loan_static->LibStatut($obj->paid, 5, $obj->alreadypayed).''; + print ''; + print $loan_static->LibStatut($obj->paid, 5, $obj->alreadypayed); + print ''; print '';