diff options
author | Camil Staps | 2016-07-27 21:29:57 +0200 |
---|---|---|
committer | Camil Staps | 2016-07-27 21:29:57 +0200 |
commit | 2acc7787e73c966c3fc1794d77dd758a3f56b566 (patch) | |
tree | 1def501ec9502dee79f0f54a470434a3b322f6a2 /include/offers.php | |
parent | Contact: use Model (diff) |
Offer: use Model
Diffstat (limited to 'include/offers.php')
-rw-r--r-- | include/offers.php | 21 |
1 files changed, 9 insertions, 12 deletions
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 = "<a href='".Constants::url_external."offers'>Offers</a> / #{$offer->getId()}"; + $header = "<a href='".Constants::url_external."offers'>Offers</a> / #{$offer->id}"; $show_individual = $id; } catch (PDOException $e) { $alert = "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The offer with id $id</i> could not be found.</div>"; @@ -68,11 +68,8 @@ require('./header.php'); $id = (int) $_GET['toggle_accept']; try { $offer = new Offer($_pdo, $id); - if ($offer->toggleAccepted()) { - echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The status offer #{$offer->getId()} has been set to <i>".($offer->isAccepted() ? "accepted" : "unaccepted")."</i>.</div>"; - } else { - echo "<div class='alert alert-warning alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The status of the offer #{$offer->getId()} could not be changed.</div>"; - } + $offer->accepted = !$offer->accepted; + echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The status offer #{$offer->id} has been set to <i>".($offer->accepted ? "accepted" : "unaccepted")."</i>.</div>"; } catch (PDOException $e) { echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The status of the offer could not be changed due to a PDO error.</div>"; } catch (Exception $e) { @@ -89,9 +86,9 @@ require('./header.php'); try { $offer = new Offer($_pdo, $id); $file = $offer->generateInvoice(); - echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$offer->getId()} is generated: <a class='alert-link' href='{$file->getFilenameURI()}' target='_blank'>{$file->filename}</a></div>"; + echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$offer->id} is generated: <a class='alert-link' href='{$file->getFilenameURI()}' target='_blank'>{$file->filename}</a></div>"; } catch (PDOException $e) { - echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$offer->getId()} could not be generated due to a PDO error.</div>"; + echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$offer->id} could not be generated due to a PDO error.</div>"; } catch (Exception $e) { echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$id} could not be generated.</div>"; } @@ -106,12 +103,12 @@ require('./header.php'); $offer = new Offer($_pdo, $id); $file = $offer->getInvoiceFile(); if ($file instanceof file && $file->delete()) { - echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$offer->getId()} is trashed.</div>"; + echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$offer->id} is trashed.</div>"; } else { echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$id} could not be trashed.</div>"; } } catch (PDOException $e) { - echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$offer->getId()} could not be trashed due to a PDO error.</div>"; + echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$offer->id} could not be trashed due to a PDO error.</div>"; } catch (Exception $e) { echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$id} could not be trashed.</div>"; } @@ -125,9 +122,9 @@ require('./header.php'); try { $offer = new Offer($_pdo, $id); if ($offer->delete()) { - echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The offer #{$offer->getId()} has been removed.</div>"; + echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The offer #{$offer->id} has been removed.</div>"; } else { - echo "<div class='alert alert-warning alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The offer #{$offer->getId()} could not be removed. Perhaps it's already removed?</div>"; + echo "<div class='alert alert-warning alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The offer #{$offer->id} could not be removed. Perhaps it's already removed?</div>"; } } catch (PDOException $e) { echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The offer could not be removed due to a PDO error.</div>"; |