2
0
forked from Wavyzz/dolibarr

Module GED accepte creation hierarchie de rpertoires et fichiers en upload.

This commit is contained in:
Laurent Destailleur
2008-04-28 21:19:01 +00:00
parent 19c68b75c2
commit 9d43f5ff0e
10 changed files with 512 additions and 278 deletions

View File

@@ -490,10 +490,10 @@ class Categorie
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_association";
dolibarr_syslog("Categorie::get_full_arbo sql=".$sql);
$res = $this->db->query ($sql);
if ($res)
$resql = $this->db->query ($sql);
if ($resql)
{
while ($obj= $this->db->fetch_object($res))
while ($obj= $this->db->fetch_object($resql))
{
$this->motherof[$obj->id_fille]=$obj->id_mere;
}
@@ -513,12 +513,12 @@ class Categorie
$sql.= " ORDER BY c.label, c.rowid";
dolibarr_syslog("Categorie::get_full_arbo sql=".$sql);
$res = $this->db->query ($sql);
if ($res)
$resql = $this->db->query($sql);
if ($resql)
{
$this->cats = array();
$i=0;
while ($obj = $this->db->fetch_object($res))
while ($obj = $this->db->fetch_object($resql))
{
$this->cats[$obj->rowid]['id'] = $obj->rowid;
@@ -556,40 +556,18 @@ class Categorie
$this->build_path_from_id_categ($key,0);
}
$this->cats=$this->sabsi($this->cats,'fulllabel', 'asc', true, false);
$this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
//$this->debug_cats();
return $this->cats;
}
/**
* \brief Advanced sort array by second index function, which produces
* ascending (default) or descending output and uses optionally
* natural case insensitive sorting (which can be optionally case
* sensitive as well).
*/
function sabsi ($array, $index, $order='asc', $natsort, $case_sensitive)
{
if (is_array($array) && count($array)>0)
{
foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index];
if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp);
else
{
($case_sensitive) ? natsort($temp) : natcasesort($temp);
if($order!='asc') $temp=array_reverse($temp,TRUE);
}
foreach(array_keys($temp) as $key) (is_numeric($key))? $sorted[]=$array[$key] : $sorted[$key]=$array[$key];
return $sorted;
}
return $array;
}
/**
* \brief Calcule les propri<72>t<EFBFBD>s fullpath et fulllabel d'une categorie
* du tableau this->cats et de toutes ces enfants
* \param id_categ id_categ entry to update
* \param protection Deep counter to avoid infinite loop
*/
function build_path_from_id_categ($id_categ,$protection=0)
{
@@ -606,6 +584,8 @@ class Categorie
$this->cats[$id_categ]['fullpath']='_'.$id_categ;
$this->cats[$id_categ]['fulllabel']=$this->cats[$id_categ]['label'];
}
// We count number of _ to have level
$this->cats[$id_categ]['level']=strlen(eregi_replace('[^_]','',$this->cats[$id_categ]['fullpath']));
// Traite ces enfants
$protection++;

View File

@@ -17,14 +17,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/categories/fiche.php
\ingroup category
\brief Page creation nouvelle categorie
\version $Id$
*/
require "./pre.inc.php";

View File

@@ -15,14 +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/categories/liste.php
\ingroup category
\brief Page liste des categories
\version $Id$
*/
require "./pre.inc.php";

View File

