diff --git a/dev/initdemo/initdemo.sh b/dev/initdemo/initdemo.sh index 5e24b7f3816..497d3abbf50 100755 --- a/dev/initdemo/initdemo.sh +++ b/dev/initdemo/initdemo.sh @@ -169,6 +169,10 @@ then cp -pr $mydir/documents_demo/* "$documentdir/" echo cp -pr $mydir/../../htdocs/install/doctemplates/* "$documentdir/doctemplates/" cp -pr $mydir/../../htdocs/install/doctemplates/* "$documentdir/doctemplates/" + mkdir -p "$documentdir/ecm/Administrative documents" + mkdir -p "$documentdir/ecm/Images" + echo cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" + cp -pr $mydir/../../doc/images/* "$documentdir/ecm/Images" else echo Detection of documents directory failed so demo files were not copied. fi diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 99b1441e658..c16cfe62e7c 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -239,14 +239,15 @@ class EcmDirectory // extends CommonObject /** * Update cache of nb of documents into database * - * @param string $sign '+' or '-' + * @param string $value '+' or '-' or new number * @return int <0 if KO, >0 if OK */ - function changeNbOfFiles($sign) + function changeNbOfFiles($value) { // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - $sql.= " cachenbofdoc = cachenbofdoc ".$sign." 1"; + if (preg_match('/[0-9]+/', $value)) $sql.= " cachenbofdoc = ".(int) $value; + else $sql.= " cachenbofdoc = cachenbofdoc ".$value." 1"; $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG); @@ -256,6 +257,12 @@ class EcmDirectory // extends CommonObject $this->error="Error ".$this->db->lasterror(); return -1; } + else + { + if (preg_match('/[0-9]+/', $value)) $this->cachenbofdoc = (int) $value; + else if ($value == '+') $this->cachenbofdoc++; + else if ($value == '-') $this->cachenbofdoc--; + } return 1; } diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php index ae4e6c6b08c..17e1a1a4308 100644 --- a/htdocs/ecm/docmine.php +++ b/htdocs/ecm/docmine.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2016 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -272,7 +272,13 @@ print ''.$langs->trans("ECMDirectoryForFiles").''; print '/ecm/'.$relativepath; print ''; print ''.$langs->trans("ECMNbOfDocs").''; -print count($filearray); +$nbofiles=count($filearray); +print $nbofiles; +// Test if nb is same than in cache +if ($nbofiles != $ecmdir->cachenbofdoc) +{ + $ecmdir->changeNbOfFiles((string) $nbofiles); +} print ''; print ''.$langs->trans("TotalSizeOfAttachedFiles").''; print dol_print_size($totalsize); diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 896db6f0b85..115ccd52f8b 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -201,8 +201,11 @@ 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); // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index 7b2145d0f93..bbcbb7090a4 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -50,6 +50,7 @@ $(document).ready(function() { ); $('#refreshbutton').click( function() { + console.log("Click on refreshbutton"); $.pleaseBePatient("trans('PleaseBePatient'); ?>"); $.get( "", { action: "build",