menu actions operationnel

This commit is contained in:
2026-07-02 13:39:17 +00:00
parent dedf5f1964
commit 16c0c594b1
6 changed files with 892 additions and 6 deletions
+100
View File
@@ -364,3 +364,103 @@ class LoginManager
return $statement->execute();
}
}
/**
* Class ActionsManager
*
* Opérations CRUD sur la table `actions`.
*/
class ActionsManager
{
private PDO $connection;
public function __construct(Database $database)
{
$this->connection = $database->getConnection();
}
/**
* Retourne toutes les actions.
*
* @return array
*/
public function listActions(): array
{
$statement = $this->connection->query(
'SELECT isin, ticker, yahoo_code, company_name, updated_at
FROM actions
ORDER BY updated_at DESC'
);
return $statement->fetchAll();
}
/**
* Retourne une action par son ISIN.
*
* @param string $isin
* @return array|null
*/
public function getActionByIsin(string $isin): ?array
{
$statement = $this->connection->prepare(
'SELECT isin, ticker, yahoo_code, company_name, updated_at
FROM actions
WHERE isin = :isin'
);
$statement->bindValue(':isin', $isin, PDO::PARAM_STR);
$statement->execute();
$result = $statement->fetch();
return $result === false ? null : $result;
}
/**
* Crée une nouvelle action.
*
* @param array $data
* @return bool
*/
public function createAction(array $data): bool
{
$statement = $this->connection->prepare(
'INSERT INTO actions (isin, ticker, yahoo_code, company_name, updated_at)
VALUES (:isin, :ticker, :yahoo_code, :company_name, NOW())'
);
$statement->bindValue(':isin', $data['isin'], PDO::PARAM_STR);
$statement->bindValue(':ticker', $data['ticker'], PDO::PARAM_STR);
$statement->bindValue(':yahoo_code', $data['yahoo_code'], PDO::PARAM_STR);
$statement->bindValue(':company_name', $data['company_name'], PDO::PARAM_STR);
return $statement->execute();
}
/**
* Met à jour une action.
*
* @param string $isin
* @param array $data
* @return bool
*/
public function updateAction(string $isin, array $data): bool
{
$statement = $this->connection->prepare(
'UPDATE actions
SET ticker = :ticker,
yahoo_code = :yahoo_code,
company_name = :company_name,
updated_at = NOW()
WHERE isin = :isin'
);
$statement->bindValue(':ticker', $data['ticker'], PDO::PARAM_STR);
$statement->bindValue(':yahoo_code', $data['yahoo_code'], PDO::PARAM_STR);
$statement->bindValue(':company_name', $data['company_name'], PDO::PARAM_STR);
$statement->bindValue(':isin', $isin, PDO::PARAM_STR);
return $statement->execute();
}
}