From 7b7b9dfef34f56b0a75c5ab920c2fdef49672714 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Sun, 24 Feb 2008 23:29:30 +0000
Subject: [PATCH] New: Next step for ECM module Fix: Some minor fixes.

---
 dev/skeletons/build_class_from_table.php      |   9 +-
 htdocs/commande/index.php                     |   4 +-
 htdocs/compta/index.php                       |   4 +-
 htdocs/conf/conf.class.php                    |   1 +
 htdocs/contrat/note.php                       |   6 +-
 htdocs/document.php                           |  27 +-
 htdocs/ecm/docdir.php                         | 307 +++++++++++++++++
 htdocs/ecm/docmine.php                        | 111 +++---
 htdocs/ecm/docother.php                       |   8 +-
 htdocs/ecm/ecmdirectory.class.php             | 318 ++++++++++++++++++
 htdocs/ecm/index.php                          | 142 +++++---
 htdocs/ecm/pre.inc.php                        |  34 +-
 htdocs/fourn/commande/index.php               |  29 +-
 htdocs/html.formfile.class.php                |   7 +-
 .../menus/barre_left/eldy_backoffice.php      |  76 +++--
 .../menus/barre_left/eldy_frontoffice.php     |  82 +++--
 .../menus/barre_top/eldy_backoffice.php       |   4 +-
 .../menus/barre_top/eldy_frontoffice.php      |   9 +-
 htdocs/includes/modules/modDocument.class.php |   2 +-
 htdocs/includes/modules/modECM.class.php      |  24 +-
 htdocs/langs/en_US/companies.lang             |   1 -
 htdocs/langs/en_US/orders.lang                |   3 +-
 htdocs/langs/en_US/other.lang                 |   1 +
 htdocs/langs/fr_BE/companies.lang             |   1 -
 htdocs/langs/fr_FR/companies.lang             |   1 -
 htdocs/langs/fr_FR/ecm.lang                   |  39 ++-
 htdocs/langs/fr_FR/orders.lang                |   3 +-
 htdocs/langs/fr_FR/other.lang                 |   1 +
 htdocs/lib/contract.lib.php                   |  24 +-
 htdocs/lib/functions.inc.php                  |  56 +--
 htdocs/product/document.php                   |  10 +-
 htdocs/theme/auguria/img/object_dir.png       | Bin 0 -> 301 bytes
 htdocs/theme/bluelagoon/img/object_dir.png    | Bin 0 -> 301 bytes
 htdocs/theme/dev/img/object_dir.png           | Bin 0 -> 301 bytes
 htdocs/theme/eldy/eldy.css.php                |   4 +-
 htdocs/theme/eldy/img/object_dir.png          | Bin 0 -> 301 bytes
 htdocs/theme/freelug/img/object_dir.png       | Bin 0 -> 301 bytes
 htdocs/theme/yellow/img/object_dir.png        | Bin 0 -> 301 bytes
 mysql/tables/llx_ecm_directories.sql          |  34 ++
 mysql/tables/llx_ecm_documents.sql            |  41 +++
 40 files changed, 1151 insertions(+), 272 deletions(-)
 create mode 100644 htdocs/ecm/docdir.php
 create mode 100644 htdocs/ecm/ecmdirectory.class.php
 create mode 100644 htdocs/theme/auguria/img/object_dir.png
 create mode 100644 htdocs/theme/bluelagoon/img/object_dir.png
 create mode 100644 htdocs/theme/dev/img/object_dir.png
 create mode 100644 htdocs/theme/eldy/img/object_dir.png
 create mode 100644 htdocs/theme/freelug/img/object_dir.png
 create mode 100644 htdocs/theme/yellow/img/object_dir.png
 create mode 100644 mysql/tables/llx_ecm_directories.sql
 create mode 100644 mysql/tables/llx_ecm_documents.sql

diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php
index 0c0fbb62567..21b30faa6b2 100644
--- a/dev/skeletons/build_class_from_table.php
+++ b/dev/skeletons/build_class_from_table.php
@@ -14,15 +14,13 @@
  * 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.
- *
- * $Id$
  */
 
 /**
         \file       dev/skeletons/build_class_from_table.php
         \ingroup    core
         \brief      Create a complete class file from a table in database
-        \version    $Revision$
+        \version    $Id$
 */
 
 // Test if batch mode
@@ -127,7 +125,9 @@ $skeletonfile='skeleton_class.class.php';
 $sourcecontent=file_get_contents($skeletonfile);
 if (! $sourcecontent)
 {
-	print "Error: Failed to read skeleton sample '".$sourcecontent."'\n";
+	print "\n";
+	print "Error: Failed to read skeleton sample '".$skeletonfile."'\n";
+	print "Try to run script from skeletons directory.\n";
 	exit;
 }
 
@@ -311,6 +311,7 @@ if ($fp)
 {
 	fputs($fp, $targetcontent);
 	fclose($fp);
+	print "\n";
 	print "File '".$outfile."' has been built in current directory.\n";
 	return 1;
 }
diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php
index a2fea6c4509..d203aaf3aab 100644
--- a/htdocs/commande/index.php
+++ b/htdocs/commande/index.php
@@ -15,15 +15,13 @@
  * 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.
- *
- * $Id$
  */
 
 /**
         \file       htdocs/commande/index.php
         \ingroup    commande
 		\brief      Page acceuil espace commandes
-		\version    $Revision$
+		\version    $Id$
 */
 
 require("./pre.inc.php");
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 492f1b3bebe..556427a9534 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -16,15 +16,13 @@
  * 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.
- *
- * $Id$
  */
 
 /**
       \file       htdocs/compta/index.php
       \ingroup    compta
       \brief      Page accueil zone comptabilit�
-      \version    $Revision$
+      \version    $Id$
 */
 
 require("./pre.inc.php");
diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php
index 1382d4e9b28..2802da1c1c3 100644
--- a/htdocs/conf/conf.class.php
+++ b/htdocs/conf/conf.class.php
@@ -257,6 +257,7 @@ class Conf
 		$this->categorie->enabled=defined("MAIN_MODULE_CATEGORIE")?MAIN_MODULE_CATEGORIE:0;
 		// Module contrat
 		$this->contrat->enabled=defined("MAIN_MODULE_CONTRAT")?MAIN_MODULE_CONTRAT:0;
+		$this->contrat->dir_output=DOL_DATA_ROOT."/contracts";
 		// Module projet
 		$this->projet->enabled=defined("MAIN_MODULE_PROJET")?MAIN_MODULE_PROJET:0;
 		// Module oscommerce 1
diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php
index aa623cc2f5a..c116b9ddbbe 100644
--- a/htdocs/contrat/note.php
+++ b/htdocs/contrat/note.php
@@ -15,15 +15,13 @@
  * 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.
- *
- * $Id$
  */
 
 /**
         \file       htdocs/contrat/note.php
         \ingroup    contrat
         \brief      Fiche de notes sur un contrat
-		\version    $Revision$
+		\version    $Id$
 */
 
 require("./pre.inc.php");
@@ -126,7 +124,7 @@ if ($_GET["id"])
 
     $hselected = 2;
 
-    dolibarr_fiche_head($head, $hselected, $langs->trans("Contract"));
+    dolibarr_fiche_head($head, 'note', $langs->trans("Contract"));
 
 
     print '<table class="border" width="100%">';
diff --git a/htdocs/document.php b/htdocs/document.php
index ebe369fe632..d3d2225ab32 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -281,17 +281,40 @@ if ($modulepart)
 		$sqlprotectagainstexternals = '';
     }
 
+    // Wrapping pour les produits et services
+    if ($modulepart == 'contract')
+    {
+        $user->getrights('contrat');
+        if ($user->rights->contrat->lire || eregi('^specimen',$original_file))	// Ce droit n'existe pas encore
+        {
+			$accessallowed=1;
+        }
+        $original_file=$conf->contrat->dir_output.'/'.$original_file;
+		$sqlprotectagainstexternals = '';
+    }
+
     // Wrapping pour les documents generaux
     if ($modulepart == 'ged')
     {
         $user->getrights('document');
-        if ($user->rights->document->lire )
+        if ($user->rights->document->lire)
         {
-	  $accessallowed=1;
+			$accessallowed=1;
         }
         $original_file= DOL_DATA_ROOT.'/ged/'.$original_file;
     }
 
