<?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;

/* calendar/user.html.twig */
class __TwigTemplate_97e84e72e1b4b2c1cfae4ea7ae0c878b08a653178d1f53a323b4f9588e4c7aef extends Template
{
    private $source;
    private $macros = [];

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

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

        $this->blocks = [
            'page_title' => [$this, 'block_page_title'],
            'page_actions' => [$this, 'block_page_actions'],
            'main' => [$this, 'block_main'],
            'stylesheets' => [$this, 'block_stylesheets'],
            'head' => [$this, 'block_head'],
            'javascripts' => [$this, 'block_javascripts'],
        ];
    }

    protected function doGetParent(array $context)
    {
        // line 1
        return "base.html.twig";
    }

    protected function doDisplay(array $context, array $blocks = [])
    {
        $macros = $this->macros;
        // line 2
        $macros["widgets"] = $this->macros["widgets"] = $this->loadTemplate("macros/widgets.html.twig", "calendar/user.html.twig", 2)->unwrap();
        // line 3
        $macros["actions"] = $this->macros["actions"] = $this->loadTemplate("calendar/actions.html.twig", "calendar/user.html.twig", 3)->unwrap();
        // line 1
        $this->parent = $this->loadTemplate("base.html.twig", "calendar/user.html.twig", 1);
        $this->parent->display($context, array_merge($this->blocks, $blocks));
    }

    // line 5
    public function block_page_title($context, array $blocks = [])
    {
        $macros = $this->macros;
        echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans("calendar.title"), "html", null, true);
    }

    // line 6
    public function block_page_actions($context, array $blocks = [])
    {
        $macros = $this->macros;
        echo twig_call_macro($macros["actions"], "macro_calendar", ["index"], 6, $context, $this->getSourceContext());
    }

    // line 8
    public function block_main($context, array $blocks = [])
    {
        $macros = $this->macros;
        // line 9
        echo "    ";
        $this->loadTemplate("calendar/user.html.twig", "calendar/user.html.twig", 9, "358738174")->display($context);
    }

    // line 17
    public function block_stylesheets($context, array $blocks = [])
    {
        $macros = $this->macros;
        // line 18
        echo "    ";
        $this->displayParentBlock("stylesheets", $context, $blocks);
        echo "
    ";
        // line 19
        echo $this->extensions['Symfony\WebpackEncoreBundle\Twig\EntryFilesTwigExtension']->renderWebpackLinkTags("calendar");
        echo "
";
    }

    // line 22
    public function block_head($context, array $blocks = [])
    {
        $macros = $this->macros;
        // line 23
        echo "    ";
        $this->displayParentBlock("head", $context, $blocks);
        echo "
    ";
        // line 24
        echo $this->extensions['Symfony\WebpackEncoreBundle\Twig\EntryFilesTwigExtension']->renderWebpackScriptTags("calendar");
        echo "
";
    }

    // line 27
    public function block_javascripts($context, array $blocks = [])
    {
        $macros = $this->macros;
        // line 28
        echo "    ";
        $this->displayParentBlock("javascripts", $context, $blocks);
        echo "
    <script>
        document.addEventListener('kimai.timesheetUpdate', function() {
            \$('#timesheet_calendar').fullCalendar('refetchEvents');
        });

        var changeHandler = function(event, delta, revertFunc) {
            var updateUrl = '";
        // line 35
        echo $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("patch_timesheet", ["id" => "-XX-"]);
        echo "'.replace('-XX-', event.id);
            var API = kimai.getPlugin('api');
            var ALERT = kimai.getPlugin('alert');

            var payload = {'begin': event.start.format()};

            if (event.end !== null && event.end !== undefined) {
                payload.end = event.end.format();
            } else {
                payload.end = null;

            }

            API.patch(updateUrl, JSON.stringify(payload), function(result) {
                ALERT.success('action.update.success');
            }, function(xhr, err) {
                if (xhr.responseJSON && xhr.responseJSON.message) {
                    err = xhr.responseJSON.message;
                }
                ALERT.error('action.update.error', err);
                revertFunc();
            });
        };

        document.addEventListener('kimai.initialized', function(event) {
            var API = event.detail.kimai.getPlugin('api');
            \$('#timesheet_calendar').fullCalendar({
                defaultView: '";
        // line 62
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, ($context["app"] ?? null), "user", [], "any", false, false, false, 62), "getPreferenceValue", [0 => "calendar.initial_view"], "method", false, false, false, 62), "html", null, true);
        echo "',
                ";
        // line 63
        if ( !(null === twig_get_attribute($this->env, $this->source, ($context["google"] ?? null), "apiKey", [], "any", false, false, false, 63))) {
            // line 64
            echo "                googleCalendarApiKey: '";
            echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["google"] ?? null), "apiKey", [], "any", false, false, false, 64), "html", null, true);
            echo "',
                ";
        }
        // line 66
        echo "                eventSources: [
                    {
                        events: function(start, end, timezone, callback) {
                            var from = moment(start.format()).format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
                            var to = moment(end.format()).format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
                            API.get('";
        // line 71
        echo $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("get_timesheets");
        echo "?size=1000&full=true&begin='+from+'&end='+to, {}, function(result) {
                                var apiEvents = [];
                                for (var record of result) {
                                    var color = record.activity.color;
                                    if (color === null) {
                                        color = record.project.color;
                                        if (color === null) {
                                            color = record.project.customer.color;
                                        }
                                    }
                                    apiEvents.push({
                                        id: record.id,
                                        title: record.activity.name,
                                        description: record.description,
                                        start: record.begin,
                                        end: record.end,
                                        activity: record.activity.name,
                                        project: record.project.name,
                                        customer: record.project.customer.name,
                                        tags: record.tags,
                                        color: color,
                                    });
                                }
                                callback(apiEvents);
                            });
                        },
                        color: '#d2d6de', // see class \"dot\"
                        name: 'kimaiUserTimeSource'
                    }
                    ";
        // line 100
        $context['_parent'] = $context;
        $context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->source, ($context["google"] ?? null), "sources", [], "any", false, false, false, 100));
        foreach ($context['_seq'] as $context["_key"] => $context["source"]) {
            // line 101
            echo "                    ,
                    {
                        googleCalendarId: '";
            // line 103
            echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["source"], "uri", [], "any", false, false, false, 103), "html", null, true);
            echo "',
                        name: '";
            // line 104
            echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["source"], "id", [], "any", false, false, false, 104), "html", null, true);
            echo "',
                        color: '";
            // line 105
            echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, $context["source"], "color", [], "any", false, false, false, 105), "html", null, true);
            echo "',
                        editable: false
                    }
                    ";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['source'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 109
        echo "                ],
                header    : {
                    left  : 'prev,next today',
                    center: 'title',
                    right : 'month,agendaWeek,agendaDay'
                },
                eventLimit: ";
        // line 115
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "dayLimit", [], "any", false, false, false, 115), "html", null, true);
        echo ",
                weekNumbers: ";
        // line 116
        if (twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "showWeekNumbers", [], "any", false, false, false, 116)) {
            echo "true";
        } else {
            echo "false";
        }
        echo ",
                allDaySlot: false,
                navLinks: true,
                locale: '";
        // line 119
        echo twig_escape_filter($this->env, twig_lower_filter($this->env, twig_replace_filter(twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, ($context["app"] ?? null), "request", [], "any", false, false, false, 119), "locale", [], "any", false, false, false, 119), ["_" => "-"])), "html", null, true);
        echo "',
                /*
                // TODO calculate height properly instead of relying on the default aspectRatio
                height: function() {
                    return 'parent';
                },
                */
                height: 'auto',
                nowIndicator: true,
                now: '";
        // line 128
        echo twig_escape_filter($this->env, $this->extensions['App\Twig\DateExtensions']->dateFormat(($context["now"] ?? null), "c"), "html", null, true);
        echo "',
                timezone: '";
        // line 129
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, twig_get_attribute($this->env, $this->source, ($context["app"] ?? null), "user", [], "any", false, false, false, 129), "preferenceValue", [0 => "timezone"], "method", false, false, false, 129), "html", null, true);
        echo "',
                weekends: ";
        // line 130
        if (twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "showWeekends", [], "any", false, false, false, 130)) {
            echo "true";
        } else {
            echo "false";
        }
        echo ",
                businessHours: {
                    dow: [";
        // line 132
        echo twig_escape_filter($this->env, twig_join_filter(twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "businessDays", [], "any", false, false, false, 132), ","), "html", null, true);
        echo "],
                    start: '";
        // line 133
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "businessTimeBegin", [], "any", false, false, false, 133), "html", null, true);
        echo "',
                    end: '";
        // line 134
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "businessTimeEnd", [], "any", false, false, false, 134), "html", null, true);
        echo "'
                },
                eventRender: function(eventObj, \$el) {
                    // don't show popover for google calendar
                    if (eventObj.source.ajaxSettings !== undefined) {
                        return;
                    }
                    // or when an event is dragged or resized
                    if(window.hidePopover) {
                        return;
                    }
                    \$el.popover({
                        title: eventObj.start.format('L') + ' | ' + eventObj.start.format('LT') + ' - ' + (eventObj.end ? eventObj.end.format('LT') : ''),
                        content:
                        '<div class=\"calendar-entry\">' +
                            '<ul>' +
                                '<li>' + '";
        // line 150
        echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans("label.customer"), "html", null, true);
        echo ": ' + eventObj.customer + '</li>' +
                                '<li>' + '";
        // line 151
        echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans("label.project"), "html", null, true);
        echo ": ' + eventObj.project + '</li>' +
                                '<li>' + '";
        // line 152
        echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\TranslationExtension']->trans("label.activity"), "html", null, true);
        echo ": ' + eventObj.activity + '</li>' +
                            '</ul>' +
                            (eventObj.description || eventObj.tags ? '<hr>' : '') +
                            (eventObj.description ? '<p>' + eventObj.description + '</p>' : '') +
                            (eventObj.tags !== null && eventObj.tags.length > 0 ? '<span class=\"badge bg-green\">' + eventObj.tags.join('</span> <span class=\"badge bg-green\">') + '</span>' : '') +
                        '</div>'
                        ,
                        trigger: 'hover',
                        placement: 'auto',
                        container: 'body',
                        html: true
                    });
                },
            ";
        // line 165
        if (( !($context["is_punch_mode"] ?? null) && $this->extensions['Symfony\Bridge\Twig\Extension\SecurityExtension']->isGranted("create_own_timesheet"))) {
            // line 166
            echo "                dayClick: function(date, jsEvent, view) {
                    // day-clicks are always triggered, unless a selection was created
                    // so clicking in a day (month view) or any slot (week and day view) will trigger a dayClick
                    // BEFORE triggering a select - make sure not two create dialogs are requested
                    if(view.type !== 'month') {
                        return;
                    }
                    var param = 'begin';
                    var begin = date.format();

                    var createUrl = '";
            // line 176
            echo $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("timesheet_create");
            echo "' + '?' + param + '=' + begin;
                    kimai.getPlugin('modal').openUrlInModal(createUrl);
                },
                selectable: true,
                select: function(start, end, jsEvent, view) {
                    if(view.type === 'month') {
                        // multi-day clicks are NOT allowed in the month view, as simple day clicks would also trigger
                        // a select - there is no way to distinguish a simple click and a two day selection
                        return;
                    }
                    var createUrl = '";
            // line 186
            echo $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("timesheet_create");
            echo "' + '?from=' + start.format() + '&to=' + end.format();
                    kimai.getPlugin('modal').openUrlInModal(createUrl);
                },
            ";
        }
        // line 190
        echo "            ";
        if ($this->extensions['Symfony\Bridge\Twig\Extension\SecurityExtension']->isGranted("edit_own_timesheet")) {
            // line 191
            echo "                eventClick: function(eventObj, jsEvent, view) {
                    if (eventObj.source.ajaxSettings !== undefined) {
                        jsEvent.preventDefault();
                        return;
                    }
                    var editUrl = '";
            // line 196
            echo $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("timesheet_edit", ["id" => "-XX-"]);
            echo "'.replace('-XX-', eventObj.id);
                    kimai.getPlugin('modal').openUrlInModal(editUrl);
                },
                ";
            // line 199
            if ( !($context["is_punch_mode"] ?? null)) {
                // line 200
                echo "                editable: true,
                eventDragStart: function(event, jsEvent, ui, view) {
                    window.hidePopover = true;
                },
                eventDragStop: function( event, jsEvent, ui, view ) {
                    window.hidePopover = false;
                },
                eventDrop: changeHandler,
                eventResizeStart: function(event, jsEvent, ui, view) {
                    window.hidePopover = true;
                },
                eventResizeStop: function( event, jsEvent, ui, view ) {
                    window.hidePopover = false;
                },
                eventResize: changeHandler,
                ";
            }
            // line 216
            echo "            ";
        }
        // line 217
        echo "                slotDuration: '";
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "slotDuration", [], "any", false, false, false, 217), "html", null, true);
        echo "',
                slotLabelInterval: '";
        // line 218
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "slotDuration", [], "any", false, false, false, 218), "html", null, true);
        echo "',
                minTime: '";
        // line 219
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "timeframeBegin", [], "any", false, false, false, 219), "html", null, true);
        echo "',
                maxTime: '";
        // line 220
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, ($context["config"] ?? null), "timeframeEnd", [], "any", false, false, false, 220), "html", null, true);
        echo "',
                defaultTimedEventDuration: '00:30'
            })
        });
    </script>
