menu csv full operationnel

This commit is contained in:
2026-07-02 14:15:39 +00:00
parent 2675598eee
commit 236ae4ab8c
6 changed files with 394 additions and 0 deletions
+43
View File
@@ -395,6 +395,49 @@ class ActionsManager
return $statement->fetchAll();
}
/**
* Exporte toutes les actions vers un fichier CSV.
*
* @param string $filePath
* @return bool
*/
public function exportActionsToCsv(string $filePath): bool
{
$actions = $this->listActions();
$directory = dirname($filePath);
if (!is_dir($directory) && !mkdir($directory, 0755, true) && !is_dir($directory)) {
return false;
}
$handle = fopen($filePath, 'w');
if ($handle === false) {
return false;
}
$header = ['isin', 'ticker', 'yahoo_code', 'company_name', 'updated_at'];
if (fputcsv($handle, $header) === false) {
fclose($handle);
return false;
}
foreach ($actions as $action) {
if (fputcsv($handle, [
$action['isin'],
$action['ticker'],
$action['yahoo_code'],
$action['company_name'],
$action['updated_at'],
]) === false) {
fclose($handle);
return false;
}
}
fclose($handle);
return true;
}
/**
* Retourne une action par son ISIN.
*