Index: html/pages/bill/actions.inc.php
===================================================================
--- html/pages/bill/actions.inc.php	(revision 6107)
+++ html/pages/bill/actions.inc.php	(working copy)
@@ -11,7 +11,7 @@
  *
  */
 
-if ($_POST['action'] == "delete_bill" && $_POST['confirm'] == "confirm")
+if ($vars['action'] == "delete_bill" && $vars['confirm'] == "confirm")
 {
   foreach (dbFetchRows("SELECT * FROM `bill_ports` WHERE `bill_id` = ?", array($bill_id)) as $port_data)
   {
@@ -29,9 +29,10 @@
   echo("<meta http-equiv='Refresh' content=\"2; url='bills/'\">");
 }
 
-if ($_POST['action'] == "reset_bill" && ($_POST['confirm'] == "rrd" || $_POST['confirm'] == "mysql"))
+if ($vars['action'] == "reset_bill" && ($vars['confirm'] == "rrd" || $vars['confirm'] == "mysql"))
 {
-  if ($_POST['confirm'] == "mysql") {
+  if ($vars['confirm'] == "mysql")
+  {
     foreach (dbFetchRows("SELECT * FROM `bill_ports` WHERE `bill_id` = ?", array($bill_id)) as $port_data)
     {
       dbDelete('port_in_measurements', '`port_id` = ?', array($port_data['bill_id']));
@@ -40,7 +41,8 @@
     dbDelete('bill_hist', '`bill_id` = ?', array($bill_id));
     dbDelete('bill_data', '`bill_id` = ?', array($bill_id));
   }
-  if ($_POST['confirm'] == "rrd") {
+  if ($vars['confirm'] == "rrd")
+  {
     // TODO: First need to add new rrd with poller/discover, so the default rrd isn't wipped
   }
 
@@ -48,55 +50,59 @@
   echo("<meta http-equiv='Refresh' content=\"2; url='bills/'\">");
 }
 
-if ($_POST['action'] == "add_bill_port")
+if ($vars['action'] == "add_bill_port")
 {
-  $check = dbFetchRows("SELECT port_id FROM `bill_ports` WHERE `bill_id` = ? LIMIT 1", array($_POST['bill_id']));
-  if ($check[0]['port_id'] != $_POST['port_id']) {
-    dbInsert(array('bill_id' => $_POST['bill_id'], 'port_id' => $_POST['port_id']), 'bill_ports');
+  foreach ($vars['port_id'] as $entry)
+  {
+    $check = dbFetchRows("SELECT port_id FROM `bill_ports` WHERE `bill_id` = ? LIMIT 1", array($entry));
+    if ($check[0]['port_id'] != $entry)
+    {
+      dbInsert(array('bill_id' => $vars['bill_id'], 'port_id' => $entry), 'bill_ports');
+    }
   }
 }
 
-if ($_GET['action'] == "delete_bill_port")
+if ($vars['action'] == "delete_bill_port")
 {
-  dbDelete('bill_ports', "`bill_id` =  ? AND `port_id` = ?", array($bill_id, $_GET['port_id']));
+  dbDelete('bill_ports', "`bill_id` =  ? AND `port_id` = ?", array($bill_id, $vars['port_id']));
 }
-if ($_POST['action'] == "update_bill")
+if ($vars['action'] == "update_bill")
 {
-  if (isset($_POST['bill_quota']) or isset($_POST['bill_cdr']))
+  if (isset($vars['bill_quota']) or isset($vars['bill_cdr']))
   {
-    if ($_POST['bill_type'] == "quota")
+    if ($vars['bill_type'] == "quota")
     {
-      if (isset($_POST['bill_quota_type']))
+      if (isset($vars['bill_quota_type']))
       {
-        if ($_POST['bill_quota_type'] == "MB") { $multiplier = 1 * $config['billing']['base']; }
-        if ($_POST['bill_quota_type'] == "GB") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base']; }
-        if ($_POST['bill_quota_type'] == "TB") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base'] * $config['billing']['base']; }
-        $bill_quota = (is_numeric($_POST['bill_quota']) ? $_POST['bill_quota'] * $config['billing']['base'] * $multiplier : 0);
+        if ($vars['bill_quota_type'] == "MB") { $multiplier = 1 * $config['billing']['base']; }
+        if ($vars['bill_quota_type'] == "GB") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base']; }
+        if ($vars['bill_quota_type'] == "TB") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base'] * $config['billing']['base']; }
+        $bill_quota = (is_numeric($vars['bill_quota']) ? $vars['bill_quota'] * $config['billing']['base'] * $multiplier : 0);
         $bill_cdr = 0;
       }
     }
-    if ($_POST['bill_type'] == "cdr")
+    if ($vars['bill_type'] == "cdr")
     {
-      if (isset($_POST['bill_cdr_type']))
+      if (isset($vars['bill_cdr_type']))
       {
-        if ($_POST['bill_cdr_type'] == "Kbps") { $multiplier = 1 * $config['billing']['base']; }
-        if ($_POST['bill_cdr_type'] == "Mbps") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base']; }
-        if ($_POST['bill_cdr_type'] == "Gbps") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base'] * $config['billing']['base']; }
-        $bill_cdr = (is_numeric($_POST['bill_cdr']) ? $_POST['bill_cdr'] * $multiplier : 0);
+        if ($vars['bill_cdr_type'] == "Kbps") { $multiplier = 1 * $config['billing']['base']; }
+        if ($vars['bill_cdr_type'] == "Mbps") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base']; }
+        if ($vars['bill_cdr_type'] == "Gbps") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base'] * $config['billing']['base']; }
+        $bill_cdr = (is_numeric($vars['bill_cdr']) ? $vars['bill_cdr'] * $multiplier : 0);
         $bill_quota = 0;
       }
     }
   }
 
-  $bill_notify  = ($_POST['bill_notify'] == 'on' ? 1 : 0);
-  $bill_contact = (strlen($_POST['bill_contact']) ? $_POST['bill_contact'] : array('NULL'));
+  $bill_notify  = ($vars['bill_notify'] == 'on' ? 1 : 0);
+  $bill_contact = (strlen($vars['bill_contact']) ? $vars['bill_contact'] : array('NULL'));
 
-  if (dbUpdate(array('bill_name' => $_POST['bill_name'], 'bill_day' => $_POST['bill_day'], 'bill_quota' => $bill_quota, 'bill_cdr' => $bill_cdr,
-                     'bill_type' => $_POST['bill_type'], 'bill_custid' => $_POST['bill_custid'], 'bill_ref' => $_POST['bill_ref'],
-                     'bill_notes' => $_POST['bill_notes'], 'bill_contact' => $bill_contact, 'bill_notify' => $bill_notify), 'bills', '`bill_id` = ?', array($bill_id)))
+  if (dbUpdate(array('bill_name' => $vars['bill_name'], 'bill_day' => $vars['bill_day'], 'bill_quota' => $bill_quota, 'bill_cdr' => $bill_cdr,
+                     'bill_type' => $vars['bill_type'], 'bill_custid' => $vars['bill_custid'], 'bill_ref' => $vars['bill_ref'],
+                     'bill_notes' => $vars['bill_notes'], 'bill_contact' => $bill_contact, 'bill_notify' => $bill_notify), 'bills', '`bill_id` = ?', array($bill_id)))
   {
     print_message("Bill Properties Updated");
   }
 }
 
-?>
+// EOF
Index: html/pages/bill/edit.inc.php
===================================================================
--- html/pages/bill/edit.inc.php	(revision 6107)
+++ html/pages/bill/edit.inc.php	(working copy)
@@ -179,12 +179,13 @@
 
 if (is_array($ports))
 {
-  foreach ($port_ids AS $port_entry) {
+  foreach ($port_ids AS $port_entry)
+  {
 
-  $emptyCheck = true;
+    $emptyCheck = true;
 
-  $port   = get_port_by_id($port_entry['port_id']);
-  $device = device_by_id_cache($port['device_id']);
+    $port   = get_port_by_id($port_entry['port_id']);
+    $device = device_by_id_cache($port['device_id']);
 
     $devicebtn = '<button class="btn"><i class="oicon-servers"></i> '.generate_device_link($device).'</button>';
     if (empty($port['ifAlias'])) { $portalias = ""; } else { $portalias = " - ".$port['ifAlias'].""; }
@@ -204,7 +205,8 @@
     echo('            </div>' . PHP_EOL);
     echo('          </form>' . PHP_EOL);
   }
-  if (!$emptyCheck) {
+  if (!$emptyCheck)
+  {
     echo('          <div class="alert alert-info">' . PHP_EOL);
     echo('            <i class="icon-info-sign"></i> There are no ports assigned to this bill' . PHP_EOL);
     echo('          </div>' . PHP_EOL);
@@ -227,7 +229,7 @@
         <div class="control-group">
           <label class="control-label" for="device">Device</label>
           <div class="controls">
-            <select style="width: 300px;" id="device" name="device" onchange="getInterfaceList(this, 'port_id')">
+            <select style="width: 300px;" id="device" name="device" class="selectpicker" onchange="getInterfaceList(this, 'port_id')">
               <option value=''>Select a device</option>
 <?php
 
@@ -234,9 +236,10 @@
 $devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname");
 foreach ($devices as $device)
 {
-  unset($done);
-  foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } }
-  if (!$done) { echo("              <option value='" . $device['device_id']  . "'>" . $device['hostname'] . "</option>"); }
+  if (device_permitted($device['device_id']))
+  {
+    echo("              <option value='" . $device['device_id']  . "'>" . $device['hostname'] . "</option>");
+  }
 }
 
 ?>
@@ -246,7 +249,7 @@
         <div class="control-group">
           <label class="control-label" for="port_id">Port</label>
           <div class="controls">
-            <select style="width: 300px;" id="port_id" name="port_id"></select>
+            <select multiple style="width: 300px;" id="port_id" class="selectpicker" name="port_id[]"></select>
           </div>
         </div>
       </fieldset>
Index: html/pages/bill/navbar.inc.php
===================================================================
--- html/pages/bill/navbar.inc.php	(revision 6107)
+++ html/pages/bill/navbar.inc.php	(working copy)
@@ -16,60 +16,51 @@
 $isAdd             = (($vars['view'] == "add") ? true : false);
 $disabledAdmin     = ($isAdmin ? "" : 'disabled="disabled"');
 $disabledUser      = ($isUser ? "" : 'disabled="disabled"');
-$links['quick']    = ($isUser ? generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'quick')) : 'javascript:;');
-$links['accurate'] = ($isUser ? generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'accurate')) : 'javascript:;');
-$links['transfer'] = ($isUser ? generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'transfer')) : 'javascript:;');
-$links['history']  = ($isUser ? generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'history')) : 'javascript:;');
-$links['api']      = ($isAdmin ? generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'api')) : 'javascript:;');
-$links['edit']     = ($isAdmin ? generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'edit')) : 'javascript:;');
-$links['delete']   = ($isAdmin ? generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'delete')) : 'javascript:;');
-$links['reset']    = ($isAdmin ? generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'reset')) : 'javascript:;');
-$links['bills']    = generate_url(array('page' => 'bills'));
-$active['quick']   = (($vars['view'] == "quick") ? "active " : "");
-$active['accurate']= (($vars['view'] == "accurate") ? "active " : "");
-$active['transfer']= (($vars['view'] == "transfer") ? "active " : "");
-$active['history'] = (($vars['view'] == "history") ? "active " : "");
-$active['api']     = (($vars['view'] == "api") ? "active " : "");
-$active['edit']    = (($vars['view'] == "edit") ? "active " : "");
-$active['reset']   = (($vars['view'] == "reset") ? "active " : "");
-$active['delete']  = (($vars['view'] == "delete") ? "active " : "");
 
