diff options
author | Camil Staps | 2016-08-01 14:11:06 +0200 |
---|---|---|
committer | Camil Staps | 2016-08-01 14:11:06 +0200 |
commit | 46198a89ccc8e6750a37e1b9127f57238242fadf (patch) | |
tree | de6c0bc2f55b759a0db6471fc0b820ee5433e648 | |
parent | Use Model::search in child::get* methods (diff) |
Array shorthands
-rw-r--r-- | classes/Client.php | 4 | ||||
-rw-r--r-- | classes/Contact.php | 2 | ||||
-rw-r--r-- | classes/Correspondence.php | 2 | ||||
-rw-r--r-- | classes/Offer.php | 24 | ||||
-rw-r--r-- | classes/Response.php | 2 | ||||
-rw-r--r-- | include/home.php | 22 | ||||
-rw-r--r-- | include/offers-view.php | 16 | ||||
-rw-r--r-- | index.php | 4 | ||||
-rw-r--r-- | nav.php | 6 |
9 files changed, 41 insertions, 41 deletions
diff --git a/classes/Client.php b/classes/Client.php index 0f0a2f8..1f04f21 100644 --- a/classes/Client.php +++ b/classes/Client.php @@ -79,7 +79,7 @@ class Client extends Model { */ 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->execute(array( + $stmt->execute([ $this->id, $name, $email, @@ -88,7 +88,7 @@ class Client extends Model { $postal_code, $city, $country - )); + ]); if ($stmt->rowCount() == 1) { return new Contact($this->pdo, $this->pdo->lastInsertId()); } else { diff --git a/classes/Contact.php b/classes/Contact.php index 7689ef7..bf816ea 100644 --- a/classes/Contact.php +++ b/classes/Contact.php @@ -65,7 +65,7 @@ class Contact extends Model { */ public function createOffer() { $stmt = $this->pdo->prepare("INSERT INTO `".Constants::db_prefix."offer` (`contactId`) VALUES (?)"); - $stmt->execute(array($this->id)); + $stmt->execute([$this->id]); if ($stmt->rowCount() == 1) { return new Offer($this->pdo, $this->pdo->lastInsertId()); } else { diff --git a/classes/Correspondence.php b/classes/Correspondence.php index 1c965df..7e5c9ae 100644 --- a/classes/Correspondence.php +++ b/classes/Correspondence.php @@ -241,7 +241,7 @@ class Correspondence extends FPDF { * @param string $lang The language, two letter code ('en', 'nl', ...) */ function SetLangauge($lang) { - $supported = array('nl', 'en'); + $supported = ['nl', 'en']; if (!in_array($lang, $supported)) { throw new Exception("Language not supported"); } else { diff --git a/classes/Offer.php b/classes/Offer.php index 8da2095..1422721 100644 --- a/classes/Offer.php +++ b/classes/Offer.php @@ -282,14 +282,14 @@ class Offer extends Model{ */ 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->execute(array( + $stmt->execute([ $this->id, $title, $description, $hours, $price_per_hour, $vat - )); + ]); if ($stmt->rowCount() == 1) { return new Assignment($this->pdo, $this->pdo->lastInsertId()); } else { @@ -313,13 +313,13 @@ class Offer extends Model{ */ 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->execute(array( + $stmt->execute([ $this->id, $title, $description, $value, $vat - )); + ]); if ($stmt->rowCount() == 1) { return new Discount($this->pdo, $this->pdo->lastInsertId()); } else { @@ -372,24 +372,24 @@ class Offer extends Model{ $this->invoice_fileId = $file->id; } else { - $invoice_nr = str_replace(array('invoice-','.pdf'), array('',''), $file->filename); + $invoice_nr = str_replace(['invoice-','.pdf'], ['', ''], $file->filename); } - $list = array(); + $list = []; foreach ($this->getAssignments() as $assignment) - $list[] = array( + $list[] = [ $assignment->title, $assignment->price_per_hour * $assignment->hours, $assignment->VAT_percentage . "%", $assignment->price_per_hour * $assignment->hours * (1 + $assignment->VAT_percentage / 100) - ); + ]; foreach ($this->getDiscounts() as $discount) - $list[] = array( + $list[] = [ $discount->title, $discount->calculate(Calculatable::SUBTOTAL), $discount->VAT_percentage . "%", $discount->calculate(Calculatable::TOTAL) - ); + ]; $pdf = new Correspondence(); $pdf->SetContact($this->getContact()); @@ -404,9 +404,9 @@ class Offer extends Model{ $pdf->SetTextColor(0); $pdf->Ln(); - $width = array(90,25,20,25); + $width = [90, 25, 20, 25]; $subtotal = 0; - $btw = array(); + $btw = []; $total = 0; // Header diff --git a/classes/Response.php b/classes/Response.php index f37b6e9..ffb3e20 100644 --- a/classes/Response.php +++ b/classes/Response.php @@ -34,7 +34,7 @@ class Response { * Create a new instance */ public function __construct() { - $this->response = array(); + $this->response = []; $this->http_response_code = 200; } diff --git a/include/home.php b/include/home.php index b42ec8e..05846cf 100644 --- a/include/home.php +++ b/include/home.php @@ -155,7 +155,7 @@ require('./header.php'); <div class="panel-body"> <?php $offers = Offer::search($_pdo, ["`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()"]); - $list = array(); + $list = []; foreach ($offers as $offer) { $start = BusinessAdmin::formatDate($offer->start_date, false); $end = BusinessAdmin::formatDate($offer->end_date, false); @@ -166,7 +166,7 @@ require('./header.php'); // We want to sort on percentage (DESC) and secondly end date (ASC) so start date (DESC) $base = str_pad($percentage, 3, '0', STR_PAD_LEFT) . $offer->start_date; for ($i = 0; isset($list["$base-$i"]); $i++); - $list["$base-$i"] = array( + $list["$base-$i"] = [ 'start' => $start, 'end' => $end, 'id' => $offer->id, @@ -174,7 +174,7 @@ require('./header.php'); 'percentage' => $percentage, 'price_excl' => Constants::invoice_valuta . $offer->calculate(Calculatable::SUBTOTAL), 'price_incl' => Constants::invoice_valuta . $offer->calculate(Calculatable::TOTAL) - ); + ]; } krsort($list, SORT_STRING); foreach ($list as $item) { @@ -301,28 +301,28 @@ require('./header.php'); <ul class="timeline"> <?php $offers = Offer::search($_pdo, ['`accepted`=1']); - $list = array(); - $sort_list = array(); + $list = []; + $sort_list = []; foreach ($offers as $offer) { - $temp = array( + $temp = [ 'id' => $offer->id, 'contact' => $offer->getContact()->name, 'assignments' => '', 'assignments_header' => '' - ); + ]; foreach ($offer->getAssignments() as $assignment) { $temp['assignments'] .= "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(Calculatable::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(Calculatable::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getHTMLDescription()}</p>"; $temp['assignments_header'] .= "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(Calculatable::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(Calculatable::TOTAL)} incl. VAT)</span><br/>"; } - $list[] = array_merge($temp, array('type' => 'start', 'time' => $offer->start_date, 'description' => 'Offer started')); + $list[] = array_merge($temp, ['type' => 'start', 'time' => $offer->start_date, 'description' => 'Offer started']); $sort_list[] = $offer->start_date . $offer->id . 0; - $list[] = array_merge($temp, array('type' => 'end', 'time' => $offer->end_date, 'description' => 'Offer ended')); + $list[] = array_merge($temp, ['type' => 'end', 'time' => $offer->end_date, 'description' => 'Offer ended']); $sort_list[] = $offer->end_date . $offer->id . 1; if ($offer->invoice_date > 0) { - $list[] = array_merge($temp, array('type' => 'invoice', 'time' => $offer->invoice_date, 'description' => 'Invoice sent')); + $list[] = array_merge($temp, ['type' => 'invoice', 'time' => $offer->invoice_date, 'description' => 'Invoice sent']); $sort_list[] = $offer->invoice_date . $offer->id . 2; if ($offer->getPaymentReceived() > 0) { - $list[] = array_merge($temp, array('type' => 'payment_received', 'time' => $offer->getPaymentReceived(), 'description' => 'Payment received')); + $list[] = array_merge($temp, ['type' => 'payment_received', 'time' => $offer->getPaymentReceived(), 'description' => 'Payment received']); $sort_list[] = $offer->getPaymentReceived() . $offer->id . 3; } } diff --git a/include/offers-view.php b/include/offers-view.php index cce5a66..09eff5b 100644 --- a/include/offers-view.php +++ b/include/offers-view.php @@ -159,28 +159,28 @@ $_offer = new Offer($_pdo, $_id); <div class="panel-body"> <ul class="timeline"> <?php - $list = array(); - $sort_list = array(); + $list = []; + $sort_list = []; - $temp = array( + $temp = [ 'id' => $_offer->id, 'contact' => $_offer->getContact()->name, 'assignments' => '', 'assignments_header' => '' - ); + ]; foreach ($_offer->getAssignments() as $assignment) { $temp['assignments'] .= "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(Calculatable::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(Calculatable::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getHTMLDescription()}</p>"; $temp['assignments_header'] .= "<b>{$assignment->title}</b><br/><span class='smaller'>(".Constants::invoice_valuta."{$assignment->calculate(Calculatable::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(Calculatable::TOTAL)} incl. VAT)</span><br/>"; } - $list[] = array_merge($temp, array('type' => 'start', 'time' => $_offer->start_date, 'description' => 'Offer started')); + $list[] = array_merge($temp, ['type' => 'start', 'time' => $_offer->start_date, 'description' => 'Offer started']); $sort_list[] = $_offer->start_date . $_offer->id . 0; - $list[] = array_merge($temp, array('type' => 'end', 'time' => $_offer->end_date, 'description' => 'Offer ended')); + $list[] = array_merge($temp, ['type' => 'end', 'time' => $_offer->end_date, 'description' => 'Offer ended']); $sort_list[] = $_offer->end_date . $_offer->id . 1; if ($_offer->invoice_date > 0) { - $list[] = array_merge($temp, array('type' => 'invoice', 'time' => $_offer->invoice_date, 'description' => 'Invoice sent')); + $list[] = array_merge($temp, ['type' => 'invoice', 'time' => $_offer->invoice_date, 'description' => 'Invoice sent']); $sort_list[] = $_offer->invoice_date . $_offer->id . 2; if ($_offer->getPaymentReceived() > 0) { - $list[] = array_merge($temp, array('type' => 'payment_received', 'time' => $_offer->getPaymentReceived(), 'description' => 'Payment received')); + $list[] = array_merge($temp, ['type' => 'payment_received', 'time' => $_offer->getPaymentReceived(), 'description' => 'Payment received']); $sort_list[] = $_offer->getPaymentReceived() . $_offer->id . 3; } } @@ -35,7 +35,7 @@ $_request = str_replace(Constants::url_internal, '', $_request); // This is the REQUEST_URI switch // The default shows a 404 page -$pages = array( +$pages = [ '/' => './include/home.php', '/clients' => './include/clients.php', '/clients/new' => './include/clients-new.php', @@ -59,7 +59,7 @@ $pages = array( '/ajax/email/offer' => './include/ajax-email-offer.php', '/pay' => './include/pay.php', '/file/get' => './include/file-get.php' -); +]; $_page = null; foreach ($pages as $uri => $path) { @@ -46,7 +46,7 @@ <ul class="dropdown-menu dropdown-tasks"> <?php $offers = Offer::search($_pdo, ["`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()"]); - $list = array(); + $list = []; foreach ($offers as $offer) { $start = BusinessAdmin::formatDate($offer->start_date, false); $end = BusinessAdmin::formatDate($offer->end_date, false); @@ -55,14 +55,14 @@ $percentage = ($total == 0) ? 100 : round($since / $total * 100); // We want to sort on percentage (DESC) and secondly end date (ASC) so start date (DESC) - $list[str_pad($percentage, 3, '0', STR_PAD_LEFT) . $offer->start_date] = array( + $list[str_pad($percentage, 3, '0', STR_PAD_LEFT) . $offer->start_date] = [ 'start' => $start, 'end' => $end, 'id' => $offer->id, 'contactClientName' => $offer->getContact()->getClient()->name, 'percentage' => $percentage, 'price' => Constants::invoice_valuta . $offer->calculate(Calculatable::SUBTOTAL) - ); + ]; } krsort($list, SORT_STRING); foreach ($list as $item) { |