NEW Add format code into exported filename

This commit is contained in:
Laurent Destailleur 2018-10-10 20:01:01 +02:00
parent 6c55bfc0f7
commit cf88de05e2
2 changed files with 31 additions and 12 deletions

View File

@ -112,6 +112,31 @@ class AccountancyExport
);
}
/**
* Return string to summarize the format (Used to generated export filename)
*
* @param int $type Format id
* @return string Format code
*/
private static function getFormatCode($type)
{
$formatcode = array (
//self::$EXPORT_TYPE_NORMAL => 'csv',
self::$EXPORT_TYPE_CONFIGURABLE => 'csv',
self::$EXPORT_TYPE_CEGID => 'cegid',
self::$EXPORT_TYPE_COALA => 'coala',
self::$EXPORT_TYPE_BOB50 => 'bob50',
self::$EXPORT_TYPE_CIEL => 'ciel',
self::$EXPORT_TYPE_QUADRATUS => 'quadratus',
self::$EXPORT_TYPE_EBP => 'ebp',
self::$EXPORT_TYPE_COGILOG => 'cogilog',
self::$EXPORT_TYPE_AGIRIS => 'agiris',
self::$EXPORT_TYPE_FEC => 'fec',
);
return $formatcode[$type];
}
/**
* Array with all export type available (key + label) and parameters for config
*
@ -179,17 +204,6 @@ class AccountancyExport
);
}
/**
* Download the export
*
* @return void
*/
public static function downloadFile()
{
global $conf;
$filename = 'general_ledger';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
}
/**
* Function who chose which export to use with the default config
@ -201,7 +215,10 @@ class AccountancyExport
{
global $conf, $langs;
self::downloadFile();
$filename = 'general_ledger-'.$this->getFormatCode($conf->global->ACCOUNTING_EXPORT_MODELCSV);
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
switch ($conf->global->ACCOUNTING_EXPORT_MODELCSV) {
case self::$EXPORT_TYPE_NORMAL :

View File

@ -400,11 +400,13 @@ if ($action == 'writebookkeeping') {
$param.='&date_endmonth='.$date_endmonth;
$param.='&date_endyear='.$date_endyear;
$param.='&in_bookkeeping='.$in_bookkeeping;
header("Location: ".$_SERVER['PHP_SELF'].($param?'?'.$param:''));
exit;
}
}
/*
* View
*/