<vn>
<vn-group>
	<vn-param id="ticket-id">
		<vn-hash-param key="ticket"/>
	</vn-param>
	<db-form id="ticket">
		<db-model id="ticket-data">
			SELECT t.id, date, a.Agencia, note, p.name province,
			zip_code, city, c.name, consignee, invoice
				FROM ticket_view t
				JOIN address_view c ON t.address_id = c.id
				JOIN vn2008.Agencias a ON t.agency_id = a.Id_Agencia
				JOIN vn2008.province p ON c.province_id = p.province_id
					WHERE t.id = #ticket
			<sql-batch property="batch">
				<item name="ticket" param="ticket-id"/>
			</sql-batch>
		</db-model>
	</db-form>
</vn-group>
<div id="title">
	<h1><t>OrderDetail</t></h1>
</div>
<div id="actions" class="action-bar">
	<button id="print">
		<img src="image/dark/print.svg" alt=""/>
		<t>Print</t>
	</button>
</div>
<div id="form" class="ticket">
	<div class="box">
		<div id="report">
			<table class="form">
			<tbody>
				<tr>
					<td class="label">
						<label><t>TicketNumber:</t></label>
					</td>
					<td>
						<htk-text column="id" form="ticket"/>
					</td>
				</tr>
				<tr>
					<td class="label">
						<label><t>DateExit:</t></label>
					</td>
					<td>
						<htk-date-chooser column="date" form="ticket" editable="false"/>
					</td>
				</tr>
				<tr>
					<td class="label">
						<label><t>SendMethod:</t></label>
					</td>
					<td>
						<htk-text column="Agencia" form="ticket"/>
					</td>
				</tr>
				<tr>
					<td class="label">
						<label><t>Notes:</t></label>
					</td>
					<td>
						<htk-text column="note" form="ticket"/>
					</td>
				</tr>
				<tr>
					<td class="label">
						<label for="total"><t>Subtotal:</t></label>
					</td>
					<td>
						<htk-text format="%.2d€">
							<db-calc-sum id="ticket-subtotal" model="movements"/>
						</htk-text>
					</td>
				</tr>
			</tbody>
			</table>
			<htk-grid model="ticket-data">
				<htk-column-spin title="_PC" column="zip_code"/>
				<htk-column-text title="_City" column="city"/>
				<htk-column-text title="_Province" column="province"/>
				<htk-column-text title="_Address" column="name"/>
				<htk-column-text title="_Consignee" column="consignee"/>
			</htk-grid>
			<htk-grid>
				<db-model id="movements">
					SELECT m.item_id, amount, concept, Categoria, Medida, Tallos, Color,
					Abreviatura, IF(fixed != FALSE, price, NULL) price, fixed, discount
						FROM ticket_row_view m
						INNER JOIN vn2008.Articles a
							ON m.item_id = a.Id_Article AND ticket_id = #ticket 
						LEFT JOIN vn2008.Origen o
							ON a.id_origen = o.id
							ORDER BY concept
					<sql-batch property="batch">
						<item name="ticket" param="ticket-id"/>
					</sql-batch>
				</db-model>
				<htk-column-spin title="_ItemNumber" column="item_id"/>
				<htk-column-spin title="_Amount" column="amount"/>
				<htk-column-text title="_Item" column="concept"/>
				<htk-column-text title="_Category" column="Categoria"/>
				<htk-column-text title="_S1" column="Medida"/>
				<htk-column-text title="_Stems" column="Tallos"/>
				<htk-column-text title="_Color" column="Color"/>
				<htk-column-text title="_Origin" column="Abreviatura"/>
				<htk-column-spin title="_Price" column="price" unit="€" digits="2"/>
				<htk-column-spin title="_Desc" column="discount" unit="%"/>
				<htk-column-spin title="_Subtotal" unit="€" digits="2" id="subtotal"/>
			</htk-grid>
		</div>
	</div>
</div>
</vn>
