diff options
author | Camil Staps | 2016-08-01 08:28:57 +0200 |
---|---|---|
committer | Camil Staps | 2016-08-01 08:28:57 +0200 |
commit | ddcdb11f4d3a97c353994990e0c6418a557e50e8 (patch) | |
tree | 518b502bb5959a32ce9adc3950b9693001a67c39 /include/home.php | |
parent | Easier accessor/mutator in Model; refreshing braintree statuses (diff) |
Unfinished braintree status means open invoice; update frontend
Diffstat (limited to 'include/home.php')
-rw-r--r-- | include/home.php | 56 |
1 files changed, 41 insertions, 15 deletions
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>"; } } ?> |