commit 5c2cfdbde91db59b9245d8084421eff39e0964f4
Author: plumbeo <plumbeo@users.noreply.github.com>
Date:   Wed Dec 21 22:37:23 2016 +0100

    Captive portal: convert tables to sortable tables
    
    Convert the used vouchers table from the old GET order method to a sortable table, and make the other tables (allowed IPs, hostnames, zones) sortable too.
    
    (cherry picked from commit 0122f1d05b24ff8160b9ec42af382185572788c4)

diff --git a/src/usr/local/www/services_captiveportal_hostname.php b/src/usr/local/www/services_captiveportal_hostname.php
index 8f16e7b2f8..e3496600fa 100644
--- a/src/usr/local/www/services_captiveportal_hostname.php
+++ b/src/usr/local/www/services_captiveportal_hostname.php
@@ -143,12 +143,12 @@ $tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_fil
 display_top_tabs($tab_array, true);
 ?>
 <div class="table-responsive">
-	<table class="table table-hover table-striped table-condensed table-rowdblclickedit">
+	<table class="table table-hover table-striped table-condensed table-rowdblclickedit sortable-theme-bootstrap" data-sortable>
 		<thead>
 			<tr>
 				<th><?=gettext("Hostname"); ?></th>
 				<th><?=gettext("Description"); ?></th>
-				<th><?=gettext("Actions"); ?></th>
+				<th data-sortable="false"><?=gettext("Actions"); ?></th>
 			</tr>
 		</thead>
 
diff --git a/src/usr/local/www/services_captiveportal_ip.php b/src/usr/local/www/services_captiveportal_ip.php
index 4d4c30e538..f910af908f 100644
--- a/src/usr/local/www/services_captiveportal_ip.php
+++ b/src/usr/local/www/services_captiveportal_ip.php
@@ -138,12 +138,12 @@ display_top_tabs($tab_array, true);
 
 ?>
 <div class="table-responsive">
-	<table class="table table-hover table-striped table-condensed table-rowdblclickedit">
+	<table class="table table-hover table-striped table-condensed table-rowdblclickedit sortable-theme-bootstrap" data-sortable>
 		<thead>
 			<tr>
 				<th><?=gettext("IP Addresses"); ?></th>
 				<th><?=gettext("Description"); ?></th>
-				<th><?=gettext("Actions"); ?></th>
+				<th data-sortable="false"><?=gettext("Actions"); ?></th>
 			</tr>
 		</thead>
 
diff --git a/src/usr/local/www/services_captiveportal_vouchers.php b/src/usr/local/www/services_captiveportal_vouchers.php
index f7a243f77d..c43d437320 100644
--- a/src/usr/local/www/services_captiveportal_vouchers.php
+++ b/src/usr/local/www/services_captiveportal_vouchers.php
@@ -448,7 +448,7 @@ display_top_tabs($tab_array, true);
 	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Voucher Rolls");?></h2></div>
 	<div class="panel-body">
 		<div class="table-responsive">
-			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
+			<table class="table table-striped table-hover table-condensed table-rowdblclickedit sortable-theme-bootstrap" data-sortable>
 				<thead>
 					<tr>
 						<th><?=gettext("Roll #")?></th>
@@ -464,18 +464,10 @@ $i = 0;
 foreach ($a_roll as $rollent):
 ?>
 					<tr>
-						<td>
-							<?=htmlspecialchars($rollent['number']); ?>&nbsp;
-						</td>
-						<td>
-							<?=htmlspecialchars($rollent['minutes'])?>&nbsp;
-						</td>
-						<td>
-							<?=htmlspecialchars($rollent['count'])?>&nbsp;
-						</td>
-						<td>
-							<?=htmlspecialchars($rollent['descr']); ?>&nbsp;
-						</td>
+						<td><?=htmlspecialchars($rollent['number']); ?></td>
+						<td><?=htmlspecialchars($rollent['minutes'])?></td>
+						<td><?=htmlspecialchars($rollent['count'])?></td>
+						<td><?=htmlspecialchars($rollent['descr']); ?></td>
 						<td>
 							<!-- These buttons are hidden/shown on checking the 'enable' checkbox -->
 							<a class="fa fa-pencil"		title="<?=gettext("Edit voucher roll"); ?>" href="services_captiveportal_vouchers_edit.php?zone=<?=$cpzone?>&amp;id=<?=$i; ?>"></a>
