<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:tal="http://xml.zope.org/namespaces/tal"
    xmlns:metal="http://xml.zope.org/namespaces/metal"
    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
    metal:use-macro="here/main_template/macros/master"
    i18n:domain="senaite.core">
  <head>
    <title></title>
    <metal:block fill-slot="javascript_head_slot"
                 tal:define="portal context/@@plone_portal_state/portal;">

      <!-- TODO move to senaite.lims bootstrap css -->
      <style type="text/css">
       #remarks-widget {
         padding-top: 2em;
       }
       #archetypes-fieldname-Remarks {
         padding: 0!important;
       }
       #remarks-widget fieldset legend {
         display: none;
       }
       #remarks-widget input.saveRemarks {
         margin-top: 1em;
       }
      </style>
    </metal:block>
  </head>

<body>

<metal:content-title fill-slot="content-title">
    <h1>
        <img tal:condition="view/icon | nothing"
            src="" tal:attributes="src view/icon"/>
        <span class="documentFirstHeading" tal:content="context/id"></span>
        <span class="barcode" tal:attributes="value context/id"></span>
        <img tal:condition="python:context.getSample().getSampleType().getHazardous()"
            title="Hazardous"
            i18n:attributes="value"
            tal:attributes="src string:${view/portal_url}/++resource++bika.lims.images/hazardous_big.png"/>
        <img tal:condition="python:context.getInvoiceExclude()"
            title="Exclude from invoice"
            i18n:attributes="value"
            tal:attributes="src string:${view/portal_url}/++resource++bika.lims.images/invoice_exclude_big.png"/>
        <img tal:condition="python:hasattr(context, 'getChildAnalysisRequest') and context.getChildAnalysisRequest()"
            title="Results have been withdrawn"
            i18n:attributes="value"
            tal:attributes="src string:${view/portal_url}/++resource++bika.lims.images/delete_big.png"/>
    </h1>
</metal:content-title>

<metal:content-description fill-slot="content-description">
</metal:content-description>

  <metal:content-core
      fill-slot="content-core"
      tal:define="portal context/@@plone_portal_state/portal;
                  specification python:request.get('specification', view.getDefaultSpec());
                  sample here/getSample;
                  colspan python:10;">

    <input type="hidden" id="bika_setup"
           tal:attributes="bika_samplepoints python: context.bika_setup.bika_samplepoints.UID()"/>

    <!-- Header Table -->
    <span tal:replace="structure view/header_table"/>

    <div tal:define="cfields python:view.get_custom_fields()"
         tal:condition="python: cfields">
        <tal:customfields repeat="cfield python:cfields.keys()">
            <span tal:replace="structure python:cfields[cfield]['title']"/>&nbsp;
            <span tal:replace="structure python:cfields[cfield]['value']"/>
        </tal:customfields>
    </div>

    <!-- Refactored Remarks Widget
         https://github.com/senaite/senaite.core/pull/920 -->
    <div id="remarks-widget" tal:define="checkPermission nocall: context/portal_membership/checkPermission;
                                     mode python:'edit' if checkPermission('Modify portal content', context) else 'view';
                                     field python:context.Schema()['Remarks'];
                                     errors python:{};">
        <h3>
          <img i18n:attributes="title" title="Remarks" src="++resource++bika.lims.images/remarks.png"/>
          <span i18n:translate="">Remarks</span>
        </h3>
        <div class="well">
          <metal:widget use-macro="python:context.widget('Remarks', mode=mode)"/>
        </div>
    </div>

    <h3 style="margin-top:2em;"
        tal:condition="python:context.bika_setup.getShowPartitions()">
        <img
            i18n:attributes="title"
            title="Partitions"
            src="++resource++bika.lims.images/samplepartition.png"/>
        <span i18n:translate="">Sample Partitions</span>
    </h3>
    <tal:parts
        tal:condition="python:context.bika_setup.getShowPartitions()"
        replace="structure view/parts"/>

    <form
        id="analysisrequest_edit_form"
        name="analysisrequest_edit_form"
        action="workflow_action"
        method="POST"
        enctype="multipart/form-data">

        <h3 style="margin-top:1em;">
        <tal:profile tal:condition="view/getAnalysisProfileTitle">
            <img title="profile"
                tal:attributes="src string:${view/portal_url}/++resource++bika.lims.images/analysisprofile.png">
            <span i18n:translate="">Profile</span>:
            <span tal:content="view/getAnalysisProfileTitle"/>
        </tal:profile>
        </h3>
        <br/>

        <tal:tables tal:repeat="table python:view.tables.items()">
            <h3 style="margin-top:1em;">
                <img title="analyses"
                    tal:attributes="src string:${view/portal_url}/++resource++bika.lims.images/analysisservice.png">
                <span tal:content="python: table[0]"/>
            </h3>
            <span tal:replace="structure python: table[1]"/>
        </tal:tables>
        <br/>

        <!-- QC Analyses table -->
        <h3 style="margin-top:1em;">
            <img title="QC Analyses"
                 tal:attributes="src string:${view/portal_url}/++resource++bika.lims.images/referencesample.png">
            <span i18n:translate="">QC Analyses</span>
        </h3>
        <tal:parts replace="structure view/qctable"/>

    </form>

    <!-- Results interpretation -->
    <h3 style="margin-top:1em;">
        <img title="Results interpretation"
             tal:attributes="src string:${view/portal_url}/++resource++bika.lims.images/referencesample.png">
        <span i18n:translate="">Results interpretation</span>
    </h3>
    <tal:parts replace="structure view/riview"/>

  </metal:content-core>
</body>
</html>
