From e73a0078128cc3154c8c70d57fd3c9c8112087b9 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 27 Jul 2016 18:46:36 +0200 Subject: Assignment: use Model --- include/assignments-edit.php | 11 ++++++----- include/assignments-new.php | 2 +- include/assignments-overview.php | 22 +++++++++++----------- include/assignments-view.php | 16 ++++++++-------- include/assignments.php | 6 +++--- include/home.php | 4 ++-- include/offers-overview.php | 2 +- include/offers-view.php | 20 ++++++++++---------- 8 files changed, 42 insertions(+), 41 deletions(-) (limited to 'include') diff --git a/include/assignments-edit.php b/include/assignments-edit.php index d2f5a6c..b51eab6 100644 --- a/include/assignments-edit.php +++ b/include/assignments-edit.php @@ -21,6 +21,7 @@ require_once('./conf.php'); require_once('./login-ajax.php'); $response = new Response(); +$response->success = true; try { $assignment = new Assignment($_pdo, $_REQUEST['pk']); @@ -29,19 +30,19 @@ try { $what_to_edit = $name[count($name) - 1]; switch ($what_to_edit) { case 'title': - $response->success = $assignment->setTitle($_REQUEST['value']); + $assignment->title = $_REQUEST['value']; break; case 'hours': - $response->success = $assignment->setHours($_REQUEST['value']); + $assignment->hours = $_REQUEST['value']; break; case 'price_per_hour': - $response->success = $assignment->setPricePerHour($_REQUEST['value']); + $assignment->price_per_hour = $_REQUEST['value']; break; case 'vat': - $response->success = $assignment->setVAT($_REQUEST['value']); + $assignment->VAT_percentage = $_REQUEST['value']; break; case 'description': - $response->success = $assignment->setDescription($_REQUEST['value']); + $assignment->description = $_REQUEST['value']; break; default: $response->http_response_code(404); diff --git a/include/assignments-new.php b/include/assignments-new.php index bcc545a..932e200 100644 --- a/include/assignments-new.php +++ b/include/assignments-new.php @@ -33,7 +33,7 @@ try { $_REQUEST['vat'] ); $response->success = true; - $response->message = "Assignment {$assignment->getTitle()} has been succesfully created. Refresh the page."; + $response->message = "Assignment {$assignment->title} has been succesfully created. Refresh the page."; } catch (PDOException $e) { $response->http_response_code(500); $response->success = false; diff --git a/include/assignments-overview.php b/include/assignments-overview.php index d4b350e..9fa226f 100644 --- a/include/assignments-overview.php +++ b/include/assignments-overview.php @@ -40,27 +40,27 @@ require_once('./login.php'); $assignments = BusinessAdmin::getAssignments($_pdo); foreach ($assignments as $assignment) { echo " - {$assignment->getId()} + data-mixer-order-time='{$assignment->hours}' + data-mixer-order-price='{$assignment->price_per_hour}'> + {$assignment->id} #{$assignment->getOffer()->getId()} to {$assignment->getOffer()->getContact()->getName()} ({$assignment->getOffer()->getContact()->getClient()->name}) - {$assignment->getTitle()}
-

{$assignment->getDescription(false)}

+ {$assignment->title}
+

{$assignment->description}

- {$assignment->getHours()}h + {$assignment->hours}h - ".Constants::invoice_valuta."{$assignment->getPricePerHour()} / hr
- {$assignment->getVAT()}% VAT + ".Constants::invoice_valuta."{$assignment->price_per_hour} / hr
+ {$assignment->VAT_percentage}% VAT - - + + "; } diff --git a/include/assignments-view.php b/include/assignments-view.php index d0a4ff3..4c031d3 100644 --- a/include/assignments-view.php +++ b/include/assignments-view.php @@ -37,20 +37,20 @@ $_assignment = new Assignment($_pdo, $_id); getId()}' + data-mixer-order-id='{$_assignment->id}' data-mixer-order-offer='{$_assignment->getOffer()->getId()}' - data-mixer-order-time='{$_assignment->getHours()}' - data-mixer-order-price='{$_assignment->getPricePerHour()}'> - {$_assignment->getId()} + data-mixer-order-time='{$_assignment->hours}' + data-mixer-order-price='{$_assignment->price_per_hour}'> + {$_assignment->id} #{$_assignment->getOffer()->getId()} to {$_assignment->getOffer()->getContact()->getName()} ({$_assignment->getOffer()->getContact()->getClient()->name}) - {$_assignment->getHours()}h + {$_assignment->hours}h - ".Constants::invoice_valuta."{$_assignment->getPricePerHour()} / hr
- {$_assignment->getVAT()}% VAT + ".Constants::invoice_valuta."{$_assignment->price_per_hour} / hr
+ {$_assignment->VAT_percentage}% VAT "; ?> @@ -63,7 +63,7 @@ $_assignment = new Assignment($_pdo, $_id);
Description
- getDescription()?> + getHTMLDescription()?>
diff --git a/include/assignments.php b/include/assignments.php index 7c3c79d..32e0c20 100644 --- a/include/assignments.php +++ b/include/assignments.php @@ -46,7 +46,7 @@ require('./header.php'); $id = (int) $_GET['id']; try { $assignment = new Assignment($_pdo, $id); - $header = "Assignments / {$assignment->getTitle()}"; + $header = "Assignments / {$assignment->title}"; $show_individual = $id; } catch (PDOException $e) { $alert = "
The assignment with id $id could not be found.
"; @@ -66,9 +66,9 @@ require('./header.php'); try { $assignment = new Assignment($_pdo, $id); if ($assignment->delete()) { - echo "
The assignment with title {$assignment->getTitle()} has been removed.
"; + echo "
The assignment with title {$assignment->title} has been removed.
"; } else { - echo "
The assignment with title {$assignment->getTitle()} could not be removed. Perhaps it's already removed?
"; + echo "
The assignment with title {$assignment->title} could not be removed. Perhaps it's already removed?
"; } } catch (PDOException $e) { echo "
The assignment could not be removed due to a PDO error.
"; diff --git a/include/home.php b/include/home.php index a15d2c4..3b461bc 100644 --- a/include/home.php +++ b/include/home.php @@ -285,8 +285,8 @@ require('./header.php'); 'assignments_header' => '' ); foreach ($offer->getAssignments() as $assignment) { - $temp['assignments'] .= "{$assignment->getTitle()}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)

{$assignment->getDescription()}

"; - $temp['assignments_header'] .= "{$assignment->getTitle()}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)
"; + $temp['assignments'] .= "{$assignment->title}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)

{$assignment->getHTMLDescription()}

"; + $temp['assignments_header'] .= "{$assignment->title}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)
"; } $list[] = array_merge($temp, array('type' => 'start', 'time' => $offer->getStartDate(), 'description' => 'Offer started')); $sort_list[] = $offer->getStartDate() . $offer->getId() . 0; diff --git a/include/offers-overview.php b/include/offers-overview.php index 9c0a706..09c6e12 100644 --- a/include/offers-overview.php +++ b/include/offers-overview.php @@ -46,7 +46,7 @@ require_once('./login.php'); {$offer->getContact()->getName()} "; foreach ($offer->getAssignments() as $assignment) { - echo "{$assignment->getTitle()}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)

{$assignment->getDescription()}

"; + 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()}

"; diff --git a/include/offers-view.php b/include/offers-view.php index 9b69dce..6b84e5c 100644 --- a/include/offers-view.php +++ b/include/offers-view.php @@ -40,8 +40,8 @@ $_offer = new Offer($_pdo, $_id); 'assignments_header' => '' ); foreach ($_offer->getAssignments() as $assignment) { - $temp['assignments'] .= "{$assignment->getTitle()}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)

{$assignment->getDescription()}

"; - $temp['assignments_header'] .= "{$assignment->getTitle()}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)
"; + $temp['assignments'] .= "{$assignment->title}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)

{$assignment->getHTMLDescription()}

"; + $temp['assignments_header'] .= "{$assignment->title}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)
"; } $list[] = array_merge($temp, array('type' => 'start', 'time' => $_offer->getStartDate(), 'description' => 'Offer started')); $sort_list[] = $_offer->getStartDate() . $_offer->getId() . 0; @@ -104,19 +104,19 @@ $_offer = new Offer($_pdo, $_id); $assignments = BusinessAdmin::getAssignments($_pdo, array("offerId = {$_offer->getId()}")); foreach ($assignments as $assignment) { echo " - {$assignment->getId()} + {$assignment->id} - {$assignment->getTitle()}
-

{$assignment->getDescription()}

+ {$assignment->title}
+

{$assignment->getHTMLDescription()}

- {$assignment->getHours()}h + {$assignment->hours}h - ".Constants::invoice_valuta."{$assignment->getPricePerHour()} / hr
- {$assignment->getVAT()}% VAT + ".Constants::invoice_valuta."{$assignment->price_per_hour} / hr
+ {$assignment->VAT_percentage}% VAT - - + + "; } -- cgit v1.2.3