aboutsummaryrefslogtreecommitdiff
path: root/nav.php
blob: 888f2b14bb33aff6a6ed280fdd2459caaf27f909 (plain) (blame)
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
130
131
132
133
134
135
136
137
138
139
140
141
<?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">
		<?php if (isset($_user)) : ?>
			<span>
				Logged in as <a href="<?=Constants::url_internal?>/settings"><?=$_user->username?></a>
				(<a href="<?=Constants::url_internal?>/?logout">logout</a>)
			</span>
		<?php endif; ?>
		<!-- /.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 = Offer::search($_pdo, ["`accepted`=1", "`start_date` <= CURDATE()", "`end_date` >= 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)
					$list[str_pad($percentage, 3, '0', STR_PAD_LEFT) . $offer->start_date] = [
						'start' => $start,
						'end' => $end,
						'id' => $offer->id,
						'contactClientName' => $offer->getContact()->getClient()->name,
						'percentage' => $percentage,
						'price' => Constants::invoice_valuta . $offer->calculate(Calculatable::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="Discounts">
					<a <?php if($_page=='/discounts') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/discounts"><i class="fa fa-percent fa-fw"></i> <span class="nav-title">Discounts</span></a>
				</li>
				<li title="Settings">
					<a <?php if($_page=='/settings') echo 'class="active"'; ?> href="<?=Constants::url_internal?>/settings"><i class="fa fa-cog fa-fw"></i> <span class="nav-title">Settings</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>