1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
<?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);
?>
<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, array("offerId = {$_offer->getId()}"));
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='".constants::url_internal."/assignments?id={$assignment->getId()}' class='btn btn-primary btn-circle fa fa-arrow-right'></a>
<a title='Delete' href='".constants::url_internal."/assignments?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>
|