<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="weekly_timesheet" language="groovy" pageWidth="792" pageHeight="612" orientation="Landscape" columnWidth="752" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="614c7195-b5d3-4a87-a1bf-dc915af870fa">
	<property name="ireport.zoom" value="1.0"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<style name="ZebraStripe">
		<conditionalStyle>
			<conditionExpression><![CDATA[$V{REPORT_COUNT}%2==1]]></conditionExpression>
			<style mode="Opaque" backcolor="#99FF99"/>
		</conditionalStyle>
	</style>
	<parameter name="whereParam" class="java.lang.String"/>
	<queryString>
		<![CDATA[select *,
(select concat(firstname," ",lastname) from users where users.id = user_id) as employee,
(select name from project where project.id = project_id) as project_name,
(select name from project_task where project_task.id = task_id) as project_task,
FORMAT(TIME_TO_SEC(TIMEDIFF(endDate,startDate))/3600,2) as hours
from calendar  a right join calendar_timesheet b on a.id = b.calendar_id
where $P{whereParam}
order by startDate]]>
	</queryString>
	<field name="id" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="name" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="description" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="startDate" class="java.sql.Timestamp">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="endDate" class="java.sql.Timestamp">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="canEdit" class="java.lang.Boolean">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="user_id" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="usergroup_id" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="max_bookings" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="calendar_id" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="project_id" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="task_id" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="employee" class="java.lang.String"/>
	<field name="project_name" class="java.lang.String"/>
	<field name="project_task" class="java.lang.String"/>
	<field name="hours" class="java.lang.String"/>
	<variable name="totalHours" class="java.lang.Float" resetType="Group" resetGroup="employee" incrementType="Group" incrementGroup="employee" calculation="Sum">
		<variableExpression><![CDATA[$F{hours}]]></variableExpression>
	</variable>
	<group name="employee">
		<groupExpression><![CDATA[$F{user_id}]]></groupExpression>
		<groupHeader>
			<band height="43">
				<rectangle>
					<reportElement uuid="d7ddfe66-746d-4459-a766-96d05043eff6" x="1" y="1" width="750" height="40" backcolor="#9090FF"/>
				</rectangle>
				<textField>
					<reportElement uuid="94e81e04-4b57-42b7-9d07-35871ca6947f" x="105" y="3" width="300" height="20"/>
					<textElement/>
					<textFieldExpression><![CDATA[$F{employee}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement uuid="6ea0e1cd-2d7a-48a7-91eb-913ab0217a28" x="5" y="23" width="100" height="20"/>
					<textElement textAlignment="Center">
						<font isBold="true"/>
					</textElement>
					<text><![CDATA[Date]]></text>
				</staticText>
				<staticText>
					<reportElement uuid="89c5d5c4-5ecf-4b99-ac40-b6ac5af5b68b" x="405" y="23" width="247" height="20"/>
					<textElement textAlignment="Left">
						<font isBold="true"/>
					</textElement>
					<text><![CDATA[Description]]></text>
				</staticText>
				<staticText>
					<reportElement uuid="16cca96a-ca79-4ec0-b629-0e61e6aa960c" x="652" y="23" width="95" height="20"/>
					<textElement textAlignment="Right">
						<font isBold="true"/>
					</textElement>
					<text><![CDATA[Hours]]></text>
				</staticText>
				<staticText>
					<reportElement uuid="0bf565e6-0ffc-427d-9ff8-21a38fc65812" x="5" y="3" width="100" height="20"/>
					<textElement>
						<font isBold="true"/>
					</textElement>
					<text><![CDATA[Employee Name:]]></text>
				</staticText>
				<staticText>
					<reportElement uuid="5a9526a2-af80-4a85-bfab-69b0468aab7a" x="105" y="23" width="150" height="20"/>
					<textElement textAlignment="Left">
						<font isBold="true"/>
					</textElement>
					<text><![CDATA[Project Name]]></text>
				</staticText>
				<staticText>
					<reportElement uuid="83d01eb4-1c41-464d-ab97-03626cb1d05e" x="255" y="23" width="150" height="20"/>
					<textElement textAlignment="Left">
						<font isBold="true"/>
					</textElement>
					<text><![CDATA[Project Task]]></text>
				</staticText>
			</band>
		</groupHeader>
		<groupFooter>
			<band height="23">
				<rectangle>
					<reportElement uuid="7bdd504b-b875-4e0b-955c-4184c8d8ab4c" x="0" y="1" width="751" height="20" backcolor="#9090FF"/>
				</rectangle>
				<textField pattern="###0.00">
					<reportElement uuid="287ea0d7-560a-4704-bac9-a0444a3ee8d6" x="652" y="0" width="95" height="20"/>
					<textElement textAlignment="Right" verticalAlignment="Middle"/>
					<textFieldExpression><![CDATA[$V{totalHours}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement uuid="d9e92207-6ddb-496f-8f38-4bee5cea0e1d" x="580" y="0" width="72" height="20"/>
					<textElement verticalAlignment="Middle">
						<font isBold="true"/>
					</textElement>
					<text><![CDATA[Total Hours:]]></text>
				</staticText>
			</band>
		</groupFooter>
	</group>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band height="26" splitType="Stretch">
			<staticText>
				<reportElement uuid="2da3f4ed-926b-4bdd-bea0-14636de7d5e3" x="0" y="0" width="359" height="24"/>
				<textElement>
					<font size="18" isBold="true"/>
				</textElement>
				<text><![CDATA[Detail Timesheet Report]]></text>
			</staticText>
		</band>
	</title>
	<detail>
		<band height="20" splitType="Stretch">
			<staticText>
				<reportElement uuid="11ce46dd-d336-4150-bb65-70900aa8a9a7" mode="Opaque" x="1" y="1" width="750" height="18" backcolor="#C0C0C0">
					<printWhenExpression><![CDATA[$V{REPORT_COUNT}%2==1]]></printWhenExpression>
				</reportElement>
				<textElement/>
				<text><![CDATA[]]></text>
			</staticText>
			<textField pattern="yyyy/MM/dd">
				<reportElement uuid="709068f9-2d45-4b84-9b39-31826a7c81d5" x="5" y="3" width="100" height="16"/>
				<textElement textAlignment="Center"/>
				<textFieldExpression><![CDATA[$F{startDate}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="6fd0a235-594e-4af7-a672-7cd803d20cd0" x="405" y="3" width="247" height="16"/>
				<textElement/>
				<textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
			</textField>
			<textField pattern="###0.00">
				<reportElement uuid="30200c73-31f5-429f-bac9-c5830ab5672f" x="652" y="3" width="95" height="16"/>
				<textElement textAlignment="Right"/>
				<textFieldExpression><![CDATA[$F{hours}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="bc9266e8-ca77-453c-87fa-5506ff2ac58a" x="105" y="3" width="150" height="16"/>
				<textElement/>
				<textFieldExpression><![CDATA[$F{project_name}]]></textFieldExpression>
			</textField>
			<textField>
				<reportElement uuid="e291408d-2bb4-43d5-a731-84f0419524ce" x="255" y="3" width="150" height="16"/>
				<textElement/>
				<textFieldExpression><![CDATA[$F{project_task}]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<summary>
		<band height="42" splitType="Stretch"/>
	</summary>
</jasperReport>