+    // Wrapping pour les documents generaux
+    if ($modulepart == 'ecm')
+    {
+        $user->getrights('ecm');
+        if ($user->rights->ecm->lire)
+        {
+			$accessallowed=1;
+        }
+        $original_file= DOL_DATA_ROOT.'/ecm/'.$original_file;
+    }
+	
     // Wrapping pour les dons
     if ($modulepart == 'don')
     {
diff --git a/htdocs/ecm/docdir.php b/htdocs/ecm/docdir.php
new file mode 100644
index 00000000000..e649f514b21
--- /dev/null
+++ b/htdocs/ecm/docdir.php
@@ -0,0 +1,307 @@
+<?php
+/* Copyright (C) 2008 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * 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.
+ */
+
+/**
+    	\file       htdoc/ecm/index.php
+		\ingroup    ecm
+		\brief      Main page for ECM section area
+		\version    $Id$
+		\author		Laurent Destailleur
+*/
+
+require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
+require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php");
+
+// Load traductions files
+$langs->load("ecm");
+$langs->load("companies");
+$langs->load("other");
+$langs->load("users");
+$langs->load("orders");
+$langs->load("propal");
+$langs->load("bills");
+$langs->load("contracts");
+
+// Load permissions
+$user->getrights('ecm');
+
+// Get parameters
+$socid = isset($_GET["socid"])?$_GET["socid"]:'';
+
+$section=$_GET["section"];
+if (! $section) $section='misc';
+$upload_dir = $conf->ecm->dir_output.'/'.$section;
+
+$page=$_GET["page"];
+$sortorder=$_GET["sortorder"];
+$sortfield=$_GET["sortfield"];
+ 
+$limit = $conf->liste_limit;
+$offset = $limit * $page ;
+if (! $sortorder) $sortorder="DESC";
+if (! $sortfield) $sortfield="label";
+
+$ecmdir = new ECMDirectory($db);
+if (! empty($_GET["section"]))
+{
+	$result=$ecmdir->fetch($_GET["section"]);
+	if (! $result > 0)
+	{
+		dolibarr_print_error($db,$ecmdir->error);
+		exit;
+	}
+}
+
+
+/*******************************************************************
+* ACTIONS
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+// 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"];
+
+	$id = $ecmdir->create($user);
+
+	if ($id > 0)
+	{
+		Header("Location: ".$_SERVER["PHP_SELF"]);
+		exit;
+	}
+	else
+	{
+		$mesg='<div class="error">Error '.$langs->trans($ecmdir->error).'</div>';
+		$_GET["action"] = "create";
+	}
+}
+
+// Suppression fichier
+if ($_POST['action'] == 'confirm_deletesection' && $_POST['confirm'] == 'yes')
+{
+	$result=$ecmdir->delete($user);
+	$mesg = '<div class="ok">'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'</div>';
+}
+
+
+
+
+/*******************************************************************
+* PAGE
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+llxHeader();
+
+$form=new Form($db);
+$ecmdirstatic = new ECMDirectory($db);
+$userstatic = new User($db);
+	
+if ($_GET["action"] == 'create')
+{
+	//***********************
+	// Create
+	//***********************
+	print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+	print '<input type="hidden" name="action" value="add">';
+	
+	$title=$langs->trans("ECMNewSection");
+	print_fiche_titre($title);
+	if ($mesg) { print $mesg."<br>"; }
+	
+	print '<table class="border" width="100%">';
+
+	// Label
+	print '<tr><td>'.$langs->trans("Label").'</td><td><input name="label" size="40" value="'.$ecmdir->label.'"></td></tr>';
+
+	// Description
+	print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
+	print '<textarea name="desc" rows="4" cols="90">';
+	print $ecmdir->description;
+	print '</textarea>';
+	print "</td></tr>";
+	
+	print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
+
+	print '</table>';
+	print '</form>';
+}
+
+
+if (! $_GET["action"] || $_GET["action"] == 'delete_section')
+{
+	//***********************
+	// List
+	//***********************
+	print_fiche_titre($langs->trans("ECMSectionOfDocuments"));
+	
+	$ecmdir->ref=$ecmdir->label;
+	print $langs->trans("ECMSection").': ';
+	print img_picto('','object_dir').' ';
+	print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php">'.$langs->trans("ECMRoot").'</a>';
+	//print ' -> <b>'.$ecmdir->getNomUrl(1).'</b><br>';
+	print "<br><br>";
+
+	/*
+	* 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 '<br>';
+	}
+
+	// Construit liste des r�pertoires
+
+	if ($mesg) { print $mesg."<br>"; }
+
+	print '<table width="100%" class="noborder">';
+	print '<tr class="liste_titre">';
+	$param='&amp;socid='.$socid;
+	print_liste_field_titre($langs->trans("ECMSection"),$_SERVER["PHP_SELF"],"label","",$param,'align="left"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"","",$param,'align="left"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"description","",$param,'align="left"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("ECMCreationUser"),$_SERVER["PHP_SELF"],"fk_user_c","",$param,'align="left"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("ECMCreationDate"),$_SERVER["PHP_SELF"],"date_c","",$param,'align="center"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("ECMNbOfDocs"),$_SERVER["PHP_SELF"],"cachenbofdoc","",$param,'align="right"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
+	print '</tr>';
+
+
+	$sql ="SELECT ed.rowid, ed.label, ed.description, ed.cachenbofdoc, ed.fk_user_c, ed.fk_user_m,";
+	$sql.=" ed.date_c,";
+	$sql.=" ed.date_m,";
+	$sql.=" ed.fk_parent,";
+	$sql.=" u.login";
+	$sql.=" FROM ".MAIN_DB_PREFIX."ecm_directories as ed";
+	$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = ed.fk_user_c";
+	$sql.=" ORDER BY label";
+	$resql=$db->query($sql);
+	if ($resql)
+	{	
+		$var=true;
+		$obj = $db->fetch_object($resql);
+		while ($obj)
+		{
+			$var=!$var;
+			
+			$ecmdirstatic->id=$obj->rowid;
+			$ecmdirstatic->ref=$obj->label;
+			
+			print '<tr '.$bc[$var].'>';
+			
+			// Section
+			print '<td align="left">';
+			print $ecmdirstatic->getNomUrl(1);
+			print "</td>\n";
+			
+			// Type
+			print '<td align="left">';
+			print $langs->trans("ECMTypeManual");
+			print "</td>\n";
+			
+			// Description
+			print '<td align="left">'.dolibarr_trunc($obj->description,32).'</td>';
+			$userstatic->id=$obj->fk_user_c;
+			$userstatic->nom=$obj->login;
+			print '<td align="left">'.$userstatic->getNomUrl(1).'</td>';
+			print '<td align="center">'.dolibarr_print_date($obj->date_c,"dayhour").'</td>';
+			
+			// Nb of docs
+			//print '<td align="right">'.$obj->cachenbofdoc.'</td>';
+			print '<td align="right">?</td>';
+			
+			print '<td align="right">';
+			echo '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&section='.urlencode($obj->rowid).'">'.img_delete().'</a>';
+			print "</td></tr>\n";
+			$obj = $db->fetch_object($resql);
+		}
+	}
+	else
+	{
+		dolibarr_print_error($db);
+	}
+	
+	// Ajout rubriques automatiques
+	$sectionauto=array( 0 => array('test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")),
+						1 => array('test'=>$conf->propal->enabled,  'label'=>$langs->trans("Proposals"),    'desc'=>$langs->trans("ECMDocsByProposals")),
+						2 => array('test'=>$conf->commande->enabled,'label'=>$langs->trans("Orders"),       'desc'=>$langs->trans("ECMDocsByOrders")),
+						3 => array('test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"),    'desc'=>$langs->trans("ECMDocsByContracts")),
+						4 => array('test'=>$conf->facture->enabled, 'label'=>$langs->trans("Invoices"),     'desc'=>$langs->trans("ECMDocsByInvoices"))
+						);
+	foreach ($sectionauto as $key => $val)
+	{
+		if ($val['test'])
+		{
+			$var=! $var;
+			
+			print '<tr '.$bc[$var].'>';
+			
+			// Section
+			print '<td align="left">';
+			print img_picto('','object_dir').' ';
+			print '<a href="'.DOL_URL_ROOT.'/ecm/docother.php">';
+			print $val['label'];
+			print '</a>';
+			print "</td>\n";
+			
+			// Type
+			print '<td align="left">';
+			print $langs->trans("ECMTypeAuto");
+			print "</td>\n";
+			
+			// Description
+			print '<td align="left">'.$val['desc'].'</td>';
+			print '<td align="left">&nbsp;</td>';
+			print '<td align="center">&nbsp;</td>';
+			print '<td align="right">&nbsp;</td>';
+		
+			print '<td align="right">&nbsp;';
+			print "</td></tr>\n";
+		}
+	}
+	
+	print "</table>";
+	// Fin de zone Ajax
+
+
+	// Actions buttons
+	print '<div class="tabsAction">';
+	if ($user->rights->ecm->setup)
+	{
+		print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=create">'.$langs->trans('ECMAddSection').'</a>';
+	}
+	else
+	{
+		print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>';
+	}
+	print '</div>';
+}
+
+
+// End of page
+$db->close();
+
+llxFooter('$Date$ - $Revision$');
+?>
diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php
index 43961dbd3fe..a454af32b8b 100644
--- a/htdocs/ecm/docmine.php
+++ b/htdocs/ecm/docmine.php
@@ -1,17 +1,33 @@
 <?php
 /* Copyright (C) 2008 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * 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.
  */
 
 /**
-    	\file       htdoc/google/index.php
-		\ingroup    google
-		\brief      Main google area page
+    	\file       htdoc/ecm/docmine.php
+		\ingroup    ecm
+		\brief      Main page for a section
 		\version    $Id$
 		\author		Laurent Destailleur
 */
 
 require("./pre.inc.php");
 require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
+require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php");
+
 
 // Load traductions files
 $langs->load("ecm");
@@ -31,10 +47,24 @@ if ($user->societe_id > 0)
     $socid = $user->societe_id;
 }
 
-$section=$_GET["section"];
-if (! $section) $section='misc';
-$upload_dir = $conf->ecm->dir_output.'/'.$section;
+$section=$_REQUEST["section"];
+if (! $section)
+{
+	dolibarr_print_error('',"ErrorSectionParamNotDefined");
+	exit;
+}
 
+$ecmdir = new ECMDirectory($db);
+if (! empty($_REQUEST["section"]))
+{
+	$result=$ecmdir->fetch($_REQUEST["section"]);
+	if (! $result > 0)
+	{
+		dolibarr_print_error($db,$ecmdir->error);
+		exit;
+	}
+}
+$upload_dir = $conf->ecm->dir_output.'/'.$ecmdir->label;
 
 
 /*******************************************************************
@@ -92,12 +122,17 @@ llxHeader();
 
 $form=new Form($db);
 
-print_fiche_titre($langs->trans("DocsMine"));
-print "<br>";
+print_fiche_titre($langs->trans("ECMManualOrg"));
 
-//$head = societe_prepare_head($societe);
+$ecmdir->ref=$ecmdir->label;
+print $langs->trans("ECMSection").': ';
+print img_picto('','object_dir').' ';
+print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php">'.$langs->trans("ECMRoot").'</a>';
+print ' -> <b>'.$ecmdir->getNomUrl(1).'</b>';
+print "<br><br>";
 
 
+//$head = societe_prepare_head($societe);
 //dolibarr_fiche_head($head, 'document', $societe->nom);
 
 
@@ -106,7 +141,7 @@ print "<br>";
 */
 if ($_GET['action'] == 'delete_file')
 {
-	$form->form_confirm($_SERVER["PHP_SELF"].'?socid='.$socid.'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
+	$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
 	print '<br>';
 }
 
@@ -161,7 +196,7 @@ if ($mesg) { print $mesg."<br>"; }
 
 // Affiche formulaire upload
 $formfile=new FormFile($db);
-$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/docmine.php');
+$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/docmine.php','',0,$section);
 
 // Affiche liste des documents existant
 print_titre($langs->trans("AttachedFiles"));
@@ -221,7 +256,7 @@ foreach($filearray as $key => $file)
 		print '<td align="right">'.$file->size.' '.$langs->trans("bytes").'</td>';
 		print '<td align="center">'.dolibarr_print_date($file->date,"dayhour").'</td>';
 		print '<td align="center">';
-		echo '<a href="'.$url.'?socid='.$socid.'&amp;action=delete_file&urlfile='.urlencode($file->name).'">'.img_delete().'</a>';
+		echo '<a href="'.$url.'?section='.$_REQUEST["section"].'&amp;action=delete_file&urlfile='.urlencode($file->name).'">'.img_delete().'</a>';
 		print "</td></tr>\n";
 	}
 }
@@ -229,58 +264,6 @@ print "</table>";
 // Fin de zone Ajax
 
 
-print "<br><br>";
-
-// Courriers
-// Les courriers sont des documents speciaux generes par des scripts
-// situes dans scripts/courrier.
-// Voir Rodo
-if ($conf->global->MAIN_MODULE_EDITEUR)
-{
-	$filearray=array();	
-	$errorlevel=error_reporting();
-	error_reporting(0);
-	$handle=opendir($courrier_dir);
-	error_reporting($errorlevel);
-	if ($handle)
-	{
-		$i=0;
-		while (($file = readdir($handle))!==false)
-		{
-			if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
-			{
-				$filearray[$i]=$file;
-				$i++;
-			}
-		}
-		closedir($handle);
-	}       	       
-
-	print '<table width="100%" class="noborder">';
-	print '<tr class="liste_titre"><td>'.$langs->trans("Courriers").'</td><td align="right">'.$langs->trans("Size").'</td><td align="center">'.$langs->trans("Date").'</td></tr>';
-
-	$var=true;
-	foreach($filearray as $key => $file)
-	{
-		if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
-		{
-			$var=!$var;
-			print "<tr $bc[$var]><td>";
-			$loc = "courrier/".get_exdir($socid);
-			echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=societe&type=application/binary&file='.urlencode($loc.'/'.$file).'">'.$file.'</a>';
-			print "</td>\n";
-
-			print '<td align="right">'.filesize($courrier_dir."/".$file). ' '.$langs->trans("bytes").'</td>';
-			print '<td align="center">'.dolibarr_print_date(filemtime($courrier_dir."/".$file),"dayhour").'</td>';
-			print "</tr>\n";
-		}
-	}
-	print "</table>";
-}
-
-
-
-
 // End of page
 $db->close();
 
