1<?
2 curFile.cache = false
3
4 include("/included/lang/order1.bfr") // DA SPOSTARE
5
6
7 if(!cookie.Get("CID")) // Il cart ID NON esiste
8 {
9 request.Redirect("/error.bfr?pID=O1NOCID")
10 }
11
12 if(userID = cookie.Get("UID")) // Se e' loggato, lo mando alla login
13 request.Redirect(langBaseUrl + "/login/")
14
15 campi = array("ragSoc", "cfPiva", "cognome", "nome", "indirizzo", "civico", "cap", "citta", "prov", "nazione", "telefono", "cellulare", "fax", "email", "password", "destinatario", "indirizzoDest", "civicoDest", "capDest", "cittaDest", "provDest", "nazioneDest", "telefonoDest", "regalo", "prefisso", "saleType")
16 for(a=1; a<=campi.dim; a++)
17 {
18 // Se il valore non esiste, creo la variabile vuota
19 if(!curScript.IsDef(campi[a]))
20 {
21 texto = campi[a] + " = \"\""
22 Eval(texto)
23 }
24 }
25 if(curScript.IsDef("tag") && tag == "registra")
26 {
27 compilati = array(
28 "la ragione sociale":ragSoc.Substitute(",",""), // 1
29 "il codice fiscale/partita Iva ":cfPiva.Substitute(", ","_"), // 2
30 "il cognome":cognome.Substitute(",",""), // 3
31 "il nome":nome.Substitute(",",""), // 4
32 "l'indirizzo":indirizzo.Substitute(",",""), // 5
33 "il numero civico":civico.Substitute(",","."), // 6
34 "il C.A.P.":cap, // 7
35 "la città":citta.Substitute(",",""), // 8
36 "la provincia":prov, // 9
37 "la nazione":nazione.Substitute(",",""), // 10
38 "il telefono":telefono, // 11
39 "il cellulare":cellulare, // 12
40 "il fax":fax.Substitute(",",""), // 13
41 "l'indirizzo e-mail":email, // 14
42 "la password":password.Substitute(",",""), // 15
43 "le modalità di pagamento":"???", // 16
44 "il destinatario":destinatario.Substitute(",",""), // 17
45 "l'indirizzo del destinatario":indirizzoDest.Substitute(",",""), // 18
46 "il numero civico del destinatario":civicoDest.Substitute(",",""), // 19
47 "il C.A.P. del destinatario":capDest, // 20
48 "la città del destinatario":cittaDest.Substitute(",",""), // 21
49 "la provincia del destinatario":provDest, // 22
50 "la nazione del destinatario":nazioneDest.Substitute(",",""), // 23
51 "il telefono del destinatario":telefonoDest.Substitute(",",""), // 24
52 "l'opzione regalo":regalo, // 25
53 "il prefisso del cellulare":prefisso, // 26
54 "il tipo di acquisto":saleType // 27
55 )
56
57 // Verifico congruenza sintattica e propedeutica dei valori inseriti
58 checkRes = checkInput2(compilati)
59 // Se ci sta un probblema, lo mostro
60 if(checkRes)
61 message = "<div id='forMessage'><span>ATTENZIONE</span> " + checkRes + "</div>"
62 else
63 {
64 // Registrazione utente
65
66 // Setto variabili array dati cliente
67 datiArray = compilati
68 ragSoc = datiArray[1]
69 cfPiva = datiArray[2]
70 cognome = datiArray[3]
71 nome = datiArray[4]
72 indirizzo = datiArray[5]
73 civico = datiArray[6]
74 cap = datiArray[7]
75 citta = datiArray[8]
76 prov = datiArray[9]
77 nazione = datiArray[10]
78 telefono = datiArray[11]
79 cellulare = datiArray[12]
80 fax = datiArray[13]
81 email = datiArray[14]
82 password = datiArray[15]
83 pagamento = datiArray[16]
84 destinatario = datiArray[17]
85 indirizzoDest = datiArray[18]
86 civicoDest = datiArray[19]
87 capDest = datiArray[20]
88 cittaDest = datiArray[21]
89 provDest = datiArray[22]
90 nazioneDest = datiArray[23]
91 telefonoDest = datiArray[24]
92 regalo = datiArray[25]
93 prefisso = datiArray[26]
94
95 // 1. se utente non registrato genero codice utente (userID)
96 // e scrivo il nuovo utente nelle anagrafiche
97 if(!cookie.Get("UID")) // se non loggato
98 {
99 newRecID = usersdb.NewRecord()
100 recNum = usersdb.GetRecNum(newRecID)
101
102 userID = genCodiceUser(newRecID)
103
104 usersdb.codice[recNum] = userID
105 usersdb.data[recNum] = oggi.Date()
106 // Definisco la lingua dell'utente (ip2country)
107 /* if(paebr.UpToLower() == "it")
108 usersdb.lingua[recNum] = "ita"
109 else
110 usersdb.lingua[recNum] = "eng"
111 */
112 usersdb.lingua[recNum] = "ita"
113 usersdb.cognome[recNum] = cognome
114 usersdb.nome[recNum] = nome
115 usersdb.email[recNum] = email
116 usersdb.username[recNum] = email
117 usersdb.password[recNum] = password
118 usersdb.export[recNum] = ""
119 usersdb.prov[recNum] = prov // provincia dell'acquirente
120
121 // tipo cliente
122 if(!datiArray.dim >= 27)
123 usersdb.tipo[recNum] = "privato"
124 else if(datiArray[27] == "pri")
125 usersdb.tipo[recNum] = "privato"
126 else if(datiArray[27] == "iva")
127 usersdb.tipo[recNum] = "business"
128 else if(datiArray[27] == "ves") // straniero
129 usersdb.tipo[recNum] = "straniero"
130
131 // 2. scrivo destinazione obbligatoria (dati cliente)
132 newRecID = destinazionidb.NewRecord()
133 recNum = destinazionidb.GetRecNum(newRecID)
134 codice_fatturazione = genCodiceDestinazione(newRecID)
135
136 destinazionidb.data[recNum] = oggi.Date()
137 destinazionidb.codice[recNum] = codice_fatturazione
138 destinazionidb.tipo[recNum] = "fatturazione"
139 destinazionidb.userID[recNum] = userID
140 destinazionidb.piva[recNum] = cfPiva
141 destinazionidb.ragione_sociale[recNum] = ragSoc
142 destinazionidb.contatto[recNum] = cognome + " " + nome // Destinatario nel contatto
143 destinazionidb.indirizzo[recNum] = indirizzo
144 destinazionidb.civico[recNum] = civico
145 destinazionidb.cap[recNum] = cap
146 destinazionidb.citta[recNum] = citta
147 destinazionidb.prov[recNum] = prov
148 destinazionidb.nazione[recNum] = nazione
149 destinazionidb.tel[recNum] = telefono
150 destinazionidb.fax[recNum] = fax
151 if(curScript.IsDef("cellulare"))
152 destinazionidb.cell[recNum] = prefisso + cellulare
153 destinazionidb.email[recNum] = email
154
155 // 3. se esiste destinatario scrivo destinazione spedizione
156 if(destinatario)
157 {
158 newRecID = destinazionidb.NewRecord()
159 recNum = destinazionidb.GetRecNum(newRecID)
160 codice_destinazione = genCodiceDestinazione(newRecID)
161
162 destinazionidb.data[recNum] = oggi.Date()
163 destinazionidb.codice[recNum] = codice_destinazione
164 destinazionidb.tipo[recNum] = "spedizione"
165 destinazionidb.userID[recNum] = userID
166 destinazionidb.contatto[recNum] = destinatario // Destinatario nel contatto
167 destinazionidb.indirizzo[recNum] = indirizzoDest
168 destinazionidb.civico[recNum] = civicoDest
169 destinazionidb.cap[recNum] = capDest
170 destinazionidb.citta[recNum] = cittaDest
171 destinazionidb.prov[recNum] = provDest
172 destinazionidb.nazione[recNum] = nazioneDest
173 destinazionidb.tel[recNum] = telefonoDest
174 destinazionidb.email[recNum] = email
175 }
176
177 // Invio email registrazione
178 emailToCli = email
179 if(emailToCli.Begins("nomail@"))
180 emailToCli = ""
181 emailSubject = "Registrazione - " + nome_negozio
182 emailText = Eval(file("/included/mailReg.txt").Get())
183 simpleMail(emailToCli,emailSubject,emailText,true)
184
185
186 vCon1 = "<h3>Grazie per esserti registrato</h3>"
187 vCon1 += "<p>Ti abbiamo inviato una mail di conferma</p>"
188 stop
189 }
190 }
191 }
192
193
194 vCon1 = ""
195 if(curScript.IsDef("message"))
196 {
197 vCon1 += message
198 }
199 if(!curScript.IsDef("tag")) // Codice per la modifica da Order2
200 {
201 if(ciddalo = cookie.Get("CID"))
202 {
203 cartdb.Select(all,"codice",equal,ciddalo) // Se ha un cart
204 if(cartdb.GetCurRecs() && cartdb.dati_utente[1]) // Se ha i dati utente
205 {
206
207 // Setto variabili array dati cliente
208 datiArray = cartdb.dati_utente[1].ToArray(", ")
209 ragSoc = datiArray[1]
210 cfPiva = datiArray[2]
211 cognome = datiArray[3]
212 nome = datiArray[4]
213 indirizzo = datiArray[5]
214 civico = datiArray[6]
215 cap = datiArray[7]
216 citta = datiArray[8]
217 prov = datiArray[9]
218 nazione = datiArray[10]
219 telefono = datiArray[11]
220 cellulare = datiArray[12]
221 fax = datiArray[13]
222 email = datiArray[14]
223 password = datiArray[15]
224 pagamento = datiArray[16]
225 destinatario = datiArray[17]
226 indirizzoDest = datiArray[18]
227 civicoDest = datiArray[19]
228 capDest = datiArray[20]
229 cittaDest = datiArray[21]
230 provDest = datiArray[22]
231 nazioneDest = datiArray[23]
232 telefonoDest = datiArray[24]
233 regalo = datiArray[25]
234 prefisso = datiArray[26]
235 if(datiArray.dim>=27)
236 saleType = datiArray[27]
237 }
238 }
239 }
240 cfApp = cfPiva.Substitute(", ","_").ToArray("_")
241 cfPiva = cfApp[1]
242 cfPiva2 = ""
243 if(cfApp.dim == 2)
244 cfPiva2 = cfApp[2]
245
246 saleTypePri = "<table><tr>
247 <th width='200px'>*Codice fiscale</th>
248 <td><input type='text' name=\'cfPiva\' value=\'" + cfPiva + "\' /></td>
249</tr></table>"
250
251 saleTypeIva = "<table><tr>
252 <th width='200px'>Ragione sociale</th>
253 <td><input type='text' name='ragSoc' value='" + ragSoc.Encode() + "' /></td>
254</tr>
255<tr>
256 <th>*Partita Iva/Codice fiscale</th>
257 <td><input type='text' name='cfPiva' value='" + cfPiva + "' /></td>
258</tr>
259<tr>
260 <th>Partita Iva<br />(<b>solo</b> se diversa dal C.F.)</th>
261 <td><input type='text' name='cfPiva' value='" + cfPiva2 + "' /></td>
262</tr></table>"
263 saleTypeVes=""
264
265 if(!curScript.IsDef("saleType") || !saleType)
266 saleType = "pri"
267
268
269 vCon1 += "<div id='regForm'>
270<div id='formTitle'><h1>Registrazione utente</h1>" + mlaCampiObbligatori[lang] + "</div>
271<form method='post' action='" + langBaseUrl + "/registrazione/' name='veroForm' onsubmit='return checkMail()'>
272<input type='hidden' name='go' value='registrazione' />
273<input type='hidden' name='tag' value='registra' />
274<fieldset><legend>" + mlaFatturazione[lang] + "</legend>
275<table>
276<tr>
277 <td colspan='2' class='forMsg'>" + mlaCFPIvaMesg(lang,nome_negozio) + "</td>
278</tr>
279<tr>
280 <th valign='top'>" + mlaTipoAcq[lang] + "</th>
281 <td>"
282
283 cPri = ""
284 if(saleType == "pri")
285 cPri = " checked"
286 cIva = ""
287 if(saleType == "iva")
288 cIva = " checked"
289 cVes = ""
290 if(saleType == "ves")
291 cVes = " checked"
292
293 vCon1 += "<input type='radio' class='radio' name='saleType' value='pri' onClick=\"setSaleType('pri')\" " + cPri + " /> " + mlaPrivato[lang] + "<br />
294 <input type='radio' class='radio' name='saleType' value='iva' onClick=\"setSaleType('iva')\" " + cIva + " /> " + mlaAzienda[lang] + "<br />
295 <input type='radio' class='radio' name='saleType' value='ves' onClick=\"setSaleType('ves')\" " + cVes + " /> " + mlaStraniero[lang] +"
296 </td>
297</tr>
298</table>
299<div id='tRagSoc' name='tRagSoc'>
300<table>
301<tr>
302 <th width='200px'>" + mlaRagSoc[lang] + "</th>
303 <td><input type='text' name='ragSoc' id='ragSoc' value='" + ragSoc.Encode() + "' /></td>
304</tr>
305</table>
306</div>
307<div id='tPIva' name='tPIva'>
308<table>
309<tr>
310 <th width='200px'><div id='pIvaLabel'>*" + mlaCFPiva[lang] + "</div></th>
311 <td><input type='text' name='cfPiva' value='" + cfPiva + "' /></td>
312</tr>
313</table>
314</div>
315<div id='tPIva2' name='tPIva2'>
316<table>
317<tr>
318 <th width='200px'>" + mlaCFPiva2[lang] + "</th>
319 <td><input type='text' name='cfPiva' id='cfPiva2' value='" + cfPiva2 + "' /></td>
320</tr>
321</table>
322</div>
323</fieldset>
324<p />"
325
326 vCon1 += "<fieldset><legend>" + mlaAcquirente[lang] + "</legend>
327<table>
328<tr>
329 <th>*" + mlaCognome[lang] + "</th>
330 <td><input type='text' name='cognome' value='" + cognome.Encode() + "' maxlength='25'/></td>
331</tr>
332<tr>
333 <th>*" + mlaNome[lang] + "</th>
334 <td><input type='text' name='nome' value='" + nome.Encode() + "' maxlength='25' /></td>
335</tr>
336
337<tr>
338 <th>*" + mlaIndirizzo[lang] + "</th>
339 <td><input type='text' name='indirizzo' value='" + indirizzo.Encode() + "' /></td>
340</tr>
341<tr>
342 <td colspan='2' class='forMsg'>" + mlaCivicoMesg[lang] + "</td>
343</tr>
344<tr>
345 <th>*" + mlaCivico[lang] + "</th>
346 <td><input type='text' name='civico' value='" + civico + "' /></td>
347</tr>
348<tr>
349 <th>*" + mlaCAP[lang] + "</th>
350 <td><input type='text' name='cap' value='" + cap + "' class='prefisso' maxlength='5' /></td>
351</tr>"
352
353 vCon1 += "<tr>
354 <th>*" + mlaCitta[lang] + "</th>
355 <td><input type='text' name='citta' value='" + citta.Encode() + "' /></td>
356</tr>
357<tr>
358 <th>*" + mlaProvincia[lang] + "</th>
359 <td>" + provincia(prov) + "</td>
360</tr>
361<tr>
362 <th>*" + mlaNazione[lang] + "</th>
363 <td><input type='text' name='nazione' value='Italia' /></td>
364</tr>"
365
366 vCon1 += "<tr>
367 <td colspan='2' class='forMsg'>" + mlaTelMesg[lang] + "</td>
368</tr>
369
370<tr>
371 <th>*" + mlaTelefono[lang] + "</th>
372 <td><input type='text' name='telefono' value='" + telefono + "' /></td>
373</tr>
374<tr>
375 <th>*" + mlaCellulare[lang] + "</th>
376 <td><input type='text' name='prefisso' value='" + prefisso + "' class='prefisso' /> -
377
378 <input type='text' name='cellulare' value='" + cellulare + "' /></td>
379</tr>
380<tr>
381 <th>" + mlaFax[lang] + "</th>
382 <td><input type='text' name='fax' value='" + fax + "' /></td>
383</tr>
384<tr>
385 <th>*" + mlaEmail[lang] + "</th>
386 <td><input type='text' name='email' value='" + email + "' /></td>
387</tr>"
388
389 email2 = ""
390 if(request.referer.Contains("/order1.bfr"))
391 email2 = email
392vCon1 += "<tr>
393 <th>*" + mlaEmail2[lang] + "</th>
394 <td><input type='text' name='email2' value='" + email2 + "' /></td>
395</tr>"
396
397
398 if(password == "")
399 {
400 password = passGen()
401 }
402
403
404vCon1 += "<tr>
405 <td colspan='2' class='forMsg'>" + mlaPasswordMesg[lang] + "</td>
406</tr>
407<tr>
408 <th>*" + mlaPassword[lang] + "</th>
409 <td><input type='text' name='password' value='" + password + "' maxlength='10' /></td>
410</tr>
411</table>
412</fieldset>
413 <p />"
414
415vCon1 += "<fieldset><legend>" + mlaSpedizione[lang] + "</span></legend>
416<table>
417<tr>
418 <td colspan='2' class='forMsg'>" + mlaSpedizioneMesg[lang] + "</td>
419</tr>
420<tr>
421 <th>" + mlaDestinatario[lang] + "</th>
422 <td><input type='text' name='destinatario' value='" + destinatario.Encode() + "' maxlength='50' /></td>
423</tr>
424<tr>
425 <th>" + mlaIndirizzo[lang] + "</th>
426 <td><input type='text' name='indirizzoDest' value='" + indirizzoDest.Encode() + "' /></td>
427</tr>
428<tr>
429 <th>" + mlaCivico[lang] + "</th>
430 <td><input type='text' name='civicoDest' value='" + civicoDest.Encode() + "' /></td>
431</tr>
432<tr>
433 <th>" + mlaCAP[lang] + "</th>
434 <td><input type='text' name='capDest' value='" + capDest + "' class='prefisso' maxlength='5' /></td>
435</tr>
436<tr>
437 <th>" + mlaCitta[lang] + "</th>
438 <td><input type='text' name='cittaDest' value='" + cittaDest.Encode() + "' /></td>
439</tr>"
440vCon1 += "<tr>
441 <th>" + mlaProvincia[lang] + "</th>
442 <td>" + provincia(provDest, "provDest") + "</td>
443</tr>
444<tr>
445 <th>" + mlaNazione[lang] + "</th>
446 <td><input type='text' name='nazioneDest' value='" + nazioneDest.Encode() + "' /></td>
447</tr>
448<tr>
449 <th>" + mlaTelefono[lang] + "</th>
450 <td><input type='text' name='telefonoDest' value='" + telefonoDest + "' /></td>
451</tr>"
452
453// OPZIONE REGALO
454/*vCon1 += "<tr>
455 <td colspan='2' class='forMsg'>" + mlaRegaloMesg[lang] + "</td>
456</tr>
457<tr>
458 <th>" + mlaRegalo[lang] + "</th>
459 <td><input type='radio' name='regalo' value='si' class='radio' /> " + mlaSi[lang] + " <input type='radio' name='regalo' value='no' checked class='radio' /> " + mlaNo[lang] + "</td></tr>
460</table>
461</fieldset> <p />"*/
462vCon1 += "<input type='hidden' name='regalo' value='no' />"
463
464 if(file.Exists("/included/site.info.privacy." + lang + ".txt"))
465 {
466 // File privacy in lingua
467 filePrivacy = file("/included/site.info.privacy." + lang + ".txt")
468 lastMod = " (" + mlaPrivacyUpdate[lang] + " " + filePrivacy.modifTime + ")"
469 testoPrivacy = filePrivacy.Get(0,-1)
470 }
471 else if(file.Exists("/included/site.info.privacy.txt"))
472 {
473 filePrivacy = file("/included/site.info.privacy.txt")
474 lastMod = " (" + mlaPrivacyUpdate[lang] + " " + filePrivacy.modifTime + ")"
475 testoPrivacy = filePrivacy.Get(0,-1)
476 }
477 else
478 {
479 lastMod = oggi
480 testoPrivacy = "File 'infoPrivacy.txt' non presente"
481 }
482 // Richiesta consenso invio newsletter
483 newsletter = "<p />" + mlaPrivacyMesg[lang] + ": <input type='radio' name='news' value='si' checked class='radio' /> " + mlaSi[lang] + " <input type='radio' name='news' value='no' class='radio' /> " + mlaNo[lang] + "</p>"
484
485
486//vCon1 += "<fieldset><legend>" + mlaPrivacy[lang] + " <span>" + lastMod + "</span></legend>"
487vCon1 += "<table>
488<tr>
489 <td ><textarea id='infoPrivacy'>" + testoPrivacy.Encode() + "</textarea>" + newsletter + "</td>
490</tr>
491</table>
492</fieldset>
493<table id='buttOrder'>
494<tr>
495 <td> </td><th align='right'><div><input type='submit' value=\"" + "Registrati" + "\" class='buyButton' /></div></th><th> </th>
496</tr>
497</table>
498
499</form>
500<script type='text/javascript'>
501 setSaleType('" + saleType + "');
502</script>
503</div>"
504
505
506
507