<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:meta="http://xml.zope.org/namespaces/meta"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      i18n:domain="euphorie"
      meta:interpolation="true"
      tal:omit-tag="">

  <p i18n:translate="intro_add_surveygroup">This form will allow you to create a new OiRA Tool.</p>

  <form class="concise" action="${request/getURL}" method="${view/method}" enctype="${view/enctype}"
        tal:define="countries view/buildSurveyTree">
    <fieldset>
      <tal:widget replace="structure view/widgets/title/render" />

      <fieldset class="comprehensive radioList" tal:define="value python:request.form.get('source', 'scratch')">
        <legend i18n:translate="label_survey_source">How would you like to start</legend>
        <dfn class="infoPanel" i18n:attributes="title" title="Information" i18n:translate="help_survey_source">
            By copying an existing OiRA tool you also inherit its evaluation algorithm
        </dfn>
        <label><input type="radio" name="source" value="scratch" checked="${python:'checked' if value=='scratch' else None}" /> <tal:span i18n:translate="survey_source_scratch">Create a new OiRA Tool from scratch</tal:span></label>
        <label tal:condition="view/my_group"><input type="radio" name="source" value="local" checked="${python:'checked' if value=='local' else None}"/> <tal:span i18n:translate="survey_source_local">Base my new OiRA Tool on an existing OiRA Tool of my organisation</tal:span></label>
        <label><input type="radio" name="source" value="other" checked="${python:'checked' if value=='other' else None}"/> <tal:span i18n:translate="survey_source_other">Base my new OiRA Tool on an existing OiRA Tool of another organisation</tal:span></label>
      </fieldset>

      <tal:countries repeat="country countries">
        <tal:mycountry condition="python:country['id']==view.my_country">
          <tal:sectors repeat="sector country/sectors">
            <tal:mysector condition="python:sector['id']==view.my_sector">
              <label class="dependsOn-source-equals-local"><tal:span i18n:translate="label_choose_surveygroup">Choose an OiRA Tool</tal:span>
                <select tal:define="value python:request.form.get('surveygroup.local')" name="surveygroup.local">
                  <tal:group repeat="group sector/groups">
                    <option value="${group/id}" selected="${python:'selected' if value==group['id'] else None}">${group/title}</option>
                  </tal:group>
                </select>
              </label>
              <tal:group repeat="group sector/groups">
                <fieldset class="comprehensive radioList dependsOn-source-equals-local dependsOn-surveygroup.local-equals-${group/id}" tal:define="value python:request.form.get('survey.local', group['surveys'][0]['id'])">
                  <legend i18n:translate="label_choose_survey">Choose a revision of the selected OiRA Tool</legend>
                  <label tal:repeat="survey group/surveys"><input type="radio" name="survey.local.${group/id}" value="${survey/id}" checked="${python:'checked' if repeat.survey.start else None}"/>${survey/title} <a href="${survey/url}" class="floatAfter">View</a></label>
                </fieldset>
              </tal:group>
            </tal:mysector>
          </tal:sectors>
        </tal:mycountry>
      </tal:countries>

      <label class="dependsOn-source-equals-other">
        <tal:span i18n:translate="label_choose_country">Choose a country</tal:span>
        <select name="country" id="country" tal:define="value python:request.form.get('country', view.my_country)">
          <option tal:repeat="country countries" value="${country/id}" selected="${python:'selected' if value==country['id'] else None}">${country/title}</option>
        </select>
      </label>

      <tal:country repeat="country countries">
        <label class="dependsOn-source-equals-other dependsOn-country-equals-${country/id}"><tal:span i18n:translate="label_choose_surveygroup">Choose an OiRA Tool</tal:span>
          <select tal:define="name string:sector.${country/id};
                              value python:request.form.get(name, '%s.%s' % (view.my_sector, view.my_group));"
            name="${name}">
            <tal:sector repeat="sector country/sectors">
              <optgroup label="${sector/title}">
                <tal:group repeat="group sector/groups">
                  <option tal:define="ovalue string:${sector/id}.${group/id}" value="${ovalue}"
                    selected="${python:'selected' if value==ovalue else None}">${group/title}</option>
                </tal:group>
              </optgroup>
            </tal:sector>
          </select>
        </label>

        <tal:sector repeat="sector country/sectors">
          <tal:group repeat="group sector/groups">
            <fieldset class="comprehensive radioList dependsOn-source-equals-other dependsOn-country-equals-${country/id} dependsOn-sector.${country/id}-equals-${sector/id}.${group/id}"
              tal:define="name string:survey.${country/id}.${group/id}; value python:request.form.get(name, group['surveys'][0]['id'])">
              <legend i18n:translate="label_choose_survey">Choose a revision of the selected OiRA Tool</legend>
              <label tal:repeat="survey group/surveys"><input type="radio" name="${name}" value="${survey/id}" checked="{python:'checked if repeat.survey.start else None'}" />${survey/title} <a href="${survey/url}" class="floatAfter">View</a></label>
            </fieldset>
          </tal:group>
        </tal:sector>
      </tal:country>

    <fieldset class="dependsOn-source-equals-scratch comprehensive radioList" tal:define="widget nocall:view/widgets/evaluation_algorithm">
    <legend>${widget/label} <sup tal:condition="widget/required" class="required">*</sup></legend>
        <dfn class="infoPanel" title="Information" i18n:translate="help_survey_evaluation_algorithm_standard" i18n:attributes="title">
        This method involves risk assessment by Severity x Exposure x Probability, whereas these have to be understood as follows; Severity of injury linked to hazard - Exposure (Frequency) to the hazard - Probability of the hazard occuring when exposed
        </dfn>
        <label><input type="radio" name="${widget/name}:list" value="kinney"
        checked="${python:'checked' if 'kinney' in widget.value else None}"/><tal:i18n
        i18n:translate="algorithm_kinney">Standard three criteria</tal:i18n><br/>
        <span class="discrete" i18n:translate="">This is the recommended evaluation algorithm, based on the Kinney method</span></label>
        <div class="secondInfoPanel">
        <dfn class="infoPanel" title="Information" i18n:translate="help_survey_evaluation_algorithm_simplified" i18n:attributes="title">
        This method involves risk assessment by Severity x Exposure, whereas these have to be understood as follows; Severity of injury linked to hazard - Exposure (Frequency) to the hazard
        </dfn>
        </div>
        <label>
        <input type="radio" name="${widget/name}:list" value="french"
        checked="${python:'checked' if 'french' in widget.value else None}"/><tal:i18n
        i18n:translate="algorithm_french">Simplified two criteria</tal:i18n><br/>
        <span class="discrete" i18n:translate="">This is a simpler evaluation algorithm using only two criteria.</span></label>
        <tal:error condition="widget/error" replace="structure widget/error/render|nothing"/>
    <input type="hidden" value="1" name="${widget/name}-empty-marker" />
    </fieldset>
</fieldset>

    <div class="buttonBar">
      <button name="form.buttons.save" type="submit" i18n:translate="button_create">Create</button>
      <button name="form.buttons.cancel" type="submit" i18n:translate="button_cancel">Cancel</button>
    </div>
  </form>
</html>
