Advertisement
noam76

invoices.php

May 11th, 2023 (edited)
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.13 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include 'connexion.php';
  4.  
  5. if(!isset($_SESSION['username'])) {
  6.     header('Location: login.php');
  7.     exit();
  8. }
  9.  
  10. // Récupération des factures
  11. $query_invoices = "SELECT * FROM invoices ORDER BY id DESC";
  12. $result_invoices = $pdo->query($query_invoices);
  13.  
  14. // Récupération des propriétaires
  15. $query_owners = "SELECT * FROM owners ORDER BY nom ASC";
  16. $result_owners = $pdo->query($query_owners);
  17.  
  18. ?>
  19.  
  20. <!DOCTYPE html>
  21. <html>
  22. <head>
  23.     <title>Finance - Gestion des factures</title>
  24.     <link rel="stylesheet" type="text/css" href="style.css">
  25. </head>
  26. <body>
  27.     <div class="header">
  28.         <h2>Gestion des factures</h2>
  29.     </div>
  30.     <div class="navbar">
  31.         <a href="home.php">Accueil</a>
  32.         <a href="payments.php">Paiements</a>
  33.         <a href="invoices.php">Factures</a>
  34.         <a href="logout.php" style="float:right">Déconnexion</a>
  35.     </div>
  36.     <div class="content">
  37.         <table>
  38.             <thead>
  39.                 <tr>
  40.                     <th>ID</th>
  41.                     <th>Date</th>
  42.                     <th>Appartement</th>
  43.                     <th>Montant</th>
  44.                     <th>Status</th>
  45.                     <th>Action</th>
  46.                 </tr>
  47.             </thead>
  48.             <tbody>
  49.                 <?php while($row = $result_invoices->fetch(PDO::FETCH_ASSOC)): ?>
  50.                     <tr>
  51.                         <td><?php echo $row['id']; ?></td>
  52.                         <td><?php echo $row['date']; ?></td>
  53.                         <td><?php echo $row['appartement']; ?></td>
  54.                         <td><?php echo $row['montant']; ?></td>
  55.                         <td><?php echo $row['status']; ?></td>
  56.                         <td><a href="edit_invoice.php?id=<?php echo $row['id']; ?>">Modifier</a></td>
  57.                     </tr>
  58.                 <?php endwhile; ?>
  59.             </tbody>
  60.         </table>
  61.         <br>
  62.         <h2>Créer une facture</h2>
  63.         <form method="post" action="save_invoice.php">
  64.             <label>Date :</label>
  65.             <input type="date" name="date" required>
  66.             <br>
  67.             <label>Propriétaire :</label>
  68.             <select name="owner_id" required>
  69.                 <?php while($row = $result_owners->fetch(PDO::FETCH_ASSOC)): ?>
  70.                     <option value="<?php echo $row['id']; ?>"><?php echo $row['nom'] . ' ' . $row['prenom']; ?></option>
  71.                 <?php endwhile; ?>
  72.             </select>
  73.             <br>
  74.             <label>Appartement :</label>
  75.             <input type="text" name="appartement" required>
  76.             <br>
  77.             <label>Montant :</label>
  78.             <input type="number" name="montant" required>
  79.             <br>
  80.             <label>Status :</label>
  81.             <select name="status" required>
  82.                 <option value="non payé">Non payé</option>
  83.                 <option value="payé">Payé</option>
  84.             </select>
  85.             <br>
  86.             <br>
  87.             <button type="submit" name="save_invoice">Enregistrer</button>
  88.         </form>
  89.     </div>
  90. </table>
  91. <div class="footer">
  92.         <p>© 2023 - Finance App</p>
  93.     </div>
  94. </body>
  95. </html>
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement