diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 033219b30f6..9d01a3c70b2 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -68,7 +68,7 @@ class FormFile
* @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used.
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
* @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files
- * @param string $htmlname Name and id of HTML form
+ * @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
* @return int <0 if KO, >0 if OK
*/
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile')
@@ -212,7 +212,7 @@ class FormFile
if (empty($res))
{
- print '
';
+ print '
';
print $out;
print '
';
}
@@ -904,7 +904,7 @@ class FormFile
/**
* Show list of documents in $filearray (may be they are all in same directory but may not)
* This also sync database if $upload_dir is defined.
- *
+ *
* @param array $filearray Array of files loaded by dol_dir_list('files') function before calling this.
* @param Object $object Object on which document is linked to.
* @param string $modulepart Value for modulepart used by download or viewimage wrapper.
diff --git a/htdocs/core/js/blockUI.js b/htdocs/core/js/blockUI.js
index c72ad69580d..6abcc706e25 100644
--- a/htdocs/core/js/blockUI.js
+++ b/htdocs/core/js/blockUI.js
@@ -23,7 +23,7 @@
// Examples
$(document).ready(function() {
// override these in your code to change the default behavior and style
- $.blockUI.events = {
+ /*$.blockUI.events = {
// styles applied when using $.growlUI
dolEventValidCSS: {
@@ -59,7 +59,7 @@ $(document).ready(function() {
'border-radius': '10px'
}
- };
+ };*/
$.dolEventValid = function(title, message, timeout, onClose) {
var $m = $('
');
@@ -67,7 +67,7 @@ $(document).ready(function() {
if (message) $m.append('
'+message+'
');
if (timeout == undefined) timeout = 3000;
$.blockUI({
- message: $m, fadeIn: 200, fadeOut: 700, centerY: false,
+ message: $m, fadeIn: 0, fadeOut: 0, centerY: false,
timeout: timeout, showOverlay: false,
onUnblock: onClose,
css: $.blockUI.events.dolEventValidCSS
@@ -80,7 +80,7 @@ $(document).ready(function() {
if (message) $m.append('
'+message+'
');
if (timeout == undefined) timeout = 0;
$.blockUI({
- message: $m, fadeIn: 200, centerY: false,
+ message: $m, fadeIn: 0, centerY: false,
timeout: timeout, showOverlay: false,
onUnblock: onClose,
css: $.blockUI.events.dolEventErrorCSS
@@ -98,7 +98,6 @@ $(document).ready(function() {
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
'border-radius': '10px',
- opacity: .5,
color: '#fff'
}
});
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index 10417d4e273..a7113a1895a 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -47,10 +47,10 @@ $result = restrictedArea($user, 'ecm', 0);
// Get parameters
$socid=GETPOST('socid','int');
$action=GETPOST('action','aZ09');
-$section=GETPOST("section")?GETPOST("section","int"):GETPOST("section_id","int");
-$module=GETPOST("module");
+$section=GETPOST('section','int')?GETPOST('section','int'):GETPOST('section_id','int');
+$module=GETPOST('module','alpha');
if (! $section) $section=0;
-$section_dir=GETPOST('section_dir');
+$section_dir=GETPOST('section_dir','alpha');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@@ -153,9 +153,10 @@ if ($action == 'confirm_deletefile')
dol_print_error($db,$ecmdir->error);
exit;
}
+ $relativepath=$ecmdir->getRelativePath();
}
else $relativepath='';
- $upload_dir = $conf->ecm->dir_output;
+ $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);
@@ -183,7 +184,6 @@ if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes')
// To refresh content of dir with cache, just open the dir in edit mode.
if ($action == 'refreshmanual')
{
-
$ecmdirtmp = new EcmDirectory($db);
// This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate
@@ -327,8 +327,9 @@ if ($action == 'refreshmanual')
//print $_SESSION["dol_screenheight"];
$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466)?($_SESSION["dol_screenheight"]-136):660; // Also into index_auto.php file
-$morejs=array();
-if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs=array("/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js");
+//$morejs=array();
+$morejs=array('includes/jquery/plugins/blockUI/jquery.blockUI.js','core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp
+if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[]="/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECMArea"),'','','','',$morejs,'',0,0);
@@ -337,19 +338,6 @@ llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECMArea"),'','','','',$morejs,
// Add sections to manage
$rowspan=0;
$sectionauto=array();
-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")); }
- 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")); }
- if (! empty($conf->projet->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsByProjects")); }
-}
// Confirm remove file (for non javascript users)
if ($action == 'delete' && empty($conf->use_javascript_ajax))
@@ -363,9 +351,12 @@ if ($action == 'delete' && empty($conf->use_javascript_ajax))
$classviewhide='inline-block';
+
+
$head = ecm_prepare_dasboard_head('');
dol_fiche_head($head, 'index', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), 1, '');
+
// Start container of all panels
?>
@@ -374,26 +365,55 @@ dol_fiche_head($head, 'index', $langs->trans("ECMArea").' - '.$langs->trans("ECM
';
+print '
';
// End top panel, toolbar
@@ -408,7 +428,6 @@ print '
';
if ($action == 'delete_section')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1);
-
}
// End confirm
@@ -628,35 +647,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
?>
-
-use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) || ! empty($section))
-{
- if (empty($section) || $section == -1)
- {
- ?>
-
- form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section?$section:-1), $user->rights->ecm->upload, 48, null, '', 0, '', 0, 'formuserfile');
-}
-else print ' ';
-
-
-
-// End Add new file area
-?>
-
global->MAIN_UPLOAD_DOC))
-{
- // Define relativepath and upload_dir
- $relativepath='';
- if ($ecmdir->id) $relativepath=$ecmdir->getRelativePath();
- else $relativepath=$section_dir;
- $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
-
- if (empty($_FILES['userfile']['tmp_name']))
- {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
- }
-
- if (! $error)
- {
- if (dol_mkdir($upload_dir) >= 0)
- {
- $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)
- {
- $result=$ecmdir->changeNbOfFiles('+');
- }
- else
- {
- $langs->load("errors");
- if ($resupload < 0) // Unknown error
- {
- setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
- }
- else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
- {
- setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors');
- }
- else // Known error
- {
- setEventMessages($langs->trans($resupload), null, 'errors');
- }
- }
- }
- else
- {
- $langs->load("errors");
- setEventMessages($langs->trans("ErrorFailToCreateDir",$upload_dir), null, 'errors');
- }
- }
-}
@@ -158,7 +111,6 @@ if ($action == 'add' && $user->rights->ecm->setup)
}
else
{
- //TODO: Translate
setEventMessages('Error '.$langs->trans($ecmdir->error), null, 'errors');
$action = "create";
}
@@ -207,6 +159,8 @@ if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes')
}
// Refresh directory view
+// This refresh list of dirs, not list of files (for preformance reason). List of files is refresh only if dir was not synchronized.
+// To refresh content of dir with cache, just open the dir in edit mode.
if ($action == 'refreshmanual')
{
$ecmdirtmp = new EcmDirectory($db);
@@ -352,8 +306,9 @@ if ($action == 'refreshmanual')
//print $_SESSION["dol_screenheight"];
$maxheightwin=(isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466)?($_SESSION["dol_screenheight"]-136):660; // Also into index.php file
-$morejs=array();
-if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs=array("/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js");
+//$morejs=array();
+$morejs=array('includes/jquery/plugins/blockUI/jquery.blockUI.js','core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp
+if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[]="/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
llxHeader($moreheadcss.$moreheadjs,$langs->trans("ECMArea"),'','','','',$morejs,'',0,0);
@@ -399,6 +354,8 @@ if ($action == 'delete' && empty($conf->use_javascript_ajax))
$classviewhide='inline-block';
+
+
$head = ecm_prepare_dasboard_head('');
dol_fiche_head($head, 'index_auto', $langs->trans("ECMArea").' - '.$langs->trans("ECMFileManager"), 1, '');
@@ -411,11 +368,11 @@ dol_fiche_head($head, 'index_auto', $langs->trans("ECMArea").' - '.$langs->trans
';
+print '
diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php
index bbcbb7090a4..3dc5e09bf08 100644
--- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php
+++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php
@@ -24,6 +24,8 @@