-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_section.php
98 lines (71 loc) · 2.55 KB
/
admin_section.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
<?php
session_start();
require "include/template2.inc.php";
require "include/dbms.inc.php";
global $conn;
$main = new Template("skins/admin/dtml/index.html");
$body = new Template("skins/admin/dtml/section.html");
$pagina = $_GET['pagina'];
$main->setContent('nome',$_SESSION['auth']['utente']['nome']);
$main->setContent('cognome',$_SESSION['auth']['utente']['cognome']);
$main->setContent('pagine','active');
$body->setContent('page', $pagina);
$pagine = $conn->query("SELECT nome as nome_pagina FROM pagina");
if ($pagine) {
if ($pagine->num_rows > 0) {
while ($row = $pagine->fetch_assoc()) {
foreach ($row as $key => $value) {
$main->setContent($key, $value);
}
}
}
}
$main->setContent('numero', $pagine->num_rows);
$noleggi = $conn->query("SELECT COUNT(*) as numero_noleggi FROM noleggio WHERE stato <> 'Terminato'");
if($noleggi){
if ($noleggi->num_rows > 0) {
$row = $noleggi->fetch_assoc();
$main->setContent('numero_noleggi', $row['numero_noleggi']);
}
}
$section = $conn->query("SELECT s.id AS id_section, sp.ordine, s.nome AS nome_section
FROM section s JOIN section_pagina sp ON s.id = sp.id_section
JOIN pagina p ON sp.id_pagina = p.id WHERE p.nome='$pagina'");
$sezioni = [];
$ordini = [];
if($section) {
if ($section->num_rows > 0) {
while ($row = $section->fetch_assoc()) {
$i = $row['id_section'];
$sezioni[$i] = $row['nome_section'];
$ordini[$row['nome_section']] = $row['ordine'];
}
}
}
$sections = $conn->query("SELECT id, nome FROM section");
$num_sezioni = $sections->num_rows;
if ($sections) {
if ($num_sezioni > 0) {
while ($row2 = $sections->fetch_assoc()) {
$nome_sezione = $row2['nome'];
$body->setContent('pagina', $pagina);
$body->setContent('nome_section', $nome_sezione);
$ord = 0;
if(array_key_exists($nome_sezione, $ordini)) {
$ord = $ordini[$nome_sezione];
}
if($ord != 0) {
$body->setContent('ordine', 0);
}
for($ordine = 1;$ordine<= $num_sezioni;$ordine++) {
if($ordine != $ord) {
$body->setContent('ordine', $ordine);
}
}
$body->setContent('ordineSel', $ord);
}
}
}
$main->setContent('content',$body->get());
$main->close();
?>