{% extends "SpicySiteBundle::layout.html.twig" %}

{% set MOIS = constant('Spicy\\RankingBundle\\Entity\\RankingType::MOIS') %}
{% set ANNEE = constant('Spicy\\RankingBundle\\Entity\\RankingType::ANNEE') %}

{% set type_ranking = "mois" %}  
{%if rankingType == MOIS%}
    {% set type_ranking = "mois" %}        
{% elseif rankingType == ANNEE%}
    {% set type_ranking = "année" %}  
{%endif%}

{% block title %}
    
    {{ parent() }}{{" : Tous les classements par "~type_ranking~" de Mimizik"}}
{% endblock %}

{% block meta_description %}
    
    <meta name="Description" content="Tous les classements par mois de Mimizik."/> 
{% endblock %}

{% block stylesheets %}
    {{ parent() }}
    {% stylesheets filter='cssrewrite,?yui_css' output='css/compiled/home_ranking.css'
        '@SpicyRankingBundle/Resources/public/css/*' %}
        <link rel="stylesheet" href="{{ asset_url }}" type="text/css" />
    {% endstylesheets %}
    <style type="text/css">
        #data-ranking th{
            font-size: 1.2em;
            padding: 0.8em 10px;        
        }
        #data-ranking td{
            font-size: 14px;
            padding: 1em 10px;
        }
        #data-ranking td .llink{
            width: 120px;
        }
        .pagination{
            margin-top: 10px;
        }
        #data-ranking .search-icon {
            background: url("/images/pagination_arrows.png") no-repeat scroll -53px 6px rgba(0, 0, 0, 0);
            height: 20px;
            width: 20px;
        }
    </style> 
{% endblock %}

{% block body %}
    {{ parent() }}
    
    <div class="page-title wrapper">
        <div class="container">            
            <span>Les classements par {{type_ranking}} de Mimizik</span>
            <div class="clear"></div>
        </div>
    </div>
    <div class="container" id="main_container" >
        <div class="column two-third" >
            <div class="content-block">
                <div class="block-content">
                    <div class="featured-blog">
                        <table border="1" id="data-ranking">
                            <tr><th>Classements</th><th></th></tr>
                        {% for ranking in rankings %}         
                            <tr>
                                <td>
                                    <a href="{{ path('mimizik_ranking_show',{'id':ranking.id,'type_id':ranking.rankingType.id})}}">
                                    {%if rankingType == MOIS%}
                                    Classement du {{ranking.dateRanking|date('m/y')}}
                                    {% elseif rankingType == ANNEE%}
                                    Classement de {{ranking.dateRanking|date('Y')}}
                                    {% endif%}
                                    </a>
                                </td>
                                <td class="link">
                                    <a class="button" href="{{ path('mimizik_ranking_show',{'id':ranking.id,'type_id':ranking.rankingType.id})}}"><span>Voir le classement</span></a>
                                </td>
                            </tr>          
                        {% endfor %}
                        </table>
                        <div id="Pagination" >

                        </div>                        
                    </div>
                </div>    
            </div>
            <div>
                <div id="banstex468x60">
                    {# {% include "SpicySiteBundle:Ads:468x60_banstex.html.twig" %} #}
                </div>  
            </div>
        </div>
        <div class="one-third column last">
            <div class="content-block">
                <div class="block-content" id="encart_droit">
                    {% include "SpicySiteBundle:Ads:encart_droit_adsense.html.twig" %}
                </div>
            </div>
        </div>
    </div>
       
{% endblock %}

{% block javascripts %}
    {{parent()}}
    
    <script type="text/javascript">
        function initPagination() {
            var num_entries = {{rankings|length}}
            // Create content inside pagination element
            $("#Pagination").pagination(num_entries, {
                //callback: pageselectCallback,
                items_per_page:10, // Show only one item per page
                link_to:"{{ path('mimizik_ranking_index',{'page':'__id__','type_id':rankingType})}}",
                current_page:{{page-1}},
                prev_text:"Prèc.",
                next_text:"Suiv.",
                num_edge_entries:2,
                num_display_entries:8,
                callback:function(){}
            });
         }

        // When document is ready, initialize pagination
        $(document).ready(function(){      
            initPagination();
        });
    </script>
    
{% endblock%}