From 2acc7787e73c966c3fc1794d77dd758a3f56b566 Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Wed, 27 Jul 2016 21:29:57 +0200
Subject: Offer: use Model
---
include/home.php | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
(limited to 'include/home.php')
diff --git a/include/home.php b/include/home.php
index f90d9d3..0ccff58 100644
--- a/include/home.php
+++ b/include/home.php
@@ -152,19 +152,19 @@ require('./header.php');
$offers = BusinessAdmin::getOffers($_pdo, array("`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()"));
$list = array();
foreach ($offers as $offer) {
- $start = BusinessAdmin::formatDate($offer->getStartDate(), false);
- $end = BusinessAdmin::formatDate($offer->getEndDate(), false);
- $since = mktime(0,0,0,date("n"),date("j"),date("Y")) - $offer->getStartDate();
- $total = $offer->getEndDate() - $offer->getStartDate();
+ $start = BusinessAdmin::formatDate($offer->start_date, false);
+ $end = BusinessAdmin::formatDate($offer->end_date, false);
+ $since = mktime(0,0,0,date("n"),date("j"),date("Y")) - $offer->start_date;
+ $total = $offer->end_date - $offer->start_date;
$percentage = ($total == 0) ? 100 : round($since / $total * 100);
// 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->getStartDate();
+ $base = str_pad($percentage, 3, '0', STR_PAD_LEFT) . $offer->start_date;
for ($i = 0; isset($list["$base-$i"]); $i++);
$list["$base-$i"] = array(
'start' => $start,
'end' => $end,
- 'id' => $offer->getId(),
+ 'id' => $offer->id,
'contactClientName' => $offer->getContact()->getClient()->name,
'percentage' => $percentage,
'price_excl' => Constants::invoice_valuta . $offer->calculate(offer::SUBTOTAL),
@@ -207,9 +207,9 @@ require('./header.php');
$offers = BusinessAdmin::getOffers($_pdo, array("`accepted`=1", "`end_date` <= CURDATE()", "`invoice_date` IS NULL OR `invoice_date`='1970-01-01' OR `invoice_date`>CURDATE()"));
foreach ($offers as $offer) {
echo "
";
- echo "{$offer->getId()} | ";
+ echo "{$offer->id} | ";
echo "{$offer->getContact()->getClient()->name} | ";
- echo "".BusinessAdmin::formatDate($offer->getEndDate(), false)." | ";
+ echo "".BusinessAdmin::formatDate($offer->end_date, false)." | ";
echo "
";
}
if (count($offers) == 0) {
@@ -248,9 +248,9 @@ require('./header.php');
} else {
foreach ($offers as $offer) {
echo "";
- echo "{$offer->getId()} | ";
+ echo "{$offer->id} | ";
echo "{$offer->getContact()->getClient()->name} | ";
- echo "".BusinessAdmin::formatDate($offer->getInvoiceDate(), false)." | ";
+ echo "".BusinessAdmin::formatDate($offer->invoice_date, false)." | ";
echo "
";
}
}
@@ -279,7 +279,7 @@ require('./header.php');
$sort_list = array();
foreach ($offers as $offer) {
$temp = array(
- 'id' => $offer->getId(),
+ 'id' => $offer->id,
'contact' => $offer->getContact()->name,
'assignments' => '',
'assignments_header' => ''
@@ -288,16 +288,16 @@ require('./header.php');
$temp['assignments'] .= "{$assignment->title}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)
{$assignment->getHTMLDescription()}
";
$temp['assignments_header'] .= "{$assignment->title}
(".Constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)
";
}
- $list[] = array_merge($temp, array('type' => 'start', 'time' => $offer->getStartDate(), 'description' => 'Offer started'));
- $sort_list[] = $offer->getStartDate() . $offer->getId() . 0;
- $list[] = array_merge($temp, array('type' => 'end', 'time' => $offer->getEndDate(), 'description' => 'Offer ended'));
- $sort_list[] = $offer->getEndDate() . $offer->getId() . 1;
- if ($offer->getInvoiceDate() > 0) {
- $list[] = array_merge($temp, array('type' => 'invoice', 'time' => $offer->getInvoiceDate(), 'description' => 'Invoice sent'));
- $sort_list[] = $offer->getInvoiceDate() . $offer->getId() . 2;
+ $list[] = array_merge($temp, array('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'));
+ $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'));
+ $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'));
- $sort_list[] = $offer->getPaymentReceived() . $offer->getId() . 3;
+ $sort_list[] = $offer->getPaymentReceived() . $offer->id . 3;
}
}
}
--
cgit v1.2.3