diff --git a/src/usr/local/www/services_captiveportal_zones.php b/src/usr/local/www/services_captiveportal_zones.php
index 4b69972ace..0951b40fee 100644
--- a/src/usr/local/www/services_captiveportal_zones.php
+++ b/src/usr/local/www/services_captiveportal_zones.php
@@ -104,14 +104,14 @@ if (is_subsystem_dirty('captiveportal')) {
 	<div class="panel panel-default">
 	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Captive Portal Zones')?></h2></div>
 		<div class="panel-body table-responsive">
-			<table class="table table-striped table-hover table-rowdblclickedit">
+			<table class="table table-striped table-hover table-rowdblclickedit sortable-theme-bootstrap" data-sortable>
 				<thead>
 					<tr>
 						<th><?=gettext('Zone')?></th>
 						<th><?=gettext('Interfaces')?></th>
 						<th><?=gettext('Number of users'); ?></th>
 						<th><?=gettext('Description'); ?></th>
-						<th><?=gettext('Actions'); ?></th>
+						<th data-sortable="false"><?=gettext('Actions'); ?></th>
 					</tr>
 				</thead>
 				<tbody>
diff --git a/src/usr/local/www/status_captiveportal_voucher_rolls.php b/src/usr/local/www/status_captiveportal_voucher_rolls.php
index e9777c22ab..0c4fa91198 100644
--- a/src/usr/local/www/status_captiveportal_voucher_rolls.php
+++ b/src/usr/local/www/status_captiveportal_voucher_rolls.php
@@ -107,17 +107,17 @@ display_top_tabs($tab_array);
 ?>
 
 <div class="table-responsive">
-	<table class="table table-striped table-hover table-condensed">
-	    <thead>
-    		<tr>
-    			<th><?=gettext("Roll#"); ?></th>
-    			<th><?=gettext("Minutes/Ticket"); ?></th>
-    			<th><?=gettext("# of Tickets"); ?></th>
-    			<th><?=gettext("Comment"); ?></th>
-    			<th><?=gettext("used"); ?></th>
-    			<th><?=gettext("active"); ?></th>
-    			<th><?=gettext("ready"); ?></th>
-    		</tr>
+	<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
+		<thead>
+    			<tr>
+    				<th><?=gettext("Roll#"); ?></th>
+    				<th><?=gettext("Minutes/Ticket"); ?></th>
+    				<th><?=gettext("# of Tickets"); ?></th>
+    				<th><?=gettext("Comment"); ?></th>
+    				<th><?=gettext("used"); ?></th>
+    				<th><?=gettext("active"); ?></th>
+    				<th><?=gettext("ready"); ?></th>
+    			</tr>
 		</thead>
 		<tbody>
 <?php
@@ -130,35 +130,21 @@ display_top_tabs($tab_array);
 				/* used also count active vouchers, remove them */
 				$used = $used - $active;
 ?>
-    		<tr>
-    			<td>
-    				<?=htmlspecialchars($rollent['number'])?>
-    			</td>
-    			<td>
-    				<?=htmlspecialchars($rollent['minutes'])?>
-    			</td>
-    			<td>
-    				<?=htmlspecialchars($rollent['count'])?>
-    			</td>
-    			<td>
-    				<?=htmlspecialchars($rollent['comment'])?>
-    			</td>
-    			<td>
-    				<?=htmlspecialchars($used)?>
-    			</td>
-    			<td>
-    				<?=htmlspecialchars($active)?>
-    			</td>
-    			<td>
-    				<?=htmlspecialchars($ready)?>
-    			</td>
-    		</tr>
+    			<tr>
+    				<td><?=htmlspecialchars($rollent['number'])?></td>
+    				<td><?=htmlspecialchars($rollent['minutes'])?></td>
+    				<td><?=htmlspecialchars($rollent['count'])?></td>
+    				<td><?=htmlspecialchars($rollent['comment'])?></td>
+    				<td><?=htmlspecialchars($used)?></td>
+    				<td><?=htmlspecialchars($active)?></td>
+    				<td><?=htmlspecialchars($ready)?></td>
+    			</tr>
 <?php
 				$i++;
 			endforeach;
 
 			unlock($voucherlck)?>
-	    </tbody>
+		</tbody>
 	</table>
 </div>
 <?php include("foot.inc");
diff --git a/src/usr/local/www/status_captiveportal_vouchers.php b/src/usr/local/www/status_captiveportal_vouchers.php
index 6e5c32833e..5fe38453b3 100644
--- a/src/usr/local/www/status_captiveportal_vouchers.php
+++ b/src/usr/local/www/status_captiveportal_vouchers.php
@@ -89,11 +89,6 @@ if (empty($cpzone)) {
 $pgtitle = array(gettext("Status"), gettext("Captive Portal"), htmlspecialchars($a_cp[$cpzone]['zone']), gettext("Active Vouchers"));
 $shortcut_section = "captiveportal-vouchers";
 
-function clientcmp($a, $b) {
-	global $order;
-	return strcmp($a[$order], $b[$order]);
-}
-
 if (!is_array($config['voucher'][$cpzone]['roll'])) {
 	$config['voucher'][$cpzone]['roll'] = array();
 }
@@ -126,11 +121,6 @@ foreach ($a_roll as $rollent) {
 	}
 }
 
-if ($_GET['order']) {
-	$order = $_GET['order'];
-	usort($db, "clientcmp");
-}
-
 include("head.inc");
 
 $tab_array = array();
@@ -145,14 +135,14 @@ display_top_tabs($tab_array);
 <div class="panel panel-default">
 	<div class="panel-heading"><h2 class="panel-title"><?=sprintf(gettext("Vouchers in Use (%d)"), count($db))?></h2></div>
 	<div class="panel-body table-responsive">
-		<table class="table table-striped table-hover table-condensed">
+		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
 			<thead>
 				<tr>
-					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=0&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Voucher"); ?></a></th>
-					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=1&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Roll"); ?></a></th>
-					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=2&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Activated at"); ?></a></th>
-					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=3&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Expires in"); ?></a></th>
-					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=4&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Expires at"); ?></a></th>
+					<th><?=gettext("Voucher"); ?></th>
+					<th><?=gettext("Roll"); ?></th>
+					<th><?=gettext("Activated at"); ?></th>
+					<th><?=gettext("Expires in"); ?></th>
+					<th><?=gettext("Expires at"); ?></th>
 				</tr>
 			</thead>
 			<tbody>
@@ -160,10 +150,10 @@ display_top_tabs($tab_array);
 foreach ($db as $dbent):
 ?>
 				<tr>
-					<td><?=$dbent[0]?></td>
-					<td><?=$dbent[1]?></td>
+					<td><?=htmlspecialchars($dbent[0])?></td>
+					<td><?=htmlspecialchars($dbent[1])?></td>
 					<td><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[2]))?></td>
-					<td><?=$dbent[3]?><?=gettext("min"); ?></td>
+					<td><?=htmlspecialchars($dbent[3])?><?=gettext("min"); ?></td>
 					<td><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[4]))?></td>
 				</tr>
 <?php
