From 1ec8d12a7b125d41ecb723c5d83f2afef95408e9 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 31 Jul 2016 09:40:25 +0200 Subject: 0.5.2 emails --- include/offers-view.php | 148 +++++++++++++++++++++++++++--------------------- include/offers.php | 20 +++++++ 2 files changed, 104 insertions(+), 64 deletions(-) (limited to 'include') diff --git a/include/offers-view.php b/include/offers-view.php index 802f42f..d96e9ed 100644 --- a/include/offers-view.php +++ b/include/offers-view.php @@ -21,70 +21,6 @@ require_once('./login.php'); $_offer = new Offer($_pdo, $_id); ?> -
-
-
- 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, 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->id . 3; - } - } - - array_multisort($sort_list, SORT_DESC, $list); - $i = 0; - 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 ""; - } - ?> -
-
- -
- -
Assignments
@@ -171,3 +107,87 @@ $_offer = new Offer($_pdo, $_id);
+
+
+
+
Tools
+
+ accepted ? + ['Accepted', 'btn-success'] : + ['Not accepted', 'btn-default']; + $eligible = $_offer->getPaymentEligibility() ? + ['Eligible for online payment', 'btn-success'] : + ['Not eligible for online payment', 'btn-default']; + ?> + + + Send invoice to contact + Delete +
+
+
+
+
+
+ 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, 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->id . 3; + } + } + + array_multisort($sort_list, SORT_DESC, $list); + $i = 0; + 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 ""; + } + ?> +
+
+ +
+ +
diff --git a/include/offers.php b/include/offers.php index 8be7530..dbe5df0 100644 --- a/include/offers.php +++ b/include/offers.php @@ -37,6 +37,7 @@ require('./header.php'); // ?toggle_payment_eligibility= Toggle the payment eligibility of the offer with id // ?generate_invoice= Generate an invoice for the offer with id // ?trash_invoice= Trash the invoice file + // ?send_invoice= Send invoice to contact // ?delete= Delete the offer with id //------------------------------------------------------------------------------ @@ -137,6 +138,25 @@ require('./header.php'); echo ""; } + // Send invoice + if (isset($_GET['send_invoice'])) { + echo "
"; + $id = (int) $_GET['send_invoice']; + try { + $offer = new Offer($_pdo, $id); + if ($offer->send()) { + echo "
The invoice for offer {$id} has been sent to {$offer->getContact()->email}.
"; + } else { + echo "
The invoice could not be sent due to an unknown error.
"; + } + } catch (PDOException $e) { + echo "
The invoice could not be sent due to a PDO error.
"; + } catch (Exception $e) { + echo "
The offer with id {$id} could not be found.
"; + } + echo "
"; + } + // Delete offer if (isset($_GET['delete'])) { echo "
"; -- cgit v1.2.3