@@ -22,10 +22,11 @@
\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/htmlecm.form.class.php");
require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php");
// Load traductions files
@@ -37,6 +38,7 @@ $langs->load("orders");
$langs->load("propal");
$langs->load("bills");
$langs->load("contracts");
$langs->load("categories");
// Load permissions
$user->getrights('ecm');
@@ -54,7 +56,7 @@ $sortfield=$_GET["sortfield"];
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if (! $sortorder) $sortorder="DESC";
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="label";
$ecmdir = new ECMDirectory($db);
@@ -70,10 +72,10 @@ if (! empty($_GET["section"]))
/*******************************************************************
* 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
********************************************************************/
// Action ajout d'un produit ou service
if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
@@ -81,12 +83,13 @@ if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
$ecmdir->ref = $_POST["ref"];
$ecmdir->label = $_POST["label"];
$ecmdir->description = $_POST["desc"];
$ecmdir->fk_parent = $_POST["catParent"];
$id = $ecmdir->create($user);
if ($id > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
Header("Location: ".DOL_URL_ROOT.'/ecm/docmine.php?section='.$id);
exit;
}
else
@@ -107,16 +110,15 @@ if ($_POST['action'] == 'confirm_deletesection' && $_POST['confirm'] == 'yes')
/*******************************************************************
* 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);
$ecmdirstatic = new ECMDirectory($db);
$userstatic = new User($db);
$formecm=new FormEcm($db);
if ($_GET["action"] == 'create')
{
@@ -133,16 +135,20 @@ if ($_GET["action"] == 'create')
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>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="label" size="40" value="'.$ecmdir->label.'"></td></tr>'."\n";
print '<tr><td>'.$langs->trans ("AddIn").'</td><td>';
print $formecm->select_all_sections($ecmdir->parent,'catParent');
print '</td></tr>'."\n";
// 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 '</td></tr>'."\n";
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>'."\n";
print '</table>';
print '</form>';
@@ -155,146 +161,40 @@ if (! $_GET["action"] || $_GET["action"] == 'delete_section')
// List
//***********************
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
*/
// 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>';
// Construit fiche rubrique
$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>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=delete_section">'.$langs->trans('Delete').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('ECMAddSection').'</a>';
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
}
print '</div>';
}

View File

@@ -27,6 +27,7 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT."/ecm/ecmdirectory.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
// Load traductions files
@@ -85,10 +86,12 @@ if ( $_POST["sendit"] && $conf->upload != 0)
{
$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$result=$ecmdir->changeNbOfFiles('+');
}
else if (!$result)
{
// Echec transfert (fichier d?passant la limite ?)
// Echec transfert (fichier depassant la limite ?)
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
// print_r($_FILES);
}
@@ -104,8 +107,11 @@ if ( $_POST["sendit"] && $conf->upload != 0)
if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
{
$file = $upload_dir . "/" . urldecode($_GET["urlfile"]);
dol_delete_file($file);
$result=dol_delete_file($file);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
$result=$ecmdir->changeNbOfFiles('-');
}
@@ -123,11 +129,12 @@ llxHeader();
$form=new Form($db);
print_fiche_titre($langs->trans("ECMManualOrg"));
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 '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a>';
print ' -> <b>'.$ecmdir->getNomUrl(1).'</b>';
print "<br><br>";
@@ -215,34 +222,7 @@ print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"date","",$pa
print '<td>&nbsp;</td>';
print '</tr>';
function compare_file($a, $b)
{
global $sortorder;
global $sortfield;
$sortorder=strtoupper($sortorder);
if ($sortorder == 'ASC') { $retup=-1; $retdown=1; }
else { $retup=1; $retdown=-1; }
if ($sortfield == 'name')
{
if ($a->name == $b->name) return 0;
return ($a->name < $b->name) ? $retup : $retdown;
}
if ($sortfield == 'date')
{
if ($a->date == $b->date) return 0;
return ($a->date < $b->date) ? $retup : $retdown;
}
if ($sortfield == 'size')
{
if ($a->size == $b->size) return 0;
return ($a->size < $b->size) ? $retup : $retdown;
}
}
usort($filearray,"compare_file");
usort($filearray,"dol_compare_file");
$var=true;
foreach($filearray as $key => $file)

View File

