-
Notifications
You must be signed in to change notification settings - Fork 3
/
aggiungiStrumentazione.php
111 lines (110 loc) · 5.61 KB
/
aggiungiStrumentazione.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
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . "toolkit.php";
require_once __DIR__ . DIRECTORY_SEPARATOR . "dbconn.php";
if (session_status() == PHP_SESSION_NONE){
session_start();
}
checkLoggedAdmin();
$content = file_get_contents(__("struttura.html"));
initBreadcrumbs($content, "Home", "index.php");
if (isset($_SESSION['language']) && $_SESSION['language']=='en'){
setTitle($content, "Add Instrumentation");
addBreadcrumb($content, "Admin Panel", "admin.php");
addBreadcrumb($content, "Add Instrumentation", "");
}else{
setTitle($content, "Aggiungi Nuova Strumentazione");
addBreadcrumb($content, "Pannello Amministrativo", "admin.php");
addBreadcrumb($content, "Aggiungi Strumentazione", "");
}
setUserStatus($content);
setupMenu($content, 0);
setAdminArea($content);
setLangArea($content, $_SERVER['PHP_SELF']);
setContentFromFile($content, __("struttura_aggiungiStrumentazione.html"));
$nome = "";
$costo = "";
$desc = "";
$disp = "";
$imgname = "";
$imgalt = "";
$engdesc = "";
$engalt = "";
if (isset($_POST['inserimento'])){
$dbAccess = new DBAccess();
$dbconn = $dbAccess->openDBConnection();
if ($dbconn == false){
die ("Errore nella connessione al database");
}else{
$moneyCheck = checkMoneyInput($_POST['Costo']);
$dispCheck = checkQtyInput($_POST['Disp']);
$formatCheck = checkFileFormatInput($_POST['imgname']);
if ($moneyCheck && $dispCheck && $formatCheck){
$result = $dbAccess->insertInstrument($_POST['NomeS'], $_POST['Costo'], $_POST['Desc'], $_POST['Disp'], $_POST['imgname'], $_POST['imgalt'], $_POST['EngDesc'], $_POST['EngAlt']);
if ($result == ""){
$status = "<div class='statussuccess'>" . getMessage("13") . "</div>";
}else{
$status = "<div class='statusfailed'>". getMessage($result) . "</div>";
$nome = $_POST['NomeS'];
$costo = $_POST['Costo'];
$desc = $_POST['Desc'];
$disp = $_POST['Disp'];
$imgname = $_POST['imgname'];
$imgalt = $_POST['imgalt'];
$engdesc = $_POST['EngDesc'];
$engalt = $_POST['EngAlt'];
}
}else{
$status = "<div class='statusfailed'>". getMessage("217") . $result;
if (isset($_SESSION['qtyErrors'])){
$status = $status . '<br /><a href="#Disp" title="' . getMessage("110") . '">' . $_SESSION["qtyErrors"] . "</a>";
}
if (isset($_SESSION['moneyErrors'])){
$status = $status . '<br /><a href="#Costo" title="' . getMessage("111") . '">' . $_SESSION["moneyErrors"] . "</a>";
}
if (isset($_SESSION['formatErrors'])){
$status = $status . '<br /><a href="#imgname" title="' . getMessage("112") . '">' . $_SESSION["formatErrors"] . "</a>";
}
$status = $status . "</div>";
$nome = $_POST['NomeS'];
$costo = $_POST['Costo'];
$desc = $_POST['Desc'];
$disp = $_POST['Disp'];
$imgname = $_POST['imgname'];
$imgalt = $_POST['imgalt'];
$engdesc = $_POST['EngDesc'];
$engalt = $_POST['EngAlt'];
}
$content = str_replace("<!--STATUS-->", $status, $content);
$dbAccess->closeDBConnection();
}
}
$content = str_replace("<!--VALOREDESC-->", $desc, $content);
$content = str_replace("<!--VALOREDESC_EN-->", $engdesc, $content);
$xml = new DOMDocument();
$xml->loadHTML($content);
$qerr=false;
$merr=false;
$ferr = false;
if (isset($_SESSION['qtyErrors'])){
$qerr = $_SESSION['qtyErrors'];
unset($_SESSION['qtyErrors']);
}
if (isset($_SESSION['moneyErrors'])){
$merr = $_SESSION['moneyErrors'];
unset($_SESSION['moneyErrors']);
}
if (isset($_SESSION['formatErrors'])){
$ferr = $_SESSION['formatErrors'];
unset($_SESSION['formatErrors']);
}
prefillAndHighlight("NomeS", false, $xml, $nome);
prefillAndHighlight("Costo", $merr, $xml, $costo);
prefillAndHighlight("Disp", $qerr, $xml, $disp);
prefillAndHighlight("imgname", $ferr, $xml, $imgname);
prefillAndHighlight("imgalt", false, $xml, $imgalt);
prefillAndHighlight("EngAlt", false, $xml, $engalt);
setHTMLNameSpaces($xml);
$content = $xml->saveXML($xml->documentElement);
addXHTMLdtd($content);
echo($content);
?>