<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../xsltforms/xsltforms.xsl" type="text/xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<head>
	<title>Expenses</title>
	<style type="text/css">
		body, .value {font-family: sans-serif; font-size: 20pt}
		.input-value {width: 6em}
		.enabled {}
		.disabled {display: none}
		.read-only {color: #ccc}
		.invalid {border: thin red solid}
		.repeat-index { background-color: lightblue}
		.valid xforms\:alert {display: none}
		xforms\:hint { width: 12em; color: blue}
		xforms\:output.read-only {color: black; font-weight: bold}
		xforms\:input xforms\:label, xforms\:select1 xforms\:label
		  {vertical-align: 10%}

	</style>

	<xforms:model id="m">
	    <xforms:instance src="exp.xml"/>
	    <xforms:instance src="currencies.xml" id="currencies"/>

	    <xforms:bind nodeset="total"
                   calculate="sum(../declarations/item/home)"/>
	    <xforms:bind nodeset="declarations/item/date"
                   type="xsd:date"/>
	    <xforms:bind nodeset="declarations/item/amount"
		   type="xsd:decimal"/>
	    <xforms:bind nodeset="declarations/item/home"
		   calculate="../amount * ../rate"/>

	    <xforms:submission id="save" method="put"
		   action="expenses.xml" replace="none"/>

	</xforms:model>
</head>
<body>
<xforms:output ref="total"><xforms:label>Total Euro</xforms:label></xforms:output>
<br/>

<xforms:repeat nodeset="declarations/item">
    <xforms:input ref="date"><xforms:label>Date</xforms:label></xforms:input>
    <xforms:input ref="what"><xforms:label>What</xforms:label></xforms:input>
    <xforms:input ref="amount"><xforms:label>Amount</xforms:label></xforms:input>
    <xforms:select1 ref="rate">
        <xforms:label></xforms:label>
        <xforms:itemset nodeset="instance('currencies')/currency">
            <xforms:label ref="name"/>
            <xforms:value ref="rate"/>
        </xforms:itemset>
    </xforms:select1>
    <xforms:output ref="home"><xforms:label> = EUR</xforms:label></xforms:output>
    <br/>
</xforms:repeat>

<br/>
<xforms:trigger><xforms:label>Another</xforms:label>
      <xforms:action ev:event="DOMActivate">
		<xforms:insert  
           		nodeset="declarations/item"
           		position="after" at="count(declarations/item)"/>
		<xforms:setvalue ref="declarations/item[last()]/date" value="substring-before('T', now())"/>
		<xforms:setvalue ref="declarations/item[last()]/what"/>
		<xforms:setvalue ref="declarations/item[last()]/amount" value="0"/>
		<xforms:setvalue ref="declarations/item[last()]/rate" value="eur"/>
      </xforms:action>
</xforms:trigger>

<xforms:submit submission="save"><xforms:label>Save</xforms:label></xforms:submit>


</body>
</html>
