<%namespace name='static' file='static_content.html'/>
<%! from django.core.urlresolvers import reverse %>
<%! from django_countries.countries import COUNTRIES %>
<%! from student.models import UserProfile %>
<%! from datetime import date %>
<%! import calendar %>

<section id="testcenter-register-modal" class="modal testcenter-register-modal">
  <div class="inner-wrapper">
    <div id="register">
      <header>
        <h2>Sign Up for Pearson VUE Test Center Proctoring</h2>
        <hr>
      </header>

      <form id="test_register_form" class="test_register_form" method="post" data-remote="true" action="/create_test_registration">
        <div class="notice"></div>
        <div id="register_error" class="modal-form-error" name="register_error"></div>
        <div id="register_error" name="register_error"></div>
	<!-- include these as pass-throughs -->
        <input id="id_email" type="hidden" name="email" maxlength="75" value="${user.email}" />
        <input id="id_username" type="hidden" name="username" maxlength="75" value="${user.username}" />
	<!-- TODO: add the course somehow... -->

	<!-- we should first start with information that we already know about the user,
	     though we should also give them the option to fix it. 
	     Some things don't change, once assigned, like client_candidate_id
	     or candidate_id. 
	  -->
        <div class="input-group">
          <label data-field="first_name">First Name*</label>
          <input name="first_name" type="text" value="${testcenteruser.first_name}" maxlength="30" placeholder="e.g. Jane">
          <label data-field="last_name">Last Name*</label>
          <input name="last_name" type="text" value="${testcenteruser.last_name}" placeholder="e.g. Smith">
          <label data-field="middle_name">Middle Name</label>
          <input name="middle_name" type="text" value="${testcenteruser.middle_name}" placeholder="e.g. Michael">
          <label data-field="suffix">Suffix</label>
          <input name="suffix" type="text" value="${testcenteruser.suffix}" placeholder="e.g. Jr.">
          <label data-field="salutation">Salutation</label>
          <input name="salutation" type="text" value="${testcenteruser.salutation}" placeholder="e.g. Dr.">
        </div>

        <div class="input-group">
          <label data-field="address_1">Address1*</label>
          <input name="address_1" type="text" value="${testcenteruser.address_1}" placeholder="123 Main St.">
          <label data-field="address_2">Address2</label>
          <input name="address_2" type="text" value="${testcenteruser.address_2}" placeholder="Apartment 2B.">
          <label data-field="address_3">Address3</label>
          <input name="address_3" type="text" value="${testcenteruser.address_3}" placeholder="Attention: John Smith">

          <label data-field="city">City</label>
          <input name="city" type="text" value="${testcenteruser.city}" placeholder="Our Fair City">
          <label data-field="state">State/Province</label>
          <input name="state" type="text" value="${testcenteruser.state}" placeholder="MA">
          <label data-field="postal_code">Postal Code</label>
          <input name="postal_code" type="text" value="${testcenteruser.postal_code}" placeholder="02138">
          <label data-field="country">Country Code*</label>
          <input name="country" type="text" value="${testcenteruser.country}" placeholder="USA">
        </div>

	<!-- for now, just leave off the phone and company information -->
        <div class="input-group">
          <label data-field="phone">Phone*</label>
          <input name="phone" type="text" value="${testcenteruser.phone}" placeholder="1-23-456-7890">
          <label data-field="phone">Extension</label>
          <input name="extension" type="text" value="${testcenteruser.extension}" placeholder="x123">
          <label data-field="phone_country_code">Phone Country Code*</label>
          <input name="phone_country_code" type="text" value="${testcenteruser.phone_country_code}" placeholder="ABC">
          <label data-field="fax">Fax</label>
          <input name="fax" type="text" value="${testcenteruser.fax}" placeholder="1-23-456-7891">
          <label data-field="fax_country_code">Fax Country Code*</label>
          <input name="fax_country_code" type="text" value="${testcenteruser.fax_country_code}" placeholder="ABC">
          <label data-field="company_name">Company</label>
          <input name="company_name" type="text" value="${testcenteruser.company_name}" placeholder="Acme Corporation">
        </div>

        <div class="input-group">
          <label data-field="accommodations">Accommodations Requested</label>
          <textarea name="accommodations"></textarea>
        </div>

        <div class="submit">
          <input name="submit" type="submit" value="Register for Test">
        </div>
      </form>

    </div>

    <div class="close-modal">
      <div class="inner">
        <p>&#10005;</p>
      </div>
    </div>
  </div>
</section>

<script type="text/javascript">
  (function() {
   $(document).delegate('#test_register_form', 'ajax:success', function(data, json, xhr) {
     if(json.success) {
       location.href="${reverse('dashboard')}";
     } else {
       $(".field-error").removeClass('field-error');
       $('#register_error').html(json.value).stop().css("display", "block");
       $("[data-field='"+json.field+"']").addClass('field-error')
     }
    });
  })(this)
</script>
