le btn creer un ordre fctionne
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db.php';
|
||||
$db = (new App\Database\Database())->getConnection();
|
||||
$stmt = $db->prepare("INSERT INTO ordreGF (isin, Nom, ticker, code_yahoo) VALUES (?, ?, ?, ?)");
|
||||
$success = $stmt->execute([$_POST['isin'], $_POST['Nom'], $_POST['ticker'], $_POST['code_yahoo']]);
|
||||
|
||||
echo json_encode(['success' => $success]);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/db.php';
|
||||
$isin = $_GET['isin'] ?? '';
|
||||
$db = (new App\Database\Database())->getConnection();
|
||||
$stmt = $db->prepare("SELECT * FROM actions WHERE isin = ?");
|
||||
$stmt->execute([$isin]);
|
||||
$action = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
echo json_encode($action ? ['success' => true, ...$action] : ['success' => false]);
|
||||
+51
-34
@@ -18,7 +18,9 @@ $connection = $database->getConnection();
|
||||
// --- Fonctions ---
|
||||
function fetchOrdreGF(PDO $connection): array
|
||||
{
|
||||
return $connection->query('SELECT * FROM `ordreGF` ORDER BY `Id` DESC')->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
$query = 'SELECT * FROM `ordreGF` ORDER BY `ID` DESC';
|
||||
$stmt = $connection->query($query);
|
||||
return $stmt->fetchAll(PDO::FETCH_ASSOC) ?: [];
|
||||
}
|
||||
|
||||
function fetchOrdreGFPied(PDO $connection, string $masterId): array
|
||||
@@ -38,9 +40,8 @@ require_once __DIR__ . '/header.php';
|
||||
<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';">
|
||||
<button type="button" class="ordregf-btn-creer" onclick="document.getElementById('modalCreerOrdre').showModal();">
|
||||
Créer un ordre
|
||||
</button>
|
||||
<button type="button" class="ordregf-btn-menu" onclick="window.location.href='/php/menu.php';">
|
||||
@@ -53,11 +54,10 @@ require_once __DIR__ . '/header.php';
|
||||
<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;">
|
||||
<!-- Corrigé à 11 pour couvrir toutes les colonnes -->
|
||||
<td colspan="11" 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']) . ' )';
|
||||
@@ -65,9 +65,9 @@ require_once __DIR__ . '/header.php';
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Lignes de détails -->
|
||||
<tr class="ordregf-detail-block">
|
||||
<td colspan="8">
|
||||
<!-- Corrigé à 11 -->
|
||||
<td colspan="11">
|
||||
<table class="ordregf-detail-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -76,17 +76,12 @@ require_once __DIR__ . '/header.php';
|
||||
<th>Prix Brut</th>
|
||||
<th>Frais</th>
|
||||
<th>Prix Net</th>
|
||||
<th>Engagement Brut</th>
|
||||
<th>Engagement Net</th>
|
||||
<th>Eng. Brut</th>
|
||||
<th>Eng. 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>
|
||||
<th style="text-align: right;">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -97,14 +92,12 @@ require_once __DIR__ . '/header.php';
|
||||
$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;
|
||||
$prixNet = $prix + ($qte != 0 ? ($frais / $qte) : 0);
|
||||
$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'] ?? '');
|
||||
@@ -114,21 +107,21 @@ require_once __DIR__ . '/header.php';
|
||||
if ($ordre_type === 'achat') {
|
||||
$totalQ += $qte;
|
||||
$engaBrut += $qte * $prix;
|
||||
$engaNet += $qte * $prixNet;
|
||||
$engaNet += ($qte * $prix) + $frais;
|
||||
} elseif ($ordre_type === 'vente') {
|
||||
$totalQ -= $qte;
|
||||
$engaBrut -= $qte * $prix;
|
||||
$engaNet -= $qte * $prixNet;
|
||||
$engaNet -= ($qte * $prix) + $frais;
|
||||
}
|
||||
} elseif ($type_op === 'short') {
|
||||
if ($ordre_type === 'achat') {
|
||||
$totalQ -= $qte;
|
||||
$engaBrut -= $qte * $prix;
|
||||
$engaNet -= $qte * $prixNet;
|
||||
$engaNet -= ($qte * $prix) + $frais;
|
||||
} elseif ($ordre_type === 'vente') {
|
||||
$totalQ += $qte;
|
||||
$engaBrut += $qte * $prix;
|
||||
$engaNet += $qte * $prixNet;
|
||||
$engaNet += ($qte * $prix) + $frais;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,28 +132,23 @@ require_once __DIR__ . '/header.php';
|
||||
<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 class="text-right"><?= number_format($qte * $prix, 2, ',', ' ') ?></td>
|
||||
<td class="text-right"><?= number_format(($qte * $prix) + $frais, 2, ',', ' ') ?></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>
|
||||
<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="3"></td>
|
||||
<td class="text-right"><?= number_format($engaBrut, 2, ',', ' ') ?></td>
|
||||
<td class="text-right"><?= number_format($engaNet, 2, ',', ' ') ?></td>
|
||||
<td colspan="4"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -174,4 +162,33 @@ require_once __DIR__ . '/header.php';
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<dialog id="modalCreerOrdre" class="ordregf-modal">
|
||||
<form id="formCreerOrdre">
|
||||
<h2>Créer un nouvel ordre</h2>
|
||||
<div class="form-group">
|
||||
<label>ISIN :</label><br>
|
||||
<input type="text" id="isinRecherche" required>
|
||||
<button type="button" id="btnRechercher">Rechercher</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Nom :</label><br>
|
||||
<input type="text" name="Nom" id="Nom" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Ticker :</label><br>
|
||||
<input type="text" name="ticker" id="ticker" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Code Yahoo :</label><br>
|
||||
<input type="text" name="code_yahoo" id="code_yahoo" readonly>
|
||||
</div>
|
||||
<div class="modal-actions" style="margin-top: 20px;">
|
||||
<button type="button" id="btnAnnuler">Annuler</button>
|
||||
<button type="submit" id="btnValider" disabled>Valider</button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<script src="/js/ordreGF.js" defer></script>
|
||||
|
||||
<?php require_once __DIR__ . '/footer.php'; ?>
|
||||
Reference in New Issue
Block a user