-$brand = 'Bill';
-if (!$isAdd) {
-  $brand .= ':'.$bill_data['bill_name'];
+$navbar['class'] = 'navbar-narrow';
+$navbar['brand'] = 'Bill';
+
+if (!$isAdd)
+{
+  $navbar['brand'] .= ': '.$bill_data['bill_name'];
 }
 
-echo('<div class="navbar navbar-narrow">
-        <div class="navbar-inner">
-<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target="#bill-nav">
-          <span class="icon-bar"></span>
-        </button>
-          <a class="brand">'.$brand.'</a>
-          <div class="nav-collapse" id="bill-nav">
-          <ul class="nav">');
-if ($isUser && !$isAdd) {
-  echo('
-            <li class="'.$active['quick'].' first"><a href="'.$links['quick'].'">Quick Graphs</a></li>
-            <li class="'.$active['accurate'].'"><a href="'.$links['accurate'].'">Accurate Graphs</a></li>
-            <li class="'.$active['transfer'].'"><a href="'.$links['transfer'].'">Transfer Graphs</a></li>
-            <li class="'.$active['history'].'"><a href="'.$links['history'].'">Historical Usage</a></li>');
+if ($isUser && !$isAdd)
+{
+  $navbar['options']['quick']['text'] = 'Quick Graphs';
+  $navbar['options']['accurate']['text'] = 'Accurate Graphs';
+  $navbar['options']['transfer']['text'] = 'Transfer Graphs';
+  $navbar['options']['history']['text'] = 'Historical Usage';
+
+  foreach ($navbar['options'] as $option => $array)
+  {
+    if ($vars['view'] == $option) { $navbar['options'][$option]['class'] .= ' active'; }
+    $navbar['options'][$option]['url'] = generate_url($vars, array('view' => $option));
+  }
 }
-if ($isAdmin && !$isAdd) {
-  echo('
-            <li class="spacer">&nbsp;</li>
-            <li class="'.$active['edit'].' first"><a href="'.$links['edit'].'">Edit</a></li>
-            <li class="'.$active['reset'].'"><a href="'.$links['reset'].'">Reset</a></li>
-            <li class="'.$active['delete'].'"><a href="'.$links['delete'].'">Delete</a></li>');
-// Don't show what doesn't work!
-//            <li class="'.$active['api'].'"><a href="'.$links['api'].'"><i class="icon-share"></i> Api</a></li>');
+
+if ($isAdmin && !$isAdd)
+{
+  $navbar_array = array( 
+    array('page' => 'edit', 'icon' => 'oicon-gear--edit'), 
+    array('page' => 'reset', 'icon' => 'oicon-arrow-circle'), 
+    array('page' => 'delete', 'icon' => 'oicon-minus-circle')
+  );
+  
+  foreach ($navbar_array as $entry)
+  {
+    $navbar['options'][$entry['page']]['url']  = generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => $entry['page']));
+    $navbar['options'][$entry['page']]['text'] = ucfirst($entry['page']);
+    $navbar['options'][$entry['page']]['icon'] = $entry['icon'];
+    if ($vars['view'] == $entry['page']) { $navbar['options'][$entry['page']]['class'] = ' active'; }
+  }
 }
-echo('
-          </ul>
-          <ul class="nav pull-right">
-            <li class="first"><a href="'.$links['bills'].'"><i class="icon-chevron-left"></i> <strong>Back</strong></a></li>
-          </ul>
-         </div>
-        </div>
-      </div>');
 
-?>
+$navbar['options_right']['back']['url']  = generate_url(array('page' => 'bills'));
+$navbar['options_right']['back']['text'] = 'Back';
+$navbar['options_right']['back']['icon'] = 'icon-chevron-left';
+
+print_navbar($navbar);
+unset($navbar);
+
+// EOF