<tal:define
    i18n:domain="senaite.core"
	define="
		portal_state context/@@plone_portal_state;
		currencies python:modules['zope.i18n.locales'].locales.getLocale('en').numbers.currencies;
		currency python:context.bika_setup.getCurrency();
		categoryUID python:view.request['categoryUID'];
		poc python:view.request['poc'];
		ar_count python:int(view.request.get('ar_count', 1));
		portal context/@@plone_portal_state/portal;
        ShowPrices python:context.bika_setup.getShowPrices();">
	<tr tal:repeat="service python:view.Services(poc, categoryUID)"
		tal:attributes="id service/UID">
        <tal:service tal:define="service_obj python:service.getObject()">
		<td style="text-align:left">
			<span
				class="service_title"
				tal:attributes="uid service/UID"
				tal:content="service/title"/>
			<em
				class="discreet"
				style="white-space:nowrap;"
				tal:condition="python:service_obj.getUnit()">(<span tal:replace="python:service_obj.getUnit()">mg/l</span>)</em>
			<img
				tal:condition="python:context.bika_setup.laboratory.getLaboratoryAccredited() and service_obj.getAccredited()"
				tal:attributes="src string:${view/portal_url}/++resource++bika.lims.images/accredited.png"/>
		</td>
        <td tal:condition="python:context.portal_type == 'Client' and ShowPrices"
            style="white-space:nowrap;"
            tal:define="analysis python: hasattr(here, service.id) and here[service.id] or None;
                vat python:service_obj.getVAT()">
            <span tal:replace="python:currencies[currency].symbol"/>
            <input
                tal:condition="python: not view.bulk_discount_applies()"
                class="price numeric"
                type="text"
                size="5"
                tal:attributes="
                    value python: analysis and analysis.getPrice() or service_obj.getPrice();
                    id string:${service/UID}_price;
                    name string:Prices.${service/UID}:record;
                    vat_amount vat"/>
            <input
                tal:condition="python: view.bulk_discount_applies()"
                class="price numeric"
                type="text"
                size="5"
                tal:attributes="
                    value python: analysis and analysis.getPrice() or service_obj.getBulkPrice();
                    id string:${service/UID}_price;
                    name string:Prices.${service/UID}:record;
                    vat_amount vat"/>
            <input
                type="hidden"
                tal:attributes="
                    value vat;
                    id string:${service/UID}_vat;
                    name string:VAT.${service/UID}:record;"/>
        </td>
        <td tal:condition="python:context.portal_type != 'Client' and ShowPrices"
            style="white-space:nowrap;"
            tal:define="analysis python: hasattr(here, service.id) and here[service.id] or None;
                vat python:service_obj.getVAT()">
            <span tal:replace="python:currencies[currency].symbol"/>
            <span tal:replace="python: analysis and analysis.getPrice() or service_obj.getPrice()"/>
            <input
                type="hidden"
                class="price numeric"
                tal:attributes="
                    value python: analysis and analysis.getPrice() or service_obj.getPrice();
                    id string:${service/UID}_price;
                    name string:Prices.${service/UID}:record;
                    vat_amount vat"/>
            <input
                type="hidden"
                tal:attributes="
                    value vat;
                    id string:${service/UID}_vat;
                    name string:VAT.${service/UID}:record;"/>
        </td>
		<td class="service" tal:attributes="colspan python:'1' if ShowPrices else '2';">
			<image
				class="copyButton"
				tal:condition="python:ar_count > 1"
				tal:attributes="
					id string:${service/UID};
                    name string:${service/Title};
					src string:${view/portal_url}/++resource++bika.lims.images/copy.png"/>
		</td>
		<tal:i define="serviceUID service/UID;serviceTitle service/title">
			<tal:i repeat="column python:range(int(view.request['ar_count']))">
				<td class='service'
					tal:define="
						disable python:int(view.request.get('disable', '-1'));
						input_id service/UID;
						input_name string:ar.${column}.Analyses:list:ignore_empty:record;
						selected python:view.request['column'] != '' and column == int(view.request['column']) and view.request['selectedservices'] or '';">
					<input
						tal:condition="python: disable > -1 and disable == column"
						disabled="disabled"
						class="cb"
						type="checkbox"
						tal:attributes="
							id input_id;
							column column;
							name input_name;
							value serviceUID;
							title serviceTitle;
                            has_resultoptions python:len(service_obj.getResultOptions()) > 0;
                            keyword python:service_obj.getKeyword();
							checked python:(selected.find(serviceUID)>-1 or request.get(input_name, [])) and 'checked' or None"/>
					<input
						tal:condition="python: disable != column"
						class="cb"
						type="checkbox"
						tal:attributes="
							id input_id;
							column column;
							name input_name;
							value serviceUID;
							title serviceTitle;
                            has_resultoptions python:len(service_obj.getResultOptions()) > 0;
                            keyword python:service_obj.getKeyword();
							checked python:(selected.find(serviceUID)>-1 or request.get(input_name, [])) and 'checked' or None"/>
					<em class="discreet"
                        tal:attributes="
                            class python:'partnr_'+serviceUID;
                            column column;
                            style python:'' if context.bika_setup.getShowPartitions() else 'display:none';"/>
				</td>
			</tal:i>
		</tal:i>
	    </tal:service>
	</tr>
</tal:define>
