From e15a67f6c9867bd9a557810b6d17cf98122a8a92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Mar 2009 23:57:28 +0000 Subject: [PATCH] Minor code clean in ECM module. --- htdocs/ecm/index.php | 52 +----- htdocs/ecm/pre.inc.php | 14 +- htdocs/ecm/search.php | 193 +++++++++++++++++++---- htdocs/includes/modules/modECM.class.php | 43 +++-- htdocs/langs/en_US/ecm.lang | 4 +- htdocs/langs/fr_FR/ecm.lang | 4 +- htdocs/lib/ecm.lib.php | 2 +- 7 files changed, 198 insertions(+), 114 deletions(-) diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 63eba93561f..301fb124194 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -223,10 +223,8 @@ if ($_GET['action'] == 'delete') if ($mesg) { print $mesg."
"; } // Tool bar -$selected='file_manager'; -if (eregi('search',$action)) $selected='search_form'; $head = ecm_prepare_head_fm($fac); -dol_fiche_head($head, $selected, '', 1); +dol_fiche_head($head, 'file_manager', '', 1); print '
'; @@ -234,54 +232,6 @@ print '
'; // Left area print '
'; -if (eregi('search',$action)) -{ - //print_fiche_titre($langs->trans("ECMSectionsManual")); - - print '
'; - print ''; - print ""; - print ''; - print "'; - print "'; - print "'; - print "'; - print "
'.$langs->trans("ECMSearchByKeywords").'
".$langs->trans("Ref").':
".$langs->trans("Title").':
".$langs->trans("Keyword").':
"; - //print $langs->trans("ECMSectionManualDesc"); - - //print_fiche_titre($langs->trans("ECMSectionAuto")); - - print '
'; - print ''; - print ""; - print ''; - - $buthtml=''; - $butshown=0; - foreach($sectionauto as $sectioncur) - { - if (! $sectioncur['test']) continue; - //if ($butshown % 2 == 0) - print ''; - print "'; - print ''; - print ''; - print ''; - //if ($butshown % 2 == 1) - print ''; - $butshown++; - } - //if ($butshown % 2 == 1) - // print ''; - - print ''; - print "
'.$langs->trans("ECMSearchByEntity").'
".$sectioncur['label'].':
  
"; - //print $langs->trans("ECMSectionAutoDesc"); -} - if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $action == 'delete') { diff --git a/htdocs/ecm/pre.inc.php b/htdocs/ecm/pre.inc.php index 54f8091c39c..a12f899bca3 100644 --- a/htdocs/ecm/pre.inc.php +++ b/htdocs/ecm/pre.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2009 Laurent Destailleur * * 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 @@ -17,11 +17,11 @@ */ /** - \file htdocs/ecm/pre.inc.php - \ingroup ecm - \brief File to manage left menu for ecm module - \version $Id$ -*/ + * \file htdocs/ecm/pre.inc.php + * \ingroup ecm + * \brief File to manage left menu for ecm module + * \version $Id$ + */ require ("../main.inc.php"); @@ -42,7 +42,7 @@ function llxHeader($head = "", $title="", $help_url='', $morehtml='') $menu->add_submenu(DOL_URL_ROOT."/ecm/index.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("List"),1,$user->rights->ecm->download); //$menu->add_submenu(DOL_URL_ROOT."/ecm/index?mainmenu=ecm&action=create&idmenu=".$_SESSION["idmenu"], $langs->trans("ECMNewDocument"),1,$user->rights->ecm->upload); - $menu->add_submenu(DOL_URL_ROOT."/ecm/docdir.php?mainmenu=ecm&action=create&idmenu=".$_SESSION["idmenu"], $langs->trans("ECMNewSection"),1,$user->rights->ecm->setup); + $menu->add_submenu(DOL_URL_ROOT."/ecm/search.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("Search"),1,$user->rights->ecm->download); /* 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); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index 536e8308e67..4d863575891 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -1,75 +1,210 @@ +/* Copyright (C) 2008-2009 Laurent Destailleur + * + * 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 htdocs/ecm/search.php - * \ingroup ecm - * \brief Page for search results - * \version $Id$ - * \author Laurent Destailleur + * \file htdocs/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."/lib/ecm.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/treeview.lib.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"]:''; +$action = isset($_GET["action"])?$_GET["action"]:$_POST['action']; +$section=isset($_GET["section"])?$_GET["section"]:$_POST['section']; +if (! $section) $section=0; -// 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="ASC"; +if (! $sortfield) $sortfield="label"; + +$ecmdir = new ECMDirectory($db); +if (! empty($_REQUEST["section"])) +{ + $result=$ecmdir->fetch($_REQUEST["section"]); + if (! $result > 0) + { + dol_print_error($db,$ecmdir->error); + exit; + } +} /******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + ********************************************************************/ /******************************************************************* -* PAGE -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ + * PAGE + * + * Put here all code to do according to value of "action" parameter + ********************************************************************/ llxHeader(); $form=new Form($db); - -print_fiche_titre($langs->trans("Search")); - -//$head = societe_prepare_head($societe); +$ecmdirstatic = new ECMDirectory($db); +$userstatic = new User($db); -//dol_fiche_head($head, 'document', $societe->nom); +// Ajout rubriques automatiques +$rowspan=0; +$sectionauto=array(); +if ($conf->produit->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>$conf->produit->enabled, 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } +if ($conf->societe->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); } +if ($conf->propal->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Prop"), 'desc'=>$langs->trans("ECMDocsByProposals")); } +if ($conf->contrat->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } +if ($conf->commande->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'supplier_order', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if ($conf->facture->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } +if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'supplier_invoice', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +//*********************** +// List +//*********************** +print_fiche_titre($langs->trans("ECMArea")); + +print $langs->trans("ECMAreaDesc")."
"; +print $langs->trans("ECMAreaDesc2")."
"; +print "
\n"; if ($mesg) { print $mesg."
"; } +// Tool bar +$head = ecm_prepare_head_fm($fac); +dol_fiche_head($head, 'search_form', '', 1); -print $langs->trans("FeatureNotYetAvailable"); + +print ''; + +print '
'; + +// Left area +print '
'; + + + +//print_fiche_titre($langs->trans("ECMSectionsManual")); + +print '
'; +print ''; +print ""; +print ''; +print "'; +print "'; +print "'; +print "'; +print "
'.$langs->trans("ECMSearchByKeywords").'
".$langs->trans("Ref").':
".$langs->trans("Title").':
".$langs->trans("Keyword").':
"; +//print $langs->trans("ECMSectionManualDesc"); + +//print_fiche_titre($langs->trans("ECMSectionAuto")); + +print '
'; +print ''; +print ""; +print ''; + +$buthtml=''; +$butshown=0; +foreach($sectionauto as $sectioncur) +{ + if (! $sectioncur['test']) continue; + //if ($butshown % 2 == 0) + print ''; + print "'; + print ''; + print ''; + print ''; + //if ($butshown % 2 == 1) + print ''; + $butshown++; +} +//if ($butshown % 2 == 1) +// print ''; + +print ''; +print "
'.$langs->trans("ECMSearchByEntity").'
".$sectioncur['label'].':
  
"; +//print $langs->trans("ECMSectionAutoDesc"); + + + +print '
'; + +print '
'; + +// Right area +$relativepath=$ecmdir->getRelativePath(); +$upload_dir = $conf->ecm->dir_output.'/'.$relativepath; +$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + +$formfile=new FormFile($db); +$param='&section='.$section; +$textifempty=($section?$langs->trans("NoFileFound"):$langs->trans("ECMSelectASection")); +$formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty); + +// print ''; + +// print '
'; + + + +print '
'; + + +print '
'; // End of page $db->close(); diff --git a/htdocs/includes/modules/modECM.class.php b/htdocs/includes/modules/modECM.class.php index b39d7caa295..8301dfd5fe4 100644 --- a/htdocs/includes/modules/modECM.class.php +++ b/htdocs/includes/modules/modECM.class.php @@ -18,23 +18,22 @@ */ /** \defgroup ecm Module ECM - \brief Module for ECM (Electronic Content Management) - \version $Id$ + * \brief Module for ECM (Electronic Content Management) + * \version $Id$ */ /** - \file htdocs/includes/modules/modECM.class.php - \ingroup ecm - \brief Description and activation file for module ECM -*/ + * \file htdocs/includes/modules/modECM.class.php + * \ingroup ecm + * \brief Description and activation file for module ECM + */ include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php"); /** \class modECM - \brief Description and activation class for module ECM -*/ - + * \brief Description and activation class for module ECM + */ class modECM extends DolibarrModules { @@ -149,6 +148,18 @@ class modECM extends DolibarrModules 'user'=>0); $r++; + $this->menu[$r]=array('fk_menu'=>'r=1', + 'type'=>'left', + 'titre'=>'ECMNewSection', + 'mainmenu'=>'ecm', + 'url'=>'/ecm/docdir.php?action=create', + 'langs'=>'ecm', + 'position'=>100, + 'perms'=>'$user->rights->ecm->setup', + 'target'=>'', + 'user'=>0); + $r++; + $this->menu[$r]=array('fk_menu'=>'r=1', 'type'=>'left', 'titre'=>'ECMFileManager', @@ -165,7 +176,7 @@ class modECM extends DolibarrModules 'type'=>'left', 'titre'=>'Search', 'mainmenu'=>'ecm', - 'url'=>'/ecm/index.php?action=search_form', + 'url'=>'/ecm/search.php', 'langs'=>'ecm', 'position'=>103, 'perms'=>'$user->rights->ecm->download', @@ -173,18 +184,6 @@ class modECM extends DolibarrModules 'user'=>0); $r++; - $this->menu[$r]=array('fk_menu'=>'r=1', - 'type'=>'left', - 'titre'=>'ECMNewSection', - 'mainmenu'=>'ecm', - 'url'=>'/ecm/docdir.php?action=create', - 'langs'=>'ecm', - 'position'=>100, - 'perms'=>'$user->rights->ecm->setup', - 'target'=>'', - 'user'=>0); - $r++; - } /** diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index ae166a87f97..fce24bd39cb 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -14,8 +14,8 @@ ECMNbOfDocsSmall=Nb of doc. ECMSection=Directory ECMSectionManual=Manual directory ECMSectionAuto=Automatic directory -ECMSectionsManual=Manual directories -ECMSectionsAuto=Automatic directories +ECMSectionsManual=Manual tree +ECMSectionsAuto=Automatic tree ECMSections=Directories ECMRoot=Root ECMNewSection=New directory diff --git a/htdocs/langs/fr_FR/ecm.lang b/htdocs/langs/fr_FR/ecm.lang index 9f57ead046a..2c25c00949c 100644 --- a/htdocs/langs/fr_FR/ecm.lang +++ b/htdocs/langs/fr_FR/ecm.lang @@ -14,8 +14,8 @@ ECMNbOfDocsSmall=Nb de doc. ECMSection=Répertoire ECMSectionManual=Répertoire manuel ECMSectionAuto=Répertoire automatique -ECMSectionsManual=Répertoires manuels -ECMSectionsAuto=Répertoires automatiques +ECMSectionsManual=Arborescence manuelle +ECMSectionsAuto=Arborescence automatique ECMSections=Répertoires ECMRoot=Racine ECMNewSection=Nouveau répertoire diff --git a/htdocs/lib/ecm.lib.php b/htdocs/lib/ecm.lib.php index 35e883742e5..3e5f6b523e6 100644 --- a/htdocs/lib/ecm.lib.php +++ b/htdocs/lib/ecm.lib.php @@ -57,7 +57,7 @@ function ecm_prepare_head_fm($fac) $head[$h][2] = 'file_manager'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/ecm/index.php?action=search_form'; + $head[$h][0] = DOL_URL_ROOT.'/ecm/search.php'; $head[$h][1] = $langs->trans('Search'); $head[$h][2] = 'search_form'; $h++;