<?php

/* VGMWOBundle:NDepartment:show.html.twig */
class __TwigTemplate_1119322d342ea5e8ecdb609f6fcdcb64bca99ae2573fe73ca8e90ac5470debba extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        // line 1
        $this->parent = $this->loadTemplate("VGMWOBundle::layout.html.twig", "VGMWOBundle:NDepartment:show.html.twig", 1);
        $this->blocks = array(
            'jumbotron_content' => array($this, 'block_jumbotron_content'),
            'content' => array($this, 'block_content'),
            'javascripts' => array($this, 'block_javascripts'),
        );
    }

    protected function doGetParent(array $context)
    {
        return "VGMWOBundle::layout.html.twig";
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        $this->parent->display($context, array_merge($this->blocks, $blocks));
    }

    // line 2
    public function block_jumbotron_content($context, array $blocks = array())
    {
        // line 3
        echo "    <div class=\"jumbotron\" style=\"padding-top: 10px; padding-bottom: 5px;\"  id=\"jumbotron\">
        <div class=\"container-fluid\">
            <div class=\"col-md-12 text-center\" style=\"padding-left: 0px;\">
                <H3 style=\"margin: 0px;\"><strong>Show and update departments</strong></H3>
            </div>
        </div>
    </div>
";
    }

    // line 11
    public function block_content($context, array $blocks = array())
    {
        // line 12
        echo "    <div class=\"container\" style=\"min-height: 500px;\">
        <div class=\"col-md-12 text-right\">
            <div class=\"col-ms-2 pull-right\">
                <a href=\"";
        // line 15
        echo $this->env->getExtension('routing')->getPath("vgm_departments");
        echo "\">
                    <span class=\"glyphicon glyphicon-list\"></span>
                    Main list
                </a>
            </div>
        </div>
        <div class=\"form-group container-fluid\">
            <div class=\"row\">
                <div>
                    <label style=\"margin-bottom: 0px;\">Department name: </label>
                    <input type=\"text\" class=\"form-control for-desktop\"
                           id=\"name\"
                           name=\"name\"
                           placeholder=\"Department Name\"
                           data-bind=\"value: name,
                                      event:{blur: check_dep_exist}\"
                           tabindex=\"1\"/>
                </div>
                <div>
                    <label style=\"margin-bottom: 0px; margin-top: 10px;\">Supervisors: </label>
                    <div data-bind=\"foreach: supervisors\">
                        <div>
                            <input type=\"checkbox\"
                                   data-bind=\"checked: selected,
                                              attr: {id: 'supervisor-' + id}\">
                            <span data-bind=\"text: fullname\"></span>
                        </div>
                    </div>
                    ";
        // line 52
        echo "                </div>
                <div>
                    <label style=\"margin-bottom: 0px; margin-top: 10px;\">Decription: </label>
                    <textarea class=\"form-control\" rows=\"3\"
                              id=\"description\"
                              name=\"description\"
                              placeholder=\"Department Description\"
                              data-bind=\"value: description\"
                              tabindex=\"3\"></textarea>
                </div>
            </div>
        </div>
        <div class=\"col-lg-12 container-fluid text-right\">
            <a class=\"btn btn-primary btn-sm\" href=\"#\" data-bind=\"click: update\">
                Update
            </a>
            <a class=\"btn btn-warning btn-sm\" href=\"";
        // line 68
        echo $this->env->getExtension('routing')->getPath("vgm_departments");
        echo "\">
                Cancel
            </a>
        </div>
    </div>
";
    }

    // line 74
    public function block_javascripts($context, array $blocks = array())
    {
        // line 75
        echo "    ";
        $this->displayParentBlock("javascripts", $context, $blocks);
        echo "
    <script type=\"text/javascript\" src=\"";
        // line 76
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/js/customized/validations/OnChangeValidations.js"), "html", null, true);
        echo "\"></script>
    <script type=\"text/javascript\" src=\"";
        // line 77
        echo twig_escape_filter($this->env, $this->env->getExtension('assets')->getAssetUrl("bundles/vgmwo/js/customized/Departments.js"), "html", null, true);
        echo "\"></script>
    <script type=\"text/javascript\">
        function go_departments_list(){
            var url = \"";
        // line 80
        echo $this->env->getExtension('routing')->getPath("vgm_departments");
        echo "\";
            window.location.href = url;
        }
        function depExist(){
            var dep_name = viewModel.name();
            var exist = false;
            if(dep_name != \"\"){
                \$.ajax({
                    type: 'post',
                    async: false,
                    dataType: 'json',
                    url: '";
        // line 91
        echo $this->env->getExtension('routing')->getPath("check_updating_exist");
        echo "',
                    data: {name: dep_name},
                    success: function(response) {
                        exist = response.exist;
                    },
                    error:function() {
                        alert(\"Checking dep's name error\");
                    }

                });
            }
            return exist;
        }

        function depUpdate(){
            \$.ajax({
                type: 'post',
                async: true,
                dataType: 'json',
                url: '";
        // line 110
        echo $this->env->getExtension('routing')->getPath("update_department");
        echo "',
                data: {id: viewModel.id(),
                       name: viewModel.name(),
                       sup_id: viewModel.chosensup() ? viewModel.chosensup().id : null,
                       description: viewModel.description()},
                success: function(response) {
                    go_departments_list();
                },
                error:function() {
                    alert(\"Updating department error\");
                }
            });
        }

        viewModel.LoadData = ko.dependentObservable(function() {
            viewModel.id(\"";
        // line 125
        echo twig_escape_filter($this->env, $this->getAttribute((isset($context["dep"]) ? $context["dep"] : null), "id", array()), "html", null, true);
        echo "\");
            viewModel.description(\"";
        // line 126
        echo twig_escape_filter($this->env, $this->getAttribute((isset($context["dep"]) ? $context["dep"] : null), "description", array()), "html", null, true);
        echo "\");
            viewModel.name(\"";
        // line 127
        echo twig_escape_filter($this->env, $this->getAttribute((isset($context["dep"]) ? $context["dep"] : null), "name", array()), "html", null, true);
        echo "\");

            var dsups = Array();
            ";
        // line 130
        $context['_parent'] = (array) $context;
        $context['_seq'] = twig_ensure_traversable($this->getAttribute((isset($context["dep"]) ? $context["dep"] : null), "supervisors", array()));
        foreach ($context['_seq'] as $context["_key"] => $context["sup"]) {
            // line 131
            echo "                dsups.push(sup.id);
            ";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['sup'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 133
        echo "
            //Filling the lists
            ";
        // line 135
        $context['_parent'] = (array) $context;
        $context['_seq'] = twig_ensure_traversable((isset($context["sups"]) ? $context["sups"] : null));
        foreach ($context['_seq'] as $context["_key"] => $context["sup"]) {
            // line 136
            echo "                var dsup = \$.grep(dsups, function(su){ return su.id == \"";
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "id", array()), "html", null, true);
            echo "\"; }).length == 1 ?
                        \$.grep(dsups, function(su){ return su.id == \"";
            // line 137
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "id", array()), "html", null, true);
            echo "\"; })[0] : null;

                if(dsup != null)
                    viewModel.supervisors.push(new supervisor(\"";
            // line 140
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "id", array()), "html", null, true);
            echo "\",
                        \"";
            // line 141
            echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($context["sup"], "picture", array()), "getFinalWebPath", array()), "html", null, true);
            echo "\", \"";
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "workercode", array()), "html", null, true);
            echo "\",
                        \"";
            // line 142
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "name", array()), "html", null, true);
            echo " ";
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "lastname", array()), "html", null, true);
            echo "\", true));
                else
                    viewModel.supervisors.push(new supervisor(\"";
            // line 144
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "id", array()), "html", null, true);
            echo "\",
                            \"";
            // line 145
            echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($context["sup"], "picture", array()), "getFinalWebPath", array()), "html", null, true);
            echo "\", \"";
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "workercode", array()), "html", null, true);
            echo "\",
                            \"";
            // line 146
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "name", array()), "html", null, true);
            echo " ";
            echo twig_escape_filter($this->env, $this->getAttribute($context["sup"], "lastname", array()), "html", null, true);
            echo "\", false));
            ";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['sup'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 148
        echo "        }, viewModel);

        // Activates knockout.js
        ko.applyBindings(viewModel, document.getElementById(\"content-body\"));
    </script>
";
    }

    public function getTemplateName()
    {
        return "VGMWOBundle:NDepartment:show.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  264 => 148,  254 => 146,  248 => 145,  244 => 144,  237 => 142,  231 => 141,  227 => 140,  221 => 137,  216 => 136,  212 => 135,  208 => 133,  201 => 131,  197 => 130,  191 => 127,  187 => 126,  183 => 125,  165 => 110,  143 => 91,  129 => 80,  123 => 77,  119 => 76,  114 => 75,  111 => 74,  101 => 68,  83 => 52,  52 => 15,  47 => 12,  44 => 11,  33 => 3,  30 => 2,  11 => 1,);
    }
}
