aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2016-07-27 18:46:36 +0200
committerCamil Staps2016-07-27 20:48:46 +0200
commite73a0078128cc3154c8c70d57fd3c9c8112087b9 (patch)
treea2e0151c8c924af53b77115f53e964993cebe1f0
parentUser: use Model (diff)
Assignment: use Model
-rw-r--r--classes/Assignment.php245
-rw-r--r--classes/Offer.php8
-rw-r--r--include/assignments-edit.php11
-rw-r--r--include/assignments-new.php2
-rw-r--r--include/assignments-overview.php22
-rw-r--r--include/assignments-view.php16
-rw-r--r--include/assignments.php6
-rw-r--r--include/home.php4
-rw-r--r--include/offers-overview.php2
-rw-r--r--include/offers-view.php20
10 files changed, 57 insertions, 279 deletions
diff --git a/classes/Assignment.php b/classes/Assignment.php
index b4a67dc..d04568b 100644
--- a/classes/Assignment.php
+++ b/classes/Assignment.php
@@ -24,76 +24,18 @@
/**
* An interface to the assignment table in the database
*/
-class Assignment {
+class Assignment extends Model {
use Calculatable;
- /**
- * @var pdo $pdo The PDO class for database communication
- * @var int $id The id of the assignment
- * @var int $offerId The id of the offer this assignment is linked to
- * @var string $title The title of the assignment
- * @var string $description The description of the assignment
- * @var int $hours The amount of hours of the assignment
- * @var float $price_per_hour The price per hour for this assignment, in your valuta
- * @var float $vat The percentage of VAT to calculate on this assignment
- */
- protected $pdo, $offerId, $id, $title, $description, $hours, $price_per_hour, $vat;
+ public
+ $table = 'assignment',
+ $fillable_columns = ['offerId', 'title', 'description', 'hours', 'price_per_hour', 'VAT_percentage'];
const SUBTOTAL = 1;
const VAT = 2;
const TOTAL = 3;
/**
- * Create a new instance
- *
- * @param PDO $pdo The PDO class, to access the database
- * @param int $id The id of the assignment to fetch
- *
- * @throws PDOException If something went wrong with the database
- * @throws Exception If the assignment could not be found
- */
- public function __construct($pdo, $id) {
- $this->pdo = $pdo;
-
- $stmt = $this->pdo->prepare("SELECT * FROM `".Constants::db_prefix."assignment` WHERE `id`=?");
- $stmt->execute(array($id));
- if ($stmt->rowCount() == 0) {
- throw new Exception("The assignment with id '$id' could not be found.");
- }
- $assignment = $stmt->fetch(PDO::FETCH_ASSOC);
-
- $this->id = $assignment['id'];
- $this->offerId = $assignment['offerId'];
- $this->title = $assignment['title'];
- $this->description = $assignment['description'];
- $this->hours = $assignment['hours'];
- $this->price_per_hour = $assignment['price_per_hour'];
- $this->vat = $assignment['VAT_percentage'];
- }
-
- //------------------------------------------------------------------------------
- // Getters and setters
- //------------------------------------------------------------------------------
-
- /**
- * Get the ID of the assignment
- *
- * @return int The ID
- */
- public function getId() {
- return $this->id;
- }
-
- /**
- * Get the ID of the offer that this assignment is linked to
- *
- * @return int The ID
- */
- public function getOfferId() {
- return $this->offerId;
- }
-
- /**
* Get the offer that this assignment is linked to
*
* @return offer The offer
@@ -103,185 +45,20 @@ class Assignment {
}
/**
- * Get the title of the assignment
+ * The description after having parsed markdown
*
- * @return string The title
+ * @return string The description in HTML format
*/
- public function getTitle() {
- return $this->title;
+ public function getHTMLDescription() {
+ $pd = new Parsedown;
+ return $pd->text($this->description);
}
- /**
- * Set the title of the assignment
- *
- * @param string $title The new title for the assignment
- *
- * @throws PDOException If something went wrong with the database
- *
- * @return bool True on succes, false on failure
- */
- public function setTitle($title) {
- $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."assignment` SET `title`=? WHERE `id`=?");
- $stmt->execute(array($title, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->title = $title;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the description of the assignment
- *
- * @param bool $parseMarkdown Whether or not to parse markdown
- *
- * @return string The description
- */
- public function getDescription($parseMarkdown = true) {
- if ($parseMarkdown) {
- $pd = new Parsedown;
- return $pd->text($this->description);
- } else {
- return $this->description;
- }
- }
-
- /**
- * Set the description of the assignment
- *
- * @param string $description The new description for the assignment
- *
- * @throws PDOException If something went wrong with the database
- *
- * @return bool True on succes, false on failure
- */
- public function setDescription($description) {
- $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."assignment` SET `description`=? WHERE `id`=?");
- $stmt->execute(array($description, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->description = $description;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the amount of hours of the assignment
- *
- * @return int The amount of hours
- */
- public function getHours() {
- return $this->hours;
- }
-
- /**
- * Set the amount of hours of the assignment
- *
- * @param int $hours The new amount hours for the assignment
- *
- * @throws PDOException If something went wrong with the database
- *
- * @return bool True on succes, false on failure
- */
- public function setHours($hours) {
- $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."assignment` SET `hours`=? WHERE `id`=?");
- $stmt->execute(array($hours, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->hours = $hours;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the price per hour of the assignment
- *
- * @return float The price per hour
- */
- public function getPricePerHour() {
- return $this->price_per_hour;
- }
-
- /**
- * Set the price per hour of the assignment
- *
- * @param float $price_per_hour The new price per hour for the assignment
- *
- * @throws PDOException If something went wrong with the database
- *
- * @return bool True on succes, false on failure
- */
- public function setPricePerHour($price_per_hour) {
- $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."assignment` SET `price_per_hour`=? WHERE `id`=?");
- $stmt->execute(array($price_per_hour, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->price_per_hour = $price_per_hour;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the VAT percentage of the assignment
- *
- * @return float The VAT percentage
- */
- public function getVAT() {
- return $this->vat;
- }
-
- /**
- * Set the VAT percentage of the assignment
- *
- * @param float $vat The new VAT percentage for the assignment
- *
- * @throws PDOException If something went wrong with the database
- *
- * @return bool True on succes, false on failure
- */
- public function setVAT($vat) {
- $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."assignment` SET `VAT_percentage`=? WHERE `id`=?");
- $stmt->execute(array($vat, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->vat = $vat;
- return true;
- } else {
- return false;
- }
- }
-
- //------------------------------------------------------------------------------
- // Other functions
- //------------------------------------------------------------------------------
-
protected function calculateSubtotal() {
- return $this->getHours() * $this->getPricePerHour();
+ return $this->hours * $this->price_per_hour;
}
protected function calculateVAT() {
- return $this->calculateSubtotal() * $this->getVAT() / 100;
- }
-
- /**
- * Remove this assignment from the database
- *
- * If this doesn't succeed (i.e. false is returned), that means the assignment was removed manually or by another instance of this class
- *
- * @throws PDOException If something went wrong with the database
- *
- * @return bool True on success, false on failure
- */
- public function delete() {
- $stmt = $this->pdo->prepare("DELETE FROM `".Constants::db_prefix."assignment` WHERE `id`=?");
- $stmt->execute(array($this->id));
- if ($stmt->rowCount() != 1) {
- return false;
- } else {
- return true;
- }
+ return $this->calculateSubtotal() * $this->VAT_percentage / 100;
}
}
diff --git a/classes/Offer.php b/classes/Offer.php
index 7b23a43..1a11633 100644
--- a/classes/Offer.php
+++ b/classes/Offer.php
@@ -574,10 +574,10 @@ class Offer {
$list = array();
foreach ($this->getAssignments() as $assignment)
$list[] = array(
- $assignment->getTitle(),
- $assignment->getPricePerHour() * $assignment->getHours(),
- $assignment->getVAT() . "%",
- $assignment->getPricePerHour() * $assignment->getHours() * (1 + $assignment->getVAT() / 100)
+ $assignment->title,
+ $assignment->price_per_hour * $assignment->hours,
+ $assignment->VAT_percentage . "%",
+ $assignment->price_per_hour * $assignment->hours * (1 + $assignment->VAT_percentage / 100)
);
foreach ($this->getDiscounts() as $discount)
$list[] = array(
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. <a class='alert-link' href='javascript:location.reload(true);'>Refresh the page</a>.";
+ $response->message = "Assignment {$assignment->title} has been succesfully created. <a class='alert-link' href='javascript:location.reload(true);'>Refresh the page</a>.";
} 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 "<tr class='mix'
- data-mixer-order-id='{$assignment->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()}'>
- <td class='col-min-width'>{$assignment->getId()}</td>
+ data-mixer-order-time='{$assignment->hours}'
+ data-mixer-order-price='{$assignment->price_per_hour}'>
+ <td class='col-min-width'>{$assignment->id}</td>
<td class='col-min-width'>
<a href='".Constants::url_internal."/offers?id={$assignment->getOffer()->getId()}'>#{$assignment->getOffer()->getId()}</a> to
<a href='".Constants::url_internal."/contacts?id={$assignment->getOffer()->getContact()->getId()}'>{$assignment->getOffer()->getContact()->getName()}</a>
(<a href='".Constants::url_internal."/clients?id={$assignment->getOffer()->getContact()->getClient()->id}'>{$assignment->getOffer()->getContact()->getClient()->name}</a>)
<td class='col-max-width'>
- <b><a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-title' data-type='text' data-pk='{$assignment->getId()}' data-url='".Constants::url_external."assignments/edit'>{$assignment->getTitle()}</a></b><br/>
- <p><a href='#' class='editable editable-noshow' id='editable-assignment-{$assignment->getId()}-description' data-type='textarea' data-mode='inline' data-pk='{$assignment->getId()}' data-url='".Constants::url_external."assignments/edit'>{$assignment->getDescription(false)}</a></p>
+ <b><a href='#' class='editable' id='editable-assignment-{$assignment->id}-title' data-type='text' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->title}</a></b><br/>
+ <p><a href='#' class='editable editable-noshow' id='editable-assignment-{$assignment->id}-description' data-type='textarea' data-mode='inline' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->description}</a></p>
</td>
- <td class='col-min-width'><a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-hours' data-type='text' data-pk='{$assignment->getId()}' data-url='".Constants::url_external."assignments/edit'>{$assignment->getHours()}</a>h</td>
+ <td class='col-min-width'><a href='#' class='editable' id='editable-assignment-{$assignment->id}-hours' data-type='text' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->hours}</a>h</td>
<td class='col-min-width'>
- ".Constants::invoice_valuta."<a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-price_per_hour' data-type='text' data-pk='{$assignment->getId()}' data-url='".Constants::url_external."assignments/edit'>{$assignment->getPricePerHour()}</a> / hr<br/>
- <a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-vat' data-type='text' data-pk='{$assignment->getId()}' data-url='".Constants::url_external."assignments/edit'>{$assignment->getVAT()}</a>% VAT
+ ".Constants::invoice_valuta."<a href='#' class='editable' id='editable-assignment-{$assignment->id}-price_per_hour' data-type='text' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->price_per_hour}</a> / hr<br/>
+ <a href='#' class='editable' id='editable-assignment-{$assignment->id}-vat' data-type='text' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->VAT_percentage}</a>% VAT
</td>
<td class='col-min-width'>
- <a title='View' href='?id={$assignment->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a>
- <a title='Delete' href='?delete={$assignment->getId()}' class='btn btn-danger btn-circle fa fa-times'></a>
+ <a title='View' href='?id={$assignment->id}' class='btn btn-primary btn-circle fa fa-arrow-right'></a>
+ <a title='Delete' href='?delete={$assignment->id}' class='btn btn-danger btn-circle fa fa-times'></a>
</td>
</tr>";
}
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);
<tbody>
<?php
echo "<tr class='mix'
- data-mixer-order-id='{$_assignment->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()}'>
- <td class='col-min-width'>{$_assignment->getId()}</td>
+ data-mixer-order-time='{$_assignment->hours}'
+ data-mixer-order-price='{$_assignment->price_per_hour}'>
+ <td class='col-min-width'>{$_assignment->id}</td>
<td class='col-min-width'>
<a href='".Constants::url_internal."/offers?id={$_assignment->getOffer()->getId()}'>#{$_assignment->getOffer()->getId()}</a> to
<a href='".Constants::url_internal."/contacts?id={$_assignment->getOffer()->getContact()->getId()}'>{$_assignment->getOffer()->getContact()->getName()}</a>
(<a href='".Constants::url_internal."/clients?id={$_assignment->getOffer()->getContact()->getClient()->id}'>{$_assignment->getOffer()->getContact()->getClient()->name}</a>)
</td>
- <td class='col-min-width'><a href='#' class='editable' id='editable-_assignment-{$_assignment->getId()}-hours' data-type='text' data-pk='{$_assignment->getId()}' data-url='".Constants::url_external."_assignments/edit'>{$_assignment->getHours()}</a>h</td>
+ <td class='col-min-width'><a href='#' class='editable' id='editable-_assignment-{$_assignment->id}-hours' data-type='text' data-pk='{$_assignment->id}' data-url='".Constants::url_external."_assignments/edit'>{$_assignment->hours}</a>h</td>
<td class='col-min-width'>
- ".Constants::invoice_valuta."<a href='#' class='editable' id='editable-_assignment-{$_assignment->getId()}-price_per_hour' data-type='text' data-pk='{$_assignment->getId()}' data-url='".Constants::url_external."_assignments/edit'>{$_assignment->getPricePerHour()}</a> / hr<br/>
- <a href='#' class='editable' id='editable-_assignment-{$_assignment->getId()}-vat' data-type='text' data-pk='{$_assignment->getId()}' data-url='".Constants::url_external."_assignments/edit'>{$_assignment->getVAT()}</a>% VAT
+ ".Constants::invoice_valuta."<a href='#' class='editable' id='editable-_assignment-{$_assignment->id}-price_per_hour' data-type='text' data-pk='{$_assignment->id}' data-url='".Constants::url_external."_assignments/edit'>{$_assignment->price_per_hour}</a> / hr<br/>
+ <a href='#' class='editable' id='editable-_assignment-{$_assignment->id}-vat' data-type='text' data-pk='{$_assignment->id}' data-url='".Constants::url_external."_assignments/edit'>{$_assignment->VAT_percentage}</a>% VAT
</td>
</tr>";
?>
@@ -63,7 +63,7 @@ $_assignment = new Assignment($_pdo, $_id);
<div class="panel panel-default">
<div class="panel-heading">Description</div>
<div class="panel-body">
- <?=$_assignment->getDescription()?>
+ <?=$_assignment->getHTMLDescription()?>
</div>
</div>
</div>
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 = "<a href='".Constants::url_external."assignments'>Assignments</a> / {$assignment->getTitle()}";
+ $header = "<a href='".Constants::url_external."assignments'>Assignments</a> / {$assignment->title}";
$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 assignment with id $id</i> could not be found.</div>";
@@ -66,9 +66,9 @@ require('./header.php');
try {
$assignment = new Assignment($_pdo, $id);
if ($assignment->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 assignment with title <i>{$assignment->getTitle()}</i> 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 assignment with title <i>{$assignment->title}</i> 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 assignment with title <i>{$assignment->getTitle()}</i> 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 assignment with title <i>{$assignment->title}</i> 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 assignment could not be removed due to a PDO error.</div>";
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'] .= "<b>{$assignment->getTitle()}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getDescription()}</p>";
- $temp['assignments_header'] .= "<b>{$assignment->getTitle()}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/>";
+ $temp['assignments'] .= "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getHTMLDescription()}</p>";
+ $temp['assignments_header'] .= "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/>";
}
$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');
<td class='col-min-width'><span title='{$offer->getContact()->getClient()->name}'>{$offer->getContact()->getName()}</span></td>
<td class='col-max-width'>";
foreach ($offer->getAssignments() as $assignment) {
- echo "<b>{$assignment->getTitle()}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getDescription()}</p>";
+ echo "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getHTMLDescription()}</p>";
}
foreach ($offer->getDiscounts() as $discount) {
echo "<b>{$discount->getTitle()}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$discount->calculate(discount::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$discount->calculate(discount::TOTAL)} incl. VAT)</span><br/><p>{$discount->getDescription()}</p>";
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'] .= "<b>{$assignment->getTitle()}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getDescription()}</p>";
- $temp['assignments_header'] .= "<b>{$assignment->getTitle()}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/>";
+ $temp['assignments'] .= "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getHTMLDescription()}</p>";
+ $temp['assignments_header'] .= "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/>";
}
$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 "<tr>
- <td class='col-min-width'>{$assignment->getId()}</td>
+ <td class='col-min-width'>{$assignment->id}</td>
<td class='col-max-width'>
- <b><a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-title' data-type='text' data-pk='{$assignment->getId()}' data-url='".Constants::url_external."assignments/edit'>{$assignment->getTitle()}</a></b><br/>
- <p>{$assignment->getDescription()}</p>
+ <b><a href='#' class='editable' id='editable-assignment-{$assignment->id}-title' data-type='text' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->title}</a></b><br/>
+ <p>{$assignment->getHTMLDescription()}</p>
</td>
- <td class='col-min-width'><a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-hours' data-type='text' data-pk='{$assignment->getId()}' data-url='".Constants::url_external."assignments/edit'>{$assignment->getHours()}</a>h</td>
+ <td class='col-min-width'><a href='#' class='editable' id='editable-assignment-{$assignment->id}-hours' data-type='text' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->hours}</a>h</td>
<td class='col-min-width'>
- ".Constants::invoice_valuta."<a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-price_per_hour' data-type='text' data-pk='{$assignment->getId()}' data-url='".Constants::url_external."assignments/edit'>{$assignment->getPricePerHour()}</a> / hr<br/>
- <a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-vat' data-type='text' data-pk='{$assignment->getId()}' data-url='".Constants::url_external."assignments/edit'>{$assignment->getVAT()}</a>% VAT
+ ".Constants::invoice_valuta."<a href='#' class='editable' id='editable-assignment-{$assignment->id}-price_per_hour' data-type='text' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->price_per_hour}</a> / hr<br/>
+ <a href='#' class='editable' id='editable-assignment-{$assignment->id}-vat' data-type='text' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->VAT_percentage}</a>% VAT
</td>
<td class='col-min-width'>
- <a title='View' href='".Constants::url_internal."/assignments?id={$assignment->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a>
- <a title='Delete' href='".Constants::url_internal."/assignments?delete={$assignment->getId()}' class='btn btn-danger btn-circle fa fa-times'></a>
+ <a title='View' href='".Constants::url_internal."/assignments?id={$assignment->id}' class='btn btn-primary btn-circle fa fa-arrow-right'></a>
+ <a title='Delete' href='".Constants::url_internal."/assignments?delete={$assignment->id}' class='btn btn-danger btn-circle fa fa-times'></a>
</td>
</tr>";
}