diff --git a/htdocs/ecm/docdir.php b/htdocs/ecm/docdir.php
index 03d8c0d4f16..ae104ad4b32 100644
--- a/htdocs/ecm/docdir.php
+++ b/htdocs/ecm/docdir.php
@@ -18,11 +18,11 @@
*/
/**
- \file htdoc/ecm/index.php
- \ingroup ecm
- \brief Main page for ECM section area
- \version $Id$
- \author Laurent Destailleur
+ \file htdoc/ecm/docdir.php
+ \ingroup ecm
+ \brief Main page for ECM section area
+ \version $Id$
+ \author Laurent Destailleur
*/
require("./pre.inc.php");
@@ -44,6 +44,7 @@ $langs->load("categories");
// Load permissions
$user->getrights('ecm');
+
// Get parameters
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
@@ -81,22 +82,34 @@ if (! empty($_GET["section"]))
// Action ajout d'un produit ou service
if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
{
- $ecmdir->ref = $_POST["ref"];
- $ecmdir->label = $_POST["label"];
- $ecmdir->description = $_POST["desc"];
+ $ecmdir->ref = trim($_POST["ref"]);
+ $ecmdir->label = trim($_POST["label"]);
+ $ecmdir->description = trim($_POST["desc"]);
$ecmdir->fk_parent = $_POST["catParent"];
- $id = $ecmdir->create($user);
-
- if ($id > 0)
+ $ok=true;
+
+ if (! $ecmdir->label)
{
- Header("Location: ".DOL_URL_ROOT.'/ecm/docmine.php?section='.$id);
- exit;
- }
- else
- {
- $mesg='
Error '.$langs->trans($ecmdir->error).'
';
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'
';
$_GET["action"] = "create";
+ $ok=false;
+ }
+
+ if ($ok)
+ {
+ $id = $ecmdir->create($user);
+
+ if ($id > 0)
+ {
+ Header("Location: ".DOL_URL_ROOT.'/ecm/index.php');
+ exit;
+ }
+ else
+ {
+ $mesg='Error '.$langs->trans($ecmdir->error).'
';
+ $_GET["action"] = "create";
+ }
}
}
@@ -186,7 +199,7 @@ if (! $_GET["action"] || $_GET["action"] == 'delete_section')
// Construit fiche rubrique
-
+print $user->rights->ecm->setup;
// Actions buttons
print '';
if ($user->rights->ecm->setup)
diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php
index 96d7215b631..47eddd95c5d 100644
--- a/htdocs/ecm/docmine.php
+++ b/htdocs/ecm/docmine.php
@@ -39,6 +39,7 @@ $langs->load("other");
// Load permissions
$user->getrights('ecm');
+
// Security check
if ($user->societe_id > 0)
{
@@ -99,9 +100,8 @@ if ( $_POST["sendit"] && $conf->upload != 0)
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']);
if ($result == 1)
{
- $mesg = '
'.$langs->trans("FileTransferComplete").'
';
+ //$mesg = '
'.$langs->trans("FileTransferComplete").'
';
//print_r($_FILES);
-
$result=$ecmdir->changeNbOfFiles('+');
}
else if (!$result)
@@ -118,7 +118,7 @@ if ( $_POST["sendit"] && $conf->upload != 0)
}
}
-// Suppression fichier
+// Remove file
if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
{
$file = $upload_dir . "/" . urldecode($_GET["urlfile"]);
@@ -129,7 +129,21 @@ if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
$result=$ecmdir->changeNbOfFiles('-');
}
+// Remove dir
+if ($_POST['action'] == 'confirm_deletedir' && $_POST['confirm'] == 'yes')
+{
+ $result=$ecmdir->delete($user);
+ header("Location: ".DOL_URL_ROOT."/ecm/index.php");
+ exit;
+ // $mesg = '
'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'
';
+}
+// Remove dir
+if ($_POST['action'] == 'update' && ! $_POST['cancel'])
+{
+ $ecmdir->description = $_POST["description"];
+ $result=$ecmdir->update($user);
+}
@@ -151,6 +165,12 @@ $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolowe
$head = ecm_prepare_head($ecmdir);
dolibarr_fiche_head($head, 'card', $langs->trans("ECMManualOrg"));
+if ($_GET["action"] == 'edit')
+{
+ print '
';
+}
print '
';
+// Actions buttons
+if ($_GET["action"] != 'edit' && $_GET['action'] != 'delete_dir' && $_GET['action'] != 'delete_file')
+{
+ print '';
+}
-/*
-* Confirmation de la suppression d'une ligne produit
-*/
+if ($mesg) { print $mesg.'
'; }
+
+
+// Confirm remove file
if ($_GET['action'] == 'delete_file')
{
$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
print '
';
}
-if ($mesg) { print $mesg."
"; }
+// Confirm remove file
+if ($_GET['action'] == 'delete_dir')
+{
+ $form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"], $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection'), 'confirm_deletedir');
+ print '
';
+}
+
// Affiche formulaire upload
$formfile=new FormFile($db);
@@ -250,11 +321,13 @@ foreach($filearray as $key => $file)
print "\n";
print ''.dol_print_size($file['size']).' | ';
print ''.dolibarr_print_date($file['date'],"dayhour").' | ';
- print '';
- echo ''.img_delete().'';
+ print ' | ';
+ //print ' ';
+ print ''.img_delete().'';
print " | \n";
}
}
+if (sizeof($filearray) == 0) print '| '.$langs->trans("ECMNoFileFound").' |
';
print "";
// Fin de zone Ajax
diff --git a/htdocs/ecm/ecmdirectory.class.php b/htdocs/ecm/ecmdirectory.class.php
index 0910c68f3cc..13ba81d972b 100644
--- a/htdocs/ecm/ecmdirectory.class.php
+++ b/htdocs/ecm/ecmdirectory.class.php
@@ -100,7 +100,7 @@ class EcmDirectory // extends CommonObject
$sql.= " '".$this->fk_user_c."'";
$sql.= ")";
- dolibarr_syslog("Ecm_directories::create sql=".$sql, LOG_DEBUG);
+ dolibarr_syslog("EcmDirectories::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@@ -120,7 +120,7 @@ class EcmDirectory // extends CommonObject
else
{
$this->error="Error ".$this->db->lasterror();
- dolibarr_syslog("Ecm_directories::create ".$this->error, LOG_ERR);
+ dolibarr_syslog("EcmDirectories::create ".$this->error, LOG_ERR);
return -1;
}
}
@@ -136,13 +136,10 @@ class EcmDirectory // extends CommonObject
global $conf, $langs;
// Clean parameters
-
$this->label=trim($this->label);
$this->fk_parent=trim($this->fk_parent);
$this->description=trim($this->description);
-
-
// Check parameters
// Put here code to add control on parameters values
@@ -151,18 +148,15 @@ class EcmDirectory // extends CommonObject
$sql.= " label='".addslashes($this->label)."',";
$sql.= " fk_parent='".$this->fk_parent."',";
- $sql.= " description='".addslashes($this->description)."',";
- $sql.= " tms=".$this->db->idate($this->tms)."";
-
-
+ $sql.= " description='".addslashes($this->description)."'";
$sql.= " WHERE rowid=".$this->id;
- dolibarr_syslog("Ecm_directories::update sql=".$sql, LOG_DEBUG);
+ dolibarr_syslog("EcmDirectories::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
- dolibarr_syslog("Ecm_directories::update ".$this->error, LOG_ERR);
+ dolibarr_syslog("EcmDirectories::update ".$this->error, LOG_ERR);
return -1;
}
@@ -195,12 +189,12 @@ class EcmDirectory // extends CommonObject
$sql.= " cachenbofdoc = cachenbofdoc ".$sign." 1";
$sql.= " WHERE rowid = ".$this->id;
- dolibarr_syslog("Ecm_directories::changeNbOfFiles sql=".$sql, LOG_DEBUG);
+ dolibarr_syslog("EcmDirectories::changeNbOfFiles sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
- dolibarr_syslog("Ecm_directories::changeNbOfFiles ".$this->error, LOG_ERR);
+ dolibarr_syslog("EcmDirectories::changeNbOfFiles ".$this->error, LOG_ERR);
return -1;
}
@@ -211,11 +205,10 @@ class EcmDirectory // extends CommonObject
/**
* \brief Load object in memory from database
* \param id id object
- * \return int <0 if KO, >0 if OK
+ * \return int <0 if KO, 0 if not found, >0 if OK
*/
function fetch($id)
{
- global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.label,";
@@ -229,14 +222,13 @@ class EcmDirectory // extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
$sql.= " WHERE t.rowid = ".$id;
- dolibarr_syslog("Ecm_directories::fetch sql=".$sql, LOG_DEBUG);
+ dolibarr_syslog("EcmDirectories::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
- if ($this->db->num_rows($resql))
- {
- $obj = $this->db->fetch_object($resql);
-
+ $obj = $this->db->fetch_object($resql);
+ if ($obj)
+ {
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
@@ -249,14 +241,15 @@ class EcmDirectory // extends CommonObject
$this->date_c = $obj->date_c;
$this->date_m = $obj->date_m;
}
+
$this->db->free($resql);
-
- return 1;
+
+ return $obj?1:0;
}
else
{
$this->error="Error ".$this->db->lasterror();
- dolibarr_syslog("Ecm_directories::fetch ".$this->error, LOG_ERR);
+ dolibarr_syslog("EcmDirectories::fetch ".$this->error, LOG_ERR);
return -1;
}
}
@@ -274,12 +267,12 @@ class EcmDirectory // extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
$sql.= " WHERE rowid=".$this->id;
- dolibarr_syslog("Ecm_directories::delete sql=".$sql);
+ dolibarr_syslog("EcmDirectories::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
- dolibarr_syslog("Ecm_directories::delete ".$this->error, LOG_ERR);
+ dolibarr_syslog("EcmDirectories::delete ".$this->error, LOG_ERR);
return -1;
}
@@ -329,11 +322,12 @@ class EcmDirectory // extends CommonObject
//$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
$picto='dir';
- $label=$langs->trans("ShowECMSection").': '.$this->ref;
-
- if ($withpicto) $result.=($lien.img_object($label,$picto,'',1).$lienfin);
+ $newref=eregi_replace('_',' ',$this->ref);
+ $newlabel=$langs->trans("ShowECMSection").': '.$newref;
+
+ if ($withpicto) $result.=($lien.img_object($newlabel,$picto,'',1).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
- if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
+ if ($withpicto != 2) $result.=$lien.$newref.$lienfin;
return $result;
}
@@ -387,7 +381,7 @@ class EcmDirectory // extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories";
$sql.= " WHERE fk_parent != 0";
- dolibarr_syslog("ECMDirectory::get_full_arbo sql=".$sql);
+ dolibarr_syslog("EcmDirectory::get_full_arbo sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
@@ -415,10 +409,16 @@ class EcmDirectory // extends CommonObject
* label = nom de la categorie
* fulllabel = nom avec chemin complet de la categorie
* fullpath = chemin complet compose des id
+ * \param force Force reload of full arbo even if already loaded
* \return array Tableau de array
*/
- function get_full_arbo()
+ function get_full_arbo($force=0)
{
+ if (empty($force) && $this->full_arbo_loaded)
+ {
+ return $this->cats;
+ }
+
// Init this->motherof array
$this->load_motherof();
@@ -435,7 +435,7 @@ class EcmDirectory // extends CommonObject
$sql.= " WHERE c.fk_user_c = u.rowid";
$sql.= " ORDER BY c.label, c.rowid";
- dolibarr_syslog("ECMDirectory::get_full_arbo sql=".$sql);
+ dolibarr_syslog("EcmDirectory::get_full_arbo sql=".$sql);
$resql = $this->db->query ($sql);
if ($resql)
{
@@ -484,8 +484,7 @@ class EcmDirectory // extends CommonObject
}
$this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
-
- //$this->debug_cats();
+ $this->full_arbo_loaded=1;
return $this->cats;
}
@@ -525,7 +524,40 @@ class EcmDirectory // extends CommonObject
}
}
- return;
+ return 1;
}
+
+ /**
+ * \brief refresh cachenboffile
+ * \param directory Directory to scan
+ * \return int <0 if ko, >0 if OK
+ */
+ function refreshcachenboffile()
+ {
+ global $conf;
+ include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
+
+ $dir=$conf->ecm->dir_output.'/'.$this->getRelativePath();
+ $filelist=dol_dir_list($dir,'files',0,'','\.meta$');
+
+ // Test if filelist is in database
+
+
+ // Update request
+ $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
+ $sql.= " cachenbofdoc='".sizeof($filelist)."'";
+ $sql.= " WHERE rowid=".$this->id;
+ dolibarr_syslog("EcmDirectories::refreshcachenboffile sql=".$sql, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql)
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dolibarr_syslog("EcmDirectories::refreshcachenboffile ".$this->error, LOG_ERR);
+ return -1;
+ }
+
+ return 1;
+ }
+
}
?>
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index ba3952fc2c2..a611e3e540f 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -1,5 +1,19 @@
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
@@ -103,220 +117,218 @@ $form=new Form($db);
$ecmdirstatic = new ECMDirectory($db);
$userstatic = new User($db);
-if (! $_GET["action"] || $_GET["action"] == 'delete_section')
+//***********************
+// List
+//***********************
+print_fiche_titre($langs->trans("ECMArea"));
+
+print $langs->trans("ECMAreaDesc")."
";
+print $langs->trans("ECMAreaDesc2")."
";
+print "
\n";
+
+print '';
+
+//print_fiche_titre($langs->trans("ECMManualOrg"));
+
+print ' ";
+//print $langs->trans("ECMManualOrgDesc");
+
+print ' | ';
+
+//print_fiche_titre($langs->trans("ECMAutoOrg"));
+
+print ' ";
+//print $langs->trans("ECMAutoOrgDesc");
+
+print ' |
';
+print '
';
+
+
+//***********************
+// Files
+//***********************
+print_fiche_titre($langs->trans("ECMSectionOfDocuments"));
+//print '
';
+
+// Confirmation de la suppression d'une ligne categorie
+if ($_GET['action'] == 'delete_section')
{
- //***********************
- // List
- //***********************
- print_fiche_titre($langs->trans("ECMArea"));
-
- print $langs->trans("ECMAreaDesc")."
";
- print $langs->trans("ECMAreaDesc2")."
";
- print "
\n";
-
- print '';
-
- //print_fiche_titre($langs->trans("ECMManualOrg"));
-
- print ' ";
- //print $langs->trans("ECMManualOrgDesc");
-
- print ' | ';
-
- //print_fiche_titre($langs->trans("ECMAutoOrg"));
-
- print ' ";
- //print $langs->trans("ECMAutoOrgDesc");
-
- print ' |
';
- print '
';
-
-
- //***********************
- // Files
- //***********************
- print_fiche_titre($langs->trans("ECMSectionOfDocuments"));
- //print '
';
-
-/*
- $ecmdir->ref=$ecmdir->label;
- print $langs->trans("ECMSection").': ';
- print img_picto('','object_dir').' ';
- print ''.$langs->trans("ECMRoot").'';
- //print ' -> '.$ecmdir->getNomUrl(1).'
';
- print "
";
-*/
-
- // Confirmation de la suppression d'une ligne categorie
- if ($_GET['action'] == 'delete_section')
- {
- $form->form_confirm($_SERVER["PHP_SELF"].'?section='.urldecode($_GET["section"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection');
- print '
';
- }
-
- if ($mesg) { print $mesg."
"; }
-
-
- // Construit liste des répertoires
- print '';
-
- // Ajout rubriques automatiques
- $sectionauto=array();
- if ($conf->societe->enabled) $sectionauto[]=array('test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties"));
- if ($conf->propal->enabled) $sectionauto[]=array('test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals"));
- if ($conf->commande->enabled) $sectionauto[]=array('test'=>$conf->commande->enabled,'label'=>$langs->trans("Orders"), 'desc'=>$langs->trans("ECMDocsByOrders"));
- if ($conf->contrat->enabled) $sectionauto[]=array('test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts"));
- if ($conf->facture->enabled) $sectionauto[]=array('test'=>$conf->facture->enabled, 'label'=>$langs->trans("Invoices"), 'desc'=>$langs->trans("ECMDocsByInvoices"));
-
- if (sizeof($sectionauto))
- {
- // Automatic sections
- print '';
- print '| '.$langs->trans("ECMSectionAuto").' | ';
- print ''.$langs->trans("Description").' | ';
- print ''.$langs->trans("ECMCreationUser").' | ';
- print ' | ';
- print ''.$langs->trans("ECMNbOfDocs").' | ';
- print ' | ';
- print '
';
-
- $sectionauto=dol_sort_array($sectionauto,'label',$sortorder,true,false);
-
- $var=true;
- foreach ($sectionauto as $key => $val)
- {
- if ($val['test'])
- {
- $var=! $var;
-
- print '';
-
- // Section
- print '| ';
- print img_picto('','object_dir').' ';
- print '';
- print $val['label'];
- print '';
- print " | \n";
-
- // Description
- print ''.$val['desc'].' | ';
- print ''.$langs->trans("ECMTypeAuto").' | ';
- print ' | ';
- print '? | ';
- print ' | ';
- print "
\n";
- }
- }
- }
-
-
- // Manual sections
-
- print '';
- $param='&socid='.$socid;
-
- print '| '.$langs->trans("ECMSectionManual").' | ';
- print ''.$langs->trans("Description").' | ';
- print ''.$langs->trans("ECMCreationUser").' | ';
- print ''.$langs->trans("ECMCreationDate").' | ';
- print ''.$langs->trans("ECMNbOfDocs").' | ';
- print ' | ';
- print '
';
-
- $ecmdirstatic = new ECMDirectory($db);
- $rub=$ecmdirstatic->get_full_arbo();
-
- $userstatic = new User($db);
-
- $nbofentries=0;
- $var=true;
- foreach($rub as $key => $val)
- {
- $var=!$var;
-
- $ecmdirstatic->id=$val['id'];
- $ecmdirstatic->ref=$val['label'];
-
- print '';
-
- // Section
- print '| ';
- print str_repeat(' ',$val['level']-1);
- print $ecmdirstatic->getNomUrl(1);
- print " | \n";
-
- // Description
- print ''.dolibarr_trunc($val['description'],32).' | ';
- $userstatic->id=$val['fk_user_c'];
- $userstatic->nom=$val['login_c'];
- print ''.$userstatic->getNomUrl(1).' | ';
- print ''.dolibarr_print_date($val['date_c'],"dayhour").' | ';
-
- // Nb of docs
- //print ''.$obj->cachenbofdoc.' | ';
- print ''.$val['cachenbofdoc'].' | ';
-
- print '';
- if ($val['cachenbofdoc'] == 0 && $val['level'] >= $rub[$key+1]['level'])
- {
- print ''.img_delete().'';
- }
- else
- {
- print ' ';
- }
- print " |
\n";
-
- $nbofentries++;
- }
-
- // If nothing to show
- if ($nbofentries == 0)
- {
- print '| '.$langs->trans("ECMNoDirecotyYet").' |
';
- }
-
- print "
";
- // Fin de zone Ajax
-
-
- // Actions buttons
- /*
- print '';
- */
+ $form->form_confirm($_SERVER["PHP_SELF"].'?section='.urldecode($_GET["section"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection');
+ print '
';
}
+if ($mesg) { print $mesg."
"; }
+
+
+// Construit liste des répertoires
+print '';
+
+// Ajout rubriques automatiques
+$sectionauto=array();
+if ($conf->societe->enabled) $sectionauto[]=array('test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties"));
+if ($conf->propal->enabled) $sectionauto[]=array('test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals"));
+if ($conf->commande->enabled) $sectionauto[]=array('test'=>$conf->commande->enabled,'label'=>$langs->trans("Orders"), 'desc'=>$langs->trans("ECMDocsByOrders"));
+if ($conf->contrat->enabled) $sectionauto[]=array('test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts"));
+if ($conf->facture->enabled) $sectionauto[]=array('test'=>$conf->facture->enabled, 'label'=>$langs->trans("Invoices"), 'desc'=>$langs->trans("ECMDocsByInvoices"));
+
+if (sizeof($sectionauto))
+{
+ // Automatic sections
+ print '';
+ print '| '.$langs->trans("ECMSectionAuto").' | ';
+ print ''.$langs->trans("Description").' | ';
+ print ''.$langs->trans("ECMNbOfDocsSmall").' | ';
+ print '';
+ print ' ';
+ print ' | ';
+ print '
';
+
+ $sectionauto=dol_sort_array($sectionauto,'label',$sortorder,true,false);
+
+ $var=true;
+ foreach ($sectionauto as $key => $val)
+ {
+ if ($val['test'])
+ {
+ $var=! $var;
+
+ print '';
+
+ // Section
+ print '| ';
+ print img_picto('','object_dir').' ';
+ print '';
+ print $val['label'];
+ print '';
+ print " | \n";
+
+ // Description
+ print ''.$val['desc'].' | ';
+ print '? | ';
+ print '';
+ $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].' ';
+ $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMAutoOrg").' ';
+ $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$langs->trans("ECMTypeAuto");
+ print $form->textwithhelp('',$htmltooltip,1,0);
+ print ' | ';
+ print "
\n";
+ }
+ }
+}
+
+
+// Manual sections
+
+print '';
+$param='&socid='.$socid;
+
+print '| '.$langs->trans("ECMSectionManual").' | ';
+print ''.$langs->trans("Description").' | ';
+print ''.$langs->trans("ECMNbOfDocsSmall");
+print ''.img_picto($langs->trans("Refresh"),'refresh').'';
+print ' | ';
+print '';
+print ''.img_picto($langs->trans("ECMNewSection"),'edit_add').'';
+print ' | ';
+print '
';
+
+$ecmdirstatic = new ECMDirectory($db);
+$rub=$ecmdirstatic->get_full_arbo();
+
+$userstatic = new User($db);
+
+$nbofentries=0;
+$var=true;
+foreach($rub as $key => $val)
+{
+ $var=!$var;
+
+ $ecmdirstatic->id=$val['id'];
+ $ecmdirstatic->ref=$val['label'];
+
+ // Refresh cache
+ if ($_GET['action'] == 'refreshauto')
+ {
+ $result=$ecmdirstatic->fetch($val['id']);
+ $result=$ecmdirstatic->refreshcachenboffile();
+
+ $ecmdirstatic->ref=$ecmdirstatic->label;
+ }
+
+
+ print '';
+
+ // Section
+ print '| ';
+ print str_repeat(' ',$val['level']-1);
+ print $ecmdirstatic->getNomUrl(1);
+ print " | \n";
+
+ // Description
+ print ''.dolibarr_trunc($val['description'],32).' | ';
+
+ // Nb of docs
+ //print ''.$obj->cachenbofdoc.' | ';
+ print ''.$val['cachenbofdoc'].' | ';
+
+ print '';
+ $userstatic->id=$val['fk_user_c'];
+ $userstatic->nom=$val['login_c'];
+ $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].' ';
+ $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMManualOrg").' ';
+ $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1).' ';
+ $htmltooltip.=''.$langs->trans("ECMCreationDate").': '.dolibarr_print_date($val['date_c'],"dayhour");
+ print $form->textwithhelp('',$htmltooltip,1,0);
+ print " |
\n";
+
+ $nbofentries++;
+}
+
+// If nothing to show
+if ($nbofentries == 0)
+{
+ print '| '.$langs->trans("ECMNoDirecotyYet").' |
';
+}
+
+print "
";
+// Fin de zone Ajax
+
+
+// Actions buttons
+/*
+print '';
+*/
+
// End of page
$db->close();
diff --git a/htdocs/ecm/pre.inc.php b/htdocs/ecm/pre.inc.php
index c061bc4370a..3d38a0cc489 100644
--- a/htdocs/ecm/pre.inc.php
+++ b/htdocs/ecm/pre.inc.php
@@ -39,7 +39,6 @@ function llxHeader($head = "", $title="", $help_url='')
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/ecm/index.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("MenuECM"),0,$user->rights->ecm->read);
- //$menu->add_submenu(DOL_URL_ROOT."/ecm/docdir.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("List"),1,$user->rights->ecm->read);
$menu->add_submenu(DOL_URL_ROOT."/ecm/index.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("List"),1,$user->rights->ecm->read);
//$menu->add_submenu(DOL_URL_ROOT."/ecm/index?mainmenu=ecm&action=create&idmenu=".$_SESSION["idmenu"], $langs->trans("ECMNewDocument"),1,$user->rights->ecm->create);
diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang
index 6487b952739..6483fe804ad 100644
--- a/htdocs/langs/en_US/ecm.lang
+++ b/htdocs/langs/en_US/ecm.lang
@@ -8,7 +8,8 @@ DocsContracts=Documents contracts
DocsProposals=Documents proposals
DocsOrders=Documents orders
DocsInvoices=Documents invoices
-ECMNbOfDocs=Nb doc
+ECMNbOfDocs=Nb of documents in directory
+ECMNbOfDocsSmall=Nb of doc.
ECMSection=Directory
ECMSectionManual=Manual directory
ECMSectionAuto=Automatic directory
@@ -41,4 +42,6 @@ ECMNoDirecotyYet=No directory created
ShowECMSection=Show directory
DeleteSection=Remove directory
ConfirmDeleteSection=Can you confirm you want to delete the directory %s ?
-ECMDirectoryForFiles=Relative directory for files
\ No newline at end of file
+ECMDirectoryForFiles=Relative directory for files
+CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files
+ECMNoFileFound=No documents saved in this directory
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/ecm.lang b/htdocs/langs/fr_FR/ecm.lang
index c42347da349..04c99ef79d3 100644
--- a/htdocs/langs/fr_FR/ecm.lang
+++ b/htdocs/langs/fr_FR/ecm.lang
@@ -8,7 +8,8 @@ DocsContracts=Documents contrats
DocsProposals=Documents propositions
DocsOrders=Documents commandes
DocsInvoices=Documents factures
-ECMNbOfDocs=Nb doc
+ECMNbOfDocs=Nb de documents de la rubrique
+ECMNbOfDocsSmall=Nb de doc.
ECMSection=Rubrique
ECMSectionManual=Rubriques manuelles
ECMSectionAuto=Rubriques automatique
@@ -22,7 +23,7 @@ ECMCreationDate=Date cr
ECMCreationUser=Créateur
ECMArea=Espace GED
ECMAreaDesc=L'espace GED (Gestion Electronique de Documents) vous permet de stocker dans Dolibarr et retrouver rapidement tout type de documents.
-ECMAreaDesc2=* Les rubriques automatiques sont alimentées automatiquement lors de l'ajout d'un document depuis une fiche objet (propal, facture, commande...).
* Les rubriques manuelles peuvent etre utilisées pour stocker des documents divers, non liés à un objet particulier.
+ECMAreaDesc2=* Les rubriques automatiques sont alimentées automatiquement lors de l'ajout d'un document depuis une fiche objet (propal, facture...).
* Les rubriques manuelles peuvent etre utilisées pour stocker des documents divers, non liés à un objet particulier.
ECMSectionWasRemoved=La rubrique %s a été effacée.
ECMDocumentsSection=Document de la section
ECMSearchByKeywords=Recherche par mots clés
@@ -40,5 +41,7 @@ ECMAutoOrg=Rubrique automatique
ECMNoDirecotyYet=Aucune rubrique créée
ShowECMSection=Afficher rubrique
DeleteSection=Suppression rubrique
-ConfirmDeleteSection=Confirmez-vous la suppression de la rubique %s ?
-ECMDirectoryForFiles=Répertoire relatif pour les fichiers
\ No newline at end of file
+ConfirmDeleteSection=Confirmez-vous la suppression de la rubrique %s ?
+ECMDirectoryForFiles=Répertoire relatif pour les fichiers
+CannotRemoveDirectoryContainsFiles=Suppression impossible car des fichiers sont présents
+ECMNoFileFound=Pas de documents stockés dans cette rubrique
\ No newline at end of file
diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php
index 4a929e042d0..8959beef7ba 100644
--- a/htdocs/lib/files.lib.php
+++ b/htdocs/lib/files.lib.php
@@ -32,7 +32,7 @@
\param $exludefilter Regex for exclude filter (example: '\.meta$')
\param $sortcriteria Sort criteria ("name","date","size")
\param $sortorder Sort order (SORT_ASC, SORT_DESC)
- \param $mode 0=Return array of key need, 1=Force all key to be loaded
+ \param $mode 0=Return array with only keys needed, 1=Force all keys to be loaded
\return array Array of array('name'=>xxx,'date'=>yyy,'size'=>zzz)
*/
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
diff --git a/mysql/migration/2.2.0-2.4.0.sql b/mysql/migration/2.2.0-2.4.0.sql
index 3c49a6f6c2c..8355789ca1a 100644
--- a/mysql/migration/2.2.0-2.4.0.sql
+++ b/mysql/migration/2.2.0-2.4.0.sql
@@ -252,6 +252,7 @@ alter table llx_tva modify fk_bank integer;
delete from llx_const where name='MAIN_USE_PREVIEW_TABS';
+drop table if exists llx_ecm_directories;
create table llx_ecm_directories
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
@@ -259,8 +260,8 @@ create table llx_ecm_directories
fk_parent integer,
description varchar(255) NOT NULL,
cachenbofdoc integer NOT NULL DEFAULT 0,
- date_c timestamp,
- date_m datetime,
+ date_c datetime,
+ date_m timestamp,
fk_user_c integer,
fk_user_m integer
) type=innodb;
diff --git a/mysql/tables/llx_ecm_directories.sql b/mysql/tables/llx_ecm_directories.sql
index 896605f7946..f0a63fb6657 100644
--- a/mysql/tables/llx_ecm_directories.sql
+++ b/mysql/tables/llx_ecm_directories.sql
@@ -27,8 +27,8 @@ create table llx_ecm_directories
fk_parent integer,
description varchar(255) NOT NULL,
cachenbofdoc integer NOT NULL DEFAULT 0,
- date_c timestamp,
- date_m datetime,
+ date_c datetime,
+ date_m timestamp,
fk_user_c integer,
fk_user_m integer
) type=innodb;