From ee7b6b8cc0cb8619c298f533a2ac791d7aa3b57c Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Wed, 27 Jul 2016 20:54:34 +0200
Subject: Discount: use Model
---
include/discounts-edit.php | 9 +++++----
include/discounts-new.php | 2 +-
include/discounts-overview.php | 18 +++++++++---------
include/discounts.php | 6 +++---
include/offers-overview.php | 2 +-
include/offers-view.php | 14 +++++++-------
6 files changed, 26 insertions(+), 25 deletions(-)
(limited to 'include')
diff --git a/include/discounts-edit.php b/include/discounts-edit.php
index 797a95b..94f4c29 100644
--- a/include/discounts-edit.php
+++ b/include/discounts-edit.php
@@ -21,6 +21,7 @@ require_once('./conf.php');
require_once('./login-ajax.php');
$response = new Response();
+$response->success = true;
try {
$discount = new Discount($_pdo, $_REQUEST['pk']);
@@ -29,16 +30,16 @@ try {
$what_to_edit = $name[count($name) - 1];
switch ($what_to_edit) {
case 'title':
- $response->success = $discount->setTitle($_REQUEST['value']);
+ $discount->title = $_REQUEST['value'];
break;
case 'value':
- $response->success = $discount->setValue($_REQUEST['value']);
+ $discount->value = $_REQUEST['value'];
break;
case 'vat':
- $response->success = $discount->setVAT($_REQUEST['value']);
+ $discount->VAT_percentage = $_REQUEST['value'];
break;
case 'description':
- $response->success = $discount->setDescription($_REQUEST['value']);
+ $discount->description = $_REQUEST['value'];
break;
default:
$response->http_response_code(404);
diff --git a/include/discounts-new.php b/include/discounts-new.php
index 26452aa..2d7fca5 100644
--- a/include/discounts-new.php
+++ b/include/discounts-new.php
@@ -32,7 +32,7 @@ try {
$_REQUEST['vat']
);
$response->success = true;
- $response->message = "Assignment {$discount->getTitle()} has been succesfully created. Refresh the page.";
+ $response->message = "Assignment {$discount->title} has been succesfully created. Refresh the page.";
} catch (PDOException $e) {
$response->http_response_code(500);
$response->success = false;
diff --git a/include/discounts-overview.php b/include/discounts-overview.php
index 60ddf13..0b0534d 100644
--- a/include/discounts-overview.php
+++ b/include/discounts-overview.php
@@ -39,25 +39,25 @@ require_once('./login.php');
$discounts = BusinessAdmin::getDiscounts($_pdo);
foreach ($discounts as $discount) {
echo "
- {$discount->getId()} |
+ data-mixer-order-value='{$discount->value}'>
+ {$discount->id} |
#{$discount->getOffer()->getId()} to
{$discount->getOffer()->getContact()->getName()}
({$discount->getOffer()->getContact()->getClient()->name})
|
- {$discount->getTitle()}
- {$discount->getDescription(false)}
+ {$discount->title}
+ {$discount->description}
|
- ".Constants::invoice_valuta."{$discount->getValue()}
- {$discount->getVAT()}% VAT
+ ".Constants::invoice_valuta."{$discount->value}
+ {$discount->VAT_percentage}% VAT
|
-
-
+
+
|
";
}
diff --git a/include/discounts.php b/include/discounts.php
index a4d9df6..5da2dc4 100644
--- a/include/discounts.php
+++ b/include/discounts.php
@@ -46,7 +46,7 @@ require('./header.php');
$id = (int) $_GET['id'];
try {
$discount = new Discount($_pdo, $id);
- $header = "Discounts / {$discount->getTitle()}";
+ $header = "Discounts / {$discount->title}";
$show_individual = $id;
} catch (PDOException $e) {
$alert = "The discount with id $id could not be found.
";
@@ -66,9 +66,9 @@ require('./header.php');
try {
$discount = new Discount($_pdo, $id);
if ($discount->delete()) {
- echo "The discount with title {$discount->getTitle()} has been removed.
";
+ echo "The discount with title {$discount->title} has been removed.
";
} else {
- echo "The discount with title {$discount->getTitle()} could not be removed. Perhaps it's already removed?
";
+ echo "The discount with title {$discount->title} could not be removed. Perhaps it's already removed?
";
}
} catch (PDOException $e) {
echo "The discount could not be removed due to a PDO error.
";
diff --git a/include/offers-overview.php b/include/offers-overview.php
index 09c6e12..2c5b483 100644
--- a/include/offers-overview.php
+++ b/include/offers-overview.php
@@ -49,7 +49,7 @@ require_once('./login.php');
echo "{$assignment->title}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)
{$assignment->getHTMLDescription()}
";
}
foreach ($offer->getDiscounts() as $discount) {
- echo "{$discount->getTitle()}
(".Constants::invoice_valuta."{$discount->calculate(discount::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$discount->calculate(discount::TOTAL)} incl. VAT)
{$discount->getDescription()}
";
+ echo "{$discount->title}
(".Constants::invoice_valuta."{$discount->calculate(discount::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$discount->calculate(discount::TOTAL)} incl. VAT)
{$discount->description}
";
}
echo "
diff --git a/include/offers-view.php b/include/offers-view.php
index 6b84e5c..9a2978f 100644
--- a/include/offers-view.php
+++ b/include/offers-view.php
@@ -147,18 +147,18 @@ $_offer = new Offer($_pdo, $_id);
$discounts = BusinessAdmin::getDiscounts($_pdo, array("offerId = {$_offer->getId()}"));
foreach ($discounts as $discount) {
echo " |
- {$discount->getId()} |
+ {$discount->id} |
- {$discount->getTitle()}
- {$discount->getDescription()}
+ {$discount->title}
+ {$discount->description}
|
- ".Constants::invoice_valuta."{$discount->getValue()} / hr
- {$discount->getVAT()}% VAT
+ ".Constants::invoice_valuta."{$discount->value} / hr
+ {$discount->VAT_percentage}% VAT
|
-
-
+
+
|
";
}
--
cgit v1.2.3