2
0
forked from Wavyzz/dolibarr

Merge manually fix of #31217 + other fix for use by external modules

This commit is contained in:
Laurent Destailleur
2024-10-03 19:30:06 +02:00
parent 6f6a87cd78
commit e412dbbe05
4 changed files with 43 additions and 19 deletions

View File

@@ -1321,7 +1321,7 @@ jQuery(document).ready(function() {
jQuery(document).ready(function() {
jQuery(".butAction.dropdown-toggle").on("click", function(event) {
jQuery(document).on("click", ".butAction.dropdown-toggle", function(event) {
console.log("Click on .butAction.dropdown-toggle");
var parentholder = jQuery(".butAction.dropdown-toggle").closest(".dropdown");
var offset = parentholder.offset();

View File

@@ -1335,7 +1335,10 @@ function dol_include_once($relpath, $classname = '')
* Return path of url or filesystem. Can check into alternate dir or alternate dir + main dir depending on value of $returnemptyifnotfound.
*
* @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile
* @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file)
* @param int $type 0=Used for a Filesystem path,
* 1=Used for an URL path (output relative),
* 2=Used for an URL path (output full path using same host that current url),
* 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file)
* @param int $returnemptyifnotfound 0:If $type==0 and if file was not found into alternate dir, return default path into main dir (no test on it)
* 1:If $type==0 and if file was not found into alternate dir, return empty string
* 2:If $type==0 and if file was not found into alternate dir, test into main dir, return default path if found, empty string if not found
@@ -1404,7 +1407,7 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
//print $key.'-'.$dirroot.'/'.$path.'-'.$conf->file->dol_url_root[$type].'<br>'."\n";
//if (file_exists($dirroot.'/'.$regs[1])) {
if (@file_exists($dirroot.'/'.$regs[1])) { // avoid [php:warn]
if ($type == 1) {
if ($type == 1 || $type == 4) {
$res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
}
if ($type == 2) {
@@ -12256,13 +12259,13 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* @param string $text Optional : short label on button. Can be escaped HTML content or full simple text.
* @param string $actionType 'default', 'danger', 'email', 'clone', 'cancel', 'delete', ...
*
* @param string|array<int,array{lang:string,enabled:bool,perm:bool,label:string,url:string}> $url Url for link or array of subbutton description
* @param string|array<int,array{lang:string,enabled:bool,perm:bool,label:string,url:string,urlroot:string}> $url Url for link or array of subbutton description
*
* Example when an array is used: $arrayforbutaction = array(
* 10 => array('lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
* 20 => array('lang'=>'orders', 'enabled'=>isModEnabled("order"), 'perm'=>$user->hasRight('commande', 'creer'), 'label' => 'CreateOrder', 'url'=>'/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
* 30 => array('lang'=>'bills', 'enabled'=>isModEnabled("invoice"), 'perm'=>$user->hasRight('facture', 'creer'), 'label' => 'CreateBill', 'url'=>'/compta/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
* );
* Example when an array is used:
* $arrayforbutaction = array(
* 10 => array('attr' => array('class'=>''), 'lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
* 20 => array('attr' => array('class'=>''), 'lang'=>'mymodule', 'enabled'=>isModEnabled("mymodule"), 'perm'=>$user->hasRight('mymodule', 'write'), 'label' => 'MyModuleAction', 'urlroot'=>dol_build_patch('/mymodule/mypage.php?action=create')),
* ); );
* @param string $id Attribute id of action button. Example 'action-delete'. This can be used for full ajax confirm if this code is reused into the ->formconfirm() method.
* @param int|boolean $userRight User action right
* // phpcs:disable
@@ -12279,7 +12282,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* 'cancel-btn-label' => '', // Override label of cancel button, if empty default label use "CloseDialog" lang key
* 'content' => '', // Override text of content, if empty default content use "ConfirmBtnCommonContent" lang key
* 'modal' => true, // true|false to display dialog as a modal (with dark background)
* 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background)
* 'isDropDrown' => false, // true|false to display dialog as a dropdown list (css dropdown-item with dark background)
* ],
* ]
* // phpcs:enable
@@ -12311,9 +12314,9 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
$tmpUrl = DOL_URL_ROOT.$button['url'].(empty($params['backtopage']) ? '' : '&amp;backtopage='.urlencode($params['backtopage']));
$id = $button['id'] ?? '';
$userRight = $button['perm'] ?? 1;
$params = $button['params'] ?? [];
$button['params'] = $button['params'] ?? [];
$out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $params);
$out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $button['params']);
}
return $out;
}
@@ -12326,8 +12329,20 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
if (!empty($subbutton['lang'])) {
$langs->load($subbutton['lang']);
}
if (!empty($subbutton['urlroot'])) {
$tmpurl = $subbutton['urlroot'].(empty($params['backtopage']) ? '' : '&amp;backtopage='.urlencode($params['backtopage']));
} else {
$tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&amp;backtopage='.urlencode($params['backtopage']));
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], array('isDropDown' => true));
}
$subbuttonparam = array();
if (!empty($subbutton['attr'])) {
$subbuttonparam['attr'] = $subbutton['attr'];
}
$subbuttonparam['isDropDown'] = (empty($params['isDropDown']) ? $subbutton['isDropDown'] : $params['isDropDown']);
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, $subbutton['id'] ?? '', $subbutton['perm'], $subbuttonparam);
}
$out .= "</div>";
$out .= "</div>";
@@ -12336,8 +12351,14 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
if (!empty($subbutton['lang'])) {
$langs->load($subbutton['lang']);
}
if (!empty($subbutton['urlroot'])) {
$tmpurl = $subbutton['urlroot'].(empty($params['backtopage']) ? '' : '&amp;backtopage='.urlencode($params['backtopage']));
} else {
$tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&amp;backtopage='.urlencode($params['backtopage']));
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm']);
}
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], $params);
}
}
@@ -12346,7 +12367,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
// Here, $url is a simple link
if (!empty($params['isDropdown']) || !empty($params['isDropDown'])) {
if (!empty($params['isDropdown']) || !empty($params['isDropDown'])) { // Use the dropdown-item style (not for action button)
$class = "dropdown-item";
} else {
$class = 'butAction';

View File

@@ -1648,9 +1648,11 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) {
}
}
// Buttons Create
if (!getDolGlobalString('PROJECT_HIDE_CREATE_OBJECT_BUTTON')) {
$arrayforbutaction = array(
//1 => array('lang' => 'propal', 'enabled' => 1, 'perm' => 1, 'label' => 'XXX'),
10 => array('lang' => 'propal', 'enabled' => isModEnabled("propal"), 'perm' => $user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url' => '/comm/propal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
20 => array('lang' => 'orders', 'enabled' => isModEnabled("order"), 'perm' => $user->hasRight('commande', 'creer'), 'label' => 'CreateOrder', 'url' => '/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
30 => array('lang' => 'bills', 'enabled' => isModEnabled("invoice"), 'perm' => $user->hasRight('facture', 'creer'), 'label' => 'CreateBill', 'url' => '/compta/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid),
@@ -1664,6 +1666,7 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) {
);
$params = array('backtopage' => $_SERVER["PHP_SELF"].'?id='.$object->id);
//$params = array('backtopage' => $_SERVER["PHP_SELF"].'?id='.$object->id, 'isDropDown' => true);
print dolGetButtonAction('', $langs->trans("Create"), 'default', $arrayforbutaction, '', 1, $params);
}

View File

@@ -362,7 +362,7 @@ a.dropdown-item {
display: block !important;
box-sizing: border-box;
width: 100%;
padding: .3em 1.5em .4em 1em;
padding: .5em 1.5em .5em 1em;
clear: both;
font-weight: 400;
color: #212529 !important;