@@ -51,7 +51,7 @@ class EcmDirectory // extends CommonObject
var $description;
var $tms;
var $cats=array();
/**
@@ -83,7 +83,7 @@ class EcmDirectory // extends CommonObject
if (! $this->cachenbofdoc) $this->cachenbofdoc=0;
$this->date_c=$now;
$this->fk_user_c=$user->id;
if ($this->fk_parent <= 0) $this->fk_parent=0;
// Check parameters
// Put here code to add control on parameters values
@@ -185,6 +185,34 @@ class EcmDirectory // extends CommonObject
}
/*
* \brief Update database
* \sign '+' or '-'
* \return int <0 if KO, >0 if OK
*/
function changeNbOfFiles($sign)
{
global $conf, $langs;
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET";
$sql.= " cachenbofdoc = cachenbofdoc ".$sign." 1";
$sql.= " WHERE rowid = ".$this->id;
dolibarr_syslog("Ecm_directories::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);
return -1;
}
return 1;
}
/*
* \brief Load object in memory from database
* \param id id object
@@ -262,7 +290,7 @@ class EcmDirectory // extends CommonObject
}
$file = $conf->ecm->dir_output . "/" . $this->label;
$result=dol_delete_dir($file);
$result=@dol_delete_dir($file);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
@@ -304,15 +332,169 @@ class EcmDirectory // extends CommonObject
$lien = '<a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$this->id.'">';
$lienfin='</a>';
//$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).$lienfin);
if ($withpicto) $result.=($lien.img_object($label,$picto,'',1).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
return $result;
}
/**
* \brief Load this->motherof array
* \return int <0 if KO, >0 if OK
*/
function load_motherof()
{
$this->motherof=array();
// Charge tableau des meres
$sql = "SELECT fk_parent as id_parent, rowid as id_son";
$sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories";
$sql.= " WHERE fk_parent != 0";
dolibarr_syslog("ECMDirectory::get_full_arbo sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj= $this->db->fetch_object($resql))
{
$this->motherof[$obj->id_son]=$obj->id_parent;
}
return 1;
}
else
{
dolibarr_print_error ($this->db);
return -1;
}
}
/**
* \brief Reconstruit l'arborescence des cat<61>gories sous la forme d'un tableau
* Renvoi un tableau de tableau('id','id_mere',...) tri<72> selon
* arbre et avec:
* id = id de la categorie
* id_mere = id de la categorie mere
* id_children = tableau des id enfant
* label = nom de la categorie
* fulllabel = nom avec chemin complet de la categorie
* fullpath = chemin complet compose des id
* \return array Tableau de array
*/
function get_full_arbo()
{
// Init this->motherof array
$this->load_motherof();
// Charge tableau des categories
$sql = "SELECT c.rowid as rowid, c.label as label,";
$sql.= " c.description as description, c.cachenbofdoc,";
$sql.= " c.fk_user_c,";
$sql.= " c.date_c,";
$sql.= " u.login as login_c,";
$sql.= " ca.rowid as rowid_fille";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."ecm_directories as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca";
$sql.= " ON c.rowid=ca.fk_parent";
$sql.= " WHERE c.fk_user_c = u.rowid";
$sql.= " ORDER BY c.label, c.rowid";
dolibarr_syslog("ECMDirectory::get_full_arbo sql=".$sql);
$resql = $this->db->query ($sql);
if ($resql)
{
$this->cats = array();
$i=0;
while ($obj = $this->db->fetch_object($resql))
{
$this->cats[$obj->rowid]['id'] = $obj->rowid;
$this->cats[$obj->rowid]['id_mere'] = $this->motherof[$obj->rowid];
$this->cats[$obj->rowid]['label'] = $obj->label;
$this->cats[$obj->rowid]['description'] = $obj->description;
$this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc;
$this->cats[$obj->rowid]['date_c'] = $obj->date_c;
$this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c;
$this->cats[$obj->rowid]['login_c'] = $obj->login_c;
if ($obj->rowid_fille)
{
if (is_array($this->cats[$obj->rowid]['id_children']))
{
$newelempos=sizeof($this->cats[$obj->rowid]['id_children']);
//print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>";
$this->cats[$obj->rowid]['id_children'][$newelempos]=$obj->rowid_fille;
}
else
{
//print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau<br>";
$this->cats[$obj->rowid]['id_children']=array($obj->rowid_fille);
}
}
$i++;
}
}
else
{
dolibarr_print_error ($this->db);
return -1;
}
// On ajoute la propriete fullpath a tous les <20>l<EFBFBD>ments
foreach($this->cats as $key => $val)
{
if (isset($motherof[$key])) continue;
$this->build_path_from_id_categ($key,0);
}
$this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
//$this->debug_cats();
return $this->cats;
}
/**
* \brief Calcule les propri<72>t<EFBFBD>s fullpath et fulllabel d'une categorie
* du tableau this->cats et de toutes ces enfants
* \param id_categ id_categ entry to update
* \param protection Deep counter to avoid infinite loop
*/
function build_path_from_id_categ($id_categ,$protection=0)
{
// Define fullpath
if (isset($this->cats[$id_categ]['id_mere']))
{
$this->cats[$id_categ]['fullpath'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
$this->cats[$id_categ]['fullpath'].='_'.$id_categ;
$this->cats[$id_categ]['fulllabel'] =$this->cats[$this->cats[$id_categ]['id_mere']]['fulllabel'];
$this->cats[$id_categ]['fulllabel'].=' >> '.$this->cats[$id_categ]['label'];
}
else
{
$this->cats[$id_categ]['fullpath']='_'.$id_categ;
$this->cats[$id_categ]['fulllabel']=$this->cats[$id_categ]['label'];
}
// We count number of _ to have level
$this->cats[$id_categ]['level']=strlen(eregi_replace('[^_]','',$this->cats[$id_categ]['fullpath']));
// Traite ces enfants
$protection++;
if ($protection > 20) return; // On ne traite pas plus de 20 niveaux
if (is_array($this->cats[$id_categ]['id_children']))
{
foreach($this->cats[$id_categ]['id_children'] as $key => $val)
{
$this->build_path_from_id_categ($val,$protection);
}
}
return;
}
}
?>

