<vn>
<vn-group>
	<vn-param id="ticket-id" on-changed="onTicketChange"/>
	<vn-hash-param key="ticket" param="ticket-id"/>
	<sql-batch id="batch">
		<custom>
			<item name="ticket" param="ticket-id"/>
		</custom>
	</sql-batch>
	<db-form id="ticket" on-ready="onTicketReady">
		<db-model id="ticket-data" property="model" batch="batch">
			CALL myTicket_get(#ticket)
		</db-model>
	</db-form>
</vn-group>
<div id="title">
	<h1><t>OrderDetail</t></h1>
</div>
<div id="actions" class="action-bar">
	<htk-bar-button
		icon="print"
		tip="_Print delivery note"
		on-click="onPrintClick"/>
</div>
<div id="form" class="ticket">
	<div class="box">
		<htk-loader class="head" form="ticket">
			<div>
				<p class="important ticket-id">
					#<htk-text column="id" form="ticket"/>
				</p>
				<p>
					<t>Preparation</t> <htk-text form="ticket" column="shipped" format="%D"/>
				</p>
				<p>
					<t>Delivery</t> <htk-text form="ticket" column="landed" format="%D"/>
				</p>
				<p>
					<span id="method"></span> <htk-text form="ticket" column="agency"/>
				</p>
			</div>
			<div class="address">
				<p>
					<htk-text form="ticket" column="nickname"/>
				</p>
				<p>
					<htk-text form="ticket" column="street"/>
				</p>
				<p>
					<htk-text form="ticket" column="postalCode"/> 
					<htk-text form="ticket" column="city"/> 
					(<htk-text form="ticket" column="province"/>)
				</p>
			</div>
			<div class="total">
				<p class="important total">
					<t>Total</t> 
					<htk-text format="%.2d€" form="ticket" column="taxBase"/>
				</p>
				<p class="important total">
					<t>Total + tax</t> 
					<htk-text format="%.2d€" form="ticket" column="total"/>
				</p>
			</div>
		</htk-loader>
		<htk-repeater form-id="iter" renderer="repeaterFunc">
			<db-model
				property="model"
				id="movements"
				batch="batch">
				CALL myTicket_getRows(#ticket)
			</db-model>
			<custom>
				<div class="line">
					<htk-image
						form="iter"
						column="image"
						stamp-column="updated"
						class="photo"
						directory="catalog"
						subdir="200x200"
						full-dir="1600x900"/>
					<div class="info">
						<h2>
							<htk-text form="iter" column="concept"/> 
						</h2>
						<p class="tags">
							<htk-text form="iter" column="value5"/> 
							<htk-text form="iter" column="value6"/> 
							<htk-text form="iter" column="value7"/>
						</p>
						<p class="amount">
							<htk-text form="iter" column="quantity"/> x
							<htk-text form="iter" column="price" format="%.2d€"/>
						</p>
						<p class="subtotal">
							<span class="discount" id="discount">
								<htk-text id="discount-subtotal" format="%.2d€"/> - 
								<htk-text form="iter" column="discount" format="%.0d%"/> = 
							</span>
							<htk-text id="subtotal" format="%.2d€"/>
						</p>
					</div>
					<div class="clear"/>
				</div>
			</custom>
		</htk-repeater>
		<htk-repeater form-id="iter" id="services" class="packages" renderer="servicesFunc">
			<db-model
				property="model"
				on-status-changed="onServicesChanged"
				batch="batch">
				CALL myTicket_getServices(#ticket)
			</db-model>
			<custom>
				<div class="line">
					<div class="info">
						<h2>
							<htk-text form="iter" column="description"/>
						</h2>
						<p class="amount">
							<htk-text form="iter" column="quantity"/> x
							<htk-text form="iter" column="price" format="%.2d€"/>
						</p>
						<p class="subtotal">
							<htk-text id="subtotal" format="%.2d€"/>
						</p>
					</div>
					<div class="clear"/>
				</div>
			</custom>
		</htk-repeater>
		<htk-repeater form-id="iter" id="packages" class="packages">
			<db-model
				property="model"
				on-status-changed="onPackagesChanged"
				batch="batch">
				CALL myTicket_getPackages(#ticket)
			</db-model>
			<custom>
				<div class="line">
					<htk-image
						form="iter"
						column="image"
						class="photo"
						directory="catalog"
						subdir="200x200"
						full-dir="1600x900"/>
					<div class="info">
						<h2>
							<htk-text form="iter" column="name"/>
						</h2>
						<p>
							#<htk-text form="iter" column="id"/>
						</p>
						<p class="amount">
							<htk-text form="iter" column="quantity"/>
						</p>
					</div>
					<div class="clear"/>
				</div>
			</custom>
		</htk-repeater>
	</div>
</div>
</vn>
