{# 
// sheepdata.tmpl
//
// The Jinja2 template for the Sheep Data page
//
// Copyright PR Hardman 2009 - 2023. 
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details./
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//
#}
{% extends "templates/base.tmpl" %}
{% from "templates/sheepmacros.tmpl" import sheeprcode with context %}
{% from "templates/sheepmacros.tmpl" import sheepbody_left with context %}
{% from "templates/sheepmacros.tmpl" import sheepbody_right with context %}
{% from "templates/sheepmacros.tmpl" import findctls with context %}
{% from "templates/sheepmacros.tmpl" import colours_and_markings_dialogs with context %}
{% from "templates/sheepmacros.tmpl" import transfer_dialog with context %}
{% from "templates/sheepmacros.tmpl" import pedcert_new_dialog with context %}
{% from "templates/sheepmacros.tmpl" import flockmult_dialog with context %}
{% block styles %}
{% endblock %}
{% block content %}
  <div id="inner" class="boxed centre">
    <div class="boxed centre">
      <noscript><p class="hilite">This page requires Javascript to function. Please enable Javascript in your browser's preference settings.</p></noscript>
      <span id="uri_root_txt" class="nodisplay">{{uri_root}}</span>
      <span id="has_progeny" class="nodisplay">{{has_progeny}}</span>
      <span id="dlg_msg" class="nodisplay">{{dlg_msg}}</span>
      <span id="page_title" >Data for {{pagetitle|e}}</span>
      <div id="input_block">
        <input id="regn_no" class="nodisplay" name="regn_no" value="{{regn_no}}"> 
        <input id="regn_flk_no" class="nodisplay" name="regn_flock" value="{{registering_flock}}">
        <input id="org_flk_no" class="nodisplay" name="org_flock" value="{{originating_flock}}">
        <input id="owning_flk_no" class="nodisplay" name="owning_flock" value="{{curr_flock_no}}">
        <input id="owning_flk_name" class="nodisplay" value="{{curr_flock_name}}">
        <input id="curr_pfx" class="nodisplay" name="curr_prefix" value="{{tag_prefix}}">
        <input id="sire_no" name="sire_no" type="hidden" value="{{sire_no}}">
        <input id="dam_no" name="dam_no" type="hidden" value="{{dam_no}}">
        <div class="prefix_insp">
          <label class="prefix_label">Tag Prefix: </label>
          <div>
            <select id="prefix_list" name="tag_prefix" tabindex="-1" {{allow_retag}} disabled>
                  <option value="{{tag_prefix}}">{{tag_prefix}}</option>    
            </select>
            <span>&nbsp;from:</span>
            <input id="tag_from_currpfx" name="tag_from" value="currpfxflk" type="radio" 
                                      tabindex="-1" checked {{allow_retag}} disabled>
            <span class=" {% if allow_retag == 'disabled' %} grayed"> {% else %} "> {% endif %}
                  Current Prefix</span>
            <span>&nbsp;&nbsp;or:</span>
            <input id="tag_from_owning" name="tag_from" value="owningflk" type="radio" 
                  tabindex="-1" {{allow_retag}} disabled>
            <span class=" {% if allow_retag == 'disabled' %} 
                                grayed"> {% else %} 
                                "> 
                              {% endif %}
                  Owning Flock: </span>
            <span id="owning_flk" >
                  {% if allow_retag != 'disabled' %}
                      ({{curr_flock_no}} - {{curr_flock_name|e}})
                  {% else %}
                      {% if no_prefixes == 'true' %}
                          ({{curr_flock_no}} - {{curr_flock_name|e}} has no assigned prefixes)
                      {% endif %}
                  {% endif %}
            </span>
            <span>&nbsp;&nbsp;or:</span>
            <input id="tag_from_org" name="tag_from" value="orggflk" type="radio" 
                  tabindex="-1" {{allow_retag}} disabled>
            <span class=" {% if allow_retag == 'disabled' %} 
                                grayed"> {% else %} 
                                "> 
                              {% endif %}
                  Originating Flock: </span>
            <span id="originating_flk" >
                  {% if allow_retag != 'disabled' %}
                      ({{originating_flock}} - {{org_flock_name|e}})
                  {% else %}
                      {% if no_prefixes == 'true' %}
                          ({{originating_flock}} - {{org_flock_name|e}} has no assigned prefixes)
                      {% endif %}
                  {% endif %}
            </span>
          </div>
          {{ sheeprcode("ok_msg") }}
        </div>
        <div class="sheepbody"> 
          <div class="sheepbody_left">
            <div class="sheepbody_data">
              {{ sheepbody_left("disabled") }}
            </div>
            <div class="sheepbody_info">
              <span>&nbsp;</span>
              <span>&nbsp;</span>
              <label>Approval Date: </label>
              <span id="approval_date">{{insp_date}}</span>
              {% if 'officer' in logingroups %}
                <label>Genotype: </label>
                <span id="genotype">{{allele_1}}/{{allele_2}}</span>
              {% endif %}
              <label >Breeder: </label>
              <span id="breeder">{{breeder_name}}</span>
              <label >Sheep Status: </label>
              <span id="xfer_status" >{{xfer_text}}</span>
            </div>
          </div>
          <div class="sheepbody_right">
              {{ sheepbody_right("disabled") }}
            <label>Registered on: </label>
            <span id="regd_on">{{registered}}</span></span>
            <label>Last Changed: </label>
            <span id="last_changed" >{{last_changed}}</span> 
          </div>
        </div>
        <div>&nbsp;</div>
        {% if ("regsec" in loginroles) %} 
        <div class="buttons-box">
          <div class="buttons_box boxed">
            <button id="data_changes_btn" tabindex="-1">Show Data Changes</button>
            <button id="tag_changes_btn" tabindex="-1">Show Tag Changes</button>
            <button id="transfer_btn" tabindex="-1">Transfer Sheep</button>
            <button id="pedcert_btn" tabindex="-1">Pedigree Cert</button>
            <button id="tag_swap_btn" tabindex="-1">Swap Tag with...</button>
          </div>
          <div class="buttons_box boxed">
            <button id="edit_btn" tabindex="-1">Change</button>
            <div class="h-pad1"></div> 
            <label id="ignore_label" class="grayed">Ignore Warnings: 
              <input id="ignore_cbox" type="checkbox" name="ignore_warnings" value="ignore" 
                    class="middle" tabindex="0" disabled>
            </label>
            <button id="save_btn" tabindex="-1" disabled>Save</button>
            <button id="reload_btn" tabindex="-1" disabled>Cancel</button>
          </div>
        </div>
        {% endif %}
      </div>
    </div>
    
    <div class="spacer">&nbsp;</div>
    <div class="centre shrink">
      {{ findctls() }}
  </div> {# End of inner div #}
{% endblock %}
{% block dialogs %}
{{ colours_and_markings_dialogs() }}
{{ transfer_dialog() }}
{{ pedcert_new_dialog() }}
{{ flockmult_dialog() }}
<div id="tag_swap_dialog" class="dialog invis">
  <div class="entry_dialog">
      <h2 id="tagswap_dlg_title" class="centre">Tag Swap</h2>
      <div class="dlg_grid">
        <label>Sheep to swap tag with:</label>
        <div>
          <input type="text" id="tag_swap_with" size="18" maxlength="32">
        </div>
        
        <label>Requested By:</label>
        <div>
          <input class="left" type="text" id="tag_swap_breeder" size="10" maxlength="10">
          {{ toggletip("", "swap_brdr", "", "Enter the name or flock no of the breeder 
              requesting the swap, or 'SSS' if correcting a data entry error") }} 
        </div>
      </div>
      <div id="tag_swap_msg" class="invis">&nbsp;</div>
      <div class="spacer">&nbsp;</div>
    <div class="buttons_box">
      <button id="tag_swap_submit">Swap Tags</button>
      <button id="tag_swap_cancel">Cancel</button>
    </div>
  </div>
</div> 

{% endblock %}
{%block scripts %}
<script type="module" src="{{uri_root}}/static/js/sheepdata.js"></script>
{% endblock %}