View File

@@ -40,13 +40,13 @@ $sortfield=$_GET["sortfield"];
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if (! $sortorder) $sortorder="DESC";
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="label";
$ecmdir = new ECMDirectory($db);
if (! empty($_GET["section"]))
if (! empty($_REQUEST["section"]))
{
$result=$ecmdir->fetch($_GET["section"]);
$result=$ecmdir->fetch($_REQUEST["section"]);
if (! $result > 0)
{
dolibarr_print_error($db,$ecmdir->error);
@@ -69,7 +69,6 @@ if ($_POST["action"] == 'add' && $user->rights->ecm->setup)
$ecmdir->description = $_POST["desc"];
$id = $ecmdir->create($user);
if ($id > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
@@ -152,6 +151,170 @@ if (! $_GET["action"] || $_GET["action"] == 'delete_section')
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>';
*/
}

View File

@@ -39,7 +39,8 @@ 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/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);
$menu->add_submenu(DOL_URL_ROOT."/ecm/docdir?mainmenu=ecm&action=create&idmenu=".$_SESSION["idmenu"], $langs->trans("ECMNewSection"),1,$user->rights->ecm->setup);

View File

@@ -10,8 +10,10 @@ DocsContracts=Documents contrats
DocsProposals=Documents propositions
DocsOrders=Documents commandes
DocsInvoices=Documents factures
ECMNbOfDocs=Nb de documents
ECMNbOfDocs=Nb doc
ECMSection=Rubrique
ECMSectionManual=Rubriques manuelles
ECMSectionAuto=Rubriques automatique
ECMSections=Rubriques
ECMRoot=Racine
ECMNewSection=Nouvelle rubrique
@@ -22,7 +24,7 @@ ECMCreationDate=Date cr
ECMCreationUser=Cr<43>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<6E>es automatiquement lors de l'ajout d'un document depuis une fiche objet.
ECMAreaDesc2=* Les rubriques automatiques sont aliment<6E>es automatiquement lors de l'ajout d'un document depuis une fiche objet.<br>* Les rubriques manuelles peuvent etre utilis<69>es pour stocker des documents li<6C>s <20> aucun <20>l<EFBFBD>ment particulier.
ECMSectionWasRemoved=La rubrique <b>%s</b> a <20>t<EFBFBD> effac<61>e.
ECMDocumentsSection=Document de la section
ECMSearchByKeywords=Recherche par mots cl<63>s
@@ -37,6 +39,7 @@ ECMDocsByContracts=Documents associ
ECMDocsByInvoices=Documents associ<63>s aux factures
ECMManualOrg=Rubrique manuelle
ECMAutoOrg=Rubrique automatique
ECMNoDirecotyYet=Aucune rubrique cr<63><72>e
ShowECMSection=Afficher rubrique
DeleteSection=Suppression rubrique
ConfirmDeleteSection=Confirmez-vous la suppression de la rubique <b>%s</b> ?

View File

@@ -3007,4 +3007,31 @@ function stopwithmem()
exit;
}
/**
* \brief Advanced sort array by second index function, which produces
* ascending (default) or descending output and uses optionally
* natural case insensitive sorting (which can be optionally case
* sensitive as well).
*/
function dol_sort_array($array, $index, $order='asc', $natsort, $case_sensitive)
{
// Clean parameters
$order=strtolower($order);
if (is_array($array) && count($array)>0)
{
foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index];
if (!$natsort) ($order=='asc') ? asort($temp) : arsort($temp);
else
{
($case_sensitive) ? natsort($temp) : natcasesort($temp);
if($order!='asc') $temp=array_reverse($temp,TRUE);
}
foreach(array_keys($temp) as $key) (is_numeric($key))? $sorted[]=$array[$key] : $sorted[$key]=$array[$key];
return $sorted;
}
return $array;
}
?>