From a89995b63f7598820e47c781f17541ab193a14f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Jan 2023 12:36:53 +0100 Subject: [PATCH] WIP Public virtual card --- htdocs/core/lib/functions.lib.php | 12 ++++++++---- htdocs/langs/en_US/main.lang | 3 ++- htdocs/main.inc.php | 20 ++++++++++++++------ htdocs/projet/card.php | 2 +- htdocs/public/users/view.php | 6 +++--- htdocs/user/card.php | 4 +--- htdocs/user/virtualcard.php | 1 + 7 files changed, 30 insertions(+), 18 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ac774209d30..e32cbc3ca9d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1731,11 +1731,13 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = * @param string $url Relative Url to open. For example '/project/card.php' * @param string $disabled Disabled text * @param string $morecss More CSS + * @param string $jsonopen Some JS code to execute on click/open of popup * @param string $backtopagejsfields The back to page must be managed using javascript instead of a redirect. * Value is 'keyforpopupid:Name_of_html_component_to_set_with id,Name_of_html_component_to_set_with_label' + * @param string $accesskey A key to use shortcut * @return string HTML component with button */ -function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '', $morecss = 'classlink button bordertransp', $backtopagejsfields = '') +function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '', $morecss = 'classlink button bordertransp', $jsonopen = '', $backtopagejsfields = '', $accesskey = '') { global $conf; @@ -1763,9 +1765,11 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di //print ''; $out .= ''; - $out .= 'use_javascript_ajax)) { $out .= ' href="'.DOL_URL_ROOT.$url.'" target="_blank"'; + } elseif ($jsonopen) { + $out .= ' onclick="javascript:'.$jsonopen.'"'; } $out .= '>'.$buttonstring.''; @@ -2324,7 +2328,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi // Add alias for thirdparty if (!empty($object->name_alias)) { - $morehtmlref .= '
'.$object->name_alias.'
'; + $morehtmlref .= '
'.dol_escape_htmltag($object->name_alias).'
'; } // Add label @@ -2346,7 +2350,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && ($conf->global->MAIN_SHOW_TECHNICAL_ID == '1' || preg_match('/'.preg_quote($object->element, '/').'/i', $conf->global->MAIN_SHOW_TECHNICAL_ID)) && !empty($object->id)) { $morehtmlref .= '
'; $morehtmlref .= '
'; - $morehtmlref .= $langs->trans("TechnicalID").': '.$object->id; + $morehtmlref .= $langs->trans("TechnicalID").': '.((int) $object->id); $morehtmlref .= '
'; } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index e747f004c87..daa01cfcfa4 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -226,6 +226,7 @@ NoUserGroupDefined=No user group defined Password=Password PasswordRetype=Repeat your password NoteSomeFeaturesAreDisabled=Note that a lot of features/modules are disabled in this demonstration. +YourUserFile=Your user file Name=Name NameSlashCompany=Name / Company Person=Person @@ -1213,4 +1214,4 @@ InternalUser=Internal user ExternalUser=External user NoSpecificContactAddress=No specific contact or address NoSpecificContactAddressBis=This tab is dedicated to force specific contacts or addresses for the current object. Use it only if you want to define one or several specific contacts or addresses for the object when the information on the thirdparty is not enough or not accurate. - +AddToContacts=Add address to my contacts diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 17912f81101..a21082a8bc6 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2280,12 +2280,14 @@ function top_menu_user($hideloginname = 0, $urllogout = '') if (empty($urllogout)) { $urllogout = DOL_URL_ROOT.'/user/logout.php?token='.newToken(); } - $logoutLink = ' '.$langs->trans("Logout").''; - $profilLink = ' '.$langs->trans("Card").''; + // Defined the links for bottom of card + $profilLink = ' '.$langs->trans("Card").''; + $urltovirtualcard = '/user/virtualcard.php?id='.((int) $user->id); + $virtuelcardLink = dolButtonToOpenUrlInDialogPopup('publicvirtualcardmenu', $langs->trans("PublicVirtualCardUrl"), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', ''), $urltovirtualcard, '', 'button-top-menu-dropdown marginleftonly nohover', "closeTopMenuLoginDropdown()", '', 'v'); + $logoutLink = ' '.$langs->trans("Logout").''; $profilName = $user->getFullName($langs).' ('.$user->login.')'; - if (!empty($user->admin)) { $profilName = ' '.$profilName; } @@ -2341,6 +2343,9 @@ function top_menu_user($hideloginname = 0, $urllogout = '')
'.$profilLink.'
+
+ '.$virtuelcardLink.' +
'.$logoutLink.'
@@ -2363,12 +2368,15 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $btnUser .= '