diff options
-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 | ||||
-rw-r--r-- | header.php | 42 | ||||
-rw-r--r-- | include/about.php | 4 | ||||
-rw-r--r-- | include/assignments-edit.php | 4 | ||||
-rw-r--r-- | include/assignments-new.php | 4 | ||||
-rw-r--r-- | include/assignments-overview.php | 20 | ||||
-rw-r--r-- | include/assignments-view.php | 14 | ||||
-rw-r--r-- | include/assignments.php | 6 | ||||
-rw-r--r-- | include/clients-edit.php | 4 | ||||
-rw-r--r-- | include/clients-new.php | 2 | ||||
-rw-r--r-- | include/clients-overview.php | 4 | ||||
-rw-r--r-- | include/clients-view.php | 20 | ||||
-rw-r--r-- | include/clients.php | 6 | ||||
-rw-r--r-- | include/contacts-edit.php | 4 | ||||
-rw-r--r-- | include/contacts-new.php | 4 | ||||
-rw-r--r-- | include/contacts-overview.php | 18 | ||||
-rw-r--r-- | include/contacts.php | 6 | ||||
-rw-r--r-- | include/discounts-edit.php | 4 | ||||
-rw-r--r-- | include/discounts-new.php | 4 | ||||
-rw-r--r-- | include/discounts-overview.php | 18 | ||||
-rw-r--r-- | include/discounts.php | 6 | ||||
-rw-r--r-- | include/home.php | 16 | ||||
-rw-r--r-- | include/offers-edit.php | 4 | ||||
-rw-r--r-- | include/offers-new.php | 4 | ||||
-rw-r--r-- | include/offers-overview.php | 20 | ||||
-rw-r--r-- | include/offers-view.php | 28 | ||||
-rw-r--r-- | include/offers.php | 12 | ||||
-rw-r--r-- | include/settings.php | 4 | ||||
-rw-r--r-- | include/users-new.php | 2 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | install/index.php | 40 | ||||
-rw-r--r-- | install/upgrade.php | 24 | ||||
-rw-r--r-- | login-ajax.php | 2 | ||||
-rw-r--r-- | login.php | 4 | ||||
-rw-r--r-- | nav.php | 28 |
48 files changed, 314 insertions, 314 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; @@ -26,40 +26,40 @@ <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> - <title><?=constants::my_name?></title> + <title><?=Constants::my_name?></title> - <link href="<?=constants::url_external?>/css/bootstrap.min.css" rel="stylesheet"> - <link href="<?=constants::url_external?>/css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet"> - <link href="<?=constants::url_external?>/css/plugins/timeline.css" rel="stylesheet"> - <link href="<?=constants::url_external?>/css/plugins/bootstrapValidator/bootstrapValidator.min.css" rel="stylesheet"> - <link href="<?=constants::url_external?>/css/plugins/bootstrap-editable.css" rel="stylesheet"> - <link href="<?=constants::url_external?>/css/plugins/bootstrap-select.min.css" rel="stylesheet"> - <link href="<?=constants::url_external?>/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"> - <link href="<?=constants::url_external?>/css/sb-admin-2.css" rel="stylesheet"> - <link href="<?=constants::url_external?>/css/businessadmin.css" rel="stylesheet"> + <link href="<?=Constants::url_external?>/css/bootstrap.min.css" rel="stylesheet"> + <link href="<?=Constants::url_external?>/css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet"> + <link href="<?=Constants::url_external?>/css/plugins/timeline.css" rel="stylesheet"> + <link href="<?=Constants::url_external?>/css/plugins/bootstrapValidator/bootstrapValidator.min.css" rel="stylesheet"> + <link href="<?=Constants::url_external?>/css/plugins/bootstrap-editable.css" rel="stylesheet"> + <link href="<?=Constants::url_external?>/css/plugins/bootstrap-select.min.css" rel="stylesheet"> + <link href="<?=Constants::url_external?>/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"> + <link href="<?=Constants::url_external?>/css/sb-admin-2.css" rel="stylesheet"> + <link href="<?=Constants::url_external?>/css/businessadmin.css" rel="stylesheet"> <!-- jQuery Version 1.11.0 --> - <script src="<?=constants::url_external?>/js/jquery-1.11.0.js"></script> + <script src="<?=Constants::url_external?>/js/jquery-1.11.0.js"></script> <!-- Bootstrap Core JavaScript --> - <script src="<?=constants::url_external?>/js/bootstrap.min.js"></script> + <script src="<?=Constants::url_external?>/js/bootstrap.min.js"></script> <!-- Plugins --> - <script src="<?=constants::url_external?>/js/plugins/metisMenu/metisMenu.min.js"></script> - <script src="<?=constants::url_external?>/js/plugins/bootstrapValidator/bootstrapValidator.min.js"></script> - <script src="<?=constants::url_external?>/js/plugins/form/jquery.form.min.js"></script> - <script src="<?=constants::url_external?>/js/plugins/bootstrap-editable.min.js"></script> - <script src="<?=constants::url_external?>/js/plugins/bootstrap-select.min.js"></script> - <script src="<?=constants::url_external?>/js/plugins/jquery.mixitup.min.js"></script> + <script src="<?=Constants::url_external?>/js/plugins/metisMenu/metisMenu.min.js"></script> + <script src="<?=Constants::url_external?>/js/plugins/bootstrapValidator/bootstrapValidator.min.js"></script> + <script src="<?=Constants::url_external?>/js/plugins/form/jquery.form.min.js"></script> + <script src="<?=Constants::url_external?>/js/plugins/bootstrap-editable.min.js"></script> + <script src="<?=Constants::url_external?>/js/plugins/bootstrap-select.min.js"></script> + <script src="<?=Constants::url_external?>/js/plugins/jquery.mixitup.min.js"></script> <!-- Custom Theme JavaScript --> - <script src="<?=constants::url_external?>/js/sb-admin-2.js"></script> + <script src="<?=Constants::url_external?>/js/sb-admin-2.js"></script> <!-- Fudge Custom JavaScript --> - <script src="<?=constants::url_external?>/js/businessadmin.js"></script> + <script src="<?=Constants::url_external?>/js/businessadmin.js"></script> <script type="text/javascript"> - var const_url_external = '<?=constants::url_external?>'; + var const_url_external = '<?=Constants::url_external?>'; </script> </head> diff --git a/include/about.php b/include/about.php index e7ab3d4..c2eb179 100644 --- a/include/about.php +++ b/include/about.php @@ -40,8 +40,8 @@ require('./header.php'); <div class="panel panel-default"> <div class="panel-heading">About</div> <div class="panel-body"> - <p class="lead">BusinessAdmin <?=constants::version?> is open source software under the GPL 3.0 license.</p> - <p>A full version of the license is available <a href="<?=constants::url_external?>LICENSE">here</a>. An excerpt is shown below:</p> + <p class="lead">BusinessAdmin <?=Constants::version?> is open source software under the GPL 3.0 license.</p> + <p>A full version of the license is available <a href="<?=Constants::url_external?>LICENSE">here</a>. An excerpt is shown below:</p> <pre>BusinessAdmin: administrative software for small companies Copyright (C) 2015 Camil Staps (ViviSoft) diff --git a/include/assignments-edit.php b/include/assignments-edit.php index 7c63680..d2f5a6c 100644 --- a/include/assignments-edit.php +++ b/include/assignments-edit.php @@ -20,10 +20,10 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { - $assignment = new assignment($_pdo, $_REQUEST['pk']); + $assignment = new Assignment($_pdo, $_REQUEST['pk']); $name = explode('-', $_REQUEST['name']); $what_to_edit = $name[count($name) - 1]; diff --git a/include/assignments-new.php b/include/assignments-new.php index 405c5fa..bcc545a 100644 --- a/include/assignments-new.php +++ b/include/assignments-new.php @@ -20,10 +20,10 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { - $offer = new offer($_pdo, $_REQUEST['offerId']); + $offer = new Offer($_pdo, $_REQUEST['offerId']); $assignment = $offer->createAssignment( $_REQUEST['title'], diff --git a/include/assignments-overview.php b/include/assignments-overview.php index 0e364d1..d4b350e 100644 --- a/include/assignments-overview.php +++ b/include/assignments-overview.php @@ -46,17 +46,17 @@ require_once('./login.php'); data-mixer-order-price='{$assignment->getPricePerHour()}'> <td class='col-min-width'>{$assignment->getId()}</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>) + <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->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> </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->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'> - ".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->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 </td> <td class='col-min-width'> <a title='View' href='?id={$assignment->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a> @@ -77,7 +77,7 @@ require_once('./login.php'); <div class="panel panel-default"> <div class="panel-heading">Create new</div> <div class="panel-body"> - <form role="form" id="newAssignment" action='<?=constants::url_external?>assignments/new' method="post" class="bootstrapValidator ajaxify" + <form role="form" id="newAssignment" action='<?=Constants::url_external?>assignments/new' method="post" class="bootstrapValidator ajaxify" data-ajaxify-options='{"success":"newAssignmentSuccess","error":"newAssignmentError","beforeSubmit":"newAssignmentBeforeSubmit"}'> <div class="ajaxify-response alert alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><span class="ajaxify-response-text"></span></div> <div class="col-lg-6"> @@ -114,7 +114,7 @@ require_once('./login.php'); data-bv-integer="true" data-bv-integer-message="Please enter an integer" /> </div> <div class="form-group"> - <label>Price per hour (<?=constants::invoice_valuta?>):</label> + <label>Price per hour (<?=Constants::invoice_valuta?>):</label> <input type="text" name="price_per_hour" class="form-control" placeholder="Price per hour" data-bv-notempty="true" data-bv-notempty-message="You have to give a rate" diff --git a/include/assignments-view.php b/include/assignments-view.php index 0bac039..d0a4ff3 100644 --- a/include/assignments-view.php +++ b/include/assignments-view.php @@ -19,7 +19,7 @@ require_once('./login.php'); -$_assignment = new assignment($_pdo, $_id); +$_assignment = new Assignment($_pdo, $_id); ?> <div class="col-lg-6"> <div class="panel panel-default"> @@ -43,14 +43,14 @@ $_assignment = new assignment($_pdo, $_id); data-mixer-order-price='{$_assignment->getPricePerHour()}'> <td class='col-min-width'>{$_assignment->getId()}</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>) + <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->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'> - ".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->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 </td> </tr>"; ?> diff --git a/include/assignments.php b/include/assignments.php index 14ed8da..7c3c79d 100644 --- a/include/assignments.php +++ b/include/assignments.php @@ -45,8 +45,8 @@ require('./header.php'); if (isset($_GET['id'])) { $id = (int) $_GET['id']; try { - $assignment = new assignment($_pdo, $id); - $header = "<a href='".constants::url_external."assignments'>Assignments</a> / {$assignment->getTitle()}"; + $assignment = new Assignment($_pdo, $id); + $header = "<a href='".Constants::url_external."assignments'>Assignments</a> / {$assignment->getTitle()}"; $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>"; @@ -64,7 +64,7 @@ require('./header.php'); echo "<div class='col-lg-12'>"; $id = (int) $_GET['delete']; try { - $assignment = new assignment($_pdo, $id); + $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>"; } else { diff --git a/include/clients-edit.php b/include/clients-edit.php index 3d92d06..00961aa 100644 --- a/include/clients-edit.php +++ b/include/clients-edit.php @@ -20,10 +20,10 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { - $client = new client($_pdo, $_REQUEST['pk']); + $client = new Client($_pdo, $_REQUEST['pk']); if ($client->setName($_REQUEST['value'])) { $response->success = true; } else { diff --git a/include/clients-new.php b/include/clients-new.php index fe66026..d1cf503 100644 --- a/include/clients-new.php +++ b/include/clients-new.php @@ -20,7 +20,7 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { $client = BusinessAdmin::createClient($_pdo, $_REQUEST['name']); diff --git a/include/clients-overview.php b/include/clients-overview.php index 860e671..cdced81 100644 --- a/include/clients-overview.php +++ b/include/clients-overview.php @@ -41,7 +41,7 @@ require_once('./login.php'); data-mixer-order-name='{$client->name}'> <td class='col-min-width'>{$client->id}</td> <td class='col-max-width'> - <a href='#' class='editable' id='editable-client-{$client->id}-name' data-type='text' data-pk='{$client->id}' data-url='".constants::url_external."clients/edit' data-title='Enter new name'> + <a href='#' class='editable' id='editable-client-{$client->id}-name' data-type='text' data-pk='{$client->id}' data-url='".Constants::url_external."clients/edit' data-title='Enter new name'> {$client->name} </a> </td> @@ -64,7 +64,7 @@ require_once('./login.php'); <div class="panel panel-default"> <div class="panel-heading">Create new</div> <div class="panel-body"> - <form role="form" id="newClient" action='<?=constants::url_external?>clients/new' method="post" class="bootstrapValidator ajaxify" + <form role="form" id="newClient" action='<?=Constants::url_external?>clients/new' method="post" class="bootstrapValidator ajaxify" data-ajaxify-options='{"success":"newClientSuccess","error":"newClientError","beforeSubmit":"newClientBeforeSubmit","clearForm":true}'> <div class="ajaxify-response alert alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><span class="ajaxify-response-text"></span></div> <div class="form-group"> diff --git a/include/clients-view.php b/include/clients-view.php index 007d94c..2472a80 100644 --- a/include/clients-view.php +++ b/include/clients-view.php @@ -19,7 +19,7 @@ require_once('./login.php'); -$_client = new client($_pdo, $_id); +$_client = new Client($_pdo, $_id); ?> <div class="col-lg-12"> <div class="panel panel-default"> @@ -41,22 +41,22 @@ $_client = new client($_pdo, $_id); foreach ($contacts as $contact) { echo "<tr> <td class='col-min-width'>{$contact->getId()}</td> - <td class='col-min-width'><a href='#' class='editable' id='editable-contact-{$contact->getId()}-name' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getName()}</a></td> + <td class='col-min-width'><a href='#' class='editable' id='editable-contact-{$contact->getId()}-name' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getName()}</a></td> <td class='col-max-width'> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-address' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getAddress()}</a><br/> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-postal_code' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getPostalCode()}</a> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-city' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getCity()}</a><br/> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-country' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getCountry()}</a> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-address' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getAddress()}</a><br/> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-postal_code' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getPostalCode()}</a> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-city' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getCity()}</a><br/> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-country' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getCountry()}</a> </td> - <td class='col-min-width'><a href='#' class='editable' id='editable-contact-{$contact->getId()}-language' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getLanguage()}</a></td> + <td class='col-min-width'><a href='#' class='editable' id='editable-contact-{$contact->getId()}-language' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getLanguage()}</a></td> <td class='col-min-width'> - <a title='View' href='".constants::url_internal."/contacts?id={$contact->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a> - <a title='Delete' href='".constants::url_internal."/contacts?delete={$contact->getId()}' class='btn btn-danger btn-circle fa fa-times'></a> + <a title='View' href='".Constants::url_internal."/contacts?id={$contact->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a> + <a title='Delete' href='".Constants::url_internal."/contacts?delete={$contact->getId()}' class='btn btn-danger btn-circle fa fa-times'></a> </td> </tr>"; } if (count($contacts) == 0) { - echo "<tr><td colspan='4'>There are no contacts in the database. Why not <a href='".constants::url_external."contacts'>create one</a>?</td></tr>"; + echo "<tr><td colspan='4'>There are no contacts in the database. Why not <a href='".Constants::url_external."contacts'>create one</a>?</td></tr>"; } ?> </tbody> diff --git a/include/clients.php b/include/clients.php index f762859..1e7110b 100644 --- a/include/clients.php +++ b/include/clients.php @@ -45,8 +45,8 @@ require('./header.php'); if (isset($_GET['id'])) { $id = (int) $_GET['id']; try { - $client = new client($_pdo, $id); - $header = "<a href='".constants::url_external."clients'>Clients</a> / {$client->name}"; + $client = new Client($_pdo, $id); + $header = "<a href='".Constants::url_external."clients'>Clients</a> / {$client->name}"; $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 client with id $id</i> could not be found.</div>"; @@ -64,7 +64,7 @@ require('./header.php'); echo "<div class='col-lg-12'>"; $id = (int) $_GET['delete']; try { - $client = new client($_pdo, $id); + $client = new Client($_pdo, $id); if ($client->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 client with name <i>{$client->name}</i> has been removed.</div>"; } else { diff --git a/include/contacts-edit.php b/include/contacts-edit.php index ac924a9..ead27d9 100644 --- a/include/contacts-edit.php +++ b/include/contacts-edit.php @@ -20,10 +20,10 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { - $contact = new contact($_pdo, $_REQUEST['pk']); + $contact = new Contact($_pdo, $_REQUEST['pk']); $name = explode('-', $_REQUEST['name']); $what_to_edit = $name[count($name) - 1]; diff --git a/include/contacts-new.php b/include/contacts-new.php index 440e744..c75298c 100644 --- a/include/contacts-new.php +++ b/include/contacts-new.php @@ -20,10 +20,10 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { - $client = new client($_pdo, $_REQUEST['clientId']); + $client = new Client($_pdo, $_REQUEST['clientId']); $contact = $client->createContact( $_REQUEST['name'], diff --git a/include/contacts-overview.php b/include/contacts-overview.php index 9cd71f3..4f2e6cf 100644 --- a/include/contacts-overview.php +++ b/include/contacts-overview.php @@ -43,20 +43,20 @@ require_once('./login.php'); data-mixer-order-name='{$contact->getName()}'> <td class='col-min-width'>{$contact->getId()}</td> <td class='col-min-width'> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-name' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getName()}</a><br/> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-name' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getName()}</a><br/> ({$contact->getClient()->name}) </td> <td class='col-max-width'> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-email' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getEmail()}</a><br/> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-email' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getEmail()}</a><br/> <br/> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-address' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getAddress()}</a><br/> - " . ($contact->getAddress_2() != '' ? "<a href='#' class='editable' id='editable-contact-{$contact->getId()}-address_2' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getAddress_2()}</a><br/>" : "") . " - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-postal_code' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getPostalCode()}</a> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-city' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getCity()}</a><br/> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-country' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getCountry()}</a> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-address' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getAddress()}</a><br/> + " . ($contact->getAddress_2() != '' ? "<a href='#' class='editable' id='editable-contact-{$contact->getId()}-address_2' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getAddress_2()}</a><br/>" : "") . " + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-postal_code' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getPostalCode()}</a> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-city' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getCity()}</a><br/> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-country' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getCountry()}</a> </td> <td class='col-min-width'> - <a href='#' class='editable' id='editable-contact-{$contact->getId()}-language' data-type='text' data-pk='{$contact->getId()}' data-url='".constants::url_external."contacts/edit'>{$contact->getLanguage()}</a> + <a href='#' class='editable' id='editable-contact-{$contact->getId()}-language' data-type='text' data-pk='{$contact->getId()}' data-url='".Constants::url_external."contacts/edit'>{$contact->getLanguage()}</a> </td> <td class='col-min-width'> <a title='View' href='?id={$contact->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a> @@ -77,7 +77,7 @@ require_once('./login.php'); <div class="panel panel-default"> <div class="panel-heading">Create new</div> <div class="panel-body"> - <form role="form" id="newContact" action='<?=constants::url_external?>contacts/new' method="post" class="bootstrapValidator ajaxify" + <form role="form" id="newContact" action='<?=Constants::url_external?>contacts/new' method="post" class="bootstrapValidator ajaxify" data-ajaxify-options='{"success":"newContactSuccess","error":"newContactError","beforeSubmit":"newContactBeforeSubmit"}'> <div class="ajaxify-response alert alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><span class="ajaxify-response-text"></span></div> <div class="form-group"> diff --git a/include/contacts.php b/include/contacts.php index 09a452f..1231e24 100644 --- a/include/contacts.php +++ b/include/contacts.php @@ -45,8 +45,8 @@ require('./header.php'); if (isset($_GET['id'])) { $id = (int) $_GET['id']; try { - $contact = new contact($_pdo, $id); - $header = "<a href='".constants::url_external."contacts'>Contacts</a> / {$contact->getName()}"; + $contact = new Contact($_pdo, $id); + $header = "<a href='".Constants::url_external."contacts'>Contacts</a> / {$contact->getName()}"; $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 contact with id $id</i> could not be found.</div>"; @@ -64,7 +64,7 @@ require('./header.php'); echo "<div class='col-lg-12'>"; $id = (int) $_GET['delete']; try { - $contact = new contact($_pdo, $id); + $contact = new Contact($_pdo, $id); if ($contact->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 contact with name <i>{$contact->getName()}</i> has been removed.</div>"; } else { diff --git a/include/discounts-edit.php b/include/discounts-edit.php index 2d64bd9..797a95b 100644 --- a/include/discounts-edit.php +++ b/include/discounts-edit.php @@ -20,10 +20,10 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { - $discount = new discount($_pdo, $_REQUEST['pk']); + $discount = new Discount($_pdo, $_REQUEST['pk']); $name = explode('-', $_REQUEST['name']); $what_to_edit = $name[count($name) - 1]; diff --git a/include/discounts-new.php b/include/discounts-new.php index b0cfa07..26452aa 100644 --- a/include/discounts-new.php +++ b/include/discounts-new.php @@ -20,10 +20,10 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { - $offer = new offer($_pdo, $_REQUEST['offerId']); + $offer = new Offer($_pdo, $_REQUEST['offerId']); $discount = $offer->createDiscount( $_REQUEST['title'], diff --git a/include/discounts-overview.php b/include/discounts-overview.php index 1bf55d6..60ddf13 100644 --- a/include/discounts-overview.php +++ b/include/discounts-overview.php @@ -44,16 +44,16 @@ require_once('./login.php'); data-mixer-order-value='{$discount->getValue()}'> <td class='col-min-width'>{$discount->getId()}</td> <td class='col-min-width'> - <a href='".constants::url_internal."/offers?id={$discount->getOffer()->getId()}'>#{$discount->getOffer()->getId()}</a> to - <a href='".constants::url_internal."/contacts?id={$discount->getOffer()->getContact()->getId()}'>{$discount->getOffer()->getContact()->getName()}</a> - (<a href='".constants::url_internal."/clients?id={$discount->getOffer()->getContact()->getClient()->id}'>{$discount->getOffer()->getContact()->getClient()->name}</a>) + <a href='".Constants::url_internal."/offers?id={$discount->getOffer()->getId()}'>#{$discount->getOffer()->getId()}</a> to + <a href='".Constants::url_internal."/contacts?id={$discount->getOffer()->getContact()->getId()}'>{$discount->getOffer()->getContact()->getName()}</a> + (<a href='".Constants::url_internal."/clients?id={$discount->getOffer()->getContact()->getClient()->id}'>{$discount->getOffer()->getContact()->getClient()->name}</a>) <td class='col-max-width'> - <b><a href='#' class='editable' id='editable-discount-{$discount->getId()}-title' data-type='text' data-pk='{$discount->getId()}' data-url='".constants::url_external."discounts/edit'>{$discount->getTitle()}</a></b><br/> - <p><a href='#' class='editable editable-noshow' id='editable-discount-{$discount->getId()}-description' data-type='textarea' data-mode='inline' data-pk='{$discount->getId()}' data-url='".constants::url_external."discounts/edit'>{$discount->getDescription(false)}</a></p> + <b><a href='#' class='editable' id='editable-discount-{$discount->getId()}-title' data-type='text' data-pk='{$discount->getId()}' data-url='".Constants::url_external."discounts/edit'>{$discount->getTitle()}</a></b><br/> + <p><a href='#' class='editable editable-noshow' id='editable-discount-{$discount->getId()}-description' data-type='textarea' data-mode='inline' data-pk='{$discount->getId()}' data-url='".Constants::url_external."discounts/edit'>{$discount->getDescription(false)}</a></p> </td> <td class='col-min-width'> - ".constants::invoice_valuta."<a href='#' class='editable' id='editable-discount-{$discount->getId()}-value' data-type='text' data-pk='{$discount->getId()}' data-url='".constants::url_external."discounts/edit'>{$discount->getValue()}</a><br/> - <a href='#' class='editable' id='editable-discount-{$discount->getId()}-vat' data-type='text' data-pk='{$discount->getId()}' data-url='".constants::url_external."discounts/edit'>{$discount->getVAT()}</a>% VAT + ".Constants::invoice_valuta."<a href='#' class='editable' id='editable-discount-{$discount->getId()}-value' data-type='text' data-pk='{$discount->getId()}' data-url='".Constants::url_external."discounts/edit'>{$discount->getValue()}</a><br/> + <a href='#' class='editable' id='editable-discount-{$discount->getId()}-vat' data-type='text' data-pk='{$discount->getId()}' data-url='".Constants::url_external."discounts/edit'>{$discount->getVAT()}</a>% VAT </td> <td class='col-min-width'> <a title='View' href='?id={$discount->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a> @@ -74,7 +74,7 @@ require_once('./login.php'); <div class="panel panel-default"> <div class="panel-heading">Create new</div> <div class="panel-body"> - <form role="form" id="newDiscount" action='<?=constants::url_external?>discounts/new' method="post" class="bootstrapValidator ajaxify" + <form role="form" id="newDiscount" action='<?=Constants::url_external?>discounts/new' method="post" class="bootstrapValidator ajaxify" data-ajaxify-options='{"success":"newDiscountSuccess","error":"newDiscountError","beforeSubmit":"newDiscountBeforeSubmit"}'> <div class="ajaxify-response alert alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><span class="ajaxify-response-text"></span></div> <div class="col-lg-6"> @@ -104,7 +104,7 @@ require_once('./login.php'); </div> <div class="col-lg-6"> <div class="form-group"> - <label>Value (<?=constants::invoice_valuta?>):</label> + <label>Value (<?=Constants::invoice_valuta?>):</label> <input type="text" name="value" class="form-control" placeholder="Value" data-bv-notempty="true" data-bv-notempty-message="You have to give a value" diff --git a/include/discounts.php b/include/discounts.php index ff2a69a..a4d9df6 100644 --- a/include/discounts.php +++ b/include/discounts.php @@ -45,8 +45,8 @@ require('./header.php'); if (isset($_GET['id'])) { $id = (int) $_GET['id']; try { - $discount = new discount($_pdo, $id); - $header = "<a href='".constants::url_external."discounts'>Discounts</a> / {$discount->getTitle()}"; + $discount = new Discount($_pdo, $id); + $header = "<a href='".Constants::url_external."discounts'>Discounts</a> / {$discount->getTitle()}"; $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 discount with id $id</i> could not be found.</div>"; @@ -64,7 +64,7 @@ require('./header.php'); echo "<div class='col-lg-12'>"; $id = (int) $_GET['delete']; try { - $discount = new discount($_pdo, $id); + $discount = new Discount($_pdo, $id); if ($discount->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 discount with title <i>{$discount->getTitle()}</i> has been removed.</div>"; } else { diff --git a/include/home.php b/include/home.php index 6a25743..a15d2c4 100644 --- a/include/home.php +++ b/include/home.php @@ -51,7 +51,7 @@ require('./header.php'); </div> </div> </div> - <a href="<?=constants::url_external?>offers"> + <a href="<?=Constants::url_external?>offers"> <div class="panel-footer"> <span class="pull-left">Unaccepted offers</span> <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span> @@ -115,7 +115,7 @@ require('./header.php'); $count = count(BusinessAdmin::getOfferIds($_pdo, array( "`invoice_date` > '1970-01-01'", "`invoice_date`<=CURDATE()", - "NOT EXISTS (SELECT * FROM `".constants::db_prefix."payment` WHERE `offerId`=`".constants::db_prefix."offer`.`id`)"))); + "NOT EXISTS (SELECT * FROM `".Constants::db_prefix."payment` WHERE `offerId`=`".Constants::db_prefix."offer`.`id`)"))); ?> <div class="panel panel-<?=($count==0 ? 'primary' : 'yellow')?>"> <div class="panel-heading"> @@ -167,8 +167,8 @@ require('./header.php'); 'id' => $offer->getId(), 'contactClientName' => $offer->getContact()->getClient()->name, 'percentage' => $percentage, - 'price_excl' => constants::invoice_valuta . $offer->calculate(offer::SUBTOTAL), - 'price_incl' => constants::invoice_valuta . $offer->calculate(offer::TOTAL) + 'price_excl' => Constants::invoice_valuta . $offer->calculate(offer::SUBTOTAL), + 'price_incl' => Constants::invoice_valuta . $offer->calculate(offer::TOTAL) ); } krsort($list, SORT_STRING); @@ -242,7 +242,7 @@ require('./header.php'); $offers = BusinessAdmin::getOffers($_pdo, array( "`invoice_date` > '1970-01-01'", "`invoice_date`<=CURDATE()", - "NOT EXISTS (SELECT * FROM `".constants::db_prefix."payment` WHERE `offerId`=`".constants::db_prefix."offer`.`id`)")); + "NOT EXISTS (SELECT * FROM `".Constants::db_prefix."payment` WHERE `offerId`=`".Constants::db_prefix."offer`.`id`)")); if (count($offers) == 0) { echo "<tr><td colspan='3'>There are no currently open invoices.</td></tr>"; } else { @@ -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->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/>"; } $list[] = array_merge($temp, array('type' => 'start', 'time' => $offer->getStartDate(), 'description' => 'Offer started')); $sort_list[] = $offer->getStartDate() . $offer->getId() . 0; @@ -311,7 +311,7 @@ require('./header.php'); case 'start': echo "<div class='timeline-badge info' title='{$item['description']}'><i class='fa fa-circle-o-notch'></i></div>"; break; case 'end': echo "<div class='timeline-badge primary' title='{$item['description']}'><i class='fa fa-circle-o'></i></div>"; break; case 'invoice': echo "<div class='timeline-badge warning' title='{$item['description']}'><i class='fa fa-check-circle-o'></i></div>"; break; - case 'payment_received': echo "<div class='timeline-badge success' title='{$item['description']}'><i class='fa fa-".constants::fa_valuta."'></i></div>"; break; + case 'payment_received': echo "<div class='timeline-badge success' title='{$item['description']}'><i class='fa fa-".Constants::fa_valuta."'></i></div>"; break; } echo "<div class='timeline-panel'>"; echo "<div class='timeline-heading'><h4 class='timeline-title'>#{$item['id']} to {$item['contact']}: {$item['description']}</h4><p><small class='text-muted'><i class='fa fa-clock-o fa-fw'></i> ".BusinessAdmin::formatDate($item['time'],false,true,true)."</small></p></div>"; diff --git a/include/offers-edit.php b/include/offers-edit.php index 7f050c3..3954098 100644 --- a/include/offers-edit.php +++ b/include/offers-edit.php @@ -20,10 +20,10 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { - $offer = new offer($_pdo, $_REQUEST['pk']); + $offer = new Offer($_pdo, $_REQUEST['pk']); $name = explode('-', $_REQUEST['name']); $what_to_edit = $name[count($name) - 1]; diff --git a/include/offers-new.php b/include/offers-new.php index 9c499a8..ecd5674 100644 --- a/include/offers-new.php +++ b/include/offers-new.php @@ -20,10 +20,10 @@ require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { - $contact = new contact($_pdo, $_REQUEST['contactId']); + $contact = new Contact($_pdo, $_REQUEST['contactId']); $offer = $contact->createOffer(); $response->success = true; diff --git a/include/offers-overview.php b/include/offers-overview.php index 9eaf25d..9c0a706 100644 --- a/include/offers-overview.php +++ b/include/offers-overview.php @@ -46,29 +46,29 @@ 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->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>"; } 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>"; + 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>"; } echo "</td> <td class='col-min-width'> <table> <tr> <th style='padding-right:1em;'>From:</th> - <td><a href='#' class='editable' id='editable-offer-{$offer->getId()}-start_date' data-type='text' data-pk='{$offer->getId()}' data-url='".constants::url_external."offers/edit'>".BusinessAdmin::formatDate($offer->getStartDate(),false,true)."</a></td> + <td><a href='#' class='editable' id='editable-offer-{$offer->getId()}-start_date' data-type='text' data-pk='{$offer->getId()}' data-url='".Constants::url_external."offers/edit'>".BusinessAdmin::formatDate($offer->getStartDate(),false,true)."</a></td> </tr> <tr> <th style='padding-right:1em;'>To:</th> - <td><a href='#' class='editable' id='editable-offer-{$offer->getId()}-end_date' data-type='text' data-pk='{$offer->getId()}' data-url='".constants::url_external."offers/edit'>".BusinessAdmin::formatDate($offer->getEndDate(),false,true)."</a></td> + <td><a href='#' class='editable' id='editable-offer-{$offer->getId()}-end_date' data-type='text' data-pk='{$offer->getId()}' data-url='".Constants::url_external."offers/edit'>".BusinessAdmin::formatDate($offer->getEndDate(),false,true)."</a></td> </tr> <tr> <th style='padding-right:1em;'>Invoice:</th> - <td><a href='#' class='editable' id='editable-offer-{$offer->getId()}-invoice_date' data-type='text' data-pk='{$offer->getId()}' data-url='".constants::url_external."offers/edit'>".BusinessAdmin::formatDate($offer->getInvoiceDate(),false,true)."</a></td> + <td><a href='#' class='editable' id='editable-offer-{$offer->getId()}-invoice_date' data-type='text' data-pk='{$offer->getId()}' data-url='".Constants::url_external."offers/edit'>".BusinessAdmin::formatDate($offer->getInvoiceDate(),false,true)."</a></td> </tr> <tr> <th style='padding-right:1em;'>Payment received:</th> - <td><a href='#' class='editable' id='editable-offer-{$offer->getId()}-payment_received' data-type='text' data-pk='{$offer->getId()}' data-url='".constants::url_external."offers/edit'>".BusinessAdmin::formatDate($offer->getPaymentReceived(),false,true)."</a></td> + <td><a href='#' class='editable' id='editable-offer-{$offer->getId()}-payment_received' data-type='text' data-pk='{$offer->getId()}' data-url='".Constants::url_external."offers/edit'>".BusinessAdmin::formatDate($offer->getPaymentReceived(),false,true)."</a></td> </tr> </table> </td> @@ -82,15 +82,15 @@ require_once('./login.php'); <table> <tr> <th style='padding-right:1em;'>Subtotal:</th> - <td>".constants::invoice_valuta."{$offer->calculate(offer::SUBTOTAL)}</td> + <td>".Constants::invoice_valuta."{$offer->calculate(offer::SUBTOTAL)}</td> </tr> <tr> <th style='padding-right:1em;'>VAT:</th> - <td>".constants::invoice_valuta."{$offer->calculate(offer::VAT)}</td> + <td>".Constants::invoice_valuta."{$offer->calculate(offer::VAT)}</td> <tr> </tr> <th style='padding-right:1em;'>Total:</th> - <td>".constants::invoice_valuta."{$offer->calculate(offer::TOTAL)}</td> + <td>".Constants::invoice_valuta."{$offer->calculate(offer::TOTAL)}</td> </tr> </table> </td> @@ -112,7 +112,7 @@ require_once('./login.php'); <div class="panel panel-default"> <div class="panel-heading">Create new</div> <div class="panel-body"> - <form role="form" id="newOffer" action='<?=constants::url_external?>offers/new' method="post" class="bootstrapValidator ajaxify" + <form role="form" id="newOffer" action='<?=Constants::url_external?>offers/new' method="post" class="bootstrapValidator ajaxify" data-ajaxify-options='{"success":"newOfferSuccess","error":"newOfferError","beforeSubmit":"newOfferBeforeSubmit"}'> <div class="ajaxify-response alert alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><span class="ajaxify-response-text"></span></div> <div class="form-group"> diff --git a/include/offers-view.php b/include/offers-view.php index 8f741c2..9b69dce 100644 --- a/include/offers-view.php +++ b/include/offers-view.php @@ -19,7 +19,7 @@ require_once('./login.php'); -$_offer = new offer($_pdo, $_id); +$_offer = new Offer($_pdo, $_id); ?> <div class="col-lg-6"> <div class="panel panel-default" id="panel-timeline"> @@ -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->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/>"; } $list[] = array_merge($temp, array('type' => 'start', 'time' => $_offer->getStartDate(), 'description' => 'Offer started')); $sort_list[] = $_offer->getStartDate() . $_offer->getId() . 0; @@ -106,17 +106,17 @@ $_offer = new offer($_pdo, $_id); echo "<tr> <td class='col-min-width'>{$assignment->getId()}</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/> + <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> </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->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'> - ".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->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 </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->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> </td> </tr>"; } @@ -149,16 +149,16 @@ $_offer = new offer($_pdo, $_id); echo "<tr> <td class='col-min-width'>{$discount->getId()}</td> <td class='col-max-width'> - <b><a href='#' class='editable' id='editable-discount-{$discount->getId()}-title' data-type='text' data-pk='{$discount->getId()}' data-url='".constants::url_external."discounts/edit'>{$discount->getTitle()}</a></b><br/> + <b><a href='#' class='editable' id='editable-discount-{$discount->getId()}-title' data-type='text' data-pk='{$discount->getId()}' data-url='".Constants::url_external."discounts/edit'>{$discount->getTitle()}</a></b><br/> <p>{$discount->getDescription()}</p> </td> <td class='col-min-width'> - ".constants::invoice_valuta."<a href='#' class='editable' id='editable-discount-{$discount->getId()}-value' data-type='text' data-pk='{$discount->getId()}' data-url='".constants::url_external."discounts/edit'>{$discount->getValue()}</a> / hr<br/> - <a href='#' class='editable' id='editable-discount-{$discount->getId()}-vat' data-type='text' data-pk='{$discount->getId()}' data-url='".constants::url_external."discounts/edit'>{$discount->getVAT()}</a>% VAT + ".Constants::invoice_valuta."<a href='#' class='editable' id='editable-discount-{$discount->getId()}-value' data-type='text' data-pk='{$discount->getId()}' data-url='".Constants::url_external."discounts/edit'>{$discount->getValue()}</a> / hr<br/> + <a href='#' class='editable' id='editable-discount-{$discount->getId()}-vat' data-type='text' data-pk='{$discount->getId()}' data-url='".Constants::url_external."discounts/edit'>{$discount->getVAT()}</a>% VAT </td> <td class='col-min-width'> - <a title='View' href='".constants::url_internal."/discounts?id={$discount->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a> - <a title='Delete' href='".constants::url_internal."/discounts?delete={$discount->getId()}' class='btn btn-danger btn-circle fa fa-times'></a> + <a title='View' href='".Constants::url_internal."/discounts?id={$discount->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a> + <a title='Delete' href='".Constants::url_internal."/discounts?delete={$discount->getId()}' class='btn btn-danger btn-circle fa fa-times'></a> </td> </tr>"; } diff --git a/include/offers.php b/include/offers.php index 81781ba..7208ee6 100644 --- a/include/offers.php +++ b/include/offers.php @@ -48,8 +48,8 @@ require('./header.php'); if (isset($_GET['id'])) { $id = (int) $_GET['id']; try { - $offer = new offer($_pdo, $id); - $header = "<a href='".constants::url_external."offers'>Offers</a> / #{$offer->getId()}"; + $offer = new Offer($_pdo, $id); + $header = "<a href='".Constants::url_external."offers'>Offers</a> / #{$offer->getId()}"; $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 offer with id $id</i> could not be found.</div>"; @@ -67,7 +67,7 @@ require('./header.php'); echo "<div class='col-lg-12'>"; $id = (int) $_GET['toggle_accept']; try { - $offer = new offer($_pdo, $id); + $offer = new Offer($_pdo, $id); if ($offer->toggleAccepted()) { echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The status offer #{$offer->getId()} has been set to <i>".($offer->isAccepted() ? "accepted" : "unaccepted")."</i>.</div>"; } else { @@ -87,7 +87,7 @@ require('./header.php'); echo "<div class='col-lg-12'>"; $id = (int) $_GET['generate_invoice']; try { - $offer = new offer($_pdo, $id); + $offer = new Offer($_pdo, $id); $file = $offer->generateInvoice(); echo "<div class='alert alert-success alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The invoice for offer #{$offer->getId()} is generated: <a class='alert-link' href='{$file->getFilenameURI()}' target='_blank'>{$file->getFilename()}</a></div>"; } catch (PDOException $e) { @@ -103,7 +103,7 @@ require('./header.php'); echo "<div class='col-lg-12'>"; $id = (int) $_GET['trash_invoice']; try { - $offer = new offer($_pdo, $id); + $offer = new Offer($_pdo, $id); $file = $offer->getInvoiceFile(); if ($file instanceof file && $file->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 invoice for offer #{$offer->getId()} is trashed.</div>"; @@ -123,7 +123,7 @@ require('./header.php'); echo "<div class='col-lg-12'>"; $id = (int) $_GET['delete']; try { - $offer = new offer($_pdo, $id); + $offer = new Offer($_pdo, $id); if ($offer->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 offer #{$offer->getId()} has been removed.</div>"; } else { diff --git a/include/settings.php b/include/settings.php index 896152c..bd4c0d0 100644 --- a/include/settings.php +++ b/include/settings.php @@ -38,7 +38,7 @@ require('./header.php'); <?php if (isset($_GET['delete_user']) && $_user->isAdmin()) { try { - $user = new user($_pdo, $_GET['delete_user']); + $user = new User($_pdo, $_GET['delete_user']); if ($user->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 user with username <i>{$user->getUsername()}</i> has been removed.</div>"; } else { @@ -135,7 +135,7 @@ require('./header.php'); <div class="panel panel-default"> <div class="panel-heading">Create new</div> <div class="panel-body"> - <form role="form" id="newUser" action='<?=constants::url_external?>users/new' method="post" class="bootstrapValidator ajaxify" + <form role="form" id="newUser" action='<?=Constants::url_external?>users/new' method="post" class="bootstrapValidator ajaxify" data-ajaxify-options='{"success":"newUserSuccess","error":"newUserError","beforeSubmit":"newUserBeforeSubmit","clearForm":true}'> <div class="ajaxify-response alert alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><span class="ajaxify-response-text"></span></div> <div class="form-group"> diff --git a/include/users-new.php b/include/users-new.php index d32e201..5b4bd7f 100644 --- a/include/users-new.php +++ b/include/users-new.php @@ -22,7 +22,7 @@ define('REQUIRE_ADMIN', true); require_once('./conf.php'); require_once('./login-ajax.php'); -$response = new response(); +$response = new Response(); try { $pass = user::generateRandomPassword(); @@ -31,7 +31,7 @@ require_once('./conf.php'); // Fetch information from the REQUEST_URI. $_request = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); -$_request = str_replace(constants::url_internal, '', $_request); +$_request = str_replace(Constants::url_internal, '', $_request); // This is the REQUEST_URI switch // The default shows a 404 page diff --git a/install/index.php b/install/index.php index 3873ce3..26812c3 100644 --- a/install/index.php +++ b/install/index.php @@ -21,7 +21,7 @@ require('../conf.php'); if (isset($_GET['create_tables'])) { try { - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."assignment` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."assignment` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `offerId` smallint(5) unsigned NOT NULL, `title` tinytext NOT NULL, @@ -34,14 +34,14 @@ if (isset($_GET['create_tables'])) { KEY `offerId` (`offerId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."client` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."client` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `name` tinytext NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`(255)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."contact` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."contact` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `clientId` smallint(5) unsigned NOT NULL, `name` tinytext NOT NULL, @@ -57,7 +57,7 @@ if (isset($_GET['create_tables'])) { KEY `clientId` (`clientId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."discount` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."discount` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `offerId` smallint(5) unsigned NOT NULL, `title` tinytext NOT NULL, @@ -67,14 +67,14 @@ if (isset($_GET['create_tables'])) { PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."file` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."file` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `filename` varchar(100) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `filename` (`filename`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."offer` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."offer` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `contactId` smallint(5) unsigned NOT NULL, `start_date` date NOT NULL, @@ -96,25 +96,25 @@ if (isset($_GET['create_tables'])) { PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."user` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."user` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(24) NOT NULL, `password` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); - $_pdo->query("ALTER TABLE `".constants::db_prefix."assignment` - ADD CONSTRAINT `assignment_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".constants::db_prefix."offer` (`id`)"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."assignment` + ADD CONSTRAINT `assignment_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".Constants::db_prefix."offer` (`id`)"); - $_pdo->query("ALTER TABLE `".constants::db_prefix."contact` - ADD CONSTRAINT `contact_ibfk_1` FOREIGN KEY (`clientId`) REFERENCES `".constants::db_prefix."client` (`id`)"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."contact` + ADD CONSTRAINT `contact_ibfk_1` FOREIGN KEY (`clientId`) REFERENCES `".Constants::db_prefix."client` (`id`)"); - $_pdo->query("ALTER TABLE `".constants::db_prefix."discount` - ADD CONSTRAINT `discount_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".constants::db_prefix."offer` (`id`);"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."discount` + ADD CONSTRAINT `discount_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".Constants::db_prefix."offer` (`id`);"); - $_pdo->query("ALTER TABLE `".constants::db_prefix."offer` - ADD CONSTRAINT `offer_ibfk_1` FOREIGN KEY (`invoice_fileId`) REFERENCES `".constants::db_prefix."file` (`id`), - ADD CONSTRAINT `offer_ibfk_2` FOREIGN KEY (`contactId`) REFERENCES `".constants::db_prefix."contact` (`id`)"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."offer` + ADD CONSTRAINT `offer_ibfk_1` FOREIGN KEY (`invoice_fileId`) REFERENCES `".Constants::db_prefix."file` (`id`), + ADD CONSTRAINT `offer_ibfk_2` FOREIGN KEY (`contactId`) REFERENCES `".Constants::db_prefix."contact` (`id`)"); $_pdo->query("ALTER TABLE `payment` ADD CONSTRAINT `payment_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `offer` (`id`);"); @@ -129,11 +129,11 @@ if (isset($_GET['create_tables'])) { } if (isset($_GET['create_folders'])) { - if (!mkdir(constants::files_folder)) { - echo "Creating folder `" . constants::files_folder . "` failed.<br/>"; + if (!mkdir(Constants::files_folder)) { + echo "Creating folder `" . Constants::files_folder . "` failed.<br/>"; } - if (!mkdir(constants::files_folder . constants::files_folder_trash)) { - echo "Creating folder `" . constants::files_folder_trash . "` failed.<br/>"; + if (!mkdir(Constants::files_folder . Constants::files_folder_trash)) { + echo "Creating folder `" . Constants::files_folder_trash . "` failed.<br/>"; } } diff --git a/install/upgrade.php b/install/upgrade.php index 0643ff5..aea97ce 100644 --- a/install/upgrade.php +++ b/install/upgrade.php @@ -40,7 +40,7 @@ if (isset($_GET['upgrade'])) { if (lower_version($_GET['upgrade'], '0.1')) { try { - $_pdo->query("ALTER TABLE `".constants::db_prefix."assignment` CHANGE `hours` `hours` FLOAT UNSIGNED NOT NULL"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."assignment` CHANGE `hours` `hours` FLOAT UNSIGNED NOT NULL"); } catch (PDOException $e) { echo "Altering the database structure failed with a PDOException ({$e->getCode()}): {$e->getMessage()}<br/>" . $e->getTraceAsString(); } @@ -48,8 +48,8 @@ if (isset($_GET['upgrade'])) { if (lower_version($_GET['upgrade'], '0.2.2')) { try { - $_pdo->query("ALTER TABLE `".constants::db_prefix."assignment` DROP FOREIGN KEY `assignment_ibfk_1`"); - $_pdo->query("ALTER TABLE `".constants::db_prefix."assignment` ADD CONSTRAINT `assignment_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".constants::db_prefix."offer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."assignment` DROP FOREIGN KEY `assignment_ibfk_1`"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."assignment` ADD CONSTRAINT `assignment_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".Constants::db_prefix."offer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE"); } catch (PDOException $e) { echo "Altering the database structure failed with a PDOException ({$e->getCode()}): {$e->getMessage()}<br/>" . $e->getTraceAsString(); } @@ -57,7 +57,7 @@ if (isset($_GET['upgrade'])) { if (lower_version($_GET['upgrade'], '0.3')) { try { - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."discount` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."discount` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `offerId` smallint(5) unsigned NOT NULL, `title` tinytext NOT NULL, @@ -66,8 +66,8 @@ if (isset($_GET['upgrade'])) { `VAT_percentage` float NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); - $_pdo->query("ALTER TABLE `".constants::db_prefix."discount` - ADD CONSTRAINT `discount_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".constants::db_prefix."offer` (`id`);"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."discount` + ADD CONSTRAINT `discount_ibfk_1` FOREIGN KEY (`offerId`) REFERENCES `".Constants::db_prefix."offer` (`id`);"); } catch (PDOException $e) { echo "Altering the database structure failed with a PDOException ({$e->getCode()}): {$e->getMessage()}<br/>" . $e->getTraceAsString(); } @@ -75,7 +75,7 @@ if (isset($_GET['upgrade'])) { if (lower_version($_GET['upgrade'], '0.4')) { try { - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."user` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."user` ( `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(24) NOT NULL, `password` varchar(255) NOT NULL, @@ -88,21 +88,21 @@ if (isset($_GET['upgrade'])) { if (lower_version($_GET['upgrade'], '0.4.2')) { try { - $_pdo->query("CREATE TABLE IF NOT EXISTS `".constants::db_prefix."payment` ( + $_pdo->query("CREATE TABLE IF NOT EXISTS `".Constants::db_prefix."payment` ( `id` smallint(5) unsigned NOT NULL, `offerId` smallint(5) unsigned NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); - $offers = $_pdo->query("SELECT `id`,`payment_received` FROM `".constants::db_prefix."offer` WHERE `payment_received` IS NOT NULL"); + $offers = $_pdo->query("SELECT `id`,`payment_received` FROM `".Constants::db_prefix."offer` WHERE `payment_received` IS NOT NULL"); $offers = $offers->fetchAll(PDO::FETCH_ASSOC); foreach ($offers as $offer) { $received = $offer['payment_received']; - $offer = new offer($_pdo, $offer['id']); + $offer = new Offer($_pdo, $offer['id']); $offer->createPayment($received); } - $_pdo->query("ALTER TABLE `".constants::db_prefix."offer` DROP `payment_received`;"); + $_pdo->query("ALTER TABLE `".Constants::db_prefix."offer` DROP `payment_received`;"); } catch (PDOException $e) { echo "Altering the database structure failed with a PDOException ({$e->getCode()}): {$e->getMessage()}<br/>" . $e->getTraceAsString(); } @@ -112,7 +112,7 @@ if (isset($_GET['upgrade'])) { } ?> -<p>You're going to upgrade to version <?=constants::version?>. What was your old version number?</p> +<p>You're going to upgrade to version <?=Constants::version?>. What was your old version number?</p> <form method="GET"> <input type="text" name="upgrade" placeholder="Old version"/> <input type="submit" value="Upgrade"/> diff --git a/login-ajax.php b/login-ajax.php index cf9eb1b..baab859 100644 --- a/login-ajax.php +++ b/login-ajax.php @@ -34,7 +34,7 @@ if (!isset($_SESSION['login']) || $_SESSION['login'] === false) { die(); } -$_user = new user($_pdo, $_SESSION['login']); +$_user = new User($_pdo, $_SESSION['login']); if (defined('REQUIRE_ADMIN') && REQUIRE_ADMIN && !$_user->isAdmin()) { print(json_encode(['success' => false, 'message' => 'You need to be an administrator.'])); @@ -31,7 +31,7 @@ require_once('./conf.php'); if (isset($_GET['logout'])) { $_SESSION['login'] = false; - header('Location: ' . constants::url_external); + header('Location: ' . Constants::url_external); die(); } @@ -86,7 +86,7 @@ if (!isset($_SESSION['login']) || $_SESSION['login'] === false) { die(); } -$_user = new user($_pdo, $_SESSION['login']); +$_user = new User($_pdo, $_SESSION['login']); if (defined('REQUIRE_ADMIN') && REQUIRE_ADMIN && !$_user->isAdmin()) { include('./header.php'); @@ -27,14 +27,14 @@ <span class="icon-bar"></span> <span class="icon-bar"></span> </button> - <a class="navbar-brand" href="<?=constants::url_internal?>/"><?=constants::my_name?></a> + <a class="navbar-brand" href="<?=Constants::url_internal?>/"><?=Constants::my_name?></a> </div> <!-- /.navbar-header --> <ul class="nav navbar-top-links navbar-right"> <span> - Logged in as <a href="<?=constants::url_internal?>/settings"><?=$_user->getUsername()?></a> - (<a href="<?=constants::url_internal?>/?logout">logout</a>) + Logged in as <a href="<?=Constants::url_internal?>/settings"><?=$_user->getUsername()?></a> + (<a href="<?=Constants::url_internal?>/?logout">logout</a>) </span> <!-- /.dropdown --> <li class="dropdown"> @@ -59,13 +59,13 @@ 'id' => $offer->getId(), 'contactClientName' => $offer->getContact()->getClient()->name, 'percentage' => $percentage, - 'price' => constants::invoice_valuta . $offer->calculate(offer::SUBTOTAL) + 'price' => Constants::invoice_valuta . $offer->calculate(offer::SUBTOTAL) ); } krsort($list, SORT_STRING); foreach ($list as $item) { echo "<li> - <a href='".constants::url_internal."/offers?id={$item['id']}'> + <a href='".Constants::url_internal."/offers?id={$item['id']}'> <div> <p> <strong>{$item['contactClientName']}</strong> ({$item['start']} - {$item['end']}; {$item['price']}) @@ -82,7 +82,7 @@ } ?> <li> - <a class="text-center" href="<?=constants::url_internal?>/offers"> + <a class="text-center" href="<?=Constants::url_internal?>/offers"> <strong>See All Offers</strong> <i class="fa fa-angle-right"></i> </a> @@ -98,28 +98,28 @@ <div class="sidebar-nav navbar-collapse"> <ul class="nav" id="side-menu"> <li title="Dashboard"> - <a <?php if($_page=='/') echo 'class="active"'; ?> href="<?=constants::url_internal?>/"><i class="fa fa-dashboard fa-fw"></i> <span class="nav-title">Dashboard</span></a> + <a <?php if($_page=='/') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/"><i class="fa fa-dashboard fa-fw"></i> <span class="nav-title">Dashboard</span></a> </li> <li title="Clients"> - <a <?php if($_page=='/clients') echo 'class="active"'; ?> href="<?=constants::url_internal?>/clients"><i class="fa fa-institution fa-fw"></i> <span class="nav-title">Clients</span></a> + <a <?php if($_page=='/clients') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/clients"><i class="fa fa-institution fa-fw"></i> <span class="nav-title">Clients</span></a> </li> <li title="Contacts"> - <a <?php if($_page=='/contacts') echo 'class="active"'; ?> href="<?=constants::url_internal?>/contacts"><i class="fa fa-user fa-fw"></i> <span class="nav-title">Contacts</span></a> + <a <?php if($_page=='/contacts') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/contacts"><i class="fa fa-user fa-fw"></i> <span class="nav-title">Contacts</span></a> </li> <li title="Offers"> - <a <?php if($_page=='/offers') echo 'class="active"'; ?> href="<?=constants::url_internal?>/offers"><i class="fa fa-briefcase fa-fw"></i> <span class="nav-title">Offers</span></a> + <a <?php if($_page=='/offers') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/offers"><i class="fa fa-briefcase fa-fw"></i> <span class="nav-title">Offers</span></a> </li> <li title="Assignments"> - <a <?php if($_page=='/assignments') echo 'class="active"'; ?> href="<?=constants::url_internal?>/assignments"><i class="fa fa-check-square fa-fw"></i> <span class="nav-title">Assignments</span></a> + <a <?php if($_page=='/assignments') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/assignments"><i class="fa fa-check-square fa-fw"></i> <span class="nav-title">Assignments</span></a> </li> <li title="Discounts"> - <a <?php if($_page=='/discounts') echo 'class="active"'; ?> href="<?=constants::url_internal?>/discounts"><i class="fa fa-percent fa-fw"></i> <span class="nav-title">Discounts</span></a> + <a <?php if($_page=='/discounts') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/discounts"><i class="fa fa-percent fa-fw"></i> <span class="nav-title">Discounts</span></a> </li> <li title="Settings"> - <a <?php if($_page=='/settings') echo 'class="active"'; ?> href="<?=constants::url_internal?>/settings"><i class="fa fa-cog fa-fw"></i> <span class="nav-title">Settings</span></a> + <a <?php if($_page=='/settings') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/settings"><i class="fa fa-cog fa-fw"></i> <span class="nav-title">Settings</span></a> </li> <li title="About"> - <a <?php if($_page=='/about') echo 'class="active"'; ?> href="<?=constants::url_internal?>/about"><i class="fa fa-info-circle fa-fw"></i> <span class="nav-title">About</span></a> + <a <?php if($_page=='/about') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/about"><i class="fa fa-info-circle fa-fw"></i> <span class="nav-title">About</span></a> </li> </ul> |