diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/Assignment.php (renamed from classes/assignment.php) | 18 | ||||
-rw-r--r-- | classes/BusinessAdmin.php | 42 | ||||
-rw-r--r-- | classes/Client.php (renamed from classes/client.php) | 10 | ||||
-rw-r--r-- | classes/Constants.php (renamed from classes/constants.php) | 2 | ||||
-rw-r--r-- | classes/Contact.php (renamed from classes/contact.php) | 28 | ||||
-rw-r--r-- | classes/Correspondence.php (renamed from classes/correspondence.php) | 28 | ||||
-rw-r--r-- | classes/Discount.php (renamed from classes/discount.php) | 16 | ||||
-rw-r--r-- | classes/FPDF.license.txt (renamed from classes/fpdf.license.txt) | 0 | ||||
-rw-r--r-- | classes/File.php (renamed from classes/file.php) | 14 | ||||
-rw-r--r-- | classes/Model.php | 2 | ||||
-rw-r--r-- | classes/Offer.php (renamed from classes/offer.php) | 52 | ||||
-rw-r--r-- | classes/Payment.php (renamed from classes/payment.php) | 10 | ||||
-rw-r--r-- | classes/Response.php (renamed from classes/response.php) | 2 | ||||
-rw-r--r-- | classes/User.php (renamed from classes/user.php) | 20 |
14 files changed, 122 insertions, 122 deletions
diff --git a/classes/assignment.php b/classes/Assignment.php index 25b6432..b4a67dc 100644 --- a/classes/assignment.php +++ b/classes/Assignment.php @@ -24,7 +24,7 @@ /** * An interface to the assignment table in the database */ -class assignment { +class Assignment { use Calculatable; /** @@ -55,7 +55,7 @@ class assignment { public function __construct($pdo, $id) { $this->pdo = $pdo; - $stmt = $this->pdo->prepare("SELECT * FROM `".constants::db_prefix."assignment` WHERE `id`=?"); + $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."); @@ -99,7 +99,7 @@ class assignment { * @return offer The offer */ public function getOffer() { - return new offer($this->pdo, $this->offerId); + return new Offer($this->pdo, $this->offerId); } /** @@ -121,7 +121,7 @@ class assignment { * @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 = $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; @@ -157,7 +157,7 @@ class assignment { * @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 = $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; @@ -186,7 +186,7 @@ class assignment { * @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 = $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; @@ -215,7 +215,7 @@ class assignment { * @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 = $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; @@ -244,7 +244,7 @@ class assignment { * @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 = $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; @@ -276,7 +276,7 @@ class assignment { * @return bool True on success, false on failure */ public function delete() { - $stmt = $this->pdo->prepare("DELETE FROM `".constants::db_prefix."assignment` WHERE `id`=?"); + $stmt = $this->pdo->prepare("DELETE FROM `".Constants::db_prefix."assignment` WHERE `id`=?"); $stmt->execute(array($this->id)); if ($stmt->rowCount() != 1) { return false; diff --git a/classes/BusinessAdmin.php b/classes/BusinessAdmin.php index 347c9c6..3e654a2 100644 --- a/classes/BusinessAdmin.php +++ b/classes/BusinessAdmin.php @@ -44,7 +44,7 @@ class BusinessAdmin { */ public static function getUserIds($pdo, $where = [], $variables = []) { $ids = []; - $users = $pdo->prepare("SELECT `id` FROM `".constants::db_prefix."user`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : "")); + $users = $pdo->prepare("SELECT `id` FROM `".Constants::db_prefix."user`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : "")); $users->execute($variables); $users = $users->fetchAll(PDO::FETCH_ASSOC); foreach ($users as $user) { @@ -70,7 +70,7 @@ class BusinessAdmin { $ids = self::getUserIds($pdo, $where, $variables); $users = []; foreach ($ids as $id) { - $users[$id] = new user($pdo, $id); + $users[$id] = new User($pdo, $id); } return $users; } @@ -88,7 +88,7 @@ class BusinessAdmin { */ public static function getClientIds($pdo) { $ids = array(); - $clients = $pdo->query("SELECT `id` FROM `".constants::db_prefix."client`")->fetchAll(PDO::FETCH_ASSOC); + $clients = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."client`")->fetchAll(PDO::FETCH_ASSOC); foreach ($clients as $client) { $ids[] = $client['id']; } @@ -110,7 +110,7 @@ class BusinessAdmin { $ids = self::getClientIds($pdo); $clients = array(); foreach ($ids as $id) { - $clients[$id] = new client($pdo, $id); + $clients[$id] = new Client($pdo, $id); } return $clients; } @@ -128,7 +128,7 @@ class BusinessAdmin { */ public static function getContactIds($pdo) { $ids = array(); - $contacts = $pdo->query("SELECT `id` FROM `".constants::db_prefix."contact`")->fetchAll(PDO::FETCH_ASSOC); + $contacts = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."contact`")->fetchAll(PDO::FETCH_ASSOC); foreach ($contacts as $contact) { $ids[] = $contact['id']; } @@ -150,7 +150,7 @@ class BusinessAdmin { $ids = self::getContactIds($pdo); $contacts = array(); foreach ($ids as $id) { - $contacts[$id] = new contact($pdo, $id); + $contacts[$id] = new Contact($pdo, $id); } return $contacts; } @@ -169,7 +169,7 @@ class BusinessAdmin { */ public static function getOfferIds($pdo, $where = array()) { $ids = array(); - $offers = $pdo->query("SELECT `id` FROM `".constants::db_prefix."offer`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); + $offers = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."offer`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); foreach ($offers as $offer) { $ids[] = $offer['id']; } @@ -192,7 +192,7 @@ class BusinessAdmin { $ids = self::getOfferIds($pdo, $where); $offers = array(); foreach ($ids as $id) { - $offers[$id] = new offer($pdo, $id); + $offers[$id] = new Offer($pdo, $id); } return $offers; } @@ -211,7 +211,7 @@ class BusinessAdmin { */ public static function getAssignmentIds($pdo, $where = array()) { $ids = array(); - $assignments = $pdo->query("SELECT `id` FROM `".constants::db_prefix."assignment`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); + $assignments = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."assignment`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); foreach ($assignments as $assignment) { $ids[] = $assignment['id']; } @@ -234,7 +234,7 @@ class BusinessAdmin { $ids = self::getAssignmentIds($pdo, $where); $assignments = array(); foreach ($ids as $id) { - $assignments[$id] = new assignment($pdo, $id); + $assignments[$id] = new Assignment($pdo, $id); } return $assignments; } @@ -253,7 +253,7 @@ class BusinessAdmin { */ public static function getDiscountIds($pdo, $where = array()) { $ids = array(); - $discounts = $pdo->query("SELECT `id` FROM `".constants::db_prefix."discount`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); + $discounts = $pdo->query("SELECT `id` FROM `".Constants::db_prefix."discount`" . ((count($where) > 0) ? (" WHERE (" . implode(') AND (', $where) . ")") : ""))->fetchAll(PDO::FETCH_ASSOC); foreach ($discounts as $discount) { $ids[] = $discount['id']; } @@ -276,7 +276,7 @@ class BusinessAdmin { $ids = self::getDiscountIds($pdo, $where); $discounts = array(); foreach ($ids as $id) { - $discounts[$id] = new discount($pdo, $id); + $discounts[$id] = new Discount($pdo, $id); } return $discounts; } @@ -296,10 +296,10 @@ class BusinessAdmin { * @return client|bool A new instance of the client object, or false on failure */ public static function createClient($pdo, $name) { - $stmt = $pdo->prepare("INSERT INTO `".constants::db_prefix."client` (`name`) VALUES (?)"); + $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."client` (`name`) VALUES (?)"); $stmt->execute(array($name)); if ($stmt->rowCount() == 1) { - return new client($pdo, $pdo->lastInsertId()); + return new Client($pdo, $pdo->lastInsertId()); } else { return false; } @@ -318,21 +318,21 @@ class BusinessAdmin { */ public static function createFile($pdo, $filename) { // Check for file existence - if (file_exists(constants::files_folder . $filename)) { + if (file_exists(Constants::files_folder . $filename)) { throw new Exception("$filename already exists."); } // Try to create the file - if (file_put_contents(constants::files_folder . $filename, '') === false) { + if (file_put_contents(Constants::files_folder . $filename, '') === false) { throw new Exception("$filename could not be created. Check the permissions."); } - $stmt = $pdo->prepare("INSERT INTO `".constants::db_prefix."file` (`filename`) VALUES (?)"); + $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."file` (`filename`) VALUES (?)"); $stmt->execute(array($filename)); if ($stmt->rowCount() == 1) { - return new file($pdo, $pdo->lastInsertId()); + return new File($pdo, $pdo->lastInsertId()); } else { - unlink(constants::files_folder . $filename); + unlink(Constants::files_folder . $filename); throw new Exception("$filename could not be added to the database"); } } @@ -349,10 +349,10 @@ class BusinessAdmin { * @return user|bool A new instance of the user object, or false on failure */ public static function createUser($pdo, $username, $password) { - $stmt = $pdo->prepare("INSERT INTO `".constants::db_prefix."user` (`username`, `password`) VALUES (?,?)"); + $stmt = $pdo->prepare("INSERT INTO `".Constants::db_prefix."user` (`username`, `password`) VALUES (?,?)"); $stmt->execute([$username, user::hash($password)]); if ($stmt->rowCount() == 1) { - return new user($pdo, $pdo->lastInsertId()); + return new User($pdo, $pdo->lastInsertId()); } else { return false; } diff --git a/classes/client.php b/classes/Client.php index 46e2da2..13e28d7 100644 --- a/classes/client.php +++ b/classes/Client.php @@ -24,7 +24,7 @@ /** * An interface to the client table in the database */ -class client extends Model { +class Client extends Model { public $table = 'client', $fillable_columns = ['name']; @@ -40,7 +40,7 @@ class client extends Model { */ public function getContactIds() { $ids = array(); - $contacts = $this->pdo->query("SELECT `id` FROM `".constants::db_prefix."contact` WHERE `clientId`={$this->id}")->fetchAll(PDO::FETCH_ASSOC); + $contacts = $this->pdo->query("SELECT `id` FROM `".Constants::db_prefix."contact` WHERE `clientId`={$this->id}")->fetchAll(PDO::FETCH_ASSOC); foreach ($contacts as $contact) { $ids[] = $contact['id']; } @@ -60,7 +60,7 @@ class client extends Model { $ids = $this->getContactIds(); $contacts = array(); foreach ($ids as $id) { - $contacts[$id] = new contact($this->pdo, $id); + $contacts[$id] = new Contact($this->pdo, $id); } return $contacts; } @@ -87,7 +87,7 @@ class client extends Model { * @return contact A new instance of the contact class containing the new contact */ public function createContact($name, $email, $address, $address_2, $postal_code, $city, $country) { - $stmt = $this->pdo->prepare("INSERT INTO `".constants::db_prefix."contact` (`clientId`,`name`,`email`,`address`,`address_2`,`postal_code`,`city`,`country`) VALUES (?,?,?,?,?,?,?,?)"); + $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."contact` (`clientId`,`name`,`email`,`address`,`address_2`,`postal_code`,`city`,`country`) VALUES (?,?,?,?,?,?,?,?)"); $stmt->execute(array( $this->id, $name, @@ -99,7 +99,7 @@ class client extends Model { $country )); if ($stmt->rowCount() == 1) { - return new contact($this->pdo, $this->pdo->lastInsertId()); + return new Contact($this->pdo, $this->pdo->lastInsertId()); } else { $error = $stmt->errorInfo(); throw new Exception($error[2]); diff --git a/classes/constants.php b/classes/Constants.php index 663d603..3ffadd7 100644 --- a/classes/constants.php +++ b/classes/Constants.php @@ -24,7 +24,7 @@ /** * A class for some constants */ -class constants { +class Constants { /** @const db_prefix A prefix to add to the tables in the database (leave empty for none) */ const db_prefix = ''; diff --git a/classes/contact.php b/classes/Contact.php index 7741c17..6ed2a78 100644 --- a/classes/contact.php +++ b/classes/Contact.php @@ -24,7 +24,7 @@ /** * An interface to the contact table in the database */ -class contact { +class Contact { /** * @var PDO $pdo The PDO class for database communication * @var int $id The id of the contact @@ -52,7 +52,7 @@ class contact { public function __construct($pdo, $id) { $this->pdo = $pdo; - $stmt = $this->pdo->prepare("SELECT * FROM `".constants::db_prefix."contact` WHERE `id`=?"); + $stmt = $this->pdo->prepare("SELECT * FROM `".Constants::db_prefix."contact` WHERE `id`=?"); $stmt->execute(array($id)); if ($stmt->rowCount() == 0) { throw new Exception("The contact with id '$id' could not be found."); @@ -99,7 +99,7 @@ class contact { * @return client The client */ public function getClient() { - return new client($this->pdo, $this->clientId); + return new Client($this->pdo, $this->clientId); } /** @@ -121,7 +121,7 @@ class contact { * @return bool True on succes, false on failure */ public function setName($name) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."contact` SET `name`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."contact` SET `name`=? WHERE `id`=?"); $stmt->execute(array($name, $this->id)); if ($stmt->rowCount() == 1) { $this->name = $name; @@ -150,7 +150,7 @@ class contact { * @return bool True on succes, false on failure */ public function setEmail($email) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."contact` SET `email`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."contact` SET `email`=? WHERE `id`=?"); $stmt->execute(array($email, $this->id)); if ($stmt->rowCount() == 1) { $this->email = $email; @@ -179,7 +179,7 @@ class contact { * @return bool True on succes, false on failure */ public function setAddress($address) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."contact` SET `address`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."contact` SET `address`=? WHERE `id`=?"); $stmt->execute(array($address, $this->id)); if ($stmt->rowCount() == 1) { $this->address = $address; @@ -208,7 +208,7 @@ class contact { * @return bool True on succes, false on failure */ public function setAddress_2($address_2) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."contact` SET `address_2`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."contact` SET `address_2`=? WHERE `id`=?"); $stmt->execute(array($address_2, $this->id)); if ($stmt->rowCount() == 1) { $this->address_2 = $address_2; @@ -237,7 +237,7 @@ class contact { * @return bool True on succes, false on failure */ public function setPostalCode($postal_code) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."contact` SET `postal_code`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."contact` SET `postal_code`=? WHERE `id`=?"); $stmt->execute(array($postal_code, $this->id)); if ($stmt->rowCount() == 1) { return true; @@ -266,7 +266,7 @@ class contact { * @return bool True on succes, false on failure */ public function setCity($city) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."contact` SET `city`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."contact` SET `city`=? WHERE `id`=?"); $stmt->execute(array($city, $this->id)); if ($stmt->rowCount() == 1) { $this->city = $city; @@ -295,7 +295,7 @@ class contact { * @return bool True on succes, false on failure */ public function setCountry($country) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."contact` SET `country`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."contact` SET `country`=? WHERE `id`=?"); $stmt->execute(array($country, $this->id)); if ($stmt->rowCount() == 1) { $this->country = $country; @@ -330,7 +330,7 @@ class contact { if (!in_array($language, correspondence::LANGUAGES)) { throw new Exception("Language $language not available."); } - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."contact` SET `language`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."contact` SET `language`=? WHERE `id`=?"); $stmt->execute(array($language, $this->id)); if ($stmt->rowCount() == 1) { $this->language = $language; @@ -354,7 +354,7 @@ class contact { * @return bool True on success, false on failure */ public function delete() { - $stmt = $this->pdo->prepare("DELETE FROM `".constants::db_prefix."contact` WHERE `id`=?"); + $stmt = $this->pdo->prepare("DELETE FROM `".Constants::db_prefix."contact` WHERE `id`=?"); $stmt->execute(array($this->id)); if ($stmt->rowCount() != 1) { return false; @@ -372,10 +372,10 @@ class contact { * @return offer A new instance of the offer class containing the new offer */ public function createOffer() { - $stmt = $this->pdo->prepare("INSERT INTO `".constants::db_prefix."offer` (`contactId`) VALUES (?)"); + $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."offer` (`contactId`) VALUES (?)"); $stmt->execute(array($this->id)); if ($stmt->rowCount() == 1) { - return new offer($this->pdo, $this->pdo->lastInsertId()); + return new Offer($this->pdo, $this->pdo->lastInsertId()); } else { $error = $stmt->errorInfo(); throw new Exception($error[2]); diff --git a/classes/correspondence.php b/classes/Correspondence.php index eb18b7d..4c7a23b 100644 --- a/classes/correspondence.php +++ b/classes/Correspondence.php @@ -24,7 +24,7 @@ /** * An extension of FPDF to generate personalized correspondence PDFs */ -class correspondence extends FPDF { +class Correspondence extends FPDF { /** * @var $contact Holds the contact this correspondence will be sent to * @var $language Holds the language this correspondence should be sent in @@ -140,7 +140,7 @@ class correspondence extends FPDF { $this->FPDF('P','mm','A4'); $this->SetMargins(30,20,20); - $this->SetAuthor(constants::invoice_name); + $this->SetAuthor(Constants::invoice_name); $this->SetCreator('BusinessAdmin Correspondence Generator'); $this->SetDisplayMode('fullpage','continuous'); } @@ -153,11 +153,11 @@ class correspondence extends FPDF { * @return a valuta symbol that can be used in FPDF */ public static function valuta() { - switch (constants::invoice_valuta) { + switch (Constants::invoice_valuta) { case '€': return chr(128); default: - return constants::invoice_valuta; + return Constants::invoice_valuta; } } @@ -190,8 +190,8 @@ class correspondence extends FPDF { * Makes a header with your details and the address of the contact */ function CorrespondenceHeader() { - if (file_exists(constants::files_folder . 'logo-correspondence.png')) { - $this->Image(constants::files_folder . 'logo-correspondence.png',30,20,50); + if (file_exists(Constants::files_folder . 'logo-correspondence.png')) { + $this->Image(Constants::files_folder . 'logo-correspondence.png',30,20,50); } $this->SetFont('Helvetica','',7); @@ -206,17 +206,17 @@ class correspondence extends FPDF { $this->Cell(12,3.5,$this->_('adres'),'',0,'R'); $this->Cell(2,3.5); $this->SetFont('',''); - $this->Cell(35,3.5, constants::invoice_name); + $this->Cell(35,3.5, Constants::invoice_name); $this->Ln(); $this->Cell(124,3.5); - $this->Cell(35,3.5, constants::invoice_address_1); + $this->Cell(35,3.5, Constants::invoice_address_1); $this->Ln(); $this->Cell(124,3.5); - $this->Cell(35,3.5, constants::invoice_address_2); + $this->Cell(35,3.5, Constants::invoice_address_2); $this->Ln(); $this->Cell(124,3.5); - $this->Cell(35,3.5, constants::invoice_address_3); + $this->Cell(35,3.5, Constants::invoice_address_3); $this->Ln(); $this->Cell(160,1.5); $this->Ln(); @@ -225,7 +225,7 @@ class correspondence extends FPDF { $this->Cell(12,3.5,$this->_('btwnr'),'',0,'R'); $this->Cell(2,3.5); $this->SetFont('',''); - $this->Cell(35,3.5, constants::invoice_tax_nr); + $this->Cell(35,3.5, Constants::invoice_tax_nr); $this->Ln(); $this->Cell(160,1.5); $this->Ln(); @@ -234,7 +234,7 @@ class correspondence extends FPDF { $this->Cell(12,3.5, $this->_('iban'),'',0,'R'); $this->Cell(2,3.5); $this->SetFont('',''); - $this->Cell(35,3.5, constants::invoice_iban); + $this->Cell(35,3.5, Constants::invoice_iban); $this->Ln(); $this->Cell(160,1.5); $this->Ln(); @@ -243,14 +243,14 @@ class correspondence extends FPDF { $this->Cell(12,3.5, $this->_('tel-nr'),'',0,'R'); $this->Cell(2,3.5); $this->SetFont('','',7); - $this->Cell(35,3.5, constants::invoice_tel_nr); + $this->Cell(35,3.5, Constants::invoice_tel_nr); $this->Ln(); $this->Cell(110,3.5); $this->SetFont('','B'); $this->Cell(12,3.5, $this->_('email'),'',0,'R'); $this->Cell(2,3.5); $this->SetFont('',''); - $this->Cell(35,3.5, constants::invoice_email); + $this->Cell(35,3.5, Constants::invoice_email); $this->Ln(); $this->Cell(110,1); $this->Cell(12,1,' ','B'); diff --git a/classes/discount.php b/classes/Discount.php index 31be887..91dd53b 100644 --- a/classes/discount.php +++ b/classes/Discount.php @@ -24,7 +24,7 @@ /** * An interface to the discount table in the database */ -class discount { +class Discount { use Calculatable; /** @@ -54,7 +54,7 @@ class discount { public function __construct($pdo, $id) { $this->pdo = $pdo; - $stmt = $this->pdo->prepare("SELECT * FROM `".constants::db_prefix."discount` WHERE `id`=?"); + $stmt = $this->pdo->prepare("SELECT * FROM `".Constants::db_prefix."discount` WHERE `id`=?"); $stmt->execute(array($id)); if ($stmt->rowCount() == 0) { throw new Exception("The discount with id '$id' could not be found."); @@ -97,7 +97,7 @@ class discount { * @return offer The offer */ public function getOffer() { - return new offer($this->pdo, $this->offerId); + return new Offer($this->pdo, $this->offerId); } /** @@ -119,7 +119,7 @@ class discount { * @return bool True on succes, false on failure */ public function setTitle($title) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."discount` SET `title`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."discount` SET `title`=? WHERE `id`=?"); $stmt->execute(array($title, $this->id)); if ($stmt->rowCount() == 1) { $this->title = $title; @@ -155,7 +155,7 @@ class discount { * @return bool True on succes, false on failure */ public function setDescription($description) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."discount` SET `description`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."discount` SET `description`=? WHERE `id`=?"); $stmt->execute(array($description, $this->id)); if ($stmt->rowCount() == 1) { $this->description = $description; @@ -184,7 +184,7 @@ class discount { * @return bool True on succes, false on failure */ public function setValue($value) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."discount` SET `value`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."discount` SET `value`=? WHERE `id`=?"); $stmt->execute(array($value, $this->id)); if ($stmt->rowCount() == 1) { $this->value = $value; @@ -213,7 +213,7 @@ class discount { * @return bool True on succes, false on failure */ public function setVAT($vat) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."discount` SET `VAT_percentage`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."discount` SET `VAT_percentage`=? WHERE `id`=?"); $stmt->execute(array($vat, $this->id)); if ($stmt->rowCount() == 1) { $this->vat = $vat; @@ -245,7 +245,7 @@ class discount { * @return bool True on success, false on failure */ public function delete() { - $stmt = $this->pdo->prepare("DELETE FROM `".constants::db_prefix."discount` WHERE `id`=?"); + $stmt = $this->pdo->prepare("DELETE FROM `".Constants::db_prefix."discount` WHERE `id`=?"); $stmt->execute(array($this->id)); if ($stmt->rowCount() != 1) { return false; diff --git a/classes/fpdf.license.txt b/classes/FPDF.license.txt index fd811c6..fd811c6 100644 --- a/classes/fpdf.license.txt +++ b/classes/FPDF.license.txt diff --git a/classes/file.php b/classes/File.php index b07064e..656ac5e 100644 --- a/classes/file.php +++ b/classes/File.php @@ -24,7 +24,7 @@ /** * An interface to the file table in the database */ -class file { +class File { /** * @var PDO $pdo The PDO class for database communication * @var int $id The id of the file @@ -44,7 +44,7 @@ class file { public function __construct($pdo, $id) { $this->pdo = $pdo; - $stmt = $this->pdo->prepare("SELECT * FROM `".constants::db_prefix."file` WHERE `id`=?"); + $stmt = $this->pdo->prepare("SELECT * FROM `".Constants::db_prefix."file` WHERE `id`=?"); $stmt->execute(array($id)); if ($stmt->rowCount() == 0) { throw new Exception("The file with id '$id' could not be found."); @@ -89,7 +89,7 @@ class file { * @return string The path */ public function getFilenamePath() { - return constants::files_folder . $this->filename; + return Constants::files_folder . $this->filename; } /** @@ -101,7 +101,7 @@ class file { * @return string The URI */ public function getFilenameURI() { - return constants::files_folder_external . $this->filename; + return Constants::files_folder_external . $this->filename; } //------------------------------------------------------------------------------ @@ -123,7 +123,7 @@ class file { public function delete() { // Try to move the file to trash $newname = pathinfo($this->filename, PATHINFO_FILENAME) . '--' . date('Y-m-d.H.i.s.') . pathinfo($this->filename, PATHINFO_EXTENSION); - $newdir = pathinfo($this->getFilenamePath(), PATHINFO_DIRNAME) . '/' . constants::files_folder_trash . '/'; + $newdir = pathinfo($this->getFilenamePath(), PATHINFO_DIRNAME) . '/' . Constants::files_folder_trash . '/'; if (!file_exists($newdir)) { if (!mkdir($newdir)) { return false; @@ -134,10 +134,10 @@ class file { } // Remove offers linked by invoice_fileId - $this->pdo->query("UPDATE `".constants::db_prefix."offer` SET `invoice_fileId`=NULL WHERE `invoice_fileId`={$this->id}"); + $this->pdo->query("UPDATE `".Constants::db_prefix."offer` SET `invoice_fileId`=NULL WHERE `invoice_fileId`={$this->id}"); // Remove the record of the file - $stmt = $this->pdo->prepare("DELETE FROM `".constants::db_prefix."file` WHERE `id`=?"); + $stmt = $this->pdo->prepare("DELETE FROM `".Constants::db_prefix."file` WHERE `id`=?"); $stmt->execute(array($this->id)); if ($stmt->rowCount() == 1) { return true; diff --git a/classes/Model.php b/classes/Model.php index 37c719a..68f045e 100644 --- a/classes/Model.php +++ b/classes/Model.php @@ -140,6 +140,6 @@ abstract class Model { * @return string The database table */ private function table() { - return constants::db_prefix . $this->table; + return Constants::db_prefix . $this->table; } } diff --git a/classes/offer.php b/classes/Offer.php index 56a8878..d08091b 100644 --- a/classes/offer.php +++ b/classes/Offer.php @@ -24,7 +24,7 @@ /** * An interface to the offer table in the database */ -class offer { +class Offer { /** * @var pdo $pdo The PDO class for database communication * @var int $id The id of the offer @@ -55,7 +55,7 @@ class offer { public function __construct($pdo, $id) { $this->pdo = $pdo; - $stmt = $this->pdo->prepare("SELECT * FROM `".constants::db_prefix."offer` WHERE `id`=?"); + $stmt = $this->pdo->prepare("SELECT * FROM `".Constants::db_prefix."offer` WHERE `id`=?"); $stmt->execute(array($id)); if ($stmt->rowCount() == 0) { throw new Exception("The offer with id '$id' could not be found."); @@ -103,7 +103,7 @@ class offer { * @return contact The contact */ public function getContact() { - return new contact($this->pdo, $this->contactId); + return new Contact($this->pdo, $this->contactId); } /** @@ -117,7 +117,7 @@ class offer { */ public function getAssignmentIds() { $ids = array(); - $assignments = $this->pdo->query("SELECT `id` FROM `".constants::db_prefix."assignment` WHERE `offerId`={$this->id}")->fetchAll(PDO::FETCH_ASSOC); + $assignments = $this->pdo->query("SELECT `id` FROM `".Constants::db_prefix."assignment` WHERE `offerId`={$this->id}")->fetchAll(PDO::FETCH_ASSOC); foreach ($assignments as $assignment) { $ids[] = $assignment['id']; } @@ -137,7 +137,7 @@ class offer { $ids = $this->getAssignmentIds(); $assignments = array(); foreach ($ids as $id) { - $assignments[$id] = new assignment($this->pdo, $id); + $assignments[$id] = new Assignment($this->pdo, $id); } return $assignments; } @@ -153,7 +153,7 @@ class offer { */ public function getDiscountIds() { $ids = array(); - $discounts = $this->pdo->query("SELECT `id` FROM `".constants::db_prefix."discount` WHERE `offerId`={$this->id}")->fetchAll(PDO::FETCH_ASSOC); + $discounts = $this->pdo->query("SELECT `id` FROM `".Constants::db_prefix."discount` WHERE `offerId`={$this->id}")->fetchAll(PDO::FETCH_ASSOC); foreach ($discounts as $discount) { $ids[] = $discount['id']; } @@ -173,7 +173,7 @@ class offer { $ids = $this->getDiscountIds(); $discounts = array(); foreach ($ids as $id) { - $discounts[$id] = new discount($this->pdo, $id); + $discounts[$id] = new Discount($this->pdo, $id); } return $discounts; } @@ -189,7 +189,7 @@ class offer { */ public function getPaymentId() { $ids = array(); - $payments = $this->pdo->query("SELECT `id` FROM `".constants::db_prefix."payment` WHERE `offerId`={$this->id}")->fetchAll(PDO::FETCH_ASSOC); + $payments = $this->pdo->query("SELECT `id` FROM `".Constants::db_prefix."payment` WHERE `offerId`={$this->id}")->fetchAll(PDO::FETCH_ASSOC); foreach ($payments as $payment) { return $payment['id']; } @@ -210,7 +210,7 @@ class offer { if (is_null($id)) { return null; } else { - return new payment($this->pdo, $id); + return new Payment($this->pdo, $id); } } @@ -233,7 +233,7 @@ class offer { * @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`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."offer` SET `start_date`=? WHERE `id`=?"); $stmt->execute(array(date('Y-m-d', $start_date), $this->id)); if ($stmt->rowCount() == 1) { $this->start_date = $start_date; @@ -262,7 +262,7 @@ class offer { * @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`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."offer` SET `end_date`=? WHERE `id`=?"); $stmt->execute(array(date('Y-m-d', $end_date), $this->id)); if ($stmt->rowCount() == 1) { $this->end_date = $end_date; @@ -291,7 +291,7 @@ class offer { * @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`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."offer` SET `invoice_date`=? WHERE `id`=?"); $stmt->execute(array(date('Y-m-d', $invoice_date), $this->id)); if ($stmt->rowCount() == 1) { $this->invoice_date = $invoice_date; @@ -332,7 +332,7 @@ class offer { * @return bool True on success, false on failure */ public function toggleAccepted() { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."offer` SET `accepted`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."offer` SET `accepted`=? WHERE `id`=?"); $new_value = !$this->accepted; $stmt->execute(array($new_value, $this->id)); if ($stmt->rowCount() == 1) { @@ -363,7 +363,7 @@ class offer { */ public function getInvoiceFile() { if ($this->invoice_fileId != null) { - return new file($this->pdo, $this->invoice_fileId); + return new File($this->pdo, $this->invoice_fileId); } else { return null; } @@ -379,7 +379,7 @@ class offer { * @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`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."offer` SET `invoice_fileId`=? WHERE `id`=?"); $stmt->execute(array($invoice_fileId, $this->id)); if ($stmt->rowCount() == 1) { $this->invoice_fileId = $invoice_fileId; @@ -453,7 +453,7 @@ class offer { * @return bool True on success, false on failure */ public function delete() { - $stmt = $this->pdo->prepare("DELETE FROM `".constants::db_prefix."offer` WHERE `id`=?"); + $stmt = $this->pdo->prepare("DELETE FROM `".Constants::db_prefix."offer` WHERE `id`=?"); $stmt->execute(array($this->id)); if ($stmt->rowCount() != 1) { return false; @@ -477,7 +477,7 @@ class offer { * @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 (?,?,?,?,?,?)"); + $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."assignment` (`offerId`,`title`,`description`,`hours`,`price_per_hour`,`VAT_percentage`) VALUES (?,?,?,?,?,?)"); $stmt->execute(array( $this->id, $title, @@ -487,7 +487,7 @@ class offer { $vat )); if ($stmt->rowCount() == 1) { - return new assignment($this->pdo, $this->pdo->lastInsertId()); + return new Assignment($this->pdo, $this->pdo->lastInsertId()); } else { $error = $stmt->errorInfo(); throw new Exception($error[2]); @@ -508,7 +508,7 @@ class offer { * @return discount A new instance of the discount class containing the new discount */ public function createDiscount($title, $description, $value, $vat) { - $stmt = $this->pdo->prepare("INSERT INTO `".constants::db_prefix."discount` (`offerId`,`title`,`description`,`value`,`VAT_percentage`) VALUES (?,?,?,?,?)"); + $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."discount` (`offerId`,`title`,`description`,`value`,`VAT_percentage`) VALUES (?,?,?,?,?)"); $stmt->execute(array( $this->id, $title, @@ -517,7 +517,7 @@ class offer { $vat )); if ($stmt->rowCount() == 1) { - return new discount($this->pdo, $this->pdo->lastInsertId()); + return new Discount($this->pdo, $this->pdo->lastInsertId()); } else { $error = $stmt->errorInfo(); throw new Exception($error[2]); @@ -536,10 +536,10 @@ class offer { */ public function createPayment($date=null) { $date = is_null($date) ? time() : $date; - $stmt = $this->pdo->prepare("INSERT INTO `".constants::db_prefix."payment` (`offerId`,`date`) VALUES (?,?)"); + $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."payment` (`offerId`,`date`) VALUES (?,?)"); $stmt->execute([$this->id, date('Y-m-d H:i:s', $date)]); if ($stmt->rowCount() == 1) { - return new payment($this->pdo, $this->pdo->lastInsertId()); + return new Payment($this->pdo, $this->pdo->lastInsertId()); } else { $error = $stmt->errorInfo(); throw new Exception($error[2]); @@ -563,7 +563,7 @@ class offer { do { $invoice_nr = date('Y',$this->invoice_date) . str_pad($i++, 2, '0', STR_PAD_LEFT); $filename = 'invoice-' . $invoice_nr . '.pdf'; - } while (file_exists(constants::files_folder . $filename)); + } while (file_exists(Constants::files_folder . $filename)); $file = BusinessAdmin::createFile($this->pdo, $filename); $this->setInvoiceFileId($file->getId()); @@ -587,7 +587,7 @@ class offer { $discount->calculate(discount::TOTAL) ); - $pdf = new correspondence(); + $pdf = new Correspondence(); $pdf->SetContact($this->getContact()); $pdf->SetTitle($pdf->_('invoice') . ' ' . $invoice_nr); $pdf->AddPage(); @@ -723,7 +723,7 @@ class offer { $oldY = $pdf->GetY(); $pdf->Cell(5,5); - $pdf->Cell(40,5, constants::invoice_iban); + $pdf->Cell(40,5, Constants::invoice_iban); $pdf->Cell(17.5,5); $pdf->Cell(40,5,$invoice_nr); $pdf->Cell(17.5,5); @@ -734,7 +734,7 @@ class offer { $pdf->SetFontSize(7); $pdf->Cell(160,5,$pdf->_('request'),0,0,'C'); $pdf->Ln(); - $pdf->Cell(160,5,str_replace('%%', constants::invoice_bic, $pdf->_('biccode')),0,0,'C'); + $pdf->Cell(160,5,str_replace('%%', Constants::invoice_bic, $pdf->_('biccode')),0,0,'C'); if (file_exists($file->getFilenamePath())) { unlink($file->getFilenamePath()); diff --git a/classes/payment.php b/classes/Payment.php index 9d4782c..11c57a3 100644 --- a/classes/payment.php +++ b/classes/Payment.php @@ -24,7 +24,7 @@ /** * An interface to the payment table in the database */ -class payment { +class Payment { /** * @var pdo $pdo The PDO class for database communication * @var int $id The id of the payment @@ -45,7 +45,7 @@ class payment { public function __construct($pdo, $id) { $this->pdo = $pdo; - $stmt = $this->pdo->prepare("SELECT * FROM `".constants::db_prefix."payment` WHERE `id`=?"); + $stmt = $this->pdo->prepare("SELECT * FROM `".Constants::db_prefix."payment` WHERE `id`=?"); $stmt->execute(array($id)); if ($stmt->rowCount() == 0) { throw new Exception("The payment with id '$id' could not be found."); @@ -85,7 +85,7 @@ class payment { * @return offer The offer */ public function getOffer() { - return new offer($this->pdo, $this->offerId); + return new Offer($this->pdo, $this->offerId); } /** @@ -107,7 +107,7 @@ class payment { * @return bool True on success, false on failure */ public function setDate($date) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."payment` SET `date`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."payment` SET `date`=? WHERE `id`=?"); $stmt->execute([date('Y-m-d H:i:s', $date), $this->id]); if ($stmt->rowCount() == 1) { $this->date = $date; @@ -131,7 +131,7 @@ class payment { * @return bool True on success, false on failure */ public function delete() { - $stmt = $this->pdo->prepare("DELETE FROM `".constants::db_prefix."payment` WHERE `id`=?"); + $stmt = $this->pdo->prepare("DELETE FROM `".Constants::db_prefix."payment` WHERE `id`=?"); $stmt->execute(array($this->id)); if ($stmt->rowCount() != 1) { return false; diff --git a/classes/response.php b/classes/Response.php index d997c00..f37b6e9 100644 --- a/classes/response.php +++ b/classes/Response.php @@ -24,7 +24,7 @@ /** * Provides a standard to base all responses to be called with AJAX on */ -class response { +class Response { /** The variable to keep the response in until output */ private $response; /** The variable to keep the HTTP response code in until output */ diff --git a/classes/user.php b/classes/User.php index f6c6322..0569433 100644 --- a/classes/user.php +++ b/classes/User.php @@ -24,7 +24,7 @@ /** * An interface to the user table in the database */ -class user { +class User { /** * @var pdo $pdo The PDO class for database communication * @var int $id The id of the user @@ -54,8 +54,8 @@ class user { public static function hash($password, $cost=null) { return password_hash( $password, - constants::password_algo, - ['cost' => is_null($cost) ? constants::password_cost : $cost] + Constants::password_algo, + ['cost' => is_null($cost) ? Constants::password_cost : $cost] ); } @@ -71,7 +71,7 @@ class user { public function __construct($pdo, $id) { $this->pdo = $pdo; - $stmt = $this->pdo->prepare("SELECT * FROM `".constants::db_prefix."user` WHERE `id`=?"); + $stmt = $this->pdo->prepare("SELECT * FROM `".Constants::db_prefix."user` WHERE `id`=?"); $stmt->execute(array($id)); if ($stmt->rowCount() == 0) { throw new Exception("The user with id '$id' could not be found."); @@ -115,7 +115,7 @@ class user { * @return bool True on succes, false on failure */ public function setName($username) { - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."user` SET `username`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."user` SET `username`=? WHERE `id`=?"); $stmt->execute(array($username, $this->id)); if ($stmt->rowCount() == 1) { $this->username = $username; @@ -136,7 +136,7 @@ class user { */ public function setPassword($password) { $password = self::hash($password); - $stmt = $this->pdo->prepare("UPDATE `".constants::db_prefix."user` SET `password`=? WHERE `id`=?"); + $stmt = $this->pdo->prepare("UPDATE `".Constants::db_prefix."user` SET `password`=? WHERE `id`=?"); $stmt->execute(array($password, $this->id)); if ($stmt->rowCount() == 1) { $this->password = $password; @@ -156,7 +156,7 @@ class user { * @return bool True iff the user has administrator rights */ public function isAdmin() { - return in_array($this->getId(), constants::user_admins); + return in_array($this->getId(), Constants::user_admins); } /** @@ -170,8 +170,8 @@ class user { if (!password_verify($password, $this->password)) { return false; } - if (password_needs_rehash($this->password, constants::password_algo, - ['cost' => constants::password_cost])) { + if (password_needs_rehash($this->password, Constants::password_algo, + ['cost' => Constants::password_cost])) { $this->setPassword($password); } return true; @@ -187,7 +187,7 @@ class user { * @return bool True on success, false on failure */ public function delete() { - $stmt = $this->pdo->prepare("DELETE FROM `".constants::db_prefix."user` WHERE `id`=?"); + $stmt = $this->pdo->prepare("DELETE FROM `".Constants::db_prefix."user` WHERE `id`=?"); $stmt->execute(array($this->id)); if ($stmt->rowCount() != 1) { return false; |