diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index 4b9d0a847f2..7d695ce023d 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -55,9 +55,10 @@ class FormEcm * @param int $selected Id of preselected section * @param string $select_name Name of HTML select component * @param string $module Module ('ecm', 'medias', ...) + * @param array $ignore_id Arroy of id to ignore * @return string String with HTML select */ - public function selectAllSections($selected = 0, $select_name = '', $module = 'ecm') + public function selectAllSections($selected = 0, $select_name = '', $module = 'ecm', $ignore_id = array()) { global $conf, $langs; $langs->load("ecm"); @@ -65,6 +66,9 @@ class FormEcm if ($select_name == '') { $select_name = "catParent"; } + if (!is_array($ignore_id)) { + $ignore_id = array($ignore_id); + } $cate_arbo = null; if ($module == 'ecm') { @@ -83,13 +87,15 @@ class FormEcm } else { $output .= ' '; foreach ($cate_arbo as $key => $value) { - $valueforoption = empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id']; - if ($selected && $valueforoption == $selected) { - $add = 'selected '; - } else { - $add = ''; + if (!in_array($cate_arbo[$key]['id'], $ignore_id)) { + $valueforoption = empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id']; + if ($selected && $valueforoption == $selected) { + $add = 'selected '; + } else { + $add = ''; + } + $output .= ''.(empty($cate_arbo[$key]['fulllabel']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['fulllabel']).''; } - $output .= ''.(empty($cate_arbo[$key]['fulllabel']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['fulllabel']).''; } } } diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index fec8151728e..b6aa59720ae 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.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'; +require_once DOL_DOCUMENT_ROOT.'/ecm/class/htmlecm.form.class.php'; // Load translation files required by page $langs->loadLangs(array('ecm', 'companies', 'other')); @@ -204,6 +205,12 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) { // Fetch was already done $ecmdir->label = dol_sanitizeFileName(GETPOST("label")); + $fk_parent = GETPOST("catParent", 'int'); + if ($fk_parent == "-1") { + $ecmdir->fk_parent = "0"; + } else { + $ecmdir->fk_parent = $fk_parent; + } $ecmdir->description = GETPOST("description"); $ret = $extrafields->setOptionalsFromPost(null, $ecmdir); if ($ret < 0) { @@ -219,8 +226,10 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) { } $result = $ecmdir->update($user); if ($result > 0) { + $newdir = $ecmdir->getRelativePath(1); + $newdir = $conf->ecm->dir_output.'/'.$newdir; // Try to rename file if changed - if ($oldlabel != $ecmdir->label && file_exists($olddir)) { + if (($oldlabel != $ecmdir->label && file_exists($olddir)) || ($olddir != $newdir && file_exists($olddir))) { $newdir = $ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory $newdir = $conf->ecm->dir_output.'/'.$newdir; //print $olddir.'-'.$newdir; @@ -270,6 +279,7 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) { */ $form = new Form($db); +$formecm = new FormEcm($db); $object = new EcmDirectory($db); // Need to create a new one instance $extrafields = new ExtraFields($db); @@ -317,11 +327,7 @@ if ($module == 'ecm') { $tmpecmdir->fetch($ecmdir->id); while ($tmpecmdir && $result > 0) { $tmpecmdir->ref = $tmpecmdir->label; - if ($i == 0 && $action == 'edit') { - $s = ''; - } else { - $s = $tmpecmdir->getNomUrl(1).$s; - } + $s = $tmpecmdir->getNomUrl(1).$s; if ($tmpecmdir->fk_parent) { $s = ' -> '.$s; $result = $tmpecmdir->fetch($tmpecmdir->fk_parent); @@ -371,6 +377,16 @@ print img_picto('','object_dir').' '.$l print $s; print '';*/ if ($module == 'ecm') { + if ($action == 'edit') { + print ''.$langs->trans("ECMDirName").''; + print ''; + print ''; + print ''.$langs->trans("ECMParentDirectory").''; + print $formecm->selectAllSections($ecmdir->fk_parent, '', 'ecm', array($ecmdir->id)); + print ''; + print ''; + } + print ''.$langs->trans("Description").''; if ($action == 'edit') { print ''; diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index bc18bed4a29..494a6c55164 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -45,3 +45,5 @@ GenerateImgWebp=Duplicate all images with another version with .webp format ConfirmGenerateImgWebp=If you confirm, you will generate an image in .webp format for all images currently into this folder (subfolders are not included)... ConfirmImgWebpCreation=Confirm all images duplication SucessConvertImgWebp=Images successfully duplicated +ECMDirName=Dir name +ECMParentDirectory=Parent directory diff --git a/htdocs/langs/fr_FR/ecm.lang b/htdocs/langs/fr_FR/ecm.lang index 605cc97625d..c5867cbc7ed 100644 --- a/htdocs/langs/fr_FR/ecm.lang +++ b/htdocs/langs/fr_FR/ecm.lang @@ -45,3 +45,5 @@ GenerateImgWebp=Dupliquer toutes les images avec une autre version au format .we ConfirmGenerateImgWebp=Si vous confirmez, vous générerez une image au format .webp pour toutes les images actuellement dans ce dossier (les sous-dossiers ne sont pas inclus)... ConfirmImgWebpCreation=Confirmer la duplication de toutes les images SucessConvertImgWebp=Images dupliquées avec succès +ECMDirName=Nom du dossier +ECMParentDirectory=Dossier parent