From 2acc7787e73c966c3fc1794d77dd758a3f56b566 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 27 Jul 2016 21:29:57 +0200 Subject: Offer: use Model --- include/offers.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'include/offers.php') diff --git a/include/offers.php b/include/offers.php index b7c00b0..2aa150d 100644 --- a/include/offers.php +++ b/include/offers.php @@ -49,7 +49,7 @@ require('./header.php'); $id = (int) $_GET['id']; try { $offer = new Offer($_pdo, $id); - $header = "Offers / #{$offer->getId()}"; + $header = "Offers / #{$offer->id}"; $show_individual = $id; } catch (PDOException $e) { $alert = "
The offer with id $id could not be found.
"; @@ -68,11 +68,8 @@ require('./header.php'); $id = (int) $_GET['toggle_accept']; try { $offer = new Offer($_pdo, $id); - if ($offer->toggleAccepted()) { - echo "
The status offer #{$offer->getId()} has been set to ".($offer->isAccepted() ? "accepted" : "unaccepted").".
"; - } else { - echo "
The status of the offer #{$offer->getId()} could not be changed.
"; - } + $offer->accepted = !$offer->accepted; + echo "
The status offer #{$offer->id} has been set to ".($offer->accepted ? "accepted" : "unaccepted").".
"; } catch (PDOException $e) { echo "
The status of the offer could not be changed due to a PDO error.
"; } catch (Exception $e) { @@ -89,9 +86,9 @@ require('./header.php'); try { $offer = new Offer($_pdo, $id); $file = $offer->generateInvoice(); - echo "
The invoice for offer #{$offer->getId()} is generated: {$file->filename}
"; + echo "
The invoice for offer #{$offer->id} is generated: {$file->filename}
"; } catch (PDOException $e) { - echo "
The invoice for offer #{$offer->getId()} could not be generated due to a PDO error.
"; + echo "
The invoice for offer #{$offer->id} could not be generated due to a PDO error.
"; } catch (Exception $e) { echo "
The invoice for offer #{$id} could not be generated.
"; } @@ -106,12 +103,12 @@ require('./header.php'); $offer = new Offer($_pdo, $id); $file = $offer->getInvoiceFile(); if ($file instanceof file && $file->delete()) { - echo "
The invoice for offer #{$offer->getId()} is trashed.
"; + echo "
The invoice for offer #{$offer->id} is trashed.
"; } else { echo "
The invoice for offer #{$id} could not be trashed.
"; } } catch (PDOException $e) { - echo "
The invoice for offer #{$offer->getId()} could not be trashed due to a PDO error.
"; + echo "
The invoice for offer #{$offer->id} could not be trashed due to a PDO error.
"; } catch (Exception $e) { echo "
The invoice for offer #{$id} could not be trashed.
"; } @@ -125,9 +122,9 @@ require('./header.php'); try { $offer = new Offer($_pdo, $id); if ($offer->delete()) { - echo "
The offer #{$offer->getId()} has been removed.
"; + echo "
The offer #{$offer->id} has been removed.
"; } else { - echo "
The offer #{$offer->getId()} could not be removed. Perhaps it's already removed?
"; + echo "
The offer #{$offer->id} could not be removed. Perhaps it's already removed?
"; } } catch (PDOException $e) { echo "
The offer could not be removed due to a PDO error.
"; -- cgit v1.2.3