diff options
Diffstat (limited to 'nav.php')
-rw-r--r-- | nav.php | 118 |
1 files changed, 118 insertions, 0 deletions
@@ -0,0 +1,118 @@ +<?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()", "`invoice_date` IS NULL OR `invoice_date` = '1970-01-01'")); + $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 + ); + } + krsort($list, SORT_STRING); + foreach ($list as $item) { + echo "<li> + <a href='/offers?id={$item['id']}'> + <div> + <p> + <strong>{$item['contactClientName']}</strong> ({$item['start']} - {$item['end']}) + </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> + <a <?php if($_page=='/') echo 'class="active"'; ?> href="<?=constants::url_internal?>/"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a> + </li> + <li> + <a <?php if($_page=='/clients') echo 'class="active"'; ?> href="<?=constants::url_internal?>/clients"><i class="fa fa-institution fa-fw"></i> Clients</a> + </li> + <li> + <a <?php if($_page=='/contacts') echo 'class="active"'; ?> href="<?=constants::url_internal?>/contacts"><i class="fa fa-user fa-fw"></i> Contacts</a> + </li> + <li> + <a <?php if($_page=='/offers') echo 'class="active"'; ?> href="<?=constants::url_internal?>/offers"><i class="fa fa-briefcase fa-fw"></i> Offers</a> + </li> + <li> + <a <?php if($_page=='/assignments') echo 'class="active"'; ?> href="<?=constants::url_internal?>/assignments"><i class="fa fa-check-square fa-fw"></i> Assignments</a> + </li> + <li> + <a <?php if($_page=='/about') echo 'class="active"'; ?> href="<?=constants::url_internal?>/about"><i class="fa fa-info-circle fa-fw"></i> About</a> + </li> + </ul> + </div> + <!-- /.sidebar-collapse --> + </div> + <!-- /.navbar-static-side --> +</nav>
\ No newline at end of file |