mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-09 02:58:23 +01:00
WIP Dir statement in ECM
This commit is contained in:
@@ -233,6 +233,7 @@ if ($type == 'directory') {
|
|||||||
'holiday',
|
'holiday',
|
||||||
'recruitment-recruitmentcandidature',
|
'recruitment-recruitmentcandidature',
|
||||||
'banque',
|
'banque',
|
||||||
|
'bank-statement',
|
||||||
'chequereceipt',
|
'chequereceipt',
|
||||||
'mrp-mo'
|
'mrp-mo'
|
||||||
);
|
);
|
||||||
@@ -286,6 +287,8 @@ if ($type == 'directory') {
|
|||||||
$upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
|
$upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
|
||||||
} elseif ($module == 'banque') {
|
} elseif ($module == 'banque') {
|
||||||
$upload_dir = $conf->bank->dir_output;
|
$upload_dir = $conf->bank->dir_output;
|
||||||
|
} elseif ($module == 'bank-statement') {
|
||||||
|
$upload_dir = $conf->bank->dir_output.'/*/statement';
|
||||||
} elseif ($module == 'chequereceipt') {
|
} elseif ($module == 'chequereceipt') {
|
||||||
$upload_dir = $conf->bank->dir_output.'/checkdeposits';
|
$upload_dir = $conf->bank->dir_output.'/checkdeposits';
|
||||||
} elseif ($module == 'mrp-mo') {
|
} elseif ($module == 'mrp-mo') {
|
||||||
@@ -300,7 +303,7 @@ if ($type == 'directory') {
|
|||||||
|
|
||||||
// Automatic list
|
// Automatic list
|
||||||
if (in_array($module, $automodules)) {
|
if (in_array($module, $automodules)) {
|
||||||
$param .= '&module='.$module;
|
$param .= '&module='.urlencode($module);
|
||||||
if (isset($search_doc_ref) && $search_doc_ref != '') {
|
if (isset($search_doc_ref) && $search_doc_ref != '') {
|
||||||
$param .= '&search_doc_ref='.urlencode($search_doc_ref);
|
$param .= '&search_doc_ref='.urlencode($search_doc_ref);
|
||||||
}
|
}
|
||||||
@@ -309,6 +312,7 @@ if ($type == 'directory') {
|
|||||||
|
|
||||||
$filter = preg_quote((string) $search_doc_ref, '/');
|
$filter = preg_quote((string) $search_doc_ref, '/');
|
||||||
$filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
|
$filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
|
||||||
|
//var_dump($filearray);
|
||||||
|
|
||||||
// To allow external users,we must restrict $filearray to entries the user is a thirdparty.
|
// To allow external users,we must restrict $filearray to entries the user is a thirdparty.
|
||||||
// This can be done by filtering on entries found into llx_ecm
|
// This can be done by filtering on entries found into llx_ecm
|
||||||
|
|||||||
@@ -1837,7 +1837,7 @@ class FormFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
print '<table width="100%" class="noborder">'."\n";
|
print '<table class="noborder centpercent">'."\n";
|
||||||
|
|
||||||
if (!empty($addfilterfields)) {
|
if (!empty($addfilterfields)) {
|
||||||
print '<tr class="liste_titre nodrag nodrop">';
|
print '<tr class="liste_titre nodrag nodrop">';
|
||||||
@@ -1927,6 +1927,9 @@ class FormFile
|
|||||||
} elseif ($modulepart == 'banque') {
|
} elseif ($modulepart == 'banque') {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
$object_instance = new Account($this->db);
|
$object_instance = new Account($this->db);
|
||||||
|
} elseif ($modulepart == 'bank-statement') {
|
||||||
|
//include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
|
$object_instance = null;
|
||||||
} elseif ($modulepart == 'chequereceipt') {
|
} elseif ($modulepart == 'chequereceipt') {
|
||||||
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
|
||||||
$object_instance = new RemiseCheque($this->db);
|
$object_instance = new RemiseCheque($this->db);
|
||||||
@@ -2050,8 +2053,8 @@ class FormFile
|
|||||||
$result = $object_instance->fetch($id);
|
$result = $object_instance->fetch($id);
|
||||||
} else {
|
} else {
|
||||||
if (!($result = $object_instance->fetch(0, $ref))) {
|
if (!($result = $object_instance->fetch(0, $ref))) {
|
||||||
//fetchOneLike looks for objects with wildcards in its reference.
|
// fetchOneLike looks for objects with wildcards in its reference.
|
||||||
//It is useful for those masks who get underscores instead of their actual symbols (because the _ had replaced all forbidden chars into filename)
|
// It is useful for those masks who get underscores instead of their actual symbols (because the _ had replaced all forbidden chars into filename)
|
||||||
// TODO Example when this is needed ?
|
// TODO Example when this is needed ?
|
||||||
// This may find when ref is 'A_B' and date was stored as 'A~B' into database, but in which case do we have this ?
|
// This may find when ref is 'A_B' and date was stored as 'A~B' into database, but in which case do we have this ?
|
||||||
// May be we can add hidden option to enable this.
|
// May be we can add hidden option to enable this.
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ function dol_basename($pathfile)
|
|||||||
*/
|
*/
|
||||||
function dol_dir_list($utf8_path, $types = "all", $recursive = 0, $filter = "", $excludefilter = null, $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0, $nohook = 0, $relativename = "", $donotfollowsymlinks = 0, $nbsecondsold = 0)
|
function dol_dir_list($utf8_path, $types = "all", $recursive = 0, $filter = "", $excludefilter = null, $sortcriteria = "name", $sortorder = SORT_ASC, $mode = 0, $nohook = 0, $relativename = "", $donotfollowsymlinks = 0, $nbsecondsold = 0)
|
||||||
{
|
{
|
||||||
global $db, $hookmanager;
|
global $hookmanager;
|
||||||
global $object;
|
global $object;
|
||||||
|
|
||||||
if ($recursive <= 1) { // Avoid too verbose log
|
if ($recursive <= 1) { // Avoid too verbose log
|
||||||
@@ -97,43 +97,52 @@ function dol_dir_list($utf8_path, $types = "all", $recursive = 0, $filter = "",
|
|||||||
$loadsize = ($mode == 1 || $mode == 3 || $sortcriteria == 'size');
|
$loadsize = ($mode == 1 || $mode == 3 || $sortcriteria == 'size');
|
||||||
$loadperm = ($mode == 1 || $mode == 4 || $sortcriteria == 'perm');
|
$loadperm = ($mode == 1 || $mode == 4 || $sortcriteria == 'perm');
|
||||||
|
|
||||||
// Clean parameters
|
|
||||||
$utf8_path = preg_replace('/([\\/]+)$/', '', $utf8_path);
|
|
||||||
$os_path = dol_osencode($utf8_path);
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
$reshook = 0;
|
$reshook = 0;
|
||||||
$file_list = array();
|
$file_list = array();
|
||||||
|
|
||||||
if (!$nohook && $hookmanager instanceof HookManager) {
|
// Clean parameters
|
||||||
$hookmanager->resArray = array();
|
$utf8_path = preg_replace('/([\\/]+)$/', '', $utf8_path);
|
||||||
|
|
||||||
$hookmanager->initHooks(array('fileslib'));
|
if (preg_match('/\*/', $utf8_path)) {
|
||||||
|
$utf8_path_array = glob($utf8_path, GLOB_ONLYDIR); // This scan dir for files. If file does not exists, return empty.
|
||||||
$parameters = array(
|
//$os_path_array = dol_dir_list($utf8_path);
|
||||||
'path' => $os_path,
|
} else {
|
||||||
'types' => $types,
|
$utf8_path_array = array($utf8_path);
|
||||||
'recursive' => $recursive,
|
|
||||||
'filter' => $filter,
|
|
||||||
'excludefilter' => $exclude_array, // Already converted to array.
|
|
||||||
'sortcriteria' => $sortcriteria,
|
|
||||||
'sortorder' => $sortorder,
|
|
||||||
'loaddate' => $loaddate,
|
|
||||||
'loadsize' => $loadsize,
|
|
||||||
'mode' => $mode
|
|
||||||
);
|
|
||||||
$reshook = $hookmanager->executeHooks('getDirList', $parameters, $object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// $hookmanager->resArray may contain array stacked by other modules
|
foreach ($utf8_path_array as $utf8_path_cursor) {
|
||||||
if (empty($reshook)) {
|
$os_path = dol_osencode($utf8_path_cursor);
|
||||||
if (!is_dir($os_path)) {
|
if (!$nohook && $hookmanager instanceof HookManager) {
|
||||||
return array();
|
$hookmanager->resArray = array();
|
||||||
|
|
||||||
|
$hookmanager->initHooks(array('fileslib'));
|
||||||
|
|
||||||
|
$parameters = array(
|
||||||
|
'path' => $os_path,
|
||||||
|
'types' => $types,
|
||||||
|
'recursive' => $recursive,
|
||||||
|
'filter' => $filter,
|
||||||
|
'excludefilter' => $exclude_array, // Already converted to array.
|
||||||
|
'sortcriteria' => $sortcriteria,
|
||||||
|
'sortorder' => $sortorder,
|
||||||
|
'loaddate' => $loaddate,
|
||||||
|
'loadsize' => $loadsize,
|
||||||
|
'mode' => $mode
|
||||||
|
);
|
||||||
|
$reshook = $hookmanager->executeHooks('getDirList', $parameters, $object);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($dir = opendir($os_path)) === false) {
|
// $hookmanager->resArray may contain array stacked by other modules
|
||||||
return array();
|
if (empty($reshook)) {
|
||||||
} else {
|
if (!is_dir($os_path)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($dir = opendir($os_path)) === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$filedate = '';
|
$filedate = '';
|
||||||
$filesize = '';
|
$filesize = '';
|
||||||
$fileperm = '';
|
$fileperm = '';
|
||||||
@@ -149,7 +158,7 @@ function dol_dir_list($utf8_path, $types = "all", $recursive = 0, $filter = "",
|
|||||||
|
|
||||||
$qualified = 1;
|
$qualified = 1;
|
||||||
|
|
||||||
$utf8_fullpathfile = "$utf8_path/$utf8_file"; // Temp variable for speed
|
$utf8_fullpathfile = $utf8_path_cursor."/".$utf8_file; // Temp variable for speed
|
||||||
|
|
||||||
// Check if file is qualified
|
// Check if file is qualified
|
||||||
foreach ($excludefilterarray as $filt) {
|
foreach ($excludefilterarray as $filt) {
|
||||||
@@ -230,14 +239,14 @@ function dol_dir_list($utf8_path, $types = "all", $recursive = 0, $filter = "",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($dir);
|
closedir($dir);
|
||||||
|
|
||||||
// Obtain a list of columns
|
|
||||||
if (!empty($sortcriteria) && $sortorder) {
|
|
||||||
$file_list = dol_sort_array($file_list, $sortcriteria, ($sortorder == SORT_ASC ? 'asc' : 'desc'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtain a list of columns
|
||||||
|
if (!empty($sortcriteria) && $sortorder) {
|
||||||
|
$file_list = dol_sort_array($file_list, $sortcriteria, ($sortorder == SORT_ASC ? 'asc' : 'desc'));
|
||||||
|
}
|
||||||
|
|
||||||
if ($hookmanager instanceof HookManager && is_array($hookmanager->resArray)) {
|
if ($hookmanager instanceof HookManager && is_array($hookmanager->resArray)) {
|
||||||
$file_list = array_merge($file_list, $hookmanager->resArray);
|
$file_list = array_merge($file_list, $hookmanager->resArray);
|
||||||
}
|
}
|
||||||
@@ -250,7 +259,7 @@ function dol_dir_list($utf8_path, $types = "all", $recursive = 0, $filter = "",
|
|||||||
* Scan a directory and return a list of files/directories.
|
* Scan a directory and return a list of files/directories.
|
||||||
* Content for string is UTF8 and dir separator is "/".
|
* Content for string is UTF8 and dir separator is "/".
|
||||||
*
|
*
|
||||||
* @param string $path Starting path from which to search. Example: 'produit/MYPROD'
|
* @param string $path Starting path from which to search. Example: 'produit/MYPROD' or 'produit/%'
|
||||||
* @param string $filter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function
|
* @param string $filter Regex filter to restrict list. This regex value must be escaped for '/', since this char is used for preg_match function
|
||||||
* @param string[]|null $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.'))
|
* @param string[]|null $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.'))
|
||||||
* @param string $sortcriteria Sort criteria ("","fullname","name","date","size")
|
* @param string $sortcriteria Sort criteria ("","fullname","name","date","size")
|
||||||
@@ -272,9 +281,9 @@ function dol_dir_list_in_database($path, $filter = "", $excludefilter = null, $s
|
|||||||
$sql .= ", description";
|
$sql .= ", description";
|
||||||
}
|
}
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."ecm_files";
|
$sql .= " FROM ".MAIN_DB_PREFIX."ecm_files";
|
||||||
$sql .= " WHERE entity = ".$conf->entity;
|
$sql .= " WHERE entity = ".((int) $conf->entity);
|
||||||
if (preg_match('/%$/', $path)) {
|
if (preg_match('/%$/', $path)) {
|
||||||
$sql .= " AND filepath LIKE '".$db->escape($path)."'";
|
$sql .= " AND (filepath LIKE '".$db->escape($path)."' OR filepath = '".$db->escape(preg_replace('/\/%$/', '', $path))."')";
|
||||||
} else {
|
} else {
|
||||||
$sql .= " AND filepath = '".$db->escape($path)."'";
|
$sql .= " AND filepath = '".$db->escape($path)."'";
|
||||||
}
|
}
|
||||||
@@ -3577,7 +3586,6 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
|
|||||||
if ($fuser->hasRight($tmpmodule, $read) || preg_match('/^specimen/i', $original_file)) {
|
if ($fuser->hasRight($tmpmodule, $read) || preg_match('/^specimen/i', $original_file)) {
|
||||||
$accessallowed = 1;
|
$accessallowed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$original_file = $conf->$tmpmodule->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
|
$original_file = $conf->$tmpmodule->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
|
||||||
} else {
|
} else {
|
||||||
if (empty($conf->$modulepart->dir_output)) { // modulepart not supported
|
if (empty($conf->$modulepart->dir_output)) { // modulepart not supported
|
||||||
|
|||||||
@@ -393,6 +393,9 @@ if (!getDolGlobalString('ECM_AUTO_TREE_HIDEN')) {
|
|||||||
$langs->load("banks");
|
$langs->load("banks");
|
||||||
$rowspan++;
|
$rowspan++;
|
||||||
$sectionauto[] = array('position' => 180, 'level' => 1, 'module' => 'banque', 'test' => isModEnabled('bank'), 'label' => $langs->trans("BankAccount"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
|
$sectionauto[] = array('position' => 180, 'level' => 1, 'module' => 'banque', 'test' => isModEnabled('bank'), 'label' => $langs->trans("BankAccount"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
|
||||||
|
// TODO Enable this
|
||||||
|
//$rowspan++;
|
||||||
|
//$sectionauto[] = array('position' => 182, 'level' => 1, 'module' => 'bank-statement', 'test' => isModEnabled('bank'), 'label' => $langs->trans("BankAccount").' - '.$langs->trans("Statement"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount").' - '.$langs->transnoentitiesnoconv("Statement")));
|
||||||
$rowspan++;
|
$rowspan++;
|
||||||
$sectionauto[] = array('position' => 190, 'level' => 1, 'module' => 'chequereceipt', 'test' => isModEnabled('bank'), 'label' => $langs->trans("CheckReceipt"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt")));
|
$sectionauto[] = array('position' => 190, 'level' => 1, 'module' => 'chequereceipt', 'test' => isModEnabled('bank'), 'label' => $langs->trans("CheckReceipt"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt")));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user