';
diff --git a/htdocs/admin/ecm_directories_extrafields.php b/htdocs/admin/ecm_directories_extrafields.php
new file mode 100644
index 00000000000..71029c0fc67
--- /dev/null
+++ b/htdocs/admin/ecm_directories_extrafields.php
@@ -0,0 +1,123 @@
+
+ * Copyright (C) 2003 Jean-Louis Bergamo
+ * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2012 Florian Henry
+ * Copyright (C) 2013 Philippe Grand
+ * Copyright (C) 2015 Claudio Aschieri
+ * Copyright (C) 2020 Frédéric France
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/admin/ecm_directories_extrafields.php
+ * \ingroup ecm
+ * \brief Page to setup extra fields of ecm
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+
+
+if (!$user->admin)
+ accessforbidden();
+
+// Load translation files required by the page
+$langs->loadLangs(array('admin', 'other', 'ecm'));
+
+
+$extrafields = new ExtraFields($db);
+$form = new Form($db);
+
+// List of supported format
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) {
+ $type2label[$key] = $langs->transnoentitiesnoconv($val);
+}
+
+$action = GETPOST('action', 'aZ09');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'ecm_directories'; //Must be the $table_element of the class that manage extrafield
+
+if (!$user->admin) {
+ accessforbidden();
+}
+
+
+/*
+ * Actions
+ */
+
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
+
+
+/*
+ * View
+ */
+
+$textobject = $langs->transnoentitiesnoconv("ECM");
+
+llxHeader('', $langs->trans("ECMSetup"));
+
+$linkback = ''.$langs->trans("BackToModuleList").'';
+print load_fiche_titre($langs->trans("ECMSetup"), $linkback, 'title_setup');
+print " \n";
+
+$head = ecm_admin_prepare_head();
+
+dol_fiche_head($head, 'attributes_ecm_directories', $langs->trans("ECM"), -1, 'ecm');
+
+require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
+
+dol_fiche_end();
+
+
+// Buttons
+if ($action != 'create' && $action != 'edit') {
+ print '
";
+}
+
+
+/* ************************************************************************** */
+/* */
+/* Creation of an optional field */
+/* */
+/* ************************************************************************** */
+
+if ($action == 'create') {
+ print ' ';
+ print load_fiche_titre($langs->trans('NewAttribute'));
+ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
+}
+
+/* ************************************************************************** */
+/* */
+/* Edition of an optional field */
+/* */
+/* ************************************************************************** */
+if ($action == 'edit' && !empty($attrname)) {
+ print " ";
+ print load_fiche_titre($langs->trans("FieldEdition", $attrname));
+ require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/admin/ecm_files_extrafields.php b/htdocs/admin/ecm_files_extrafields.php
new file mode 100644
index 00000000000..9d747d4f684
--- /dev/null
+++ b/htdocs/admin/ecm_files_extrafields.php
@@ -0,0 +1,123 @@
+
+ * Copyright (C) 2003 Jean-Louis Bergamo
+ * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2012 Florian Henry
+ * Copyright (C) 2013 Philippe Grand
+ * Copyright (C) 2015 Claudio Aschieri
+ * Copyright (C) 2020 Frédéric France
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/admin/ecm_files_extrafields.php
+ * \ingroup ecm
+ * \brief Page to setup extra fields of ecm
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+
+
+if (!$user->admin)
+ accessforbidden();
+
+// Load translation files required by the page
+$langs->loadLangs(array('admin', 'other', 'ecm'));
+
+
+$extrafields = new ExtraFields($db);
+$form = new Form($db);
+
+// List of supported format
+$tmptype2label = ExtraFields::$type2label;
+$type2label = array('');
+foreach ($tmptype2label as $key => $val) {
+ $type2label[$key] = $langs->transnoentitiesnoconv($val);
+}
+
+$action = GETPOST('action', 'aZ09');
+$attrname = GETPOST('attrname', 'alpha');
+$elementtype = 'ecm_files'; //Must be the $table_element of the class that manage extrafield
+
+if (!$user->admin) {
+ accessforbidden();
+}
+
+
+/*
+ * Actions
+ */
+
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
+
+
+/*
+ * View
+ */
+
+$textobject = $langs->transnoentitiesnoconv("ECM");
+
+llxHeader('', $langs->trans("ECMSetup"));
+
+$linkback = ''.$langs->trans("BackToModuleList").'';
+print load_fiche_titre($langs->trans("ECMSetup"), $linkback, 'title_setup');
+print " \n";
+
+$head = ecm_admin_prepare_head();
+
+dol_fiche_head($head, 'attributes_ecm_files', $langs->trans("ECM"), -1, 'ecm');
+
+require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
+
+dol_fiche_end();
+
+
+// Buttons
+if ($action != 'create' && $action != 'edit') {
+ print '
';
if ($action == 'edit')
diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php
index 40068e2e0a3..483335093e9 100644
--- a/htdocs/ecm/file_card.php
+++ b/htdocs/ecm/file_card.php
@@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load translation files required by page
$langs->loadLangs(array('ecm', 'companies', 'other', 'users', 'orders', 'propal', 'bills', 'contracts', 'categories'));
@@ -94,6 +95,10 @@ $filepathtodocument = $relativetodocument.$file->label;
// Try to load object from index
$object = new ECMFiles($db);
+$extrafields = new ExtraFields($db);
+// fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
$result = $object->fetch(0, '', $filepathtodocument);
if ($result < 0)
{
@@ -148,7 +153,6 @@ if ($action == 'update')
// Now we update index of file
$db->begin();
-
//print $oldfile.' - '.$newfile;
if ($newlabel != $oldlabel)
{
@@ -181,6 +185,16 @@ if ($action == 'update')
if ($object->id > 0)
{
+ $ret = $extrafields->setOptionalsFromPost(null, $object);
+ if ($ret < 0) $error++;
+ if (!$error) {
+ // Actions on extra fields
+ $result = $object->insertExtraFields();
+ if ($result < 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $error++;
+ }
+ }
// Call update to set the share key
$result = $object->update($user);
if ($result < 0)
@@ -365,8 +379,9 @@ if (!empty($object->share))
print 'share ? ' checked="checked"' : '').' /> ';
}
}
-print '';
-
+print '';
+print '';
+print $object->showOptionals($extrafields, ($action == 'edit'?'edit':'view'));
print '';
print '';
diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
index cae368aea21..ffce6b110dc 100644
--- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
+++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
@@ -105,28 +105,28 @@ ALTER TABLE llx_c_incoterms ADD COLUMN label varchar(100) NULL;
CREATE TABLE llx_recruitment_recruitmentjobposition(
- rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
- ref varchar(128) DEFAULT '(PROV)' NOT NULL,
- entity INTEGER DEFAULT 1 NOT NULL,
- label varchar(255) NOT NULL,
- qty integer DEFAULT 1 NOT NULL,
- fk_soc integer,
- fk_project integer,
- fk_user_recruiter integer,
- fk_user_supervisor integer,
- fk_establishment integer,
- date_planned date,
- remuneration_suggested varchar(255),
- description text,
- note_public text,
- note_private text,
- date_creation datetime NOT NULL,
- tms timestamp,
- fk_user_creat integer NOT NULL,
- fk_user_modif integer,
- last_main_doc varchar(255),
- import_key varchar(14),
- model_pdf varchar(255),
+ rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
+ ref varchar(128) DEFAULT '(PROV)' NOT NULL,
+ entity INTEGER DEFAULT 1 NOT NULL,
+ label varchar(255) NOT NULL,
+ qty integer DEFAULT 1 NOT NULL,
+ fk_soc integer,
+ fk_project integer,
+ fk_user_recruiter integer,
+ fk_user_supervisor integer,
+ fk_establishment integer,
+ date_planned date,
+ remuneration_suggested varchar(255),
+ description text,
+ note_public text,
+ note_private text,
+ date_creation datetime NOT NULL,
+ tms timestamp,
+ fk_user_creat integer NOT NULL,
+ fk_user_modif integer,
+ last_main_doc varchar(255),
+ import_key varchar(14),
+ model_pdf varchar(255),
status smallint NOT NULL
) ENGINE=innodb;
@@ -160,24 +160,24 @@ CREATE TABLE llx_recruitment_recruitmentcandidature(
-- BEGIN MODULEBUILDER FIELDS
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
entity integer NOT NULL DEFAULT 1,
- fk_recruitmentjobposition INTEGER NULL,
- ref varchar(128) DEFAULT '(PROV)' NOT NULL,
- description text,
- note_public text,
- note_private text,
- date_creation datetime NOT NULL,
- tms timestamp,
- fk_user_creat integer NOT NULL,
- fk_user_modif integer,
- import_key varchar(14),
- model_pdf varchar(255),
- status smallint NOT NULL,
- firstname varchar(128),
+ fk_recruitmentjobposition INTEGER NULL,
+ ref varchar(128) DEFAULT '(PROV)' NOT NULL,
+ description text,
+ note_public text,
+ note_private text,
+ date_creation datetime NOT NULL,
+ tms timestamp,
+ fk_user_creat integer NOT NULL,
+ fk_user_modif integer,
+ import_key varchar(14),
+ model_pdf varchar(255),
+ status smallint NOT NULL,
+ firstname varchar(128),
lastname varchar(128),
email varchar(255),
phone varchar(64),
date_birth date,
- remuneration_requested integer,
+ remuneration_requested integer,
remuneration_proposed integer,
email_msgid varchar(255),
fk_recruitment_origin INTEGER NULL
@@ -272,8 +272,8 @@ ALTER TABLE llx_recruitment_recruitmentcandidature ADD UNIQUE INDEX uk_recruitme
ALTER TABLE llx_product MODIFY COLUMN seuil_stock_alerte float;
ALTER TABLE llx_product MODIFY COLUMN desiredstock float;
-ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN seuil_stock_alerte float;
-ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN desiredstock float;
+ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN seuil_stock_alerte float;
+ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN desiredstock float;
ALTER TABLE llx_product ADD COLUMN fk_state integer DEFAULT NULL;
@@ -331,5 +331,24 @@ ALTER TABLE llx_bank ADD COLUMN import_key varchar(14);
ALTER TABLE llx_menu MODIFY COLUMN enabled text;
+CREATE TABLE llx_ecm_files_extrafields
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp,
+ fk_object integer NOT NULL,
+ import_key varchar(14) -- import key
+) ENGINE=innodb;
+
+ALTER TABLE llx_ecm_files_extrafields ADD INDEX idx_ecm_files_extrafields (fk_object);
+
+CREATE TABLE llx_ecm_directories_extrafields
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp,
+ fk_object integer NOT NULL,
+ import_key varchar(14) -- import key
+) ENGINE=innodb;
+
+ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extrafields (fk_object);
ALTER TABLE llx_website_page ADD COLUMN object_type varchar(255);
ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255);
diff --git a/htdocs/install/mysql/tables/llx_ecm_directories_extrafields.key.sql b/htdocs/install/mysql/tables/llx_ecm_directories_extrafields.key.sql
new file mode 100644
index 00000000000..a84fa2c845c
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_ecm_directories_extrafields.key.sql
@@ -0,0 +1,20 @@
+-- ===================================================================
+-- Copyright (C) 2020 Frédéric France
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+--
+-- ===================================================================
+
+
+ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extrafields (fk_object);
diff --git a/htdocs/install/mysql/tables/llx_ecm_directories_extrafileds.sql b/htdocs/install/mysql/tables/llx_ecm_directories_extrafileds.sql
new file mode 100644
index 00000000000..e2e496267ba
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_ecm_directories_extrafileds.sql
@@ -0,0 +1,26 @@
+-- ========================================================================
+-- Copyright (C) 2020 Frédéric France
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+--
+-- ========================================================================
+
+CREATE TABLE llx_ecm_directories_extrafields
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp,
+ fk_object integer NOT NULL,
+ import_key varchar(14) -- import key
+) ENGINE=innodb;
+
diff --git a/htdocs/install/mysql/tables/llx_ecm_files_extrafields.key.sql b/htdocs/install/mysql/tables/llx_ecm_files_extrafields.key.sql
new file mode 100644
index 00000000000..3ebd3712184
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_ecm_files_extrafields.key.sql
@@ -0,0 +1,20 @@
+-- ===================================================================
+-- Copyright (C) 2020 Frédéric France
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+--
+-- ===================================================================
+
+
+ALTER TABLE llx_ecm_files_extrafields ADD INDEX idx_ecm_files_extrafields (fk_object);
diff --git a/htdocs/install/mysql/tables/llx_ecm_files_extrafields.sql b/htdocs/install/mysql/tables/llx_ecm_files_extrafields.sql
new file mode 100644
index 00000000000..0cf0de6d375
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_ecm_files_extrafields.sql
@@ -0,0 +1,26 @@
+-- ========================================================================
+-- Copyright (C) 2020 Frédéric France
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+--
+-- ========================================================================
+
+CREATE TABLE llx_ecm_files_extrafields
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp,
+ fk_object integer NOT NULL,
+ import_key varchar(14) -- import key
+) ENGINE=innodb;
+
diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang
index 369ac6dfdfa..aaf81b0f346 100644
--- a/htdocs/langs/en_US/ecm.lang
+++ b/htdocs/langs/en_US/ecm.lang
@@ -50,3 +50,6 @@ ReSyncListOfDir=Resync list of directories
HashOfFileContent=Hash of file content
NoDirectoriesFound=No directories found
FileNotYetIndexedInDatabase=File not yet indexed into database (try to re-upload it)
+ExtraFieldsEcmFiles=Extrafields Ecm Files
+ExtraFieldsEcmDirectories=Extrafields Ecm Directories
+ECMSetup=ECM Setup