From 381b77850c00bd37f54504d87bce83e72d57bb7f Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 14 Nov 2016 01:47:34 +0100
Subject: [PATCH] Fix do not show cloning of virtual product if option is off

---
 htdocs/core/class/html.form.class.php  |  2 +-
 htdocs/langs/en_US/products.lang       |  2 +-
 htdocs/product/card.php                |  5 ++++-
 htdocs/product/class/product.class.php |  2 +-
 htdocs/theme/eldy/style.css.php        | 21 +++++----------------
 htdocs/theme/md/style.css.php          | 25 +++++--------------------
 6 files changed, 17 insertions(+), 40 deletions(-)

diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 81eaea387ff..3e704816d5c 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3342,7 +3342,7 @@ class Form
             }
 
         	// Now add questions
-            $more.='<table class="paddingrightonly" width="100%">'."\n";
+            $more.='<table class="paddingtopbottomonly" width="100%">'."\n";
             $more.='<tr><td colspan="3">'.(! empty($formquestion['text'])?$formquestion['text']:'').'</td></tr>'."\n";
             foreach ($formquestion as $key => $input)
             {
diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang
index 9bea19a30a2..89aa8ff296e 100644
--- a/htdocs/langs/en_US/products.lang
+++ b/htdocs/langs/en_US/products.lang
@@ -89,7 +89,7 @@ NoteNotVisibleOnBill=Note (not visible on invoices, proposals...)
 ServiceLimitedDuration=If product is a service with limited duration:
 MultiPricesAbility=Several segment of prices per product/service (each customer is in one segment)
 MultiPricesNumPrices=Number of prices
-AssociatedProductsAbility=Activate the package feature
+AssociatedProductsAbility=Activate the feature to manage virtual products
 AssociatedProducts=Virtual product
 AssociatedProductsNumber=Number of products composing this virtual product
 ParentProductsNumber=Number of parent packaging product
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index b4a3f8ab420..f1f226b835f 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -1748,8 +1748,11 @@ $formquestionclone=array(
     array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24),
     array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1),
     array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true),
-    array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1)
 );
+if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
+{
+    $formquestionclone[]=array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1);
+}
 
 // Confirm delete product
 if (($action == 'delete' && (empty($conf->use_javascript_ajax) || ! empty($conf->dol_use_jmobile)))	// Output when action = clone if jmobile or no js
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 34d538675b9..7cf9079fc0c 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -2856,7 +2856,7 @@ class Product extends CommonObject
 
 		$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association (fk_product_pere, fk_product_fils, qty)';
 		$sql.= " SELECT ".$toId.", fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association";
-		$sql.= " WHERE fk_product_pere = '".$fromId."'";
+		$sql.= " WHERE fk_product_pere = ".$fromId;
 
 		dol_syslog(get_class($this).'::clone_association', LOG_DEBUG);
 		if (! $this->db->query($sql))
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 12fd7d05b26..ab9c2f2b7d6 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -2406,6 +2406,7 @@ td.border, div.tagtable div div.border {
 	width:auto;
 }
 
+
 /* Main boxes */
 
 table.liste, table.noborder, table.formdoc, div.noborder {
@@ -2418,27 +2419,15 @@ table.liste, table.noborder, table.formdoc, div.noborder {
 	border-top-color: rgb(<?php echo $colortopbordertitle1 ?>);
 	border-top-style: solid;
 
-/*	border-right-width: 1px;
-	border-right-color: #BBB;
-	border-right-style: solid;
-
-	border-left-width: 1px;
-	border-left-color: #BBB;
-	border-left-style: solid;
-*/
 	border-bottom-width: 1px;
 	border-bottom-color: #BBB;
 	border-bottom-style: solid;
 
 	margin: 0px 0px 5px 0px;
-
-/*	-moz-box-shadow: 2px 2px 4px #CCC;
-	-webkit-box-shadow: 2px 2px 4px #CCC;
-	box-shadow: 2px 2px 4px #CCC;
-
-	-moz-border-radius: 0.2em;
-	-webkit-border-radius: 0.2em;
-	border-radius: 0.2em;*/
+}
+table.paddingtopbottomonly tr td {
+	padding-top: 1px;
+	padding-bottom: 2px;
 }
 .liste_titre_add td, .liste_titre_add th, .liste_titre_add .tagtd
 {
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 43bd1844947..6d8bc972ceb 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -2301,6 +2301,7 @@ td.border, div.tagtable div div.border {
 	width:auto;
 }
 
+
 /* Main boxes */
 
 table.liste, table.noborder, table.formdoc, div.noborder {
@@ -2313,36 +2314,16 @@ table.liste, table.noborder, table.formdoc, div.noborder {
 	border-top-color: rgb(<?php echo $colortopbordertitle1 ?>);
 	border-top-style: solid;
 
-/*	border-right-width: 1px;
-	border-right-color: #BBB;
-	border-right-style: solid;
-
-	border-left-width: 1px;
-	border-left-color: #BBB;
-	border-left-style: solid;
-*/
 	border-bottom-width: 1px;
 	border-bottom-color: #BBB;
 	border-bottom-style: solid;
 	
 	margin: 0px 0px 8px 0px;
-    /*
-	-moz-box-shadow: 2px 2px 4px #CCC;
-	-webkit-box-shadow: 2px 2px 4px #CCC;
-	box-shadow: 2px 2px 4px #CCC;
-    */
-	/* box-shadow: 0 0 3px rgba(0,0,0,0.16); */
 	
 	-moz-border-radius: 0.1em;
 	-webkit-border-radius: 0.1em;
 	border-radius: 0.1em;
 }
-/*
-#tablelines tr.liste_titre:first-child td, form.formnoborder, tr.liste_titre.trnoborder td {
-    border-top-width: 1px;
-    border-top-color: rgb(<?php echo $colortopbordertitle1 ?>);
-    border-top-style: solid;
-}*/
 table.noborder tr, div.noborder form {
 	border-top-color: #FEFEFE;
 
@@ -2355,6 +2336,10 @@ table.noborder tr, div.noborder form {
 	border-left-style: solid;
 	min-height: 26px;
 }
+table.paddingtopbottomonly tr td {
+	padding-top: 1px;
+	padding-bottom: 2px;
+}
 
 .liste_titre_add td, .liste_titre_add th, .liste_titre_add .tagtd
 {
-- 
GitLab