diff --git a/htdocs/ecm/docother.php b/htdocs/ecm/docother.php
index 2586d8d09b8..8e3ddb466fc 100644
--- a/htdocs/ecm/docother.php
+++ b/htdocs/ecm/docother.php
@@ -3,9 +3,9 @@
  */
 
 /**
-    	\file       htdoc/google/index.php
-		\ingroup    google
-		\brief      Main google area page
+    	\file       htdoc/ecm/docother.php
+		\ingroup    ecm
+		\brief      Main ecm page
 		\version    $Id$
 		\author		Laurent Destailleur
 */
@@ -92,7 +92,7 @@ llxHeader();
 
 $form=new Form($db);
 
-print_fiche_titre($langs->trans("Documents"));
+print_fiche_titre($langs->trans("ECMAutoOrg"));
 
 //$head = societe_prepare_head($societe);
 
diff --git a/htdocs/ecm/ecmdirectory.class.php b/htdocs/ecm/ecmdirectory.class.php
new file mode 100644
index 00000000000..3c852822577
--- /dev/null
+++ b/htdocs/ecm/ecmdirectory.class.php
@@ -0,0 +1,318 @@
+<?php
+/* Copyright (C) 2007-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * 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.
+ */
+
+/**
+        \file       dev/skeletons/ecm_directories.class.php
+        \ingroup    mymodule othermodule1 othermodule2
+        \brief      This file is an example for a class file
+		\version    $Id$
+		\author		Put author name here
+		\remarks	Initialy built by build_class_from_table on 2008-02-24 19:24
+*/
+
+// Put here all includes required by your class file
+//require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
+//require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
+//require_once(DOL_DOCUMENT_ROOT."/product.class.php");
+
+
+/**
+        \class      EcmDirectory
+        \brief      Class to manage ECM directories
+		\remarks	Initialy built by build_class_from_table on 2008-02-24 19:24
+*/
+class EcmDirectory // extends CommonObject
+{
+	var $db;							//!< To store db handler
+	var $error;							//!< To return error code (or message)
+	var $errors=array();				//!< To return several error codes (or messages)
+	//var $element='ecm_directories';			//!< Id that identify managed objects
+	//var $table_element='ecm_directories';	//!< Name of table without prefix where object is stored
+    
+    var $id;
+    
+	var $label;
+	var $fk_parent;
+	var $description;
+	var $tms;
+
+    
+
+	
+    /**
+     *      \brief      Constructor
+     *      \param      DB      Database handler
+     */
+    function EcmDirectory($DB) 
+    {
+        $this->db = $DB;
+        return 1;
+    }
+
+	
+    /**
+     *      \brief      Create in database
+     *      \param      user        User that create
+     *      \return     int         <0 si ko, >0 si ok
+     */
+    function create($user)
+    {
+    	global $conf, $langs;
+    	
+		$now=time();
+		
+		// Clean parameters
+        $this->label=sanitize_string($this->label);
+		$this->fk_parent=trim($this->fk_parent);
+		$this->description=trim($this->description);
+		if (! $this->cachenbofdoc) $this->cachenbofdoc=0;
+		$this->date_c=$now;
+		$this->fk_user_c=$user->id;
+        
+
+		// Check parameters
+		// Put here code to add control on parameters values
+		
+        // Insert request
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."ecm_directories(";
+		$sql.= "label,";
+		$sql.= "fk_parent,";
+		$sql.= "description,";
+		$sql.= "cachenbofdoc,";
+		$sql.= "date_c,";
+		$sql.= "fk_user_c";
+        $sql.= ") VALUES (";
+		$sql.= " '".$this->label."',";
+		$sql.= " '".$this->fk_parent."',";
+		$sql.= " '".$this->description."',";
+		$sql.= " ".($this->cachenbofdoc).",";
+		$sql.= " ".$this->db->idate($this->date_c).",";
+		$sql.= " '".$this->fk_user_c."'";
+		$sql.= ")";
+
+	   	dolibarr_syslog("Ecm_directories::create sql=".$sql, LOG_DEBUG);
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories");
+    
+			$result=create_exdir($conf->ecm->dir_output.'/'.$this->label);
+			
+            // Appel des triggers
+            include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+            $interface=new Interfaces($this->db);
+            $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
+            if ($result < 0) { $error++; $this->errors=$interface->errors; }
+            // Fin appel triggers
+
+            return $this->id;
+        }
+        else
+        {
+            $this->error="Error ".$this->db->lasterror();
+            dolibarr_syslog("Ecm_directories::create ".$this->error, LOG_ERR);
+            return -1;
+        }
+    }
+
+    /*
+     *      \brief      Update database
+     *      \param      user        	User that modify
+     *      \param      notrigger	    0=no, 1=yes (no update trigger)
+     *      \return     int         	<0 if KO, >0 if OK
+     */
+    function update($user=0, $notrigger=0)
+    {
+    	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
+
+        // Update request
+        $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
+        
+		$sql.= " label='".addslashes($this->label)."',";
+		$sql.= " fk_parent='".$this->fk_parent."',";
+		$sql.= " description='".addslashes($this->description)."',";
+		$sql.= " tms=".$this->db->idate($this->tms)."";
+
+        
+        $sql.= " WHERE rowid=".$this->id;
+
+        dolibarr_syslog("Ecm_directories::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);
+            return -1;
+        }
+
+		if (! $notrigger)
+		{
+            // Appel des triggers
+            include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+            $interface=new Interfaces($this->db);
+            $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
+            if ($result < 0) { $error++; $this->errors=$interface->errors; }
+            // Fin appel triggers
+    	}
+
+        return 1;
+    }
+  
+  
+    /*
+     *    \brief      Load object in memory from database
+     *    \param      id          id object
+     *    \param      user        User that load
+     *    \return     int         <0 if KO, >0 if OK
+     */
+    function fetch($id, $user=0)
+    {
+    	global $langs;
+        $sql = "SELECT";
+		$sql.= " t.rowid,";
+		$sql.= " t.label,";
+		$sql.= " t.fk_parent,";
+		$sql.= " t.description,";
+		$sql.= " t.cachenbofdoc,";
+		$sql.= " t.fk_user_c,";
+		$sql.= " t.fk_user_m,";
+		$sql.= " ".$this->db->pdate('t.date_c').",";
+		$sql.= " ".$this->db->pdate('t.date_m')."";
+        $sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
+        $sql.= " WHERE t.rowid = ".$id;
+    
+    	dolibarr_syslog("Ecm_directories::fetch sql=".$sql, LOG_DEBUG);
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            if ($this->db->num_rows($resql))
+            {
+                $obj = $this->db->fetch_object($resql);
+    
+                $this->id    = $obj->rowid;
+                $this->ref   = $obj->rowid;
+                
+				$this->label = $obj->label;
+				$this->fk_parent = $obj->fk_parent;
+				$this->description = $obj->description;
+				$this->cachenbofdoc = $obj->cachenbofdoc;
+				$this->fk_user_m = $obj->fk_user_m;
+				$this->fk_user_c = $obj->fk_user_c;
+				$this->date_c = $obj->date_c;
+				$this->date_m = $obj->date_m;
+            }
+            $this->db->free($resql);
+            
+            return 1;
+        }
+        else
+        {
+      	    $this->error="Error ".$this->db->lasterror();
+            dolibarr_syslog("Ecm_directories::fetch ".$this->error, LOG_ERR);
+            return -1;
+        }
+    }
+    
+    
+ 	/*
+	*   \brief      Delete object in database
+    *	\param      user        User that delete
+	*	\return		int			<0 if KO, >0 if OK
+	*/
+	function delete($user)
+	{
+		global $conf, $langs;
+	
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
+		$sql.= " WHERE rowid=".$this->id;
+	
+	   	dolibarr_syslog("Ecm_directories::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);
+			return -1;
+		}
+	
+		$file = $conf->ecm->dir_output . "/" . $this->label;
+		$result=dol_delete_dir($file);
+		
+        // Appel des triggers
+        include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
+        $interface=new Interfaces($this->db);
+        $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+        if ($result < 0) { $error++; $this->errors=$interface->errors; }
+        // Fin appel triggers
+
+		return 1;
+	}
+
+  
+	/**
+	 *		\brief		Initialise object with example values
+	 *		\remarks	id must be 0 if object instance is a specimen.
+	 */
+	function initAsSpecimen()
+	{
+		$this->id=0;
+		
+		$this->label='MyDirectory';
+		$this->fk_parent='0';
+		$this->description='This is a directory';
+	}
+
+	
+  /**
+     \brief      Renvoie nom clicable (avec eventuellement le picto)
+     \param		withpicto		0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
+     \param		option			Sur quoi pointe le lien
+     \return		string			Chaine avec URL
+   */
+  function getNomUrl($withpicto=0,$option='')
+  {
+    global $langs;
+		
+    $result='';
+		
+    $lien = '<a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$this->id.'">';
+    $lienfin='</a>';
+		
+    $picto='dir';
+
+    $label=$langs->trans("ShowECMSection").': '.$this->ref;
+		
+    if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
+    if ($withpicto && $withpicto != 2) $result.=' ';
+    if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
+    return $result;
+  }
+
+}
+?>
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index 7d88e2bc39c..b4d31f67114 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -3,20 +3,26 @@
  */
 
 /**
-    	\file       htdoc/google/index.php
-		\ingroup    google
-		\brief      Main google area page
+    	\file       htdoc/ecm/index.php
+		\ingroup    ecm
+		\brief      Main page for ECM section area
 		\version    $Id$
 		\author		Laurent Destailleur
 */
 
 require("./pre.inc.php");
 require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
+require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php");
 
 // Load traductions files
 $langs->load("ecm");
 $langs->load("companies");
 $langs->load("other");
+$langs->load("users");
+$langs->load("orders");
+$langs->load("propal");
+$langs->load("bills");
+$langs->load("contracts");
 
 // Load permissions
 $user->getrights('ecm');
@@ -24,17 +30,29 @@ $user->getrights('ecm');
 // Get parameters
 $socid = isset($_GET["socid"])?$_GET["socid"]:'';
 
-// Permissions
-if ($user->societe_id > 0)
-{
-    $action = '';
-    $socid = $user->societe_id;
-}
-
 $section=$_GET["section"];
 if (! $section) $section='misc';
 $upload_dir = $conf->ecm->dir_output.'/'.$section;
 
+$page=$_GET["page"];
+$sortorder=$_GET["sortorder"];
+$sortfield=$_GET["sortfield"];
+ 
+$limit = $conf->liste_limit;
+$offset = $limit * $page ;
+if (! $sortorder) $sortorder="DESC";
+if (! $sortfield) $sortfield="label";
+
+$ecmdir = new ECMDirectory($db);
+if (! empty($_GET["section"]))
+{
+	$result=$ecmdir->fetch($_GET["section"]);
+	if (! $result > 0)
+	{
+		dolibarr_print_error($db,$ecmdir->error);
+		exit;
+	}
+}
 
 
 /*******************************************************************
@@ -43,45 +61,37 @@ $upload_dir = $conf->ecm->dir_output.'/'.$section;
 * Put here all code to do according to value of "action" parameter
 ********************************************************************/
 
