Some enhancements in ecm module

This commit is contained in:
Laurent Destailleur 2008-04-29 23:49:00 +00:00
parent 24bb2ca1d4
commit 79306a55d3
10 changed files with 427 additions and 291 deletions

View File

@ -18,11 +18,11 @@
*/
/**
\file htdoc/ecm/index.php
\ingroup ecm
\brief Main page for ECM section area
\version $Id$
\author Laurent Destailleur
\file htdoc/ecm/docdir.php
\ingroup ecm
\brief Main page for ECM section area
\version $Id$
\author Laurent Destailleur
*/
require("./pre.inc.php");
@ -44,6 +44,7 @@ $langs->load("categories");
// Load permissions
$user->getrights('ecm');
// Get parameters
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
@ -81,22 +82,34 @@ if (! empty($_GET["section"]))
// Action ajout d'un produit ou service
if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
{
$ecmdir->ref = $_POST["ref"];
$ecmdir->label = $_POST["label"];
$ecmdir->description = $_POST["desc"];
$ecmdir->ref = trim($_POST["ref"]);
$ecmdir->label = trim($_POST["label"]);
$ecmdir->description = trim($_POST["desc"]);
$ecmdir->fk_parent = $_POST["catParent"];
$id = $ecmdir->create($user);
if ($id > 0)
$ok=true;
if (! $ecmdir->label)
{
Header("Location: ".DOL_URL_ROOT.'/ecm/docmine.php?section='.$id);
exit;
}
else
{
$mesg='<div class="error">Error '.$langs->trans($ecmdir->error).'</div>';
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")).'</div>';
$_GET["action"] = "create";
$ok=false;
}
if ($ok)
{
$id = $ecmdir->create($user);
if ($id > 0)
{
Header("Location: ".DOL_URL_ROOT.'/ecm/index.php');
exit;
}
else
{
$mesg='<div class="error">Error '.$langs->trans($ecmdir->error).'</div>';
$_GET["action"] = "create";
}
}
}
@ -186,7 +199,7 @@ if (! $_GET["action"] || $_GET["action"] == 'delete_section')
// Construit fiche rubrique
print $user->rights->ecm->setup;
// Actions buttons
print '<div class="tabsAction">';
if ($user->rights->ecm->setup)

View File

