{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<h1>{$layout.pagetitle}</h1>

<form method="post" name="ticketlist" id="ticketlist" action="?m=rtprint&type=ticketlist" target="_blank">
	<input type="submit" class="hiddenbtn">
</form>

<table class="lmsbox">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 99%;">
	</colgroup>
	<thead>
		<tr>
			<td>
				{icon name="helpdesk"}
			</td>
			<td>
				<strong>{trans("List of Requests")}</strong>
			</td>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td colspan="2">
				<table style="width: 100%;">
					<colgroup>
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 92%;">
					</colgroup>
					<tr>
						<td>
							{icon name="timetable"}
						</td>
						<td class="nobr">
							<strong>{trans("Period")}</strong>
						</td>
						<td class="nobr" colspan="8">
							{date_period_preset from='[form="ticketlist"][name="datefrom"]' to='[form="ticketlist"][name="dateto"]'
								periods="previous-year,previous-month,current-year,current-month,next-month,next-year"}
							<label>
								{trans("From")}
								<input type="text" size="10" name="datefrom" value="" placeholder="{trans("yyyy/mm/dd")}"
									form="ticketlist"
									{tip class="lms-ui-date" text="Enter date in 'yyyy/mm/dd' format (empty field means current date) or click to choose it from calendar" trigger="datefrom"}>&nbsp;
							</label>
							<label>
								{trans("To")}
								<input type="text" size="10" name="dateto" value="" placeholder="{trans("yyyy/mm/dd")}"
									form="ticketlist"
									{tip class="lms-ui-date" text="Enter date in 'yyyy/mm/dd' format (empty field means current date) or click to choose it from calendar" trigger="dateto"}>&nbsp;
							</label>
						</td>
					</tr>
					<tr>
						<td>
							{icon name="home"}
						</td>
						<td class="nobr">
							<strong>{trans("Address")}</strong>
						</td>
						<td class="nobr" colspan="8">
							<input type="text" name="address" form="ticketlist">
							<strong>{trans("City")}</strong>
							<input type="text" name="city" value="" form="ticketlist">
							<strong>{trans("Postcode")}</strong>
							<input type="text" name="zip" value="" size="10" form="ticketlist">
						</td>
					</tr>
					<tr>
						<td>
							{icon name="queue"}
						</td>
						<td class="nobr">
							<strong>{trans("Queue")}</strong>
						</td>
						<td>
							<select size="1" name="queue" {tip text="You can select queue to limit results"}
								form="ticketlist">
								<option value="0">{trans("— all queues —")}</option>
								{foreach $queues as $queue}
									<option value="{$queue.id}">{$queue.name|trunescape:40}</option>
								{/foreach}
							</select>
						</td>
						<td>
							{icon name="customer"}
						</td>
						<td class="nobr">
							<strong>{trans("Customer")}</strong>
						</td>
						<td class="nobr">
							{customerlist form="ticketlist" customers=$customers selectname="cust" inputname="customer"
								version=2
								firstoption="— all customers —" selecttip="You can select customer to limit results"
								inputtip="Enter customer ID or leave empty for all customers"}
						</td>
						<td>
							{icon name="subject"}
						</td>
						<td class="nobr">
							<strong>{trans("Subject")}</strong>
						</td>
						<td>
							<input type="text" name="subject" value="" size="30"
								form="ticketlist" {tip text="Enter subject"}>
						</td>
					</tr>
					<tr>
						<td>
							{icon name="status"}
						</td>
						<td>
							<strong>{trans("Status")}</strong>
						</td>
						<td>
							<select size="1" name="status" {tip text="You can select status to limit results"}
								form="ticketlist">
								<option value="">{trans("— all —")}</option>
								<option value="-1">{trans("not resolved")}</option>
								{foreach $_RT_STATES as $key => $item}
									<option value="{$key}">{$item.label}</option>
								{/foreach}
							</select>
						</td>
						<td>
							{icon name="uptime"}
						</td>
						<td>
							<strong>{trans("Uptime")}</strong>
						</td>
						<td>
							<label>
								<input type="text" name="days" size="3" form="ticketlist">
								{trans("days")}
							</label>
						</td>
						<td>
						</td>
					</tr>
					{if ConfigHelper::checkPrivilege('helpdesk_advanced_operations')}
						<tr>
							<td>
								{icon name="delete"}
							</td>
							<td>
								<strong>{trans("<!rt>Removed")}</strong>
							</td>
							<td>
								<select size="1" name="removed" {tip text="You can select status to limit results"}
									form="ticketlist">
									<option value="">{trans("— all —")}</option>
									<option value="-1">{trans("Not removed")}</option>
									<option value="1">{trans("Removed")}</option>
								</select>
							</td>
						</tr>
					{/if}
					<tr>
						<td>
							{icon name="helpdesk"}
						</td>
						<td class="nobr">
							<strong>{trans("Categories")}</strong>
						</td>
						<td>
							<input type="hidden" name="categories" value="all" form="ticketlist">
							<select size="1" name="categories[]" multiple class="lms-ui-multiselect lms-ui-multiselect-filter"
								form="ticketlist" data-default-value="{trans("— all —")}">
								<option value="-1" data-exclusive>{trans('— no categories —')}</option>
								{foreach $categories as $c}
									<option value="{$c.id}">{$c.name}</option>
								{/foreach}
							</select>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="lms-ui-box-buttons">
				{button onclick="document.ticketlist.submit()" icon="print" label="Print" form="ticketlist"}
				<label>
					<input type="checkbox" name="extended" value="1" form="ticketlist">
					{trans("extended format")}
				</label>&nbsp;
				<label>
					<input type="checkbox" name="contacts" value="1" form="ticketlist" checked>
					{trans("include contact info")}
				</label>
				<label>
					<input type="checkbox" name="comment-details" value="1" form="ticketlist" disabled checked>
					<span class="lms-ui-label">{trans("comment details")}</span>
				</label>
			</td>
		</tr>
	</tbody>
</table>

<script>

	$(function() {
		$('[form="ticketlist"][name="extended"]').change(function() {
			$('[form="ticketlist"][name="comment-details"]').prop('disabled', !$(this).prop('checked'));
		});
	});

</script>

<form method="post" name="stats" id="stats" action="?m=rtprint&type=stats" target="_blank">
	<input type="submit" class="hiddenbtn">
</form>

<table class="lmsbox">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 99%;">
	</colgroup>
	<thead>
		<tr>
			<td>
				{icon name="helpdesk"}
			</td>
			<td>
				<strong>{trans("Requests Stats")}</strong>
			</td>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td colspan="2">
				<table style="width: 100%;">
					<colgroup>
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 96%;">
					</colgroup>
					<tr>
						<td>
							{icon name="timetable"}
						</td>
						<td class="nobr">
							<strong>{trans("Period")}</strong>
						</td>
						<td class="nobr" colspan="3">
							{date_period_preset from='[form="stats"][name="datefrom"]' to='[form="stats"][name="dateto"]'
								periods="previous-year,previous-month,current-year,current-month,next-month,next-year"}
							<label>
								{trans("From")}
								<input type="text" size="10" name="datefrom" value="" placeholder="{trans("yyyy/mm/dd")}"
									form="stats"
									{tip class="lms-ui-date" text="Enter date in 'yyyy/mm/dd' format (empty field means current date) or click to choose it from calendar" trigger="datefrom"}>&nbsp;
							</label>
							<label>
								{trans("To")}
								<input type="text" size="10" name="dateto" value="" placeholder="{trans("yyyy/mm/dd")}"
									form="stats"
									{tip class="lms-ui-date" text="Enter date in 'yyyy/mm/dd' format (empty field means current date) or click to choose it from calendar" trigger="dateto"}>&nbsp;
							</label>
						</td>
					</tr>
					<tr>
						<td>
							{icon name="queue"}
						</td>
						<td class="nobr">
							<strong>{trans("Queue")}</strong>
						</td>
						<td>
							<select size="1" name="queue" {tip text="You can select queue to limit results"}
								form="stats">
								<option value="0">{trans("— all queues —")}</option>
								{foreach $queues as $queue}
									<option value="{$queue.id}">{$queue.name|trunescape:40}</option>
								{/foreach}
							</select>
						</td>
						<td>
							{icon name="customer"}
						</td>
						<td class="nobr">
							<strong>{t a="<input type=\"text\" name=\"times\" size=\"3\" form=\"stats\">" b="<input type=\"text\" name=\"days\" size=\"3\" form=\"stats\">"}Customers requesting more than $a times in last $b days{/t}</strong>
						</td>
					</tr>
					{if ConfigHelper::checkPrivilege('helpdesk_advanced_operations')}
						<tr>
							<td>
								{icon name="delete"}
							</td>
							<td>
								<strong>{trans("<!rt>Removed")}</strong>
							</td>
							<td colspan="3">
								<select size="1" name="removed" {tip text="You can select status to limit results"}
									form="stats">
									<option value="">{trans("— all —")}</option>
									<option value="-1">{trans("Not removed")}</option>
									<option value="1">{trans("Removed")}</option>
								</select>
							</td>
						</tr>
					{/if}
					<tr>
						<td>
							{icon name="helpdesk"}
						</td>
						<td>
							<strong>{trans("Categories")}</strong>
						</td>
						<td colspan="3">
							<input type="hidden" name="categories" value="all" form="stats">
							<select size="1" name="categories[]" multiple class="lms-ui-multiselect lms-ui-multiselect-filter"
								form="stats" data-default-value="{trans("— all —")}">
								<option value="-1" data-exclusive>{trans('— no categories —')}</option>
								{foreach $categories as $c}
									<option value="{$c.id}">{$c.name}</option>
								{/foreach}
							</select>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="lms-ui-box-buttons">
				{button onclick="document.stats.submit()" icon="print" label="Print"}
			</td>
		</tr>
	</tbody>
</table>
{/block}
