An error occurred while processing the template.
The following has evaluated to null or missing:
==> mandatory  [in template "383767#383802#960406" at line 1057, column 30]

----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
	- Failed at: #if mandatory == "true"  [in template "383767#383802#960406" at line 1057, column 25]
----
1<#-- 
2    Sezione di pagamento Zainetto Verde 
3    ©Suggesto 2021 
4--> 
5 
6<#assign 
7    JALS = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") 
8    articleId = "1221309" 
9    article = JALS.fetchArticle(groupId, articleId) 
10    document = saxReaderUtil.read(article.getContent()) 
11    rootElement = document.getRootElement() 
12    allegati = [] 
13     
14    stringSelector = "dynamic-element[@name='allegato']" 
15    xPathSelector = saxReaderUtil.createXPath(stringSelector) 
16/> 
17 
18<#if xPathSelector.selectNodes(rootElement)??> 
19    <#assign allegati = xPathSelector.selectNodes(rootElement)> 
20</#if> 
21 
22<#macro printContent> 
23    <div id="pay" class="p-3" v-cloak> 
24        <div v-show="loading"> 
25            <div class="d-flex align-items-center justify-content-center h-full"> 
26                <div class="loading-animation"></div> 
27            </div> 
28        </div> 
29         
30        <div class="container" v-show="!loading"> 
31            <div class="text-center" v-if="name == 'Placeholder'"> 
32                <p class="text-dark">Errore interno.</p> 
33                <p class="text-dark">Ricarica la pagina per continuare.</p> 
34            </div> 
35            <div class="row" v-else> 
36                <div class="col-12"> 
37                    <ol class="d-none d-lg-flex nav multi-step-nav multi-step-nav-collapse-sm flex-row" role="tablist"> 
38                    	<li v-for="(num, index) in totalSteps" class="multi-step-item" :class="{'complete': currentStep >= num, 'multi-step-item-expand': index != totalSteps-1}"> 
39                    		<div class="multi-step-divider"></div> 
40                    		<div class="multi-step-indicator"> 
41                    			<button class="multi-step-icon bg-image-none" data-toggle="tab" @click="currentStep = num" v-if="isDev"> 
42                    			    <span class="text-white font-weight-bold">{{ num }}</span> 
43                    			</button> 
44                    			<div class="multi-step-icon bg-image-none" data-toggle="tab" v-else> 
45                    			    <span class="text-white font-weight-bold">{{ num }}</span> 
46                    			</div> 
47                    		</div> 
48                    	</li> 
49                    </ol> 
50                     
51                    <div class="tbar subnav-tbar subnav-tbar-light d-lg-none"> 
52                    	<div class="container-fluid container-fluid-max-xl"> 
53                    		<div class="tbar-nav"> 
54                    			<div class="tbar-item tbar-item-expand"> 
55                    				<div class="tbar-section"> 
56                    					<span class="component-text text-truncate-inline"> 
57                    						<span class="text-truncate">Acquisto</span> 
58                    					</span> 
59                    				</div> 
60                    			</div> 
61                    			<div class="tbar-item"> 
62                    				<span class="component-text">Pagina {{ currentStep }} di {{ totalSteps }}</span> 
63                    			</div> 
64                    		</div> 
65                    	</div> 
66                    </div> 
67                     
68                    <div class="tab-content mt-lg-5"> 
69                     
70                        <#-- CALENDARIO --> 
71                        <div class="tab-pane fade" :class="{'show active': currentStep == 1}" role="tabpanel"> 
72                            <div class="row justify-content-between"> 
73                                <div class="d-none d-lg-block col-12 mb-4"> 
74                                    <p class="text-dark display-5 font-weight-light">Scegli la data</p> 
75                                </div> 
76                                 
77                                <div class="col-12 col-lg-5"> 
78                                    <div id="v-calendar" class="single w-100 w-lg-75 mx-auto mb-3 mb-lg-4"> 
79                                        <v-calendar 
80                                            v-if="calendar.ready" 
81                                            v-model="calendar.dataSelected" 
82                                            @dayclick="selectDate" 
83                                            :available-dates="calendar.dateDisponibili" 
84                                            :attributes="calendar.attributes" 
85                                            :min-page="calendar.initialPage" 
86                                            :min-date="calendar.dataInizio" 
87                                            :max-date="calendar.dataFine" 
88                                            nav-visibility="hidden" 
89                                            title-position="left" 
90                                            ref="calendar" 
91                                            mode="single" 
92                                            is-expanded 
93                                            is-inline 
94                                        /> 
95                                    </div> 
96                                     
97                                    <div class="card void mt-4 mt-lg-0"> 
98                                        <div class="card-row flex-column flex-md-row"> 
99                                            <div class="autofit-col autofit-col-expand"> 
100                                                <section class="autofit-section"> 
101                                                    <p class="text-dark text-center text-md-left mb-lg-0">Desideri prenotare per un gruppo o verificare la disponibilità di date e orari non elencati?</p> 
102                                                </section> 
103                                            </div> 
104                                            <div class="autofit-col"> 
105                                                <section class="autofit-section"> 
106                                                    <button @click="openParentModal('#requestinfo-payment-modal')" class="btn btn-outline-dark btn-block py-2 px-3">Contattaci</button> 
107                                                </section> 
108                                            </div> 
109                                        </div> 
110                                    </div> 
111                                </div> 
112                                <div class="col-12 col-lg-6"> 
113                                    <div class="card-row mb-4 mt-5 mt-lg-0"> 
114                                        <div class="autofit-col"> 
115                                            <section class="autofit-section"> 
116                                                <p class="h4 text-dark mb-0">Scegli una data</p> 
117                                            </section> 
118                                        </div> 
119                                        <div class="autofit-col autofit-col-expand"> 
120                                            <section class="autofit-section text-right"> 
121                                                <button class="btn btn-gradient px-0 text-dark" v-show="calendar.dataSelected != null" @click="resetDates()">Cancella le date</button> 
122                                            </section> 
123                                        </div> 
124                                    </div> 
125                                     
126                                    <div id="results"> 
127                                        <div class="card void" v-for="(package, index) in packages" :key="package._id.$oid"> 
128                                            <div class="card-row" v-show="package.show"> 
129                                                <div class="autofit-col autofit-col-expand"> 
130                                                    <section class="autofit-section"> 
131                                                        <p class="text-muted mb-0">dal {{ package.startDate | moment().format("DD MMMM YYYY") }} al {{ package.endDate | moment().format("DD MMMM YYYY") }}</p> 
132                                                        <p class="mb-0"> 
133                                                            <span class="badge badge-pill badge-primary bg-gradient-h" v-if="package.forGroup"> 
134                                                            	<span class="badge-item badge-item-expand">Per gruppi</span> 
135                                                            </span> 
136                                                            <template v-if="package.marketingGroups"> 
137                                                                <span v-for="(item, index) in package.marketingGroups" :key="'mg-' + index" class="badge badge-pill badge-primary bg-gradient-h"> 
138                                                                	<span class="badge-item badge-item-expand">{{ item.name }}</span> 
139                                                                </span> 
140                                                            </template> 
141                                                        </p> 
142                                                        <p class="text-dark mb-0">A partire da {{ package.basePrice | money }}</p> 
143                                                         
144                                                        <template v-for="(sconto, index) in package.purchaseBeforeDiscount"> 
145                                                            <p v-if="isDiscountValid(sconto) && sconto.discount != 0" :key="'discount-' + index + '-' + package._id.$oid" class="text-muted small mb-0"> 
146                                                                Acquista prima del {{ sconto.dateEnd | moment().format("DD MMMM YYYY") }}: 
147                                                                <span class="label label-success"> 
148                                                					<span class="label-item label-item-expand">Sconto di {{ sconto.discount | money }}</span> 
149                                                				</span> 
150                                            				</p> 
151                                                        </template> 
152                                                    </section> 
153                                                </div> 
154                                                <div class="autofit-col"> 
155                                                    <section class="autofit-section"> 
156                                                        <button class="btn btn-dark py-2 px-3 px-lg-4" v-if="_.get(selectedPackage, '_id.$oid', '') == package._id.$oid"> 
157                                                            Scelto 
158                                                            <i class="fas fa-check ml-2"></i> 
159                                                        </button> 
160                                                         
161                                                        <button @click="selectPackage(package._id.$oid)" class="btn btn-outline-dark py-2 px-3 px-lg-4" v-else> 
162                                                            Scegli 
163                                                        </button> 
164                                                    </section> 
165                                                </div> 
166                                            </div> 
167                                             
168                                            <div v-if="index < packages.length - 1" class="dropdown-divider w-75 mx-auto my-3"></div> 
169                                        </div> 
170                                    </div> 
171                                </div> 
172                                 
173                                <div class="col-12"> 
174                                    <div class="card void mt-3 mt-lg-5 mb-0"> 
175                                        <div class="card-row"> 
176                                            <div class="autofit-col autofit-col-expand"> 
177                                                <section class="autofit-section text-left"> 
178                                                    <#-- 
179                                                    <button @click="gotoStep('prev')" class="btn btn-outline-dark py-2 px-3 px-lg-4"> 
180                                                        Indietro 
181                                                    </button> 
182                                                    --> 
183                                                </section> 
184                                            </div> 
185                                            <div class="autofit-col autofit-col-expand"> 
186                                                <section class="autofit-section text-right"> 
187                                                    <button @click="!_.isEmpty(selectedPackage) ? gotoStep('next') : ''" class="btn btn-gradient py-2 px-3 px-lg-4" :disabled="_.isEmpty(selectedPackage)"> 
188                                                        Avanti 
189                                                    </button> 
190                                                </section> 
191                                            </div> 
192                                        </div> 
193                                    </div> 
194                                </div> 
195                            </div> 
196                        </div> 
197                         
198                        <#-- TRASPORTO --> 
199                        <div class="tab-pane fade" :class="{'show active': currentStep == 2}" role="tabpanel"> 
200                            <div class="row justify-content-between"> 
201                                <div class="d-none d-lg-block col-12 mb-4"> 
202                                    <p class="text-dark display-5 font-weight-light">Scegli il tuo trasferimento</p> 
203                                </div> 
204                                 
205                                <div class="col-12 col-lg-6" v-if="!_.isEmpty(selectedPackage)"> 
206                                    <ul class="list-group mb-lg-0"> 
207                                    	<li v-for="(partenza, index) in selectedPackage.airportsAndPrices" :key="'airport-' + index" class="list-group-item"> 
208                                    	    <div class="card-row flex-column flex-lg-row"> 
209                                    	        <div class="autofit-col autofit-col-expand"> 
210                                    	            <section class="autofit-section my-auto"> 
211                                    	                <span class="label label-success" v-if="partenza.price == 0"> 
212                                        					<span class="label-item label-item-expand">Volo incluso</span> 
213                                        				</span> 
214                                                				 
215                                            			<div class="custom-control custom-radio"> 
216                                            				<label> 
217                                            				    <input class="custom-control-input" type="radio" name="airportsAndPrices" v-model="selectedAirport" :value="partenza" /> 
218                                            					<span class="custom-control-label"> 
219                                            					    <span class="custom-control-label-text">{{ getCity(partenza.airport) }}</span> 
220                                            					</span> 
221                                            				</label> 
222                                            			</div> 
223                                            		</section> 
224                                        		</div> 
225                                        		<div class="autofit-col autofit-col-expand"> 
226                                    				<section class="autofit-section my-auto"> 
227                                    				    <p class="text-dark text-right h3 mb-0 mr-3">{{ partenza.price | money }}</p> 
228                                    				</section> 
229                                        		</div> 
230                                    	    </div> 
231                                    	</li> 
232                                    </ul> 
233                                </div> 
234                                <div class="col-12 col-lg-6" v-else> 
235                                    <p class="text-dark display-5 font-weight-light">Per continuare, seleziona un periodo dalla prima pagina.</p> 
236                                </div> 
237                                 
238                                <div class="col-12"> 
239                                    <div class="card void mt-3 mt-lg-5 mb-0"> 
240                                        <div class="card-row"> 
241                                            <div class="autofit-col autofit-col-expand"> 
242                                                <section class="autofit-section text-left"> 
243                                                    <button @click="gotoStep('prev')" class="btn btn-outline-dark py-2 px-3 px-lg-4"> 
244                                                        Indietro 
245                                                    </button> 
246                                                </section> 
247                                            </div> 
248                                            <div class="autofit-col autofit-col-expand"> 
249                                                <section class="autofit-section text-right"> 
250                                                    <button @click="!_.isEmpty(selectedAirport) ? gotoStep('next') : ''" class="btn btn-gradient py-2 px-3 px-lg-4" :disabled="_.isEmpty(selectedAirport)"> 
251                                                        Avanti 
252                                                    </button> 
253                                                </section> 
254                                            </div> 
255                                        </div> 
256                                    </div> 
257                                </div> 
258                            </div> 
259                        </div> 
260                         
261                        <#-- ALLOGGIO --> 
262                        <div class="tab-pane fade" :class="{'show active': currentStep == 3}" role="tabpanel"> 
263                            <div class="row"> 
264                                <div class="d-none d-lg-block col-12 mb-4"> 
265                                    <p class="text-dark display-5 font-weight-light">Scegli l'alloggio</p> 
266                                </div> 
267                                 
268                                <div class="col-12 col-lg-7" v-if="!_.isEmpty(selectedPackage)"> 
269                                    <ul class="list-group mb-lg-0"> 
270                                    	<li v-for="(accomodation, index) in selectedPackage.lodgingTypesAndPrices" :key="'accomodation-' + index" class="list-group-item"> 
271                                    	    <div class="card-row flex-column flex-lg-row"> 
272                                    	        <div class="autofit-col autofit-col-expand"> 
273                                    	            <section class="autofit-section my-auto"> 
274                                            			<div class="custom-control custom-radio"> 
275                                            				<label> 
276                                            				    <input class="custom-control-input" type="radio" name="lodgingTypesAndPrices" v-model="selectedAccomodation" :value="accomodation" /> 
277                                            					<span class="custom-control-label"> 
278                                            					    <span class="custom-control-label-text">{{ accomodation.lodgingType }}</span> 
279                                            					</span> 
280                                            				</label> 
281                                            			</div> 
282                                            		</section> 
283                                        		</div> 
284                                        		<div class="autofit-col autofit-col-expand"> 
285                                    				<section class="autofit-section my-auto"> 
286                                    				    <p class="text-dark text-right h3 mb-0 mr-3">{{ accomodation.price | money }}</p> 
287                                    				</section> 
288                                        		</div> 
289                                    	    </div> 
290                                    	</li> 
291                                    </ul> 
292                                </div> 
293                                <div class="col-12" v-else> 
294                                    <p class="text-dark display-5 font-weight-light">Per continuare, seleziona un periodo dalla prima pagina.</p> 
295                                </div> 
296                                 
297                                <div class="col-12"> 
298                                    <div class="card void mt-3 mt-lg-5 mb-0"> 
299                                        <div class="card-row"> 
300                                            <div class="autofit-col autofit-col-expand"> 
301                                                <section class="autofit-section text-left"> 
302                                                    <button @click="gotoStep('prev')" class="btn btn-outline-dark py-2 px-3 px-lg-4"> 
303                                                        Indietro 
304                                                    </button> 
305                                                </section> 
306                                            </div> 
307                                            <div class="autofit-col autofit-col-expand"> 
308                                                <section class="autofit-section text-right"> 
309                                                    <button @click="!_.isEmpty(selectedAccomodation) ? gotoStep('next') : ''" class="btn btn-gradient py-2 px-3 px-lg-4" :disabled="_.isEmpty(selectedAccomodation)"> 
310                                                        Avanti 
311                                                    </button> 
312                                                </section> 
313                                            </div> 
314                                        </div> 
315                                    </div> 
316                                </div> 
317                            </div> 
318                        </div> 
319                         
320                        <#-- SERVIZI --> 
321                        <div class="tab-pane fade" :class="{'show active': currentStep == 4}" role="tabpanel"> 
322                            <div class="row"> 
323                                <div class="d-none d-lg-block col-12 mb-4"> 
324                                    <p class="text-dark display-5 font-weight-light">Scegli I servizi</p> 
325                                </div> 
326                                 
327                                <div class="col-12 col-lg-7" v-if="!_.isEmpty(selectedPackage)"> 
328                                    <ul class="list-group mb-lg-0"> 
329                                    	<li v-for="(service, index) in selectedPackage.servicesAndPrices" :key="'service-' + index" class="list-group-item"> 
330                                    	    <div class="card-row flex-column flex-lg-row"> 
331                                    	        <div class="autofit-col autofit-col-expand"> 
332                                    	            <section class="autofit-section my-auto"> 
333                                    	                <span class="label label-danger" v-if="service.mandatory"> 
334                                        					<span class="label-item label-item-expand">Obbligatorio</span> 
335                                        				</span> 
336                                        				 
337                                            			<div class="custom-control custom-checkbox"> 
338                                            				<label class="{'no-events': service.mandatory}"> 
339                                            					<input class="custom-control-input" :class="{'no-events': service.mandatory}" type="checkbox" v-model="selectedServices" :value="service" :checked="service.mandatory" :disabled="service.mandatory" /> 
340                                            					<span class="custom-control-label"> 
341                                            					    <span class="custom-control-label-text">{{ service.service }}</span> 
342                                            					</span> 
343                                            				</label> 
344                                            			</div> 
345                                            		</section> 
346                                        		</div> 
347                                        		<div class="autofit-col autofit-col-expand" style="min-width: 15%;"> 
348                                    				<section class="autofit-section my-auto"> 
349                                    				    <p class="text-dark text-right h3 mb-0 mr-3">{{ service.price | money }}</p> 
350                                    				</section> 
351                                        		</div> 
352                                    	    </div> 
353                                    	</li> 
354                                    </ul> 
355                                </div> 
356                                <div class="col-12" v-else> 
357                                    <p class="text-dark display-5 font-weight-light">Per continuare, seleziona un periodo dalla prima pagina.</p> 
358                                </div> 
359                                 
360                                <div class="col-12"> 
361                                    <div class="card void mt-3 mt-lg-5 mb-0"> 
362                                        <div class="card-row"> 
363                                            <div class="autofit-col autofit-col-expand"> 
364                                                <section class="autofit-section text-left"> 
365                                                    <button @click="gotoStep('prev')" class="btn btn-outline-dark py-2 px-3 px-lg-4"> 
366                                                        Indietro 
367                                                    </button> 
368                                                </section> 
369                                            </div> 
370                                            <div class="autofit-col autofit-col-expand"> 
371                                                <section class="autofit-section text-right"> 
372                                                    <button @click="selectedServices.length > 0 ? gotoStep('next') : ''" class="btn btn-gradient py-2 px-3 px-lg-4" :disabled="selectedServices.length == 0"> 
373                                                        Avanti 
374                                                    </button> 
375                                                </section> 
376                                            </div> 
377                                        </div> 
378                                    </div> 
379                                </div> 
380                            </div> 
381                        </div> 
382                         
383                        <#-- PAGAMENTO --> 
384                        <div class="tab-pane fade" :class="{'show active': currentStep == 5}" role="tabpanel" v-if="isDev"> 
385                            <div class="row"> 
386                                <div class="d-none d-lg-block col-12 mb-4"> 
387                                    <p class="text-dark display-5 font-weight-light">Scegli il metodo di pagamento</p> 
388                                </div> 
389                                 
390                                <div class="col-12 col-lg-7" v-if="!_.isEmpty(selectedPackage)"> 
391                                    <ul class="list-group mb-lg-0"> 
392                                    	<li v-for="(type, index) in selectedPackage.paymentType" :key="'type-' + index" class="list-group-item"> 
393                                    	    <div class="card-row flex-column flex-lg-row"> 
394                                    	        <div class="autofit-col autofit-col-expand"> 
395                                    	            <section class="autofit-section my-auto"> 
396                                            			<div class="custom-control custom-radio"> 
397                                            				<label> 
398                                            				    <input class="custom-control-input" type="radio" name="paymentMethod" v-model="selectedPayment" :value="type" /> 
399                                            					<span class="custom-control-label"> 
400                                            					    <span class="custom-control-label-text"> 
401                                            					        {{ type.type }} 
402                                            					    </span> 
403                                            					</span> 
404                                            				</label> 
405                                            			</div> 
406                                            		</section> 
407                                        		</div> 
408                                        		<div class="autofit-col autofit-col-expand" v-if="type.amount != 0"> 
409                                    				<section class="autofit-section my-auto"> 
410                                    				    <p class="text-dark text-right h3 mb-0 mr-3">Acconto: {{ type.amount | money }}</p> 
411                                    				</section> 
412                                        		</div> 
413                                        		<div class="autofit-col autofit-col-expand"> 
414                                    				<section class="autofit-section text-right my-auto"> 
415                                    				    <img src="${images_folder}/nexi.png" height="60" alt="visa-mastercard" v-if="type == 'bonifico'"> 
416                                    				    <img src="${images_folder}/visa-mastercard.png" height="60" alt="visa-mastercard" v-if="type == 'cartaCredito'"> 
417                                    				    <img src="${images_folder}/paypal.png" height="60" alt="visa-mastercard" v-if="type == 'cartaCreditoAcconto'"> 
418                                    				</section> 
419                                        		</div> 
420                                    	    </div> 
421                                    	</li> 
422                                    </ul> 
423                                </div> 
424                                <div class="col-12" v-else> 
425                                    <p class="text-dark display-5 font-weight-light">Per continuare, seleziona un periodo dalla prima pagina.</p> 
426                                </div> 
427                                 
428                                <div class="col-12"> 
429                                    <div class="card void mt-3 mt-lg-5 mb-0"> 
430                                        <div class="card-row"> 
431                                            <div class="autofit-col autofit-col-expand"> 
432                                                <section class="autofit-section text-left"> 
433                                                    <button @click="gotoStep('prev')" class="btn btn-outline-dark py-2 px-3 px-lg-4"> 
434                                                        Indietro 
435                                                    </button> 
436                                                </section> 
437                                            </div> 
438                                            <div class="autofit-col autofit-col-expand"> 
439                                                <section class="autofit-section text-right"> 
440                                                    <button @click="!_.isEmpty(selectedPayment) ? gotoStep('next') : ''" class="btn btn-gradient py-2 px-3 px-lg-4" :disabled="_.isEmpty(selectedPayment)"> 
441                                                        Avanti 
442                                                    </button> 
443                                                </section> 
444                                            </div> 
445                                        </div> 
446                                    </div> 
447                                </div> 
448                            </div> 
449                        </div> 
450                         
451                        <#-- USER INFOS || (totalSteps == 6 && currentStep == 5) --> 
452                        <div class="tab-pane fade" :class="{'show active': (isDev && totalSteps == 7 && currentStep == 6)}" role="tabpanel"> 
453                            <div class="row justify-content-center"> 
454                                <div class="d-none d-lg-block col-12 mb-4"> 
455                                    <p class="text-dark display-5 font-weight-light">Inserisci i tuoi dati</p> 
456                                </div> 
457                                 
458                                <div class="col-12 col-lg-9" v-if="!_.isEmpty(selectedPackage)"> 
459                                    <div class="sheet sheet-lg"> 
460                                        <div class="sheet-header"> 
461                                    		<div class="sheet-text"> 
462                                    		    Vuoi che i dati vengano salvati automaticamente per i prossimi acquisti? 
463                                    		    Impostali nel <a href="javascript:void(0);" @click="redirectParent('/profilo')" class="text-aqua font-weight-bold">tuo profilo</a> per non doverli inserire la prossima volta 
464                                    		</div> 
465                                    	</div> 
466                                    	<div class="sheet-section"> 
467                                    		<div class="form-group-autofit"> 
468                                    			<div class="form-group-item"> 
469                                    				<label for="userName">Nome *</label> 
470                                    				<input class="form-control" id="userName" v-model="userData.firstName" type="text"/> 
471                                    			</div> 
472                                    			<div class="form-group-item"> 
473                                    				<label for="userSurname">Cognome *</label> 
474                                    				<input class="form-control" id="userSurname" v-model="userData.lastName" type="text"/> 
475                                    			</div> 
476                                    		</div> 
477                                    		<div class="form-group-autofit"> 
478                                    			<div class="form-group-item"> 
479                                    				<label for="billingEmail">Email *</label> 
480                                    				<input class="form-control" id="billingEmail" v-model="userMail" type="email"/> 
481                                    			</div> 
482                                    			<div class="form-group-item"> 
483                                    				<label for="phone">Telefono *</label> 
484                                    				<input class="form-control" id="phone" v-model="userData.phone" type="text"/> 
485                                    			</div> 
486                                    		</div> 
487                                    		<div class="form-group-autofit"> 
488                                    			<div class="form-group-item"> 
489                                    				<label for="billingAddress">Indirizzo *</label> 
490                                    				<input class="form-control" id="billingAddress" v-model="userData.billingStreetAddress" type="text"/> 
491                                    			</div> 
492                                    			<div class="form-group-item"> 
493                                    				<label for="billingPostalCode">CAP *</label> 
494                                    				<input class="form-control" id="billingPostalCode" v-model="userData.billingPostalCode" type="text"/> 
495                                    			</div> 
496                                    		</div> 
497                                    		<div class="form-group-autofit"> 
498                                    			<div class="form-group-item"> 
499                                    				<label for="billingCity">Città *</label> 
500                                    				<input class="form-control" id="billingCity" v-model="userData.billingCity" type="text"/> 
501                                    			</div> 
502                                    		    <div class="form-group-item" v-if="signedIn"> 
503                                    		        <label for="regione_acquisto">Provincia</label> 
504                                                	<select id="regione_acquisto" class="form-control" v-model="userData.billingRegionId"> 
505                                                	    <option v-if="regionList.length == 0" disabled>Non disponibile</option> 
506                                                		<option v-for="region in regionList" :key="region.CODE" :value="region.ID">{{ region.NAME }}</option> 
507                                                	</select> 
508                                    		    </div> 
509                                    		</div> 
510                                    		<div class="form-group-autofit"> 
511                                    		    <div class="form-group-item" v-if="signedIn"> 
512                                        		    <label for="nazione_acquisto">Stato</label> 
513                                                	<select id="nazione_acquisto" class="form-control" v-model="userData.billingCountryId" @change="getRegionList()"> 
514                                                	    <option value="null" selected>Scegli</option> 
515                                                		<option v-for="country in countryList" :key="country.A2" :value="country.ID">{{ country.NAME }}</option> 
516                                                	</select> 
517                                    		    </div> 
518                                    			<div class="form-group-item"> 
519                                    				<label for="fiscalCode">Codice fiscale</label> 
520                                    				<input class="form-control" id="fiscalCode" v-model="userData.fiscalCode" type="text"/> 
521                                    			</div> 
522                                    		</div> 
523                                    		 
524                                    		<div class="form-group-autofit"> 
525                                            	<div class="form-group-item"> 
526                                            		<div class="form-text">I campi contrassegnati con * sono obbligatori.</div> 
527                                            	</div> 
528                                            </div> 
529                                    	</div> 
530                                    </div> 
531                                </div> 
532                                <div class="col-12" v-else> 
533                                    <p class="text-dark display-5 font-weight-light">Per continuare, seleziona un periodo dalla prima pagina.</p> 
534                                </div> 
535                                 
536                                <div class="col-12"> 
537                                    <div class="card void mt-3 mt-lg-5 mb-0"> 
538                                        <div class="card-row"> 
539                                            <div class="autofit-col autofit-col-expand"> 
540                                                <section class="autofit-section text-left"> 
541                                                    <button @click="gotoStep('prev')" class="btn btn-outline-dark py-2 px-3 px-lg-4"> 
542                                                        Indietro 
543                                                    </button> 
544                                                </section> 
545                                            </div> 
546                                            <div class="autofit-col autofit-col-expand"> 
547                                                <section class="autofit-section text-right"> 
548                                                    <button @click="gotoStep('next')" class="btn btn-gradient py-2 px-3 px-lg-4" :disabled="!valid"> 
549                                                        Avanti 
550                                                    </button> 
551                                                </section> 
552                                            </div> 
553                                        </div> 
554                                    </div> 
555                                </div> 
556                            </div> 
557                        </div> 
558                         
559                        <#-- RIEPILOGO --> 
560                        <div class="tab-pane fade" :class="{'show active': (isDev && currentStep == 7) || (totalSteps == 5 && currentStep == 5)}" role="tabpanel"> 
561                         
562                            <div class="sheet border-0 p-0 p-lg-4"> 
563                                <div class="row"> 
564                                    <div class="d-none d-lg-block col-12 mb-4"> 
565                                        <p class="text-dark display-5 font-weight-light">Riepilogo</p> 
566                                    </div> 
567                                     
568                                    <div class="col-12"> 
569                                        <div class="card void"> 
570                                    	    <div class="card-row flex-column flex-lg-row mb-4 mb-lg-0"> 
571                                    	        <div class="autofit-col autofit-col-expand"> 
572                                    	            <section class="autofit-section mb-auto"> 
573                                            			<p class="h1 display-5 title-large">{{ name }}</p> 
574                                            			<p class="text-dark"> 
575                                    	                    Dal {{ selectedPackage.startDate | moment().format("DD MMMM YYYY") }} al {{ selectedPackage.endDate | moment().format("DD MMMM YYYY") }} 
576                                                        </p> 
577                                                    </section> 
578                                                </div> 
579                                            </div> 
580                                        </div> 
581                                    </div> 
582                                </div> 
583                                 
584                                <div class="row"> 
585                                    <div class="col-12 col-lg-6 order-2 order-lg-1"> 
586                                        <div class="panel panel-secondary"> 
587                                            <div class="panel-header"> 
588                                                <div class="panel-title"> 
589                                                    Informazioni di base: 
590                                                </div> 
591                                            </div> 
592                                            <div class="panel-body"> 
593                                                <p class="mb-0"> 
594                                                    Prezzo del viaggio: <span class="font-weight-bold">{{ packagePrice | money }}</span> 
595                                                </p> 
596                                                <p class="mb-0" v-if="packageDiscount != 0"> 
597                                                    Sconto applicato: <span class="font-weight-bold">{{ packageDiscount | money }}</span> 
598                                                </p> 
599                                            </div> 
600                                        </div> 
601                                         
602                                        <div class="panel panel-secondary"> 
603                                            <div class="panel-header"> 
604                                                <div class="panel-title"> 
605                                                    Sistemazione: 
606                                                </div> 
607                                            </div> 
608                                            <div class="panel-body"> 
609                                                <p class="mb-0"> 
610                                                    {{ selectedAccomodation.lodgingType }} <span class="font-weight-bold">({{ selectedAccomodation.price | money }})</span> 
611                                                </p> 
612                                            </div> 
613                                        </div> 
614                                         
615                                        <div class="panel panel-secondary"> 
616                                            <div class="panel-header"> 
617                                                <div class="panel-title"> 
618                                                    Servizi scelti: 
619                                                </div> 
620                                            </div> 
621                                            <div class="panel-body"> 
622                                                <p v-for="(service, index) in selectedServices" :key="'selectedService-' + index" class="mb-0"> 
623                                                    {{ service.service }} <span class="font-weight-bold">({{ service.price | money }})</span> 
624                                                </p> 
625                                            </div> 
626                                        </div> 
627                                         
628                                        <div class="panel panel-secondary"> 
629                                            <div class="panel-header"> 
630                                                <div class="panel-title"> 
631                                                    Trasporto scelto: 
632                                                </div> 
633                                            </div> 
634                                            <div class="panel-body"> 
635                                                <p class="mb-0"> 
636                                                    {{ selectedAirport.airport }} <span class="font-weight-bold">({{ selectedAirport.price | money }})</span> 
637                                                </p> 
638                                            </div> 
639                                        </div> 
640                                         
641                                        <div class="panel panel-secondary" v-if="isDev"> 
642                                            <div class="panel-header"> 
643                                                <div class="panel-title"> 
644                                                    Tipo di pagamento scelto: 
645                                                </div> 
646                                            </div> 
647                                            <div class="panel-body"> 
648                                                <div class="card void m-0 p-0"> 
649                                                    <div class="card-row"> 
650                                                        <div class="autofit-col autofit-col-expand my-auto"> 
651                                                            <section class="autofit-section"> 
652                                                                <p class="mb-0"> 
653                                                                    {{ selectedPayment.type }} <span class="font-weight-bold" v-if="selectedPayment.amount && selectedPayment.amount != 0">( Acconto: {{ selectedPayment.amount | money }})</span> 
654                                                                </p> 
655                                                            </section> 
656                                                        </div> 
657                                                    </div> 
658                                                </div> 
659                                            </div> 
660                                        </div> 
661                                    </div> 
662                                    <div class="col-12 col-lg-6 order-1 order-lg-2"> 
663                                        <div class="panel panel-secondary"> 
664                                            <div class="panel-body"> 
665                                                <div class="card void my-3"> 
666                                                    <div class="d-flex justify-content-center"> 
667                                                        <div class="d-flex flex-column text-center mx-auto"> 
668                                        				    <span class="sticker sticker-xl sticker-person rounded-circle mb-4"> 
669                                                            	<span class="sticker-overlay"> 
670                                                            		<img :src="image" class="w-100 h-100" :alt="name"> 
671                                                            	</span> 
672                                                            </span> 
673                                                             
674                                                            <button class="btn btn-outline-dark px-3" @click="favourite ? removeFavourite() : setFavourite()" v-if="signedIn"> 
675                                                                <span v-if="favourite"> 
676                                                                    Salvato 
677                                                                </span> 
678                                                                <span v-else> 
679                                                                    Salva 
680                                                                </span> 
681                                                                 
682                                                                <i class="fa-heart fa-lg ml-3" :class="favourite ? 'fas' : 'far'"></i> 
683                                                            </button> 
684                                                        </div> 
685                                                    </div> 
686                                                </div> 
687                                                 
688                                                <div class="card void my-3"> 
689                                                    <div class="card-row flex-column"> 
690                                                        <div class="autofit-col autofit-col-expand"> 
691                                                            <section class="autofit-section"> 
692                                                                <p class="text-dark text-center my-4"> 
693                                                                    Totale importo: 
694                                                                    <span class="display-5 ml-3">{{ totalPrice | money }}</span> 
695                                                                </p> 
696                                                                <p class="text-dark text-center my-4" v-if="_.get(selectedPayment, 'amount', 0) != 0"> 
697                                                                    Acconto da pagare: 
698                                                                    <span class="display-5 ml-3">{{ selectedPayment.amount | money }}</span> 
699                                                                </p> 
700                                                            </section> 
701                                                        </div> 
702                                                        <div class="autofit-col autofit-col-expand mb-4"> 
703                                                            <section class="autofit-section"> 
704                                                             
705                                                                <div v-for="(attachment, index) in attachments" :key="'attachment-' + index" class="card-row mb-4 mb-lg-2"> 
706                                                                    <div class="autofit-col autofit-col-expand"> 
707                                                                        <section class="autofit-section"> 
708                                                                            <div class="custom-control custom-checkbox"> 
709                                                                    			<label> 
710                                                                    				<input v-model="policy['condition' + sum(index, 1)]" class="custom-control-input" type="checkbox"> 
711                                                                    				<span class="custom-control-label"> 
712                                                                    					<span class="custom-control-label-text"> 
713                                                                    					    {{ attachment.title }} 
714                                                                    					    <template v-if="attachment.mandatory">*</template> 
715                                                                    					</span> 
716                                                                    				</span> 
717                                                                    			</label> 
718                                                                    		</div> 
719                                                                        </section> 
720                                                                    </div> 
721                                                                    <div class="autofit-col"> 
722                                                                        <section class="autofit-section"> 
723                                                                            <a :href="attachment.file" class="text-aqua mb-0" download> 
724                                                                                Scarica il documento 
725                                                                                <i class="fas fa-download ml-1"></i> 
726                                                                            </a> 
727                                                                        </section> 
728                                                                    </div> 
729                                                                </div> 
730                                                             
731                                                                <#-- 
732                                                                <div class="card-row mb-4 mb-lg-2"> 
733                                                                    <div class="autofit-col autofit-col-expand"> 
734                                                                        <section class="autofit-section"> 
735                                                                            <div class="custom-control custom-checkbox"> 
736                                                                    			<label> 
737                                                                    				<input v-model="policy.acceptedConditions" class="custom-control-input" type="checkbox"> 
738                                                                    				<span class="custom-control-label"> 
739                                                                    					<span class="custom-control-label-text">Accetto le condizioni generali di vendita</span> 
740                                                                    				</span> 
741                                                                    			</label> 
742                                                                    		</div> 
743                                                                        </section> 
744                                                                    </div> 
745                                                                    <div class="autofit-col"> 
746                                                                        <section class="autofit-section"> 
747                                                                            <a href="/documents/383793/873164/Condizioni_generali_di_vendita.pdf" class="text-aqua mb-0" download> 
748                                                                                Scarica l'allegato 
749                                                                                <i class="fas fa-download ml-1"></i> 
750                                                                            </a> 
751                                                                        </section> 
752                                                                    </div> 
753                                                                </div> 
754                                                                <div class="card-row mb-4 mb-lg-2"> 
755                                                                    <div class="autofit-col autofit-col-expand"> 
756                                                                        <section class="autofit-section"> 
757                                                                            <div class="custom-control custom-checkbox"> 
758                                                                    			<label> 
759                                                                    				<input v-model="policy.acceptedInsurance" class="custom-control-input" type="checkbox"> 
760                                                                    				<span class="custom-control-label"> 
761                                                                    					<span class="custom-control-label-text">Accetto il contratto di assicurazione NOBIS</span> 
762                                                                    				</span> 
763                                                                    			</label> 
764                                                                    		</div> 
765                                                                        </section> 
766                                                                    </div> 
767                                                                    <div class="autofit-col"> 
768                                                                        <section class="autofit-section"> 
769                                                                            <a href="/documents/383793/873164/NOBIS+Compagnia+di+Assicurazioni_Set_informativo.pdf" class="text-aqua mb-0" download> 
770                                                                                Scarica l'allegato 
771                                                                                <i class="fas fa-download ml-1"></i> 
772                                                                            </a> 
773                                                                        </section> 
774                                                                    </div> 
775                                                        		</div> 
776                                                                <div class="card-row mb-4 mb-lg-2"> 
777                                                                    <div class="autofit-col autofit-col-expand"> 
778                                                                        <section class="autofit-section"> 
779                                                                            <div class="custom-control custom-checkbox"> 
780                                                                    			<label> 
781                                                                    				<input class="custom-control-input" type="checkbox"> 
782                                                                    				<span class="custom-control-label"> 
783                                                                    					<span class="custom-control-label-text">Accetto il contratto di assicurazione ITALIANA (facoltativo)</span> 
784                                                                    				</span> 
785                                                                    			</label> 
786                                                                    		</div> 
787                                                                        </section> 
788                                                                    </div> 
789                                                                    <div class="autofit-col"> 
790                                                                        <section class="autofit-section"> 
791                                                                            <a href="/documents/383793/873164/ITALIANA+Assicurazioni_Set_informativo.pdf" class="text-aqua mb-0" download> 
792                                                                                Scarica l'allegato 
793                                                                                <i class="fas fa-download ml-1"></i> 
794                                                                            </a> 
795                                                                        </section> 
796                                                                    </div> 
797                                                        		</div> 
798                                                        		--> 
799                                                            </section> 
800                                                        </div> 
801                                                        <div class="autofit-col autofit-col-expand"> 
802                                                            <section class="autofit-section"> 
803                                                                <button @click="setProgressData();openParentModal('#requestinfo-payment-modal')" class="btn btn-gradient btn-block py-2 mb-3" :disabled="!validPolicy"> 
804                                                                    Verifica disponibilità 
805                                                                </button> 
806                                                                 
807                                                                <button v-if="signedIn" @click="createOrderAndPaymentUrl()" class="btn btn-gradient btn-block py-2" :disabled="!validPolicy"> 
808                                                                    Procedi al pagamento 
809                                                                </button> 
810                                                                <button v-else @click="setProgressData();redirectParent('/login')" class="btn btn-outline-dark btn-block py-2"> 
811                                                                    Accedi per procedere al pagamento 
812                                                                </button> 
813                                                            </section> 
814                                                        </div> 
815                                                    </div> 
816                                                </div> 
817                                            </div> 
818                                        </div> 
819                                    </div> 
820                                </div> 
821                                 
822                                <div class="row"> 
823                                    <div class="col-12"> 
824                                        <div class="card void mt-3 mt-lg-5 mb-0"> 
825                                            <div class="card-row"> 
826                                                <div class="autofit-col autofit-col-expand"> 
827                                                    <section class="autofit-section text-left"> 
828                                                        <button @click="gotoStep('prev')" class="btn btn-outline-dark py-2 px-3 px-lg-4"> 
829                                                            Indietro 
830                                                        </button> 
831                                                    </section> 
832                                                </div> 
833                                            </div> 
834                                        </div> 
835                                    </div> 
836                                </div> 
837                            </div> 
838                        </div> 
839                    </div> 
840                </div> 
841            </div> 
842        </div> 
843    </div> 
844</#macro> 
845 
846<#assign 
847    DLAppLocalService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLAppLocalService") 
848    JALS = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") 
849    suggestoMkspAPI = serviceLocator.findService("eu.suggesto.suggestogui.service.SuggestoGuiLocalService") 
850    productServiceAPI = serviceLocator.findService("eu.suggesto.d40.builder.d40.service.ProductLocalService") 
851    saxReaderUtil = staticUtil["com.liferay.portal.kernel.xml.SAXReaderUtil"] 
852     
853    images_folder = themeDisplay.getPathThemeImages() 
854    icons_folder = images_folder + "/icons" 
855    contentId = result.getRequestStringParameter("contentId") 
856    defLocale = localeUtil.fromLanguageId("it_IT") 
857    image = "https://via.placeholder.com/300" 
858    dateSoggiorno = [] 
859    packages = [] 
860    name = "Placeholder" 
861    prezzo_base = 0 
862    sCatSistemazione = "" 
863/> 
864 
865<#if contentId?has_content> 
866    <#assign 
867        packages = getPackagesByItemId(groupId, groupId, contentId) 
868        article = JALS.getArticle(themeDisplay.getSiteGroupId(), contentId) 
869        document = saxReaderUtil.read(article.getContent()) 
870        rootElement = document.getRootElement() 
871        groupedCategories = suggestoMkspAPI.getGroupedArticleCategories(groupId, contentId, locale, defLocale) 
872         
873        xPathDate = saxReaderUtil.createXPath("dynamic-element[@name='data_inizio']") 
874        xPathImage = saxReaderUtil.createXPath("dynamic-element[@name='anteprima']") 
875        xPathName = saxReaderUtil.createXPath("dynamic-element[@name='nome_scuola']/dynamic-content[@language-id='" + themeDisplay.getLocale() + "']") 
876        xPathPrezzo = saxReaderUtil.createXPath("dynamic-element[@name='prezzo_base']/dynamic-content[@language-id='" + themeDisplay.getLocale() + "']") 
877    /> 
878     
879    <#if (groupedCategories.length() > 0) > 
880        <#list 0..groupedCategories.length()-1 as i> 
881            <#assign 
882                gc = groupedCategories.getJSONObject(i) 
883                gcCat = gc.getJSONArray("categories") 
884                vacabularyName = gc.getString("vocabularyName") 
885            /> 
886             
887            <#if vacabularyName == "Tipo di sistemazione"> 
888                <#list 0..gcCat.length()-1 as y> 
889                    <#assign 
890                        sCat = gcCat.getJSONObject(y) 
891                        sCatId = sCat.getString("categoryId") 
892                        sCatSistemazione = sCat.getString("name") 
893                        sCatIcon = sCat.getString("icon") 
894                    /> 
895                </#list> 
896            </#if> 
897        </#list> 
898    </#if> 
899     
900    <#if xPathDate.selectNodes(rootElement)??> 
901        <#list xPathDate.selectNodes(rootElement) as node> 
902            <#assign 
903                dataInizio = node.selectSingleNode("dynamic-content[@language-id='" + themeDisplay.getLocale() + "']").getStringValue()?replace("-", "/") 
904                dataFine = node.selectSingleNode("dynamic-element[@name='data_fine']/dynamic-content[@language-id='" + themeDisplay.getLocale() + "']").getStringValue()?replace("-", "/") 
905                dateSoggiorno += [ 
906
907                        "dataInizio": "${dataInizio}", 
908                        "dataFine": "${dataFine}" 
909
910
911            /> 
912        </#list> 
913    </#if> 
914     
915    <#if xPathImage.selectSingleNode(rootElement)??> 
916        <#compress> 
917            <#assign tmpImage = xPathImage.selectSingleNode(rootElement).getStringValue()?trim> 
918        </#compress> 
919         
920        <#if tmpImage?has_content> 
921            <#assign 
922                image = tmpImage 
923                jsonField = jsonFactoryUtil.createJSONObject(image) 
924                fileEntry = DLAppLocalService.getFileEntryByUuidAndGroupId(jsonField.uuid, groupId) 
925                image = "/documents/" + jsonField.groupId + "/" + fileEntry.folderId + "/" + jsonField.title + "/" + jsonField.uuid 
926            /> 
927        </#if> 
928    </#if> 
929     
930    <#if xPathName.selectSingleNode(rootElement)??> 
931        <#assign name = xPathName.selectSingleNode(rootElement).getStringValue()?trim?capitalize> 
932    </#if> 
933     
934    <#if xPathPrezzo.selectSingleNode(rootElement)??> 
935        <#assign prezzo_base = xPathPrezzo.selectSingleNode(rootElement).getStringValue()?trim> 
936    </#if> 
937</#if> 
938 
939<@printContent /> 
940 
941<script> 
942    if(!Liferay.ThemeDisplay.getUserEmailAddress().includes("@suggesto.")){ 
943        Vue.config.devtools = false; 
944
945     
946    Vue.filter("money", function(value){ 
947        return parseFloat(value).toFixed(2).toString().replace(".", ",") + "€"; 
948    }); 
949     
950    var pay = new Vue({ 
951        el: "#pay", 
952        data: { 
953            isDev: Liferay.ThemeDisplay.getUserEmailAddress().includes("@suggesto") && !Liferay.ThemeDisplay.getUserEmailAddress().includes("studente"), 
954            loading: true, 
955            favourite: false, 
956            contentId: "${contentId}", 
957            image: "${getPrefix(htmlUtil.escape(image), 300, '')}", 
958            currentStep: 1, 
959            totalSteps: 0, 
960            name: "${name}", 
961            signedIn: Liferay.ThemeDisplay.isSignedIn(), 
962            groupId: Liferay.ThemeDisplay.getScopeGroupId(), 
963            userMail: Liferay.ThemeDisplay.getUserEmailAddress(), 
964            defaultLanguage: "it", 
965            defaultCountryId: "8", 
966            packagePrice: 0, 
967            packageDiscount: 0, 
968            selectedPackage: {}, 
969            selectedAirport: {}, 
970            selectedAccomodation: {}, 
971            selectedServices: [], 
972            selectedPayment: {}, 
973            paymentLink: "#", 
974            oid: "", 
975            packages: [], 
976            attachments: [], 
977            calendar: { 
978                ready: false, 
979                initialPage: { 
980                    month: null, 
981                    year: null 
982                }, 
983                periodoSelected: { 
984                    start: null, 
985                    end: null 
986                }, 
987                dataSelected: null, 
988                dataInizio: null, 
989                dataFine: null, 
990                attributes: [] 
991            }, 
992            policy: { 
993                <#list allegati as allegato> 
994                    condition${allegato?counter}: false, 
995                </#list> 
996            }, 
997            countryList: [], 
998            regionList: [], 
999            userData: {} 
1000        }, 
1001        created(){ 
1002            var that = this; 
1003             
1004            moment.locale(navigator.language.split("-")[0]); 
1005             
1006            window.addEventListener("keyup", function(e){  
1007                if(e.which == 27){ 
1008                    that.closeParentModal("#pay-modal"); 
1009
1010            }); 
1011             
1012            this.getPackages(); 
1013            this.initCalendar(); 
1014            this.setAttachments(); 
1015        }, 
1016        mounted(){ 
1017            window.addEventListener("message", this.getExternalData.bind(this)); 
1018             
1019            if(this.signedIn){ 
1020                this.userId = Liferay.ThemeDisplay.getUserId(); 
1021                this.checkFavourite(); 
1022                this.getUserData(); 
1023                 
1024                if(this.isDev){ 
1025                    this.totalSteps = 7; 
1026                }else{ 
1027                    this.totalSteps = 5; 
1028
1029            }else{ 
1030                //this.getCountryList(); 
1031                this.totalSteps = 5; 
1032
1033             
1034            this.calendar.ready = true; 
1035            this.getProgressData(); 
1036            this.loading = false; 
1037        }, 
1038        computed: { 
1039            totalPrice: function(){ 
1040                return this.selectedServices.reduce(function(total, item){ 
1041                    return Number(total) + Number(item.price); 
1042                }, Number(this.packagePrice) - Number(this.packageDiscount) + Number(this.selectedAirport.price || 0) + Number(this.selectedAccomodation.price || 0)); 
1043                 
1044                <#-- + Number(this.selectedPayment.amount || 0) --> 
1045            }, 
1046            validPolicy: function(){ 
1047                var valid = false; 
1048                 
1049                if( 
1050                    <#list allegati as allegato> 
1051                        <#assign stringSelector = "dynamic-element[@name='mandatory']/dynamic-content[@language-id = '" + themeDisplay.getLocale() + "']"> 
1052                        <#assign xPathSelector = saxReaderUtil.createXPath(stringSelector)> 
1053                        <#if xPathSelector.selectSingleNode(allegato)??> 
1054                            <#assign mandatory = xPathSelector.selectSingleNode(allegato).getData()> 
1055                        </#if> 
1056                         
1057                        <#if mandatory == "true">  
1058                            <#if !allegato?is_first> && </#if> 
1059                            this.policy.condition${allegato?counter} 
1060                        </#if> 
1061                    </#list> 
1062                ){ 
1063                    valid = true; 
1064
1065                 
1066                return valid; 
1067            }, 
1068            valid: function(){ 
1069                var valid = true; 
1070                 
1071                if(!this.userData.hasOwnProperty("firstName") || typeof this.userData["firstName"] !== "string" || this.userData["firstName"].length == 0){ 
1072                    valid = false; 
1073
1074                if(!this.userData.hasOwnProperty("lastName") || typeof this.userData["lastName"] !== "string" || this.userData["lastName"].length == 0){ 
1075                    valid = false; 
1076
1077                if(!this.userData.hasOwnProperty("billingPostalCode") || typeof this.userData["billingPostalCode"] !== "string" || this.userData["billingPostalCode"].length == 0){ 
1078                    valid = false; 
1079
1080                if(!this.userData.hasOwnProperty("billingStreetAddress") || typeof this.userData["billingStreetAddress"] !== "string" || this.userData["billingStreetAddress"].length == 0){ 
1081                    valid = false; 
1082
1083                if(!this.userData.hasOwnProperty("billingCity") || typeof this.userData["billingCity"] !== "string" || this.userData["billingCity"].length == 0){ 
1084                    valid = false; 
1085
1086                /* 
1087                if(!this.userData.hasOwnProperty("city") || typeof this.userData["city"] !== "string" || this.userData["city"].length == 0){ 
1088                    valid = false; 
1089
1090                */ 
1091                if(!this.userData.hasOwnProperty("phone") || typeof this.userData["phone"] !== "string" || this.userData["phone"].length == 0){ 
1092                    valid = false; 
1093
1094                 
1095                if(this.signedIn){ 
1096                    if(!this.userData.hasOwnProperty("billingCountryId") || typeof this.userData["billingCountryId"] !== "string" || this.userData["billingCountryId"].length == 0){ 
1097                        valid = false; 
1098
1099                    if(!this.userData.hasOwnProperty("billingRegionId") || typeof this.userData["billingRegionId"] !== "string" || this.userData["billingRegionId"].length == 0){ 
1100                        valid = false; 
1101
1102
1103                 
1104                if(this.userMail == ""){ 
1105                    valid = false; 
1106
1107                 
1108                return valid; 
1109
1110        }, 
1111        watch: { 
1112            "calendar.dataSelected": function(val){ 
1113                if(val != null){ 
1114                    this.showResults(val); 
1115
1116
1117        }, 
1118        methods: { 
1119            sum: function(num1, num2){ 
1120                return Number(num1 + num2); 
1121            }, 
1122            openParentModal: function(id){ 
1123                window.parent.$(id).modal("show"); 
1124            }, 
1125            closeParentModal: function(id){ 
1126                window.parent.$(id).modal("hide"); 
1127            }, 
1128            redirectParent: function(url){ 
1129                window.top.location = "${themeDisplay.getPortalURL()}" + url + "?from=" + window.top.location.href; 
1130            }, 
1131            gotoStep: function(step){ 
1132                if(typeof(step) == "number"){ 
1133                    this.currentStep = step; 
1134                }else{ 
1135                    if(step == "next"){ 
1136                        this.currentStep++; 
1137
1138                    if(step == "prev"){ 
1139                        this.currentStep--; 
1140
1141
1142            }, 
1143            getCity: function(fullString){ 
1144                return fullString.substr(0, fullString.indexOf('(') === -1 ? fullString.length : fullString.indexOf('(')); 
1145            }, 
1146            isBefore: function(data){ 
1147                return moment(data).isBefore(new Date()); 
1148            }, 
1149            isAfter: function(data){ 
1150                return moment(data).isAfter(new Date()); 
1151            }, 
1152            getExternalData: function(message){ 
1153                var strExtData = JSON.parse(JSON.stringify(message.data)); 
1154                 
1155                if(strExtData.source == null){ 
1156                    var extData = JSON.parse(strExtData); 
1157                    console.log("dati ricevuti da iframe"); 
1158                     
1159                    if(extData.key == "packageId"){ 
1160                        if(_.isEmpty(this.selectedPackage)){ 
1161                            this.selectPackage(extData.data); 
1162                     
1163                            this.calendar.periodoSelected.start = moment(this.selectedPackage.startDate).format("DD MMMM YYYY"); 
1164                            this.calendar.periodoSelected.end = moment(this.selectedPackage.endDate).format("DD MMMM YYYY"); 
1165                            //this.currentStep = 2; 
1166                             
1167                            console.log("selected packageIndex: " + extData.data); 
1168                        }else{ 
1169                            console.log("Package already selected"); 
1170
1171
1172
1173            }, 
1174            setAttachments: function(){ 
1175                <#list allegati as allegato> 
1176                    <#assign stringSelector = "dynamic-element[@name='testo']/dynamic-content[@language-id = '" + themeDisplay.getLocale() + "']"> 
1177                    <#assign xPathSelector = saxReaderUtil.createXPath(stringSelector)> 
1178                    <#if xPathSelector.selectSingleNode(allegato)??> 
1179                        <#assign text = xPathSelector.selectSingleNode(allegato).getData()> 
1180                    </#if> 
1181         
1182                    <#assign stringSelector = "dynamic-element[@name='mandatory']/dynamic-content[@language-id = '" + themeDisplay.getLocale() + "']"> 
1183                    <#assign xPathSelector = saxReaderUtil.createXPath(stringSelector)> 
1184                    <#if xPathSelector.selectSingleNode(allegato)??> 
1185                        <#assign mandatory = xPathSelector.selectSingleNode(allegato).getData()> 
1186                    </#if> 
1187                     
1188                    <#assign stringSelector = "dynamic-element[@name='documento']/dynamic-content[@language-id = '" + themeDisplay.getLocale() + "']"> 
1189                    <#assign xPathSelector = saxReaderUtil.createXPath(stringSelector)> 
1190                    <#if xPathSelector.selectSingleNode(allegato)??> 
1191                        <#assign document = jsonFactoryUtil.createJSONObject(xPathSelector.selectSingleNode(allegato).getData())> 
1192                    </#if> 
1193                     
1194                    var newAttachment = { 
1195                        title: "${text}", 
1196                        mandatory: ${mandatory}, 
1197                        file: "${'/documents/' + document.getString('groupId') + '/0/' + document.getString('title') + '/' + document.getString('uuid')}" 
1198
1199                     
1200                    this.attachments.push(newAttachment); 
1201                </#list> 
1202            }, 
1203            getUserData: function(){ 
1204                var that = this; 
1205                 
1206                Liferay.Service("/destinazione.d40user/get-user-data", { 
1207                    groupId: this.groupId, 
1208                    userId: this.userId 
1209                }, function(res){ 
1210                    console.log("Get user data: ", res); 
1211                     
1212                    if(res.success){ 
1213                        that.userData = res.data; 
1214                        that.getCountryList(); 
1215                    }else{ 
1216                        console.log("Error getting user data"); 
1217
1218                }).catch(function(err){ 
1219                    console.error("Error getting userData: ", err); 
1220                }); 
1221            }, 
1222            getCountryList: function(){ 
1223                var that = this; 
1224                 
1225                Liferay.Service("/destinazione.d40user/get-country-list", { 
1226                    language: this.defaultLanguage 
1227                }, function(res){ 
1228                    console.log("Get country list: ", res); 
1229                     
1230                    if(res.success){ 
1231                        that.countryList = res.data; 
1232                         
1233                        if(that.userData.billingCountryId == "0" || that.userData.billingCountryId == null){ 
1234                            that.userData.billingCountryId = that.countryList.find(country => country.ID === that.defaultCountryId).ID; 
1235                        }else{ 
1236                            that.userData.billingCountryId = that.defaultCountryId; 
1237
1238                         
1239                        that.getRegionList(); 
1240
1241                }).catch(function(err){ 
1242                    console.error("Error getting countryList: ", err); 
1243                }); 
1244            }, 
1245            getRegionList: function(){ 
1246                var that = this, 
1247                    idToUse = this.defaultCountryId; 
1248                 
1249                if(this.userData.hasOwnProperty("billingCountryId") && typeof this.userData["billingCountryId"] === "string" && this.userData["billingCountryId"].length){ 
1250                    idToUse = this.userData.billingCountryId; 
1251
1252                 
1253                Liferay.Service("/destinazione.d40user/get-region-list", { 
1254                    countryId: idToUse 
1255                }, function(res){ 
1256                    console.log("Get region list: ", res); 
1257                     
1258                    if(res.success){ 
1259                        that.regionList = res.data; 
1260                         
1261                        if(that.userData.billingRegionId == "0" || that.userData.billingRegionId == null){ 
1262                             
1263
1264
1265                }).catch(function(err){ 
1266                    console.error("Error getting regionList: ", err); 
1267                }); 
1268            }, 
1269            getPackages: function(){ 
1270                var that = this, 
1271                    tempPackages = [], 
1272                    packagesObj = ${jsonFactoryUtil.looseSerialize(packages)}; 
1273             
1274                packagesObj.data.items.forEach(function(pacchetto){ 
1275                    pacchetto.airportsAndPrices = JSON.parse(pacchetto.airportsAndPrices); 
1276                    pacchetto.lodgingTypesAndPrices = JSON.parse(pacchetto.lodgingTypesAndPrices.replace(/lodgingPrice/g, "price")); 
1277                    pacchetto.servicesAndPrices = JSON.parse(pacchetto.servicesAndPrices); 
1278                     
1279                    pType = pacchetto.paymentType; 
1280                    pacchetto.paymentType = []; 
1281                     
1282                    if (JSON.parse(pType) instanceof Array) { 
1283                        console.log("paymentType: array"); 
1284                         
1285                        var types = JSON.parse(pType); 
1286                         
1287                        types.forEach(function(type){ 
1288                            if(typeof type === 'object'){ 
1289                                var newPaymentType = { 
1290                                    "type": type.type, 
1291                                    "amount": Number(type.amount) 
1292
1293                            }else{ 
1294                                console.log(typeof type); 
1295                                 
1296                                var newPaymentType = { 
1297                                    "type": type, 
1298                                    "amount": 0 
1299
1300
1301                             
1302                            pacchetto.paymentType.push(newPaymentType); 
1303                        }); 
1304                    } else { 
1305                        var types = { 
1306                            "type": JSON.parse(pType), 
1307                            "amount": 0 
1308
1309                         
1310                        pacchetto.paymentType = types; 
1311
1312                     
1313                    pacchetto.purchaseBeforeDiscount = JSON.parse(pacchetto.purchaseBeforeDiscount); 
1314                    pacchetto.endDate = moment(pacchetto.startDate).add(pacchetto.numNights, "days").toDate(); 
1315                    pacchetto.show = true; 
1316                     
1317                    tempPackages.push(pacchetto); 
1318                }); 
1319                 
1320                tempPackages.sort(function(a, b){ 
1321                    return new Date(a.startDate) - new Date(b.startDate); 
1322                }); 
1323                 
1324                this.packages = tempPackages; 
1325            }, 
1326            selectPackage: function(packageId){ 
1327                var that = this; 
1328                 
1329                console.log("select package with id " + packageId); 
1330                 
1331                this.selectedPackage = this.packages.find(function(package){ 
1332                    return package._id.$oid == packageId 
1333                }); 
1334                 
1335                this.packagePrice = this.selectedPackage.basePrice; 
1336                this.packageDiscount = 0; 
1337                 
1338                this.selectedPackage.purchaseBeforeDiscount.forEach(function(sconto){ 
1339                    if(that.isDiscountValid(sconto) && sconto.discount != 0){ 
1340                        that.packageDiscount = Number(sconto.discount); 
1341
1342                }); 
1343                 
1344                this.setMandatoryServices(); 
1345            }, 
1346            select: function(name, obj){ 
1347                if(name == "airport"){ 
1348                    this.selectedAirport = obj; 
1349
1350                if(name == "accomodation"){ 
1351                    this.selectedAccomodation = obj; 
1352
1353            }, 
1354            checkFavourite: function(){ 
1355                var that = this; 
1356                 
1357                Liferay.Service('/destinazione.favorite/get-wish-list', { 
1358                    groupId: Liferay.ThemeDisplay.getScopeGroupId(), 
1359                    sessionId: String(Liferay.ThemeDisplay.getSessionId()), 
1360                    userId: String(Liferay.ThemeDisplay.getUserId()), 
1361                }, function(res){ 
1362                    console.log("getWishList response: ", res); 
1363                    if(res.success){ 
1364                        res.data.forEach(function(obj){ 
1365                            if(obj.itemId == that.contentId){ 
1366                                that.favourite = true; 
1367                                that.oid = obj._id.$oid; 
1368
1369                        }); 
1370
1371                }).catch(function(err){ 
1372                    console.error("Error getting wishlist: ", err); 
1373                }); 
1374            }, 
1375            createOrderAndPaymentUrl: function(){ 
1376                var that = this; 
1377                 
1378                if(this.isDev){ 
1379                    console.log("creating link for developer:"); 
1380                     
1381                    var orderPrice = 0; 
1382                     
1383                    var orderParams = { 
1384                        selectedPackage: this.selectedPackage, 
1385                        selectedAccomodation: this.selectedAccomodation, 
1386                        selectedAirport: this.selectedAirport, 
1387                        selectedServices: this.selectedServices, 
1388                        selectedPayment: this.selectedPayment, 
1389                        userData: this.userData 
1390
1391                     
1392                    if(this.selectedPayment.amount == 0){ 
1393                        orderPrice = this.totalPrice; 
1394                    }else{ 
1395                        orderPrice = this.selectedPayment.amount; 
1396
1397                     
1398                    Liferay.Service("/destinazione.order/add-order-and-get-payment-url", { 
1399                        groupId: this.groupId, 
1400                        userId: this.userId, 
1401                        itemGroupId: Liferay.ThemeDisplay.getScopeGroupId(), 
1402                        itemId: this.contentId, 
1403                        totalPrice: this.totalPrice, 
1404                        params: JSON.stringify(orderParams), 
1405                        currency: "EUR", 
1406                        priceToPay: orderPrice, 
1407                        userEmail: this.userMail, 
1408                        languageId: "ITA", 
1409                        description: this.name, 
1410                        session_id: String(Liferay.ThemeDisplay.getSessionId()), 
1411                        cart_id: "12", 
1412                        baseUrl: Liferay.ThemeDisplay.getURLHome().split("/web/")[0], 
1413                        locsz: "" 
1414                    }, function(res){ 
1415                        console.log("Res: ", res); 
1416                        if(res.success){ 
1417                            console.log("redirecting..."); 
1418                            window.open(res.data.url, "_blank"); 
1419                            that.closeParentModal("#pay-modal"); 
1420
1421                    }).catch(function(err){ 
1422                        console.error("Error: ", err); 
1423                    }); 
1424                }else{ 
1425                    console.log("No action. User is not a developer"); 
1426
1427            }, 
1428            setFavourite: function(){ 
1429                var that = this; 
1430                 
1431                if(this.signedIn){ 
1432                    Liferay.Service('/destinazione.favorite/add-to-wish-list', { 
1433                        groupId: Liferay.ThemeDisplay.getScopeGroupId(), 
1434                        sessionId: String(Liferay.ThemeDisplay.getSessionId()), 
1435                        userId: String(Liferay.ThemeDisplay.getUserId()), 
1436                        itemGroupId: 11, 
1437                        itemId: this.contentId 
1438                    }, function(res){ 
1439                        if(res.success){ 
1440                            console.log("addToWishList response: ", res); 
1441                            that.favourite = true; 
1442
1443                    }).catch(function(err){ 
1444                        console.error("Error adding to wishlist: ", err); 
1445                    }); 
1446                }else{ 
1447                    this.redirect("login?contentId=${contentId}"); 
1448
1449            }, 
1450            removeFavourite: function(){ 
1451                var that = this; 
1452                 
1453                Liferay.Service('/destinazione.favorite/delete-item-from-wish-list', { 
1454                    oid: this.oid 
1455                }, function(res) { 
1456                    console.log("deleteFromWishList response: ", res); 
1457                    that.favourite = false; 
1458                    that.checkFavourite(); 
1459                }).catch(function(err){ 
1460                    console.error("Error removing from wishlist: ", err); 
1461                }); 
1462            }, 
1463            saveData: function(){ 
1464                console.log("todo save data"); 
1465            }, 
1466            setCustomStyle: function(){ 
1467                var that = this, 
1468                    style = document.createElement('style'); 
1469                 
1470                style.type = 'text/css'; 
1471                 
1472                this.packages.forEach(function(package, index){ 
1473                    if(index > 0){ 
1474                        if(moment(package.startDate).isSame(that.packages[index-1].endDate)){ 
1475                            console.log("la data " + package.startDate + " combacia"); 
1476                             
1477                            var dateClass = ".id-" + moment(package.startDate).format("YYYY-MM-DD"); 
1478                            style.innerHTML += dateClass + ' .vc-highlights .vc-day-layer { box-shadow: none !important; }'; 
1479
1480
1481                }); 
1482                 
1483                if(style.innerHTML != ""){ 
1484                    document.getElementsByTagName('head')[0].appendChild(style); 
1485                    console.log("custom style for calendar injected"); 
1486
1487            }, 
1488            initCalendar: function(){ 
1489                var that = this; 
1490                this.calendar.dataInizio = moment(this.packages[0].startDate).toDate(); 
1491                this.calendar.initialPage.month = moment(this.calendar.dataInizio).month() + 1; 
1492                this.calendar.initialPage.year = moment(this.calendar.dataInizio).year(); 
1493                this.calendar.dataFine = moment(this.packages[this.packages.length - 1].endDate).toDate(); 
1494                 
1495                this.packages.forEach(function(package, index){ 
1496                    var periodo = { 
1497                        key: package.itemId + "_" + index, 
1498                        highlight: true, 
1499                        dates: [{ 
1500                            "start": moment(package.startDate).toDate(), 
1501                            "end": moment(package.endDate).toDate() 
1502                        }], 
1503                        order: index 
1504                    }; 
1505                     
1506                    that.calendar.attributes.push(periodo); 
1507                }); 
1508                 
1509                this.setCustomStyle(); 
1510            }, 
1511            selectDate: function(value){ 
1512                var that = this; 
1513                 
1514                console.log("Data scelta: ", value) 
1515                this.calendar.dataSelected = value.date; 
1516                 
1517                this.packages.forEach(function(package){ 
1518                    if(moment(value.date).isBetween(package.startDate, package.endDate)){ 
1519                        console.log(value.date + " è compresa"); 
1520                        package.show = true; 
1521
1522                }); 
1523            }, 
1524            resetDates: function(){ 
1525                this.calendar.dataSelected = null; 
1526                this.packages.forEach(function(package){ 
1527                    package.show = true; 
1528                }); 
1529            }, 
1530            showResults: function(data){ 
1531                var that = this; 
1532                 
1533                this.packages.forEach(function(package){ 
1534                    package.show = false; 
1535                     
1536                    if(moment(data).isBetween(package.startDate, package.endDate)){ 
1537                        console.log(data + " è compresa"); 
1538                        package.show = true; 
1539
1540                }); 
1541            }, 
1542            setMandatoryServices: function(){ 
1543                var that = this; 
1544                 
1545                this.selectedServices = []; 
1546                 
1547                this.selectedPackage.servicesAndPrices.forEach(function(service){ 
1548                    if(service.mandatory){ 
1549                        that.selectedServices.push(service); 
1550
1551                }); 
1552            }, 
1553            setProgressData: function(){ 
1554                localStorage.removeItem("progressData"); 
1555                console.log("removed old progress data"); 
1556                 
1557                var progressData = { 
1558                    selectedAccomodation: this.selectedAccomodation, 
1559                    selectedAirport: this.selectedAirport, 
1560                    selectedPackage: this.selectedPackage, 
1561                    selectedPayment: this.selectedPayment, 
1562                    selectedServices: this.selectedServices, 
1563                    packagePrice: this.packagePrice, 
1564                    packageDiscount: this.packageDiscount 
1565
1566                 
1567                localStorage.setItem("progressData", JSON.stringify(progressData)); 
1568                console.log("progressData saved"); 
1569            }, 
1570            getProgressData: function(){ 
1571                if(localStorage.getItem("progressData") !== null){ 
1572                    console.log("previous data exists, get..."); 
1573                     
1574                    var previousData = JSON.parse(localStorage.getItem("progressData")); 
1575                     
1576                    this.selectedAccomodation = previousData.selectedAccomodation; 
1577                    this.selectedAirport = previousData.selectedAirport; 
1578                    this.selectedPackage = previousData.selectedPackage; 
1579                    this.selectedPayment = previousData.selectedPayment; 
1580                    this.selectedServices = previousData.selectedServices; 
1581                    this.packagePrice = previousData.packagePrice; 
1582                    this.packageDicount = previousData.packageDiscount; 
1583                     
1584                    console.log("previous data restored"); 
1585                    localStorage.removeItem("progressData"); 
1586                     
1587                    this.currentStep = 5; 
1588                     
1589                    this.openParentModal("#pay-modal"); 
1590                }else{ 
1591                    console.log("no previous data exists"); 
1592
1593            }, 
1594            isDiscountValid: function(sconto){ 
1595                var today = new Date(), 
1596                    valid = false; 
1597                 
1598                if(moment(today).isSameOrAfter(sconto.date) && moment(today).isSameOrBefore(sconto.dateEnd)){ 
1599                    valid = true; 
1600
1601                 
1602                return valid; 
1603
1604
1605    }); 
1606</script> 
1607 
1608<#function getPackagesByItemId groupId itemGroupId itemId> 
1609    <#return productServiceAPI.getPackagesByItemId(groupId?number, itemGroupId?number, itemId, "", 0, 100)> 
1610</#function> 
1611 
1612<#function getPrefix img width height> 
1613    <#assign 
1614        baseUrl = "https://d28r45jypu6nt9.cloudfront.net/o/d40/img/" 
1615        siteUrl = themeDisplay.getURLPortal()?replace("://", ".") 
1616        w = width 
1617        h = height 
1618    /> 
1619    <#if height?is_string> 
1620        <#assign prefix = baseUrl + "w_" + w + "/" + siteUrl> 
1621    <#else> 
1622        <#assign prefix = baseUrl + "w_" + w + ",h_" + h + "/" + siteUrl> 
1623    </#if> 
1624     
1625    <#if !img?contains("/documents/")> 
1626        <#assign prefix = ""> 
1627    </#if> 
1628     
1629    <#return prefix + img> 
1630</#function>