@ -39,6 +39,7 @@ $langs->load("other");
// Load permissions
$user->getrights('ecm');
// Security check
if ($user->societe_id > 0)
{
@ -99,9 +100,8 @@ if ( $_POST["sendit"] && $conf->upload != 0)
$result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']);
if ($result == 1)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$result=$ecmdir->changeNbOfFiles('+');
}
else if (!$result)
@ -118,7 +118,7 @@ if ( $_POST["sendit"] && $conf->upload != 0)
}
}
// Suppression fichier
// Remove file
if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
{
$file = $upload_dir . "/" . urldecode($_GET["urlfile"]);
@ -129,7 +129,21 @@ if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
$result=$ecmdir->changeNbOfFiles('-');
}
// Remove dir
if ($_POST['action'] == 'confirm_deletedir' && $_POST['confirm'] == 'yes')
{
$result=$ecmdir->delete($user);
header("Location: ".DOL_URL_ROOT."/ecm/index.php");
exit;
// $mesg = '<div class="ok">'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'</div>';
}
// Remove dir
if ($_POST['action'] == 'update' && ! $_POST['cancel'])
{
$ecmdir->description = $_POST["description"];
$result=$ecmdir->update($user);
}
@ -151,6 +165,12 @@ $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolowe
$head = ecm_prepare_head($ecmdir);
dolibarr_fiche_head($head, 'card', $langs->trans("ECMManualOrg"));
if ($_GET["action"] == 'edit')
{
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="section" value="'.$section.'">';
print '<input type="hidden" name="action" value="update">';
}
print '<table class="border" width="100%">';
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
@ -174,13 +194,19 @@ while ($tmpecmdir && $result > 0)
//print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a>';
print $s;
print '</td></tr>';
print '<tr><td>'.$langs->trans("Description").'</td><td>';
print dol_nl2br($ecmdir->description);
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
if ($_GET["action"] == 'edit')
{
print '<textarea class="flat" name="description" cols="80">';
print $ecmdir->description;
print '</textarea>';
}
else print dol_nl2br($ecmdir->description);
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMCreationUser").'</td><td>';
$user=new User($db,$ecmdir->fk_user_c);
$user->fetch();
print $user->getNomUrl(1);
$userecm=new User($db,$ecmdir->fk_user_c);
$userecm->fetch();
print $userecm->getNomUrl(1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMCreationDate").'</td><td>';
print dolibarr_print_date($ecmdir->date_c,'dayhour');
@ -200,22 +226,67 @@ foreach($filearray as $key => $file)
}
print dol_print_size($totalsize);
print '</td></tr>';
if ($_GET["action"] == 'edit')
{
print '<tr><td colspan="2" align="center">';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
}
print '</table>';
if ($_GET["action"] == 'edit')
{
print '</form>';
}
print '</div>';
// Actions buttons
if ($_GET["action"] != 'edit' && $_GET['action'] != 'delete_dir' && $_GET['action'] != 'delete_file')
{
print '<div class="tabsAction">';
if ($user->rights->ecm->setup)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&section='.$section.'">'.$langs->trans('Edit').'</a>';
}
if (sizeof($filearray) == 0)
{
if ($user->rights->ecm->setup)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete_dir&section='.$section.'">'.$langs->trans('Delete').'</a>';
}
else
{
print '<a class="butActionDeleteRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
}
}
else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("CannotRemoveDirectoryContainsFiles").'">'.$langs->trans('Delete').'</a>';
}
print '</div>';
}
/*
* Confirmation de la suppression d'une ligne produit
*/
if ($mesg) { print $mesg.'<br>'; }
// Confirm remove file
if ($_GET['action'] == 'delete_file')
{
$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
print '<br>';
}
if ($mesg) { print $mesg."<br>"; }
// Confirm remove file
if ($_GET['action'] == 'delete_dir')
{
$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"], $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection'), 'confirm_deletedir');
print '<br>';
}
// Affiche formulaire upload
$formfile=new FormFile($db);
@ -250,11 +321,13 @@ foreach($filearray as $key => $file)
print "</td>\n";
print '<td align="right">'.dol_print_size($file['size']).'</td>';
print '<td align="center">'.dolibarr_print_date($file['date'],"dayhour").'</td>';
print '<td align="center">';
echo '<a href="'.$url.'?section='.$_REQUEST["section"].'&amp;action=delete_file&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
print '<td align="right">';
//print '&nbsp;';
print '<a href="'.$url.'?section='.$_REQUEST["section"].'&amp;action=delete_file&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>';
print "</td></tr>\n";
}
}
if (sizeof($filearray) == 0) print '<tr '.$bc[$var].'><td colspan="4">'.$langs->trans("ECMNoFileFound").'</td></tr>';
print "</table>";
// Fin de zone Ajax

View File

