| rev |
line source |
|
bsw/jbe@1309
|
1 for i, field in ipairs(config.self_registration.fields) do
|
|
bsw/jbe@1309
|
2 local class = ""
|
|
bsw/jbe@1309
|
3 local field_error = slot.get_content("self_registration__invalid_" .. field.name)
|
|
bsw/jbe@1309
|
4 if field_error == "" then
|
|
bsw/jbe@1309
|
5 field_error = nil
|
|
bsw/jbe@1309
|
6 end
|
|
bsw/jbe@1309
|
7 if field_error then
|
|
bsw/jbe@1309
|
8 class = " is-invalid"
|
|
bsw/jbe@1309
|
9 end
|
|
bsw@1359
|
10 if not field.internal then
|
|
bsw@1423
|
11 if field.type == "comment" then
|
|
bsw@1423
|
12 ui.tag { content = field.label }
|
|
bsw@1423
|
13 elseif field.name == "date_of_birth" then
|
|
bsw@1359
|
14 local label = field.label
|
|
bsw@1359
|
15 if field.optional then
|
|
bsw@1359
|
16 label = label .. config.self_registration.optional_field_indicator
|
|
bsw@1359
|
17 end
|
|
bsw@1359
|
18 ui.tag{ tag = "label", attr = { style = "vertical-align: bottom; border-bottom: 1px solid rgba(0,0,0, 0.12); color: #777; font-size: 16px;" }, content = field.label .. ":" }
|
|
bsw@1359
|
19 slot.put(" ")
|
|
bsw@1359
|
20 local days = { { id = 0, name = _"day" } }
|
|
bsw@1359
|
21 for i = 1, 31 do
|
|
bsw@1359
|
22 table.insert(days, { id = i, name = i })
|
|
bsw@1359
|
23 end
|
|
bsw@1359
|
24 local months = {
|
|
bsw/jbe@1309
|
25 { id = 0, name = _"month" },
|
|
bsw@1359
|
26 { id = 1, name = "gennaio" },
|
|
bsw@1359
|
27 { id = 2, name = "febbraio" },
|
|
bsw@1359
|
28 { id = 3, name = "marzo" },
|
|
bsw@1359
|
29 { id = 4, name = "aprile" },
|
|
bsw@1359
|
30 { id = 5, name = "maggio" },
|
|
bsw@1359
|
31 { id = 6, name = "giugno" },
|
|
bsw@1359
|
32 { id = 7, name = "luglio" },
|
|
bsw@1359
|
33 { id = 8, name = "agosto" },
|
|
bsw@1359
|
34 { id = 9, name = "settembre" },
|
|
bsw@1359
|
35 { id = 10, name = "ottobre" },
|
|
bsw@1359
|
36 { id = 11, name = "novembre" },
|
|
bsw@1359
|
37 { id = 12, name = "dicembre" },
|
|
bsw@1359
|
38 }
|
|
bsw@1359
|
39 if config.self_registration.lang == "en" then
|
|
bsw@1359
|
40 months = {
|
|
bsw@1359
|
41 { id = 0, name = _"month" },
|
|
bsw@1359
|
42 { id = 1, name = "January" },
|
|
bsw@1359
|
43 { id = 2, name = "February" },
|
|
bsw@1359
|
44 { id = 3, name = "March" },
|
|
bsw@1359
|
45 { id = 4, name = "April" },
|
|
bsw@1359
|
46 { id = 5, name = "May" },
|
|
bsw@1359
|
47 { id = 6, name = "June" },
|
|
bsw@1359
|
48 { id = 7, name = "July" },
|
|
bsw@1359
|
49 { id = 8, name = "August" },
|
|
bsw@1359
|
50 { id = 9, name = "September" },
|
|
bsw@1359
|
51 { id = 10, name = "October" },
|
|
bsw@1359
|
52 { id = 11, name = "November" },
|
|
bsw@1359
|
53 { id = 12, name = "December" },
|
|
bsw@1359
|
54 }
|
|
bsw@1359
|
55 end
|
|
bsw@1490
|
56 if config.self_registration.lang == "de" then
|
|
bsw@1490
|
57 months = {
|
|
bsw@1490
|
58 { id = 0, name = _"month" },
|
|
bsw@1490
|
59 { id = 1, name = "Januar" },
|
|
bsw@1490
|
60 { id = 2, name = "Februar" },
|
|
bsw@1490
|
61 { id = 3, name = "März" },
|
|
bsw@1490
|
62 { id = 4, name = "April" },
|
|
bsw@1490
|
63 { id = 5, name = "Mai" },
|
|
bsw@1490
|
64 { id = 6, name = "Juni" },
|
|
bsw@1490
|
65 { id = 7, name = "Juli" },
|
|
bsw@1490
|
66 { id = 8, name = "August" },
|
|
bsw@1490
|
67 { id = 9, name = "September" },
|
|
bsw@1490
|
68 { id = 10, name = "Oktober" },
|
|
bsw@1490
|
69 { id = 11, name = "November" },
|
|
bsw@1490
|
70 { id = 12, name = "Dezember" },
|
|
bsw@1490
|
71 }
|
|
bsw@1490
|
72 end
|
|
bsw@1359
|
73 local years = { { id = 0, name = _"year" } }
|
|
bsw@1422
|
74 local min_age = config.self_registration.min_age or 16
|
|
bsw@1422
|
75 for i = (atom.date:get_current()).year - min_age, 1900, -1 do
|
|
bsw@1359
|
76 table.insert(years, { id = i, name = i })
|
|
bsw@1359
|
77 end
|
|
bsw@1359
|
78 ui.field.select{
|
|
bsw@1359
|
79 container_attr = { style = "display: inline-block; " },
|
|
bsw@1359
|
80 attr = { class = class },
|
|
bsw@1359
|
81 foreign_records = days,
|
|
bsw@1359
|
82 foreign_id = "id",
|
|
bsw@1359
|
83 foreign_name = "name",
|
|
bsw@1359
|
84 name = "verification_data_" .. field.name .. "_day",
|
|
bsw@1359
|
85 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_day" })
|
|
bsw@1359
|
86 }
|
|
bsw@1359
|
87 slot.put(" ")
|
|
bsw@1359
|
88 ui.field.select{
|
|
bsw@1359
|
89 container_attr = { style = "display: inline-block; " },
|
|
bsw@1359
|
90 attr = { class = class },
|
|
bsw@1359
|
91 foreign_records = months,
|
|
bsw@1359
|
92 foreign_id = "id",
|
|
bsw@1359
|
93 foreign_name = "name",
|
|
bsw@1359
|
94 name = "verification_data_" .. field.name .. "_month",
|
|
bsw@1359
|
95 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_month" })
|
|
bsw@1359
|
96 }
|
|
bsw@1359
|
97 slot.put(" ")
|
|
bsw@1359
|
98 ui.field.select{
|
|
bsw@1359
|
99 container_attr = { style = "display: inline-block; " },
|
|
bsw@1359
|
100 attr = { class = class },
|
|
bsw@1359
|
101 foreign_records = years,
|
|
bsw@1359
|
102 foreign_id = "id",
|
|
bsw@1359
|
103 foreign_name = "name",
|
|
bsw@1359
|
104 name = "verification_data_" .. field.name .. "_year",
|
|
bsw@1359
|
105 value = tonumber(request.get_param{ name = "verification_data_" .. field.name .. "_year" })
|
|
bsw@1359
|
106 }
|
|
bsw@1359
|
107 slot.put("<br />")
|
|
bsw@1377
|
108
|
|
bsw@1377
|
109 elseif field.type == "dropdown" then
|
|
bsw@1380
|
110 local options = { { id = "", name = "" } }
|
|
bsw@1377
|
111 for i_options, option in ipairs(field.options) do
|
|
bsw@1679
|
112 if not option.id then
|
|
bsw@1679
|
113 option.id = option.name
|
|
bsw@1679
|
114 end
|
|
bsw@1377
|
115 table.insert(options, option)
|
|
bsw@1377
|
116 end
|
|
bsw@1380
|
117 ui.tag{ tag = "label", attr = { style = "vertical-align: bottom; border-bottom: 1px solid rgba(0,0,0, 0.12); color: #777; font-size: 16px;" }, content = field.label .. ":" }
|
|
bsw@1380
|
118 slot.put(" ")
|
|
bsw@1377
|
119 ui.field.select{
|
|
bsw@1377
|
120 container_attr = { style = "display: inline-block; " },
|
|
bsw@1377
|
121 attr = { class = class },
|
|
bsw@1377
|
122 foreign_records = options,
|
|
bsw@1377
|
123 foreign_id = "id",
|
|
bsw@1377
|
124 foreign_name = "name",
|
|
bsw@1377
|
125 name = "verification_data_" .. field.name,
|
|
bsw@1377
|
126 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
|
|
bsw@1377
|
127 }
|
|
bsw@1381
|
128 slot.put("<br />")
|
|
bsw@1377
|
129
|
|
bsw@1359
|
130 elseif field.type == "image" then
|
|
bsw@1386
|
131 slot.put("<br />")
|
|
bsw@1392
|
132 ui.tag{ tag = "label", attr = { style = "vertical-align: bottom; border-bottom: 1px solid rgba(0,0,0, 0.12); color: #777; font-size: 16px;" }, content = field.label .. ":" }
|
|
bsw@1392
|
133 slot.put("<br />")
|
|
bsw@1391
|
134 ui.script{ script = [[
|
|
bsw@1391
|
135 function getFile(){
|
|
bsw@1392
|
136 document.getElementById("fileInput").click();
|
|
bsw@1391
|
137 }
|
|
bsw@1391
|
138 function fileChoosen(obj){
|
|
bsw@1391
|
139 var file = obj.value;
|
|
bsw@1391
|
140 var fileName = file.split("\\");
|
|
bsw@1399
|
141 var checked = false;
|
|
bsw@1399
|
142 var label = "]] .. field.upload_label .. [[";
|
|
bsw@1402
|
143 if (fileName[fileName.length-1].length > 0) {
|
|
bsw@1398
|
144 label = fileName[fileName.length-1];
|
|
bsw@1398
|
145 }
|
|
bsw@1399
|
146 document.getElementById("fileBtn").innerHTML = label;
|
|
bsw@1391
|
147 event.preventDefault();
|
|
bsw@1391
|
148 }
|
|
bsw@1391
|
149 ]] }
|
|
bsw@1393
|
150 ui.tag{ tag = "input", attr = { id = "fileInput", style = "display: none;", type = "file", name = "verification_data_" .. field.name, onchange = "fileChoosen(this);" } }
|
|
bsw@1400
|
151 ui.tag{
|
|
bsw@1403
|
152 attr = { id = "fileBtn", class = "mdl-button mdl-js-button mdl-button--underlined", onclick = "getFile();" },
|
|
bsw@1400
|
153 content = field.upload_label
|
|
bsw@1395
|
154 }
|
|
bsw@1367
|
155 if field.optional_checkbox then
|
|
bsw@1391
|
156 slot.put(" ")
|
|
bsw@1375
|
157 ui.tag{ tag = "label", attr = {
|
|
bsw@1375
|
158 class = "mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect",
|
|
bsw@1394
|
159 style = "display: inline;",
|
|
bsw@1375
|
160 ["for"] = "verification_data_" .. field.name .. "_optout"
|
|
bsw@1375
|
161 },
|
|
bsw@1375
|
162 content = function()
|
|
bsw@1375
|
163 ui.tag{
|
|
bsw@1375
|
164 tag = "input",
|
|
bsw@1375
|
165 attr = {
|
|
bsw@1375
|
166 type = "checkbox",
|
|
bsw@1375
|
167 class = "mdl-checkbox__input",
|
|
bsw@1375
|
168 id = "verification_data_" .. field.name .. "_optout",
|
|
bsw@1375
|
169 name = "verification_data_" .. field.name .. "_optout",
|
|
bsw@1375
|
170 value = "1",
|
|
bsw@1375
|
171 style = "float: left;",
|
|
bsw@1375
|
172 checked = request.get_param{ name = "verification_data_" .. field.name .. "_optout" } and "checked" or nil,
|
|
bsw@1375
|
173 }
|
|
bsw@1375
|
174 }
|
|
bsw@1375
|
175 ui.tag{
|
|
bsw@1375
|
176 attr = { class = "mdl-checkbox__label" },
|
|
bsw@1375
|
177 content = field.optional_checkbox
|
|
bsw@1375
|
178 }
|
|
bsw@1375
|
179 end
|
|
bsw@1375
|
180 }
|
|
bsw@1367
|
181 end
|
|
bsw@1359
|
182
|
|
bsw@1359
|
183 elseif field.name == "unit" then
|
|
bsw@1359
|
184 local units_selector = Unit:new_selector()
|
|
bsw@1359
|
185 :add_where{ "active" }
|
|
bsw@1412
|
186 :add_order_by("name")
|
|
bsw@1359
|
187 if field.where then
|
|
bsw@1359
|
188 units_selector:add_where(field.where)
|
|
bsw@1359
|
189 end
|
|
bsw@1359
|
190 local units = {}
|
|
bsw@1359
|
191 if field.optional then
|
|
bsw@1359
|
192 table.insert(units, {
|
|
bsw@1359
|
193 id = "",
|
|
bsw@1404
|
194 name = _"none"
|
|
bsw@1359
|
195 })
|
|
bsw@1359
|
196 end
|
|
bsw@1359
|
197 for i_unit, unit in ipairs(units_selector:exec()) do
|
|
bsw@1359
|
198 table.insert(units, unit)
|
|
bsw@1359
|
199 end
|
|
bsw@1382
|
200 ui.tag{ tag = "label", attr = { style = "vertical-align: bottom; border-bottom: 1px solid rgba(0,0,0, 0.12); color: #777; font-size: 16px;" }, content = field.label .. ":" }
|
|
bsw@1382
|
201 slot.put(" ")
|
|
bsw@1359
|
202 ui.field.select{
|
|
bsw@1383
|
203 container_attr = { style = "display: inline-block; " },
|
|
bsw@1359
|
204 foreign_records = units,
|
|
bsw@1359
|
205 foreign_id = "id",
|
|
bsw@1359
|
206 foreign_name = "name",
|
|
bsw@1359
|
207 name = "verification_data_" .. field.name,
|
|
bsw@1359
|
208 value = tonumber(request.get_param{ name = "verification_data_" .. field.name })
|
|
bsw@1359
|
209 }
|
|
bsw@1386
|
210 slot.put("<br />")
|
|
bsw@1359
|
211 else
|
|
bsw@1359
|
212 if field.name == "mobile_phone" then
|
|
bsw@1359
|
213 if config.self_registration.lang ~= "en" then
|
|
bsw@1359
|
214 ui.tag{ content = "+39" }
|
|
bsw@1359
|
215 slot.put(" ")
|
|
bsw@1359
|
216 end
|
|
bsw@1359
|
217 end
|
|
bsw@1405
|
218 local label = field.label
|
|
bsw@1405
|
219 if field.optional then
|
|
bsw@1405
|
220 label = label .. config.self_registration.optional_field_indicator
|
|
bsw@1405
|
221 end
|
|
bsw@1359
|
222 ui.field.text{
|
|
bsw@1359
|
223 container_attr = { class = "mdl-textfield mdl-js-textfield mdl-textfield--floating-label" .. class },
|
|
bsw@1359
|
224 attr = { id = "lf-register__data_" .. field.name, class = "mdl-textfield__input" },
|
|
bsw@1359
|
225 label_attr = { class = "mdl-textfield__label", ["for"] = "lf-register__data" .. field.name },
|
|
bsw@1406
|
226 label = label,
|
|
bsw@1359
|
227 name = "verification_data_" .. field.name,
|
|
bsw@1359
|
228 value = request.get_param{ name = "verification_data_" .. field.name }
|
|
bsw/jbe@1309
|
229 }
|
|
bsw/jbe@1309
|
230 end
|
|
bsw@1327
|
231 slot.put("<br />")
|
|
bsw/jbe@1309
|
232 end
|
|
bsw/jbe@1309
|
233 end
|