Merge pull request #21363 from Quatadah/dolicloud-qnasdami-dropdownmenu

adding dropdown menu in case of a lot of buttons in project
This commit is contained in:
Laurent Destailleur
2022-07-27 10:15:39 +02:00
committed by GitHub
2 changed files with 28 additions and 17 deletions

View File

@@ -10411,6 +10411,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key * 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key
* 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key * 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key
* 'modal' => true, // true|false to display dialog as a modal (with dark background) * '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)
* ], * ],
* ] * ]
* // phpcs:enable * // phpcs:enable
@@ -10420,12 +10421,16 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
{ {
global $hookmanager, $action, $object, $langs; global $hookmanager, $action, $object, $langs;
//var_dump($params);
if ($params['isDropdown'])
$class = "dropdown-item";
else {
$class = 'butAction'; $class = 'butAction';
if ($actionType == 'danger' || $actionType == 'delete') { if ($actionType == 'danger' || $actionType == 'delete') {
$class = 'butActionDelete'; $class = 'butActionDelete';
if (!empty($url) && strpos($url, 'token=') === false) $url .= '&token='.newToken(); if (!empty($url) && strpos($url, 'token=') === false) $url .= '&token='.newToken();
} }
}
$attr = array( $attr = array(
'class' => $class, 'class' => $class,
'href' => empty($url) ? '' : $url, 'href' => empty($url) ? '' : $url,

View File

@@ -1331,50 +1331,56 @@ if ($action == 'create' && $user->rights->projet->creer) {
} }
} }
// Add button to create objects from project
if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) { if (!empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) {
print'<div class="dropdown inline-block">';
print'<a style="margin-right: auto;"class="dropdown-toggle butAction" data-toggle="dropdown">'.$langs->trans("Create").'</a>';
print '<div class="dropdown-menu">';
print '<div class="dropdown-global-search-button-list" >';
if (!empty($conf->propal->enabled) && $user->rights->propal->creer) { if (!empty($conf->propal->enabled) && $user->rights->propal->creer) {
$langs->load("propal"); $langs->load("propal");
print dolGetButtonAction('', $langs->trans('AddProp'), 'default', DOL_URL_ROOT.'/comm/propal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('AddProp'), 'default', DOL_URL_ROOT.'/comm/propal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
if (!empty($conf->commande->enabled) && $user->rights->commande->creer) { if (!empty($conf->commande->enabled) && $user->rights->commande->creer) {
$langs->load("orders"); $langs->load("orders");
print dolGetButtonAction('', $langs->trans('CreateOrder'), 'default', DOL_URL_ROOT.'/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('CreateOrder'), 'default', DOL_URL_ROOT.'/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
if (isModEnabled('facture') && $user->rights->facture->creer) { if (isModEnabled('facture') && $user->rights->facture->creer) {
$langs->load("bills"); $langs->load("bills");
print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer) { if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer) {
$langs->load("supplier_proposal"); $langs->load("supplier_proposal");
print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('AddSupplierProposal'), 'default', DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
if (!empty($conf->supplier_order->enabled) && ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer)) { if (!empty($conf->supplier_order->enabled) && ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer)) {
$langs->load("suppliers"); $langs->load("suppliers");
print dolGetButtonAction('', $langs->trans('AddSupplierOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('AddSupplierOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
if (!empty($conf->supplier_invoice->enabled) && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) { if (!empty($conf->supplier_invoice->enabled) && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
$langs->load("suppliers"); $langs->load("suppliers");
print dolGetButtonAction('', $langs->trans('AddSupplierInvoice'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('AddSupplierInvoice'), 'default', DOL_URL_ROOT.'/fourn/facture/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) { if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer) {
$langs->load("interventions"); $langs->load("interventions");
print dolGetButtonAction('', $langs->trans('AddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('AddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
if (!empty($conf->contrat->enabled) && $user->rights->contrat->creer) { if (!empty($conf->contrat->enabled) && $user->rights->contrat->creer) {
$langs->load("contracts"); $langs->load("contracts");
print dolGetButtonAction('', $langs->trans('AddContract'), 'default', DOL_URL_ROOT.'/contrat/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('AddContract'), 'default', DOL_URL_ROOT.'/contrat/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->creer) { if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->creer) {
$langs->load("trips"); $langs->load("trips");
print dolGetButtonAction('', $langs->trans('AddTrip'), 'default', DOL_URL_ROOT.'/expensereport/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('AddTrip'), 'default', DOL_URL_ROOT.'/expensereport/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
if (!empty($conf->don->enabled) && $user->rights->don->creer) { if (!empty($conf->don->enabled) && $user->rights->don->creer) {
$langs->load("donations"); $langs->load("donations");
print dolGetButtonAction('', $langs->trans('AddDonation'), 'default', DOL_URL_ROOT.'/don/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, ''); print dolGetButtonAction('', $langs->trans('AddDonation'), 'default', DOL_URL_ROOT.'/don/card.php?action=create&amp;projectid='.$object->id.'&amp;socid='.$object->socid, '', 1, array('isDropDown' => true));
} }
print "</div>";
print "</div>";
print "</div>";
} }
// Clone // Clone
if ($user->rights->projet->creer) { if ($user->rights->projet->creer) {
if ($userWrite > 0) { if ($userWrite > 0) {