<?php

/* DorcasTabithaBundle:ClientInformation:clientinformationformupdate.html.twig */
class __TwigTemplate_a9202a23c33705dc16d04bf001177cf0 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>

    <form id=\"clientform\" action=\"";
        // line 8
        if (isset($context["client"])) { $_client_ = $context["client"]; } else { $_client_ = null; }
        echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath("DorcasTabithaBundle_clientinformation_update", array("client_id" => $this->getAttribute($_client_, "clientid"))), "html", null, true);
        echo "\" method=\"post\" ";
        if (isset($context["form"])) { $_form_ = $context["form"]; } else { $_form_ = null; }
        echo $this->env->getExtension('form')->renderEnctype($_form_);
        echo ">
        ";
        // line 9
        $this->env->loadTemplate("DorcasTabithaBundle:ClientInformation:clientinformationlayout.html.twig")->display($context);
        // line 10
        echo "    </form>

";
    }

    // line 14
    public function block_javascripts($context, array $blocks = array())
    {
        // line 15
        echo "
    ";
        // line 16
        $this->displayParentBlock("javascripts", $context, $blocks);
        echo "
    
<script type=\"text/javascript\">

\$(function() {
//    \$( \".datepicker\" ).datepicker({ showAnim: \"slideDown\" });
    \$( \".datepicker\" ).datepicker({ changeMonth: true, changeYear: true, yearRange:\"-90:+0\", maxDate: \"+0d\"
        });
        });

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


    /**--------------------------
    //* Validate Date Field script- By JavaScriptKit.com
    //* For this script and 100s more, visit http://www.javascriptkit.com
    //* This notice must stay intact for usage
    ---------------------------**/

