<?php

/* DorcasTabithaBundle:Users:userformtwo.html.twig */
class __TwigTemplate_1213733593cebcec7954ef16ad529ab7 extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = $this->env->loadTemplate("::base.html.twig");

        $this->blocks = array(
            'body' => array($this, 'block_body'),
            'javascripts' => array($this, 'block_javascripts'),
        );
    }

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

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

    // line 3
    public function block_body($context, array $blocks = array())
    {
        // line 4
        echo "
<div id=\"override_javascript_alert\"></div>
<div id=\"override_javascript_alertx\"></div>

<div id=\"navbar\" style=\"font-size:18px;\">   
    <ul>       
        <li><a href=\"";
        // line 10
        echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("DorcasTabithaBundle_homepage"), "html", null, true);
        echo "\">Home</a></li>
        <li><a href=\"";
        // line 11
        echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("DorcasTabithaBundle_search_show"), "html", null, true);
        echo "\">Client Search</a></li> 
        <li><a href=\"";
        // line 12
        echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("DorcasTabithaBundle_clientinformation_new"), "html", null, true);
        echo "\">New Client</a></li> 
        ";
        // line 13
        if ($this->env->getExtension('security')->isGranted("ROLE_ADMIN")) {
            // line 14
            echo "            <li><a href=\"";
            echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("DorcasTabithaBundle_users_show"), "html", null, true);
            echo "\" style=\"background-color:#00b5cb; font-size:30px;\">Users</a></li>
            <li><a href=\"";
            // line 15
            echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("DorcasTabithaBundle_message_show"), "html", null, true);
            echo "\">Message/Reports</a></li>
        ";
        }
        // line 16
        echo "  
    </ul> 
</div>

    <section class=\"user\" id=\"users\">
                ";
        // line 22
        echo "       

        ";
        // line 24
        if (array_key_exists("form", $context)) {
            // line 25
            echo "            <div style=\"color:maroon;\">
            ";
            // line 26
            echo $this->env->getExtension('form')->renderErrors($this->getContext($context, "form"));
            echo "
            </div>
        ";
        }
        // line 29
        echo "
        ";
        // line 30
        echo $this->env->getExtension('actions')->renderAction("DorcasTabithaBundle:Users:renew", array("user" => $this->getContext($context, "user")), array());
        // line 31
        echo "    </section>

    <section class=\"users\" id=\"users\">
        <section class=\"previous-users\">       
           ";
        // line 35
        $this->env->loadTemplate("DorcasTabithaBundle:Users:userloop.html.twig")->display(array_merge($context, array("users" => $this->getContext($context, "users"))));
        // line 36
        echo "        </section>
    </section>

    </div>
</div>

";
    }

    // line 44
    public function block_javascripts($context, array $blocks = array())
    {
        // line 45
        echo "
    ";
        // line 46
        $this->displayParentBlock("javascripts", $context, $blocks);
        echo " 

<script type=\"text/javascript\">

function displayemail()
{
    var textareaid = document.getElementById('emailList');
    if ( textareaid.style.display=='none')
    {
        textareaid.style.display='block';
    }
    else
    {
        textareaid.style.display='none';
    }

}   


window.alert = function(message) {
\t\$('#override_javascript_alert').html(message).dialog({
\t\tmodal:true,
\t\ttitle:'Tabitha Validation Message',
\t\tbuttons: {
\t\t\t'OK':function(){
\t\t\t\t\$(this).dialog('close');
\t\t\t}
\t\t}
\t});
};

warnusers = function(message) {
\t\$('#override_javascript_alertx').html(message).dialog({
\t\tmodal: true,
                title:'Tabitha Warning Message',
\t\t\tbuttons: {
\t\t\t\t\"Continue to Home Page\": function() {
                                        var form = document.forms[\"clientform\"];
                                        form.submit();
\t\t\t\t\t\$( this ).dialog( \"close\" );
\t\t\t\t},
\t\t\t\tCancel: function() {
\t\t\t\t\t\$( this ).dialog( \"close\" );
\t\t\t\t}
\t\t\t}
\t\t});
\t};


function submitFormClient(navnumber) {
    var form = document.forms[\"clientform\"];
    var hiddenField = document.createElement(\"input\"); 
    hiddenField.setAttribute(\"type\", \"hidden\"); 
    hiddenField.setAttribute(\"name\", \"passnav\"); 
    hiddenField.setAttribute(\"value\", navnumber); 
    form.appendChild(hiddenField);
    if (navnumber == 9)
    {
        save(true)
    }
    else
    {
        save(false);
    }
}
    

function save(nav)
{ 
    // Read all values

    var username = document.getElementById('userform_username');
    var firstname = document.getElementById('userform_first_name');
    var lastname = document.getElementById('userform_last_name');
    var passwordfirst = document.getElementById('userform_password_first');
    var passwordsecond = document.getElementById('userform_password_second');

    okaytosubmit = true;
    alertMessage = \"\";

    // Check username for length < 5 characters
    if ( username.value.length < 5 )
    {
        alertMessage = alertMessage + '&#8227 Username must have at least 5 characters.<br/>';
        okaytosubmit = false;
    }

    // Check Password First not blank and for length < 8 chanracters
    if ( passwordfirst.value != '' && passwordfirst.value.length < 8 )
    {
        alertMessage = alertMessage + '&#8227 Password must have at least 8 characters.<br/>';
        okaytosubmit = false;
    }

    // Check Password Second not blank and for length < 8 chanracters
    else if ( passwordsecond.value != '' && passwordsecond.value.length < 8 )
    {
        alertMessage = alertMessage + '&#8227 Confirm Password must have at least 8 characters.<br/>';
        okaytosubmit = false;
    }

    // Check that passwords match
    if ( passwordfirst.value != passwordsecond.value )
    {
        alertMessage = alertMessage + '&#8227 Passwords do not match.<br/>';
        okaytosubmit = false;
    }


    // Check First Name not blank
    if ( firstname.value == '' )
    {
        alertMessage = alertMessage + '&#8227 Please enter a first name.<br/>';
        okaytosubmit = false;
    }

    // Check Last Name not blank
    if ( lastname.value == '' )
    {
        alertMessage = alertMessage + '&#8227 Please enter a last name.<br/>';
        okaytosubmit = false;
    }

    if (okaytosubmit == true)
    {
        var form = document.forms[\"clientform\"];
        form.submit();
    }
    else
    {
        // If HOME Nav is selected, then it is okay to redirect without saving
            if(nav)
            {
                alertMessage = '<p style = \"color:red;\"> Warning: Your changes to Users will not be saved! </p>';
                warnusers(alertMessage);
            }
            else
            {
                alert(alertMessage);
            }
    }
}

</script>       
 
";
    }

    public function getTemplateName()
    {
        return "DorcasTabithaBundle:Users:userformtwo.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  113 => 46,  110 => 45,  107 => 44,  97 => 36,  95 => 35,  89 => 31,  87 => 30,  84 => 29,  78 => 26,  75 => 25,  73 => 24,  69 => 22,  62 => 16,  57 => 15,  52 => 14,  50 => 13,  46 => 12,  42 => 11,  38 => 10,  30 => 4,  27 => 3,);
    }
}
