Constants

SUBTOTAL

SUBTOTAL

VAT

VAT

TOTAL

TOTAL

Properties

$pdo

$pdo : \pdo

Type

\pdo — The PDO class for database communication

$id

$id : \pdo

Type

\pdo — The PDO class for database communication

$contactId

$contactId : \pdo

Type

\pdo — The PDO class for database communication

$start_date

$start_date : \pdo

Type

\pdo — The PDO class for database communication

$end_date

$end_date : \pdo

Type

\pdo — The PDO class for database communication

$invoice_date

$invoice_date : \pdo

Type

\pdo — The PDO class for database communication

$accepted

$accepted : \pdo

Type

\pdo — The PDO class for database communication

$invoice_fileId

$invoice_fileId : \pdo

Type

\pdo — The PDO class for database communication

$payment_received

$payment_received : \pdo

Type

\pdo — The PDO class for database communication

Methods

__construct()

__construct(\PDO  $pdo, integer  $id) 

Create a new instance

Blah

Parameters

\PDO $pdo

The PDO class, to access the database

integer $id

The id of the offer to fetch

Throws

\PDOException

If something went wrong with the database

\Exception

If the offer could not be found

getId()

getId() : integer

Get the ID of the offer

Returns

integer —

The ID

getContactId()

getContactId() : integer

Get the ID of the contact that this offer is linked to

Returns

integer —

The ID

getContact()

getContact() : \contact

Get the contact that this offer is linked to

Returns

\contact

The contact

getAssignmentIds()

getAssignmentIds() : array<mixed,integer>

Get all assignment ids for this offer

Throws

\PDOException

Is something went wrong with the database

Returns

array<mixed,integer> —

The ids

getAssignments()

getAssignments() : array<mixed,\assignment>

Get all assignments for this offer

Throws

\PDOException

If something went wrong with the database

Returns

array<mixed,\assignment> —

An array indexed by id of instances of the assignment class

getStartDate()

getStartDate() : integer

Get the start date of the assignment

Returns

integer —

The start date as a UNIX timestamp

setStartDate()

setStartDate(integer  $start_date) : boolean

Set the start date of the assignment

Parameters

integer $start_date

The new start date for the assignment as a UNIX timestamp

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

getEndDate()

getEndDate() : integer

Get the end date of the assignment

Returns

integer —

The end date as a UNIX timestamp

setEndDate()

setEndDate(integer  $end_date) : boolean

Set the end date of the assignment

Parameters

integer $end_date

The new end date for the assignment as a UNIX timestamp

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

getInvoiceDate()

getInvoiceDate() : integer

Get the invoice date of the assignment

Returns

integer —

The invoice date as a UNIX timestamp

setInvoiceDate()

setInvoiceDate(integer  $invoice_date) : boolean

Set the invoice date of the assignment

Parameters

integer $invoice_date

The new invoice date for the assignment as a UNIX timestamp

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

getPaymentReceived()

getPaymentReceived() : integer|null

Get the date the payment was received

Returns

integer|null —

The date as a UNIX timestamp, or null if it wasn't received yet

setPaymentReceived()

setPaymentReceived(integer  $payment_received) : boolean

Set the payment received date of the assignment

Parameters

integer $payment_received

The new date the payment has been received as a UNIX timestamp

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

isAccepted()

isAccepted() : boolean

Check if the offer is accepted or not

Returns

boolean —

True if the offer is accepted, false if not

toggleAccepted()

toggleAccepted() : boolean

Toggle the `accepted' status of the offer

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on success, false on failure

getInvoiceFileId()

getInvoiceFileId() : integer

Get the ID of the file that the invoice of this offer is linked to

Returns

integer —

The ID

getInvoiceFile()

getInvoiceFile() : \file|null

Get the file that the invoice this offer is linked to

Returns

\file|null —

The file, or null if it doesn't exist

setInvoiceFileId()

setInvoiceFileId(integer  $invoice_fileId) : boolean

Set the invoice file id of the assignment

Parameters

integer $invoice_fileId

The new invoice file id for the assignment

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on succes, false on failure

calculate()

calculate(integer  $what = self::TOTAL, integer  $round = 2, boolean  $format = true) : float|boolean

Calculate a handy number about the invoice

Subtotal: the sum of the prices of the assignments excl. VAT

VAT: the sum of all the VAT from all the assignments

Total: the sum of subtotal and total

Parameters

integer $what

Any of offer::SUBTOTAL, offer::VAT and offer::TOTAL

integer $round

How many decimals to round the result on

boolean $format

Whether to format the number nicely (for output) or not (for calculations)

Throws

\PDOException

If something went wrong with the database

Returns

float|boolean —

The calculated value rounded to $round decimals, or false on incorrect input

delete()

delete() : boolean

Remove this offer from the database

If this doesn't succeed (i.e. false is returned), that means the offer was removed manually or by another instance of this class

Throws

\PDOException

If something went wrong with the database

Returns

boolean —

True on success, false on failure

createAssignment()

createAssignment(string  $title, string  $description, integer  $hours, float  $price_per_hour, float  $vat) : \assignment

Make a new assignment linked to this order

Parameters

string $title

The title for this assignment

string $description

The description for this assignment

integer $hours

The amount of hours to work on this assignment

float $price_per_hour

The price per hour on this assignment

float $vat

The VAT percentage (so, 21 for 21%, not 0.21!)

Throws

\PDOException

If something went wrong with the database

\Exception

If there was a problem with the input

Returns

\assignment

A new instance of the assignment class containing the new assignment

generateInvoice()

generateInvoice() : \file

Generate a PDF invoice

Throws

\PDOException

If something went wrong with the database

\Exception

If the file could not be written or an other error occured

Returns

\file

An instance of the file class with information on the invoice file generated