NEW Add attached document on bank account visible in automatic ECM.

This commit is contained in:
Laurent Destailleur 2019-04-21 19:54:30 +02:00
parent 734b1ca7c1
commit 6da42941a8
7 changed files with 29 additions and 17 deletions

View File

@ -57,7 +57,7 @@ if (! $sortfield) $sortfield="name";
$object = new PaymentVarious($db); $object = new PaymentVarious($db);
$object->fetch($id, $ref); $object->fetch($id, $ref);
$upload_dir = $conf->banque->dir_output.'/'.dol_sanitizeFileName($object->id); $upload_dir = $conf->bank->dir_output.'/'.dol_sanitizeFileName($object->id);
$modulepart='banque'; $modulepart='banque';

View File

@ -179,7 +179,7 @@ if ($type == 'directory')
$sorting = (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC); $sorting = (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC);
// Right area. If module is defined here, we are in automatic ecm. // Right area. If module is defined here, we are in automatic ecm.
$automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport', 'holiday'); $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport', 'holiday', 'banque');
// TODO change for multicompany sharing // TODO change for multicompany sharing
// Auto area for suppliers invoices // Auto area for suppliers invoices
@ -212,12 +212,14 @@ if ($type == 'directory')
elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
// Auto area for holiday // Auto area for holiday
elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
// Auto area for holiday
elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output;
// Automatic list // Automatic list
if (in_array($module, $automodules)) if (in_array($module, $automodules))
{ {
$param.='&module='.$module; $param.='&module='.$module;
if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.$search_doc_ref; if (isset($search_doc_ref) && $search_doc_ref != '') $param.='&search_doc_ref='.urlencode($search_doc_ref);
$textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound"))); $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));

View File

@ -1464,7 +1464,7 @@ class FormFile
print '<td></td>'; print '<td></td>';
print '<td></td>'; print '<td></td>';
// Action column // Action column
print '<td class="liste_titre" align="middle">'; print '<td class="liste_titre center">';
$searchpicto=$form->showFilterButtons(); $searchpicto=$form->showFilterButtons();
print $searchpicto; print $searchpicto;
print '</td>'; print '</td>';
@ -1474,10 +1474,10 @@ class FormFile
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
$sortref="fullname"; $sortref="fullname";
if ($modulepart == 'invoice_supplier') $sortref='level1name'; if ($modulepart == 'invoice_supplier') $sortref='level1name';
print_liste_field_titre("Ref", $url, $sortref, "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("Ref", $url, $sortref, "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Documents2", $url, "name", "", $param, 'class="left"', $sortfield, $sortorder); print_liste_field_titre("Documents2", $url, "name", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Size", $url, "size", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Size", $url, "size", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Date", $url, "date", "", $param, 'class="center"', $sortfield, $sortorder); print_liste_field_titre("Date", $url, "date", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('', '', ''); print_liste_field_titre('', '', '');
print '</tr>'."\n"; print '</tr>'."\n";
@ -1557,6 +1557,11 @@ class FormFile
include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
$object_instance=new Holiday($this->db); $object_instance=new Holiday($this->db);
} }
elseif ($modulepart == 'banque')
{
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$object_instance=new Account($this->db);
}
foreach($filearray as $key => $file) foreach($filearray as $key => $file)
{ {
@ -1569,17 +1574,20 @@ class FormFile
// Define relative path used to store the file // Define relative path used to store the file
$relativefile=preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); $relativefile=preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']);
//var_dump($file);
$id=0; $ref=''; $label=''; $id=0; $ref=''; $label='';
// To show ref or specific information according to view to show (defined by $module) // To show ref or specific information according to view to show (defined by $module)
if ($modulepart == 'company' || $modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } if ($modulepart == 'company' || $modulepart == 'tax') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); }
elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices elseif ($modulepart == 'invoice_supplier') { preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); if (is_numeric($ref)) { $id=$ref; $ref=''; } } // $ref may be also id with old supplier invoices
elseif ($modulepart == 'user' || $modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); } elseif ($modulepart == 'user' || $modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id=(isset($reg[1])?$reg[1]:''); }
elseif (in_array($modulepart, array('invoice', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'project', 'fichinter', 'expensereport'))) elseif (in_array($modulepart, array('invoice', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'project', 'fichinter', 'expensereport', 'banque')))
{ {
preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:'');
} }
else
{
//print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n";
}
if (! $id && ! $ref) continue; if (! $id && ! $ref) continue;
$found=0; $found=0;
@ -1597,13 +1605,13 @@ class FormFile
//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 //It is useful for those masks who get underscores instead of their actual symbols
//fetchOneLike requires some info in the object. If it doesn't have it, then 0 is returned //fetchOneLike requires some info in the object. If it doesn't have it, then 0 is returned
//that's why we look only look fetchOneLike when fetch returns 0 //that's why we look only into fetchOneLike when fetch returns 0
if (!$result = $object_instance->fetch('', $ref)) { if (!$result = $object_instance->fetch('', $ref)) {
$result = $object_instance->fetchOneLike($ref); $result = $object_instance->fetchOneLike($ref);
} }
} }
if ($result > 0) { // Save object into a cache if ($result > 0) { // Save object loaded into a cache
$found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance;
} }
if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); } if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); }

View File

@ -182,7 +182,7 @@ function various_payment_prepare_head($object)
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->banque->dir_output . "/" . dol_sanitizeFileName($object->ref); $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id); $nbLinks=Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id;

View File

@ -2701,7 +2701,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
} }
// Wrapping pour les remises de cheques // Wrapping pour les remises de cheques
elseif ($modulepart == 'remisecheque' && !empty($conf->banque->dir_output)) elseif ($modulepart == 'remisecheque' && !empty($conf->bank->dir_output))
{ {
if ($fuser->rights->banque->{$lire} || preg_match('/^specimen/i', $original_file)) if ($fuser->rights->banque->{$lire} || preg_match('/^specimen/i', $original_file))
{ {
@ -2712,7 +2712,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
} }
// Wrapping for bank // Wrapping for bank
elseif ($modulepart == 'bank' && !empty($conf->bank->dir_output)) elseif (($modulepart == 'banque' || $modulepart == 'bank') && !empty($conf->bank->dir_output))
{ {
if ($fuser->rights->banque->{$lire}) if ($fuser->rights->banque->{$lire})
{ {

View File

@ -169,6 +169,7 @@ $refname=basename(dirname($original_file)."/");
// Security check // Security check
if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart');
// Check security and set return info with full path of file
$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname);
$accessallowed = $check_access['accessallowed']; $accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];

View File

@ -332,6 +332,7 @@ if (! empty($conf->global->ECM_AUTO_TREE_ENABLED))
if (! empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsByInterventions")); } if (! empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsByInterventions")); }
if (! empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsByExpenseReports")); } if (! empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsByExpenseReports")); }
if (! empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsByHolidays")); } if (! empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsByHolidays")); }
if (! empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsByBankAccount")); }
$rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsByUsers")); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsByUsers"));
} }