<?php

use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;

/* widget/widget-dailyworkingtimechart.html.twig */
class __TwigTemplate_088946a11d10775ef86581eb336fe2fd53b7c1c1a59b28fb02f0f7b3dc539cbe extends Template
{
    private $source;
    private $macros = [];

    public function __construct(Environment $env)
    {
        parent::__construct($env);

        $this->source = $this->getSourceContext();

        $this->parent = false;

        $this->blocks = [
        ];
    }

    protected function doDisplay(array $context, array $blocks = [])
    {
        $macros = $this->macros;
        // line 1
        $context["type"] = ((twig_get_attribute($this->env, $this->source, ($context["options"] ?? null), "type", [], "any", true, true, false, 1)) ? (_twig_default_filter(twig_get_attribute($this->env, $this->source, ($context["options"] ?? null), "type", [], "any", false, false, false, 1), "bar")) : ("bar"));
        // line 2
        $context["chart_id"] = twig_get_attribute($this->env, $this->source, ($context["options"] ?? null), "id", [], "any", false, false, false, 2);
        // line 3
        $context["backgroundColor"] = twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, ($context["kimai_context"] ?? null), "chart", [], "any", false, false, false, 3), "background_color", [], "any", false, false, false, 3);
        // line 4
        $context["gridColor"] = twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, ($context["kimai_context"] ?? null), "chart", [], "any", false, false, false, 4), "grid_color", [], "any", false, false, false, 4);
        // line 5
        $context["activities"] = twig_get_attribute($this->env, $this->source, ($context["data"] ?? null), "activities", [], "any", false, false, false, 5);
        // line 6
        $context["data"] = twig_get_attribute($this->env, $this->source, ($context["data"] ?? null), "data", [], "any", false, false, false, 6);
        // line 7
        echo "
<div class=\"chart\">
    <canvas id=\"";
        // line 9
        echo twig_escape_filter($this->env, ($context["chart_id"] ?? null), "html", null, true);
        echo "\" style=\"height: ";
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, ($context["kimai_context"] ?? null), "chart", [], "any", false, false, false, 9), "height", [], "any", false, false, false, 9), "html", null, true);
        echo "px;\"></canvas>
</div>

