-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrichiesta-preventivo.php
322 lines (311 loc) · 11.6 KB
/
richiesta-preventivo.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<?php
//recupero dati dall'url
$data = $_GET['dati'];
$pieces = explode(";", $data);
$id = $pieces['0'];
$desc = $pieces['1'];
$rif = $pieces['2'];
//connessione al db
$conn = mysql_connect("192.168.1.1:3306", "userName", "pwd") or die ('Errore di connessione al server: ' . mysql_error());
mysql_select_db("dbName", $conn) or die ('Errore di connessione al db: ' . mysql_error());
?>
<html>
<head>
<title>
Richiesta preventivo
</title>
<script type="text/javascript">
function inviaDati() {
//validazione dei campi
if( document.preventivo.qta.value == "" )
{
alert( "Inserire la quantità!" );
document.preventivo.qta.focus() ;
return false;
}
//si setta il campo hidden dati con il valore quantità
document.preventivo.dati.value = document.preventivo.qta.value;
if( document.preventivo.colore.value == "0" )
{
alert( "Selezionare il colore!" );
return false;
}
//si aggiunge al campo hidden dati il colore selezionato
document.preventivo.dati.value = document.preventivo.qta.value + ";" + document.preventivo.colore.value;
if( document.preventivo.fronte.value == "0" )
{
alert( "Selezionare i colori fronte!" );
return false;
}
//si aggiunge al campo hidden dati il colore fronte selezionato
document.preventivo.dati.value = document.preventivo.qta.value + ";" + document.preventivo.colore.value + ";" + document.preventivo.fronte.value;
if( document.preventivo.retro.value == "0" )
{
alert( "Selezionare i colori retro!" );
return false;
}
//si aggiunge al campo hidden dati il colore retro selezionato
document.preventivo.dati.value = document.preventivo.qta.value + ";" + document.preventivo.colore.value + ";" + document.preventivo.fronte.value +
";" + document.preventivo.retro.value;
if( document.preventivo.dx.value == "0" )
{
alert( "Selezionare i colori manica destra!" );
return false;
}
//si aggiunge al campo hidden dati il colore dx selezionato
document.preventivo.dati.value = document.preventivo.qta.value + ";" + document.preventivo.colore.value + ";" + document.preventivo.fronte.value +
";" + document.preventivo.retro.value + ";" + document.preventivo.dx.value;
if( document.preventivo.sx.value == "0" )
{
alert( "Selezionare i colori manica sinistra!" );
return false;
}
//si aggiunge al campo hidden dati il colore sx selezionato
document.preventivo.dati.value = document.preventivo.qta.value + ";" + document.preventivo.colore.value + ";" + document.preventivo.fronte.value +
";" + document.preventivo.retro.value + ";" + document.preventivo.dx.value + ";" + document.preventivo.sx.value;
if( document.preventivo.nome.value == "" )
{
alert( "Inserire il nome!" );
document.preventivo.nome.focus() ;
return false;
}
//si aggiunge al campo hidden dati il nome inserito
document.preventivo.dati.value = document.preventivo.qta.value + ";" + document.preventivo.colore.value + ";" + document.preventivo.fronte.value +
";" + document.preventivo.retro.value + ";" + document.preventivo.dx.value + ";" + document.preventivo.sx.value +
";" + document.preventivo.nome.value;
if( document.preventivo.cognome.value == "" )
{
alert( "Inserire il cognome!" );
document.preventivo.cognome.focus() ;
return false;
}
//si aggiunge al campo hidden dati il cognome inserito
document.preventivo.dati.value = document.preventivo.qta.value + ";" + document.preventivo.colore.value + ";" + document.preventivo.fronte.value +
";" + document.preventivo.retro.value + ";" + document.preventivo.dx.value + ";" + document.preventivo.sx.value +
";" + document.preventivo.nome.value + ";" + document.preventivo.cognome.value;
if( document.preventivo.email.value == "" )
{
alert( "Inserire l'email!" );
document.preventivo.email.focus() ;
return false;
}
//si aggiunge al campo hidden dati l'email inserito
document.preventivo.dati.value = document.preventivo.qta.value + ";" + document.preventivo.colore.value + ";" + document.preventivo.fronte.value +
";" + document.preventivo.retro.value + ";" + document.preventivo.dx.value + ";" + document.preventivo.sx.value +
";" + document.preventivo.nome.value + ";" + document.preventivo.cognome.value + ";" + document.preventivo.email.value;
if( document.preventivo.telefono.value == "" )
{
alert( "Inserire il telefono!" );
document.preventivo.telefono.focus() ;
return false;
}
//si setta il campo hidden con il valore finale - aggiunto il tel e le note (campo facoltativo) inserite
document.preventivo.dati.value = document.preventivo.id.value + ";" + document.preventivo.riferimento.value + ";" + document.preventivo.descrizione.value +
";" + document.preventivo.qta.value + ";" + document.preventivo.colore.value + ";" + document.preventivo.fronte.value +
";" + document.preventivo.retro.value + ";" + document.preventivo.dx.value + ";" + document.preventivo.sx.value +
";" + document.preventivo.nome.value + ";" + document.preventivo.cognome.value + ";" + document.preventivo.email.value +
";" + document.preventivo.telefono.value + ";" + document.preventivo.note.value;
if( !document.preventivo.consenso.checked )
{
alert( "Si deve dare il consenso al trattamento dei dati personali!" );
document.preventivo.consenso.focus() ;
return false;
}
alert ( document.preventivo.dati.value );
//validazione return true -> action e submit
document.forms["preventivo"].action = "richiesta-preventivo-sendmail.php";
document.forms["preventivo"].submit();
}
</script>
<style>
</style>
</head>
<body>
<form id="preventivo" name="preventivo" method="post">
<center>
<table width="40%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td> </td>
<td>
<div class="titoloazzurro" style="font-weight: bold; color: #48CA0D; font-size: 21px;"><center>RICHIESTA PREVENTIVO:</center></div>
<input type="hidden" id="id" name="id" value="<?php echo $id?>" />
<input type="hidden" id="riferimento" name="riferimento" value="<?php echo $rif?>" />
<input type="hidden" id="descrizione" name="descrizione" value="<?php echo $desc?>" />
<input type="hidden" id="dati" name="dati" value="" />
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td colspan="2" height="15px"> </td>
</tr>
<tr>
<td style="text-align:left;font-weight: bold; color: #000; font-size: 14px;">Id prodotto: <?php echo "<font color='#0DE0E1'>".$id."</font>"?></td>
<td style="text-align:left;font-weight: bold; color: #000; font-size: 14px;">Riferimento: <?php echo "<font color='#0DE0E1'>".$rif."</font>"?></td>
</tr>
<tr>
<td colspan="2" style="text-align:left;font-weight: bold; color: #000; font-size: 14px;">Descrizione: <?php echo "<font color='#0DE0E1'>".$desc."</font>"?></td>
</tr>
</table>
</td>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
<td style="font-weight: bold; color: #EC1B23; text-align:center;">DATI PRODOTTO</td>
<td> </td>
</tr>
<tr>
<td colspan="3" height="30"> </td>
</tr>
<tr>
<td>
<strong>Quantità</strong><br />
<input name="qta" type="text" id="qta" size="5"/>
</td>
<td> </td>
<td>
<strong>Colore</strong><br />
<?php
$query = "SELECT a.color, b.name FROM ps_attribute a, ps_attribute_lang b
WHERE a.id_attribute = b.id_attribute AND a.id_attribute IN
(SELECT id_attribute
FROM ps_product_attribute_combination
WHERE id_product_attribute IN (SELECT id_product_attribute
FROM ps_product_attribute
WHERE id_product = $id))";
// query andata a buon fine
if($result = mysql_query($query)) {
// ci sono risultati, si prepara la combobox
if($ok = mysql_num_rows($result) > 0) {
//--- inizio combobox colori ---
echo "<select name='colore' id='colore'>\n";
echo "<option value='0' selected='selected'>-- Seleziona --</option>\n";
// per ogni item nel $result...
while ($row = mysql_fetch_array($result))
// si aggiunge una nuova option alla combobox
echo "<option style='background-color: $row[color]' value='$row[color] - $row[name]'>$row[name]</span></option>\n";
//--- fine combobox colori ---
echo "</select>\n";
}
// dalla query non ritorna nulla
else { echo "Non ci sono risultati dalla query"; }
}
// errore query
else { echo "Query colori non andata a buon fine"; }
?>
</td>
</tr>
<tr>
<td>
<strong>Colori Stampa-fronte</strong><br />
<select id="fronte" name="fronte" >
<option value="0" selected="selected">-- Seleziona --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td>
<td> </td>
<td>
<strong>Colori Stampa-retro</strong><br />
<select id="retro" name="retro" >
<option value="0" selected="selected">-- Seleziona --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td>
</tr>
<tr>
<td>
<strong>Colori manica dx</strong><br />
<select id="dx" name="dx" >
<option value="0" selected="selected">-- Seleziona --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td>
<td> </td>
<td>
<strong>Colori manica sx</strong><br />
<select name="sx" id="sx">
<option value="0" selected="selected">-- Seleziona --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td>
</tr>
<tr>
<td colspan="3" height="20"> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td> </td>
<td style="font-weight: bold; color: #EC1B23; text-align:center;">DATI PERSONALI</td>
<td> </td>
</tr>
<tr>
<td colspan="3" height="30"> </td>
</tr>
<tr>
<td>
<strong>Nome</strong><br />
<input type="text" id="nome" name="nome" />
</td>
<td> </td>
<td>
<strong>Cognome</strong><br />
<input type="text" id="cognome" name="cognome" />
</td>
</tr>
<tr>
<td>
<strong>Email</strong><br />
<input type="text" id="email" name="email" />
</td>
<td> </td>
<td>
<strong>Telefono</strong><br />
<input type="text" id="telefono" name="telefono" /></td>
</tr>
<tr>
<td colspan="3">
<strong>Note</strong><br />
<textarea id="note" name="note" cols="80" rows="5"></textarea>
</td>
</tr>
<tr>
<td colspan="3"><input type="checkbox" id="consenso" name="consenso" value="1">
<font color="#EC1B23">Consenso al trattamento dei dati personali e sensibili ai sensi nuovo T.U. Privacy (D.Lgs. 196/03).</font><br />
</td>
</tr>
<tr>
<td colspan="3">
<div align="center">
<input type="button" id="invia" name="invia" value="Invia" onClick="inviaDati();"/>
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div align="center">
<input type="button" id="back" name="back" value="Indietro" onClick="history.back();"/>
</div>
</td>
</tr>
</table>
</center>
</form>
</body>
</html>