. */ require_once(__DIR__ . '/../index.php'); require_once(__DIR__ . '/../login.php'); require('./header.php'); ?>

Welcome

= CURDATE()"]); ?>
CURDATE()"]); ?>
'1970-01-01'", "`invoice_date`<=CURDATE()", "NOT EXISTS (SELECT * FROM `".Constants::db_prefix."payment` WHERE `offerId`=`".Constants::db_prefix."offer`.`id`)"]); foreach (Offer::search($_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++; } } ?>
Currently active offers
= CURDATE()"]); $list = []; foreach ($offers as $offer) { $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->start_date; for ($i = 0; isset($list["$base-$i"]); $i++); $list["$base-$i"] = [ 'start' => $start, 'end' => $end, 'id' => $offer->id, 'contactClientName' => $offer->getContact()->getClient()->name, '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) { echo "

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

"; } if (count($list) == 0) { echo "There are no currently active offers."; } ?>
Finished offers
CURDATE()"]); foreach ($offers as $offer) { echo ""; } if (count($offers) == 0) { echo ""; } ?>
# Contact Offer ended
{$offer->id} {$offer->getContact()->getClient()->name} ".BusinessAdmin::formatDate($offer->end_date, false)."
There are no offers that need an invoice.
Currently open invoices
'1970-01-01'", "`invoice_date`<=CURDATE()", "NOT EXISTS (SELECT * FROM `".Constants::db_prefix."payment` WHERE `offerId`=`".Constants::db_prefix."offer`.`id`)"]); $open_offers = Offer::search($_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 ""; } else { foreach ($offers as $offer) { echo ""; } foreach ($open_offers as $offer) { if ($offer->getPayment()->isBraintreeFinished()) { continue; } echo ""; } } ?>
# Contact Invoice sent Braintree status
There are no currently open invoices.
{$offer->id} {$offer->getContact()->getClient()->name} ".BusinessAdmin::formatDate($offer->invoice_date, false)."
{$offer->id} {$offer->getContact()->getClient()->name} ".BusinessAdmin::formatDate($offer->invoice_date, false)." {$offer->getPayment()->braintree_status}
Timeline
    $offer->id, 'contact' => $offer->getContact()->name, 'assignments' => '', 'assignments_header' => '' ]; foreach ($offer->getAssignments() as $assignment) { $temp['assignments'] .= "{$assignment->title}
    (".Constants::invoice_valuta."{$assignment->calculate(Calculatable::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(Calculatable::TOTAL)} incl. VAT)

    {$assignment->getHTMLDescription()}

    "; $temp['assignments_header'] .= "{$assignment->title}
    (".Constants::invoice_valuta."{$assignment->calculate(Calculatable::SUBTOTAL)} excl. VAT, ".Constants::invoice_valuta."{$assignment->calculate(Calculatable::TOTAL)} incl. VAT)
    "; } $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, ['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, ['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, ['type' => 'payment_received', 'time' => $offer->getPaymentReceived(), 'description' => 'Payment received']); $sort_list[] = $offer->getPaymentReceived() . $offer->id . 3; } } } array_multisort($sort_list, SORT_DESC, $list); foreach ($list as $item) { if ($item['time'] > time()) { continue; } echo ""; switch ($item['type']) { case 'start': echo "
    "; break; case 'end': echo "
    "; break; case 'invoice': echo "
    "; break; case 'payment_received': echo "
    "; break; } echo "
    "; echo "

    #{$item['id']} to {$item['contact']}: {$item['description']}

    ".BusinessAdmin::formatDate($item['time'],false,true,true)."

    "; switch ($item['type']) { case 'start': echo "
    {$item['assignments']}
    "; break; default: echo "
    {$item['assignments_header']}
    "; } echo "
    "; echo ""; } if (count($list) == 0) { echo '
  • Welcome to BusinessAdmin!

    When you start adding projects, a timeline will appear here.
  • '; } ?>