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/>.
*/
?>
<!-- Navigation -->
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?=constants::url_internal?>/"><?=constants::my_name?></a>
</div>
<!-- /.navbar-header -->
<ul class="nav navbar-top-links navbar-right">
<!-- /.dropdown -->
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-tasks fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-tasks">
<?php
$offers = BusinessAdmin::getOffers($_pdo, array("`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= CURDATE()"));
$list = array();
foreach ($offers as $offer) {
$start = BusinessAdmin::formatDate($offer->getStartDate(), false);
$end = BusinessAdmin::formatDate($offer->getEndDate(), false);
$since = mktime(0,0,0,date("n"),date("j"),date("Y")) - $offer->getStartDate();
$total = $offer->getEndDate() - $offer->getStartDate();
$percentage = ($total == 0) ? 100 : round($since / $total * 100);
// We want to sort on percentage (DESC) and secondly end date (ASC) so start date (DESC)
$list[str_pad($percentage, 3, '0', STR_PAD_LEFT) . $offer->getStartDate()] = array(
'start' => $start,
'end' => $end,
'id' => $offer->getId(),
'contactClientName' => $offer->getContact()->getClient()->getName(),
'percentage' => $percentage,
'price' => constants::invoice_valuta . $offer->calculate(offer::SUBTOTAL)
);
}
krsort($list, SORT_STRING);
foreach ($list as $item) {
echo "<li>
<a href='".constants::url_internal."/offers?id={$item['id']}'>
<div>
<p>
<strong>{$item['contactClientName']}</strong> ({$item['start']} - {$item['end']}; {$item['price']})
</p>
<div class='progress progress-striped active' title='{$item['percentage']}% complete'>
<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>
</div>
</a>
</li>";
}
if (count($list) == 0) {
echo "<li><a href='#'><div><p>There are no currently active offers.</p></div></a></li>";
}
?>
<li>
<a class="text-center" href="<?=constants::url_internal?>/offers">
<strong>See All Offers</strong>
<i class="fa fa-angle-right"></i>
</a>
</li>
</ul>
<!-- /.dropdown-tasks -->
</li>
<!-- /.dropdown -->
</ul>
<!-- /.navbar-top-links -->
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li title="Dashboard">
<a <?php if($_page=='/') echo 'class="active"'; ?> href="<?=constants::url_internal?>/"><i class="fa fa-dashboard fa-fw"></i> <span class="nav-title">Dashboard</span></a>
</li>
<li title="Clients">
<a <?php if($_page=='/clients') echo 'class="active"'; ?> href="<?=constants::url_internal?>/clients"><i class="fa fa-institution fa-fw"></i> <span class="nav-title">Clients</span></a>
</li>
<li title="Contacts">
<a <?php if($_page=='/contacts') echo 'class="active"'; ?> href="<?=constants::url_internal?>/contacts"><i class="fa fa-user fa-fw"></i> <span class="nav-title">Contacts</span></a>
</li>
<li title="Offers">
<a <?php if($_page=='/offers') echo 'class="active"'; ?> href="<?=constants::url_internal?>/offers"><i class="fa fa-briefcase fa-fw"></i> <span class="nav-title">Offers</span></a>
</li>
<li title="Assignments">
<a <?php if($_page=='/assignments') echo 'class="active"'; ?> href="<?=constants::url_internal?>/assignments"><i class="fa fa-check-square fa-fw"></i> <span class="nav-title">Assignments</span></a>
</li>
<li title="About">
<a <?php if($_page=='/about') echo 'class="active"'; ?> href="<?=constants::url_internal?>/about"><i class="fa fa-info-circle fa-fw"></i> <span class="nav-title">About</span></a>
</li>
</ul>
<a href="#" id="collapse-menu" title="Collapse menu"><i class="fa fa-fw fa-caret-square-o-left"></i></a>
<?php if (isset($_SESSION['ba-collapse']) && $_SESSION['ba-collapse'] == true) : ?>
<script type="text/javascript">
$(document).ready(function(){
$('#collapse-menu').trigger('click', { load: true });
});
</script>
<?php endif; ?>
</div>
<!-- /.sidebar-collapse -->
</div>
<!-- /.navbar-static-side -->
</nav>
|