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