Fix :external user (client for example) can see PMP and accountancy infos (#27952)

This commit is contained in:
Vincent Maury 2024-02-01 17:43:33 +01:00 committed by GitHub
parent e1a1015f60
commit 08b9cf2a40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5228,7 +5228,7 @@ class Product extends CommonObject
*/
public function getTooltipContentArray($params)
{
global $conf, $langs;
global $conf, $langs, $user;
$langs->loadLangs(array('products', 'other'));
@ -5313,29 +5313,31 @@ class Product extends CommonObject
}
$datas['duration'] .= (!empty($this->duration_unit) && isset($dur[$this->duration_unit]) ? " ".$langs->trans($dur[$this->duration_unit]) : '');
}
if (!empty($this->pmp) && $this->pmp) {
$datas['pmp'] = "<br><b>".$langs->trans("PMPValue").'</b>: '.price($this->pmp, 0, '', 1, -1, -1, $conf->currency);
}
if (isModEnabled('accounting')) {
if ($this->status && isset($this->accountancy_code_sell)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$selllabel = '<br>';
$selllabel .= '<br><b>'.$langs->trans('ProductAccountancySellCode').':</b> '.length_accountg($this->accountancy_code_sell);
$selllabel .= '<br><b>'.$langs->trans('ProductAccountancySellIntraCode').':</b> '.length_accountg($this->accountancy_code_sell_intra);
$selllabel .= '<br><b>'.$langs->trans('ProductAccountancySellExportCode').':</b> '.length_accountg($this->accountancy_code_sell_export);
$datas['accountancysell'] = $selllabel;
if (empty($user->socid)) {
if (!empty($this->pmp) && $this->pmp) {
$datas['pmp'] = "<br><b>".$langs->trans("PMPValue").'</b>: '.price($this->pmp, 0, '', 1, -1, -1, $conf->currency);
}
if ($this->status_buy && isset($this->accountancy_code_buy)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$buylabel = '';
if (empty($this->status)) {
$buylabel .= '<br>';
if (isModEnabled('accounting')) {
if ($this->status && isset($this->accountancy_code_sell)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$selllabel = '<br>';
$selllabel .= '<br><b>'.$langs->trans('ProductAccountancySellCode').':</b> '.length_accountg($this->accountancy_code_sell);
$selllabel .= '<br><b>'.$langs->trans('ProductAccountancySellIntraCode').':</b> '.length_accountg($this->accountancy_code_sell_intra);
$selllabel .= '<br><b>'.$langs->trans('ProductAccountancySellExportCode').':</b> '.length_accountg($this->accountancy_code_sell_export);
$datas['accountancysell'] = $selllabel;
}
if ($this->status_buy && isset($this->accountancy_code_buy)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$buylabel = '';
if (empty($this->status)) {
$buylabel .= '<br>';
}
$buylabel .= '<br><b>'.$langs->trans('ProductAccountancyBuyCode').':</b> '.length_accountg($this->accountancy_code_buy);
$buylabel .= '<br><b>'.$langs->trans('ProductAccountancyBuyIntraCode').':</b> '.length_accountg($this->accountancy_code_buy_intra);
$buylabel .= '<br><b>'.$langs->trans('ProductAccountancyBuyExportCode').':</b> '.length_accountg($this->accountancy_code_buy_export);
$datas['accountancybuy'] = $buylabel;
}
$buylabel .= '<br><b>'.$langs->trans('ProductAccountancyBuyCode').':</b> '.length_accountg($this->accountancy_code_buy);
$buylabel .= '<br><b>'.$langs->trans('ProductAccountancyBuyIntraCode').':</b> '.length_accountg($this->accountancy_code_buy_intra);
$buylabel .= '<br><b>'.$langs->trans('ProductAccountancyBuyExportCode').':</b> '.length_accountg($this->accountancy_code_buy_export);
$datas['accountancybuy'] = $buylabel;
}
}
// show categories for this record only in ajax to not overload lists
@ -5363,7 +5365,7 @@ class Product extends CommonObject
*/
public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss = '', $add_label = 0, $sep = ' - ')
{
global $conf, $langs, $hookmanager;
global $conf, $langs, $hookmanager, $user;
include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
$result = '';