';
- }
-
- // Form to add new line
- if ($permissiontoedit && $action != 'selectlines') {
- if ($action != 'editline') {
- // Add products/services form
-
- $parameters = array();
- $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- if (empty($reshook))
- $object->formAddObjectLine(1, $mysoc, $soc);
- }
+ print '
';
}
if (!empty($object->lines)) {
- $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
+ $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/variants/tpl', ($permissiontoedit ? 1 : 0));
}
if (!empty($object->lines) || ($permissiontoedit && $action != 'selectlines' && $action != 'editline')) {
diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php
index fc96f247e63..ae82873d8bd 100644
--- a/htdocs/variants/class/ProductAttribute.class.php
+++ b/htdocs/variants/class/ProductAttribute.class.php
@@ -1272,11 +1272,13 @@ class ProductAttribute extends CommonObject
* @param int $selected Object line selected
* @param int $dateSelector 1=Show also date range input fields
* @param string $defaulttpldir Directory where to find the template
+ * @param int $addcreateline 1=Add create line
* @return void
*/
- public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir = '/variants/tpl')
+ public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir = '/variants/tpl', $addcreateline = 0)
{
global $conf, $hookmanager, $langs, $user, $form, $object;
+ global $mysoc;
// TODO We should not use global var for this
global $disableedit, $disablemove, $disableremove;
@@ -1306,9 +1308,25 @@ class ProductAttribute extends CommonObject
}
}
+
+ if ($addcreateline) {
+ // Form to add new line
+ if ($action != 'selectlines') {
+ if ($action != 'editline') {
+ // Add products/services form
+
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ if (empty($reshook))
+ $object->formAddObjectLine(1, $mysoc, $buyer);
+ }
+ }
+ }
+
$i = 0;
- print "\n";
+ print "\n";
foreach ($this->lines as $line) {
if (is_object($hookmanager)) { // Old code is commented on preceding line.
$parameters = array('line' => $line, 'num' => $num, 'i' => $i, 'selected' => $selected, 'table_element_line' => $line->table_element);
@@ -1320,7 +1338,7 @@ class ProductAttribute extends CommonObject
$i++;
}
- print "\n";
+ print "\n";
}
/**
diff --git a/htdocs/variants/tpl/productattributevalueline_create.tpl.php b/htdocs/variants/tpl/productattributevalueline_create.tpl.php
index cc16302a68d..f23e7175f58 100644
--- a/htdocs/variants/tpl/productattributevalueline_create.tpl.php
+++ b/htdocs/variants/tpl/productattributevalueline_create.tpl.php
@@ -84,7 +84,7 @@ if ($nolinesbefore) {