dolibarr/htdocs/ecm/index.php

835 lines
29 KiB
PHP
Raw Normal View History

2008-02-19 22:04:23 +01:00
<?php
2014-01-26 18:43:30 +01:00
/* Copyright (C) 2008-2014 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2008-2010 Regis Houssin <regis.houssin@capnetworks.com>
2008-04-30 01:49:00 +02:00
*
* 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 3 of the License, or
2008-04-30 01:49:00 +02:00
* (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
2011-08-01 01:45:11 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2008-02-19 22:04:23 +01:00
*/
/**
2008-11-09 13:33:13 +01:00
* \file htdocs/ecm/index.php
* \ingroup ecm
* \brief Main page for ECM section area
* \author Laurent Destailleur
*/
2008-02-19 22:04:23 +01:00
2010-11-02 10:10:43 +01:00
if (! defined('REQUIRE_JQUERY_LAYOUT')) define('REQUIRE_JQUERY_LAYOUT','1');
if (! defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1);
2010-11-02 10:10:43 +01:00
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
2008-02-19 22:04:23 +01:00
// 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");
2008-02-19 22:04:23 +01:00
2009-04-28 08:49:44 +02:00
// Security check
if ($user->societe_id) $socid=$user->societe_id;
2011-03-28 10:41:37 +02:00
$result = restrictedArea($user, 'ecm', 0);
2009-04-28 08:49:44 +02:00
2008-02-19 22:04:23 +01:00
// Get parameters
2012-02-27 22:26:22 +01:00
$socid=GETPOST('socid','int');
$action=GETPOST("action");
2012-03-25 22:47:37 +02:00
$section=GETPOST("section")?GETPOST("section","int"):GETPOST("section_id","int");
2011-04-17 20:41:26 +02:00
$module=GETPOST("module");
if (! $section) $section=0;
2013-11-17 02:59:01 +01:00
$section_dir=GETPOST('section_dir');
2008-02-19 22:04:23 +01:00
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="fullname";
2013-07-14 01:21:00 +02:00
if ($module == 'invoice_supplier' && $sortfield == "fullname") $sortfield="level1name";
2011-11-23 15:19:44 +01:00
$ecmdir = new EcmDirectory($db);
2012-03-25 22:47:37 +02:00
if ($section)
{
2012-03-25 22:47:37 +02:00
$result=$ecmdir->fetch($section);
if (! $result > 0)
{
dol_print_error($db,$ecmdir->error);
exit;
}
}
2008-02-19 22:04:23 +01:00
$form=new Form($db);
2011-11-23 15:19:44 +01:00
$ecmdirstatic = new EcmDirectory($db);
$userstatic = new User($db);
2012-08-04 02:20:51 +02:00
$error=0;
2008-02-19 22:04:23 +01:00
2012-03-24 15:20:49 +01:00
/*
* Actions
*/
// Upload file
if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
2012-03-25 22:47:37 +02:00
// Define relativepath and upload_dir
$relativepath='';
if ($ecmdir->id) $relativepath=$ecmdir->getRelativePath();
2013-11-17 02:59:01 +01:00
else $relativepath=$section_dir;
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
2009-01-18 11:42:58 +01:00
2012-08-04 02:20:51 +02:00
if (empty($_FILES['userfile']['tmp_name']))
{
2012-08-04 02:20:51 +02:00
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("File")), 'errors');
}
if (! $error)
{
if (dol_mkdir($upload_dir) >= 0)
{
2012-08-04 02:20:51 +02:00
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),0, 0, $_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
2012-08-04 02:20:51 +02:00
//$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
//print_r($_FILES);
$result=$ecmdir->changeNbOfFiles('+');
}
2012-08-04 02:20:51 +02:00
else
{
2012-08-04 02:20:51 +02:00
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
setEventMessage($langs->trans("ErrorFileNotUploaded"), 'errors');
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
setEventMessage($langs->trans("ErrorFileIsInfectedWithAVirus"), 'errors');
}
else // Known error
{
setEventMessage($langs->trans($resupload), 'errors');
}
}
}
2012-08-04 02:20:51 +02:00
else
{
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFailToCreateDir",$upload_dir).'</div>';
}
}
}
2012-03-25 22:47:37 +02:00
// Add directory
2012-03-25 22:47:37 +02:00
if ($action == 'add' && $user->rights->ecm->setup)
2008-02-19 22:04:23 +01:00
{
$ecmdir->ref = 'NOTUSEDYET';
$ecmdir->label = GETPOST("label");
$ecmdir->description = GETPOST("desc");
$id = $ecmdir->create($user);
if ($id > 0)
{
2012-08-31 05:58:38 +02:00
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
$mesg='<div class="error">Error '.$langs->trans($ecmdir->error).'</div>';
2012-02-08 18:07:55 +01:00
$action = "create";
}
2012-03-25 22:47:37 +02:00
clearstatcache();
2008-02-19 22:04:23 +01:00
}
// Remove file
if ($action == 'confirm_deletefile')
{
if (GETPOST('confirm') == 'yes')
{
2013-11-17 02:59:01 +01:00
$langs->load("other");
if ($section)
{
2013-11-17 02:59:01 +01:00
$result=$ecmdir->fetch($section);
if (! ($result > 0))
{
dol_print_error($db,$ecmdir->error);
exit;
}
$relativepath=$ecmdir->getRelativePath();
}
2013-11-17 02:59:01 +01:00
else $relativepath='';
$upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:'');
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
$ret=dol_delete_file($file);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
2012-07-29 15:47:24 +02:00
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
$result=$ecmdir->changeNbOfFiles('-');
2012-03-25 22:47:37 +02:00
clearstatcache();
}
$action='file_manager';
}
// Remove directory
2012-02-08 18:07:55 +01:00
if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes')
2008-02-19 22:04:23 +01:00
{
$result=$ecmdir->delete($user);
$mesg = '<div class="ok">'.$langs->trans("ECMSectionWasRemoved", $ecmdir->label).'</div>';
2012-03-25 22:47:37 +02:00
clearstatcache();
2008-02-19 22:04:23 +01:00
}
// Refresh directory view
2012-02-08 18:07:55 +01:00
if ($action == 'refreshmanual')
{
$ecmdirtmp = new EcmDirectory($db);
// This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate
clearstatcache();
2012-03-25 22:47:37 +02:00
$diroutputslash=str_replace('\\','/',$conf->ecm->dir_output);
$diroutputslash.='/';
// Scan directory tree on disk
$disktree=dol_dir_list($conf->ecm->dir_output,'directories',1,'','^temp$','','',0);
2008-02-19 22:04:23 +01:00
// Scan directory tree in database
$sqltree=$ecmdirstatic->get_full_arbo(0);
$adirwascreated=0;
// Now we compare both trees to complete missing trees into database
//var_dump($disktree);
//var_dump($sqltree);
2012-06-02 18:55:04 +02:00
foreach($disktree as $dirdesc) // Loop on tree onto disk
{
$dirisindatabase=0;
foreach($sqltree as $dirsqldesc)
{
if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname'])
{
$dirisindatabase=1;
break;
}
}
if (! $dirisindatabase)
{
$txt="Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
dol_syslog($txt);
//print $txt."<br>\n";
// We must first find the fk_parent of directory to create $dirdesc['fullname']
$fk_parent=-1;
$relativepathmissing=str_replace($diroutputslash,'',$dirdesc['fullname']);
$relativepathtosearchparent=$relativepathmissing;
//dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
if (preg_match('/\//',$relativepathtosearchparent))
//while (preg_match('/\//',$relativepathtosearchparent))
{
$relativepathtosearchparent=preg_replace('/\/[^\/]*$/','',$relativepathtosearchparent);
$txt="Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
dol_syslog($txt);
//print $txt." -> ";
$parentdirisindatabase=0;
foreach($sqltree as $dirsqldesc)
{
if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent)
{
$parentdirisindatabase=$dirsqldesc['id'];
break;
}
}
if ($parentdirisindatabase > 0)
{
dol_syslog("Yes with id ".$parentdirisindatabase);
//print "Yes with id ".$parentdirisindatabase."<br>\n";
$fk_parent=$parentdirisindatabase;
//break; // We found parent, we can stop the while loop
}
else
{
dol_syslog("No");
//print "No<br>\n";
}
}
else
{
dol_syslog("Parent is root");
$fk_parent=0; // Parent is root
}
if ($fk_parent >= 0)
{
$ecmdirtmp->ref = 'NOTUSEDYET';
$ecmdirtmp->label = dol_basename($dirdesc['fullname']);
$ecmdirtmp->description = '';
$ecmdirtmp->fk_parent = $fk_parent;
$txt="We create directory ".$ecmdirtmp->label." with parent ".$fk_parent;
dol_syslog($txt);
//print $ecmdirtmp->cachenbofdoc."<br>\n";exit;
$id = $ecmdirtmp->create($user);
if ($id > 0)
{
$newdirsql=array('id'=>$id,
'id_mere'=>$ecmdirtmp->fk_parent,
'label'=>$ecmdirtmp->label,
'description'=>$ecmdirtmp->description,
'fullrelativename'=>$relativepathmissing);
$sqltree[]=$newdirsql; // We complete fulltree for following loops
//var_dump($sqltree);
$adirwascreated=1;
}
else
{
dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
}
}
else {
$txt="Parent of ".$dirdesc['fullname']." not found";
dol_syslog($txt);
//print $txt."<br>\n";
}
}
}
// Loop now on each sql tree to check if dir exists
foreach($sqltree as $dirdesc) // Loop on each sqltree to check dir is on disk
{
$dirtotest=$conf->ecm->dir_output.'/'.$dirdesc['fullrelativename'];
if (! dol_is_dir($dirtotest))
{
$mesg.=$dirtotest." not found onto disk. We delete from database dir with id=".$dirdesc['id']."<br>\n";
$ecmdirtmp->id=$dirdesc['id'];
$ecmdirtmp->delete($user,'databaseonly');
//exit;
}
}
$sql="UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cahce counting, we set to value -1 = "unknown"
dol_syslog("sql = ".$sql);
2012-06-02 18:55:04 +02:00
$db->query($sql);
// If a directory was added, the fulltree array is not correctly completed and sorted, so we clean
// it to be sure that fulltree array is not used without reloading it.
if ($adirwascreated) $sqltree=null;
}
2008-02-19 22:04:23 +01:00
2012-03-24 15:20:49 +01:00
/*
* View
*/
//print "xx".$_SESSION["dol_screenheight"];
2010-12-13 12:36:22 +01:00
$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500)?($_SESSION["dol_screenheight"]-166):660;
$morejs=array();
2012-07-30 21:44:00 +02:00
if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs=array("/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js");
$moreheadcss="
2011-07-06 13:40:21 +02:00
<!-- dol_screenheight=".$_SESSION["dol_screenheight"]." -->
<style type=\"text/css\">
2010-08-26 04:45:48 +02:00
#containerlayout {
2010-12-01 22:16:28 +01:00
height: ".$maxheightwin."px;
2010-08-26 04:45:48 +02:00
margin: 0 auto;
width: 100%;
min-width: 700px;
_width: 700px; /* min-width for IE6 */
}
2011-07-06 13:40:21 +02:00
</style>";
$moreheadjs=empty($conf->use_javascript_ajax)?"":"
2011-07-06 13:40:21 +02:00
<script type=\"text/javascript\">
2010-08-26 04:45:48 +02:00
jQuery(document).ready(function () {
jQuery('#containerlayout').layout({
name: \"ecmlayout\"
, paneClass: \"ecm-layout-pane\"
2011-10-26 15:04:37 +02:00
, resizerClass: \"ecm-layout-resizer\"
, togglerClass: \"ecm-layout-toggler\"
, center__paneSelector: \"#ecm-layout-center\"
2010-11-02 10:48:05 +01:00
, north__paneSelector: \"#ecm-layout-north\"
, west__paneSelector: \"#ecm-layout-west\"
2010-08-27 22:48:55 +02:00
, resizable: true
2012-03-26 03:09:35 +02:00
, north__size: 32
2010-08-26 04:45:48 +02:00
, north__resizable: false
, north__closable: false
2011-04-02 11:24:15 +02:00
, west__size: 340
2010-08-26 04:45:48 +02:00
, west__minSize: 280
, west__slidable: true
, west__resizable: true
, west__togglerLength_closed: '100%'
, useStateCookie: true
2010-08-26 04:45:48 +02:00
});
2010-08-27 22:48:55 +02:00
2010-11-02 10:48:05 +01:00
jQuery('#ecm-layout-center').layout({
center__paneSelector: \".ecm-in-layout-center\"
, south__paneSelector: \".ecm-in-layout-south\"
2010-08-27 22:48:55 +02:00
, resizable: false
, south__minSize: 32
2010-08-27 22:48:55 +02:00
, south__resizable: false
, south__closable: false
});
2010-08-26 04:45:48 +02:00
});
2011-07-06 13:40:21 +02:00
</script>";
llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECMArea"),'','','','',$morejs,'',0,0);
2010-08-26 04:45:48 +02:00
2008-02-19 22:04:23 +01:00
// Add sections to manage
2008-05-04 15:33:49 +02:00
$rowspan=0;
$sectionauto=array();
2014-01-26 18:43:30 +01:00
if (! empty($conf->global->ECM_AUTO_TREE_ENABLED))
{
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); }
if (! empty($conf->societe->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); }
if (! empty($conf->propal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Prop"), 'desc'=>$langs->trans("ECMDocsByProposals")); }
if (! empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); }
if (! empty($conf->commande->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
if (! empty($conf->facture->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
2014-01-26 18:43:30 +01:00
if (! empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBySocialContributions")); }
2013-11-17 02:59:01 +01:00
if (! empty($conf->projet->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsByProjects")); }
}
2011-01-10 01:09:31 +01:00
print_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"));
2008-04-30 01:49:00 +02:00
print '<div class="hideonsmartphone">';
2008-04-30 01:49:00 +02:00
print $langs->trans("ECMAreaDesc")."<br>";
print $langs->trans("ECMAreaDesc2")."<br>";
print "<br>\n";
print '</div>';
2008-04-30 01:49:00 +02:00
2012-10-27 00:23:16 +02:00
// Confirm remove file (for non javascript users)
if ($action == 'delete' && empty($conf->use_javascript_ajax))
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1);
2013-11-07 02:56:56 +01:00
}
2008-09-02 15:15:25 +02:00
2011-07-18 03:44:15 +02:00
dol_htmloutput_mesg($mesg);
2008-09-02 15:15:25 +02:00
2010-08-26 04:45:48 +02:00
if (! empty($conf->use_javascript_ajax)) $classviewhide='hidden';
else $classviewhide='visible';
// Start container of all panels
2010-08-26 04:45:48 +02:00
?>
<div id="containerlayout"> <!-- begin div id="containerlayout" -->
2012-12-29 23:40:16 +01:00
<div id="ecm-layout-north" class="toolbar largebutton">
2010-08-26 04:45:48 +02:00
<?php
// Start top panel, toolbar
print '<div class="toolbarbutton">';
// Toolbar
if ($user->rights->ecm->setup)
{
2012-03-24 15:20:49 +01:00
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create" class="toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
else
{
2012-03-24 15:20:49 +01:00
print '<a href="#" class="toolbarbutton" title="'.$langs->trans("NotAllowed").'">';
print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'')));
print '<a href="'.$url.'" class="toolbarbutton" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
2010-08-26 04:45:48 +02:00
print '</a>';
2010-08-26 01:27:44 +02:00
print '</div>';
// End top panel, toolbar
2010-08-26 04:45:48 +02:00
?>
</div>
<div id="ecm-layout-west" class="<?php echo $classviewhide; ?>">
2010-08-26 04:45:48 +02:00
<?php
// Start left area
2010-08-12 00:22:17 +02:00
// Confirmation de la suppression d'une ligne categorie
if ($action == 'delete_section')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
2013-11-07 02:56:56 +01:00
}
// End confirm
2008-05-04 15:33:49 +02:00
if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete')
2008-04-30 01:49:00 +02:00
{
2008-09-02 02:27:05 +02:00
print '<table width="100%" class="nobordernopadding">';
2011-06-22 00:48:40 +02:00
print '<tr class="liste_titre">';
2010-08-12 00:22:17 +02:00
print '<td class="liste_titre" align="left" colspan="6">';
print '&nbsp;'.$langs->trans("ECMSections");
print '</td></tr>';
$showonrightsize='';
// Auto section
2011-09-17 21:49:50 +02:00
if (count($sectionauto))
{
2012-03-25 22:47:37 +02:00
$htmltooltip=$langs->trans("ECMAreaDesc2");
2009-01-30 22:21:22 +01:00
// Root title line (Automatic section)
print '<tr>';
print '<td>';
2008-09-02 02:27:05 +02:00
print '<table class="nobordernopadding"><tr class="nobordernopadding">';
2009-01-30 22:21:22 +01:00
print '<td align="left" width="24">';
2008-09-02 02:27:05 +02:00
print img_picto_common('','treemenu/base.gif');
2012-03-25 22:47:37 +02:00
print '</td><td align="left">';
$txt=$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionsAuto").')';
print $form->textwithpicto($txt, $htmltooltip, 1, 0);
2008-09-01 23:51:38 +02:00
print '</td>';
print '</tr></table>';
print '</td>';
2008-09-02 02:27:05 +02:00
print '<td align="right">&nbsp;</td>';
2008-09-02 15:15:25 +02:00
print '<td align="right">&nbsp;</td>';
print '<td align="right">&nbsp;</td>';
2008-10-26 02:26:18 +01:00
print '<td align="right">&nbsp;</td>';
2008-09-02 15:15:25 +02:00
print '<td align="center">';
print '</td>';
2008-09-01 23:51:38 +02:00
print '</tr>';
$sectionauto=dol_sort_array($sectionauto,'label','ASC',true,false);
2012-06-02 18:55:04 +02:00
print '<tr>';
print '<td colspan="6" style="padding-left: 20px">';
print '<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">';
2008-09-02 02:27:05 +02:00
$nbofentries=0;
$oldvallevel=0;
2008-09-01 23:51:38 +02:00
foreach ($sectionauto as $key => $val)
{
2012-06-02 18:55:04 +02:00
if (empty($val['test'])) continue; // If condition to show is ok
$var=false;
print '<li class="directory collapsed">';
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
{
print '<a class="fmdirlia jqft ecmjqft" href="'.DOL_URL_ROOT.'/ecm/index.php?module='.$val['module'].'">';
print $val['label'];
print '</a>';
}
else
2008-09-01 23:51:38 +02:00
{
2012-06-02 18:55:04 +02:00
print '<a class="fmdirlia jqft ecmjqft" href="'.DOL_URL_ROOT.'/ecm/index.php?module='.$val['module'].'">';
print $val['label'];
print '</a>';
2008-09-01 23:51:38 +02:00
}
2012-06-02 18:55:04 +02:00
print '<div class="ecmjqft">';
// Info
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionAuto").'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$langs->trans("ECMTypeAuto").'<br>';
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['desc'];
print $form->textwithpicto('', $htmltooltip, 1, 'info');
2012-06-02 18:55:04 +02:00
print '</div>';
print '</li>';
$nbofentries++;
2008-09-01 23:51:38 +02:00
}
2012-06-02 18:55:04 +02:00
print '</ul></div></td></tr>';
}
// Manual section
2012-03-25 22:47:37 +02:00
$htmltooltip=$langs->trans("ECMAreaDesc2");
// Root of manual section
print '<tr><td>';
2008-09-02 02:27:05 +02:00
print '<table class="nobordernopadding"><tr class="nobordernopadding">';
print '<td align="left" width="24px">';
print img_picto_common('','treemenu/base.gif');
2012-03-25 22:47:37 +02:00
print '</td><td align="left">';
$txt=$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionsManual").')';
print $form->textwithpicto($txt, $htmltooltip, 1, 'info');
2008-09-02 02:27:05 +02:00
print '</td>';
2008-09-02 15:15:25 +02:00
print '</tr></table></td>';
print '<td align="right">';
print '</td>';
print '<td align="right">&nbsp;</td>';
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create">'.img_edit_add().'</a></td>';
print '<td align="right">&nbsp;</td>';
2008-10-26 02:26:18 +01:00
print '<td align="right">&nbsp;</td>';
2008-09-02 15:15:25 +02:00
print '<td align="center">';
2012-03-25 22:47:37 +02:00
//print $form->textwithpicto('',$htmltooltip,1,"info");
2008-09-02 15:15:25 +02:00
print '</td>';
2008-09-02 02:27:05 +02:00
print '</tr>';
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
{
print '<tr><td colspan="6" style="padding-left: 20px">';
// Show filemanager tree
print '<div id="filetree" class="ecmfiletree"></div>';
2012-03-25 22:47:37 +02:00
if ($action == 'deletefile') print $form->formconfirm('eeeee', $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 'deletefile');
print '</td></tr>';
}
else
{
2012-06-02 18:55:04 +02:00
print '<tr><td colspan="6" style="padding-left: 20px">';
print '<div id="filetree" class="ecmfiletree">';
print '<ul class="ecmjqft">';
// Load full tree
2012-06-02 18:55:04 +02:00
if (empty($sqltree)) $sqltree=$ecmdirstatic->get_full_arbo(0); // Slow
// ----- This section will show a tree from a fulltree array -----
// $section must also be defined
// ----------------------------------------------------------------
// Define fullpathselected ( _x_y_z ) of $section parameter
$fullpathselected='';
foreach($sqltree as $key => $val)
{
//print $val['id']."-".$section."<br>";
if ($val['id'] == $section)
{
$fullpathselected=$val['fullpath'];
break;
}
}
//print "fullpathselected=".$fullpathselected."<br>";
// Update expandedsectionarray in session
$expandedsectionarray=array();
if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray=explode(',',$_SESSION['dol_ecmexpandedsectionarray']);
2012-03-25 22:47:37 +02:00
if ($section && GETPOST('sectionexpand') == 'true')
{
// We add all sections that are parent of opened section
$pathtosection=explode('_',$fullpathselected);
foreach($pathtosection as $idcursor)
{
if ($idcursor && ! in_array($idcursor,$expandedsectionarray)) // Not already in array
{
$expandedsectionarray[]=$idcursor;
}
}
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
}
2012-03-25 22:47:37 +02:00
if ($section && GETPOST('sectionexpand') == 'false')
{
// We removed all expanded sections that are child of the closed section
$oldexpandedsectionarray=$expandedsectionarray;
$expandedsectionarray=array(); // Reset
foreach($oldexpandedsectionarray as $sectioncursor)
{
// is_in_subtree(fulltree,sectionparent,sectionchild)
if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
}
$_SESSION['dol_ecmexpandedsectionarray']=join(',',$expandedsectionarray);
}
//print $_SESSION['dol_ecmexpandedsectionarray'].'<br>';
$nbofentries=0;
$oldvallevel=0;
$var=true;
foreach($sqltree as $key => $val)
{
$var=false;
$ecmdirstatic->id=$val['id'];
$ecmdirstatic->ref=$val['label'];
// Refresh cache
2012-06-02 18:55:04 +02:00
if (preg_match('/refresh/i',$action))
{
$result=$ecmdirstatic->fetch($val['id']);
$ecmdirstatic->ref=$ecmdirstatic->label;
$result=$ecmdirstatic->refreshcachenboffile(0);
$val['cachenbofdoc']=$result;
}
//$fullpathparent=preg_replace('/(_[^_]+)$/i','',$val['fullpath']);
// Define showline
$showline=0;
// If directory is son of expanded directory, we show line
if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
// If directory is brother of selected directory, we show line
elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
// If directory is parent of selected directory or is selected directory, we show line
elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
// If we are level one we show line
elseif ($val['level'] < 2) $showline=1;
if ($showline)
{
if (in_array($val['id'],$expandedsectionarray)) $option='indexexpanded';
else $option='indexnotexpanded';
//print $option;
2012-06-02 18:55:04 +02:00
print '<li class="directory collapsed">';
// Show tree graph pictos
2012-06-02 18:55:04 +02:00
$cpt=1;
while ($cpt < $sqltree[$key]['level'])
{
print ' &nbsp; &nbsp;';
$cpt++;
}
$resarray=tree_showpad($sqltree,$key,1);
$a=$resarray[0];
$nbofsubdir=$resarray[1];
$nboffilesinsubdir=$resarray[2];
2012-03-25 22:47:37 +02:00
// Show link
2012-06-02 18:55:04 +02:00
print $ecmdirstatic->getNomUrl(0,$option,32,'class="fmdirlia jqft ecmjqft"');
print '<div class="ecmjqft">';
// Nb of docs
2012-06-02 18:55:04 +02:00
print '<table class="nobordernopadding"><tr><td>';
print $val['cachenbofdoc'];
print '</td>';
print '<td align="left">';
if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
print '</td>';
// Info
print '<td align="center">';
$userstatic->id=$val['fk_user_c'];
$userstatic->lastname=$val['login_c'];
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1).'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'],"dayhour").'<br>';
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
print $form->textwithpicto('', $htmltooltip, 1, 'info');
print "</td>";
2012-06-02 18:55:04 +02:00
print '</tr></table>';
print '</div>';
print "</li>\n";
}
$oldvallevel=$val['level'];
$nbofentries++;
}
// If nothing to show
if ($nbofentries == 0)
{
2012-06-02 18:55:04 +02:00
print '<li class="directory collapsed">';
print '<div class="ecmjqft">';
print $langs->trans("ECMNoDirectoryYet");
2012-06-02 18:55:04 +02:00
print '</div>';
print "</li>\n";
}
2012-06-02 18:55:04 +02:00
print '</ul>';
print '</div>';
print '</td></tr>';
}
2009-01-30 22:21:22 +01:00
2008-09-01 23:51:38 +02:00
print "</table>";
2008-09-02 15:15:25 +02:00
}
// End left banner
2010-08-26 04:45:48 +02:00
?>
</div>
<div id="ecm-layout-center" class="<?php echo $classviewhide; ?>">
<div class="pane-in ecm-in-layout-center">
<div id="ecmfileview" class="ecmfileview">
2010-08-26 04:45:48 +02:00
<?php
// Start right panel
$mode='noajax';
include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
2008-09-02 15:15:25 +02:00
2010-08-27 22:48:55 +02:00
// End right panel
2010-08-27 22:48:55 +02:00
?>
</div>
</div>
<div class="pane-in ecm-in-layout-south layout-padding valignmiddle">
2010-08-27 22:48:55 +02:00
<?php
// Start Add new file area
// To attach new file
if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || ! empty($section))
{
2013-11-17 02:59:01 +01:00
if (empty($section) || $section == -1)
{
?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#formuserfile').hide();
});
</script>
<?php
}
2014-01-26 18:43:30 +01:00
2012-03-25 22:47:37 +02:00
$formfile=new FormFile($db);
2013-11-17 02:59:01 +01:00
$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/index.php', 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0, 'formuserfile');
}
else print '&nbsp;';
2008-09-02 15:15:25 +02:00
// End Add new file area
2010-08-26 04:45:48 +02:00
?>
</div>
</div>
</div> <!-- end div id="containerlayout" -->
2010-08-26 04:45:48 +02:00
<?php
// End of page
2008-02-19 22:04:23 +01:00
2013-11-17 02:59:01 +01:00
if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
include 'tpl/builddatabase.tpl.php';
}
2008-02-19 22:04:23 +01:00
llxFooter();
$db->close();
2008-02-19 22:04:23 +01:00
?>