<!--
    Default template used to render one barcode big sticker

    To retrieve the item, use view.current_item, that will return an array with
    the following structure:

    [analysis_request_object, sample_object, sample_partition_object]

    Although sample_object (position 1 in the array) will never be None,
    analysis_request_object can be None when
    a) The user requested to render stickers for samples (instead of ARs) or
    b) The user requested to render stickers for sample partitions or
    c) The user requested to render stickers for reference samples.

    If c), both analysis_request_object and sample_partition_object will be None
-->
<tal:sticker define="
    portal_state      context/@@plone_portal_state;
    portal_url        portal_state/portal_url;
    show_partitions   python:context.bika_setup.getShowPartitions();
    item              view/current_item;
    ar                python:item[0];
    ar_id             python:ar.getId() if ar else '';
    sample            python:item[1];
    part              python:item[2];
    partnr            python:part.getId().split('-')[1];
    sample            python:part.aq_parent;
    CSID              python:sample.getClientSampleID();
    Order             python:sample.getAnalysisRequests()[0].getClientOrderNumber();
    Hazardous         python:sample.getSampleType().getHazardous();
    SampleType        python:sample.getSampleType().Title();
    Sampler           python:sample.getSampler();
    SampleType        python:sample.getSampleType().Title();
    SamplePoint       python:sample.getSamplePoint() and sample.getSamplePoint().Title() or '';
    Preservation      python:part.getPreservation() and part.getPreservation().Title() or '';
    Container         python:part.getContainer() and part.getContainer().Title() or '';
    sd                python:sample.getSamplingDate();
    SamplingDate      python:sd.Date() if sd else '';
    Deviation         python:sample.getSamplingDeviation() and sample.getSamplingDeviation().Title() or '';
    DateSampled       python:sample.getDateSampled().Date() if sample.getDateSampled() else '';
    Composite         python:sample.getComposite();
    AdHoc             python:sample.getAdHoc();
    analyses          python:part.getAnalyses();
    field_analyses    python:[analysis for analysis in analyses if analysis.getPointOfCapture()=='field'];
    smart_id          python:part.getId() if show_partitions else sample.getId();
    hazardous         python:sample.getSampleType().getHazardous();">


    <table cellpadding="0" cellspacing="0" class="info-container">
        <thead>
            <tr>
                <th i18n:translate="">Sample ID</th>
                <td><strong tal:content="string:${smart_id}"/></td>
                <th i18n:translate="">Hazardous</th>
                <td tal:content="Hazardous"/>
            </tr>
            <tr>
                <th i18n:translate="">Date Sampled</th>
                <td tal:content="DateSampled"/>
                <th i18n:translate="">Sampler</th>
                <td tal:content="Sampler"/>
            </tr>
            <tr>
                <th i18n:translate="">CSID</th>
                <td tal:content="CSID"/>
                <th i18n:translate="">Order</th>
                <td tal:content="Order"/>
            </tr>
            <tr>
                <th i18n:translate="">Deviation</th>
                <td tal:content="Deviation"/>
                <th i18n:translate="">Composite</th>
                <td class="left" tal:content="Composite"/>
            </tr>
            <tr>
                <th i18n:translate="">Container</th>
                <td tal:content="Container"/>
                <th i18n:translate="">Preservation</th>
                <td tal:content="Preservation"/>
            </tr>
            <tr>
                <th i18n:translate="">Sample Type</th>
                <td colspan='3' tal:content="SampleType"/>
            </tr>
            <tr>
                <th i18n:translate="">Sample Point</th>
                <td colspan='3' tal:content="SamplePoint"/>
            </tr>
            <tr tal:condition="python:field_analyses">
                <th colspan="4" i18n:translate="">Field Analyses</th>
            </tr>
            <tal:block repeat="analysis python:field_analyses">
            <tr>
                <td colspan="4" tal:content="python:analysis.Title()"/>
            </tr>
            </tal:block>
            <tr>
                <td colspan="4" class='barcode-container'>
                    <!-- Barcode -->
                    <div class="barcode"
                        tal:attributes="data-id smart_id;"
                        data-barHeight="12"
                        data-code="code128"
                        data-addQuietZone="true"
                        data-showHRI="false">
                    </div>
                </td>
            </tr>
        </thead>
    </table>
</tal:sticker>
