-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathkoszyk.lista.php
85 lines (76 loc) · 2.47 KB
/
koszyk.lista.php
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
require_once 'vendor/autoload.php';
session_start();
use Ibd\Koszyk;
$koszyk = new Koszyk();
if(isset($_POST['zmien'])) {
$koszyk->zmienLiczbeSztuk($_POST['ilosci']);
header("Location: koszyk.lista.php");
}
$listaKsiazek = $koszyk->pobierzWszystkie();
include 'header.php';
?>
<h2>Koszyk</h2>
<form method="post" action="">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th> </th>
<th>Tytuł</th>
<th>Autor</th>
<th>Kategoria</th>
<th>Cena PLN</th>
<th>Liczba sztuk</th>
<th>Cena razem</th>
<th> </th>
</tr>
</thead>
<?php if(count($listaKsiazek) > 0): ?>
<tbody>
<?php foreach($listaKsiazek as $ks): ?>
<tr>
<td style="width: 100px">
<?php if(!empty($ks['zdjecie'])): ?>
<img src="zdjecia/<?= $ks['zdjecie'] ?>" alt="<?= $ks['tytul'] ?>" class="img-thumbnail" />
<?php else: ?>
brak zdjęcia
<?php endif; ?>
</td>
<td><?= $ks['tytul'] ?></td>
<td><?= $ks['id_autora'] ?></td>
<td><?= $ks['id_kategorii'] ?></td>
<td><?= $ks['cena'] ?></td>
<td>
<div style="width: 50px">
<input type="text" name="ilosci[<?= $ks['id_koszyka'] ?>]" value="<?= $ks['liczba_sztuk'] ?>" class="form-control" />
</div>
</td>
<td><?= $ks['cena'] * $ks['liczba_sztuk'] ?></td>
<td style="white-space: nowrap">
<a href="koszyk.usun.php" title="usuń z koszyka">
<i class="fas fa-trash"></i>
</a>
<a href="ksiazki.szczegoly.php?id=<?=$ks['id']?>" title="szczegóły">
<i class="fas fa-folder-open"></i>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<td colspan="4"> </td>
<td colspan="4" class="text-right">
<input type="submit" class="btn btn-secondary btn-sm" name="zmien" value="Zmień liczbę sztuk" />
<?php if (!empty($_SESSION['id_uzytkownika'])): ?>
<a href="zamowienie.php" class="btn btn-primary btn-sm">Złóż zamówienie</a>
<?php endif; ?>
</td>
</tr>
</tfoot>
<?php else: ?>
<tr><td colspan="8" style="text-align: center">Brak produktów w koszyku.</td></tr>
<?php endif; ?>
</table>
</form>
<?php include 'footer.php'; ?>