<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<metal:block use-macro="context/global_defines/macros/defines" />

<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"
      tal:attributes="lang default_language|default;
                      xml:lang default_language|default;"
      i18n:domain="senaite.core"
      tal:define="portal_state context/@@plone_portal_state;
                  portal_url portal_state/portal_url;
                  plone_view context/@@plone;
                  portal portal_state/portal;">
<head>
    <div tal:replace="structure provider:plone.resourceregistries.scripts" />
</head>
<body class="A4" data-layout="A4">
    <div id='ar_publish_container'>
        <div id="ar_publish_header" tal:condition="python:view.showOptions()">
            <div id='options_handler'>
                <div class='options-line'>
                    <label for="sel_format" i18n:translate="">Template</label>
                    <select id="sel_format" name="sel_format">
                        <tal:formats tal:repeat="format python:view.getAvailableFormats()">
                            <tal:format define="current python:request.get('template', view._DEFAULT_TEMPLATE);">
                            <option selected
                                    tal:attributes="value python:format['id']"
                                    tal:content="python:format['title']"
                                    tal:condition="python:format['id']==current"></option>
                            <option tal:attributes="value python:format['id']"
                                    tal:content="python:format['title']"
                                    tal:condition="python:format['id']!=current"></option>
                            </tal:format>
                        </tal:formats>
                    </select>
                    <a href='#' id='sel_format_info'><img tal:attributes='src python:portal.absolute_url()+"/++resource++bika.lims.images/info.png";'/></a>
                    &nbsp;&nbsp;&nbsp;
                    <label for="sel_layout" i18n:translate="">Layout</label>
                    <select id="sel_layout" name="sel_layout">
                        <option value="A4" selected>DIN-A4 (210 x 297 mm)</option>
                        <option value="letter">Letter size (216 x 279mm)</option>
                    </select>
                </div>
                <div class='options-line'>
                    <label i18n:translate="">Margins (mm)</label>
                    top: <input class='option-margin' id="margin-top" type="text"/>&nbsp;
                    right: <input class='option-margin' id="margin-right" type="text"/>&nbsp;
                    bottom: <input class='option-margin' id="margin-bottom" type="text"/>&nbsp;
                    left: <input class='option-margin' id="margin-left" type="text"/>
                </div>
                <div class='options-line'>
                    <input type="checkbox" name="landscape" id='landscape' value="0"><span i18n:translate="">Landscape</span><br/>
                    <input type="checkbox" name="qcvisible" id='qcvisible' value="0"><span i18n:translate="">Show QC Analyses</span><br/>
                    <input type="checkbox" name="hvisible" id='hvisible' value="0"><span i18n:translate="">Show Hidden Analyses</span>
                </div>
            </div>
            <div id="sel_format_info_pane" style="display:none">
                <p i18n:translate="">Refer to <a target="_blank" href="https://github.com/bikalabs/Bika-LIMS/wiki/Creating-new-report-templates">Creating new report templates</a> documentation from Bika LIMS wiki to get more or add your own report templates.</p>
            </div>
            <div id='ar_publish_summary'>
                <span tal:content="python:view.getAnalysisRequestsCount()"></span>&nbsp;
                <span i18n:translate=""> analysis requests selected</span>:&nbsp;
                <tal:ars repeat="ar python:view.getAnalysisRequests()">
                    <a tal:attributes="href python:'#'+ar.id" tal:content="python: ar.id"></a>&nbsp;
                </tal:ars>
            </div>
            <div id='ar_publish_buttons'>
                <input type="button" id='cancel_button' value="Cancel"/>&nbsp;&nbsp;
                <input type="button" id='publish_button' value="Publish"/>
            </div>
        </div>
        <style id='report-base-style'>
            /** Report preview styling **/
            html, body { margin: 0; }
            html { background-color:#cdcdcd; }
            body.A4 #ar_publish_container { width: 210mm; }
            body.A4.landscape #ar_publish_container { width: 297mm; }
            body.letter #ar_publish_container { width: 216mm; }
            body.letter.landscape #ar_publish_container { width: 279mm; }
            #report {
                background-color:#ffffff;
            }
            div.ar_publish_page {
                border: 1px dashed #cdcdcd;
            }
            #ar_publish_container {
                margin:0 auto;
                background-color:#fff;
                padding:30px;
            }
            #ar_publish_header {
                margin:-30px -30px 30px -30px;
                padding:10px 20px 20px 10px;
                background-color: #dcdcdc;
                border-bottom: 20px solid #CDCDCD;
                font-size:11px;
            }
            #ar_publish_header * {
                font-family: Arial !important;
                font-size:11.5px !important;
            }
            #ar_publish_header #options_handler label {
                padding:5px 10px 5px 10px;
            }
            #ar_publish_header #options_handler input {
                padding:5px 10px 0px;
            }
            #ar_publish_header #ar_publish_summary {
                padding-left:10px;
                padding-top:10px;
            }
            #ar_publish_header #ar_publish_buttons {
                text-align:right;
                padding-left:10px;
                padding-top:10px;
            }
            #ar_publish_header #ar_publish_buttons input {
                padding:4px 15px;
                border:none;
                color:#fff;
                font-size:1.2em;
                cursor:pointer;
            }
            #ar_publish_header #ar_publish_buttons input:hover {
                opacity:0.8;
                moz-opacity:0.8;
                filter:alpha(opacity=80);
                -webkit-transition: opacity 250ms ease-in-out;
                -moz-transition: opacity 250ms ease-in-out;
                -o-transition: opacity 250ms ease-in-out;
                -ms-transition: opacity 250ms ease-in-out;
                transition: opacity 250ms ease-in-out;
            }
            #ar_publish_header #ar_publish_buttons #cancel_button {
                background-color:#666;
            }
            #ar_publish_header #ar_publish_buttons #publish_button {
                background-color:#0B486B;
            }
            #ar_publish_header #options_handler div.options-line {
                padding:0 0 10px 0;
            }
            #ar_publish_header #options_handler input.option-margin {
                border: 1px solid #bbb;
                padding: 1px 2px;
                width: 16px;
            }
            #sel_format_info {
                padding: 0 15px 0 5px;
                outline:0;
            }
            #sel_format_info img {
                vertical-align:middle;
            }
            #sel_format_info_pane {
                background-color: #EFEFEF;
                border-top: 1px solid #008000;
                line-height: 1.5em;
                margin: 10px -20px 10px -10px;
                padding: 10px 20px;
            }
            .page-break {
                background-color: #cdcdcd;
                height: 20px;
                margin: 0mm -30mm;
            }
            .clearfix {
                clear:both !important;
                margin:0 !important;
                padding:0 !important;
                height:0 !important;
            }
            .page-footer.footer-invalid,
            .page-header.header-invalid {
                border: 1px dotted red;
                color: red;
                padding: 5px;
            }
            .barcode-hri {
                clear:both;
                width: 100%;
                background-color: #FFFFFF;
                color: #000000;
                text-align: center;
                font-size: 10px;
            }
        </style>
        <style id='report-style' tal:content='structure python:view.getReportStyle()'></style>
        <style id='layout-style'></style>
        <style id='layout-print'>
            @media print {
                a {
                    text-decoration:none;
                    color:#000;
                }
                div.ar_publish_page {
                    border: none;
                }
                html {
                    background-color:#fff !important;
                    margin:0 !important;
                    padding:0 !important;
                }
                body {
                    padding:0 !important;
                    margin:0 !important;
                }
                .page-break, .page-break-after, .page-break-before {
                    display: block !important;
                    border:none !important;
                    padding:0 !important;
                    margin:0 !important;
                    background-color:transparent !important;
                }
                div.page-break {
                    page-break-after: always;
                }
                div.page-break-after {
                    page-break-after: always;
                }
                div.page-break-before {
                    page-break-before: always;
                }
                .page-footer {
                    margin:0 !important;
                    border:none !important;
                    background-color:#ffffff;
                }
                #ar_publish_header {
                    display:none;
                    visibility:hidden;
                }
                .page-footer.footer-invalid,
                .page-header.header-invalid {
                    display:none;
                }
            }
        </style>

        <div id='report'>

        <tal:singlearreport condition="python:view.isSingleARTemplate()">
        <!-- Single-AR template.
          The templates from this type will render one AR at a time, so one
          report per AR will be generated.
        -->
        <tal:ar tal:repeat="i python:range(view.getAnalysisRequestsCount())">
        <div tal:attributes="id python:view.getAnalysisRequestObj().id;
                            uid python:view.getAnalysisRequestObj().UID();
                            class python:('ar_publish_body singlear %s' % ('ar-invalid' if hasattr(view.getAnalysisRequestObj(),'isInvalid') and view.getAnalysisRequestObj().isInvalid() else ('ar-provisional' if view.getAnalysisRequest()['prepublish']==True else '')))"
            tal:content='structure python:view.getReportTemplate()'></div>
        </tal:ar>
        </tal:singlearreport>

        <tal:multiarreport condition="python:not view.isSingleARTemplate()">
        <!--
          Multi-AR template. ARs grouped by client.
          The templates from this type must be able to render multiples ARs, so
          each report will contain a bunch of ARs from the same client
        -->
        <tal:argroup repeat="i python:range(view.getGroupedAnalysisRequestsCount())">
        <tal:multiar define="ids python:':'.join([ar.id for ar in view.getAnalysisRequestGroup()]);
                            uids python:':'.join([ar.UID() for ar in view.getAnalysisRequestGroup()]);
                            inv  python:len([hasattr(ar,'isInvalid') and ar.isInvalid() for ar in view.getAnalysisRequestGroup() if hasattr(ar,'isInvalid') and ar.isInvalid()]) > 0;">
        <div tal:content="structure python:view.getGroupedReportTemplate()"
             tal:attributes="id ids;
                            uid uids;
                            class python:'ar_publish_body multiar %s' % ('ar-invalid' if inv else '');"></div>
        </tal:multiar>
        </tal:argroup>
        </tal:multiarreport>
        </div>
    </div>
    <div id="my_mm" style="height:1mm;display:none"></div>
</body>
</html>
