Project

General

Profile

« Previous | Next » 

Revision 5c2cfdbd

Added by Caio Plumbeo over 8 years ago

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)

View differences:

src/usr/local/www/services_captiveportal_hostname.php
143 143
display_top_tabs($tab_array, true);
144 144
?>
145 145
<div class="table-responsive">
146
	<table class="table table-hover table-striped table-condensed table-rowdblclickedit">
146
	<table class="table table-hover table-striped table-condensed table-rowdblclickedit sortable-theme-bootstrap" data-sortable>
147 147
		<thead>
148 148
			<tr>
149 149
				<th><?=gettext("Hostname"); ?></th>
150 150
				<th><?=gettext("Description"); ?></th>
151
				<th><?=gettext("Actions"); ?></th>
151
				<th data-sortable="false"><?=gettext("Actions"); ?></th>
152 152
			</tr>
153 153
		</thead>
154 154

  
src/usr/local/www/services_captiveportal_ip.php
138 138

  
139 139
?>
140 140
<div class="table-responsive">
141
	<table class="table table-hover table-striped table-condensed table-rowdblclickedit">
141
	<table class="table table-hover table-striped table-condensed table-rowdblclickedit sortable-theme-bootstrap" data-sortable>
142 142
		<thead>
143 143
			<tr>
144 144
				<th><?=gettext("IP Addresses"); ?></th>
145 145
				<th><?=gettext("Description"); ?></th>
146
				<th><?=gettext("Actions"); ?></th>
146
				<th data-sortable="false"><?=gettext("Actions"); ?></th>
147 147
			</tr>
148 148
		</thead>
149 149

  
src/usr/local/www/services_captiveportal_vouchers.php
448 448
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Voucher Rolls");?></h2></div>
449 449
	<div class="panel-body">
450 450
		<div class="table-responsive">
451
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
451
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit sortable-theme-bootstrap" data-sortable>
452 452
				<thead>
453 453
					<tr>
454 454
						<th><?=gettext("Roll #")?></th>
......
464 464
foreach ($a_roll as $rollent):
465 465
?>
466 466
					<tr>
467
						<td>
468
							<?=htmlspecialchars($rollent['number']); ?>&nbsp;
469
						</td>
470
						<td>
471
							<?=htmlspecialchars($rollent['minutes'])?>&nbsp;
472
						</td>
473
						<td>
474
							<?=htmlspecialchars($rollent['count'])?>&nbsp;
475
						</td>
476
						<td>
477
							<?=htmlspecialchars($rollent['descr']); ?>&nbsp;
478
						</td>
467
						<td><?=htmlspecialchars($rollent['number']); ?></td>
468
						<td><?=htmlspecialchars($rollent['minutes'])?></td>
469
						<td><?=htmlspecialchars($rollent['count'])?></td>
470
						<td><?=htmlspecialchars($rollent['descr']); ?></td>
479 471
						<td>
480 472
							<!-- These buttons are hidden/shown on checking the 'enable' checkbox -->
481 473
							<a class="fa fa-pencil"		title="<?=gettext("Edit voucher roll"); ?>" href="services_captiveportal_vouchers_edit.php?zone=<?=$cpzone?>&amp;id=<?=$i; ?>"></a>
src/usr/local/www/services_captiveportal_zones.php
104 104
	<div class="panel panel-default">
105 105
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Captive Portal Zones')?></h2></div>
106 106
		<div class="panel-body table-responsive">
107
			<table class="table table-striped table-hover table-rowdblclickedit">
107
			<table class="table table-striped table-hover table-rowdblclickedit sortable-theme-bootstrap" data-sortable>
108 108
				<thead>
109 109
					<tr>
110 110
						<th><?=gettext('Zone')?></th>
111 111
						<th><?=gettext('Interfaces')?></th>
112 112
						<th><?=gettext('Number of users'); ?></th>
113 113
						<th><?=gettext('Description'); ?></th>
114
						<th><?=gettext('Actions'); ?></th>
114
						<th data-sortable="false"><?=gettext('Actions'); ?></th>
115 115
					</tr>
116 116
				</thead>
117 117
				<tbody>
src/usr/local/www/status_captiveportal_voucher_rolls.php
107 107
?>
108 108

  
109 109
<div class="table-responsive">
110
	<table class="table table-striped table-hover table-condensed">
111
	    <thead>
112
    		<tr>
113
    			<th><?=gettext("Roll#"); ?></th>
114
    			<th><?=gettext("Minutes/Ticket"); ?></th>
115
    			<th><?=gettext("# of Tickets"); ?></th>
116
    			<th><?=gettext("Comment"); ?></th>
117
    			<th><?=gettext("used"); ?></th>
118
    			<th><?=gettext("active"); ?></th>
119
    			<th><?=gettext("ready"); ?></th>
120
    		</tr>
110
	<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
111
		<thead>
112
    			<tr>
113
    				<th><?=gettext("Roll#"); ?></th>
