1<#setting time_zone="Europe/Madrid">
2<#setting date_format="yyyy-MM-dd HH:mm">
3<#setting locale="es_ES">
4<#assign actualDate =.now?date?iso_utc>
5<#assign datenow = .now?date?iso_utc +" "+ .now?time?iso_local_nz>
6<#assign dateTimeNow = datenow?datetime("yyyy-MM-dd HH:mm")?date>
7
8<#function escapeId text>
9 <#assign id = text?replace('^[^a-z]', '', 'ri')>
10 <#assign id = id?replace('[^a-z|0-9|_]', '-', 'ri')>
11 <#return id>
12</#function>
13<#function getDay date renderer>
14 <#attempt>
15 <#assign displayDate = dateUtil.parseDate("yyyy-MM-dd", date, locale)?date>
16 <#recover>
17 <#assign displayDate = renderer.getCreateDate()?date>
18 </#attempt>
19 <#return dateUtil.getDate(displayDate, "dd MMM", locale)/>
20</#function>
21
22<#function getTime textTime>
23 <#assign time = "00:00"/>
24 <#attempt>
25 <#assign time = textTime/>
26 <#recover>
27 <#assign time = "00:00"/>
28 </#attempt>
29 <#return time/>
30</#function>
31
32<#function normalizeDate field textTime renderer>
33 <#assign date_Data = getterUtil.getString(field.getValue().getString(locale))>
34 <#attempt>
35 <#assign displayDate = dateUtil.parseDate("yyyy-MM-dd", date_Data + " " + getTime(textTime), locale)?datetime.iso("Europe/Madrid")>
36 <#recover>
37 <#assign displayDate = renderer.getCreateDate()?date>
38 </#attempt>
39 <#return displayDate/>
40</#function>
41
42<#macro pintarAviso entry id>
43 <#assign
44 assetRenderer = entry.getAssetRenderer()
45 ddmFormValuesReader = assetRenderer.getDDMFormValuesReader()
46 textFields = ddmFormValuesReader.getDDMFormFieldValues('text')
47 htmlFields = ddmFormValuesReader.getDDMFormFieldValues('rich_text')
48 dateFields = ddmFormValuesReader.getDDMFormFieldValues('date')
49 titulo = ""
50 fecha = ""
51 fechaFin = ""
52 entradilla = ""
53 descripcion = ""
54 zonas = ""
55 initTime= ""
56 endTime= ""
57
58 />
59 <#assign titulo = entry.getTitle(locale) />
60 <#list htmlFields as htmlField>
61 <#if htmlField.name == 'ContenidoDeAviso'>
62 <#assign descripcion = htmlField.getValue().getString(locale) />
63 </#if>
64 <#if htmlField.name == 'Zonas'>
65 <#assign zonas = htmlField.getValue().getString(locale) />
66 </#if>
67 </#list>
68 <#list textFields as textField>
69 <#if textField.name == 'Entradilla'>
70 <#if textField.getValue().getString(locale)?has_content && textField.getValue().getString(locale)??>
71 <#assign entradilla = textField.getValue().getString(locale) />
72 </#if>
73 </#if>
74 <#if textField.name == 'horaInicio'>
75 <#assign initTime = getTime(textField.getValue().getString(locale)) />
76 </#if>
77 <#if textField.name == 'horaFin'>
78 <#assign endTime =getTime(textField.getValue().getString(locale)) />
79 </#if>
80 </#list>
81 <#list dateFields as dateField>
82 <#if dateField.name == 'FechaInicioAviso'>
83 <#assign fecha = dateField.getValue().getString(locale) />
84 </#if>
85 <#if dateField.name == 'FechaFinAviso'>
86 <#assign fechaFin = dateField.getValue().getString(locale) />
87 </#if>
88 </#list>
89
90 <div class="aviso">
91 <div class="icono-aviso col-sm-2 col-md-1">
92 <span class="icon-aviso"></span>
93 </div>
94 <div class="fecha-aviso col-sm-3 col-md-2">
95 <span class="dia">${getDay(fecha, entry)} - ${getDay(fechaFin, entry)}</span>
96 <span class="hora">${initTime} - ${endTime}</span>
97 </div>
98 <div class="descripcion-aviso col-sm-7 col-md-9">
99 <a href="#" title="#" data-target="#detalleAviso${id}" id="${escapeId(titulo)}" data-toggle="modal" >${titulo}</a>
100 <span class="municipios">${entradilla}</span>
101 <!--Aqui iría el detalle de aviso en plan emergente-->
102 <@pintarDetalleAviso titulo=titulo entradilla=entradilla fecha=fecha fechaFin=fechaFin descripcion=descripcion zonas=zonas id=id/>
103 </div>
104 </div>
105</#macro>
106<#macro pintarDetalleAviso titulo entradilla fecha fechaFin descripcion zonas id>
107<div aria-labelledby="detalleAviso${id}Label" class="fade modal detalleAviso" id="detalleAviso${id}" role="dialog" tabindex="-1">
108 <div class="modal-dialog modal-full-screen">
109 <div class="modal-content">
110 <div class="modal-header">
111 <button aria-labelledby="Close" class="btn btn-default close" data-dismiss="modal" role="button" type="button" title="Cerrar"/>
112 </div>
113 <div class="modal-body modal-body-no-footer">
114 <div class="generic-content">
115
116 <article class="detalle-aviso">
117
118 <header>
119 <div class="container">
120 <div class="row">
121 <div class="content-header">
122 <span class="icon-aviso"></span>
123 <h1>${titulo}</h1>
124 <summary>
125 <span class="horario">${fecha} - ${fechaFin}</span>
126 <#if zonas!= "">
127 <span class="zonas">${zonas}</span>
128 </#if>
129 </summary>
130 </div>
131 </div>
132 </div>
133 </header>
134
135 <section class="container-generic-content">
136 <div class="container">
137 <div class="row">
138 <div class="col-md-8 col-md-offset-2">
139 ${descripcion}
140 </div>
141 </div>
142 </div>
143 </section>
144
145 </article>
146 </div><!-- .generic-content -->
147 </div><!-- modal-body -->
148 </div>
149 </div>
150</div>
151</#macro>
152
153<#assign currentAlerts = []>
154<#assign plannedAlerts = []>
155<#assign pastAlerts = []>
156
157<#if entries?has_content>
158 <#list entries as curEntry>
159 <#assign assetRenderer = curEntry.getAssetRenderer()
160 ddmFormValuesReader = assetRenderer.getDDMFormValuesReader()
161 textFields = ddmFormValuesReader.getDDMFormFieldValues('text')
162 dateFields = ddmFormValuesReader.getDDMFormFieldValues('date')
163 textInitTime=""
164 textEndTime=""/>
165 <#list textFields as textField>
166 <#if textField.name == 'horaInicio'>
167 <#assign textInitTime =textField.getValue().getString(locale) />
168 </#if>
169 <#if textField.name == 'horaFin'>
170 <#assign textEndTime =textField.getValue().getString(locale) />
171 </#if>
172 </#list>
173 <#list dateFields as dateField>
174 <#if dateField.name == 'FechaInicioAviso'>
175 <#-- <#assign initDate = normalizeDate(dateField,textInitTime, curEntry) /> -->
176 <#assign initDate = getterUtil.getString(dateField.getValue().getString(locale)) + " " + textInitTime/>
177 <#assign initDate = initDate?datetime("yyyy-MM-dd HH:mm")?date/>
178 </#if>
179 <#if dateField.name == 'FechaFinAviso'>
180 <#-- <#assign endDate = normalizeDate(dateField,textEndTime, curEntry) /> -->
181 <#assign endDate = getterUtil.getString(dateField.getValue().getString(locale)) + " " + textEndTime/>
182 <#assign endDate =endDate?datetime("yyyy-MM-dd HH:mm")?date />
183 </#if>
184 </#list>
185
186 <#if (dateTimeNow >= initDate ) && (dateTimeNow <= endDate) >
187 <#assign currentAlerts = currentAlerts + [curEntry] />
188
189 <#elseif (initDate > dateTimeNow ) >
190 <#assign plannedAlerts = plannedAlerts + [curEntry] />
191
192 <#elseif (endDate < dateTimeNow ) >
193 <#assign pastAlerts = pastAlerts + [curEntry] />
194 </#if>
195 </#list>
196</#if>
197
198
199<#assign contador=1>
200<div class="generic-content">
201 <div class="list-avisos">
202<section>
203 <div class="container">
204 <div class="row">
205 <div class="wrapper-avisos">
206 <ul class="nav nav-tabs nav-tabs-default tab-avisos" role="tablist">
207 <li class="col-xs-4" role="presentation">
208 <a href="#tab1" aria-controls="settings" role="tab" data-toggle="tab" class="active" aria-selected="true"><@liferay.language key="aqualogy.liferay.current.alerts" /></a>
209 </li>
210 <li class="col-xs-4" role="presentation">
211 <a href="#tab2" aria-controls="settings" role="tab" data-toggle="tab"><@liferay.language key="aqualogy.liferay.plannet.alerts" /></a>
212 </li>
213 <li class="col-xs-4" role="presentation">
214 <a href="#tab3" aria-controls="settings" role="tab" data-toggle="tab"><@liferay.language key="aqualogy.liferay.finished.alerts" /></a>
215 </li>
216 </ul>
217 <div class="tab-content">
218 <div role="tabpanel" class="tab-content-actuales tab-pane fade active in" id="tab1">
219 <#if currentAlerts?has_content>
220 <#list currentAlerts as curEntry>
221 <@pintarAviso entry=curEntry id=contador />
222 <#assign contador += 1>
223 </#list>
224 </#if>
225 </div>
226 <div role="tabpanel" class="tab-content-actuales tab-pane fade" id="tab2">
227 <#if plannedAlerts?has_content>
228 <#list plannedAlerts as curEntry>
229 <@pintarAviso entry=curEntry id=contador />
230 <#assign contador += 1>
231 </#list>
232 </#if>
233 </div>
234 <div role="tabpanel" class="tab-content-actuales tab-pane fade" id="tab3">
235 <#if pastAlerts?has_content>
236 <#list pastAlerts as curEntry>
237 <@pintarAviso entry=curEntry id=contador />
238 <#assign contador += 1>
239 </#list>
240 </#if>
241 </div>
242 </div>
243 </div>
244 </div>
245 </div>
246</section>
247
248</div>
249</div>
250<script>
251
252 function openAlertAnchor() {
253 var id = window.location.hash.substring(1);
254 if (id != null && id != '') {
255 var alertLink = document.getElementById(id);
256 if (alertLink != null) {
257 alertLink.click();
258 }
259 }
260 }
261 openAlertAnchor();
262
263</script>