aboutsummaryrefslogtreecommitdiff
path: root/include/offers-view.php
diff options
context:
space:
mode:
authorCamil Staps2015-02-05 00:40:47 +0100
committerCamil Staps2015-02-05 00:40:47 +0100
commitc50a323c25a0787ba2051b19721983776a229615 (patch)
tree87e13060ca6633bed3f5de2e25c5eedf866a0073 /include/offers-view.php
parentInitial commit (diff)
Initial commit
Diffstat (limited to 'include/offers-view.php')
-rw-r--r--include/offers-view.php130
1 files changed, 130 insertions, 0 deletions
diff --git a/include/offers-view.php b/include/offers-view.php
new file mode 100644
index 0000000..b7fb092
--- /dev/null
+++ b/include/offers-view.php
@@ -0,0 +1,130 @@
+<?php
+/**
+ * BusinessAdmin: administrative software for small companies
+ * Copyright (C) 2015 Camil Staps (ViviSoft)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+$_offer = new offer($_pdo, $_id);
+$_offer->generateInvoice();
+?>
+<div class="col-lg-6">
+ <div class="panel panel-default" id="panel-timeline">
+ <div class="panel-heading">
+ <i class="fa fa-clock-o fa-fw"></i> Timeline
+ </div>
+ <!-- /.panel-heading -->
+ <div class="panel-body">
+ <ul class="timeline">
+ <?php
+ $list = array();
+ $sort_list = array();
+
+ $temp = array(
+ 'id' => $_offer->getId(),
+ 'contact' => $_offer->getContact()->getName(),
+ 'assignments' => '',
+ 'assignments_header' => ''
+ );
+ foreach ($_offer->getAssignments() as $assignment) {
+ $temp['assignments'] .= "<b>{$assignment->getTitle()}</b><br/><span class='smaller'>(".constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/><p>{$assignment->getDescription()}</p>";
+ $temp['assignments_header'] .= "<b>{$assignment->getTitle()}</b><br/><span class='smaller'>(".constants::invoice_valuta."{$assignment->calculate(assignment::SUBTOTAL)} excl. VAT, ".constants::invoice_valuta."{$assignment->calculate(assignment::TOTAL)} incl. VAT)</span><br/>";
+ }
+ $list[] = array_merge($temp, array('type' => 'start', 'time' => $_offer->getStartDate(), 'description' => 'Offer started'));
+ $sort_list[] = $_offer->getStartDate() . $_offer->getId() . 0;
+ $list[] = array_merge($temp, array('type' => 'end', 'time' => $_offer->getEndDate(), 'description' => 'Offer ended'));
+ $sort_list[] = $_offer->getEndDate() . $_offer->getId() . 1;
+ if ($_offer->getInvoiceDate() > 0) {
+ $list[] = array_merge($temp, array('type' => 'invoice', 'time' => $_offer->getInvoiceDate(), 'description' => 'Invoice sent'));
+ $sort_list[] = $_offer->getInvoiceDate() . $_offer->getId() . 2;
+ if ($_offer->getPaymentReceived() > 0) {
+ $list[] = array_merge($temp, array('type' => 'payment_received', 'time' => $_offer->getPaymentReceived(), 'description' => 'Payment received'));
+ $sort_list[] = $_offer->getPaymentReceived() . $_offer->getId() . 3;
+ }
+ }
+
+ array_multisort($sort_list, SORT_DESC, $list);
+ $i = 0;
+ foreach ($list as $item) {
+ if ($item['time'] > time()) {
+ continue;
+ }
+ echo "<li" . ($i++ % 2 == 0 ? ' class="timeline-inverted"' : '') . ">";
+ switch ($item['type']) {
+ case 'start': echo "<div class='timeline-badge info' title='{$item['description']}'><i class='fa fa-circle-o-notch'></i></div>"; break;
+ case 'end': echo "<div class='timeline-badge primary' title='{$item['description']}'><i class='fa fa-circle-o'></i></div>"; break;
+ case 'invoice': echo "<div class='timeline-badge warning' title='{$item['description']}'><i class='fa fa-check-circle-o'></i></div>"; break;
+ case 'payment_received': echo "<div class='timeline-badge success' title='{$item['description']}'><i class='fa fa-eur'></i></div>"; break;
+ }
+ echo "<div class='timeline-panel'>";
+ echo "<div class='timeline-heading'><h4 class='timeline-title'>#{$item['id']} to {$item['contact']}: {$item['description']}</h4><p><small class='text-muted'><i class='fa fa-clock-o fa-fw'></i> ".BusinessAdmin::formatDate($item['time'],false,true,true)."</small></p></div>";
+ switch ($item['type']) {
+ case 'start': echo "<div class='timeline-body'>{$item['assignments']}</div>"; break;
+ default: echo "<div class='timeline-body'>{$item['assignments_header']}</div>";
+ }
+ echo "</div>";
+ echo "</li>";
+ }
+ ?>
+ </ul>
+ </div>
+ <!-- /.panel-body -->
+ </div>
+ <!-- /.panel -->
+</div>
+<div class="col-lg-6">
+ <div class="panel panel-default">
+ <div class="panel-heading">Assignments</div>
+ <div class="panel-body table-responsive">
+ <table class="table table-bordered table-striped">
+ <thead>
+ <tr>
+ <th>#</th>
+ <th>Briefing</th>
+ <th>Time</th>
+ <th>Price</th>
+ <th>Tools</th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php
+ $assignments = BusinessAdmin::getAssignments($_pdo);
+ foreach ($assignments as $assignment) {
+ echo "<tr>
+ <td class='col-min-width'>{$assignment->getId()}</td>
+ <td class='col-max-width'>
+ <b><a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-title' data-type='text' data-pk='{$assignment->getId()}' data-url='".constants::url_external."assignments/edit'>{$assignment->getTitle()}</a></b><br/>
+ <p>{$assignment->getDescription()}</p>
+ </td>
+ <td class='col-min-width'><a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-hours' data-type='text' data-pk='{$assignment->getId()}' data-url='".constants::url_external."assignments/edit'>{$assignment->getHours()}</a>h</td>
+ <td class='col-min-width'>
+ ".constants::invoice_valuta."<a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-price_per_hour' data-type='text' data-pk='{$assignment->getId()}' data-url='".constants::url_external."assignments/edit'>{$assignment->getPricePerHour()}</a> / hr<br/>
+ <a href='#' class='editable' id='editable-assignment-{$assignment->getId()}-vat' data-type='text' data-pk='{$assignment->getId()}' data-url='".constants::url_external."assignments/edit'>{$assignment->getVAT()}</a>% VAT
+ </td>
+ <td class='col-min-width'>
+ <a title='View' href='?id={$assignment->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a>
+ <a title='Delete' href='?delete={$assignment->getId()}' class='btn btn-danger btn-circle fa fa-times'></a>
+ </td>
+ </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>";
+ }
+ ?>
+ </tbody>
+ </table>
+ </div>
+ </div>
+</div> \ No newline at end of file