<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
	"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
  <title>Application for HILIS Registration</title>
  <link rel="stylesheet" type="text/css" href="/css/site.css" />
  <script language="javascript" type="text/javascript">
  <!-- Hide script
  //<![CDATA[
    function showhide_source(f,v) {
      var t = f.elements['other_source'];
      if(v=='OTHER'){
        t.style.visibility='visible'
      }
      else{
        t.style.visibility='hidden'
      }
    }
    function showhide_role(f,v) {
      var t = f.elements['other_role'];
      if(v=='OTHER'){
        t.style.visibility='visible'
      }
      else{
        t.style.visibility='hidden'
      }
    }
    onload = function() {
      [% UNLESS vars.location.match('OTHER') %]
        document.application.other_source.style.visibility='hidden'
      [% END %]
      [% UNLESS vars.designation.match('OTHER') %]
        document.application.other_role.style.visibility='hidden'
      [% END %]
    }
    //]]> End script hiding -->
    </script>
</head>
<body>
  [% # PROCESS dumper.tt dump = vars %]
  [% # PROCESS dumper.tt dump = errs %]
  <div>
    <p>
      <a name="top">
        <img src="/images/logo.jpeg" title="Leeds Teaching Hospitals NHS Trust Logo"
            border="0" align="right" alt="Logo"/>
      </a>
    </p>
    <br clear="all" />

    <table cellspacing="1" cellpadding="3" border="0" width="100%">
      <tr bgcolor="#cbe0eb">
        <td align="left" valign="top" class="border">
          &nbsp;<b>Welcome to HMDS</b>
        </td>
        <td align="center" class="border" valign="top" width="50%">
          [% USE date(format = '%A, %d %B %Y, %T', locale = 'en_GB');
            date.format %]
        </td>
        <td align="right" width="25%" class="border" valign="top">&nbsp;</td>
      </tr>
    </table>
    <br />
  
    <table id="main">
      <tr>
        <td>
          <table>
            <tr>
              <td>
                <h2>Application for HILIS Registration</h2>
                [% UNLESS send_success # already submitted %]
                <p>
                  Please enter your details below. All fields are required.
                </p>
                [% END %]
                
              [% IF errs.error_other_role || errs.error_other_source %]
              <ul class="dfv_errors">
                [% IF errs.error_other_role %]
                  <li>
                    please enter an alternative role if selecting 'other'
                  </li>
                [% END %]
                [% IF errs.error_other_source %]
                  <li>
                    please enter an alternative location if selecting 'other'
                   </li>
                [% END %]
              </ul>
              [% END %]
              
              [% IF msg %]
              <p class="dfv_errors">
              Sorry, there is a problem with the mail server and your message was
              not	sent. Your details have been preserved in the form below, please
              try again shortly. The error	message	was: "[% msg %]". Please copy
              this message to <a href="mailto:[% admin %]">HMDS admin</a> if the
              error persists. Apologies for the inconvenience.
              </p>
              [% ELSIF send_success %]
              <p class="info">
              Your registration details have been submitted. You should receive
              an e-mail copy within 24 hours at [% vars.email %], but if not please
              contact <a href="mailto:[% admin %]">HMDS admin</a>.
              </p>
              [% END %]
              
                <form method="post" action="[% %]" name="application"
                  enctype="application/x-www-form-urlencoded">
                  <div id="registration">
                    <table border="0">
                      <tr>
                        <td class="red">First Name:</td>
                        <td colspan="2">
                          <input type="text" name="first_name" />
                          [% errs.error_first_name %]
                        </td>
                      </tr>
                      
                      <tr>
                        <td class="red">Last Name:</td>
                        <td colspan="2">
                          <input type="text" name="last_name" />
                          [% errs.error_last_name %]
                        </td>
                      </tr>
                      
                      <tr>
                        <td class="red">Location:</td>
                        <td>
                          <select name="location"
                            onchange="showhide_source(this.form,this.value)">
                            <option value=""></option>
                          [% FOREACH location IN user_locations.sort %]
                            <option value="[% location %]">[% location %]</option>
                          [% END %]
                            <option disabled>---</option>
                            <option value="OTHER">Other</option>
                          </select>
                          [% errs.error_location %]
                        </td>
                        <td>
                          <textarea name="other_source" id="other_source" rows=1
                            cols=15></textarea>
                        </td>
                      </tr>
                      
                      <tr>
                        <td class="red">Department:</td>
                        <td colspan="2">
                          <input type="text" name="dept" />
                          [% errs.error_dept %]
                        </td>
                      </tr>
                      
                      <tr>
                        <td class="red">Role:</td>
                        <td>
                          <select name="designation"
                              onchange="showhide_role(this.form,this.value)">
                            <option  value=""></option>
                          [% FOREACH role IN roles.sort;
                                NEXT IF role.match('^(Administrator|Visitor|Guest|Lab staff)');                            
                            %]
                            <option value="[% role %]">[% role %]</option>
                          [% END %]
                            <option disabled>---</option>
                            <option value="OTHER">Other</option>
                          </select>
                          [% errs.error_role %]
                        </td>
                        <td>
                          <textarea name="other_role" rows=1 cols=15></textarea>
                        </td>
                      </tr>
                      
                      <tr>
                        <td class="red"><div>Departmental</div>address:</div></td>
                        <td colspan="2">
                          <textarea name="contact" rows=3 cols=50></textarea>
                          [% errs.error_contact %]
                        </td>
                      </tr>
                      
                      <tr>
                        <td class="red">Telephone:</td>
                        <td colspan="2">
                          <input type="text" name="tel" />
                          [% errs.error_tel %]
                        </td>
                      </tr>
                      
                      <tr>
                        <td class="red">E-mail:</td>
                        <td>
                          <input type="text" name="email"  />
                          [% errs.error_email %]
                        </td>
                        <td class="right">
                          &nbsp;re-type e-mail for validation:
                          <input type="text" name="email2"  />
                          [% errs.error_email2 %]
                        </td>
                      </tr>
                    </table>
                    
                    <p class="hr"></p>
                  </div>
                  [% UNLESS send_success # already submitted %]
                  <p class="center">
                    <input type="submit" name="register" value="Submit Registration" />
                    <input type="reset" value="Reset All Values" />
                  </p>
                  [% END %]
                </form>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </div>
</body>
</html>