WIP : sauvegarde avant de continuer ordreGF fctionne mais pas les btn

This commit is contained in:
2026-07-05 13:52:19 +00:00
parent 33a23d0392
commit 26c5f06f98
7 changed files with 369 additions and 5 deletions
+3 -1
View File
@@ -1,9 +1,10 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bourse - Page d'Accueil</title>
<title>Bourse</title>
<link rel="stylesheet" href="/css/style.css">
<?php if (!empty($pageStylesheets) && is_array($pageStylesheets)): ?>
<?php foreach ($pageStylesheets as $sheet): ?>
@@ -12,6 +13,7 @@
<?php endif; ?>
<link rel="shortcut icon" href="/assets/images/favicon.png" type="image/x-icon">
</head>
<body class="<?= !empty($bodyClass) ? htmlspecialchars($bodyClass, ENT_QUOTES, 'UTF-8') : '' ?>">
<header class="header">
<div class="container">
+1 -1
View File
@@ -28,7 +28,7 @@ require_once __DIR__ . '/header.php';
</header>
<form name="menu" class="menu-grid" action="#" method="post" autocomplete="off" novalidate>
<button type="button" class="menu-button" data-target="/php/order_gf.php">
<button type="button" class="menu-button" data-target="/php/ordreGF.php">
<div class="menu-button__content">
<span class="menu-button__title">Ordre GF</span>
<span class="menu-button__text">Voir et modifier les ordres GF</span>
+177
View File
@@ -0,0 +1,177 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/session.php';
require_once __DIR__ . '/db.php';
if (empty($_SESSION['user_id'])) {
header('Location: ../index.php');
exit;
}
$pageStylesheets = ['/css/ordreGF.css'];
$bodyClass = 'ordregf-page';
$database = new App\Database\Database();
$connection = $database->getConnection();
// --- Fonctions ---
function fetchOrdreGF(PDO $connection): array
{
return $connection->query('SELECT * FROM `ordreGF` ORDER BY `Id` DESC')->fetchAll(PDO::FETCH_ASSOC) ?: [];
}
function fetchOrdreGFPied(PDO $connection, string $masterId): array
{
$stmt = $connection->prepare('SELECT * FROM `ordreGF_pied` WHERE `Id_entete` = :masterId ORDER BY `Id` ASC');
$stmt->execute([':masterId' => $masterId]);
return $stmt->fetchAll(PDO::FETCH_ASSOC) ?: [];
}
$ordres = fetchOrdreGF($connection);
require_once __DIR__ . '/header.php';
?>
<section class="ordregf-shell">
<div class="ordregf-card">
<header class="ordregf-card-header" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px;">
<h1 class="ordregf-title">Gestion des ordres GF</h1>
<!-- Conteneur des boutons -->
<div style="display: flex; gap: 10px;">
<button type="button" class="ordregf-btn-creer" onclick="window.location.href='/php/creer_ordre.php';">
Créer un ordre
</button>
<button type="button" class="ordregf-btn-menu" onclick="window.location.href='/php/menu.php';">
Retour au menu
</button>
</div>
</header>
<div class="ordregf-table-wrapper">
<table class="ordregf-table">
<tbody>
<?php foreach ($ordres as $ordre): ?>
<!-- Ligne d'entête (Master) -->
<tr class="ordregf-master-row ordregf-header-style">
<td colspan="8" style="font-weight: bold; font-size: 1.1em; color: #fff;">
<?php
// Affichage explicite des colonnes demandées
echo htmlspecialchars((string)$ordre['isin']) . ' --- ' .
htmlspecialchars((string)$ordre['Nom']) . ' ( ' .
htmlspecialchars((string)$ordre['ticker']) . ' )';
?>
</td>
</tr>
<!-- Lignes de détails -->
<tr class="ordregf-detail-block">
<td colspan="8">
<table class="ordregf-detail-table">
<thead>
<tr>
<th>Date</th>
<th>Qté</th>
<th>Prix Brut</th>
<th>Frais</th>
<th>Prix Net</th>
<th>Engagement Brut</th>
<th>Engagement Net</th>
<th>Ordre</th>
<th>Type</th>
<th>Etat</th>
<!-- Cellule pour le bouton -->
<th style="text-align: right;">
<button type="button" class="ordregf-btn-petit ordregf-btn-creer-petit" onclick="...">
Créer
</button>
</th>
</tr>
</thead>
<tbody>
<?php
$totalQ = 0;
$engaBrut = 0;
$engaNet = 0;
$details = fetchOrdreGFPied($connection, (string)$ordre['ID']);
foreach ($details as $detail):
// Calculs
$qte = (int)($detail['Quantite'] ?? 0);
$prix = (float)($detail['Prix_brut'] ?? 0);
$frais = (float)($detail['Frais_brocker'] ?? 0) + (float)($detail['Frais_etat'] ?? 0) + (float)($detail['Frais_autre'] ?? 0);
$prixNet = $prix + $frais;
$date = !empty($detail['Date_op']) ? date('d/m/Y', strtotime($detail['Date_op'])) : '--/--/----';
// Logique du Total Q
$ordre_type = strtolower($detail['Ordre'] ?? '');
$type_op = strtolower($detail['Type'] ?? '');
$etat = strtolower($detail['Etat'] ?? '');
if ($etat === 'actif') {
if ($type_op === 'long') {
if ($ordre_type === 'achat') {
$totalQ += $qte;
$engaBrut += $qte * $prix;
$engaNet += $qte * $prixNet;
} elseif ($ordre_type === 'vente') {
$totalQ -= $qte;
$engaBrut -= $qte * $prix;
$engaNet -= $qte * $prixNet;
}
} elseif ($type_op === 'short') {
if ($ordre_type === 'achat') {
$totalQ -= $qte;
$engaBrut -= $qte * $prix;
$engaNet -= $qte * $prixNet;
} elseif ($ordre_type === 'vente') {
$totalQ += $qte;
$engaBrut += $qte * $prix;
$engaNet += $qte * $prixNet;
}
}
}
?>
<tr class="ordregf-detail-row">
<td><?= htmlspecialchars($date) ?></td>
<td class="text-right"><?= number_format($qte, 0, ',', ' ') ?></td>
<td class="text-right"><?= number_format($prix, 3, ',', ' ') ?></td>
<td class="text-right"><?= number_format($frais, 3, ',', ' ') ?></td>
<td class="text-right"><?= number_format($prixNet, 3, ',', ' ') ?></td>
<td class="text-right"><?= number_format($qte * $prix, 3, ',', ' ') ?></td>
<td class="text-right"><?= number_format($qte * $prixNet, 3, ',', ' ') ?></td>
<td><?= htmlspecialchars($detail['Ordre'] ?? '') ?></td>
<td><?= htmlspecialchars($detail['Type'] ?? '') ?></td>
<td><?= htmlspecialchars($detail['Etat'] ?? '') ?></td>
<td style="text-align: right;">
<button type="button" class="ordregf-btn-petit ordregf-btn-modifier-petit" data-detail='<?= json_encode($detail) ?>'>
Modifier
</button>
</td>
</tr>
<?php endforeach; ?>
<!-- Ligne du Footer de calcul -->
<tr style="background-color: rgba(255, 255, 255, 0.08); font-weight: bold;">
<td style="text-align: right;">TOTAL :</td>
<td class="text-right"><?= number_format($totalQ, 0, ',', ' ') ?></td>
<td class="text-right"><?= number_format($engaBrut / $totalQ, 3, ',', ' ') ?></td>
<td class="text-right"><?= number_format($engaNet / $totalQ - $engaBrut / $totalQ, 3, ',', ' ') ?></td>
<td class="text-right"><?= number_format($engaNet / $totalQ, 3, ',', ' ') ?></td>
<td class="text-right"><?= number_format($engaBrut, 3, ',', ' ') ?></td>
<td class="text-right"><?= number_format($engaNet, 3, ',', ' ') ?></td>
<td colspan="4"></td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</section>
<?php require_once __DIR__ . '/footer.php'; ?>