114
    				<th><?=gettext("Minutes/Ticket"); ?></th>
115
    				<th><?=gettext("# of Tickets"); ?></th>
116
    				<th><?=gettext("Comment"); ?></th>
117
    				<th><?=gettext("used"); ?></th>
118
    				<th><?=gettext("active"); ?></th>
119
    				<th><?=gettext("ready"); ?></th>
120
    			</tr>
121 121
		</thead>
122 122
		<tbody>
123 123
<?php
......
130 130
				/* used also count active vouchers, remove them */
131 131
				$used = $used - $active;
132 132
?>
133
    		<tr>
134
    			<td>
135
    				<?=htmlspecialchars($rollent['number'])?>
136
    			</td>
137
    			<td>
138
    				<?=htmlspecialchars($rollent['minutes'])?>
139
    			</td>
140
    			<td>
141
    				<?=htmlspecialchars($rollent['count'])?>
142
    			</td>
143
    			<td>
144
    				<?=htmlspecialchars($rollent['comment'])?>
145
    			</td>
146
    			<td>
147
    				<?=htmlspecialchars($used)?>
148
    			</td>
149
    			<td>
150
    				<?=htmlspecialchars($active)?>
151
    			</td>
152
    			<td>
153
    				<?=htmlspecialchars($ready)?>
154
    			</td>
155
    		</tr>
133
    			<tr>
134
    				<td><?=htmlspecialchars($rollent['number'])?></td>
135
    				<td><?=htmlspecialchars($rollent['minutes'])?></td>
136
    				<td><?=htmlspecialchars($rollent['count'])?></td>
137
    				<td><?=htmlspecialchars($rollent['comment'])?></td>
138
    				<td><?=htmlspecialchars($used)?></td>
139
    				<td><?=htmlspecialchars($active)?></td>
140
    				<td><?=htmlspecialchars($ready)?></td>
141
    			</tr>
156 142
<?php
157 143
				$i++;
158 144
			endforeach;
159 145

  
160 146
			unlock($voucherlck)?>
161
	    </tbody>
147
		</tbody>
162 148
	</table>
163 149
</div>
164 150
<?php include("foot.inc");
src/usr/local/www/status_captiveportal_vouchers.php
89 89
$pgtitle = array(gettext("Status"), gettext("Captive Portal"), htmlspecialchars($a_cp[$cpzone]['zone']), gettext("Active Vouchers"));
90 90
$shortcut_section = "captiveportal-vouchers";
91 91

  
92
function clientcmp($a, $b) {
93
	global $order;
94
	return strcmp($a[$order], $b[$order]);
95
}
96

  
97 92
if (!is_array($config['voucher'][$cpzone]['roll'])) {
98 93
	$config['voucher'][$cpzone]['roll'] = array();
99 94
}
......
126 121
	}
127 122
}
128 123

  
129
if ($_GET['order']) {
130
	$order = $_GET['order'];
131
	usort($db, "clientcmp");
132
}
133

  
134 124
include("head.inc");
135 125

  
136 126
$tab_array = array();
......
145 135
<div class="panel panel-default">
146 136
	<div class="panel-heading"><h2 class="panel-title"><?=sprintf(gettext("Vouchers in Use (%d)"), count($db))?></h2></div>
147 137
	<div class="panel-body table-responsive">
148
		<table class="table table-striped table-hover table-condensed">
138
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
149 139
			<thead>
150 140
				<tr>
151
					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=0&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Voucher"); ?></a></th>
152
					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=1&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Roll"); ?></a></th>
153
					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=2&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Activated at"); ?></a></th>
154
					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=3&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Expires in"); ?></a></th>
155
					<th><a href="?zone=<?=htmlspecialchars($cpzone)?>&amp;order=4&amp;showact=<?=htmlspecialchars($_GET['showact'])?>"><?=gettext("Expires at"); ?></a></th>
141
					<th><?=gettext("Voucher"); ?></th>
142
					<th><?=gettext("Roll"); ?></th>
143
					<th><?=gettext("Activated at"); ?></th>
144
					<th><?=gettext("Expires in"); ?></th>
145
					<th><?=gettext("Expires at"); ?></th>
156 146
				</tr>
157 147
			</thead>
158 148
			<tbody>
......
160 150
foreach ($db as $dbent):
161 151
?>
162 152
				<tr>
163
					<td><?=$dbent[0]?></td>
164
					<td><?=$dbent[1]?></td>
153
					<td><?=htmlspecialchars($dbent[0])?></td>
154
					<td><?=htmlspecialchars($dbent[1])?></td>
165 155
					<td><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[2]))?></td>
166
					<td><?=$dbent[3]?><?=gettext("min"); ?></td>
156
					<td><?=htmlspecialchars($dbent[3])?><?=gettext("min"); ?></td>
167 157
					<td><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[4]))?></td>
168 158
				</tr>
169 159
<?php

Also available in: Unified diff