function checkdate(input){
    var validformat=/^\\d{2}\\/\\d{2}\\/\\d{4}\$/ //Basic check for format validity
    var returnval=false
    if (!validformat.test(input))
    {
//        alert(\"Invalid Date Format. Please correct and submit again.\")
    }
    else{ //Detailed check for valid date ranges
        var monthfield=input.split(\"/\")[0]
        var dayfield=input.split(\"/\")[1]
        var yearfield=input.split(\"/\")[2]
        var dayobj = new Date(yearfield, monthfield-1, dayfield)
        if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
        {
//            alert(\"Invalid Day, Month, or Year range detected. Please correct and submit again.\")
        }
        else
            returnval=true
    }
  //  if (returnval==false) input.select()
    return returnval
}



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)
    {
        savenext(true)
    }
    else
    {
        savenext(false);
    }
}


function savenext(nav)
{ 
    // Read all values
    var ssn = document.getElementById('clientinformationform_ssn').value;
    var firstName = document.getElementById('clientinformationform_first_name').value;
    var lastName = document.getElementById('clientinformationform_last_name').value;
    var city = document.getElementById('clientinformationform_city').value;
    var state = document.getElementById('clientinformationform_state').value;
    var genderF = document.getElementById('clientinformationform_gender_f').checked;
    var genderM = document.getElementById('clientinformationform_gender_m').checked;
    var birthDate = document.getElementById('clientinformationform_birth_date').value;
    var otherAdultOneSsn = document.getElementById('clientinformationform_other_adult_oneSsn').value;
    var otherAdultTwoSsn = document.getElementById('clientinformationform_other_adult_twoSsn').value;
    var homePhone = document.getElementById('clientinformationform_home_phone').value;
    var cellPhone = document.getElementById('clientinformationform_cell_phone').value;
    var workPhone = document.getElementById('clientinformationform_work_phone').value;
    var email = document.getElementById('clientinformationform_email').value;

    okaytosubmit = true;
    alertMessage = \"\";

    // Check SSN for blank or length < 11 characters
    if (!ssn || ssn.length < 11)
    {
        alertMessage = alertMessage + '&#8227 Please enter Social Security Number. <br/>';
        okaytosubmit = false;
    }

    // Check First Name for blank
    if (!firstName)
    {
        alertMessage = alertMessage + '&#8227 Please enter First Name. <br/>';
        okaytosubmit = false;
    }

    // Check Last Name for blank
    if (!lastName)
    {
        alertMessage = alertMessage + '&#8227 Please enter Last Name. <br/>';
        okaytosubmit = false;
    }

    // Check City for blank
    if (!city)
    {
        alertMessage = alertMessage + '&#8227 Please enter City. <br/>';
        okaytosubmit = false;
    }


    // Check State for blank
    if (!state)
    {
        alertMessage = alertMessage + '&#8227 Please enter City. <br/>';
        okaytosubmit = false;
    }

    // Check Gender for checked
    if (!genderF && !genderM)
    {
        alertMessage = alertMessage + '&#8227 Please enter Gender. <br/>';
        okaytosubmit = false;
    }

    // Check Home Phone length < 14 characters
    if (homePhone && homePhone.length < 14)
    {
        alertMessage = alertMessage + '&#8227 Please correct Home Phone. <br/>';
        okaytosubmit = false;
    }

    // Check Cell Phone length < 14 characters
    if (cellPhone && cellPhone.length < 14)
    {
        alertMessage = alertMessage + '&#8227 Please correct Cell Phone. <br/>';
        okaytosubmit = false;
    }

    // Check Work Phone length < 14 characters
    if (workPhone && workPhone.length < 14)
    {
        alertMessage = alertMessage + '&#8227 Please correct Work Phone. <br/>';
        okaytosubmit = false;
    }

    // Check Birth Date for blank
    if (!birthDate)
    {
        alertMessage = alertMessage + '&#8227 Please enter Birth Date. <br/>';
        okaytosubmit = false;
    }

    // Check Birth Date for valid date
    if (birthDate && !checkdate(birthDate))
    {
        alertMessage = alertMessage + '&#8227 Please enter a valid Birth Date. <br/>';
        okaytosubmit = false;
    }

    // Check Other Adult One SSN for not blank and length = 11 characters
    if (otherAdultOneSsn && otherAdultOneSsn.length < 11)
    {
        alertMessage = alertMessage + '&#8227 Please correct Other Adult #1 SSN. <br/>';
        okaytosubmit = false;
    }

    // Check Other Adult Two SSN for not blank and length = 11 characters
    if (otherAdultTwoSsn && otherAdultTwoSsn.length < 11)
    {
        alertMessage = alertMessage + '&#8227 Please correct Other Adult #2 SSN. <br/>';
        okaytosubmit = false;
    }
    
    // Check Email for valid (kinda) address
    if ( email )
    {
        var atpos = email.indexOf(\"@\");
        var dotpos = email.lastIndexOf(\".\");
        if ( atpos <1 || dotpos < atpos+2 || dotpos+2 >= email.length)
        //if ( email && email.indexOf(\"@\") == -1 ))
        {
            alertMessage = alertMessage + '&#8227 Please enter a valid Email address.<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 Client Information will not be saved! </p>';
                warnusers(alertMessage);
            }
            else
            {
                alert(alertMessage);
            }
    }
}

function warnUsersSearch(uriLocation)
{
     alertMessage = '<p style = \"color:red;\"> Warning: Any changes to Client Information will not be saved! </p>';
     warnRedirect(uriLocation, alertMessage);
}

warnRedirect = function(uriLocation, message) {
\t\$('#override_javascript_alertx').html(message).dialog({
\t\tmodal: true,
                title:'Tabitha Warning Message',
\t\t\tbuttons: {
\t\t\t\t\"Continue to Search Page\": function() {
                                        window.location = uriLocation;
\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};


</script>

";
    }

    public function getTemplateName()
    {
        return "DorcasTabithaBundle:ClientInformation:clientinformationformupdate.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  457 => 206,  453 => 204,  449 => 203,  443 => 202,  436 => 197,  429 => 195,  426 => 194,  420 => 193,  416 => 192,  413 => 191,  410 => 190,  408 => 189,  405 => 188,  398 => 185,  391 => 182,  384 => 179,  377 => 176,  369 => 172,  365 => 170,  362 => 169,  359 => 168,  354 => 167,  352 => 166,  322 => 140,  315 => 137,  308 => 134,  301 => 131,  281 => 122,  276 => 119,  272 => 117,  268 => 116,  260 => 113,  242 => 105,  237 => 104,  233 => 103,  220 => 99,  210 => 97,  207 => 96,  192 => 90,  185 => 87,  164 => 78,  145 => 69,  142 => 68,  131 => 64,  125 => 61,  81 => 25,  70 => 21,  41 => 12,  174 => 64,  169 => 61,  128 => 38,  203 => 71,  187 => 61,  141 => 47,  129 => 63,  119 => 37,  59 => 17,  370 => 141,  355 => 130,  350 => 129,  345 => 128,  338 => 125,  333 => 124,  328 => 123,  321 => 120,  316 => 119,  311 => 118,  304 => 115,  299 => 114,  294 => 128,  287 => 123,  274 => 101,  269 => 100,  264 => 99,  257 => 96,  247 => 106,  240 => 91,  223 => 100,  218 => 85,  213 => 84,  205 => 80,  195 => 78,  188 => 75,  183 => 74,  171 => 81,  149 => 71,  137 => 52,  72 => 26,  40 => 12,  21 => 3,  252 => 107,  248 => 74,  244 => 73,  236 => 71,  230 => 102,  225 => 63,  222 => 62,  212 => 50,  204 => 95,  200 => 79,  197 => 47,  177 => 65,  160 => 54,  157 => 75,  126 => 18,  106 => 32,  98 => 6,  184 => 60,  181 => 59,  173 => 38,  163 => 49,  155 => 63,  139 => 66,  135 => 58,  133 => 57,  114 => 15,  110 => 49,  105 => 47,  93 => 27,  76 => 22,  69 => 47,  209 => 78,  206 => 51,  201 => 76,  194 => 64,  191 => 70,  186 => 67,  180 => 66,  176 => 61,  166 => 66,  158 => 48,  153 => 51,  143 => 49,  134 => 20,  123 => 60,  118 => 36,  90 => 33,  87 => 27,  66 => 20,  60 => 39,  146 => 44,  136 => 65,  122 => 17,  107 => 33,  101 => 31,  95 => 29,  82 => 25,  73 => 22,  67 => 17,  52 => 14,  109 => 41,  104 => 34,  96 => 32,  84 => 26,  80 => 24,  26 => 7,  34 => 3,  112 => 34,  102 => 32,  89 => 16,  63 => 40,  56 => 12,  43 => 9,  92 => 28,  79 => 29,  57 => 16,  46 => 10,  37 => 4,  33 => 4,  29 => 2,  19 => 1,  44 => 9,  27 => 3,  55 => 15,  45 => 10,  36 => 8,  50 => 15,  47 => 14,  30 => 4,  25 => 3,  249 => 96,  239 => 72,  235 => 90,  228 => 84,  224 => 82,  219 => 80,  217 => 58,  214 => 98,  211 => 75,  208 => 74,  202 => 94,  199 => 93,  193 => 44,  182 => 63,  178 => 84,  175 => 57,  172 => 59,  165 => 55,  161 => 57,  156 => 51,  154 => 57,  150 => 50,  147 => 49,  132 => 51,  127 => 62,  117 => 51,  113 => 34,  86 => 32,  83 => 25,  78 => 15,  68 => 20,  64 => 22,  61 => 21,  48 => 10,  39 => 8,  32 => 5,  24 => 6,  22 => 4,  23 => 3,  20 => 2,  17 => 1,  144 => 55,  138 => 46,  130 => 19,  124 => 38,  121 => 59,  115 => 45,  111 => 33,  108 => 31,  99 => 43,  94 => 34,  91 => 71,  88 => 28,  85 => 26,  77 => 58,  74 => 20,  71 => 21,  65 => 19,  62 => 15,  58 => 16,  54 => 15,  51 => 14,  42 => 9,  38 => 11,  35 => 10,  31 => 8,  28 => 3,);
    }
}
