aboutsummaryrefslogtreecommitdiff
path: root/classes/OfferItem.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/OfferItem.php')
-rw-r--r--classes/OfferItem.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/classes/OfferItem.php b/classes/OfferItem.php
new file mode 100644
index 0000000..5753eb2
--- /dev/null
+++ b/classes/OfferItem.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Provides the OfferItem class, an interface to database tables related to
+ * offers
+ *
+ * @author Camil Staps
+ *
+ * BusinessAdmin: administrative software for small companies
+ * Copyright (C) 2015 Camil Staps (ViviSoft)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * An abstract interface to a database table related to offers
+ */
+abstract class OfferItem extends Model implements Calculatable {
+ /**
+ * Get the offer that this assignment is linked to
+ *
+ * @return offer The offer
+ */
+ public function getOffer() {
+ return new Offer($this->pdo, $this->offerId);
+ }
+
+ /**
+ * The description after having parsed markdown
+ *
+ * @return string The description in HTML format
+ */
+ public function getHTMLDescription() {
+ $pd = new Parsedown;
+ return $pd->text($this->description);
+ }
+
+ public function calculateVAT() {
+ return $this->calculateSubtotal() * $this->VAT_percentage / 100;
+ }
+}