<script type=\"text/javascript\">
    var myChart = null;
    
    var paintChart = function() {
        myChart = new Chart(
            document.getElementById('";
        // line 17
        echo twig_escape_filter($this->env, ($context["chart_id"] ?? null), "html", null, true);
        echo "').getContext('2d'), {
                type: '";
        // line 18
        echo twig_escape_filter($this->env, ($context["type"] ?? null), "html", null, true);
        echo "',
                data: {
                    labels: [
                        ";
        // line 21
        $context['_parent'] = $context;
        $context['_seq'] = twig_ensure_traversable(($context["data"] ?? null));
        $context['loop'] = [
          'parent' => $context['_parent'],
          'index0' => 0,
          'index'  => 1,
          'first'  => true,
        ];
        if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof \Countable)) {
            $length = count($context['_seq']);
            $context['loop']['revindex0'] = $length - 1;
            $context['loop']['revindex'] = $length;
            $context['loop']['length'] = $length;
            $context['loop']['last'] = 1 === $length;
        }
        foreach ($context['_seq'] as $context["_key"] => $context["day"]) {
            // line 22
            echo "moment('";
            echo twig_escape_filter($this->env, $this->extensions['App\Twig\DateExtensions']->dateFormat(twig_get_attribute($this->env, $this->source, $context["day"], "day", [], "any", false, false, false, 22), "Y-m-d"), "html", null, true);
            echo "').format('ll')
                        ";
            // line 23
            if ( !twig_get_attribute($this->env, $this->source, $context["loop"], "last", [], "any", false, false, false, 23)) {
                echo ",";
            }
            ++$context['loop']['index0'];
            ++$context['loop']['index'];
            $context['loop']['first'] = false;
            if (isset($context['loop']['length'])) {
                --$context['loop']['revindex0'];
                --$context['loop']['revindex'];
                $context['loop']['last'] = 0 === $context['loop']['revindex0'];
            }
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['day'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 25
        echo "                    ],
                    datasets: [
                        ";
        // line 27
        $context['_parent'] = $context;
        $context['_seq'] = twig_ensure_traversable(($context["activities"] ?? null));
        foreach ($context['_seq'] as $context["activityId"] => $context["activity"]) {
            // line 28
            $context["activityColor"] = _twig_default_filter($this->extensions['App\Twig\Extensions']->color(twig_get_attribute($this->env, $this->source, $context["activity"], "activity", [], "any", false, false, false, 28)), _twig_default_filter($this->extensions['App\Twig\Extensions']->color(twig_get_attribute($this->env, $this->source, $context["activity"], "project", [], "any", false, false, false, 28)), ($context["backgroundColor"] ?? null)));
            // line 29
            echo "                        ";
            $context["activityName"] = twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["activity"], "activity", [], "any", false, false, false, 29), "name", [], "any", false, false, false, 29);
            // line 30
            echo "                        {
                            label: '";
            // line 31
            echo twig_escape_filter($this->env, ($context["activityName"] ?? null), "html", null, true);
            echo "',
                            backgroundColor: '";
            // line 32
            echo twig_escape_filter($this->env, ($context["activityColor"] ?? null), "html", null, true);
            echo "',
                            borderColor: '#fff',
                            borderWidth: 1,
                            data: [";
            // line 36
            $context['_parent'] = $context;
            $context['_seq'] = twig_ensure_traversable(($context["data"] ?? null));
            $context['loop'] = [
              'parent' => $context['_parent'],
              'index0' => 0,
              'index'  => 1,
              'first'  => true,
            ];
            if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof \Countable)) {
                $length = count($context['_seq']);
                $context['loop']['revindex0'] = $length - 1;
                $context['loop']['revindex'] = $length;
                $context['loop']['length'] = $length;
                $context['loop']['last'] = 1 === $length;
            }
            foreach ($context['_seq'] as $context["_key"] => $context["day"]) {
                // line 37
                $context["realDayData"] = null;
                // line 38
                $context['_parent'] = $context;
                $context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->source, $context["day"], "details", [], "any", false, false, false, 38));
                foreach ($context['_seq'] as $context["_key"] => $context["entry"]) {
                    // line 39
                    $context["loopId"] = ((twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["entry"], "project", [], "any", false, false, false, 39), "id", [], "any", false, false, false, 39) . "_") . twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["entry"], "activity", [], "any", false, false, false, 39), "id", [], "any", false, false, false, 39));
                    // line 40
                    if (0 === twig_compare(($context["loopId"] ?? null), $context["activityId"])) {
                        // line 41
                        $context["realDayData"] = twig_number_format_filter($this->env, (twig_get_attribute($this->env, $this->source, $context["entry"], "duration", [], "any", false, false, false, 41) / 3600), 2, ".", "");
                    }
                }
                $_parent = $context['_parent'];
                unset($context['_seq'], $context['_iterated'], $context['_key'], $context['entry'], $context['_parent'], $context['loop']);
                $context = array_intersect_key($context, $_parent) + $_parent;
                // line 44
                if ( !(null === ($context["realDayData"] ?? null))) {
                    // line 45
                    echo "'";
                    echo twig_escape_filter($this->env, ($context["realDayData"] ?? null), "html", null, true);
                    echo "'";
                } else {
                    // line 47
                    echo "0";
                }
                // line 49
                if ( !twig_get_attribute($this->env, $this->source, $context["loop"], "last", [], "any", false, false, false, 49)) {
                    echo ",";
                }
                ++$context['loop']['index0'];
                ++$context['loop']['index'];
                $context['loop']['first'] = false;
                if (isset($context['loop']['length'])) {
                    --$context['loop']['revindex0'];
                    --$context['loop']['revindex'];
                    $context['loop']['last'] = 0 === $context['loop']['revindex0'];
                }
            }
            $_parent = $context['_parent'];
            unset($context['_seq'], $context['_iterated'], $context['_key'], $context['day'], $context['_parent'], $context['loop']);
            $context = array_intersect_key($context, $_parent) + $_parent;
            // line 51
            echo "],
                            realData: [";
            // line 53
            $context['_parent'] = $context;
            $context['_seq'] = twig_ensure_traversable(($context["data"] ?? null));
            $context['loop'] = [
              'parent' => $context['_parent'],
              'index0' => 0,
              'index'  => 1,
              'first'  => true,
            ];
            if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof \Countable)) {
                $length = count($context['_seq']);
                $context['loop']['revindex0'] = $length - 1;
                $context['loop']['revindex'] = $length;
                $context['loop']['length'] = $length;
                $context['loop']['last'] = 1 === $length;
            }
            foreach ($context['_seq'] as $context["_key"] => $context["day"]) {
                // line 54
                $context["realDayData"] = null;
                // line 55
                $context['_parent'] = $context;
                $context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->source, $context["day"], "details", [], "any", false, false, false, 55));
                foreach ($context['_seq'] as $context["_key"] => $context["entry"]) {
                    // line 56
                    $context["loopId"] = ((twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["entry"], "project", [], "any", false, false, false, 56), "id", [], "any", false, false, false, 56) . "_") . twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["entry"], "activity", [], "any", false, false, false, 56), "id", [], "any", false, false, false, 56));
                    // line 57
                    if (0 === twig_compare(($context["loopId"] ?? null), $context["activityId"])) {
                        // line 58
                        $context["realDayData"] = ["duration" => $this->extensions['App\Twig\LocaleExtensions']->duration(twig_get_attribute($this->env, $this->source, $context["entry"], "duration", [], "any", false, false, false, 58)), "project" => twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["entry"], "project", [], "any", false, false, false, 58), "name", [], "any", false, false, false, 58), "customer" => twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["entry"], "project", [], "any", false, false, false, 58), "customer", [], "any", false, false, false, 58), "name", [], "any", false, false, false, 58), "activity" => twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, $context["entry"], "activity", [], "any", false, false, false, 58), "name", [], "any", false, false, false, 58), "total" => $this->extensions['App\Twig\LocaleExtensions']->duration(twig_get_attribute($this->env, $this->source, $context["day"], "totalDuration", [], "any", false, false, false, 58))];
                    }
                }
                $_parent = $context['_parent'];
                unset($context['_seq'], $context['_iterated'], $context['_key'], $context['entry'], $context['_parent'], $context['loop']);
                $context = array_intersect_key($context, $_parent) + $_parent;
                // line 61
                if ( !(null === ($context["realDayData"] ?? null))) {
                    // line 62
                    echo json_encode(($context["realDayData"] ?? null));
                } else {
                    // line 64
                    echo "0";
                }
                // line 66
                if ( !twig_get_attribute($this->env, $this->source, $context["loop"], "last", [], "any", false, false, false, 66)) {
                    echo ",";
                }
                ++$context['loop']['index0'];
                ++$context['loop']['index'];
                $context['loop']['first'] = false;
                if (isset($context['loop']['length'])) {
                    --$context['loop']['revindex0'];
                    --$context['loop']['revindex'];
                    $context['loop']['last'] = 0 === $context['loop']['revindex0'];
                }
            }
            $_parent = $context['_parent'];
            unset($context['_seq'], $context['_iterated'], $context['_key'], $context['day'], $context['_parent'], $context['loop']);
            $context = array_intersect_key($context, $_parent) + $_parent;
            // line 68
            echo "]
                        },";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['activityId'], $context['activity'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 71
        echo "                    ]
                },
                options: {
                    maintainAspectRatio: true,
                    responsive: true,
                    legend: false,
                    barPercentage: 0.5,
                    categoryPercentage: 0.9,
                    scales: {
                        xAxes: [{
                            stacked: true,
                            gridLines: {
                                display: false
                            },
                        }],
                        yAxes: [{
                            stacked: true,
                            ticks: {
                                beginAtZero: true
                            },
                            gridLines: {
                                display: true,
                                color: '";
        // line 93
        echo twig_escape_filter($this->env, ($context["gridColor"] ?? null), "html", null, true);
        echo "',
                                lineWidth: 1
                            }
                        }],
                    },
                    tooltips: {
                        callbacks: {
                            label: function(tooltipItem, data) {
                                var tooltipData = data.datasets[tooltipItem.datasetIndex].realData[tooltipItem.index];
                                return ' ' + tooltipData.duration + ': ' + tooltipData.activity;
                            },
                            beforeTitle: function(tooltipItems, data) {
                                var tooltipItem = tooltipItems[0];
                                var tooltipData = data.datasets[tooltipItem.datasetIndex].realData[tooltipItem.index];
                                return tooltipData.customer;
                            },
                            title: function(tooltipItems, data) {
                                var tooltipItem = tooltipItems[0];
                                var tooltipData = data.datasets[tooltipItem.datasetIndex].realData[tooltipItem.index];
                                return tooltipData.project;
                            },
                            afterTitle: function(tooltipItems, data) {
                                return ' ';
                            },
                            footer: function(tooltipItems, data) {
                                var tooltipItem = tooltipItems[0];
                                var tooltipData = data.datasets[tooltipItem.datasetIndex].realData[tooltipItem.index];
                                return '";
        // line 120
        echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans("stats.durationTotal"), "html", null, true);
        echo ": ' + tooltipData.total;
                            },
                            beforeFooter: function(tooltipItems, data) {
                                return ' ';
                            },
                        },
                    }
                }
            }
        );
    };
    
    var destroyChart = function () {
        myChart.destroy();
    };
    
    ";
        // line 136
        if (twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, ($context["app"] ?? null), "request", [], "any", false, false, false, 136), "xmlHttpRequest", [], "any", false, false, false, 136)) {
            // line 137
            echo "        paintChart();
    ";
        } else {
            // line 139
            echo "        document.addEventListener('kimai.initialized', paintChart);
    ";
        }
        // line 141
        echo "</script>
";
    }

    public function getTemplateName()
    {
        return "widget/widget-dailyworkingtimechart.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  351 => 141,  347 => 139,  343 => 137,  341 => 136,  322 => 120,  292 => 93,  268 => 71,  261 => 68,  245 => 66,  242 => 64,  239 => 62,  237 => 61,  230 => 58,  228 => 57,  226 => 56,  222 => 55,  220 => 54,  203 => 53,  200 => 51,  184 => 49,  181 => 47,  176 => 45,  174 => 44,  167 => 41,  165 => 40,  163 => 39,  159 => 38,  157 => 37,  140 => 36,  134 => 32,  130 => 31,  127 => 30,  124 => 29,  122 => 28,  118 => 27,  114 => 25,  98 => 23,  93 => 22,  76 => 21,  70 => 18,  66 => 17,  53 => 9,  49 => 7,  47 => 6,  45 => 5,  43 => 4,  41 => 3,  39 => 2,  37 => 1,);
    }

    public function getSourceContext()
    {
        return new Source("", "widget/widget-dailyworkingtimechart.html.twig", "/var/www/html/kimai2/templates/widget/widget-dailyworkingtimechart.html.twig");
    }
}
