From b35f44e3cb60b11b3ab42c727fe625b7236bee84 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Thu, 19 Dec 2013 20:57:13 +0100
Subject: [PATCH] New: Add option MAIN_HIDE_INACTIVETAB_ON_PRINT to hide
 inactive tabs when you use the "print" view on screen.

---
 ChangeLog                              | 4 +++-
 htdocs/core/lib/functions.lib.php      | 9 +++++----
 htdocs/theme/amarok/style.css.php      | 9 ++++++---
 htdocs/theme/auguria/style.css.php     | 8 ++++++--
 htdocs/theme/bureau2crea/style.css.php | 8 ++++++--
 htdocs/theme/cameleo/style.css.php     | 8 ++++++--
 htdocs/theme/eldy/style.css.php        | 5 ++++-
 7 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b834ee3d08d..aed7dd1ca92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,7 +6,9 @@ English Dolibarr ChangeLog
 For users:
 - New: Add list of orders products in tab "consumption" on thirdparties.
 - New: Add graph stats for suppliers orders in tab "stats" on products.
-
+- New: Add option MAIN_HIDE_INACTIVETAB_ON_PRINT to hide inactive tabs when you
+  use the "print" view on screen.
+   
 For translators:
 - Update language files.
 
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 02934e76ed1..839c8e7a505 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -622,7 +622,9 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
 	// Show tabs
 	for ($i = 0 ; $i <= $maxkey ; $i++)
 	{
-		$out.='<div class="inline-block tabsElem">';
+		$isactive=(is_numeric($active) && $i == $active) || (! is_numeric($active) && $active == $links[$i][2]);
+
+		$out.='<div class="inline-block tabsElem'.((! $isactive && ! empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT))?' hideonprint':'').'">';
 		if (isset($links[$i][2]) && $links[$i][2] == 'image')
 		{
 			if (!empty($links[$i][0]))
@@ -637,10 +639,9 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
 		else if (! empty($links[$i][1]))
 		{
 			//print "x $i $active ".$links[$i][2]." z";
-			if ((is_numeric($active) && $i == $active)
-			|| (! is_numeric($active) && $active == $links[$i][2]))
+			if ($isactive)
 			{
-				$out.='<a data-role="button" id="active" class="tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
+				$out.='<a data-role="button"'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabactive tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
 			}
 			else
 			{
diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php
index a7011f06a68..ad4a2f04c7c 100644
--- a/htdocs/theme/amarok/style.css.php
+++ b/htdocs/theme/amarok/style.css.php
@@ -363,6 +363,9 @@ center .error { padding:8px !important; padding-left:26px !important; padding-ri
 .maxwidthonsmartphone { max-width: 100px; }
 <?php } ?>
 .linkobject { cursor:pointer; }
+<?php if (GETPOST("optioncss") == 'print') { ?>
+.hideonprint { display: none !important; }
+<?php } ?>
 
 
 /* ============================================================================== */
@@ -988,11 +991,11 @@ a.tab {
 	-webkit-border-top-right-radius:6px;
 }
 
-a.tab#active {
+.tabactive {
 	color:#232323;
 	font-weight:bold;
-	background-color:#ffffff;
-	<?php echo $dol_use_jmobile?'':'border-bottom:solid 1px #ffffff;'; ?>
+	background-color:#ffffff !important;
+	<?php echo $dol_use_jmobile?'':'border-bottom:solid 1px #ffffff !important;'; ?>
 }
 
 a.tab:hover {color:#333333;}
diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php
index 7942eb87bb9..9f862fbca07 100644
--- a/htdocs/theme/auguria/style.css.php
+++ b/htdocs/theme/auguria/style.css.php
@@ -246,6 +246,10 @@ div.inline-block
 .maxwidthonsmartphone { max-width: 100px; }
 <?php } ?>
 .linkobject { cursor: pointer; }
+<?php if (GETPOST("optioncss") == 'print') { ?>
+.hideonprint { display: none !important; }
+<?php } ?>
+
 
 /* ============================================================================== */
 /* Styles for dragging lines                                                      */
@@ -1082,8 +1086,8 @@ a.tab:visited {
     border-<?php print $left; ?>: 1px solid #D8D8D8;
     border-top: 1px solid #D8D8D8;
 }
-a.tab#active {
-    background: white;
+div.tabs a.tab:active, .tabactive {
+    background: white !important;
     border-bottom: #dee7ec 1px solid;
 	font-family: <?php print $fontlist ?>;
     color: #436976;
diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php
index 672403fdb1f..608dbc3dae3 100644
--- a/htdocs/theme/bureau2crea/style.css.php
+++ b/htdocs/theme/bureau2crea/style.css.php
@@ -270,6 +270,10 @@ div.inline-block
 .maxwidthonsmartphone { max-width: 100px; }
 <?php } ?>
 .linkobject { cursor: pointer; }
+<?php if (GETPOST("optioncss") == 'print') { ?>
+.hideonprint { display: none !important; }
+<?php } ?>
+
 
 /* ============================================================================== */
 /* Styles for dragging lines                                                      */
@@ -1127,8 +1131,8 @@ div.tabs a.tab {
     padding: 0px 10px 0px 10px;
 }
 
-div.tabs a.tab#active {
-    background-color: #FFF;
+div.tabs a.tab:active, .tabactive {
+    background-color: #888 !important;
     color: #D45416;
     border-bottom: 0px;
     background-image: none;
diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php
index ef10a847d9a..51bb93c0207 100644
--- a/htdocs/theme/cameleo/style.css.php
+++ b/htdocs/theme/cameleo/style.css.php
@@ -245,6 +245,10 @@ div.inline-block
 .maxwidthonsmartphone { max-width: 100px; }
 <?php } ?>
 .linkobject { cursor: pointer; }
+<?php if (GETPOST("optioncss") == 'print') { ?>
+.hideonprint { display: none !important; }
+<?php } ?>
+
 
 /* ============================================================================== */
 /* Styles for dragging lines                                                      */
@@ -1225,8 +1229,8 @@ background: linear-gradient(top, #fceabb 0%,#fccd4d 50%,#FFA820 87%,#fbdf93 100%
 }
 
 
-div.tabs a.tab#active {
-    color: #FFF;
+div.tabs a.tab:active, .tabactive {
+    color: #FFF !important;
     padding: 0px 6px 0px 6px;
     -moz-border-radius-topleft:8px;
     -moz-border-radius-topright:8px;
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 04aa243db61..e1c13988d6e 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -412,6 +412,9 @@ th .button {
 .maxwidthonsmartphone { max-width: 100px; }
 <?php } ?>
 .linkobject { cursor: pointer; }
+<?php if (GETPOST("optioncss") == 'print') { ?>
+.hideonprint { display: none; }
+<?php } ?>
 
 
 /* ============================================================================== */
@@ -1443,7 +1446,7 @@ a.tab:link, a.tab:visited, a.tab:hover, a.tab#active {
 	background-image: none !important;
 }
 
-a.tab#active {
+.tabactive {
 <?php if ($usecss3) { ?>
 /*    border-bottom: 1px solid rgb(<?php echo $colorbacktabactive; ?>) !important; */
 	background: rgba(<?php echo $colorbacktabcard2; ?>, 0.5)  url(<?php echo dol_buildpath($path.'/theme/'.$theme.'/img/nav-overlay3.png',1); ?>) 50% 0 repeat-x;
-- 
GitLab