-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadmin.php
290 lines (245 loc) · 7.36 KB
/
admin.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<?php include "header.php"; ?>
<body>
<?php include "menu/me_admin.php"; ?>
<?php
//verifica se admin
if(!isset($user->caps['administrator'])){ ?>
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
<h1>Você não tem permissão para acessar esta página.</h1>
</main>
<?php
}else{ // se tiver autorização para acessar a página
if(isset($_GET['p'])){
$p = $_GET['p'];
}else{
$p = 'inicio';
}
switch($p){
case "inicio" :
?>
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
<h1>Bem-vindo!</h1>
</main>
<?php
break;
case "inserir_edital":
?>
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
<h1>Inserir Edital</h1>
<div class="col-md-offset-1 col-md-10">
<form class="form-horizontal" role="form" method="post" action="?p=editar_edital" >
<div class="form-group">
<label>Título do Edital</label>
<input type="text" class="form-control" name="edital" />
</div>
<div class="form-group">
<label>ID do Projeto no Mapas Culturais</label>
<input type="text" class="form-control" name="id_mapas" />
</div>
<div class="form-group">
<label>Número de fases</label>
<input type="text" class="form-control" name="fases" />
</div>
<div class="form-group">
<input type="hidden" name="inserir" value="1" />
<input type="submit" value="Inserir Edital" class="btn btn-theme btn-lg btn-block" />
</div>
</div>
</form>
</main>
<?php
break;
case "editar_edital";
global $wpdb;
if(isset($_POST['edital'])){
$edital = $_POST['edital'];
$id_mapas = $_POST['id_mapas'];
$fases = $_POST['fases'];
}
if(isset($_POST['inserir'])){ //inserir
$sql_inserir = "INSERT INTO `ava_edital` (`id`, `edital`, `id_mapas`, `fases`, `publicado`)
VALUES (NULL, '$edital', '$id_mapas', '$fases', '1')";
$inserir = $wpdb->query($sql_inserir);
$id_edital = $wpdb->insert_id;
$ed = $wpdb->get_row("SELECT * FROM ava_edital WHERE id = '$id_edital'",ARRAY_A);
}
if(isset($_POST['atualizar'])){ //atualizar
$id_atualizar = $_POST['atualizar'];
$sql_atualizar = "UPDATE `ava_edital` SET
`edital` = '$edital',
`id_mapas` = '$id_mapas',
`fases` = '$fases'
WHERE `id` = '$id_atualizar'";
$atualizar = $wpdb->query($sql_atualizar);
$ed = $wpdb->get_row("SELECT * FROM ava_edital WHERE id = '$id_atualizar'",ARRAY_A);
}
if(isset($_POST['edit_atualizar'])){
$id_atualizar = $_POST['edit_atualizar'];
$ed = $wpdb->get_row("SELECT * FROM ava_edital WHERE id = '$id_atualizar'",ARRAY_A);
}
?>
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
<h1>Atualizar Edital</h1>
<h2><?php //var_dump($atualizar); echo $sql_atualizar; ?></h2>
<div class="col-md-offset-1 col-md-10">
<form class="form-horizontal" role="form" method="post" action="?p=editar_edital" >
<div class="form-group">
<label>Título do Edital</label>
<input type="text" class="form-control" name="edital" value="<?php echo $ed['edital']; ?>" />
</div>
<div class="form-group">
<label>ID do Projeto no Mapas Culturais</label>
<input type="text" class="form-control" name="id_mapas" value="<?php echo $ed['id_mapas']; ?>"/>
</div>
<div class="form-group">
<label>Número de fases</label>
<input type="text" class="form-control" name="fases" value="<?php echo $ed['fases']; ?> "/>
</div>
<div class="form-group">
<input type="hidden" name="atualizar" value="<?php echo $ed['id']; ?> "/>
<input type="submit" value="Atualizar Edital" class="btn btn-theme btn-lg btn-block">
</div>
</form>
<div class="form-group">
<form class="form-horizontal" role="form" method="post" action="?p=avaliadores" >
<input type="hidden" name="id_edital" value="<?php echo $ed['id']; ?> "/>
<input type="submit" value="Avaliadores" class="btn btn-theme btn-lg btn-block">
</form>
</div>
<div class="form-group">
<input type="hidden" name="atualizar" value="<?php echo $ed['id']; ?> "/>
<input type="submit" value="Subir Planilha de Inscrições " class="btn btn-theme btn-lg btn-block">
</div>
</div>
</main>
<?php
break;
case "listar_edital":
?>
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
<h1>Listar Editais</h1>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>ID MAPAS</th>
<th>Título</th>
<th>Período de Avaliação</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$edit = editais($user->ID);
for($i = 0; $i < count($edit); $i++){
?>
<tr>
<td><?php //echo $i; ?></td>
<td><?php echo $edit[$i]['mapas']; ?></td>
<td><?php echo $edit[$i]['titulo']; ?></td>
<td><?php echo $edit[$i]['periodo']; ?></td>
<td>
<form class="form-horizontal" role="form" method="post" action="?p=editar_edital" >
<input type="hidden" name="edit_atualizar" value="<?php echo $edit[$i]['id']; ?> "/>
<input type="submit" value="Editar" class="btn btn-theme btn-lg btn-block">
</form>
<?php //echo $edital[0]['periodo']; ?>
</td>
<td>
<input type="hidden" name="atualizar" value="<?php echo $ed['id']; ?> "/>
<input type="submit" value="Apagar" class="btn btn-theme btn-lg btn-block">
<?php //echo $edital[0]['periodo']; ?>
</td>
</tr>
<?php
} ?>
</tbody>
</table>
</div>
</main>
<?php
break;
case "avaliadores":
if(isset($_POST['id_edital'])){
$id_atualizar = $_POST['id_edital'];
$edit = editais("",$_POST['id_edital']);
}
?>
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
<h1>Avaliadores - <?php echo $edit[0]['titulo']; ?></h1>
<h2></h2>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Nome Completo</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$args = array('role' => 'administrator,avaliador');
$users = get_users($args);
var_dump($users);
for($i = 0; $i < count($edit); $i++){
?>
<tr>
<td><?php //echo $i; ?></td>
<td><?php echo $edit[$i]['mapas']; ?></td>
<td><?php echo $edit[$i]['titulo']; ?></td>
<td><?php echo $edit[$i]['periodo']; ?></td>
</tr>
<?php
} ?>
</tbody>
</table>
</div>
</main>
<?php
break;
case "usuario":
?>
<main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
<h1>Usuários</h1>
<h2></h2>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Nome Completo</th>
</tr>
</thead>
<tbody>
<?php
$args = array();
$users = get_users( array( 'fields' => array('ID') ) );
foreach($users as $user_id){
$user_meta = get_user_meta ( $user_id->ID);
$user_data = get_userdata( $user_id->ID );
?>
<tr>
<td><?php echo $user_id->ID; ?></td>
<td><?php echo $user_data->display_name; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</main>
<?php
break;
}
?>
<?php } //fim da validação do usuário ?>
</div>
</div>
<?php
include "footer.php";
?>