diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php
index cbe5d74003e..aaeb08461b6 100644
--- a/htdocs/admin/emailcollector_card.php
+++ b/htdocs/admin/emailcollector_card.php
@@ -457,9 +457,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '
';
// Operations
- print '';
+ print '';
+ if (! empty($conf->use_javascript_ajax)) {
+ include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
+ }
+
print '';
print '';
diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php
index 2dba328610e..5348f36976d 100644
--- a/htdocs/core/ajax/row.php
+++ b/htdocs/core/ajax/row.php
@@ -42,8 +42,8 @@ top_httphead();
print ''."\n";
// Registering the location of boxes
-if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST['table_element_line']) && ! empty($_POST['table_element_line']))
- && (isset($_POST['fk_element']) && ! empty($_POST['fk_element'])) && (isset($_POST['element_id']) && ! empty($_POST['element_id'])) )
+if ((! empty($_POST['roworder'])) && (! empty($_POST['table_element_line']))
+ && (! empty($_POST['fk_element'])) && (! empty($_POST['element_id'])))
{
$roworder=GETPOST('roworder','alpha',2);
$table_element_line=GETPOST('table_element_line','alpha',2);
@@ -53,6 +53,7 @@ if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST[
dol_syslog("AjaxRow roworder=".$roworder." table_element_line=".$table_element_line." fk_element=".$fk_element." element_id=".$element_id, LOG_DEBUG);
$rowordertab = explode(',',$roworder);
+ $newrowordertab = array();
foreach($rowordertab as $value)
{
if (! empty($value)) $newrowordertab[] = $value;
@@ -62,6 +63,7 @@ if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST[
$row->table_element_line = $table_element_line;
$row->fk_element = $fk_element;
$row->id = $element_id;
+
$row->line_ajaxorder($newrowordertab); // This update field rank or position in table row->table_element_line
// Reorder line to have position of children lines sharing same counter than parent lines
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 3db628a88f9..e07001fda7c 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2379,7 +2379,7 @@ abstract class CommonObject
function updateRangOfLine($rowid,$rang)
{
$fieldposition = 'rang';
- if ($this->table_element_line == 'ecm_files') $fieldposition = 'position';
+ if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang;
$sql.= ' WHERE rowid = '.$rowid;
@@ -2417,14 +2417,17 @@ abstract class CommonObject
*/
function updateLineUp($rowid,$rang)
{
- if ($rang > 1 )
+ if ($rang > 1)
{
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET rang = '.$rang ;
+ $fieldposition = 'rang';
+ if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang ;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
$sql.= ' AND rang = '.($rang - 1);
if ($this->db->query($sql) )
{
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET rang = '.($rang - 1);
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang - 1);
$sql.= ' WHERE rowid = '.$rowid;
if (! $this->db->query($sql) )
{
@@ -2450,12 +2453,15 @@ abstract class CommonObject
{
if ($rang < $max)
{
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET rang = '.$rang;
+ $fieldposition = 'rang';
+ if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang;
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
$sql.= ' AND rang = '.($rang+1);
if ($this->db->query($sql) )
{
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET rang = '.($rang+1);
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang+1);
$sql.= ' WHERE rowid = '.$rowid;
if (! $this->db->query($sql) )
{
diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php
index 0a282b13dc6..167d51ade75 100644
--- a/htdocs/core/tpl/ajaxrow.tpl.php
+++ b/htdocs/core/tpl/ajaxrow.tpl.php
@@ -16,8 +16,13 @@
* along with this program. If not, see .
*
* Javascript code to activate drag and drop on lines
- * You can use this if you want to be abale to drag and drop rows of a table.
- * You must add id="tablelines" on table level tag and have ($nboflines or count($object->lines) or count($taskarray) > 0)
+ * You can use this if you want to be able to drag and drop rows of a table.
+ * You must add id="tablelines" on table level tag
+ * and $object and $object->id is defined
+ * and $object->fk_element or $fk_element is defined
+ * and have ($nboflines or count($object->lines) or count($taskarray) > 0)
+ * and have $table_element_line = 'tablename' or $object->table_element_line with line to move
+ *
*/
// Protection to avoid direct call of template
@@ -32,7 +37,7 @@ if (empty($object) || ! is_object($object))
id;
-$fk_element=$object->fk_element;
+$fk_element=empty($object->fk_element)?$fk_element:$object->fk_element;
$table_element_line=(empty($table_element_line)?$object->table_element_line:$table_element_line);
$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):(empty($nboflines)?0:$nboflines)));
$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php
index fa5b500b40b..2332a5930ac 100644
--- a/htdocs/emailcollector/class/emailcollector.class.php
+++ b/htdocs/emailcollector/class/emailcollector.class.php
@@ -602,7 +602,10 @@ class EmailCollector extends CommonObject
{
$this->filters = array();
- $sql='SELECT rowid, type, rulevalue, status FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectorfilter WHERE fk_emailcollector = '.$this->id;
+ $sql = 'SELECT rowid, type, rulevalue, status';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectorfilter';
+ $sql.= ' WHERE fk_emailcollector = '.$this->id;
+ //$sql.= ' ORDER BY position';
$resql = $this->db->query($sql);
if ($resql)
@@ -631,7 +634,10 @@ class EmailCollector extends CommonObject
{
$this->actions = array();
- $sql='SELECT rowid, type, actionparam, status FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectoraction WHERE fk_emailcollector = '.$this->id;
+ $sql = 'SELECT rowid, type, actionparam, status';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'emailcollector_emailcollectoraction';
+ $sql.= ' WHERE fk_emailcollector = '.$this->id;
+ $sql.= ' ORDER BY position';
$resql = $this->db->query($sql);
if ($resql)
diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php
index 42eecd097bd..8764a90251d 100644
--- a/htdocs/emailcollector/class/emailcollectoraction.class.php
+++ b/htdocs/emailcollector/class/emailcollectoraction.class.php
@@ -58,6 +58,9 @@ class EmailCollectorAction extends CommonObject
public $picto = 'emailcollectoraction@emailcollector';
+ public $fk_element = 'fk_emailcollector';
+
+
/**
* 'type' if the field format.
* 'label' the translation key.
@@ -90,6 +93,7 @@ class EmailCollectorAction extends CommonObject
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,),
'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',),
'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,),
+ 'position' => array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>1, 'position'=>600, 'default'=>'0',),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled')),
);
diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql
index 123badcd901..3a25b7030e0 100644
--- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql
+++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql
@@ -180,21 +180,6 @@ ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_entit
ALTER TABLE llx_emailcollector_emailcollector ADD INDEX idx_emailcollector_status (status);
-CREATE TABLE llx_emailcollector_emailcollectoraction(
- -- BEGIN MODULEBUILDER FIELDS
- rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
- fk_emailcollector INTEGER NOT NULL,
- type varchar(128) NOT NULL,
- actionparam varchar(255) NULL,
- date_creation datetime NOT NULL,
- tms timestamp NOT NULL,
- fk_user_creat integer NOT NULL,
- fk_user_modif integer,
- import_key varchar(14),
- status integer NOT NULL
- -- END MODULEBUILDER FIELDS
-) ENGINE=innodb;
-
CREATE TABLE llx_emailcollector_emailcollectorfilter(
-- BEGIN MODULEBUILDER FIELDS
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
@@ -210,6 +195,22 @@ CREATE TABLE llx_emailcollector_emailcollectorfilter(
-- END MODULEBUILDER FIELDS
) ENGINE=innodb;
+CREATE TABLE llx_emailcollector_emailcollectoraction(
+ -- BEGIN MODULEBUILDER FIELDS
+ rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
+ fk_emailcollector INTEGER NOT NULL,
+ type varchar(128) NOT NULL,
+ actionparam varchar(255) NULL,
+ date_creation datetime NOT NULL,
+ tms timestamp NOT NULL,
+ fk_user_creat integer NOT NULL,
+ fk_user_modif integer,
+ position integer DEFAULT 0,
+ import_key varchar(14),
+ status integer NOT NULL
+ -- END MODULEBUILDER FIELDS
+) ENGINE=innodb;
+
ALTER TABLE llx_emailcollector_emailcollectorfilter ADD INDEX idx_emailcollector_fk_emailcollector (fk_emailcollector);
ALTER TABLE llx_emailcollector_emailcollectorfilter ADD CONSTRAINT fk_emailcollectorfilter_fk_emailcollector FOREIGN KEY (fk_emailcollector) REFERENCES llx_emailcollector_emailcollector(rowid);
diff --git a/htdocs/install/mysql/tables/llx_emailcollector_emailcollectoraction.sql b/htdocs/install/mysql/tables/llx_emailcollector_emailcollectoraction.sql
index 82251f33706..e0239cf98f6 100644
--- a/htdocs/install/mysql/tables/llx_emailcollector_emailcollectoraction.sql
+++ b/htdocs/install/mysql/tables/llx_emailcollector_emailcollectoraction.sql
@@ -24,7 +24,8 @@ CREATE TABLE llx_emailcollector_emailcollectoraction(
tms timestamp NOT NULL,
fk_user_creat integer NOT NULL,
fk_user_modif integer,
- import_key varchar(14),
+ position integer DEFAULT 0,
+ import_key varchar(14),
status integer NOT NULL
-- END MODULEBUILDER FIELDS
) ENGINE=innodb;
\ No newline at end of file
diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php
index f9420919e91..de6ac5c8959 100644
--- a/htdocs/variants/list.php
+++ b/htdocs/variants/list.php
@@ -130,7 +130,7 @@ $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
- |
+ |
0): ?>
|