@ -100,7 +100,7 @@ class EcmDirectory // extends CommonObject
$sql.= " '".$this->fk_user_c."'";
$sql.= ")";
dolibarr_syslog("Ecm_directories::create sql=".$sql, LOG_DEBUG);
dolibarr_syslog("EcmDirectories::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -120,7 +120,7 @@ class EcmDirectory // extends CommonObject
else
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Ecm_directories::create ".$this->error, LOG_ERR);
dolibarr_syslog("EcmDirectories::create ".$this->error, LOG_ERR);
return -1;
}
}
@ -136,13 +136,10 @@ class EcmDirectory // extends CommonObject
global $conf, $langs;
// Clean parameters
$this->label=trim($this->label);
$this->fk_parent=trim($this->fk_parent);
$this->description=trim($this->description);
// Check parameters
// Put here code to add control on parameters values
@ -151,18 +148,15 @@ class EcmDirectory // extends CommonObject
$sql.= " label='".addslashes($this->label)."',";
$sql.= " fk_parent='".$this->fk_parent."',";
$sql.= " description='".addslashes($this->description)."',";
$sql.= " tms=".$this->db->idate($this->tms)."";
$sql.= " description='".addslashes($this->description)."'";
$sql.= " WHERE rowid=".$this->id;
dolibarr_syslog("Ecm_directories::update sql=".$sql, LOG_DEBUG);
dolibarr_syslog("EcmDirectories::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Ecm_directories::update ".$this->error, LOG_ERR);
dolibarr_syslog("EcmDirectories::update ".$this->error, LOG_ERR);
return -1;
}
@ -195,12 +189,12 @@ class EcmDirectory // extends CommonObject
$sql.= " cachenbofdoc = cachenbofdoc ".$sign." 1";
$sql.= " WHERE rowid = ".$this->id;
dolibarr_syslog("Ecm_directories::changeNbOfFiles sql=".$sql, LOG_DEBUG);
dolibarr_syslog("EcmDirectories::changeNbOfFiles sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Ecm_directories::changeNbOfFiles ".$this->error, LOG_ERR);
dolibarr_syslog("EcmDirectories::changeNbOfFiles ".$this->error, LOG_ERR);
return -1;
}
@ -211,11 +205,10 @@ class EcmDirectory // extends CommonObject
/**
* \brief Load object in memory from database
* \param id id object
* \return int <0 if KO, >0 if OK
* \return int <0 if KO, 0 if not found, >0 if OK
*/
function fetch($id)
{
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.label,";
@ -229,14 +222,13 @@ class EcmDirectory // extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
$sql.= " WHERE t.rowid = ".$id;
dolibarr_syslog("Ecm_directories::fetch sql=".$sql, LOG_DEBUG);
dolibarr_syslog("EcmDirectories::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
@ -249,14 +241,15 @@ class EcmDirectory // extends CommonObject
$this->date_c = $obj->date_c;
$this->date_m = $obj->date_m;
}
$this->db->free($resql);
return 1;
return $obj?1:0;
}
else
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Ecm_directories::fetch ".$this->error, LOG_ERR);
dolibarr_syslog("EcmDirectories::fetch ".$this->error, LOG_ERR);
return -1;
}
}
@ -274,12 +267,12 @@ class EcmDirectory // extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
$sql.= " WHERE rowid=".$this->id;
dolibarr_syslog("Ecm_directories::delete sql=".$sql);
dolibarr_syslog("EcmDirectories::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Ecm_directories::delete ".$this->error, LOG_ERR);
dolibarr_syslog("EcmDirectories::delete ".$this->error, LOG_ERR);
return -1;
}
@ -329,11 +322,12 @@ class EcmDirectory // extends CommonObject
//$picto=DOL_URL_ROOT.'/theme/common/treemenu/folder.gif';
$picto='dir';
$label=$langs->trans("ShowECMSection").': '.$this->ref;
if ($withpicto) $result.=($lien.img_object($label,$picto,'',1).$lienfin);
$newref=eregi_replace('_',' ',$this->ref);
$newlabel=$langs->trans("ShowECMSection").': '.$newref;
if ($withpicto) $result.=($lien.img_object($newlabel,$picto,'',1).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
if ($withpicto != 2) $result.=$lien.$newref.$lienfin;
return $result;
}
@ -387,7 +381,7 @@ class EcmDirectory // extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories";
$sql.= " WHERE fk_parent != 0";
dolibarr_syslog("ECMDirectory::get_full_arbo sql=".$sql);
dolibarr_syslog("EcmDirectory::get_full_arbo sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
@ -415,10 +409,16 @@ class EcmDirectory // extends CommonObject
* label = nom de la categorie
* fulllabel = nom avec chemin complet de la categorie
* fullpath = chemin complet compose des id
* \param force Force reload of full arbo even if already loaded
* \return array Tableau de array
*/
function get_full_arbo()
function get_full_arbo($force=0)
{
if (empty($force) && $this->full_arbo_loaded)
{
return $this->cats;
}
// Init this->motherof array
$this->load_motherof();
@ -435,7 +435,7 @@ class EcmDirectory // extends CommonObject
$sql.= " WHERE c.fk_user_c = u.rowid";
$sql.= " ORDER BY c.label, c.rowid";
dolibarr_syslog("ECMDirectory::get_full_arbo sql=".$sql);
dolibarr_syslog("EcmDirectory::get_full_arbo sql=".$sql);
$resql = $this->db->query ($sql);
if ($resql)
{
@ -484,8 +484,7 @@ class EcmDirectory // extends CommonObject
}
$this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
//$this->debug_cats();
$this->full_arbo_loaded=1;
return $this->cats;
}
@ -525,7 +524,40 @@ class EcmDirectory // extends CommonObject
}
}
return;
return 1;
}
/**
* \brief refresh cachenboffile
* \param directory Directory to scan
* \return int <0 if ko, >0 if OK
*/
function refreshcachenboffile()
{
global $conf;
include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php');
$dir=$conf->ecm->dir_output.'/'.$this->getRelativePath();
$filelist=dol_dir_list($dir,'files',0,'','\.meta$');
// Test if filelist is in database
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
$sql.= " cachenbofdoc='".sizeof($filelist)."'";
$sql.= " WHERE rowid=".$this->id;
dolibarr_syslog("EcmDirectories::refreshcachenboffile sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("EcmDirectories::refreshcachenboffile ".$this->error, LOG_ERR);
return -1;
}
return 1;
}
}
?>

