-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage_quals.php
159 lines (142 loc) · 4.27 KB
/
manage_quals.php
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
ob_start(); // Output buffering - allows header rewrites to happen at anytime before flushing the buffer
session_start();
require_once("incdir.php.inc");
require_once("config.php");
include_php_dir("includes");
mysql_init();
document_header();
echo include_javascript_dir("js",$debug);
echo include_stylesheet_dir("stylesheets",$debug);
check_validated();
//Any pre-page logic should go here!
if (isset($_POST['qual-input-submit'])){
echo 'new qual submitted';
$qualinfo = array();
$qualinfo['name'] = $_POST['qual_name'];
$qualinfo['url'] = $_POST['qual_url'];
$qualinfo['level'] = $_POST['qual_level'];
$qualinfo['value'] = $_POST['qual_value'];
add_qual($qualinfo);
}
open_page("Manage Quals");
draw_page();
close_page();
ob_end_flush(); // Flush the buffer out to client
document_footer(); mysql_end();
function draw_page()
{
?>
<div class="container">
<?php open_panel("qual_table","List of Quals", false); ?>
<?php draw_quals_table(); ?>
<?php close_panel(); ?>
<?php open_panel("qual_input","Add a New Qual", false); ?>
<?php draw_quals_input_form(); ?>
<?php close_panel(); ?>
</div>
<?
}
function draw_quals_table() {
$quals = get_quals(true);
?>
<div class="col-md-10">
<table class="table table-condensed">
<tr>
<th>Name</th>
<th>Level</th>
<th>Value</th>
<th>URL</th>
</tr>
<?php
while($qual = $quals->fetch_array()) {
//Convert the level to the appropriate name
$qual['level']=qual_level_to_levelname($qual['level']);
echo '<tr class='.'"quallist';
if ($qual['inactive']==1) //If the qual is inactive, this will add "inactive" to its class
echo ' quallist-inactive';
echo '" onclick="openEdit('.$qual['qual_id'].')">';
echo '<td>'.$qual['name'].'</td>';
echo '<td>'.ucfirst($qual['level']).'</td>';
echo '<td>'.$qual['value'].'</td>';
echo '<td><a href="'.$qual['url'].'"> <span class="glyphicon glyphicon-link"></span></a></td>';
echo '</tr>';
}
?>
<tr>
<td colspan=2>Total Value</td>
<td><?php echo get_qual_point_total(); ?></td>
<td></td>
</table>
</div>
<div class="col-md-2">
<button class="btn btn-default btn-sm" onclick="toggleinactive()">Toggle inactives</button>
</div>
<?php
}
function draw_quals_input_form() {
?>
<form role="form" method="post">
<div class="col-xs-6">
<div class="col-xs-6">
<div class="form-group">
<label for="qual_name">Name</label>
<input type="text" class="form-control" id="qual_name" name="qual_name" />
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label for="qual_url">url</label>
<input type="text" class="form-control" id="qual_url" name="qual_url" />
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label for="qual_level">Level</label>
<select class="form-control" type="text" id="qual_level" name="qual_level">
<option value="0">Page</option>
<option value="1">Squire</option>
<option value="2">Specialist</option>
</select>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label for="qual_value">Qual Value</label>
<select class="form-control" type="text" id="qual_value" name="qual_value">
<option value="50">50</option>
<option value="75">75</option>
<option value="100">100</option>
</select>
</div>
</div>
<input type="hidden" name="qual-input-submit" value="true">
<button type="submit" class="btn btn-default pull-right">Submit</button>
</div>
<div class="col-xs-6">
<p>Enter the qual details in the menu to the left
</p>
</div>
</form>
<?
}
?>
<!-- JS to show inactive users if a button is clicked -->
<script type="text/javascript">
function toggleinactive() {
var inactives = document.getElementsByClassName("quallist-inactive");
for(var i=0; i<inactives.length; i++) {
if( inactives[i].style.display=="table-row")
inactives[i].style.display="none";
else
inactives[i].style.display="table-row";
}
}
</script>
<!-- also, don't forget password mismatch js -->
<!-- popup javascript -->
<script type="text/javascript">
function openEdit(id) {
window.open('edit_qual.php?qual_id='+id,'_blank','height=540,width=680,menubar=no,status=no,titlebar=no,toolbar=no');
}
</script>