<?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" />
  <style>
    .itemhidden, #itemhidden, .viewHide  {
        display: none
    }
    .itemshown {
        display: inline
    }
    .details {
        color: #00f;
    }
    #send-details {
        margin-left: 2em;
        padding: 2px 10px;
        background-color: #ffebcd;
    }
	.highlight {
	  background-color: #ffebcd;
	}
  </style>
  <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>
    <script type="text/javascript" src="/js/common.js"></script>
</head>
<body>
  [% # PROCESS dumper.tt dump = vars %]
  [% # PROCESS dumper.tt dump = errs %]
  [% # PROCESS dumper.tt dump =  settings %]
  <div>
    <p>
      <a name="top">
        <img src="/images/[% settings.logo_image %]" title="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 [% settings.lab_name_abbreviation %]</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 [% settings.item('_centre').upper %]
                    [% settings.lab_name_abbreviation %] HILIS Registration</h2>

                <!-- // returns user to login page, not here
                <p class="indent details">I already have a login but have forgotten
                    my details:
                  [% div_name = 'detail'; INCLUDE site/snippets/toggleview.tt %]
                </p>
                <div id="[% div_name %]" class="itemhidden">
                    <div id="send-details">
                        <form method="post" action="[% app_url %]/user/password_change"
                            name="forgotten_pwd" id="forgotten_pwd">
                            <p class="title">
                                Enter your email address:
                                <input type="text" id="email_address" name="email_address"
                                    size="40" value="[% email_address %]" />
                                <input type="hidden" name="access_token"
                                    value="[% c.query.param('access_token') %]" />
                                [% site.html.submit %]
                            </p>
                            <p>
                            [% UNLESS email_address %]
                                Your password will be reset and a new one e-mailed to you.
                            [% END %]
                            </p>
                        </form>
                    </div>
                </div>
                -->

                [% UNLESS addr_in_use %]
                    <p class="info">** if you already have an account and have forgotten
                        your details please go to the <a href="[% settings.service_url %]">
						login page</a></a> and use the 'forgotten password/inactive account' link **
                    </p>
                [% END %]

                <p>I do not already have a HILIS account:
                    [% div_name = 'detail'; INCLUDE site/snippets/toggleview.tt %]
                </p>

                [% class = vars.size ? 'itemshow' : 'itemhidden' # vars is common return %]
                <div id="[% div_name %]" class="[% class %]">
                  [% 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">
                        <input type="hidden" name="service" [%# optional - non-LTH only %] />
                      <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('(?i)^(admin|visitor|system|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>

                          [% IF addr_in_use %]
							<tr>
							  <td class="info highlight" colspan="3">
								<div class="indent">Email address is already registered.
								If you have forgotten your account details</div>
								<div class="indent">please go to the
								<a href="[% settings.service_url %]">login
								page</a></a> and use the 'forgotten password/inactive
								account' link</div>
							  </td>
							</tr>
						  [% END %]

                          <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>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </div>
</body>
</html>