";
    }

    public function getTemplateName()
    {
        return "calendar/user.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  419 => 220,  415 => 219,  411 => 218,  406 => 217,  403 => 216,  385 => 200,  383 => 199,  377 => 196,  370 => 191,  367 => 190,  360 => 186,  347 => 176,  335 => 166,  333 => 165,  317 => 152,  313 => 151,  309 => 150,  290 => 134,  286 => 133,  282 => 132,  273 => 130,  269 => 129,  265 => 128,  253 => 119,  243 => 116,  239 => 115,  231 => 109,  221 => 105,  217 => 104,  213 => 103,  209 => 101,  205 => 100,  173 => 71,  166 => 66,  160 => 64,  158 => 63,  154 => 62,  124 => 35,  113 => 28,  109 => 27,  103 => 24,  98 => 23,  94 => 22,  88 => 19,  83 => 18,  79 => 17,  74 => 9,  70 => 8,  63 => 6,  56 => 5,  51 => 1,  49 => 3,  47 => 2,  40 => 1,);
    }

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


/* calendar/user.html.twig */
class __TwigTemplate_97e84e72e1b4b2c1cfae4ea7ae0c878b08a653178d1f53a323b4f9588e4c7aef___358738174 extends Template
{
    private $source;
    private $macros = [];

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

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

