menu csv full operationnel
This commit is contained in:
+43
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user