diff options
Diffstat (limited to 'include/offers.php')
-rw-r--r-- | include/offers.php | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/include/offers.php b/include/offers.php index 2aa150d..8be7530 100644 --- a/include/offers.php +++ b/include/offers.php @@ -32,11 +32,12 @@ require('./header.php'); //------------------------------------------------------------------------------ // Check for GET variables // - // ?id=<id> View information of the offer with id <id> - // ?toggle_accept=<id> Toggle the accepted status of the offer with id <id> - // ?generate_invoice=<id> Generate an invoice for the offer with id <id> - // ?trash_invoice=<id> Trash the invoice file - // ?delete=<id> Delete the offer with id <id> + // ?id=<id> View information of the offer with id <id> + // ?toggle_accept=<id> Toggle the accepted status of the offer with id <id> + // ?toggle_payment_eligibility=<id> Toggle the payment eligibility of the offer with id <id> + // ?generate_invoice=<id> Generate an invoice for the offer with id <id> + // ?trash_invoice=<id> Trash the invoice file + // ?delete=<id> Delete the offer with id <id> //------------------------------------------------------------------------------ // The header of the page @@ -69,7 +70,7 @@ require('./header.php'); try { $offer = new Offer($_pdo, $id); $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>"; + 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 of 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) { @@ -79,6 +80,27 @@ require('./header.php'); echo "</div>"; } + // Toggle offer payment eligibility + if (isset($_GET['toggle_payment_eligibility'])) { + echo "<div class='col-lg-12'>"; + $id = (int) $_GET['toggle_payment_eligibility']; + try { + $offer = new Offer($_pdo, $id); + if ($offer->getPaymentEligibility()) { + $offer->payment_key = null; + } else { + $offer->payment_key = Offer::getRandomPaymentKey(); + } + 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} is now <i>".($offer->getPaymentEligibility() ? "eligible" : "ineligible")."</i> for online payment.</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 online payment eligibility could not be changed due to a PDO error.</div>"; + } catch (Exception $e) { + 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 with id {$id} could not be found.</div>"; + } + + echo "</div>"; + } + // Generate invoice if (isset($_GET['generate_invoice'])) { echo "<div class='col-lg-12'>"; |