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

{% set showSearchDesc = 'hide' %}

{% block head_additions %}<meta name="robots" content="noindex, nofollow">{% endblock %}

{% block title %}Install Statistics - {{ package.name }} - {{ parent() }}{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-xs-12 package">
            <div class="package-header">
                <h2 class="title">
                    <a href="{{ path("view_package", {name: package.name}) }}">{{ package.name }}</a> install statistics
                </h2>
            </div>
        </div>
    </div>

    <section class="row package-installs">
        <div class="col-lg-12">
            <h3>Installs</h3>

            <div class="row">
                <div class="col-md-4 col-xs-12">
                    <dl class="dl-horizontal">
                        <dt class="font-normal">Overall</dt>
                        <dd class="font-normal">{{ downloads.total|number_format(0, '.', '&#8201;')|raw }}</dd>
                    </dl>
                </div>
                <div class="col-md-4 col-xs-12">
                    <dl class="dl-horizontal">
                        <dt class="font-normal">Last 30 days</dt>
                        <dd class="font-normal">{{ downloads.monthly|number_format(0, '.', '&#8201;')|raw }}</dd>
                    </dl>
                </div>
                <div class="col-md-4 col-xs-12">
                    <dl class="dl-horizontal">
                        <dt class="font-normal">Today<br><small>(since midnight, UTC)</small></dt>
                        <dd class="font-normal">{{ downloads.daily|number_format(0, '.', '&#8201;')|raw }}</dd>
                    </dl>
                </div>
            </div>

            <h3>Daily installs{% if average != 'daily' %}, averaged {{ average }}{% endif %}</h3>
            <div class="row">
                <div class="col-xs-12">
                    <svg class="chart js-all-dls" width="500" height="200">
                        Sorry, the graph can't be displayed because your browser doesn't support &lt;svg&gt; html element.
                    </svg>
                </div>
            </div>

            <br>
            <h3>Daily installs per version{% if average != 'daily' %}, averaged {{ average }}{% endif %}</h3>
            <div class="row package version-stats">
                <div class="col-xs-12 col-md-9 version-stats-chart">
                    <div style="position: relative">
                        <svg class="chart js-version-dls" width="500" height="200">
                            Sorry, the graph can't be displayed because your browser doesn't support &lt;svg&gt; html element.
                        </svg>
                    </div>
                </div>
                {% include 'PackagistWebBundle:Package:versionList.html.twig' with {versions: versions, expandedId: expandedId} %}
            </div>
        </div>
    </section>
{% endblock %}

{% block stylesheets %}
    <link href="https://cdn.rawgit.com/novus/nvd3/v1.7.1/build/nv.d3.css" rel="stylesheet">
{% endblock %}

{% block scripts %}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
    <script src="https://cdn.rawgit.com/novus/nvd3/v1.7.1/build/nv.d3.min.js"></script>
    <script src="{{ asset('bundles/packagistweb/js/charts.js') }}"></script>
    <script>
        (function () {
            var average = {{ average|json_encode|raw }};
            var date = {{ date|json_encode|raw }};
            var versions = {{ versions|json_encode|raw }};

            initPackageStats(average, date, versions, {{ path('package_stats', {name: package.name})|json_encode|raw }}, {{ path('version_stats', {name: package.name, version: '_VERSION_'})|json_encode|raw }});
        }());
    </script>
{% endblock %}
