aboutsummaryrefslogtreecommitdiff
path: root/classes/offer.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/offer.class.php')
-rw-r--r--classes/offer.class.php131
1 files changed, 64 insertions, 67 deletions
diff --git a/classes/offer.class.php b/classes/offer.class.php
index 1a465f4..9e0a956 100644
--- a/classes/offer.class.php
+++ b/classes/offer.class.php
@@ -26,15 +26,15 @@
*/
class offer {
/**
- * @var pdo $pdo The PDO class for database communication
- * @var int $id The id of the offer
- * @var int $contactId The id of the contact this offer is linked to
- * @var int $start_date A UNIX timestamp of the start date
- * @var int $end_date A UNIX timestamp of the end date
- * @var int $invoice_date A UNIX timestamp of the invoice date
- * @var bool $accepted Whether the offer is accepted or not
- * @var null|int $invoice_fileId If an invoice has been generated, an the id of the file
- * @var null|int $payment_received A UNIX timestamp of the date the payment has been received
+ * @var pdo $pdo The PDO class for database communication
+ * @var int $id The id of the offer
+ * @var int $contactId The id of the contact this offer is linked to
+ * @var int $start_date A UNIX timestamp of the start date
+ * @var int $end_date A UNIX timestamp of the end date
+ * @var int $invoice_date A UNIX timestamp of the invoice date
+ * @var bool $accepted Whether the offer is accepted or not
+ * @var null|int $invoice_fileId If an invoice has been generated, an the id of the file
+ * @var null|int $payment_received A UNIX timestamp of the date the payment has been received
*/
protected $pdo, $id, $contactId, $start_date, $end_date, $invoice_date, $accepted, $invoice_fileId, $payment_received;
@@ -45,11 +45,11 @@ class offer {
/**
* Create a new instance
*
- * @param PDO $pdo The PDO class, to access the database
- * @param int $id The id of the offer to fetch
+ * @param PDO $pdo The PDO class, to access the database
+ * @param int $id The id of the offer to fetch
*
- * @throws PDOException If something went wrong with the database
- * @throws Exception If the offer could not be found
+ * @throws PDOException If something went wrong with the database
+ * @throws Exception If the offer could not be found
*/
public function __construct($pdo, $id) {
$this->pdo = $pdo;
@@ -78,7 +78,7 @@ class offer {
/**
* Get the ID of the offer
*
- * @return int The ID
+ * @return int The ID
*/
public function getId() {
return $this->id;
@@ -87,9 +87,9 @@ class offer {
/**
* Get the ID of the contact that this offer is linked to
*
- * @see offer::getContact() This function returns the contact as an instance of the object class
+ * @see offer::getContact() This function returns the contact as an instance of the object class
*
- * @return int The ID
+ * @return int The ID
*/
public function getContactId() {
return $this->contactId;
@@ -98,9 +98,9 @@ class offer {
/**
* Get the contact that this offer is linked to
*
- * @see offer::getContactId() This function returns just the id
+ * @see offer::getContactId() This function returns just the id
*
- * @return contact The contact
+ * @return contact The contact
*/
public function getContact() {
return new contact($this->pdo, $this->contactId);
@@ -109,11 +109,11 @@ class offer {
/**
* Get all assignment ids for this offer
*
- * @see offer::getAssignments() This funtion returns instances of the assignment class instead of just the ids
+ * @see offer::getAssignments() This funtion returns instances of the assignment class instead of just the ids
*
* @throws PDOException Is something went wrong with the database
*
- * @return int[] The ids
+ * @return int[] The ids
*/
public function getAssignmentIds() {
$ids = array();
@@ -127,11 +127,11 @@ class offer {
/**
* Get all assignments for this offer
*
- * @see offer::getAssignmentIds() This function returns just the ids of the assignments, and not instances of the assignment class
+ * @see offer::getAssignmentIds() This function returns just the ids of the assignments, and not instances of the assignment class
*
- * @throws PDOException If something went wrong with the database
+ * @throws PDOException If something went wrong with the database
*
- * @return assignment[] An array indexed by id of instances of the assignment class
+ * @return assignment[] An array indexed by id of instances of the assignment class
*/
public function getAssignments() {
$ids = $this->getAssignmentIds();
@@ -145,7 +145,7 @@ class offer {
/**
* Get the start date of the assignment
*
- * @return int The start date as a UNIX timestamp
+ * @return int The start date as a UNIX timestamp
*/
public function getStartDate() {
return $this->start_date;
@@ -154,11 +154,11 @@ class offer {
/**
* Set the start date of the assignment
*
- * @param int $start_date The new start date for the assignment as a UNIX timestamp
+ * @param int $start_date The new start date for the assignment as a UNIX timestamp
*
- * @throws PDOException If something went wrong with the database
+ * @throws PDOException If something went wrong with the database
*
- * @return bool True on succes, false on failure
+ * @return bool True on succes, false on failure
*/
public function setStartDate($start_date) {
$stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."offer` SET `start_date`=? WHERE `id`=?");
@@ -174,7 +174,7 @@ class offer {
/**
* Get the end date of the assignment
*
- * @return int The end date as a UNIX timestamp
+ * @return int The end date as a UNIX timestamp
*/
public function getEndDate() {
return $this->end_date;
@@ -183,11 +183,11 @@ class offer {
/**
* Set the end date of the assignment
*
- * @param int $end_date The new end date for the assignment as a UNIX timestamp
+ * @param int $end_date The new end date for the assignment as a UNIX timestamp
*
- * @throws PDOException If something went wrong with the database
+ * @throws PDOException If something went wrong with the database
*
- * @return bool True on succes, false on failure
+ * @return bool True on succes, false on failure
*/
public function setEndDate($end_date) {
$stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."offer` SET `end_date`=? WHERE `id`=?");
@@ -203,7 +203,7 @@ class offer {
/**
* Get the invoice date of the assignment
*
- * @return int The invoice date as a UNIX timestamp
+ * @return int The invoice date as a UNIX timestamp
*/
public function getInvoiceDate() {
return $this->invoice_date;
@@ -212,11 +212,11 @@ class offer {
/**
* Set the invoice date of the assignment
*
- * @param int $invoice_date The new invoice date for the assignment as a UNIX timestamp
+ * @param int $invoice_date The new invoice date for the assignment as a UNIX timestamp
*
- * @throws PDOException If something went wrong with the database
+ * @throws PDOException If something went wrong with the database
*
- * @return bool True on succes, false on failure
+ * @return bool True on succes, false on failure
*/
public function setInvoiceDate($invoice_date) {
$stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."offer` SET `invoice_date`=? WHERE `id`=?");
@@ -232,7 +232,7 @@ class offer {
/**
* Get the date the payment was received
*
- * @return int|null The date as a UNIX timestamp, or null if it wasn't received yet
+ * @return int|null The date as a UNIX timestamp, or null if it wasn't received yet
*/
public function getPaymentReceived() {
return $this->payment_received;
@@ -241,11 +241,11 @@ class offer {
/**
* Set the payment received date of the assignment
*
- * @param int $payment_received The new date the payment has been received as a UNIX timestamp
+ * @param int $payment_received The new date the payment has been received as a UNIX timestamp
*
- * @throws PDOException If something went wrong with the database
+ * @throws PDOException If something went wrong with the database
*
- * @return bool True on succes, false on failure
+ * @return bool True on succes, false on failure
*/
public function setPaymentReceived($payment_received) {
$stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."offer` SET `payment_received`=? WHERE `id`=?");
@@ -261,7 +261,7 @@ class offer {
/**
* Check if the offer is accepted or not
*
- * @return bool True if the offer is accepted, false if not
+ * @return bool True if the offer is accepted, false if not
*/
public function isAccepted() {
return $this->accepted;
@@ -270,9 +270,9 @@ class offer {
/**
* Toggle the `accepted' status of the offer
*
- * @throws PDOException If something went wrong with the database
+ * @throws PDOException If something went wrong with the database
*
- * @return bool True on success, false on failure
+ * @return bool True on success, false on failure
*/
public function toggleAccepted() {
$stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."offer` SET `accepted`=? WHERE `id`=?");
@@ -289,9 +289,9 @@ class offer {
/**
* Get the ID of the file that the invoice of this offer is linked to
*
- * @see offer::getInvoiceFile() This function returns the file as an instance of the file class
+ * @see offer::getInvoiceFile() This function returns the file as an instance of the file class
*
- * @return int The ID
+ * @return int The ID
*/
public function getInvoiceFileId() {
return $this->invoice_fileId;
@@ -300,9 +300,9 @@ class offer {
/**
* Get the file that the invoice this offer is linked to
*
- * @see offer::getInvoiceId() This function returns just the id
+ * @see offer::getInvoiceId() This function returns just the id
*
- * @return file|null The file, or null if it doesn't exist
+ * @return file|null The file, or null if it doesn't exist
*/
public function getInvoiceFile() {
if ($this->invoice_fileId != null) {
@@ -315,11 +315,11 @@ class offer {
/**
* Set the invoice file id of the assignment
*
- * @param int $invoice_fileId The new invoice file id for the assignment
+ * @param int $invoice_fileId The new invoice file id for the assignment
*
- * @throws PDOException If something went wrong with the database
+ * @throws PDOException If something went wrong with the database
*
- * @return bool True on succes, false on failure
+ * @return bool True on succes, false on failure
*/
public function setInvoiceFileId($invoice_fileId) {
$stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."offer` SET `invoice_fileId`=? WHERE `id`=?");
@@ -345,13 +345,13 @@ class offer {
*
* Total: the sum of subtotal and total
*
- * @param int $what Any of offer::SUBTOTAL, offer::VAT and offer::TOTAL
- * @param int $round How many decimals to round the result on
- * @param bool $format Whether to format the number nicely (for output) or not (for calculations)
+ * @param int $what Any of offer::SUBTOTAL, offer::VAT and offer::TOTAL
+ * @param int $round How many decimals to round the result on
+ * @param bool $format Whether to format the number nicely (for output) or not (for calculations)
*
- * @throws PDOException If something went wrong with the database
+ * @throws PDOException If something went wrong with the database
*
- * @return float|bool The calculated value rounded to $round decimals, or false on incorrect input
+ * @return float|bool The calculated value rounded to $round decimals, or false on incorrect input
*/
public function calculate($what = self::TOTAL, $round = 2, $format = true) {
$return = 0;
@@ -388,7 +388,7 @@ class offer {
*
* @throws PDOException If something went wrong with the database
*
- * @return bool True on success, false on failure
+ * @return bool True on success, false on failure
*/
public function delete() {
$stmt = $this->pdo->prepare("DELETE FROM `".constants::db_prefix."offer` WHERE `id`=?");
@@ -404,15 +404,15 @@ class offer {
* Make a new assignment linked to this order
*
* @param string $title The title for this assignment
- * @param string $description The description for this assignment
- * @param int $hours The amount of hours to work on this assignment
- * @param float $price_per_hour The price per hour on this assignment
- * @param float $vat The VAT percentage (so, 21 for 21%, not 0.21!)
+ * @param string $description The description for this assignment
+ * @param int $hours The amount of hours to work on this assignment
+ * @param float $price_per_hour The price per hour on this assignment
+ * @param float $vat The VAT percentage (so, 21 for 21%, not 0.21!)
*
* @throws PDOException If something went wrong with the database
- * @throws Exception If there was a problem with the input
+ * @throws Exception If there was a problem with the input
*
- * @return assignment A new instance of the assignment class containing the new assignment
+ * @return assignment A new instance of the assignment class containing the new assignment
*/
public function createAssignment($title, $description, $hours, $price_per_hour, $vat) {
$stmt = $this->pdo->prepare("INSERT INTO `".constants::db_prefix."assignment` (`offerId`,`title`,`description`,`hours`,`price_per_hour`,`VAT_percentage`) VALUES (?,?,?,?,?,?)");
@@ -435,13 +435,10 @@ class offer {
/**
* Generate a PDF invoice
*
- * @throws PDOException If something went wrong with the database
- * @throws Exception If the file could not be written or an other error occured
- *
- * @return file An instance of the file class with information on the invoice file generated
+ * @throws PDOException If something went wrong with the database
+ * @throws Exception If the file could not be written or an other error occured
*
- * @todo This function was directly copied from the old admin.vivisoft.nl class invoice. It should be checked and improved.
- * @todo This function should use self::calculate()
+ * @return file An instance of the file class with information on the invoice file generated
*/
public function generateInvoice() {
// Check if we already have a file