From 3fd4403bc7e9e9f4162354e354af5c40b958f154 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 8 Nov 2022 22:28:59 +0100 Subject: [PATCH] Can show some tab entries as disabled (greyed link) --- htdocs/core/lib/functions.lib.php | 6 +++--- htdocs/core/lib/product.lib.php | 24 +++++++++++++++++++----- htdocs/langs/en_US/admin.lang | 2 +- htdocs/product/list.php | 5 ++--- htdocs/theme/eldy/global.inc.php | 6 ++++++ htdocs/theme/md/style.css.php | 6 ++++++ 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b5ec311b0c5..af4228c9777 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1810,7 +1810,7 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di /** * Show tab header of a card * - * @param array $links Array of tabs. Currently initialized by calling a function xxx_admin_prepare_head + * @param array $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. * @param string $active Active tab name (document', 'info', 'ldap', ....) * @param string $title Title * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after) @@ -1831,7 +1831,7 @@ function dol_fiche_head($links = array(), $active = '0', $title = '', $notab = 0 /** * Show tabs of a record * - * @param array $links Array of tabs. Note that label into $links[$i][1] must be already HTML escaped. + * @param array $links Array of tabs (0=>url, 1=>label, 2=>code, 3=>not used, 4=>text after link, 5=>morecssonlink). Currently initialized by calling a function xxx_admin_prepare_head. Note that label into $links[$i][1] must be already HTML escaped. * @param string $active Active tab name * @param string $title Title * @param int $notab -1 or 0=Add tab header, 1=no tab header (if you set this to 1, using print dol_get_fiche_end() to close tab is not required), -2=Add tab header with no seaparation under tab (to start a tab just after), -3=-2+'noborderbottom' @@ -1934,7 +1934,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab $out .= '
'; if (!empty($links[$i][0])) { $titletoshow = preg_replace('/<.*$/', '', $links[$i][1]); - $out .= ''; + $out .= ''; } $out .= $links[$i][1]; if (!empty($links[$i][0])) { diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 7795f927c19..79d8ac57834 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -53,11 +53,19 @@ function product_prepare_head($object) $head[$h][2] = 'card'; $h++; - if (!empty($object->status) && $usercancreadprice) { - $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; - $head[$h][1] = $langs->trans("SellingPrices"); - $head[$h][2] = 'price'; - $h++; + if (!empty($object->status)) { + if ($usercancreadprice) { + $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id; + $head[$h][1] = $langs->trans("SellingPrices"); + $head[$h][2] = 'price'; + $h++; + } else { + $head[$h][0] = '#'; + $head[$h][1] = $langs->trans("SellingPrices"); + $head[$h][2] = 'price'; + $head[$h][5] = 'disabled'; + $h++; + } } if (!empty($object->status_buy) || (isModEnabled('margin') && !empty($object->status))) { // If margin is on and product on sell, we may need the cost price even if product os not on purchase @@ -69,6 +77,12 @@ function product_prepare_head($object) $head[$h][1] = $langs->trans("BuyingPrices"); $head[$h][2] = 'suppliers'; $h++; + } else { + $head[$h][0] = '#'; + $head[$h][1] = $langs->trans("BuyingPrices"); + $head[$h][2] = 'suppliers'; + $head[$h][5] = 'disabled'; + $h++; } } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index dae72d3d703..eb03e174525 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2316,7 +2316,7 @@ UsePassword=Use a password UseOauth=Use a OAUTH token Images=Images MaxNumberOfImagesInGetPost=Max number of images allowed in a HTML field submitted in a form -MaxNumberOfPostOnPublicPagesByIP=Max number of posts on public pages with an IP Address +MaxNumberOfPostOnPublicPagesByIP=Max number of posts on public pages with the same IP address CIDLookupURL=The module brings an URL that can be used by an external tool to get the name of a thirdparty or contact from its phone number. URL to use is: ScriptIsEmpty=The script is empty ShowHideTheNRequests=Show/hide the %s SQL request(s) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 47110ac873f..e637e478df4 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -422,7 +422,7 @@ $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_u if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' p.fk_unit, cu.label as cu_label,'; } -$sql .= ' MIN(pfp.unitprice) as minsellprice'; +$sql .= ' MIN(pfp.unitprice) as bestpurchaseprice'; if (isModEnabled('variants') && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) { $sql .= ', pac.rowid as prod_comb_id'; } @@ -1727,8 +1727,7 @@ while ($i < min($num, $limit)) { // Better buy price if (!empty($arrayfields['p.minbuyprice']['checked'])) { print ''; - if ($obj->tobuy && $obj->minsellprice != '' && $usercancreadprice) { - //print price($obj->minsellprice).' '.$langs->trans("HT"); + if ($obj->tobuy && $obj->bestpurchaseprice != '' && $usercancreadprice) { if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) { if ($product_fourn->product_fourn_price_id > 0) { if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_order") && !empty($user->rights->supplier_order->lire)) || (isModEnabled("supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 01f8b6329cc..86df18dfb37 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2536,6 +2536,12 @@ span.mainmenuaspan.tmenudisabled { cursor: not-allowed; } +a.disabled { + color: #aaa; + text-decoration: none !important; + cursor: default; +} + a.tmenu:link, a.tmenu:visited, a.tmenu:hover, a.tmenu:active { padding: 0px 2px 0px 2px; margin: 0px 0px 0px 0px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 6a21b5a6812..3abb4e8773e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2586,6 +2586,12 @@ span.mainmenuaspan.tmenudisabled { cursor: not-allowed; } +a.disabled { + color: #aaa; + text-decoration: none !important; + cursor: default; +} + a.tmenu:link, a.tmenu:visited, a.tmenu:hover, a.tmenu:active { font-weight: normal; padding: 0px 5px 0px 5px;