list.xhtml 6.34 KB
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:composite="http://java.sun.com/jsf/composite"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:tools="http://java.sun.com/jsf/composite/tools">

<composite:interface>
</composite:interface>

<composite:implementation>

	<h:outputText rendered="#{billListView.bills.rowCount le 0}"
		value="#{i18n['bills.noBills']}" />

	<h:form rendered="#{billListView.canWriteBill}">
		<p:commandButton ajax="false"
			action="#{billListView.showPayButtonsAction()}"
			value="#{i18n['bill.showPayButtons']}" />
	</h:form>


	<h:form rendered="#{billListView.bills.rowCount gt 0}" id="billList" styleClass="moya_datatable3">

		<p:dataTable styleClass="bordertable" id="billList"
			value="#{billListView.bills}" var="bill"
			rowStyleClass="#{bill.expired ? 'expired' : (bill.paidDate != null ? 'paid' : null)}"
			expandedRow="true">

			<p:column style="width:16px"
				rendered="#{billListView.bills.rowCount lt 20}">
				<p:rowToggler />
			</p:column>
			<p:column rendered="#{billListView.canWriteBill}">
				<f:facet name="header">
					<h:outputText value="#{i18n['bill.payer']}" />
				</f:facet>
				<h:link rendered="#{billListView.canWriteBill}" outcome="/useradmin/edit" value="#{bill.user.user.login} #{bill.addr1}">
					<f:param name="userid" value="#{bill.user.user.id}" />
				</h:link>
				<h:outputText rendered="#{not billListView.canWriteBill}"
					value="#{bill.addr1}" />
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="${i18n['bill.sentDate']}" />
				</f:facet>
				<h:outputText value="#{bill.sentDateTime}">
					<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}"
						timeZone="#{sessionHandler.timezone}" />
				</h:outputText>
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="${i18n['bill.id']}" />
				</f:facet>
				<h:outputText value="#{bill.id}" />
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="${i18n['bill.billNumber']}" />
				</f:facet>
				<h:outputText value="#{bill.billNumber}" />
			</p:column>
			<p:column rendered="#{billListView.canWriteBill}">
				<f:facet name="header">
					<h:outputText value="${i18n['bill.referencenumber']}" />
				</f:facet>
				<h:outputText value="#{bill.referenceNumberBase}">
					<f:converter binding="#{referenceNumberConverter}" />
				</h:outputText>
			</p:column>
			<!-- 
			<p:column headerText="#{i18n['bill.notes']}" rendered="#{productShopView.gatherBillInfo}">
				<h:outputText value="#{bill.notes}" />
			</p:column>
			 -->
			<p:column>
				<f:facet name="header">
					<h:outputText value="${i18n['bill.totalPrice']}" />
				</f:facet>
				<h:outputText value="#{bill.totalPrice()}">
					<f:convertNumber currencyCode="EUR" maxFractionDigits="2"
						minFractionDigits="2" type="currency"
						locale="#{sessionHandler.locale}" />
				</h:outputText>
			</p:column>
			<p:column>
				<f:facet name="header">
					<h:outputText value="${i18n['bill.vat']}" />
				</f:facet>
				<h:outputText value="#{bill.totalVat()}">
					<f:convertNumber currencyCode="EUR" maxFractionDigits="2"
						minFractionDigits="2" type="currency"
						locale="#{sessionHandler.locale}" />
				</h:outputText>
			</p:column>

			<p:column
				rendered="#{(!bill.expired and sessionHandler.isEventBoolProperty('ALLOW_BILLING')) or billListView.canWriteBill}">
				<ui:fragment>
					<a href="#{request.contextPath}/PrintBill?billid=#{bill.id}"
						target="_blank">#{i18n['bill.printBill']}</a>
				</ui:fragment>
			</p:column>
			<p:column>
				<h:link outcome="/bill/showBill" value="#{i18n['bill.show']}">
					<f:param name="billid" value="#{bill.id}" />
				</h:link>
			</p:column>
			<p:column rendered="#{billListView.canWriteBill}">
				<h:link outcome="/bill/edit" value="#{i18n['bill.edit']}">
					<f:param name="billid" value="#{bill.id}" />
				</h:link>
			</p:column>
			<p:column rendered="#{billListView.canWriteBill}">
				<p:commandButton update="billList" onerror="location.reload(true)"
					rendered="#{bill.paidDate == null and  billListView.showPayButtons}"
					action="#{billListView.markPaid()}"
					value="#{i18n['bill.markPaid']}" />
				<h:outputText rendered="#{bill.paidDate != null}"
					value="#{i18n['bill.isPaid']}" />
				<h:outputText
					rendered="#{bill.paidDate == null and !billListView.showPayButtons}"
					value="#{i18n['bill.isNotPaid']}" />
			</p:column>
			<p:column rendered="#{!billListView.canWriteBill}">
				<h:outputText rendered="#{bill.paidDate != null}"
					value="#{i18n['bill.isPaid']}" />
				<h:outputText rendered="#{bill.paidDate == null}"
					value="#{i18n['bill.isNotPaid']}" />
			</p:column>
			<p:column rendered="#{billListView.canWriteBill and not empty billListView.paytrailMerchantId}">
				<button onclick="showPaymentstatus('#{bill.id}'); return false;"><h:outputText value="#{i18n['bill.checkPaytrail']}" /></button>
			</p:column>
			

			<p:rowExpansion rendered="#{billListView.bills.rowCount lt 20}">
				<p:dataList value="#{bill.billLines}" var="line">
					<h:outputText value="#{line.name}" />:
					<h:outputText value="#{line.quantity}">
						<f:convertNumber minFractionDigits="0" maxFractionDigits="0" />
					</h:outputText>
				</p:dataList>
			</p:rowExpansion>

		</p:dataTable>

	</h:form>
	
	

	<form id="paymentcheckform" target="_blank" action="https://payment.paytrail.com/check-payment" method="post">
					<input name="MERCHANT_ID" type="hidden" value="#{billListView.paytrailMerchantId}" />
					<input id="paymentordernr" name="ORDER_NUMBER" type="hidden" value="" />
					<input id="paymentauthcode" name="AUTHCODE" type="hidden" value="" />
					<input name="VERSION" type="hidden" value="2" />
	</form>
	<script type="text/javascript" >
	function showPaymentstatus(id) {
		$("#paymentordernr").val(id);
		$("#paymentauthcode").val(authcodes[id]);
		$("#paymentcheckform").submit();
		return false;
	}	
	
		var authcodes ={};
		<ui:repeat var="ac" value="#{billListView.paytrailAuthcodes}">
			<h:outputText value="authcodes['#{ac.key}'] ='#{ac.value}';" />
		</ui:repeat>
	</script>

</composite:implementation>
</html>