<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
        metal:use-macro="here/main_template/macros/master"
        i18n:domain="senaite.core">

<head>
    <metal:block fill-slot="javascript_head_slot"
            tal:define="portal context/@@plone_portal_state/portal;">
        <script type="text/javascript"
                tal:attributes="src python:portal.absolute_url() + '/bika_widgets/datetimewidget.js'"></script>
        <script type="text/javascript"
                tal:attributes="src python:portal.absolute_url() + '/bika_widgets/referencewidget.js'"></script>
        <script type="text/javascript"
                tal:attributes="src python:portal.absolute_url() + '/bika_widgets/rejectionwidget.js'"></script>
        <link rel="stylesheet" type="text/css" media="all" href=""
                tal:attributes="href string:${portal/absolute_url}/bika_widgets/referencewidget.css"/>
    </metal:block>
</head>

<body>

<metal:title fill-slot="content-title">
    <h1>
        <img tal:condition="view/icon | nothing" tal:attributes="src view/icon"/>
        <tal:new i18n:translate="">Request new analyses</tal:new>
    </h1>
</metal:title>

<div metal:fill-slot="content-core"
        tal:define="
                portal                    context/@@plone_portal_state/portal;
        plone_view                context/@@plone;
        portal_state              context/@@plone_portal_state;
        currencies                python:modules['zope.i18n.locales'].locales.getLocale('en').numbers.currencies;
        currency                  python:context.bika_setup.getCurrency();
        checkPermission           nocall: context/portal_membership/checkPermission;
        tabindex                  view/tabindex;
        partitionable             view/partitioned_services;
        prominentfields           python:view.get_fields_with_visibility('prominent', mode='header_table');
        prominentfieldnames       python:[f.getName() for f in prominentfields];
        hiddenprominentfields     python:view.get_fields_with_visibility('hiddenprominent', mode='header_table');
        hiddenprominentfieldnames python:[f.getName() for f in hiddenprominentfields]">

    <form id="analysisrequest_edit_form"
          name="analysisrequest_edit_form"
          method="POST">

        <input type="hidden" name="submitted" value="1"/>
        <span tal:replace="structure context/@@authenticator/authenticator"/>
        <input type="hidden"
               name="came_from" tal:attributes="value view/came_from"/>

    <span id="bika_setup" style="display:none;"
            tal:define="bika_setup python: context.bika_setup;"
            tal:attributes="EnableARSpecs     python: 'true' if bika_setup.getEnableARSpecs() else '';
                    MemberDiscount            python: bika_setup.getMemberDiscount();
                    MemberDiscountApplies     python: view.getMemberDiscountApplies();
                    Currency                  python: bika_setup.getCurrency();
                    ShowPartitions            python: bika_setup.getShowPartitions();
                    ShowPrices                python: bika_setup.getShowPrices();
                    bika_samplepoints_uid     python: bika_setup.bika_samplepoints.UID();
                    bika_artemplates_uid      python: bika_setup.bika_artemplates.UID();
                    bika_analysisprofiles_uid python: bika_setup.bika_analysisprofiles.UID();
                    bika_analysisspecs_uid    python: bika_setup.bika_analysisspecs.UID();
                    samplingwfenabled         python: 'true' if bika_setup.getSamplingWorkflowEnabled() else '';
                    bika_analysisspecs_path   python:'/'.join(bika_setup.bika_analysisspecs.getPhysicalPath())">
    </span>

        <input type="hidden" id="layout" name="layout"
                tal:attributes="value view/layout"/>

        <!-- ar_count goes here for the jquery expanding services rows to know how to print themselves -->
        <input type="hidden" id="ar_count" name="ar_count"
                tal:attributes="value view/ar_count"/>

        <!-- These services have partition setup records -->
        <input type="hidden" id="partitioned_services"
               name="partitioned_services"
                tal:attributes="value partitionable"/>

        <!-- The specs for each AR. -->
        <input type="hidden" id="specs" name="specs" value="{}"
                tal:attributes="value python:modules['json'].dumps(dict([(x, {}) for x in range(view.ar_count)]))"/>

        <!-- The specs for each AR - this value is completed when using copy_to_new in this form.
             The value in this field is blended with the 'Specification' found in the form. -->
        <input type="hidden" id="copy_to_new_specs" name="copy_to_new_specs"
               value="{}"
                tal:attributes="value view/copy_to_new_specs"/>

        <!-- And the current form partition configuration is stored here -->
        <input type="hidden" id="parts" name="parts" value="{}"/>

        <input type="hidden"
               id="PhysicalPath"
                tal:attributes="here python:'/'.join(context.getPhysicalPath()[:-3])"/>

        <!-- Column layout is default: -->
        <tal:cols tal:condition="python: view.layout=='columns'">
            <metal:rows
                    use-macro='view/ar_add_by_col_template/macros/ar_add_by_col'/>
        </tal:cols>

        <!-- Row layout is optional: -->
        <tal:rows tal:condition="python: view.layout=='rows'">
            <metal:rows
                    use-macro='view/ar_add_by_row_template/macros/ar_add_by_row'/>
        </tal:rows>

        <input class="context button allowMultiSubmit"
               type="submit"
               name="save_button"
                i18n:attributes="value"
               value="Save"/>

        <br/>&nbsp;

        <div class="discreeter">

            <!-- XXX this also -->
            <p tal:condition="python:context.bika_setup.laboratory.getLaboratoryAccredited()">
                <img tal:attributes="src string:${portal/absolute_url}/++resource++bika.lims.images/accredited.png">
        <span i18n:translate="">
            Methods included in the
                <tal:block
                        replace="here/bika_setup/laboratory/AccreditationBody"
                        i18n:name="accreditation_body"/>
            schedule of Accreditation for this Laboratory.
            Analysis remarks are not accredited
        </span>
            </p>
        </div>

    </form>
</div>
</body>
</html>
