Browse Source

NEW Add format code into exported filename

Laurent Destailleur 6 years ago
parent
commit
cf88de05e2

+ 29 - 12
htdocs/accountancy/class/accountancyexport.class.php

@@ -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 :

+ 2 - 0
htdocs/accountancy/journal/expensereportsjournal.php

@@ -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
  */