aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2016-08-01 08:28:57 +0200
committerCamil Staps2016-08-01 08:28:57 +0200
commitddcdb11f4d3a97c353994990e0c6418a557e50e8 (patch)
tree518b502bb5959a32ce9adc3950b9693001a67c39
parentEasier accessor/mutator in Model; refreshing braintree statuses (diff)
Unfinished braintree status means open invoice; update frontend
-rw-r--r--include/assignments-overview.php2
-rw-r--r--include/clients-overview.php2
-rw-r--r--include/clients-view.php2
-rw-r--r--include/contacts-overview.php2
-rw-r--r--include/discounts-overview.php2
-rw-r--r--include/home.php56
-rw-r--r--include/offers-overview.php2
-rw-r--r--include/offers-view.php6
-rw-r--r--include/offers.php3
9 files changed, 52 insertions, 25 deletions
diff --git a/include/assignments-overview.php b/include/assignments-overview.php
index 0415cb9..a558062 100644
--- a/include/assignments-overview.php
+++ b/include/assignments-overview.php
@@ -65,7 +65,7 @@ require_once('./login.php');
</tr>";
}
if (count($assignments) == 0) {
- echo "<tr><td colspan='6'>There are no assignments in the database. Why not start with creating one, below?</td></tr>";
+ echo "<tr><td colspan='6'>There are no assignments in the database.</td></tr>";
}
?>
</tbody>
diff --git a/include/clients-overview.php b/include/clients-overview.php
index cdced81..e714304 100644
--- a/include/clients-overview.php
+++ b/include/clients-overview.php
@@ -52,7 +52,7 @@ require_once('./login.php');
</tr>";
}
if (count($clients) == 0) {
- echo "<tr><td colspan='3'>There are no clients in the database. Why not start with creating one, on the right?</td></tr>";
+ echo "<tr><td colspan='3'>There are no clients in the database.</td></tr>";
}
?>
</tbody>
diff --git a/include/clients-view.php b/include/clients-view.php
index 6648026..4f27046 100644
--- a/include/clients-view.php
+++ b/include/clients-view.php
@@ -56,7 +56,7 @@ $_client = new Client($_pdo, $_id);
</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.</td></tr>";
}
?>
</tbody>
diff --git a/include/contacts-overview.php b/include/contacts-overview.php
index fcd788e..5f08bf2 100644
--- a/include/contacts-overview.php
+++ b/include/contacts-overview.php
@@ -65,7 +65,7 @@ require_once('./login.php');
</tr>";
}
if (count($contacts) == 0) {
- echo "<tr><td colspan='5'>There are no contacts in the database. Why not start with creating one, on the right?</td></tr>";
+ echo "<tr><td colspan='5'>There are no contacts in the database.</td></tr>";
}
?>
</tbody>
diff --git a/include/discounts-overview.php b/include/discounts-overview.php
index b361ac3..34f5016 100644
--- a/include/discounts-overview.php
+++ b/include/discounts-overview.php
@@ -62,7 +62,7 @@ require_once('./login.php');
</tr>";
}
if (count($discounts) == 0) {
- echo "<tr><td colspan='6'>There are no discounts in the database. Why not start with creating one, below?</td></tr>";
+ echo "<tr><td colspan='6'>There are no discounts in the database.</td></tr>";
}
?>
</tbody>
diff --git a/include/home.php b/include/home.php
index 43cfeb1..9fac972 100644
--- a/include/home.php
+++ b/include/home.php
@@ -112,10 +112,15 @@ require('./header.php');
</div>
<div class="col-lg-3 col-md-3 col-sm-6">
<?php
- $count = count(BusinessAdmin::getOfferIds($_pdo, array(
+ $count = count(BusinessAdmin::getOffers($_pdo, [
"`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`)"]));
+ foreach (BusinessAdmin::getOffers($_pdo, ['EXISTS (SELECT * FROM `'.Constants::db_prefix.'payment` WHERE `offerId`=`'.Constants::db_prefix.'offer`.`id` AND `braintree_id` IS NOT NULL)']) as $offer) {
+ if (!$offer->getPayment()->isBraintreeFinished()) {
+ $count++;
+ }
+ }
?>
<div class="panel panel-<?=($count==0 ? 'primary' : 'yellow')?>">
<div class="panel-heading">
@@ -173,7 +178,7 @@ require('./header.php');
}
krsort($list, SORT_STRING);
foreach ($list as $item) {
- echo "<p>#{$item['id']} to {$item['contactClientName']} ({$item['start']} - {$item['end']}; {$item['price_excl']} excl. VAT, {$item['price_incl']} incl. VAT)<span class='pull-right text-muted'>{$item['percentage']}% complete</span></p>
+ echo "<p>#<a href='offers?id={$item['id']}'>{$item['id']}</a> to {$item['contactClientName']} ({$item['start']} - {$item['end']}; {$item['price_excl']} excl. VAT, {$item['price_incl']} incl. VAT)<span class='pull-right text-muted'>{$item['percentage']}% complete</span></p>
<div class='progress progress-striped active' style='clear:both;'>
<div class='progress-bar progress-bar-".($item['percentage'] < 60 ? 'info' : ($item['percentage'] < 80 ? 'warning' : 'danger'))."' style='width:{$item['percentage']}%;' aria-valuemax='100' aria-valuemin='0' aria-valuenow='{$item['percentage']}' role='progressbar'></div>
</div>";
@@ -206,11 +211,11 @@ require('./header.php');
<?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 "<tr>";
- echo "<td>{$offer->id}</td>";
- echo "<td>{$offer->getContact()->getClient()->name}</td>";
- echo "<td>".BusinessAdmin::formatDate($offer->end_date, false)."</td>";
- echo "</tr>";
+ echo "<tr>
+ <td><a href='offers?id={$offer->id}'>{$offer->id}</a></td>
+ <td>{$offer->getContact()->getClient()->name}</td>
+ <td>".BusinessAdmin::formatDate($offer->end_date, false)."</td>
+ </tr>";
}
if (count($offers) == 0) {
echo "<tr><td colspan='3'>There are no offers that need an invoice.</td></tr>";
@@ -235,6 +240,7 @@ require('./header.php');
<th>#</th>
<th>Contact</th>
<th>Invoice sent</th>
+ <th>Braintree status</th>
</tr>
</thead>
<tbody>
@@ -243,15 +249,35 @@ require('./header.php');
"`invoice_date` > '1970-01-01'",
"`invoice_date`<=CURDATE()",
"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>";
+ $open_offers = BusinessAdmin::getOffers($_pdo,
+ ['EXISTS (SELECT * FROM `'.Constants::db_prefix.'payment` WHERE `offerId`=`'.Constants::db_prefix.'offer`.`id` AND `braintree_id` IS NOT NULL)']);
+ $count = count($offers);
+ foreach ($open_offers as $offer) {
+ if (!$offer->getPayment()->isBraintreeFinished()) {
+ $count++;
+ }
+ }
+ if ($count == 0) {
+ echo "<tr><td colspan='4'>There are no currently open invoices.</td></tr>";
} else {
foreach ($offers as $offer) {
- echo "<tr>";
- echo "<td>{$offer->id}</td>";
- echo "<td>{$offer->getContact()->getClient()->name}</td>";
- echo "<td>".BusinessAdmin::formatDate($offer->invoice_date, false)."</td>";
- echo "</tr>";
+ echo "<tr>
+ <td><a href='offers?id={$offer->id}'>{$offer->id}</a></td>
+ <td>{$offer->getContact()->getClient()->name}</td>
+ <td>".BusinessAdmin::formatDate($offer->invoice_date, false)."</td>
+ <td></td>
+ </tr>";
+ }
+ foreach ($open_offers as $offer) {
+ if ($offer->getPayment()->isBraintreeFinished()) {
+ continue;
+ }
+ echo "<tr>
+ <td><a href='offers?id={$offer->id}'>{$offer->id}</a></td>
+ <td>{$offer->getContact()->getClient()->name}</td>
+ <td>".BusinessAdmin::formatDate($offer->invoice_date, false)."</td>
+ <td>{$offer->getPayment()->braintree_status}</td>
+ </tr>";
}
}
?>
diff --git a/include/offers-overview.php b/include/offers-overview.php
index 6d9bbc1..29b52b3 100644
--- a/include/offers-overview.php
+++ b/include/offers-overview.php
@@ -103,7 +103,7 @@ require_once('./login.php');
</tr>";
}
if (count($offers) == 0) {
- echo "<tr><td colspan='6'>There are no offers in the database. Why not start with creating one, below?</td></tr>";
+ echo "<tr><td colspan='6'>There are no offers in the database.</td></tr>";
}
?>
</tbody>
diff --git a/include/offers-view.php b/include/offers-view.php
index 1455e43..323fc31 100644
--- a/include/offers-view.php
+++ b/include/offers-view.php
@@ -57,7 +57,7 @@ $_offer = new Offer($_pdo, $_id);
</tr>";
}
if (count($assignments) == 0) {
- echo "<tr><td colspan='5'>There are no assignments in the database. Why not start with creating one, below?</td></tr>";
+ echo "<tr><td colspan='5'>There are no assignments in the database.</td></tr>";
}
?>
</tbody>
@@ -99,7 +99,7 @@ $_offer = new Offer($_pdo, $_id);
</tr>";
}
if (count($discounts) == 0) {
- echo "<tr><td colspan='4'>There are no discounts in the database. Why not start with creating one, below?</td></tr>";
+ echo "<tr><td colspan='4'>There are no discounts in the database.</td></tr>";
}
?>
</tbody>
@@ -135,7 +135,7 @@ $_offer = new Offer($_pdo, $_id);
</tr>";
}
if (count($payments) == 0) {
- echo "<tr><td colspan='4'>There are no payments in the database. Why not start with creating one, below?</td></tr>";
+ echo "<tr><td colspan='4'>There are no payments in the database.</td></tr>";
}
?>
</tbody>
diff --git a/include/offers.php b/include/offers.php
index 165d88f..22bd332 100644
--- a/include/offers.php
+++ b/include/offers.php
@@ -127,6 +127,7 @@ require('./header.php');
//------------------------------------------------------------------------------
// The header of the page
//------------------------------------------------------------------------------
+
$header = 'Offers';
// Whether or not to show an individual offer in the end (false if not, or the id if yes)
$show_individual = false;
@@ -136,7 +137,7 @@ require('./header.php');
$id = (int) $_GET['id'];
try {
$offer = new Offer($_pdo, $id);
- $header = "<a href='".Constants::url_external."offers'>Offers</a> / #{$offer->id}";
+ $header = "<a href='".Constants::url_external."offers'>Offers</a> / #<a href='".Constants::url_external."offers?id={$offer->id}'>{$offer->id}</a>";
$show_individual = $id;
$accepted = $offer->accepted ?
['Accepted', 'btn-success'] :