{% extends "new/adminLTE2_base.html" %}
{% load static %}
{% load humanize %}

{% block headMedia %}
	<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.18/datatables.min.css"/>
{% endblock %}

{% block leftbar %}
        {% include "new/index-leftbar.html" %}
{% endblock %}


{% block dash-title %}

	<b>{{form.text.value|default:"Noticias"|capfirst}}</b>
	[{{form.startDate.value}}, {{form.endDate.value}}]

{% endblock %}


{% block dash %}

	<!-- /.row -->
	<div class="row">
		<div class="col-lg-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					Noticias
				</div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">



                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-news">
                                <thead>
                                    <tr>
                                        <th>Titulo</th>
                                        <th>URL</th>
					<th>Fecha</th>
                                    </tr>
                                </thead>
                               <tfoot>
                                    <tr>
                                        <th>Titulo</th>
                                        <th>URL</th>
                                        <th>Fecha</th>
                                    </tr>
                                </tfoot>

                            </table>
                            <!-- /.table-responsive -->



                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->

{% endblock %}

{% block scripts %}
	<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.18/datatables.min.js"></script>

	<script>
	$(document).ready(function() {
	$('#dataTables-news').DataTable({
		"order": [[ 2, "desc" ]],
		"responsive": true,
		"processing": true,
		"serverSide": true,
		"language": {"url": "/static/languages/Spanish.json" },
		"ajax": {
			"url":"/catalog/ws/news/",
			"data":{"query":{startDate":"{{form.startDate.value}}", "endDate":"{{form.endDate.value}}", "ajaxPublishers":[{% for p in form.publishers.value %}{{p}}{% if not forloop.last %},{% endif %}{% endfor %}], "text":"{{form.text.value}}"}}

			}

		});
	});
	console.log(" {{form.publishers.data|safe}} ");
	</script>

{% endblock %}