mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-23 09:51:33 +01:00
NEW The margin section can now be shown/hidden
This commit is contained in:
@@ -211,7 +211,7 @@ class FormMargin
|
|||||||
*/
|
*/
|
||||||
public function displayMarginInfos($object, $force_price = false)
|
public function displayMarginInfos($object, $force_price = false)
|
||||||
{
|
{
|
||||||
global $langs, $conf, $user, $hookmanager;
|
global $langs, $user, $hookmanager;
|
||||||
global $action;
|
global $action;
|
||||||
|
|
||||||
if (!empty($user->socid)) {
|
if (!empty($user->socid)) {
|
||||||
@@ -224,50 +224,53 @@ class FormMargin
|
|||||||
|
|
||||||
$marginInfo = $this->getMarginInfosArray($object, $force_price);
|
$marginInfo = $this->getMarginInfosArray($object, $force_price);
|
||||||
|
|
||||||
|
print '<!-- displayMarginInfos() - Show margin table -->' . "\n";
|
||||||
|
|
||||||
$parameters = array('marginInfo' => &$marginInfo);
|
$parameters = array('marginInfo' => &$marginInfo);
|
||||||
$reshook = $hookmanager->executeHooks('displayMarginInfos', $parameters, $object, $action);
|
$reshook = $hookmanager->executeHooks('displayMarginInfos', $parameters, $object, $action);
|
||||||
if ($reshook < 0) {
|
if ($reshook < 0) {
|
||||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
} elseif (empty($reshook)) {
|
} elseif (empty($reshook)) {
|
||||||
if (getDolGlobalString('MARGIN_ADD_SHOWHIDE_BUTTON')) {
|
$hidemargininfos = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ?? ''; // Clean cookie
|
||||||
print $langs->trans('ShowMarginInfos') . ' ';
|
|
||||||
$hidemargininfos = preg_replace('/[^a-zA-Z0-9_\-]/', '', $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ?? ''; // Clean cookie
|
|
||||||
print '<span id="showMarginInfos" class="linkobject valignmiddle ' . (!empty($hidemargininfos) ? '' : 'hideobject') . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</span>';
|
|
||||||
print '<span id="hideMarginInfos" class="linkobject valignmiddle ' . (!empty($hidemargininfos) ? 'hideobject' : '') . '">' . img_picto($langs->trans("Enabled"), 'switch_on') . '</span>';
|
|
||||||
|
|
||||||
print '<script nonce="'.getNonce().'">$(document).ready(function() {';
|
$buttonToShowHideMargin = '<span id="showMarginInfos" class="linkobject valignmiddle ' . (!empty($hidemargininfos) ? '' : 'hideobject') . '">';
|
||||||
print '$("span#showMarginInfos").click(function() { console.log("click on showMargininfos"); date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "DOLUSER_MARGININFO_HIDE_SHOW=0; expires=" + date.toGMTString() + "; path=/ "; $(".margintable").show(); $("span#showMarginInfos").addClass("hideobject"); $("span#hideMarginInfos").removeClass("hideobject"); });';
|
$buttonToShowHideMargin .= img_picto($langs->trans("ShowMarginInfos"), 'switch_off', '', 0, 0, 0, '', 'size15x');
|
||||||
print '$("span#hideMarginInfos").click(function() { console.log("click on hideMarginInfos"); date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "DOLUSER_MARGININFO_HIDE_SHOW=1; expires=" + date.toGMTString() + "; path=/ "; $(".margintable").hide(); $("span#hideMarginInfos").addClass("hideobject"); $("span#showMarginInfos").removeClass("hideobject"); });';
|
$buttonToShowHideMargin .= '</span>';
|
||||||
if (!empty($hidemargininfos)) {
|
$buttonToShowHideMargin .= '<span id="hideMarginInfos" class="linkobject valignmiddle ' . (!empty($hidemargininfos) ? 'hideobject' : '') . '">';
|
||||||
print 'console.log("hide the margin info"); $("#margintable").hide();';
|
$buttonToShowHideMargin .= img_picto($langs->trans("Hide"), 'switch_on_grey', '', 0, 0, 0, '', 'size15x opacitymedium');
|
||||||
}
|
$buttonToShowHideMargin .= '</span>';
|
||||||
print '});</script>';
|
|
||||||
|
$buttonToShowHideMargin .= '<script nonce="'.getNonce().'">$(document).ready(function() {';
|
||||||
|
$buttonToShowHideMargin .= '$("span#showMarginInfos").click(function() { console.log("click on showMargininfos"); date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "DOLUSER_MARGININFO_HIDE_SHOW=0; expires=" + date.toGMTString() + "; path=/ "; $(".margininfo").show(); $("span#showMarginInfos").addClass("hideobject"); $("span#hideMarginInfos").removeClass("hideobject"); });';
|
||||||
|
$buttonToShowHideMargin .= '$("span#hideMarginInfos").click(function() { console.log("click on hideMarginInfos"); date = new Date(); date.setTime(date.getTime()+(30*86400000)); document.cookie = "DOLUSER_MARGININFO_HIDE_SHOW=1; expires=" + date.toGMTString() + "; path=/ "; $(".margininfo").hide(); $("span#hideMarginInfos").addClass("hideobject"); $("span#showMarginInfos").removeClass("hideobject"); });';
|
||||||
|
if (!empty($hidemargininfos)) {
|
||||||
|
$buttonToShowHideMargin .= 'console.log("hide the margin info"); $(".margininfo").hide();';
|
||||||
}
|
}
|
||||||
|
$buttonToShowHideMargin .= '});</script>';
|
||||||
|
|
||||||
print '<!-- displayMarginInfos() - Show margin table -->' . "\n";
|
|
||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
|
|
||||||
print '<table class="noborder margintable centpercent" id="margintable">';
|
print '<table class="noborder margintable centpercent" id="margintable">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td class="liste_titre">' . $langs->trans('Margins') . '</td>';
|
print '<td class="liste_titre">' . $langs->trans('Margins') . ' ' . $buttonToShowHideMargin . '</td>';
|
||||||
print '<td class="liste_titre right">' . $langs->trans('SellingPrice') . '</td>';
|
print '<td class="liste_titre right margininfo'.(empty($_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ? '' : ' hideobject').'">' . $langs->trans('SellingPrice') . '</td>';
|
||||||
if (getDolGlobalString('MARGIN_TYPE') == "1") {
|
if (getDolGlobalString('MARGIN_TYPE') == "1") {
|
||||||
print '<td class="liste_titre right">' . $langs->trans('BuyingPrice') . '</td>';
|
print '<td class="liste_titre right margininfo'.(empty($_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ? '' : ' hideobject').'">' . $langs->trans('BuyingPrice') . '</td>';
|
||||||
} else {
|
} else {
|
||||||
print '<td class="liste_titre right">' . $langs->trans('CostPrice') . '</td>';
|
print '<td class="liste_titre right margininfo'.(empty($_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ? '' : ' hideobject').'">' . $langs->trans('CostPrice') . '</td>';
|
||||||
}
|
}
|
||||||
print '<td class="liste_titre right">' . $langs->trans('Margin') . '</td>';
|
print '<td class="liste_titre right margininfo'.(empty($_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ? '' : ' hideobject').'">' . $langs->trans('Margin') . '</td>';
|
||||||
if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
|
if (getDolGlobalString('DISPLAY_MARGIN_RATES')) {
|
||||||
print '<td class="liste_titre right">' . $langs->trans('MarginRate') . '</td>';
|
print '<td class="liste_titre right margininfo'.(empty($_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ? '' : ' hideobject').'">' . $langs->trans('MarginRate') . '</td>';
|
||||||
}
|
}
|
||||||
if (getDolGlobalString('DISPLAY_MARK_RATES')) {
|
if (getDolGlobalString('DISPLAY_MARK_RATES')) {
|
||||||
print '<td class="liste_titre right">' . $langs->trans('MarkRate') . '</td>';
|
print '<td class="liste_titre right margininfo'.(empty($_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ? '' : ' hideobject').'">' . $langs->trans('MarkRate') . '</td>';
|
||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
if (isModEnabled("product")) {
|
if (isModEnabled("product")) {
|
||||||
//if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) {
|
//if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) {
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven margininfo'.(empty($_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ? '' : ' hideobject').'">';
|
||||||
print '<td>' . $langs->trans('MarginOnProducts') . '</td>';
|
print '<td>' . $langs->trans('MarginOnProducts') . '</td>';
|
||||||
print '<td class="right">' . price($marginInfo['pv_products']) . '</td>';
|
print '<td class="right">' . price($marginInfo['pv_products']) . '</td>';
|
||||||
print '<td class="right">' . price($marginInfo['pa_products']) . '</td>';
|
print '<td class="right">' . price($marginInfo['pa_products']) . '</td>';
|
||||||
@@ -282,7 +285,7 @@ class FormMargin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isModEnabled("service")) {
|
if (isModEnabled("service")) {
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven margininfo'.(empty($_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ? '' : ' hideobject').'">';
|
||||||
print '<td>' . $langs->trans('MarginOnServices') . '</td>';
|
print '<td>' . $langs->trans('MarginOnServices') . '</td>';
|
||||||
print '<td class="right">' . price($marginInfo['pv_services']) . '</td>';
|
print '<td class="right">' . price($marginInfo['pv_services']) . '</td>';
|
||||||
print '<td class="right">' . price($marginInfo['pa_services']) . '</td>';
|
print '<td class="right">' . price($marginInfo['pa_services']) . '</td>';
|
||||||
@@ -297,7 +300,7 @@ class FormMargin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isModEnabled("product") && isModEnabled("service")) {
|
if (isModEnabled("product") && isModEnabled("service")) {
|
||||||
print '<tr class="liste_total">';
|
print '<tr class="liste_total margininfo'.(empty($_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']) ? '' : ' hideobject').'">';
|
||||||
print '<td>' . $langs->trans('TotalMargin') . '</td>';
|
print '<td>' . $langs->trans('TotalMargin') . '</td>';
|
||||||
print '<td class="right">' . price($marginInfo['pv_total']) . '</td>';
|
print '<td class="right">' . price($marginInfo['pv_total']) . '</td>';
|
||||||
print '<td class="right">' . price($marginInfo['pa_total']) . '</td>';
|
print '<td class="right">' . price($marginInfo['pa_total']) . '</td>';
|
||||||
@@ -310,7 +313,7 @@ class FormMargin
|
|||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
} elseif ($reshook > 0) {
|
} elseif ($reshook > 0) {
|
||||||
|
|||||||
@@ -5045,7 +5045,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco
|
|||||||
'off', 'on', 'order',
|
'off', 'on', 'order',
|
||||||
'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'proposal', 'puce',
|
'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'proposal', 'puce',
|
||||||
'stock', 'resize', 'service', 'stats',
|
'stock', 'resize', 'service', 'stats',
|
||||||
'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_warning', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench',
|
'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_grey', 'switch_on_warning', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench',
|
||||||
'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
|
'github', 'google', 'jabber', 'microsoft', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
|
||||||
'generic', 'home', 'hrm', 'members', 'products', 'invoicing',
|
'generic', 'home', 'hrm', 'members', 'products', 'invoicing',
|
||||||
'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'pictoconfirm', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region',
|
'partnership', 'payment', 'payment_vat', 'pencil-ruler', 'pictoconfirm', 'preview', 'project', 'projectpub', 'projecttask', 'question', 'refresh', 'region',
|
||||||
@@ -5094,7 +5094,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco
|
|||||||
'member' => 'user-alt', 'meeting' => 'chalkboard-teacher', 'mrp' => 'cubes', 'next' => 'arrow-alt-circle-right',
|
'member' => 'user-alt', 'meeting' => 'chalkboard-teacher', 'mrp' => 'cubes', 'next' => 'arrow-alt-circle-right',
|
||||||
'trip' => 'wallet', 'expensereport' => 'wallet', 'group' => 'users', 'movement' => 'people-carry',
|
'trip' => 'wallet', 'expensereport' => 'wallet', 'group' => 'users', 'movement' => 'people-carry',
|
||||||
'sign-out' => 'sign-out-alt',
|
'sign-out' => 'sign-out-alt',
|
||||||
'switch_off' => 'toggle-off', 'switch_on' => 'toggle-on', 'switch_on_warning' => 'toggle-on', 'switch_on_red' => 'toggle-on', 'check' => 'check', 'bookmark' => 'star',
|
'switch_off' => 'toggle-off', 'switch_on' => 'toggle-on', 'switch_on_grey' => 'toggle-on', 'switch_on_warning' => 'toggle-on', 'switch_on_red' => 'toggle-on', 'check' => 'check', 'bookmark' => 'star',
|
||||||
'bank' => 'university', 'close_title' => 'times', 'delete' => 'trash', 'filter' => 'filter',
|
'bank' => 'university', 'close_title' => 'times', 'delete' => 'trash', 'filter' => 'filter',
|
||||||
'list-alt' => 'list-alt', 'calendarlist' => 'bars', 'calendar' => 'calendar-alt', 'calendarmonth' => 'calendar-alt', 'calendarweek' => 'calendar-week', 'calendarday' => 'calendar-day', 'calendarperuser' => 'table',
|
'list-alt' => 'list-alt', 'calendarlist' => 'bars', 'calendar' => 'calendar-alt', 'calendarmonth' => 'calendar-alt', 'calendarweek' => 'calendar-week', 'calendarday' => 'calendar-day', 'calendarperuser' => 'table',
|
||||||
'intervention' => 'ambulance', 'invoice' => 'file-invoice-dollar', 'order' => 'file-invoice',
|
'intervention' => 'ambulance', 'invoice' => 'file-invoice-dollar', 'order' => 'file-invoice',
|
||||||
@@ -5165,7 +5165,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco
|
|||||||
// Define $marginleftonlyshort
|
// Define $marginleftonlyshort
|
||||||
$arrayconvpictotomarginleftonly = array(
|
$arrayconvpictotomarginleftonly = array(
|
||||||
'bank', 'check', 'delete', 'generic', 'grip', 'grip_title', 'jabber',
|
'bank', 'check', 'delete', 'generic', 'grip', 'grip_title', 'jabber',
|
||||||
'grip_title', 'grip', 'listlight', 'note', 'on', 'off', 'playdisabled', 'printer', 'resize', 'sign-out', 'stats', 'switch_on', 'switch_on_red', 'switch_off',
|
'grip_title', 'grip', 'listlight', 'note', 'on', 'off', 'playdisabled', 'printer', 'resize', 'sign-out', 'stats', 'switch_on', 'switch_on_grey', 'switch_on_red', 'switch_off',
|
||||||
'uparrow', '1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected'
|
'uparrow', '1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected'
|
||||||
);
|
);
|
||||||
if (!array_key_exists($pictowithouttext, $arrayconvpictotomarginleftonly)) {
|
if (!array_key_exists($pictowithouttext, $arrayconvpictotomarginleftonly)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user