-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestrequette_ajax.php
More file actions
66 lines (62 loc) · 2.25 KB
/
testrequette_ajax.php
File metadata and controls
66 lines (62 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
require_once 'model_db.php';
// CREATION D'UNE INSTANCE DE LA BASE DE DONNEE
$db = new Database();
// Création des factures
if (isset($_POST['action']) && $_POST['action'] == 'create'){
extract($_POST);
//CALCUL DU MONTANT QU'ON REMBOURSSE A L'UTULISATEUR
$returned = (int)$received - (int)$amount;
// INSERTION DE MON ELEMENT DANS LA BASE DE DONNEE
$db->create($customer, $cashier, (int)$amount, (int)$received, (int)$returned, $state);
echo 'prefect';
}
// Récuperer une facture
if (isset($_POST['action']) && $_POST['action'] == 'fetch'){
$output = '';
if ($db->countFacture() > 0){
$factureLists = $db->read();
// $output += '
$output .= '
<table class="table table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Client</th>
<th scope="col">Caissier</th>
<th scope="col">Montant</th>
<th scope="col">Perçu</th>
<th scope="col">Retourné</th>
<th scope="col">Etat</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
';
foreach ($factureLists as $factureList) {
// $output += '
$output .= '
<tr>
<th scope="row">' . $factureList->id . '</th>
<td>' . $factureList->customer . '</td>
<td>' . $factureList->cashier . '</td>
<td>' . $factureList->amount . '</td>
<td>' . $factureList->received . '</td>
<td>' . $factureList->returned . '</td>
<td>cc' . $factureList->state . '</td>
<td>
<a href="#" class="text-info me-2 infoBtn" title="voir details"><i class="fas fa-info-circle"></i></a>
<a href="#" class="text-primary me-2 editoBtn" title="Modifier"><i class="fas fa-edit"></i></a>
<a href="#" class="text-danger me-2 deleteBtn" title="Supprimer"><i class="fas fa-trash-alt"></i></a>
</td>
</tr>
';
}
$output .= '</tbody></table>';
// $output += '</tbody></table>';
echo $output;
}
else{
echo "<h2>Aucune facture pour ce montant</h2>";
}
}