View File

@ -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.
*/
/**
@ -103,220 +117,218 @@ $form=new Form($db);
$ecmdirstatic = new ECMDirectory($db);
$userstatic = new User($db);
if (! $_GET["action"] || $_GET["action"] == 'delete_section')
//***********************
// List
//***********************
print_fiche_titre($langs->trans("ECMArea"));
print $langs->trans("ECMAreaDesc")."<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/search.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/search.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>';
//***********************
// Files
//***********************
print_fiche_titre($langs->trans("ECMSectionOfDocuments"));
//print '<br>';
// Confirmation de la suppression d'une ligne categorie
if ($_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/search.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/search.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>';
//***********************
// Files
//***********************
print_fiche_titre($langs->trans("ECMSectionOfDocuments"));
//print '<br>';
/*
$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>';
}
if ($mesg) { print $mesg."<br>"; }
// Construit liste des répertoires
print '<table width="100%" class="noborder">';
// Ajout rubriques automatiques
$sectionauto=array();
if ($conf->societe->enabled) $sectionauto[]=array('test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties"));
if ($conf->propal->enabled) $sectionauto[]=array('test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals"));
if ($conf->commande->enabled) $sectionauto[]=array('test'=>$conf->commande->enabled,'label'=>$langs->trans("Orders"), 'desc'=>$langs->trans("ECMDocsByOrders"));
if ($conf->contrat->enabled) $sectionauto[]=array('test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts"));
if ($conf->facture->enabled) $sectionauto[]=array('test'=>$conf->facture->enabled, 'label'=>$langs->trans("Invoices"), 'desc'=>$langs->trans("ECMDocsByInvoices"));
if (sizeof($sectionauto))
{
// Automatic sections
print '<tr class="liste_titre">';
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSectionAuto").'</td>';
print '<td class="liste_titre" align="left">'.$langs->trans("Description").'</td>';
print '<td class="liste_titre" align="left">'.$langs->trans("ECMCreationUser").'</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("ECMNbOfDocs").'</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '</tr>';
$sectionauto=dol_sort_array($sectionauto,'label',$sortorder,true,false);
$var=true;
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";
// Description
print '<td align="left">'.$val['desc'].'</td>';
print '<td align="left">'.$langs->trans("ECMTypeAuto").'</td>';
print '<td align="center">&nbsp;</td>';
print '<td align="right">?</td>';
print '<td align="right">&nbsp;</td>';
print "</tr>\n";
}
}
}
// Manual sections
print '<tr class="liste_titre">';
$param='&amp;socid='.$socid;
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSectionManual").'</td>';
print '<td class="liste_titre" align="left">'.$langs->trans("Description").'</td>';
print '<td class="liste_titre" align="left">'.$langs->trans("ECMCreationUser").'</td>';
print '<td class="liste_titre" align="center">'.$langs->trans("ECMCreationDate").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("ECMNbOfDocs").'</td>';
print '<td class="liste_titre" align="center">&nbsp;</td>';
print '</tr>';
$ecmdirstatic = new ECMDirectory($db);
$rub=$ecmdirstatic->get_full_arbo();
$userstatic = new User($db);
$nbofentries=0;
$var=true;
foreach($rub as $key => $val)
{
$var=!$var;
$ecmdirstatic->id=$val['id'];
$ecmdirstatic->ref=$val['label'];
print '<tr '.$bc[$var].'>';
// Section
print '<td align="left">';
print str_repeat(' &nbsp; &nbsp; ',$val['level']-1);
print $ecmdirstatic->getNomUrl(1);
print "</td>\n";
// Description
print '<td align="left">'.dolibarr_trunc($val['description'],32).'</td>';
$userstatic->id=$val['fk_user_c'];
$userstatic->nom=$val['login_c'];
print '<td align="left">'.$userstatic->getNomUrl(1).'</td>';
print '<td align="center">'.dolibarr_print_date($val['date_c'],"dayhour").'</td>';
// Nb of docs
//print '<td align="right">'.$obj->cachenbofdoc.'</td>';
print '<td align="right">'.$val['cachenbofdoc'].'</td>';
print '<td align="right">';
if ($val['cachenbofdoc'] == 0 && $val['level'] >= $rub[$key+1]['level'])
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&section='.urlencode($val['id']).'">'.img_delete().'</a>';
}
else
{
print '&nbsp;';
}
print "</td></tr>\n";
$nbofentries++;
}
// If nothing to show
if ($nbofentries == 0)
{
print '<tr '.$bc[false].'><td colspan="6">'.$langs->trans("ECMNoDirecotyYet").'</td></tr>';
}
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>';
*/
$form->form_confirm($_SERVER["PHP_SELF"].'?section='.urldecode($_GET["section"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection');
print '<br>';
}
if ($mesg) { print $mesg."<br>"; }
// Construit liste des répertoires
print '<table width="100%" class="noborder">';
// Ajout rubriques automatiques
$sectionauto=array();
if ($conf->societe->enabled) $sectionauto[]=array('test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties"));
if ($conf->propal->enabled) $sectionauto[]=array('test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals"));
if ($conf->commande->enabled) $sectionauto[]=array('test'=>$conf->commande->enabled,'label'=>$langs->trans("Orders"), 'desc'=>$langs->trans("ECMDocsByOrders"));
if ($conf->contrat->enabled) $sectionauto[]=array('test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts"));
if ($conf->facture->enabled) $sectionauto[]=array('test'=>$conf->facture->enabled, 'label'=>$langs->trans("Invoices"), 'desc'=>$langs->trans("ECMDocsByInvoices"));
if (sizeof($sectionauto))
{
// Automatic sections
print '<tr class="liste_titre">';
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSectionAuto").'</td>';
print '<td class="liste_titre" align="left">'.$langs->trans("Description").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("ECMNbOfDocsSmall").'</td>';
print '<td class="liste_titre">';
print '&nbsp;';
print '</td>';
print '</tr>';
$sectionauto=dol_sort_array($sectionauto,'label',$sortorder,true,false);
$var=true;
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";
// Description
print '<td align="left">'.$val['desc'].'</td>';
print '<td align="right">?</td>';
print '<td align="right">';
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMAutoOrg").'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$langs->trans("ECMTypeAuto");
print $form->textwithhelp('',$htmltooltip,1,0);
print '</td>';
print "</tr>\n";
}
}
}
// Manual sections
print '<tr class="liste_titre">';
$param='&amp;socid='.$socid;
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSectionManual").'</td>';
print '<td class="liste_titre" align="left">'.$langs->trans("Description").'</td>';
print '<td class="liste_titre" align="right">'.$langs->trans("ECMNbOfDocsSmall");
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshauto">'.img_picto($langs->trans("Refresh"),'refresh').'</a>';
print '</td>';
print '<td class="liste_titre" align="right">';
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir?action=create">'.img_picto($langs->trans("ECMNewSection"),'edit_add').'</a>';
print '</td>';
print '</tr>';
$ecmdirstatic = new ECMDirectory($db);
$rub=$ecmdirstatic->get_full_arbo();
$userstatic = new User($db);
$nbofentries=0;
$var=true;
foreach($rub as $key => $val)
{
$var=!$var;
$ecmdirstatic->id=$val['id'];
$ecmdirstatic->ref=$val['label'];
// Refresh cache
if ($_GET['action'] == 'refreshauto')
{
$result=$ecmdirstatic->fetch($val['id']);
$result=$ecmdirstatic->refreshcachenboffile();
$ecmdirstatic->ref=$ecmdirstatic->label;
}
print '<tr '.$bc[$var].'>';
// Section
print '<td align="left">';
print str_repeat(' &nbsp; &nbsp; ',$val['level']-1);
print $ecmdirstatic->getNomUrl(1);
print "</td>\n";
// Description
print '<td align="left">'.dolibarr_trunc($val['description'],32).'</td>';
// Nb of docs
//print '<td align="right">'.$obj->cachenbofdoc.'</td>';
print '<td align="right">'.$val['cachenbofdoc'].'</td>';
print '<td align="right">';
$userstatic->id=$val['fk_user_c'];
$userstatic->nom=$val['login_c'];
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMManualOrg").'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1).'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dolibarr_print_date($val['date_c'],"dayhour");
print $form->textwithhelp('',$htmltooltip,1,0);
print "</td></tr>\n";
$nbofentries++;
}
// If nothing to show
if ($nbofentries == 0)
{
print '<tr '.$bc[false].'><td colspan="6">'.$langs->trans("ECMNoDirecotyYet").'</td></tr>';
}
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();

View File

@ -39,7 +39,6 @@ function llxHeader($head = "", $title="", $help_url='')
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/ecm/index.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("MenuECM"),0,$user->rights->ecm->read);
//$menu->add_submenu(DOL_URL_ROOT."/ecm/docdir.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("List"),1,$user->rights->ecm->read);
$menu->add_submenu(DOL_URL_ROOT."/ecm/index.php?mainmenu=ecm&idmenu=".$_SESSION["idmenu"], $langs->trans("List"),1,$user->rights->ecm->read);
//$menu->add_submenu(DOL_URL_ROOT."/ecm/index?mainmenu=ecm&action=create&idmenu=".$_SESSION["idmenu"], $langs->trans("ECMNewDocument"),1,$user->rights->ecm->create);

View File

@ -8,7 +8,8 @@ DocsContracts=Documents contracts
DocsProposals=Documents proposals
DocsOrders=Documents orders
DocsInvoices=Documents invoices
ECMNbOfDocs=Nb doc
ECMNbOfDocs=Nb of documents in directory
ECMNbOfDocsSmall=Nb of doc.
ECMSection=Directory
ECMSectionManual=Manual directory
ECMSectionAuto=Automatic directory
@ -41,4 +42,6 @@ ECMNoDirecotyYet=No directory created
ShowECMSection=Show directory
DeleteSection=Remove directory
ConfirmDeleteSection=Can you confirm you want to delete the directory <b>%s</b> ?
ECMDirectoryForFiles=Relative directory for files
ECMDirectoryForFiles=Relative directory for files
CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files
ECMNoFileFound=No documents saved in this directory

View File

@ -8,7 +8,8 @@ DocsContracts=Documents contrats
DocsProposals=Documents propositions
DocsOrders=Documents commandes
DocsInvoices=Documents factures
ECMNbOfDocs=Nb doc
ECMNbOfDocs=Nb de documents de la rubrique
ECMNbOfDocsSmall=Nb de doc.
ECMSection=Rubrique
ECMSectionManual=Rubriques manuelles
ECMSectionAuto=Rubriques automatique
@ -22,7 +23,7 @@ ECMCreationDate=Date cr
ECMCreationUser=Créateur
ECMArea=Espace GED
ECMAreaDesc=L'espace GED (Gestion Electronique de Documents) vous permet de stocker dans Dolibarr et retrouver rapidement tout type de documents.
ECMAreaDesc2=* Les rubriques automatiques sont alimentées automatiquement lors de l'ajout d'un document depuis une fiche objet (propal, facture, commande...).<br>* Les rubriques manuelles peuvent etre utilisées pour stocker des documents divers, non liés à un objet particulier.
ECMAreaDesc2=* Les rubriques automatiques sont alimentées automatiquement lors de l'ajout d'un document depuis une fiche objet (propal, facture...).<br>* Les rubriques manuelles peuvent etre utilisées pour stocker des documents divers, non liés à un objet particulier.
ECMSectionWasRemoved=La rubrique <b>%s</b> a été effacée.
ECMDocumentsSection=Document de la section
ECMSearchByKeywords=Recherche par mots clés
@ -40,5 +41,7 @@ ECMAutoOrg=Rubrique automatique
ECMNoDirecotyYet=Aucune rubrique créée
ShowECMSection=Afficher rubrique
DeleteSection=Suppression rubrique
ConfirmDeleteSection=Confirmez-vous la suppression de la rubique <b>%s</b> ?
ECMDirectoryForFiles=Répertoire relatif pour les fichiers
ConfirmDeleteSection=Confirmez-vous la suppression de la rubrique <b>%s</b> ?
ECMDirectoryForFiles=Répertoire relatif pour les fichiers
CannotRemoveDirectoryContainsFiles=Suppression impossible car des fichiers sont présents
ECMNoFileFound=Pas de documents stockés dans cette rubrique

View File

@ -32,7 +32,7 @@
\param $exludefilter Regex for exclude filter (example: '\.meta$')
\param $sortcriteria Sort criteria ("name","date","size")
\param $sortorder Sort order (SORT_ASC, SORT_DESC)
\param $mode 0=Return array of key need, 1=Force all key to be loaded
\param $mode 0=Return array with only keys needed, 1=Force all keys to be loaded
\return array Array of array('name'=>xxx,'date'=>yyy,'size'=>zzz)
*/
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)

View File

@ -252,6 +252,7 @@ alter table llx_tva modify fk_bank integer;
delete from llx_const where name='MAIN_USE_PREVIEW_TABS';
drop table if exists llx_ecm_directories;
create table llx_ecm_directories
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
@ -259,8 +260,8 @@ create table llx_ecm_directories
fk_parent integer,
description varchar(255) NOT NULL,
cachenbofdoc integer NOT NULL DEFAULT 0,
date_c timestamp,
date_m datetime,
date_c datetime,
date_m timestamp,
fk_user_c integer,
fk_user_m integer
) type=innodb;

View File

@ -27,8 +27,8 @@ create table llx_ecm_directories
fk_parent integer,
description varchar(255) NOT NULL,
cachenbofdoc integer NOT NULL DEFAULT 0,
date_c timestamp,
date_m datetime,
date_c datetime,
date_m timestamp,
fk_user_c integer,
fk_user_m integer
) type=innodb;