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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
|
{% extends 'registration/base_custom.html' %}
{% block title %}Home{% endblock %}
{%block nav%}
<nav class="nav-extended">
<div class="nav-wrapper teal">
<a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
<a href="#!" class="breadcrumb hide-on-med-and-down">Account</a>
<ul class="right">
{% if user.is_staff or perms.client.staff %}
<li><a href="{% url 'server' %}">Pannello Admin</a></li>
{% endif %}
<li><a href="{% url 'personal' %}">{{ user.username }}</a></li>
<li><a class="tooltipped" data-position="bottom" data-tooltip="Informazioni" href="{% url 'about' %}"><i class="material-icons">info_outline</i></a></li>
<li><a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a></li>
</ul>
</div>
<div class="nav-content teal">
<ul class="tabs tabs-transparent">
<li class="tab"><a class="active" href="#personal">Info Personali</a></li>
<li class="tab"><a href="#medic">Info Mediche</a></li>
</ul>
</div>
</nav>
{% endblock%}
{% block content %}
<form action="{% url 'personal'%}" method="post" id="form1" enctype="multipart/form-data">
<div id="personal" class="row">
<div class="col l8 offset-l2 s12">
<div class="card-panel">
<div class="row">
<div class="col 12">
<input type="hidden" name="action" id="action">
<input type="hidden" name="delete_vac" id="delete_vac">
<input type="hidden" name="delete_health" id="delete_health">
{% csrf_token %}
<div class="row">
<div class="input-field col l4 s12">
<input name="first_name" value="{{first_name}}" id="first_name" type="text" >
<label for="first_name">Nome</label>
</div>
<div class="input-field col l4 s12">
<input name="last_name" value="{{last_name}}" id="last_name" type="text" >
<label for="last_name">Cognome</label>
</div>
<div class="input-field col l4 s12">
<input name="birth_date" value="{{birth_date}}" id="birth_date" type="text" class="datepicker">
<label for="birth_date">Data di nascita</label>
</div>
<div class="input-field col l4 s12">
<select name="branca" disabled>
<option value="" disabled {{branca_default}}>Scegli</option>
<option value="colonia" {{branca_castorini}}>Castorini</option>
<option value="muta" {{branca_lupetti}}>Lupetti</option>
<option value="reparto" {{branca_esploratori}}>Esploratori</option>
<option value="posto" {{branca_pionieri}}>Pionieri</option>
<option value="clan" {{branca_rover}}>Rover</option>
</select>
<label>Branca</label>
</div>
<div class="input-field col l8 s12">
<input value="{{parent_name}}" name="parent_name" id="parent_name" type="text" >
<label for="parent_name">Nome dei genitori</label>
</div>
<div class="input-field col l12 s12">
<input value="{{via}}" name="via" id="via" type="text" >
<label for="via">Via e numero</label>
</div>
<div class="input-field col l4 s12">
<input value="{{cap}}" name="cap" id="cap" type="text" >
<label for="cap">CAP</label>
</div>
<div class="input-field col l4 s12">
<input value="{{country}}" name="country" id="country" type="text" >
<label for="country">Paese</label>
</div>
<div class="input-field col l4 s12">
<input value="{{nationality}}" name="nationality" id="nationality" type="text" >
<label for="nationality">Nazionalità</label>
</div>
<div class="input-field col l4 s12">
<input value="{{phone}}" name="phone" id="phone" type="text" >
<label for="phone">Cellulare</label>
</div>
<div class="input-field col l4 s12">
<input value="{{home_phone}}" name="home_phone" id="home_phone" type="text" >
<label for="home_phone">Telefono di casa</label>
</div>
<div class="input-field col l4 s12">
<input value="{{email}}" name="email" id="email" type="text" >
<label for="email">Email</label>
</div>
<div class="input-field col l8 s12">
<input value="{{school}}" name="school" id="school" type="text" >
<label for="school">Scuola frequentata</label>
</div>
<div class="input-field col l4 s12">
<input value="{{year}}" name="year" id="year" type="text" >
<label for="year">Classe</label>
</div>
</div>
<div class="fixed-action-btn">
<a class="btn-floating btn-large teal" onclick="send('save')">
<i class="large material-icons">save</i>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="medic" class="row">
<div class="col l8 offset-l2 s12">
<div class="card-panel">
<div class="row">
<div class="col s12">
<h6>Persona di contatto in caso di necessità</h6>
</div>
</div>
<div class="row">
<div class="input-field col l6 s12">
<input name="emer_name" value="{{emer_name}}" id="emer_name" type="text" >
<label for="emer_name">Nome e cognome</label>
</div>
<div class="input-field col l3 s12">
<input name="emer_relative" value="{{emer_relative}}" id="emer_relative" type="text" >
<label for="emer_releative">Parentela</label>
</div>
<div class="input-field col l3 s12">
<input name="cell_phone" value="{{cell_phone}}" id="cellphone" type="text" >
<label for="cell_phone">Cellulare</label>
</div>
<div class="input-field col l9 s12">
<input value="{{address}}" name="address" id="address" type="text" >
<label for="address">Indirizzo completo</label>
</div>
<div class="input-field col l3 s12">
<input value="{{emer_phone}}" name="emer_phone" id="emer_phone" type="text" >
<label for="emer_phone">Telefono di casa</label>
</div>
</div>
<div class="row">
<div class="col s12">
<h6>Assicurazione</h6>
</div>
</div>
<div class="row">
<div class="input-field col l4 s12">
<input value="{{health_care}}" name="health_care" id="health_care" type="text" >
<label for="health_care">Cassa Malati</label>
</div>
<div class="input-field col l4 s12">
<input value="{{injuries}}" name="injuries" id="injuries" type="text" >
<label for="injuries">Infortuni</label>
</div>
<div class="input-field col l4 s12">
<input value="{{rc}}" name="rc" id="rc" type="text" >
<label for="rc">Responsabilità civile</label>
</div>
</div>
<div class="row">
<div class="switch col s12">
È sostenitore REGA
<label>
No
<input name="rega" type="checkbox" {{rega_check}}>
<span class="lever"></span>
Si
</label>
</div>
</div>
<div class="row">
<div class="col s12">
<h6>Medico di famiglia</h6>
</div>
<div class="input-field col l6 s12">
<input value="{{medic_name}}" name="medic_name" id="medic_name" type="text" >
<label for="medic_name">Nome e cognome</label>
</div>
<div class="input-field col l6 s12">
<input value="{{medic_phone}}" name="medic_phone" id="medic_phone" type="text" >
<label for="medic_phone">Telefono studio</label>
</div>
<div class="input-field col l12 s12">
<input value="{{medic_address}}" name="medic_address" id="medic_address" type="text" >
<label for="medic_address">Indirizzo completo</label>
</div>
</div>
<div class="row">
<div class="col s12">
<h6>Scheda medica personale</h6>
</div>
<div class="input-field col s12">
<input value="{{sickness}}" name="sickness" id="sickness" type="text" data-length="250">
<label for="sickness">Principali malattie avute</label>
</div>
<div class="input-field col l8 s12">
<input value="{{vaccine}}" name="vaccine" id="vaccine" type="text" data-length="250">
<label for="vaccine">Vacinazioni fatte</label>
</div>
<div class="input-field col l4 s12">
<label for="tetanus_date">Ultima vacinazione contro il tetano</label>
<input value="{{tetanus_date}}" name="tetanus_date" id="tetanus_date" type="text" class="datepicker">
</div>
<div class="input-field col s12">
<input value="{{allergy}}" name="allergy" id="allergy" type="text" data-length="250">
<label for="allergy">Allergie particolari/Intolleraze alimentari</label>
</div>
<div class="switch col s12">
Deve assumere regolarmente medicamenti
<label>
No
<input name="drugs_bool" type="checkbox" {{drugs_check}}>
<span class="lever"></span>
Si
</label>
</div>
<div class="col s12">
<div class="card teal">
<div class="card-content">
<p style="color:white"><b>In caso dovesse assumere farmaci, avvisare comunque i capi</b></p>
</div>
</div>
</div>
<div class="input-field col s12">
<input value="{{drugs}}" name="drugs" id="drugs" type="text" data-length="250">
<label for="drugs">Se sì quali, in che dosi e prescrizioni</label>
</div>
<div class="switch col s12">
Informazioni particolari sullo stato di salute: (postumi di operazioni, incidenti, malattie, disturbi fisici)
<label>
No
<input name="misc_bool" type="checkbox" {{misc_check}}>
<span class="lever"></span>
Si
</label>
</div>
<div class="input-field col s12">
<input value="{{misc}}" name="misc" id="misc" type="text" data-length="250">
<label for="misc">Se sì quali</label>
</div>
</div>
<div class="row">
<div class="col s12">
<h6>Allegati</h6>
</div>
<div class="col s12">
<div class="card">
<div class="card-content">
Certificato di vacinazione
<div class="file-field input-field">
<div class="btn teal">
<span><i class="material-icons left">file_upload</i>File</span>
<input type="file" name="vac_certificate" id="vac_certificate">
</div>
<div class="file-path-wrapper">
<input id="vac_file" value="{{vac_certificate}}" class="file-path" type="text" placeholder="Certificato di vacinazione">
</div>
</div>
{% if vac_certificate != ''%}
<a class="btn teal" onclick="send('download_vac')"><i class="material-icons left">file_download</i>Download</a>
<a class="btn teal" onclick="delete_vac()"><i class="material-icons left">delete</i><span>Elimina</span></a>
{% endif %}
</div>
</div>
</div>
<div class="col s12">
<div class="card">
<div class="card-content">
Tessera cassa malati
<div class="file-field input-field">
<div class="btn teal">
<span><i class="material-icons left">file_upload</i>File</span>
<input type="file" name="health_care_certificate" id="health_care_certificate">
</div>
<div class="file-path-wrapper">
<input id="health_care_file" value="{{health_care_certificate}}" class="file-path" type="text" placeholder="Tessera cassa malati">
</div>
</div>
{% if health_care_certificate != ''%}
<a class="btn teal" onclick="send('download_health')"><i class="material-icons left">file_download</i>Download</a>
<a class="btn teal" onclick="delete_health()"><i class="material-icons left">delete</i><span>Elimina</span></a>
{% endif %}
</div>
</div>
</div>
</div>
<div class="fixed-action-btn">
<a class="btn-floating btn-large teal" onclick="send('save')">
<i class="large material-icons">save</i>
</a>
</div>
</form>
</div>
</div>
</div>
{% endblock %}
{% block script %}
function send(id) {
$('#form1').trigger('reinitialize.areYouSure');
var form = document.getElementById('form1');
var action = document.getElementById('action');
action.setAttribute('value', id);
form.submit();
}
function delete_vac() {
var action = document.getElementById('delete_vac');
var text = document.getElementById('vac_file');
action.setAttribute('value', 'vac');
text.setAttribute('value', '');
}
function delete_health() {
var action = document.getElementById('delete_health');
var text = document.getElementById('health_care_file');
action.setAttribute('value', 'health');
text.setAttribute('value', '');
}
var elem = $('.tabs')
var options = {
yearRange:100,
format:'dd mmmm yyyy',
i18n: {
months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ],
monthsShort: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic' ],
weekdays: [ 'domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato' ],
weekdaysShort: [ 'dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab' ],
weekdaysAbbrev: [ 'D', 'L', 'M', 'M', 'G', 'V', 'S' ],
today: 'Oggi',
clear: 'Cancella',
close: 'Chiudi',
firstDay: 1,
format: 'dddd d mmmm yyyy',
formatSubmit: 'yyyy/mm/dd',
labelMonthNext: 'Mese successivo',
labelMonthPrev: 'Mese precedente',
labelMonthSelect: 'Seleziona un mese',
labelYearSelect: 'Seleziona un anno'
}
}
$(document).ready(function() {
$('input#sickness, input#vaccine, input#allergy, input#drugs, input#misc').characterCounter();
$('.datepicker').datepicker(options);
$('.tabs').tabs();
$('select').formSelect();
{% if error %}
M.toast({html: '{{ error_text}}', classes: 'orange'})
{% endif %}
document.getElementById("vac_certificate").onchange = function() {
if(this.files[0].size > 1048576*10){
M.toast({html: 'Il file è troppo grande. Grandezza massima 10MB', classes: 'orange'});
this.value = "";
}
};
document.getElementById("health_care_certificate").onchange = function() {
if(this.files[0].size > 1048576*10){
M.toast({html: 'Il file è troppo grande. Grandezza massima 10MB', classes: 'orange'});
this.value = "";
}
};
});
/*!
* jQuery Plugin: Are-You-Sure (Dirty Form Detection)
* https://github.com/codedance/jquery.AreYouSure/
*
* Copyright (c) 2012-2014, Chris Dance and PaperCut Software http://www.papercut.com/
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Author: chris.dance@papercut.com
* Version: 1.9.0
* Date: 13th August 2014
*/
(function($) {
$.fn.areYouSure = function(options) {
var settings = $.extend(
{
'message' : 'You have unsaved changes!',
'dirtyClass' : 'dirty',
'change' : null,
'silent' : false,
'addRemoveFieldsMarksDirty' : false,
'fieldEvents' : 'change keyup propertychange input',
'fieldSelector': ":input:not(input[type=submit]):not(input[type=button])"
}, options);
var getValue = function($field) {
if ($field.hasClass('ays-ignore')
|| $field.hasClass('aysIgnore')
|| $field.attr('data-ays-ignore')
|| $field.attr('name') === undefined) {
return null;
}
if ($field.is(':disabled')) {
return 'ays-disabled';
}
var val;
var type = $field.attr('type');
if ($field.is('select')) {
type = 'select';
}
switch (type) {
case 'checkbox':
case 'radio':
val = $field.is(':checked');
break;
case 'select':
val = '';
$field.find('option').each(function(o) {
var $option = $(this);
if ($option.is(':selected')) {
val += $option.val();
}
});
break;
default:
val = $field.val();
}
return val;
};
var storeOrigValue = function($field) {
$field.data('ays-orig', getValue($field));
};
var checkForm = function(evt) {
var isFieldDirty = function($field) {
var origValue = $field.data('ays-orig');
if (undefined === origValue) {
return false;
}
return (getValue($field) != origValue);
};
var $form = ($(this).is('form'))
? $(this)
: $(this).parents('form');
// Test on the target first as it's the most likely to be dirty
if (isFieldDirty($(evt.target))) {
setDirtyStatus($form, true);
return;
}
$fields = $form.find(settings.fieldSelector);
if (settings.addRemoveFieldsMarksDirty) {
// Check if field count has changed
var origCount = $form.data("ays-orig-field-count");
if (origCount != $fields.length) {
setDirtyStatus($form, true);
return;
}
}
// Brute force - check each field
var isDirty = false;
$fields.each(function() {
var $field = $(this);
if (isFieldDirty($field)) {
isDirty = true;
return false; // break
}
});
setDirtyStatus($form, isDirty);
};
var initForm = function($form) {
var fields = $form.find(settings.fieldSelector);
$(fields).each(function() { storeOrigValue($(this)); });
$(fields).unbind(settings.fieldEvents, checkForm);
$(fields).bind(settings.fieldEvents, checkForm);
$form.data("ays-orig-field-count", $(fields).length);
setDirtyStatus($form, false);
};
var setDirtyStatus = function($form, isDirty) {
var changed = isDirty != $form.hasClass(settings.dirtyClass);
$form.toggleClass(settings.dirtyClass, isDirty);
// Fire change event if required
if (changed) {
if (settings.change) settings.change.call($form, $form);
if (isDirty) $form.trigger('dirty.areYouSure', [$form]);
if (!isDirty) $form.trigger('clean.areYouSure', [$form]);
$form.trigger('change.areYouSure', [$form]);
}
};
var rescan = function() {
var $form = $(this);
var fields = $form.find(settings.fieldSelector);
$(fields).each(function() {
var $field = $(this);
if (!$field.data('ays-orig')) {
storeOrigValue($field);
$field.bind(settings.fieldEvents, checkForm);
}
});
// Check for changes while we're here
$form.trigger('checkform.areYouSure');
};
var reinitialize = function() {
initForm($(this));
}
if (!settings.silent && !window.aysUnloadSet) {
window.aysUnloadSet = true;
$(window).bind('beforeunload', function() {
$dirtyForms = $("form").filter('.' + settings.dirtyClass);
if ($dirtyForms.length == 0) {
return;
}
// Prevent multiple prompts - seen on Chrome and IE
if (navigator.userAgent.toLowerCase().match(/msie|chrome/)) {
if (window.aysHasPrompted) {
return;
}
window.aysHasPrompted = true;
window.setTimeout(function() {window.aysHasPrompted = false;}, 900);
}
return settings.message;
});
}
return this.each(function(elem) {
if (!$(this).is('form')) {
return;
}
var $form = $(this);
$form.submit(function() {
$form.removeClass(settings.dirtyClass);
});
$form.bind('reset', function() { setDirtyStatus($form, false); });
// Add a custom events
$form.bind('rescan.areYouSure', rescan);
$form.bind('reinitialize.areYouSure', reinitialize);
$form.bind('checkform.areYouSure', checkForm);
initForm($form);
});
};
})(jQuery);
$('form').areYouSure();
{% endblock %}
|