aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2016-07-27 21:06:48 +0200
committerCamil Staps2016-07-27 21:06:48 +0200
commit390251ac43ca889a318369342b4663ef928349d8 (patch)
treeb2b0a68dd6fccf6fa52d2c1fc95bdd70811a60b3
parentDiscount: use Model (diff)
Contact: use Model
-rw-r--r--classes/Contact.php340
-rw-r--r--classes/Correspondence.php10
-rw-r--r--include/assignments-overview.php4
-rw-r--r--include/clients-view.php18
-rw-r--r--include/contacts-edit.php15
-rw-r--r--include/contacts-new.php2
-rw-r--r--include/contacts-overview.php26
-rw-r--r--include/contacts.php6
-rw-r--r--include/discounts-overview.php4
-rw-r--r--include/home.php2
-rw-r--r--include/offers-overview.php4
-rw-r--r--include/offers-view.php2
12 files changed, 60 insertions, 373 deletions
diff --git a/classes/Contact.php b/classes/Contact.php
index 6ed2a78..ed2a80d 100644
--- a/classes/Contact.php
+++ b/classes/Contact.php
@@ -24,73 +24,20 @@
/**
* An interface to the contact table in the database
*/
-class Contact {
- /**
- * @var PDO $pdo The PDO class for database communication
- * @var int $id The id of the contact
- * @var int $clientId The id of the client the contact is linked to
- * @var string $name The name of the contact
- * @var string $email The email address of the contact
- * @var string $address The first address line (normally street and house number) of the contact
- * @var string $address_2 The second address line (can be null)
- * @var string $postal_code The postal code of the contact
- * @var string $city The city of the contact
- * @var string $country The country of the contact
- * @var string $language The language of the contact
- */
- protected $pdo, $id, $clientId, $name, $email, $address, $postal_code, $city, $country, $language;
-
- /**
- * Create a new instance
- *
- * @param PDO $pdo The PDO class, to access the database
- * @param int $id The id of the contact to fetch
- *
- * @throws PDOException If something went wrong with the database
- * @throws Exception If the contact could not be found
- */
- public function __construct($pdo, $id) {
- $this->pdo = $pdo;
-
- $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.");
+class Contact extends Model {
+ public
+ $table = 'contact',
+ $fillable_columns = ['clientId', 'name', 'email', 'address', 'address_2', 'postal_code', 'city', 'country', 'language'];
+
+ protected function mutator($key, $value) {
+ switch ($key) {
+ case 'language':
+ if (!in_array($value, Correspondence::LANGUAGES)) {
+ throw new Exception("Language $value not available.");
+ }
+ default:
+ return parent::mutator($key, $value);
}
- $contact = $stmt->fetch(PDO::FETCH_ASSOC);
-
- $this->id = $contact['id'];
- $this->clientId = $contact['clientId'];
- $this->name = $contact['name'];
- $this->email = $contact['email'];
- $this->address = $contact['address'];
- $this->address_2 = $contact['address_2'];
- $this->postal_code = $contact['postal_code'];
- $this->city = $contact['city'];
- $this->country = $contact['country'];
- $this->language = $contact['language'];
- }
-
- //------------------------------------------------------------------------------
- // Getters and setters
- //------------------------------------------------------------------------------
-
- /**
- * Get the ID of the contact
- *
- * @return int The ID
- */
- public function getId() {
- return $this->id;
- }
-
- /**
- * Get the ID of the client that this contact is linked to
- *
- * @return int The ID
- */
- public function getClientId() {
- return $this->clientId;
}
/**
@@ -103,267 +50,6 @@ class Contact {
}
/**
- * Get the name of the contact
- *
- * @return string The name
- */
- public function getName() {
- return $this->name;
- }
-
- /**
- * Set the name of the contact
- *
- * @param string $name The new name for the contact
- *
- * @throws PDOException If something went wrong with the database
- *
- * @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->execute(array($name, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->name = $name;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the email of the contact
- *
- * @return string The email
- */
- public function getEmail() {
- return $this->email;
- }
-
- /**
- * Set the email of the contact
- *
- * @param string $email The new email for the contact
- *
- * @throws PDOException If something went wrong with the database
- *
- * @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->execute(array($email, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->email = $email;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the first address line of the contact
- *
- * @return string The address
- */
- public function getAddress() {
- return $this->address;
- }
-
- /**
- * Set the first address line of the contact
- *
- * @param string $address The new address for the contact
- *
- * @throws PDOException If something went wrong with the database
- *
- * @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->execute(array($address, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->address = $address;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the second address line of the contact
- *
- * @return string The address
- */
- public function getAddress_2() {
- return $this->address_2;
- }
-
- /**
- * Set the second address line of the contact
- *
- * @param string $address_2 The new address for the contact
- *
- * @throws PDOException If something went wrong with the database
- *
- * @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->execute(array($address_2, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->address_2 = $address_2;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the postal_code of the contact
- *
- * @return string The postal_code
- */
- public function getPostalCode() {
- return $this->postal_code;
- }
-
- /**
- * Set the postal code of the contact
- *
- * @param $postal_code string The new postal code for the contact
- *
- * @throws PDOException If something went wrong with the database
- *
- * @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->execute(array($postal_code, $this->id));
- if ($stmt->rowCount() == 1) {
- return true;
- $this->postal_code = $postal_code;
- } else {
- return false;
- }
- }
-
- /**
- * Get the city of the contact
- *
- * @return string The city
- */
- public function getCity() {
- return $this->city;
- }
-
- /**
- * Set the city of the contact
- *
- * @param string $city The new city for the contact
- *
- * @throws PDOException If something went wrong with the database
- *
- * @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->execute(array($city, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->city = $city;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the country of the contact
- *
- * @return string The country
- */
- public function getCountry() {
- return $this->country;
- }
-
- /**
- * Set the country of the contact
- *
- * @param string $country The new country for the contact
- *
- * @throws PDOException If something went wrong with the database
- *
- * @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->execute(array($country, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->country = $country;
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Get the language of the contact
- *
- * @return string The language
- */
- public function getLanguage() {
- return $this->language;
- }
-
- /**
- * Set the language of the contact
- *
- * @see correspondence::LANGUAGES The available languages
- *
- * @param string $language The new language for the contact
- *
- * @throws PDOException If something went wrong with the database
- * @throws Exception If the language is unknown
- *
- * @return bool True on succes, false on failure
- */
- public function setLanguage($language) {
- 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->execute(array($language, $this->id));
- if ($stmt->rowCount() == 1) {
- $this->language = $language;
- return true;
- } else {
- return false;
- }
- }
-
- //------------------------------------------------------------------------------
- // Other functions
- //------------------------------------------------------------------------------
-
- /**
- * Remove this contact from the database
- *
- * If this doesn't succeed (i.e. false is returned), that means the contact was removed manually or by another instance of this class
- *
- * @throws PDOException If something went wrong with the database
- *
- * @return bool True on success, false on failure
- */
- public function delete() {
- $stmt = $this->pdo->prepare("DELETE FROM `".Constants::db_prefix."contact` WHERE `id`=?");
- $stmt->execute(array($this->id));
- if ($stmt->rowCount() != 1) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
* Make a new offer for this contact
*
* @throws PDOException If something went wrong with the database
diff --git a/classes/Correspondence.php b/classes/Correspondence.php
index 4c7a23b..09873c3 100644
--- a/classes/Correspondence.php
+++ b/classes/Correspondence.php
@@ -183,7 +183,7 @@ class Correspondence extends FPDF {
function SetContact($contact) {
$this->contact = $contact;
- $this->language = $contact->getLanguage();
+ $this->language = $contact->language;
}
/**
@@ -262,16 +262,16 @@ class Correspondence extends FPDF {
$this->SetFont('','',11);
$this->SetXY(30,56.5);
- $this->Cell(90,5.5,utf8_decode($this->contact->getName()));
+ $this->Cell(90,5.5,utf8_decode($this->contact->name));
$this->Ln();
$this->SetXY(30,61.5);
- $this->Cell(90,5.5,utf8_decode($this->contact->getAddress()));
+ $this->Cell(90,5.5,utf8_decode($this->contact->address));
$this->Ln();
$this->SetXY(30,66.5);
- $this->Cell(90,5.5,utf8_decode($this->contact->getPostalCode().' '.$this->contact->getCity()));
+ $this->Cell(90,5.5,utf8_decode($this->contact->postal_code.' '.$this->contact->city));
$this->Ln();
$this->SetXY(30,71.5);
- $this->Cell(90,5.5,utf8_decode($this->contact->getCountry()));
+ $this->Cell(90,5.5,utf8_decode($this->contact->country));
$this->Ln();
}
diff --git a/include/assignments-overview.php b/include/assignments-overview.php
index 9fa226f..e10323b 100644
--- a/include/assignments-overview.php
+++ b/include/assignments-overview.php
@@ -47,7 +47,7 @@ require_once('./login.php');
<td class='col-min-width'>{$assignment->id}</td>
<td class='col-min-width'>
<a href='".Constants::url_internal."/offers?id={$assignment->getOffer()->getId()}'>#{$assignment->getOffer()->getId()}</a> to
- <a href='".Constants::url_internal."/contacts?id={$assignment->getOffer()->getContact()->getId()}'>{$assignment->getOffer()->getContact()->getName()}</a>
+ <a href='".Constants::url_internal."/contacts?id={$assignment->getOffer()->getContact()->id}'>{$assignment->getOffer()->getContact()->name}</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->id}-title' data-type='text' data-pk='{$assignment->id}' data-url='".Constants::url_external."assignments/edit'>{$assignment->title}</a></b><br/>
@@ -86,7 +86,7 @@ require_once('./login.php');
<select name="offerId" class="form-control">
<?php
foreach (BusinessAdmin::getOffers($_pdo) as $offer) {
- echo "<option value='{$offer->getId()}'>#{$offer->getId()} to {$offer->getContact()->getName()} ({$offer->getContact()->getClient()->name})</option>";
+ echo "<option value='{$offer->getId()}'>#{$offer->getId()} to {$offer->getContact()->name} ({$offer->getContact()->getClient()->name})</option>";
}
?>
</select>
diff --git a/include/clients-view.php b/include/clients-view.php
index 2472a80..6648026 100644
--- a/include/clients-view.php
+++ b/include/clients-view.php
@@ -40,18 +40,18 @@ $_client = new Client($_pdo, $_id);
$contacts = $_client->getContacts();
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'>{$contact->id}</td>
+ <td class='col-min-width'><a href='#' class='editable' id='editable-contact-{$contact->id}-name' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->name}</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->id}-address' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->address}</a><br/>
+ <a href='#' class='editable' id='editable-contact-{$contact->id}-postal_code' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->postal_code}</a>
+ <a href='#' class='editable' id='editable-contact-{$contact->id}-city' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->city}</a><br/>
+ <a href='#' class='editable' id='editable-contact-{$contact->id}-country' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->country}</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->id}-language' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->language}</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->id}' class='btn btn-primary btn-circle fa fa-arrow-right'></a>
+ <a title='Delete' href='".Constants::url_internal."/contacts?delete={$contact->id}' class='btn btn-danger btn-circle fa fa-times'></a>
</td>
</tr>";
}
diff --git a/include/contacts-edit.php b/include/contacts-edit.php
index ead27d9..a0ffdee 100644
--- a/include/contacts-edit.php
+++ b/include/contacts-edit.php
@@ -21,6 +21,7 @@ require_once('./conf.php');
require_once('./login-ajax.php');
$response = new Response();
+$response->success = true;
try {
$contact = new Contact($_pdo, $_REQUEST['pk']);
@@ -29,25 +30,25 @@ try {
$what_to_edit = $name[count($name) - 1];
switch ($what_to_edit) {
case 'name':
- $response->success = $contact->setName($_REQUEST['value']);
+ $contact->name = $_REQUEST['value'];
break;
case 'email':
- $response->success = $contact->setEmail($_REQUEST['value']);
+ $contact->email = $_REQUEST['value'];
break;
case 'address':
- $response->success = $contact->setAddress($_REQUEST['value']);
+ $contact->address = $_REQUEST['value'];
break;
case 'postal_code':
- $response->success = $contact->setPostalCode($_REQUEST['value']);
+ $contact->postal_code = $_REQUEST['value'];
break;
case 'city':
- $response->success = $contact->setCity($_REQUEST['value']);
+ $contact->city = $_REQUEST['value'];
break;
case 'country':
- $response->success = $contact->setCountry($_REQUEST['value']);
+ $contact->country = $_REQUEST['value'];
break;
case 'language':
- $response->success = $contact->setLanguage($_REQUEST['value']);
+ $contact->language = $_REQUEST['value'];
break;
default:
$response->http_response_code(404);
diff --git a/include/contacts-new.php b/include/contacts-new.php
index c75298c..b671be4 100644
--- a/include/contacts-new.php
+++ b/include/contacts-new.php
@@ -35,7 +35,7 @@ try {
$_REQUEST['country']
);
$response->success = true;
- $response->message = "Contact {$contact->getName()} has been succesfully created. <a class='alert-link' href='javascript:location.reload(true);'>Refresh the page</a>.";
+ $response->message = "Contact {$contact->name} has been succesfully created. <a class='alert-link' href='javascript:location.reload(true);'>Refresh the page</a>.";
} catch (PDOException $e) {
$response->http_response_code(500);
$response->success = false;
diff --git a/include/contacts-overview.php b/include/contacts-overview.php
index 4f2e6cf..fcd788e 100644
--- a/include/contacts-overview.php
+++ b/include/contacts-overview.php
@@ -39,28 +39,28 @@ require_once('./login.php');
$contacts = BusinessAdmin::getContacts($_pdo);
foreach ($contacts as $contact) {
echo "<tr class='mix'
- data-mixer-order-id='{$contact->getId()}'
- data-mixer-order-name='{$contact->getName()}'>
- <td class='col-min-width'>{$contact->getId()}</td>
+ data-mixer-order-id='{$contact->id}'
+ data-mixer-order-name='{$contact->name}'>
+ <td class='col-min-width'>{$contact->id}</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->id}-name' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->name}</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->id}-email' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->email}</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->id}-address' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->address}</a><br/>
+ " . ($contact->address_2 != '' ? "<a href='#' class='editable' id='editable-contact-{$contact->id}-address_2' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->address_2}</a><br/>" : "") . "
+ <a href='#' class='editable' id='editable-contact-{$contact->id}-postal_code' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->postal_code}</a>
+ <a href='#' class='editable' id='editable-contact-{$contact->id}-city' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->city}</a><br/>
+ <a href='#' class='editable' id='editable-contact-{$contact->id}-country' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->country}</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->id}-language' data-type='text' data-pk='{$contact->id}' data-url='".Constants::url_external."contacts/edit'>{$contact->language}</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>
- <a title='Delete' href='?delete={$contact->getId()}' class='btn btn-danger btn-circle fa fa-times'></a>
+ <a title='View' href='?id={$contact->id}' class='btn btn-primary btn-circle fa fa-arrow-right'></a>
+ <a title='Delete' href='?delete={$contact->id}' class='btn btn-danger btn-circle fa fa-times'></a>
</td>
</tr>";
}
diff --git a/include/contacts.php b/include/contacts.php
index 1231e24..28656c9 100644
--- a/include/contacts.php
+++ b/include/contacts.php
@@ -46,7 +46,7 @@ require('./header.php');
$id = (int) $_GET['id'];
try {
$contact = new Contact($_pdo, $id);
- $header = "<a href='".Constants::url_external."contacts'>Contacts</a> / {$contact->getName()}";
+ $header = "<a href='".Constants::url_external."contacts'>Contacts</a> / {$contact->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 contact with id $id</i> could not be found.</div>";
@@ -66,9 +66,9 @@ require('./header.php');
try {
$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>";
+ 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->name}</i> has been removed.</div>";
} else {
- echo "<div class='alert alert-warning alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The contact with name <i>{$contact->getName()}</i> could not be removed. Perhaps it's already removed?</div>";
+ echo "<div class='alert alert-warning alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The contact with name <i>{$contact->name}</i> could not be removed. Perhaps it's already removed?</div>";
}
} catch (PDOException $e) {
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close fa fa-times' data-dismiss='alert' aria-hidden='true'></button>The contact could not be removed due to a PDO error.</div>";
diff --git a/include/discounts-overview.php b/include/discounts-overview.php
index 0b0534d..5253fd2 100644
--- a/include/discounts-overview.php
+++ b/include/discounts-overview.php
@@ -45,7 +45,7 @@ require_once('./login.php');
<td class='col-min-width'>{$discount->id}</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."/contacts?id={$discount->getOffer()->getContact()->id}'>{$discount->getOffer()->getContact()->name}</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->id}-title' data-type='text' data-pk='{$discount->id}' data-url='".Constants::url_external."discounts/edit'>{$discount->title}</a></b><br/>
@@ -83,7 +83,7 @@ require_once('./login.php');
<select name="offerId" class="form-control">
<?php
foreach (BusinessAdmin::getOffers($_pdo) as $offer) {
- echo "<option value='{$offer->getId()}'>#{$offer->getId()} to {$offer->getContact()->getName()} ({$offer->getContact()->getClient()->name})</option>";
+ echo "<option value='{$offer->getId()}'>#{$offer->getId()} to {$offer->getContact()->name} ({$offer->getContact()->getClient()->name})</option>";
}
?>
</select>
diff --git a/include/home.php b/include/home.php
index 3b461bc..f90d9d3 100644
--- a/include/home.php
+++ b/include/home.php
@@ -280,7 +280,7 @@ require('./header.php');
foreach ($offers as $offer) {
$temp = array(
'id' => $offer->getId(),
- 'contact' => $offer->getContact()->getName(),
+ 'contact' => $offer->getContact()->name,
'assignments' => '',
'assignments_header' => ''
);
diff --git a/include/offers-overview.php b/include/offers-overview.php
index 2c5b483..b172629 100644
--- a/include/offers-overview.php
+++ b/include/offers-overview.php
@@ -43,7 +43,7 @@ require_once('./login.php');
echo "<tr>
<td class='col-min-width'>{$offer->getId()}</td>
- <td class='col-min-width'><span title='{$offer->getContact()->getClient()->name}'>{$offer->getContact()->getName()}</span></td>
+ <td class='col-min-width'><span title='{$offer->getContact()->getClient()->name}'>{$offer->getContact()->name}</span></td>
<td class='col-max-width'>";
foreach ($offer->getAssignments() as $assignment) {
echo "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getHTMLDescription()}</p>";
@@ -120,7 +120,7 @@ require_once('./login.php');
<select name="contactId" class="form-control">
<?php
foreach (BusinessAdmin::getContacts($_pdo) as $contact) {
- echo "<option value='{$contact->getId()}'>{$contact->getName()} ({$contact->getClient()->name})</option>";
+ echo "<option value='{$contact->id}'>{$contact->name} ({$contact->getClient()->name})</option>";
}
?>
</select>
diff --git a/include/offers-view.php b/include/offers-view.php
index 9a2978f..aba4c26 100644
--- a/include/offers-view.php
+++ b/include/offers-view.php
@@ -35,7 +35,7 @@ $_offer = new Offer($_pdo, $_id);
$temp = array(
'id' => $_offer->getId(),
- 'contact' => $_offer->getContact()->getName(),
+ 'contact' => $_offer->getContact()->name,
'assignments' => '',
'assignments_header' => ''
);