-// Envoie fichier
-if ( $_POST["sendit"] && $conf->upload != 0)
+// Action ajout d'un produit ou service
+if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
 {
-  if (! is_dir($upload_dir)) create_exdir($upload_dir);
-  
-  if (is_dir($upload_dir))
-  {
-  	$result = doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']);
-  	if ($result == 1)
-    {
-    	$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
-    	//print_r($_FILES);
-    }
-    else if (!$result)
-    {
-    	// Echec transfert (fichier d?passant la limite ?)
-    	$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
-    	// print_r($_FILES);
-    }
-    else
-    {
-    	// Fichier infect? par un virus
-    	$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWith",$result).'</div>';
-    }
-  }
+	$ecmdir->ref                = $_POST["ref"];
+	$ecmdir->label              = $_POST["label"];
+	$ecmdir->description        = $_POST["desc"];
+
+	$id = $ecmdir->create($user);
+
+	if ($id > 0)
+	{
+		Header("Location: ".$_SERVER["PHP_SELF"]);
+		exit;
+	}
+	else
+	{
+		$mesg='<div class="error">Error '.$langs->trans($ecmdir->error).'</div>';
+		$_GET["action"] = "create";
+	}
 }
 
 // Suppression fichier
-if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
+if ($_POST['action'] == 'confirm_deletesection' && $_POST['confirm'] == 'yes')
 {
-  $file = $upload_dir . "/" . urldecode($_GET["urlfile"]);
-  dol_delete_file($file);
-  $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
+	$result=$ecmdir->delete($user);
+	$mesg = '<div class="ok">'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'</div>';
 }
 
 
 
 
-
 /*******************************************************************
 * PAGE
 *
@@ -91,10 +101,58 @@ if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
 llxHeader();
 
 $form=new Form($db);
+$ecmdirstatic = new ECMDirectory($db);
+$userstatic = new User($db);
 
-print_fiche_titre($langs->trans("ECMArea"));
-
-
+if (! $_GET["action"] || $_GET["action"] == 'delete_section')
+{
+	//***********************
+	// List
+	//***********************
+	print_fiche_titre($langs->trans("ECMArea"));
+
+	print $langs->trans("ECMAreaDesc")."<br>";
+	print $langs->trans("ECMAreaDesc2")."<br>";
+	print "<br>\n";
+
+	print '<table class="notopnoleftnoright" width="100%"><tr><td width="50%" valign="top">';
+
+	//print_fiche_titre($langs->trans("ECMManualOrg"));
+
+	print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/todo.php">';
+	print '<table class="noborder" width="100%">';
+	print "<tr class=\"liste_titre\">";
+	print '<td colspan="3">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
+	print "<tr $bc[0]><td>".$langs->trans("Title").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>';
+	print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
+	print "<tr $bc[0]><td>".$langs->trans("Keyword").':</td><td><input type="text" name="sall" class="flat" size="18"></td>';
+	print '</tr>';
+	print "</table></form><br>";
+	//print $langs->trans("ECMManualOrgDesc");
+		
+	print '</td><td width="50%" valign="top">';
+
+	//print_fiche_titre($langs->trans("ECMAutoOrg"));
+
+	print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/todo.php">';
+	print '<table class="noborder" width="100%">';
+	print "<tr class=\"liste_titre\">";
+	print '<td colspan="3">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
+
+	$buthtml='<td rowspan="5"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
+	$butshown=0;
+
+	if ($conf->societe->enabled)  { print "<tr $bc[0]><td>".$langs->trans("ThirdParty").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
+	if ($conf->contrat->enabled)  { print "<tr $bc[0]><td>".$langs->trans("Contrat").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
+	if ($conf->propal->enabled)   { print "<tr $bc[0]><td>".$langs->trans("Proposal").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
+	if ($conf->commande->enabled) { print "<tr $bc[0]><td>".$langs->trans("Order").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
+	if ($conf->facture->enabled)  { print "<tr $bc[0]><td>".$langs->trans("Invoice").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'.($butshown?'':$buthtml).'</tr>'; $butshown=1; }
+	print "</table></form><br>";
+	//print $langs->trans("ECMAutoOrgDesc");
+		
+	print '</td></tr>';
+	print '</table>';
+}
 
 
 // End of page
diff --git a/htdocs/ecm/pre.inc.php b/htdocs/ecm/pre.inc.php
index a3cf834e3ca..210d7097c6a 100644
--- a/htdocs/ecm/pre.inc.php
+++ b/htdocs/ecm/pre.inc.php
@@ -1,5 +1,19 @@
 <?php
 /* Copyright (C) 2008 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * 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.
  */
 
 /**
@@ -15,7 +29,7 @@ $user->getrights('ecm');
 
 function llxHeader($head = "", $title="", $help_url='')
 {
-	global $conf,$langs;
+	global $conf,$langs,$user;
 	$langs->load("ecm");
 	$langs->load("bills");
 	$langs->load("propal");
@@ -24,12 +38,18 @@ 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"));
-	$menu->add_submenu(DOL_URL_ROOT."/ecm/docmine.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsMine"));
-	$menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsThirdParties"));
-	$menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsInvoices"));
-	$menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsProposals"));
-	
+	$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?mainmenu=ecm&action=create&idmenu=".$_SESSION["idmenu"], $langs->trans("ECMNewDocument"),1,$user->rights->ecm->create);
+
+	$menu->add_submenu(DOL_URL_ROOT."/ecm/docdir?mainmenu=ecm&action=create&idmenu=".$_SESSION["idmenu"], $langs->trans("ECMNewSection"),1,$user->rights->ecm->setup);
+/*
+	if ($conf->societe->enabled) $menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsThirdParties"),2);
+	if ($conf->contrat->enabled) $menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsContracts"),2);
+	if ($conf->propal->enabled) $menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsProposals"),2);
+	if ($conf->commande->enabled) $menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsOrders"),2);
+	if ($conf->facture->enabled) $menu->add_submenu(DOL_URL_ROOT."/ecm/docother.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("DocsInvoices"),2);
+*/	
 	left_menu($menu->liste, $help_url);
 }
 ?>
diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php
index 0c4582d4933..ded28636c61 100644
--- a/htdocs/fourn/commande/index.php
+++ b/htdocs/fourn/commande/index.php
@@ -15,10 +15,6 @@
  * 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.
- *
- * $Id$
- * $Source$
- *
  */
 
 /**
@@ -31,7 +27,12 @@
 require("./pre.inc.php");
 require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
 
-llxHeader('',"Commandes Fournisseurs");
+
+/*
+* 	View
+*/
+
+llxHeader('',$langs->trans("SuppliersOrdersArea"));
 
 // S�curit� acc�s client
 if ($user->societe_id > 0) 
@@ -42,10 +43,10 @@ if ($user->societe_id > 0)
 
 $commande = new CommandeFournisseur($db);
 
-print_barre_liste($langs->trans("SuppliersOrders"), $page, "index.php", "", $sortfield, $sortorder, '', $num);
+print_barre_liste($langs->trans("SuppliersOrdersArea"), $page, "index.php", "", $sortfield, $sortorder, '', $num);
 
-print '<table class="noborder" width="100%">';
-print '<tr valign="top"><td width="30%">';
+print '<table class="notopnoleftnoright" width="100%">';
+print '<tr valign="top"><td class="notopnoleft" width="30%">';
 
 $sql = "SELECT count(cf.rowid), fk_statut";
 $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,";
@@ -84,13 +85,11 @@ else
 {
   dolibarr_print_error($db);
 }
-/*
- *
- */
-print '</td><td width="70%" valign="top">';
-/*
- *
- */
+
+
+print '</td><td width="70%" valign="top" class="notopnoleft">';
+
+
 $sql = "SELECT u.name, u.firstname";
 $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
 $sql .= " , ".MAIN_DB_PREFIX."user_rights as ur";
diff --git a/htdocs/html.formfile.class.php b/htdocs/html.formfile.class.php
index 35aeb214e9f..09b2abb7152 100644
--- a/htdocs/html.formfile.class.php
+++ b/htdocs/html.formfile.class.php
@@ -14,13 +14,12 @@
  * 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.
- *
- * $Id$
  */
 
 /**
         \file       htdocs/html.formfile.class.php
         \brief      Fichier de la classe des fonctions pr�d�finie de composants html fichiers
+		\version	$Id$
 */
 
 
@@ -51,9 +50,10 @@ class FormFile
 	*    	\param      url				Url
 	*    	\param      titre			Titre zone
 	*    	\param      addcancel		1=Ajoute un bouton 'Annuler'
+	*		\param		sectionid		If upload must be done inside a particular ECM section
 	*		\return		int				<0 si ko, >0 si ok
 	*/