        $this->blocks = [
            'box_body_class' => [$this, 'block_box_body_class'],
            'box_body' => [$this, 'block_box_body'],
        ];
    }

    protected function doGetParent(array $context)
    {
        // line 9
        return "@AdminLTE/Widgets/box-widget.html.twig";
    }

    protected function doDisplay(array $context, array $blocks = [])
    {
        $macros = $this->macros;
        $this->parent = $this->loadTemplate("@AdminLTE/Widgets/box-widget.html.twig", "calendar/user.html.twig", 9);
        $this->parent->display($context, array_merge($this->blocks, $blocks));
    }

    // line 10
    public function block_box_body_class($context, array $blocks = [])
    {
        $macros = $this->macros;
        echo "no-padding";
    }

    // line 11
    public function block_box_body($context, array $blocks = [])
    {
        $macros = $this->macros;
        // line 12
        echo "            <div id=\"timesheet_calendar\"></div>
        ";
    }

    public function getTemplateName()
    {
        return "calendar/user.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  493 => 12,  489 => 11,  482 => 10,  471 => 9,  419 => 220,  415 => 219,  411 => 218,  406 => 217,  403 => 216,  385 => 200,  383 => 199,  377 => 196,  370 => 191,  367 => 190,  360 => 186,  347 => 176,  335 => 166,  333 => 165,  317 => 152,  313 => 151,  309 => 150,  290 => 134,  286 => 133,  282 => 132,  273 => 130,  269 => 129,  265 => 128,  253 => 119,  243 => 116,  239 => 115,  231 => 109,  221 => 105,  217 => 104,  213 => 103,  209 => 101,  205 => 100,  173 => 71,  166 => 66,  160 => 64,  158 => 63,  154 => 62,  124 => 35,  113 => 28,  109 => 27,  103 => 24,  98 => 23,  94 => 22,  88 => 19,  83 => 18,  79 => 17,  74 => 9,  70 => 8,  63 => 6,  56 => 5,  51 => 1,  49 => 3,  47 => 2,  40 => 1,);
    }

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