From ddcdb11f4d3a97c353994990e0c6418a557e50e8 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 1 Aug 2016 08:28:57 +0200 Subject: Unfinished braintree status means open invoice; update frontend --- include/assignments-overview.php | 2 +- include/clients-overview.php | 2 +- include/clients-view.php | 2 +- include/contacts-overview.php | 2 +- include/discounts-overview.php | 2 +- include/home.php | 56 +++++++++++++++++++++++++++++----------- include/offers-overview.php | 2 +- include/offers-view.php | 6 ++--- include/offers.php | 3 ++- 9 files changed, 52 insertions(+), 25 deletions(-) (limited to 'include') 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'); "; } if (count($assignments) == 0) { - echo "There are no assignments in the database. Why not start with creating one, below?"; + echo "There are no assignments in the database."; } ?> 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'); "; } if (count($clients) == 0) { - echo "There are no clients in the database. Why not start with creating one, on the right?"; + echo "There are no clients in the database."; } ?> 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); "; } if (count($contacts) == 0) { - echo "There are no contacts in the database. Why not create one?"; + echo "There are no contacts in the database."; } ?> 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'); "; } if (count($contacts) == 0) { - echo "There are no contacts in the database. Why not start with creating one, on the right?"; + echo "There are no contacts in the database."; } ?> 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'); "; } if (count($discounts) == 0) { - echo "There are no discounts in the database. Why not start with creating one, below?"; + echo "There are no discounts in the database."; } ?> 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');
'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++; + } + } ?>
@@ -173,7 +178,7 @@ require('./header.php'); } krsort($list, SORT_STRING); foreach ($list as $item) { - echo "

#{$item['id']} to {$item['contactClientName']} ({$item['start']} - {$item['end']}; {$item['price_excl']} excl. VAT, {$item['price_incl']} incl. VAT){$item['percentage']}% complete

+ echo "

#{$item['id']} to {$item['contactClientName']} ({$item['start']} - {$item['end']}; {$item['price_excl']} excl. VAT, {$item['price_incl']} incl. VAT){$item['percentage']}% complete

"; @@ -206,11 +211,11 @@ require('./header.php'); CURDATE()")); foreach ($offers as $offer) { - echo ""; - echo "{$offer->id}"; - echo "{$offer->getContact()->getClient()->name}"; - echo "".BusinessAdmin::formatDate($offer->end_date, false).""; - echo ""; + echo " + {$offer->id} + {$offer->getContact()->getClient()->name} + ".BusinessAdmin::formatDate($offer->end_date, false)." + "; } if (count($offers) == 0) { echo "There are no offers that need an invoice."; @@ -235,6 +240,7 @@ require('./header.php'); # Contact Invoice sent + Braintree status @@ -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 "There are no currently open invoices."; + $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 "There are no currently open invoices."; } else { foreach ($offers as $offer) { - echo ""; - echo "{$offer->id}"; - echo "{$offer->getContact()->getClient()->name}"; - echo "".BusinessAdmin::formatDate($offer->invoice_date, false).""; - echo ""; + echo " + {$offer->id} + {$offer->getContact()->getClient()->name} + ".BusinessAdmin::formatDate($offer->invoice_date, false)." + + "; + } + foreach ($open_offers as $offer) { + if ($offer->getPayment()->isBraintreeFinished()) { + continue; + } + echo " + {$offer->id} + {$offer->getContact()->getClient()->name} + ".BusinessAdmin::formatDate($offer->invoice_date, false)." + {$offer->getPayment()->braintree_status} + "; } } ?> 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'); "; } if (count($offers) == 0) { - echo "There are no offers in the database. Why not start with creating one, below?"; + echo "There are no offers in the database."; } ?> 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); "; } if (count($assignments) == 0) { - echo "There are no assignments in the database. Why not start with creating one, below?"; + echo "There are no assignments in the database."; } ?> @@ -99,7 +99,7 @@ $_offer = new Offer($_pdo, $_id); "; } if (count($discounts) == 0) { - echo "There are no discounts in the database. Why not start with creating one, below?"; + echo "There are no discounts in the database."; } ?> @@ -135,7 +135,7 @@ $_offer = new Offer($_pdo, $_id); "; } if (count($payments) == 0) { - echo "There are no payments in the database. Why not start with creating one, below?"; + echo "There are no payments in the database."; } ?> 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 = "Offers / #{$offer->id}"; + $header = "Offers / #{$offer->id}"; $show_individual = $id; $accepted = $offer->accepted ? ['Accepted', 'btn-success'] : -- cgit v1.2.3