-	function form_attach_new_file($url,$titre='',$addcancel=0)
+	function form_attach_new_file($url,$titre='',$addcancel=0, $sectionid=0)
 	{
 		global $conf,$langs;
 		
@@ -65,6 +65,7 @@ class FormFile
 			print_titre($titre);
 
 			print '<form name="userfile" action="'.$url.'" enctype="multipart/form-data" method="POST">';
+			print '<input type="hidden" name="section" value="'.$sectionid.'">';
 			
 			print '<table width="100%" class="noborder">';
 			print '<tr><td width="50%" valign="top">';
diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php
index 78061dabaf0..73e94ceef95 100644
--- a/htdocs/includes/menus/barre_left/eldy_backoffice.php
+++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php
@@ -193,14 +193,16 @@ class MenuLeft {
 
 				if ($conf->societe->enabled && $conf->fournisseur->enabled)
 				{
-					$newmenu->add(DOL_URL_ROOT."/fourn/liste.php?leftmenu=suppliers", $langs->trans("Suppliers"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire);
+					$newmenu->add(DOL_URL_ROOT."/fourn/index.php?leftmenu=suppliers", $langs->trans("Suppliers"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire);
 
 					// S�curit� acc�s client
 					if ($user->societe_id == 0)
 					{
 						$newmenu->add_submenu(DOL_URL_ROOT."/soc.php?leftmenu=suppliers&amp;action=create&amp;type=f",$langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && $user->rights->fournisseur->lire);
 					}
+					$newmenu->add_submenu(DOL_URL_ROOT."/fourn/liste.php?leftmenu=suppliers", $langs->trans("List"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire);
 					$newmenu->add_submenu(DOL_URL_ROOT."/contact/index.php?leftmenu=suppliers&amp;type=f",$langs->trans("Contacts"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire && $user->rights->societe->contact->lire);
+			    	$newmenu->add_submenu(DOL_URL_ROOT."/fourn/stats.php",$langs->trans("Statistics"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire);
 				}
 
 				// Prospects
@@ -259,6 +261,16 @@ class MenuLeft {
 			{
 				$langs->load("companies");
 
+				// Actions
+				if ($conf->agenda->enabled)
+				{
+					$newmenu->add(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions", $langs->trans("Agenda"), 0, $user->rights->agenda->myactions->read);
+					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/societe.php?leftmenu=actions", $langs->trans("NewAction"), 1, $user->rights->agenda->myactions->read);
+					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions&amp;status=todo", $langs->trans("MenuToDoActions"), 1, $user->rights->agenda->myactions->read);
+					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions&amp;time=today", $langs->trans("Today"), 1, $user->rights->agenda->myactions->read);
+					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/rapport/index.php?leftmenu=actions", $langs->trans("Reportings"), 1, $user->rights->agenda->myactions->read);
+				}
+
 				// Prospects
 				$newmenu->add(DOL_URL_ROOT."/comm/prospect/index.php?leftmenu=prospects", $langs->trans("Prospects"), 0, $user->rights->societe->lire);
 
@@ -284,16 +296,6 @@ class MenuLeft {
 				$newmenu->add(DOL_URL_ROOT."/contact/index.php?leftmenu=contacts", $langs->trans("Contacts"), 0, $user->rights->societe->contact->lire);
 				$newmenu->add_submenu(DOL_URL_ROOT."/contact/fiche.php?leftmenu=contacts&amp;action=create", $langs->trans("NewContact"), 1, $user->rights->societe->contact->creer);
 				$newmenu->add_submenu(DOL_URL_ROOT."/contact/index.php?leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->contact->lire);
-
-				// Actions
-				if ($conf->agenda->enabled)
-				{
-					$newmenu->add(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions", $langs->trans("Agenda"), 0, $user->rights->agenda->myactions->read);
-					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/societe.php?leftmenu=actions", $langs->trans("NewAction"), 1, $user->rights->agenda->myactions->read);
-					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions&amp;status=todo", $langs->trans("MenuToDoActions"), 1, $user->rights->agenda->myactions->read);
-					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions&amp;time=today", $langs->trans("Today"), 1, $user->rights->agenda->myactions->read);
-					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/rapport/index.php?leftmenu=actions", $langs->trans("Reportings"), 1, $user->rights->agenda->myactions->read);
-				}
 				
 				// Propal
 				if ($conf->propal->enabled)
@@ -310,11 +312,11 @@ class MenuLeft {
 					if ($leftmenu=="propals") $newmenu->add_submenu(DOL_URL_ROOT."/comm/propal/stats/index.php?leftmenu=propals", $langs->trans("Statistics"), 1, $user->rights->propale->lire);
 				}
 
-				// Commandes
-				if ($conf->commande->enabled )
+				// Customers orders
+				if ($conf->commande->enabled)
 				{
 					$langs->load("orders");
-					$newmenu->add(DOL_URL_ROOT."/commande/index.php?leftmenu=orders", $langs->trans("Orders"), 0 ,$user->rights->commande->lire);
+					$newmenu->add(DOL_URL_ROOT."/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0 ,$user->rights->commande->lire);
 					if ($leftmenu=="orders") $newmenu->add_submenu(DOL_URL_ROOT."/societe.php?leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer);
 					if ($leftmenu=="orders") $newmenu->add_submenu(DOL_URL_ROOT."/commande/liste.php?leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->creer);
 					if ($leftmenu=="orders") $newmenu->add_submenu(DOL_URL_ROOT."/commande/liste.php?leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire);
@@ -326,11 +328,13 @@ class MenuLeft {
 					if ($leftmenu=="orders") $newmenu->add_submenu(DOL_URL_ROOT."/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1 ,$user->rights->commande->lire);
 				}
 
-				// Expeditions
-				if ($conf->expedition->enabled) {
-					$newmenu->add(DOL_URL_ROOT."/expedition/index.php?leftmenu=sendings", $langs->trans("Sendings"), 0, $user->rights->expedition->lire);
-					if ($leftmenu=="sendings") $newmenu->add_submenu(DOL_URL_ROOT."/expedition/liste.php?leftmenu=sendings", $langs->trans("List"), 1 ,$user->rights->expedition->lire);
-					if ($leftmenu=="sendings") $newmenu->add_submenu(DOL_URL_ROOT."/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1 ,$user->rights->expedition->lire);
+				// Suppliers orders
+				if ($conf->fournisseur->enabled)
+				{
+					$langs->load("orders");
+					$newmenu->add(DOL_URL_ROOT."/fourn/commande/index.php?leftmenu=orders_suppliers",$langs->trans("SuppliersOrders"), 0, $user->rights->fournisseur->commande->lire);
+					if ($leftmenu=="orders_suppliers") $newmenu->add_submenu(DOL_URL_ROOT."/societe.php?leftmenu=orders_suppliers", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer);
+					if ($leftmenu=="orders_suppliers") $newmenu->add_submenu(DOL_URL_ROOT."/fourn/commande/liste.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire);
 				}
 
 				// Contrat
@@ -575,6 +579,7 @@ class MenuLeft {
 			*/
 			if ($mainmenu == 'products')
 			{
+				// Products
 				if ($conf->produit->enabled)
 				{
 					$newmenu->add(DOL_URL_ROOT."/product/index.php?leftmenu=product&amp;type=0", $langs->trans("Products"), 0, $user->rights->produit->lire);
@@ -589,6 +594,7 @@ class MenuLeft {
 					}
 				}
 
+				// Services
 				if ($conf->service->enabled)
 				{
 					$newmenu->add(DOL_URL_ROOT."/product/index.php?leftmenu=service&amp;type=1", $langs->trans("Services"), 0, $user->rights->produit->lire);
@@ -599,12 +605,26 @@ class MenuLeft {
 					$newmenu->add_submenu(DOL_URL_ROOT."/product/liste.php?leftmenu=service&amp;type=1", $langs->trans("List"), 1, $user->rights->produit->lire);
 				}
 
+				// Categories
+				if ($conf->categorie->enabled)
+				{
+					$langs->load("categories");
+					$newmenu->add(DOL_URL_ROOT."/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 0, $user->rights->categorie->lire);
+					if ($user->societe_id == 0)
+					{
+						$newmenu->add_submenu(DOL_URL_ROOT."/categories/fiche.php?action=create&amp;type=0", $langs->trans("NewCat"), 1, $user->rights->categorie->creer);
+					}
+					//if ($leftmenu=="cat") $newmenu->add_submenu(DOL_URL_ROOT."/categories/liste.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
+				}
+
+				// Statistics
 				$newmenu->add(DOL_URL_ROOT."/product/stats/index.php?leftmenu=stats", $langs->trans("Statistics"), 0, $user->rights->produit->lire);
 				if ($conf->propal->enabled)
 				{
 					$newmenu->add_submenu(DOL_URL_ROOT."/product/popuprop.php?leftmenu=stats", $langs->trans("Popularity"), 1, $user->rights->propale->lire);
 				}
 
+				// Stocks
 				if ($conf->stock->enabled)
 				{
 					$langs->load("stocks");
@@ -615,16 +635,15 @@ class MenuLeft {
 					if ($leftmenu=="stock") $newmenu->add_submenu(DOL_URL_ROOT."/product/stock/mouvement.php", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire);
 				}
 
-				if ($conf->categorie->enabled)
+				// Expeditions
+				if ($conf->expedition->enabled) 
 				{
-					$langs->load("categories");
-					$newmenu->add(DOL_URL_ROOT."/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 0, $user->rights->categorie->lire);
-					if ($user->societe_id == 0)
-					{
-						$newmenu->add_submenu(DOL_URL_ROOT."/categories/fiche.php?action=create&amp;type=0", $langs->trans("NewCat"), 1, $user->rights->categorie->creer);
-					}
-					//if ($leftmenu=="cat") $newmenu->add_submenu(DOL_URL_ROOT."/categories/liste.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
+					$langs->load("sendings");
+					$newmenu->add(DOL_URL_ROOT."/expedition/index.php?leftmenu=sendings", $langs->trans("Sendings"), 0, $user->rights->expedition->lire);
+					if ($leftmenu=="sendings") $newmenu->add_submenu(DOL_URL_ROOT."/expedition/liste.php?leftmenu=sendings", $langs->trans("List"), 1 ,$user->rights->expedition->lire);
+					if ($leftmenu=="sendings") $newmenu->add_submenu(DOL_URL_ROOT."/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1 ,$user->rights->expedition->lire);
 				}
+
 			}
 
 
@@ -633,7 +652,6 @@ class MenuLeft {
 			*/
 			if ($mainmenu == 'suppliers')
 			{
-
 				$langs->load("suppliers");
 
 				if ($conf->societe->enabled && $conf->fournisseur->enabled)
@@ -683,7 +701,7 @@ class MenuLeft {
 				}
 
 			}
-
+			
 			/*
 			* Menu AGENDA
 			*/
diff --git a/htdocs/includes/menus/barre_left/eldy_frontoffice.php b/htdocs/includes/menus/barre_left/eldy_frontoffice.php
index 669ebb9c669..1ab88397311 100644
--- a/htdocs/includes/menus/barre_left/eldy_frontoffice.php
+++ b/htdocs/includes/menus/barre_left/eldy_frontoffice.php
@@ -14,14 +14,12 @@
 * 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.
-*
-* $Id$
 */
 
 /**
 		\file       htdocs/includes/menus/barre_left/eldy_frontoffice.php
 		\brief      Gestionnaire du menu du gauche Eldy
-		\version    $Revision$
+		\version    $Id$
 		
 		\remarks    La construction d'un gestionnaire pour le menu de gauche est simple:
 		\remarks    A l'aide d'un objet $newmenu=new Menu() et des m�thode add et add_submenu,
@@ -198,21 +196,23 @@ class MenuLeft {
 
 				if ($conf->societe->enabled && $conf->fournisseur->enabled)
 				{
-					$newmenu->add(DOL_URL_ROOT."/fourn/liste.php?leftmenu=suppliers", $langs->trans("Suppliers"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire);
+					$newmenu->add(DOL_URL_ROOT."/fourn/index.php?leftmenu=suppliers", $langs->trans("Suppliers"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire);
 
 					// S�curit� acc�s client
 					if ($user->societe_id == 0)
 					{
 						$newmenu->add_submenu(DOL_URL_ROOT."/soc.php?leftmenu=suppliers&amp;action=create&amp;type=f",$langs->trans("NewSupplier"), 2, $user->rights->societe->creer && $user->rights->fournisseur->lire);
 					}
-					$newmenu->add_submenu(DOL_URL_ROOT."/contact/index.php?leftmenu=suppliers&amp;type=f",$langs->trans("Contacts"), 2, $user->rights->societe->contact->lire && $user->rights->fournisseur->lire);
+					$newmenu->add_submenu(DOL_URL_ROOT."/fourn/liste.php?leftmenu=suppliers", $langs->trans("List"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire);
+					$newmenu->add_submenu(DOL_URL_ROOT."/contact/index.php?leftmenu=suppliers&amp;type=f",$langs->trans("Contacts"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire && $user->rights->societe->contact->lire);
+			    	$newmenu->add_submenu(DOL_URL_ROOT."/fourn/stats.php",$langs->trans("Statistics"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire);
 				}
 
 				// Prospects
 			    if ($conf->societe->enabled)
 			    {
 					$langs->load("commercial");
-					$newmenu->add(DOL_URL_ROOT."/comm/prospect/prospects.php?leftmenu=prospects", $langs->trans("Prospects"), 1, $user->rights->societe->lire);
+					$newmenu->add(DOL_URL_ROOT."/comm/prospect/prospects.php?leftmenu=prospects", $langs->trans("Prospects"), 2, $user->rights->societe->lire);
 
 					$newmenu->add_submenu(DOL_URL_ROOT."/soc.php?leftmenu=prospects&amp;action=create&amp;type=p", $langs->trans("MenuNewProspect"), 2, $user->rights->societe->creer);
 					$newmenu->add_submenu(DOL_URL_ROOT."/contact/index.php?leftmenu=customers&amp;type=p", $langs->trans("Contacts"), 2, $user->rights->societe->contact->lire);
@@ -242,6 +242,17 @@ class MenuLeft {
 			{
 				$langs->load("companies");
 
+				// Actions
+				/*
+				if ($conf->agenda->enabled)
+				{
+					$newmenu->add(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions", $langs->trans("Agenda"), 0, $user->rights->agenda->myactions->read);
+					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/societe.php?leftmenu=actions", $langs->trans("NewAction"), 1, $user->rights->agenda->myactions->read);
+					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions&amp;status=todo", $langs->trans("MenuToDoActions"), 1, $user->rights->agenda->myactions->read);
+					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions&amp;time=today", $langs->trans("Today"), 1, $user->rights->agenda->myactions->read);
+					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/rapport/index.php?leftmenu=actions", $langs->trans("Reportings"), 1, $user->rights->agenda->myactions->read);
+				}
+				*/
 				// Prospects
 				/*
 				$newmenu->add(DOL_URL_ROOT."/comm/prospect/index.php?leftmenu=prospects", $langs->trans("Prospects"), 0, $user->rights->societe->lire);
@@ -271,17 +282,6 @@ class MenuLeft {
 				$newmenu->add_submenu(DOL_URL_ROOT."/contact/fiche.php?leftmenu=contacts&amp;action=create", $langs->trans("NewContact"), 1, $user->rights->societe->contact->creer);
 				$newmenu->add_submenu(DOL_URL_ROOT."/contact/index.php?leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->contact->lire);
 				*/
-				// Actions
-				/*
-				if ($conf->agenda->enabled)
-				{
-					$newmenu->add(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions", $langs->trans("Agenda"), 0, $user->rights->agenda->myactions->read);
-					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/societe.php?leftmenu=actions", $langs->trans("NewAction"), 1, $user->rights->agenda->myactions->read);
-					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions&amp;status=todo", $langs->trans("MenuToDoActions"), 1, $user->rights->agenda->myactions->read);
-					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/index.php?leftmenu=actions&amp;time=today", $langs->trans("Today"), 1, $user->rights->agenda->myactions->read);
-					if ($leftmenu=="actions") $newmenu->add_submenu(DOL_URL_ROOT."/comm/action/rapport/index.php?leftmenu=actions", $langs->trans("Reportings"), 1, $user->rights->agenda->myactions->read);
-				}
-				*/
 				// Propal
 				if ($conf->propal->enabled)
 				{
@@ -295,11 +295,11 @@ class MenuLeft {
 					if ($leftmenu=="propals") $newmenu->add_submenu(DOL_URL_ROOT."/comm/propal/stats/", $langs->trans("Statistics"), 1, $user->rights->propale->lire);
 				}
 
-				// Commandes
+				// Customers orders
 				if ($conf->commande->enabled )
 				{
 					$langs->load("orders");
-					$newmenu->add(DOL_URL_ROOT."/commande/index.php?leftmenu=orders", $langs->trans("Orders"), 0 ,$user->rights->commande->lire);
+					$newmenu->add(DOL_URL_ROOT."/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0 ,$user->rights->commande->lire);
 					if ($leftmenu=="orders") $newmenu->add_submenu(DOL_URL_ROOT."/societe.php?leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer);
 					if ($leftmenu=="orders") $newmenu->add_submenu(DOL_URL_ROOT."/commande/liste.php?leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->creer);
 					if ($leftmenu=="orders") $newmenu->add_submenu(DOL_URL_ROOT."/commande/liste.php?leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire);
@@ -311,11 +311,13 @@ class MenuLeft {
 					if ($leftmenu=="orders") $newmenu->add_submenu(DOL_URL_ROOT."/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1 ,$user->rights->commande->lire);
 				}
 
-				// Expeditions
-				if ($conf->expedition->enabled) {
-					$newmenu->add(DOL_URL_ROOT."/expedition/index.php?leftmenu=sendings", $langs->trans("Sendings"), 0, $user->rights->expedition->lire);
-					if ($leftmenu=="sendings") $newmenu->add_submenu(DOL_URL_ROOT."/expedition/liste.php?leftmenu=sendings", $langs->trans("List"), 1 ,$user->rights->expedition->lire);
-					if ($leftmenu=="sendings") $newmenu->add_submenu(DOL_URL_ROOT."/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1 ,$user->rights->expedition->lire);
+				// Suppliers orders
+				if ($conf->fournisseur->enabled)
+				{
+					$langs->load("orders");
+					$newmenu->add(DOL_URL_ROOT."/fourn/commande/index.php?leftmenu=orders_suppliers",$langs->trans("SuppliersOrders"), 0, $user->rights->fournisseur->commande->lire);
+					if ($leftmenu=="orders_suppliers") $newmenu->add_submenu(DOL_URL_ROOT."/societe.php?leftmenu=orders_suppliers", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer);
+					if ($leftmenu=="orders_suppliers") $newmenu->add_submenu(DOL_URL_ROOT."/fourn/commande/liste.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire);
 				}
 
 				// Contrat
@@ -560,6 +562,7 @@ class MenuLeft {
 			*/
 			if ($mainmenu == 'products')
 			{
+				// Products
 				if ($conf->produit->enabled)
 				{
 					$newmenu->add(DOL_URL_ROOT."/product/index.php?leftmenu=product&amp;type=0", $langs->trans("Products"), 0, $user->rights->produit->lire);
@@ -574,6 +577,7 @@ class MenuLeft {
 					}
 				}
 
+				// Services
 				if ($conf->service->enabled)
 				{
 					$newmenu->add(DOL_URL_ROOT."/product/index.php?leftmenu=service&amp;type=1", $langs->trans("Services"), 0, $user->rights->produit->lire);
@@ -584,12 +588,26 @@ class MenuLeft {
 					$newmenu->add_submenu(DOL_URL_ROOT."/product/liste.php?leftmenu=service&amp;type=1", $langs->trans("List"), 1, $user->rights->produit->lire);
 				}
 
+				// Categories
+				if ($conf->categorie->enabled)
+				{
+					$langs->load("categories");
+					$newmenu->add(DOL_URL_ROOT."/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 0, $user->rights->categorie->lire);
+					if ($user->societe_id == 0)
+					{
+						$newmenu->add_submenu(DOL_URL_ROOT."/categories/fiche.php?action=create&amp;type=0", $langs->trans("NewCat"), 1, $user->rights->categorie->creer);
+					}
+					//if ($leftmenu=="cat") $newmenu->add_submenu(DOL_URL_ROOT."/categories/liste.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
+				}
+
+				// Statistics
 				$newmenu->add(DOL_URL_ROOT."/product/stats/index.php?leftmenu=stats", $langs->trans("Statistics"), 0, $user->rights->produit->lire);
 				if ($conf->propal->enabled)
 				{
 					$newmenu->add_submenu(DOL_URL_ROOT."/product/popuprop.php?leftmenu=stats", $langs->trans("Popularity"), 1, $user->rights->propale->lire);
 				}
 
+				// Stocks
 				if ($conf->stock->enabled)
 				{
 					$langs->load("stocks");
@@ -600,15 +618,13 @@ class MenuLeft {
 					if ($leftmenu=="stock") $newmenu->add_submenu(DOL_URL_ROOT."/product/stock/mouvement.php", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire);
 				}
 
-				if ($conf->categorie->enabled)
+				// Expeditions
+				if ($conf->expedition->enabled) 
 				{
-					$langs->load("categories");
-					$newmenu->add(DOL_URL_ROOT."/categories/index.php?leftmenu=cat&amp;type=0", $langs->trans("Categories"), 0, $user->rights->categorie->lire);
-					if ($user->societe_id == 0)
-					{
-						if ($leftmenu=="cat") $newmenu->add_submenu(DOL_URL_ROOT."/categories/fiche.php?action=create&amp;type=0", $langs->trans("NewCat"), 1, $user->rights->categorie->creer);
-					}
-					//if ($leftmenu=="cat") $newmenu->add_submenu(DOL_URL_ROOT."/categories/liste.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
+					$langs->load("sendings");
+					$newmenu->add(DOL_URL_ROOT."/expedition/index.php?leftmenu=sendings", $langs->trans("Sendings"), 0, $user->rights->expedition->lire);
+					if ($leftmenu=="sendings") $newmenu->add_submenu(DOL_URL_ROOT."/expedition/liste.php?leftmenu=sendings", $langs->trans("List"), 1 ,$user->rights->expedition->lire);
+					if ($leftmenu=="sendings") $newmenu->add_submenu(DOL_URL_ROOT."/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1 ,$user->rights->expedition->lire);
 				}
 
 			}
@@ -619,7 +635,6 @@ class MenuLeft {
 			*/
 			if ($mainmenu == 'suppliers')
 			{
-
 				$langs->load("suppliers");
 
 				if ($conf->societe->enabled && $conf->fournisseur->enabled)
@@ -659,7 +674,6 @@ class MenuLeft {
 
 			}
 
-
 			/*
 			* Menu AGENDA
 			*/
diff --git a/htdocs/includes/menus/barre_top/eldy_backoffice.php b/htdocs/includes/menus/barre_top/eldy_backoffice.php
index 2f056f79e70..46420e6c83a 100644
--- a/htdocs/includes/menus/barre_top/eldy_backoffice.php
+++ b/htdocs/includes/menus/barre_top/eldy_backoffice.php
@@ -139,6 +139,7 @@ class MenuTop {
         }
 
         // Suppliers
+/*
         if ($conf->fournisseur->enabled)
         {
             $langs->load("suppliers");
@@ -158,7 +159,8 @@ class MenuTop {
             else
             		print '<td class="tmenu"><font class="tmenudisabled">'.$langs->trans("Suppliers").'</font></td>';
         }
-        
+*/
+
         // Commercial
         if ($conf->commercial->enabled)
         {
diff --git a/htdocs/includes/menus/barre_top/eldy_frontoffice.php b/htdocs/includes/menus/barre_top/eldy_frontoffice.php
index b3ca97bc41d..c3d4661dbc3 100644
--- a/htdocs/includes/menus/barre_top/eldy_frontoffice.php
+++ b/htdocs/includes/menus/barre_top/eldy_frontoffice.php
@@ -139,6 +139,7 @@ class MenuTop {
         }
 
         // Suppliers
+/*
         if ($conf->fournisseur->enabled)
         {
             $langs->load("suppliers");
@@ -152,15 +153,13 @@ class MenuTop {
             {
                 $class = 'class="tmenu"';
             }
-        
-/*
-           if ($user->rights->fournisseur->lire)
+       
+			if ($user->rights->fournisseur->lire)
             		print '<td class="tmenu"><a '.$class.' href="'.DOL_URL_ROOT.'/fourn/index.php?mainmenu=suppliers&amp;leftmenu="'.($this->atarget?" target=$this->atarget":"").'>'.$langs->trans("Suppliers").'</a></td>';
             else
             		print '<td class="tmenu"><font class="tmenudisabled">'.$langs->trans("Suppliers").'</font></td>';
-*/
         }
-        
+*/        
         // Commercial
         if ($conf->commercial->enabled)
         {
diff --git a/htdocs/includes/modules/modDocument.class.php b/htdocs/includes/modules/modDocument.class.php
index 737a5f0196b..5af1188e44b 100644
--- a/htdocs/includes/modules/modDocument.class.php
+++ b/htdocs/includes/modules/modDocument.class.php
@@ -55,7 +55,7 @@ class modDocument extends DolibarrModules
     $this->version = $this->revision[1];
     $this->const_name = 'MAIN_MODULE_DOCUMENT';
     $this->special = 2;
-    $this->picto='generic';
+    $this->picto='dir';
 
     // Dir
     $this->dirs = array();
diff --git a/htdocs/includes/modules/modECM.class.php b/htdocs/includes/modules/modECM.class.php
index a35d6fa6e0a..7a81fce767e 100644
--- a/htdocs/includes/modules/modECM.class.php
+++ b/htdocs/includes/modules/modECM.class.php
@@ -64,7 +64,7 @@ class modECM extends DolibarrModules
 		// Where to store the module in setup page (0=common,1=interface,2=other)
 		$this->special = 2;
 		// Name of png file (without png) used for this module
-		$this->picto='generic';
+		$this->picto='dir';
 		
 		// Data directories to create when module is enabled
 		$this->dirs = array();
@@ -94,6 +94,28 @@ class modECM extends DolibarrModules
 		// Permissions
 		$this->rights_class = 'ecm';	// Permission key
 		$this->rights = array();		// Permission array used by this module
+
+		$r++;
+		$this->rights[$r][0] = 2500;
+		$this->rights[$r][1] = 'Consulter les documents';
+		$this->rights[$r][2] = 'r';
+		$this->rights[$r][3] = 1;
+		$this->rights[$r][4] = 'read';
+
+		$r++;
+		$this->rights[$r][0] = 2501;
+		$this->rights[$r][1] = 'Soumettre des documents';
+		$this->rights[$r][2] = 'w';
+		$this->rights[$r][3] = 1;
+		$this->rights[$r][4] = 'create';
+
+		$r++;
+		$this->rights[$r][0] = 2515;
+		$this->rights[$r][1] = 'Administrer les rubriques de documents';
+		$this->rights[$r][2] = 'w';
+		$this->rights[$r][3] = 1;
+		$this->rights[$r][4] = 'setup';
+
 		
         // Menus
 		//------
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index e6a74b992e7..97a11f157af 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -206,7 +206,6 @@ ProspectsByStatus=Prospects by status
 BillingContact=Billing contact
 NbOfAttachedFiles=Number of attached files
 AttachANewFile=Attach a new file
-FileWasRemoved=Files was removed
 NoRIB=No RIB defined
 NoParentCompany=None
 ExportImport=Import-Export
diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang
index 1c7a87bfbd9..f6cfd17b4c8 100755
--- a/htdocs/langs/en_US/orders.lang
+++ b/htdocs/langs/en_US/orders.lang
@@ -1,5 +1,6 @@
 # Dolibarr language file - en_US - orders
-OrdersArea=Orders area
+OrdersArea=Customers orders area
+SuppliersOrdersArea=Suppliers orders area
 OrderCard=Order card
 Order=Order
 Orders=Orders
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index 434ed888ed3..e997beb95f8 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -60,6 +60,7 @@ ValidatedBy=Validated by %s
 CanceledBy=Canceled by %s
 ClosedBy=Closed by %s
 FileWasRemoved=File was deleted
+DirWasRemoved=Directory was removed
 FeatureNotYetAvailable=Feature not yet available in this version
 FeatureExperimental=Experimental feature. Not stable in this version
 FeatureDevelopment=Development feature. Not stable in this version
diff --git a/htdocs/langs/fr_BE/companies.lang b/htdocs/langs/fr_BE/companies.lang
index ab394513eee..8736889c34b 100644
--- a/htdocs/langs/fr_BE/companies.lang
+++ b/htdocs/langs/fr_BE/companies.lang
@@ -166,7 +166,6 @@ BillingContact=Contact de facturation
 TotalSizeOfAttachedFiles=Taille totale des fichiers attach�s
 NbOfAttachedFiles=Nombre de fichiers attach�s
 AttachANewFile=Attacher un nouveau fichier
-FileWasRemoved=Fichiers supprim�s
 NoRIB=Aucun RIB d�fini
 NoParentCompany=Aucune
 ExportImport=Import/Export
diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang
index 6b7728de353..6d11e4ff0af 100644
--- a/htdocs/langs/fr_FR/companies.lang
+++ b/htdocs/langs/fr_FR/companies.lang
@@ -206,7 +206,6 @@ ProspectsByStatus=Prospects par 
 BillingContact=Contact facturation
 NbOfAttachedFiles=Nombre de fichiers joints
 AttachANewFile=Joindre un nouveau fichier
-FileWasRemoved=Le fichier a �t� supprim�
 NoRIB=Aucun RIB d�fini
 NoParentCompany=Aucune
 ExportImport=Import-Export
diff --git a/htdocs/langs/fr_FR/ecm.lang b/htdocs/langs/fr_FR/ecm.lang
index 3de8206420b..830ffd1c582 100644
--- a/htdocs/langs/fr_FR/ecm.lang
+++ b/htdocs/langs/fr_FR/ecm.lang
@@ -1,7 +1,42 @@
 # Dolibarr language file - fr_FR - ecm
 MenuECM=Documents
 DocsMine=Mes documents
+DocsGlobal=Documents globaux
+DocsExternal=Documents externes
+DocsGenerated=Documents g�n�r�s
+DocsElements=Documents �lements
 DocsThirdParties=Documents tiers
-DocsInvoices=Documents factures
+DocsContracts=Documents contrats
 DocsProposals=Documents propositions
-ECMArea=Espace Gestion de documents
\ No newline at end of file
+DocsOrders=Documents commandes
+DocsInvoices=Documents factures
+ECMNbOfDocs=Nb de documents
+ECMSection=Rubrique
+ECMSections=Rubriques
+ECMRoot=Racine
+ECMNewSection=Nouvelle rubrique
+ECMAddSection=Ajouter rubrique manuelle
+ECMNewSection=Nouvelle rubrique manuelle
+ECMNewDocument=Nouveau document
+ECMCreationDate=Date cr�ation
+ECMCreationUser=Cr�ateur
+ECMArea=Espace Gestion de documents
+ECMAreaDesc=L'espace Gestion des documents vous permet de stocker et retrouver rapidement des documents dans Dolibarr.
+ECMAreaDesc2=Vous pouvez creer des rubriques manuelles ou y ajouter des documents.<br>Les rubriques automatiques sont aliment�es automatiquement lors de l'ajout d'un document depuis une fiche objet.
+ECMSectionWasRemoved=La rubrique <b>%s</b> a �t� effac�e.
+ECMDocumentsSection=Document de la section
+ECMSearchByKeywords=Recherche par mots cl�s
+ECMSearchByEntity=Recherche par objet
+ECMSectionOfDocuments=Rubriques des documents
+ECMTypeManual=Manuelle
+ECMTypeAuto=Automatique
+ECMDocsByThirdParties=Documents associ�s aux tiers
+ECMDocsByProposals=Documents associ�s aux propositions
+ECMDocsByOrders=Documents associ�s aux commandes
+ECMDocsByContracts=Documents associ�s aux contrats
+ECMDocsByInvoices=Documents associ�s aux factures
+ECMManualOrg=Rubrique manuelle
+ECMAutoOrg=Rubrique automatique
+ShowECMSection=Afficher rubrique
+DeleteSection=Suppression rubrique
+ConfirmDeleteSection=Confirmez-vous la suppression de la rubique <b>%s</b> ?
diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang
index 0de6dc0861a..f22506044f1 100755
--- a/htdocs/langs/fr_FR/orders.lang
+++ b/htdocs/langs/fr_FR/orders.lang
@@ -1,5 +1,6 @@
 # Dolibarr language file - fr_FR - orders
-OrdersArea=Espace commandes
+OrdersArea=Espace commandes clients
+SuppliersOrdersArea=Espace commandes fournisseurs
 OrderCard=Fiche commande
 Order=Commande
 Orders=Commandes
diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang
index 99814f2af2e..1b3f3e97d63 100644
--- a/htdocs/langs/fr_FR/other.lang
+++ b/htdocs/langs/fr_FR/other.lang
@@ -60,6 +60,7 @@ ValidatedBy=Valid
 CanceledBy=Annul� par %s
 ClosedBy=Clotur� par %s
 FileWasRemoved=Le fichier a �t� supprim�
+DirWasRemoved=Le r�pertoire a �t� supprim�
 FeatureNotYetAvailable=Fonctionnalit� pas encore disponible dans cette version
 FeatureExperimental=Fonctionnalit� exp�rimentale. Non stable dans cette version
 FeatureDevelopment=Fonctionnalit� en d�veloppement. Non stable dans cette version
diff --git a/htdocs/lib/contract.lib.php b/htdocs/lib/contract.lib.php
index c76ce4d3854..974e488e313 100644
--- a/htdocs/lib/contract.lib.php
+++ b/htdocs/lib/contract.lib.php
@@ -15,17 +15,12 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  * or see http://www.gnu.org/
- *
- * $Id$
- * $Source$
  */
 
 /**
 	    \file       htdocs/lib/contract.lib.php
 		\brief      Ensemble de fonctions de base pour le module contrat
-		\version    $Revision$
-
-		Ensemble de fonctions de base de dolibarr sous forme d'include
+		\version    $Id$
 */
 
 function contract_prepare_head($contrat)
@@ -35,20 +30,29 @@ function contract_prepare_head($contrat)
 	$head = array();
 	
 	$head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id;
-	$head[$h][1] = $langs->trans("ContractCard");
+	$head[$h][1] = $langs->trans("ContractCard");
+	$head[$h][2] = 'card';
 	$h++;
 
 	$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id;
 	$head[$h][1] = $langs->trans("ContractContacts");
+	$head[$h][2] = 'contact';
 	$h++;
 
 	$head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$contrat->id;
 	$head[$h][1] = $langs->trans("Note");
+	$head[$h][2] = 'note';
 	$h++;
 
-	$head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id;
-	$head[$h][1] = $langs->trans("Info");
-	$h++;
+	$head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id;
+	$head[$h][1] = $langs->trans("Documents");
+	$head[$h][2] = 'documents';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id;
+	$head[$h][1] = $langs->trans("Info");
+	$head[$h][2] = 'info';
+	$h++;
 
 
 	return $head;
diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php
index fb98be95d86..22a873147b4 100644
--- a/htdocs/lib/functions.inc.php
+++ b/htdocs/lib/functions.inc.php
@@ -1513,31 +1513,37 @@ function print_liste_field_titre($name, $file, $field, $begin="", $options="", $
     {
         print '<td class="liste_titre" '. $td.'>';
     }
-    print $name."&nbsp;";
-    if (! $sortorder)
-    {
-        print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
-        print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
-    }
-    else
-    {
-        if ($field != $sortfield)
-		{
-            print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
-            print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
-        }
-        else {
-			$sortorder=strtoupper($sortorder);
-            if ($sortorder == 'DESC' ) {
-                print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
-                print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>';
-            }
-            if ($sortorder == 'ASC' ) {
-                print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>';
-                print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
-            }
-        }
-    }
+    print $name;
+	
+	// If this is a sort field
+	if ($field)
+	{
+		print "&nbsp;";
+	    if (! $sortorder)
+	    {
+	        print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
+	        print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
+	    }
+	    else
+	    {
+	        if ($field != $sortfield)
+			{
+	            print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
+	            print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
+	        }
+	        else {
+				$sortorder=strtoupper($sortorder);
+	            if ($sortorder == 'DESC' ) {
+	                print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
+	                print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>';
+	            }
+	            if ($sortorder == 'ASC' ) {
+	                print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>';
+	                print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
+	            }
+	        }
+	    }
+	}
     print "</td>";
 }
 
diff --git a/htdocs/product/document.php b/htdocs/product/document.php
index f0df45fb1e2..c0da709e9fb 100755
--- a/htdocs/product/document.php
+++ b/htdocs/product/document.php
@@ -18,15 +18,13 @@
  * 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.
- *
- * $Id$
  */
  
 /**
         \file       htdocs/product/document.php
         \ingroup    product
         \brief      Page des documents joints sur les produits
-        \version    $Revision$
+        \version    $Id$
 */
 
 require('./pre.inc.php');
@@ -51,6 +49,7 @@ if ($_GET['id'] || $_GET["ref"])
     $prodref = sanitize_string($product->ref);
     $upload_dir = $conf->produit->dir_output.'/'.$prodref;
 }
+$modulepart='produit';
 
 
 /*
@@ -99,7 +98,8 @@ if ($product->id)
 	if ($action=='delete')
 	{
 		$file = $upload_dir . '/' . urldecode($_GET['urlfile']);
-		dol_delete_file($file);
+		$result=dol_delete_file($file);
+		//if ($result >= 0) $mesg=$langs->trans("FileWasRemoced");
 	}
 
 	$head=product_prepare_head($product, $user);
@@ -204,7 +204,7 @@ if ($product->id)
 				$var=!$var;
 				print '<tr '.$bc[$var].'>';
 				print '<td>';
-				echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=produit&file='.$prodref.'/'.urlencode($file).'">'.$file.'</a>';
+				echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&file='.$prodref.'/'.urlencode($file).'">'.$file.'</a>';
 				print "</td>\n";
 				print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>';
 				print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir.'/'.$file),'dayhour').'</td>';
diff --git a/htdocs/theme/auguria/img/object_dir.png b/htdocs/theme/auguria/img/object_dir.png
new file mode 100644
index 0000000000000000000000000000000000000000..6f364389133c425747e0eaf8eb2920013a815572
GIT binary patch
literal 301
zcmeAS@N?(olHy`uVBq!ia0y~yVBiB`4rT@h290TVA2Tp8=$E)glsFfqCYEI8=P86_
z=B6^FWajEA7?~)fy(}xzQ!p|xuuw2Eurf8ZGBQ@sHZU|Wi2b^fg@J*Ay~NYkmHh^j
zgs`RL%4mg!3=9mM1s;*b3=G^tAk28_ZrvXS1_qXNM_)$<hK>E)e-c?47#O4jd_r9R
z|NkEq6}5D!;{X5G{$E@A|Nqis$Br>DFns_1{kR0fZUzPh#*!evU<QY0H_{jw7<@fl
z978H@rJjrAV^HK^b*yNp_%F=g%{Do6zm~?t7vc@!(J4HE!H%I@O4#f!+d2A7yL0Ja
zc#ux_>b|<$Mn6(@qmJ&5N;dp1@9+BPCG#?2#uF!h_2x4$Ffe$!`njxgN@xNAD7IvR

literal 0
HcmV?d00001

diff --git a/htdocs/theme/bluelagoon/img/object_dir.png b/htdocs/theme/bluelagoon/img/object_dir.png
new file mode 100644
index 0000000000000000000000000000000000000000..6f364389133c425747e0eaf8eb2920013a815572
GIT binary patch
literal 301
zcmeAS@N?(olHy`uVBq!ia0y~yVBiB`4rT@h290TVA2Tp8=$E)glsFfqCYEI8=P86_
z=B6^FWajEA7?~)fy(}xzQ!p|xuuw2Eurf8ZGBQ@sHZU|Wi2b^fg@J*Ay~NYkmHh^j
zgs`RL%4mg!3=9mM1s;*b3=G^tAk28_ZrvXS1_qXNM_)$<hK>E)e-c?47#O4jd_r9R
z|NkEq6}5D!;{X5G{$E@A|Nqis$Br>DFns_1{kR0fZUzPh#*!evU<QY0H_{jw7<@fl
z978H@rJjrAV^HK^b*yNp_%F=g%{Do6zm~?t7vc@!(J4HE!H%I@O4#f!+d2A7yL0Ja
zc#ux_>b|<$Mn6(@qmJ&5N;dp1@9+BPCG#?2#uF!h_2x4$Ffe$!`njxgN@xNAD7IvR

literal 0
HcmV?d00001

diff --git a/htdocs/theme/dev/img/object_dir.png b/htdocs/theme/dev/img/object_dir.png
new file mode 100644
index 0000000000000000000000000000000000000000..6f364389133c425747e0eaf8eb2920013a815572
GIT binary patch
literal 301
zcmeAS@N?(olHy`uVBq!ia0y~yVBiB`4rT@h290TVA2Tp8=$E)glsFfqCYEI8=P86_
z=B6^FWajEA7?~)fy(}xzQ!p|xuuw2Eurf8ZGBQ@sHZU|Wi2b^fg@J*Ay~NYkmHh^j
zgs`RL%4mg!3=9mM1s;*b3=G^tAk28_ZrvXS1_qXNM_)$<hK>E)e-c?47#O4jd_r9R
z|NkEq6}5D!;{X5G{$E@A|Nqis$Br>DFns_1{kR0fZUzPh#*!evU<QY0H_{jw7<@fl
z978H@rJjrAV^HK^b*yNp_%F=g%{Do6zm~?t7vc@!(J4HE!H%I@O4#f!+d2A7yL0Ja
zc#ux_>b|<$Mn6(@qmJ&5N;dp1@9+BPCG#?2#uF!h_2x4$Ffe$!`njxgN@xNAD7IvR

literal 0
HcmV?d00001

diff --git a/htdocs/theme/eldy/eldy.css.php b/htdocs/theme/eldy/eldy.css.php
index 8b55d5e0658..e53970c2bd7 100644
--- a/htdocs/theme/eldy/eldy.css.php
+++ b/htdocs/theme/eldy/eldy.css.php
@@ -16,14 +16,12 @@
  * 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.
- *
- * $Id$
  */
 
 /**
 		\file       htdocs/theme/eldy/eldy.css.php
 		\brief      Fichier de style CSS du theme Eldy
-		\version    $Revision$
+		\version    $Id$
 */
 
 require("../../conf/conf.php");
diff --git a/htdocs/theme/eldy/img/object_dir.png b/htdocs/theme/eldy/img/object_dir.png
new file mode 100644
index 0000000000000000000000000000000000000000..6f364389133c425747e0eaf8eb2920013a815572
GIT binary patch
literal 301
zcmeAS@N?(olHy`uVBq!ia0y~yVBiB`4rT@h290TVA2Tp8=$E)glsFfqCYEI8=P86_
z=B6^FWajEA7?~)fy(}xzQ!p|xuuw2Eurf8ZGBQ@sHZU|Wi2b^fg@J*Ay~NYkmHh^j
zgs`RL%4mg!3=9mM1s;*b3=G^tAk28_ZrvXS1_qXNM_)$<hK>E)e-c?47#O4jd_r9R
z|NkEq6}5D!;{X5G{$E@A|Nqis$Br>DFns_1{kR0fZUzPh#*!evU<QY0H_{jw7<@fl
z978H@rJjrAV^HK^b*yNp_%F=g%{Do6zm~?t7vc@!(J4HE!H%I@O4#f!+d2A7yL0Ja
zc#ux_>b|<$Mn6(@qmJ&5N;dp1@9+BPCG#?2#uF!h_2x4$Ffe$!`njxgN@xNAD7IvR

literal 0
HcmV?d00001

diff --git a/htdocs/theme/freelug/img/object_dir.png b/htdocs/theme/freelug/img/object_dir.png
new file mode 100644
index 0000000000000000000000000000000000000000..6f364389133c425747e0eaf8eb2920013a815572
GIT binary patch
literal 301
zcmeAS@N?(olHy`uVBq!ia0y~yVBiB`4rT@h290TVA2Tp8=$E)glsFfqCYEI8=P86_
z=B6^FWajEA7?~)fy(}xzQ!p|xuuw2Eurf8ZGBQ@sHZU|Wi2b^fg@J*Ay~NYkmHh^j
zgs`RL%4mg!3=9mM1s;*b3=G^tAk28_ZrvXS1_qXNM_)$<hK>E)e-c?47#O4jd_r9R
z|NkEq6}5D!;{X5G{$E@A|Nqis$Br>DFns_1{kR0fZUzPh#*!evU<QY0H_{jw7<@fl
z978H@rJjrAV^HK^b*yNp_%F=g%{Do6zm~?t7vc@!(J4HE!H%I@O4#f!+d2A7yL0Ja
zc#ux_>b|<$Mn6(@qmJ&5N;dp1@9+BPCG#?2#uF!h_2x4$Ffe$!`njxgN@xNAD7IvR

literal 0
HcmV?d00001

diff --git a/htdocs/theme/yellow/img/object_dir.png b/htdocs/theme/yellow/img/object_dir.png
new file mode 100644
index 0000000000000000000000000000000000000000..6f364389133c425747e0eaf8eb2920013a815572
GIT binary patch
literal 301
zcmeAS@N?(olHy`uVBq!ia0y~yVBiB`4rT@h290TVA2Tp8=$E)glsFfqCYEI8=P86_
z=B6^FWajEA7?~)fy(}xzQ!p|xuuw2Eurf8ZGBQ@sHZU|Wi2b^fg@J*Ay~NYkmHh^j
zgs`RL%4mg!3=9mM1s;*b3=G^tAk28_ZrvXS1_qXNM_)$<hK>E)e-c?47#O4jd_r9R
z|NkEq6}5D!;{X5G{$E@A|Nqis$Br>DFns_1{kR0fZUzPh#*!evU<QY0H_{jw7<@fl
z978H@rJjrAV^HK^b*yNp_%F=g%{Do6zm~?t7vc@!(J4HE!H%I@O4#f!+d2A7yL0Ja
zc#ux_>b|<$Mn6(@qmJ&5N;dp1@9+BPCG#?2#uF!h_2x4$Ffe$!`njxgN@xNAD7IvR

literal 0
HcmV?d00001

diff --git a/mysql/tables/llx_ecm_directories.sql b/mysql/tables/llx_ecm_directories.sql
new file mode 100644
index 00000000000..896605f7946
--- /dev/null
+++ b/mysql/tables/llx_ecm_directories.sql
@@ -0,0 +1,34 @@
+-- ===================================================================
+-- Copyright (C) 2008 Laurent Destailleur  <eldy@users.sourceforge.net>
+--
+-- 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.
+--
+-- $Id$
+-- ===================================================================
+
+-- drop table llx_ecm_directories;
+
+create table llx_ecm_directories
+(
+  rowid           integer AUTO_INCREMENT PRIMARY KEY,
+  label           varchar(32) NOT NULL,
+  fk_parent       integer,
+  description     varchar(255) NOT NULL,
+  cachenbofdoc    integer NOT NULL DEFAULT 0,
+  date_c		  timestamp,
+  date_m		  datetime,
+  fk_user_c		  integer,
+  fk_user_m		  integer
+) type=innodb;
diff --git a/mysql/tables/llx_ecm_documents.sql b/mysql/tables/llx_ecm_documents.sql
new file mode 100644
index 00000000000..931e86d6294
--- /dev/null
+++ b/mysql/tables/llx_ecm_documents.sql
@@ -0,0 +1,41 @@
+-- ===================================================================
+-- Copyright (C) 2008 Laurent Destailleur  <eldy@users.sourceforge.net>
+--
+-- 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.
+--
+-- $Id$
+-- ===================================================================
+
+-- drop table llx_ecm_document;
+
+create table llx_ecm_document
+(
+  rowid           integer AUTO_INCREMENT PRIMARY KEY,
+  ref             varchar(16)  NOT NULL,
+  filename        varchar(255) NOT NULL,
+  filesize        integer      NOT NULL,
+  filemime        varchar(32)  NOT NULL,
+  fullpath_dol    varchar(255) NOT NULL,
+  fullpath_orig   varchar(255) NOT NULL,
+  description     text,
+  manualkeyword   text,
+  fk_create       integer  NOT NULL,
+  fk_update       integer,
+  date_c	      datetime NOT NULL,
+  date_u		  timestamp,
+  fk_directory    integer,
+  fk_status		  smallint DEFAULT 0,
+  private         smallint DEFAULT 0
+) type=innodb;
-- 
GitLab