From 2197faf27421f3df01d7ae6618ddf12873dca3bb Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 1 Jun 2023 18:20:05 +0200 Subject: admin-promo done --- lib/promo.php | 13 +++++++ public/admin-promo.php | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ public/admin.css | 6 +++- public/index.php | 12 +------ 4 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 lib/promo.php create mode 100644 public/admin-promo.php diff --git a/lib/promo.php b/lib/promo.php new file mode 100644 index 0000000..ae200fa --- /dev/null +++ b/lib/promo.php @@ -0,0 +1,13 @@ + 0; $i--) + if (abs((($i/$count_buff)-$price_buff)/$price_buff) < 0.001) + return $i."+".($count_buff - $i)." gratis"; + } + return ((1-$price_buff)*100)."% korting per ".$count_buff."-pack"; +} + +?> diff --git a/public/admin-promo.php b/public/admin-promo.php new file mode 100644 index 0000000..83103e3 --- /dev/null +++ b/public/admin-promo.php @@ -0,0 +1,98 @@ + + + + +prepare("delete from promotion where id = ?"); + $statement->bind_param("i", $_POST['id']); + $statement->execute(); + break; + } + case "add": { + $statement = $cursor->prepare("insert into webs.promotion (`product`, `price_buff`, `count_buff`) values (?, ?, ?)"); + $statement->bind_param("idi", $_POST['product_id'], $_POST['price_buff'], $_POST['count_buff']); + $statement->execute(); + break; + } + } + + $promo_id = $_POST['id']; + $new_status = $_POST['status']; + if (!$promo_id) break; + if (!$new_status) break; + + $statement = $cursor->prepare("update `promo` set status = ? where id = ?"); + $statement->bind_param("ii", $new_status, $promo_id); + $statement->execute(); +} while (false); ?> +price_buff, $promo->count_buff); + echo <<<"EOF" +
+ + + + $promo->product_id + $promo->name + $promo->count_buff + $promo->price_buff + $promo_str + + + + +
+ EOF; +} +?> + + + + + aanbiedingen + + + + +
+

aanbieding toevoegen

+
+ + + + + + + + +
+

huidige aanbiedingen

+ + + + + + + + + + query("select promotion.id, product.id as product_id, product.name, count_buff, price_buff from promotion join product on product.id = promotion.product"); + while ($promo = $res->fetch_object()) promo_template($promo); + ?> +
product idproduct naamper aantalver­menig­vuldigings­factorzichtbaar alsverwijderen
+
+ + + diff --git a/public/admin.css b/public/admin.css index bc1d821..8adeb79 100644 --- a/public/admin.css +++ b/public/admin.css @@ -34,9 +34,13 @@ table td { border: 2px solid var(--bg-alt); } +table td input { width: 100%; } + .order-table td:nth-child(1) { text-align: center; } .order-table td:nth-child(3) { text-align: right; } .order-table td:nth-child(4) { text-align: right; } .order-table td select, -.order-table td input { width: 100%; } +.promo-table td:nth-child(1) { text-align: center; } +.promo-table td:nth-child(3) { text-align: right; } +.promo-table td:nth-child(4) { text-align: right; } diff --git a/public/index.php b/public/index.php index fecf624..3540692 100644 --- a/public/index.php +++ b/public/index.php @@ -1,16 +1,6 @@ - 0; $i--) - if (abs((($i/$count_buff)-$price_buff)/$price_buff) < 0.001) - return $i."+".($count_buff - $i)." gratis"; - } - return ((1-$price_buff)*100)."% korting per ".$count_buff."-pack"; -} -?> + -- cgit v1.2.3