-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsettingsAzienda.php
213 lines (178 loc) · 8.3 KB
/
settingsAzienda.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
<?php
session_start();
define("INCLUDING", 'TRUE');
include('config.php');
//include_once 'configurazioneDB.php';
include_once 'database.php';
require_once (METHODS_PATH . '/azienda.class.php');
$db = Database::getInstance();
$mysqli = $db->getConnection();
?>
<!DOCTYPE html>
<html>
<head>
<title> | Borsa delle Idee | Modifica</title>
<?php include(TEMPLATES_PATH.'/head.php');
?>
<script type="text/javascript">
function carica() {
var x = document.getElementById("nazione").value;
x= x.toLowerCase();
x= x.replace(' ', '');
if(x=='italiana'|| x=='italia'|| x=='italy')
{
document.getElementById("prov").style.display="block";
}
else{
document.getElementById("prov").style.display="none";
document.getElementById("provincia").value="";
}
}
</script>
<script type="text/javascript">
function myFunction() {
var x = document.getElementById("nazione").value;
x= x.toLowerCase();
x= x.replace(' ', '');
if(x=='italiana'|| x=='italia'|| x=='italy')
{
document.getElementById("prov").style.display="block";
}
else{
document.getElementById("prov").style.display="none";
document.getElementById("provincia").value="";
}
}
</script>
</head>
<body onload="carica()">
<div class="container">
<?php include (TEMPLATES_PATH.'/navbar.php'); ?>
<?php // controllo se � stato impostato l id per evitare che accedano direttamente senza fare il login
if( !isset($_SESSION['loggeduser']) )
header("Location: index.php");
// Ricavo tutte le informazioni sull azienda che mi interessa tramite l id
$id=$_SESSION['loggeduser']->getid();
$_SESSION['ID']=$id;
$sql = "SELECT * FROM UTENTI JOIN AZIENDE ON ID_UTENTE=ID WHERE ID='".$id."'";
$result=$mysqli->query($sql);
$dati=$result->fetch_assoc();
// tutti i dati son messi nelll array dati
//prendo il nome della provincia selezionato per metterlo nella dropdown come default
$sql = "SELECT NOME FROM PROVINCE JOIN AZIENDE ON CODICE=PROVINCIA WHERE ID_UTENTE='".$id."'";
$result=$mysqli->query($sql);
$dati_nome=$result->fetch_assoc();
//prendo tutte le informazioni riguradanti i contatti
$SQLcont="SELECT * FROM CONTATTI JOIN AZIENDE ON ID_UTENTE=PROPRIETARIO WHERE PROPRIETARIO='".$id."'";
$result_cont=$mysqli->query($SQLcont);
// tutti i valori saranno memorizzati nell array dati_cont
$dati_cont=$result_cont->fetch_assoc();
//per sapere le province
$SQLprov="SELECT * FROM PROVINCE WHERE NOME IS NOT NULL AND NOME<>'".$dati_nome['NOME']."';";
$result_prov=$mysqli->query($SQLprov);
// tutti i valori saranno memorizzati nell array dati_prov
// per conoscere le persone che lavorano nell azienda
$SQLpers="SELECT NOME,COGNOME FROM PERSONE JOIN AZIENDE A ON A.ID_UTENTE=AZIENDA WHERE AZIENDA='".$id."'";
$result_pers=$mysqli->query($SQLpers);
//per le idee sviluppate dagli utenti dell azienda
$SQLidee="SELECT TITOLO,P.ID_UTENTE FROM IDEE JOIN PERSONE P ON CREATORE=P.ID_UTENTE JOIN AZIENDE A ON AZIENDA=A.ID_UTENTE WHERE A.ID_UTENTE='".$id."'";
$result_idee=$mysqli->query($SQLidee);
?>
<div class="col-sm-offset-2 col-sm-8">
<div class="user-info well panel panel-default">
<h4>Modifica i tuoi dati</h4>
<ul class="nav nav-tabs" id="mioTab">
<li class="active"><a href="#personale" data-toggle="tab">Personale</a></li>
<li><a href="#contatti" data-toggle="tab">Contatti</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="personale"><h1></h1>
<form method="post" name="registra" action="emodifica.php" id="registra">
<fieldset class="form-group">
<label for="Nome">Ragione Sociale</label>
<input type="nome" required class="form-control" id="nome" name="nome" value='<?php echo $dati["RAGIONE_SOCIALE"]; ?>' >
</fieldset>
<fieldset class="form-group">
<label for="immagine">Immagine</label>
<input type="file" class="form-control" name="immagine" id="immagine">
</fieldset>
<fieldset class="form-group">
<label for="cap">Cap</label>
<input type="tel" required pattern="[0-9]{1,15}" id="cap" name="cap" value='<?php echo $dati["CAP"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for="indirizzo">Indirizzo</label>
<input type="indirizzo" required class="form-control" id="indirizzo" name="indirizzo" value='<?php echo $dati["INDIRIZZO"]; ?>' >
</fieldset>
<fieldset class="form-group">
<label for="citta">Citta</label>
<input type="text" required class="form-control" id="citta" name="citta" value='<?php echo $dati["CITTA"]; ?>'>
</fieldset>
<fieldset class="form-group">
<div id='prov' class="col-sm-6 form-group" style="display: none;">
<label for="provincia">Province</label>
<select class="form-control" id='provincia' name="provincia" >
<option value="" selected><?php echo $dati_nome['NOME'];?> </option>
<?php
while ($row = mysqli_fetch_assoc($result_prov) ){
echo "<option id='$row[CODICE]'>$row[NOME]</option>";
}
?>
</select> </div>
</fieldset>
<fieldset class="form-group">
<label for="Regione">Regione </label>
<input type="text" required class="form-control" id="regione" name="regione" value='<?php echo $dati["REGIONE"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for=nazione>Nazione </label>
<input type="text" required class="form-control" oninput="myFunction()" id="nazione" name="nazione" value='<?php echo $dati["NAZIONE"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for=nazione>Partita Iva </label>
<input type="text" required class="form-control" id="partita_iva" name="partita_iva" value='<?php echo $dati["PARTITA_IVA"]; ?>'>
</fieldset>
</div>
<div class="tab-pane" id="contatti"><h1></h1>
<fieldset class="form-group">
<label for=nazione>Telefono </label>
<input type="tel" pattern="[0-9]{1,15}" required class="form-control" id="telefono" name="telefono" value='<?php echo $dati_cont["TELEFONO"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for=nazione>Cellulare </label>
<input type="tel" pattern="[0-9]{1,15}" class="form-control" id="cellulare" name="cellulare" value='<?php echo $dati_cont["CELLULARE"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for="fax">Fax </label>
<input type="tel" pattern="[0-9]{1,15}" class="form-control" id="fax" name="fax" value='<?php echo $dati_cont["FAX"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for="facebook">Facebook</label>
<input type="text" class="form-control" id="facebook" name="facebook" value='<?php echo $dati_cont["FACEBOOK"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for="twitter">Twitter</label>
<input type="text" class="form-control" id="twitter" name="twitter" value='<?php echo $dati_cont["TWITTER"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for="linkedin">Linkedin</label>
<input type="text" class="form-control" id="linkedin" name="linkedin" value='<?php echo $dati_cont["LINKEDIN"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for="sito_web">Sito web</label>
<input type="text" class="form-control" id="sito_web" name="sito_web" value='<?php echo $dati_cont["SITO_WEB"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for="email">Email</label>
<input type="text" class="form-control" id="email" name="email" value='<?php echo $dati["EMAIL"]; ?>'>
</fieldset>
<fieldset class="form-group">
<label for="parlaci">Maggiori dettagli</label>
<textarea class="form-control" id="descrizione" name="descrizione" rows="3"><?php echo $dati["DESCRIZIONE"];?></textarea>
</fieldset>
</div>
<input id="aggiorna" value="AGGIORNA" type="submit" name="aggiorna"></td>
</form>
</div>
</div>
</div>