{block name="rtfilter"}

{$hide_disabled_users = ConfigHelper::checkConfig('rt.hide_disabled_users', ConfigHelper::checkConfig('phpui.helpdesk_hide_disabled_users'))}
{$hide_deleted_users = ConfigHelper::checkConfig('rt.hide_deleted_users', ConfigHelper::checkConfig('phpui.helpdesk_hide_deleted_users'))}

<TR>
    <TD colspan="10" class="ticket-list-filter">
        <div class="lms-ui-filter-container">
        <div class="lms-ui-filter-definition">
        <FORM method="GET" action="?m=rtqueueview" name="filter" form="filter-form">
            <INPUT type="submit" class="hiddenbtn">
            <INPUT type="HIDDEN" name="m" value="rtqueueview">
            <label class="nobr">
            {trans("Queue")}
            <input type="hidden" name="id" value="all">
            <SELECT size="1" name="id[]" OnChange="document.filter.submit();" multiple class="lms-ui-multiselect lms-ui-multiselect-filter" data-default-value="{trans("— all —")}">
                {foreach $queues as $q}
                    <OPTION value="{$q.id}"{if is_array($filter.ids) && in_array($q.id, $filter.ids)} SELECTED{/if}>{$q.name}</OPTION>
                {/foreach}
            </SELECT>
            </label>
            <label class="nobr">
            {trans("Service type")}
            <input type="hidden" name="ts" value="all">
            <SELECT size="1" name="ts[]" OnChange="document.filter.submit();" multiple class="lms-ui-multiselect lms-ui-multiselect-filter" data-default-value="{trans("— all —")}">
                {foreach $_SERVICETYPES as $key => $ts}
                    <OPTION value="{$key}"{if is_array($filter.serviceids) && in_array($key, $filter.serviceids)} SELECTED{/if}>{$ts}</OPTION>
                {/foreach}
            </SELECT>
            </label>
            <label class="nobr">
                {trans("Ticket type")}
                <input type="hidden" name="tt" value="all">
                <SELECT size="1" name="tt[]" OnChange="document.filter.submit();" multiple class="lms-ui-multiselect lms-ui-multiselect-filter" data-default-value="{trans("— all —")}">
                {foreach Localisation::arraySort($_RT_TYPES, 'label') as $key => $tt}
                    <OPTION value="{$key}"{if is_array($filter.typeids) && in_array($key, $filter.typeids)} SELECTED{/if}>{$tt.label}</OPTION>
                {/foreach}
                </SELECT>
            </label>
            <label class="nobr">
            {trans("Category")}
            <input type="hidden" name="catid" value="all">
            <SELECT size="1" name="catid[]" OnChange="document.filter.submit();" multiple class="lms-ui-multiselect lms-ui-multiselect-filter" data-default-value="{trans("— all —")}">
                    <option value="-1" {if !empty($filter.catids) && in_array(-1, $filter.catids)} selected{/if}>{trans('— no categories —')}</option>
                    {foreach $categories as $c}
                    <OPTION value="{$c.id}"{if !empty($filter.catids) && in_array($c.id, $filter.catids)} SELECTED{/if}>{$c.name}</OPTION>
                    {/foreach}
            </SELECT>
            </label>
            <label class="nobr">
            {trans("Status")}
            <input type="hidden" name="s" value="-2">
            <SELECT size="1" name="s[]" OnChange="document.filter.submit();" multiple class="lms-ui-multiselect" data-default-value="{trans("— all —")}">
                <option value="-1" data-exclusive{if !is_array($filter.state) && $filter.state == -1} selected{/if}>{trans("not resolved")}</option>
                {foreach $_RT_STATES as $idx => $s}
                    <OPTION value="{$idx}" {if is_array($filter.state) && in_array($idx, $filter.state)} SELECTED{/if}>{$s.label}</OPTION>
                {/foreach}
            </SELECT>
            </label>
            <label class="nobr">
            {trans("Priority")}
            <input type="hidden" name="priority" value="all">
            <SELECT size="1" name="priority[]" OnChange="document.filter.submit();" multiple class="lms-ui-multiselect" data-default-value="{trans("— all —")}">
                {foreach $_RT_PRIORITIES as $idx => $priority}
                    <OPTION value="{$idx}" {if is_array($filter.priority) && in_array($idx, $filter.priority)} SELECTED{/if}>{$priority}</OPTION>
                {/foreach}
                <option value="-101" {if is_array($filter.priority) && in_array('-101', $filter.priority)} selected{/if}>{trans("undefined")}</option>
            </SELECT>
            </label>
            <label class="nobr">
                {trans("Source")}
                <SELECT size="1" name="source" OnChange="document.filter.submit();">
                    <option value="-1">{trans("— all —")}</option>
                    {foreach Localisation::arraySort($_RT_SOURCES) as $idx => $source}
                        <OPTION value="{$idx}"{if $filter.source == $idx} selected{/if}>{$source}</OPTION>
                    {/foreach}
                </SELECT>
            </label>
			<label class="nobr">
				{trans("Cause")}
				<select size="1" name="cause" onchange="document.filter.submit();">
					<option value=""{if !isset($filter.cause) || $filter.cause === ""} selected{/if}>{trans("— any —")}</option>
					<option value="0"{if $filter.cause === 0} selected{/if}>{trans("unknown/other")}</option>
					<option value="1"{if $filter.cause == 1} selected{/if}>{trans("customer's side")}</option>
					<option value="2"{if $filter.cause == 2} selected{/if}>{trans("company's side")}</option>
				</select>
			</label>
            <label class="nobr">
            {trans("Owner")}
                <input type="hidden" name="owner" value="all">
                <select size="1" name="owner[]" OnChange="document.filter.submit();" multiple class="lms-ui-multiselect"
                        data-default-value="{trans("No filter")}" data-popup-title="{trans("Select owners")}">
                    <option value="all" data-exclusive{if empty($filter.owner)} selected{/if}>{trans("No filter")}</option>
                    <option value="-1" {if !empty($filter.owner) && is_array($filter.owner) && in_array('-1', $filter.owner)} selected{/if}>{trans("no owner")}</option>
                    <option value="-2" data-exclusive{if !empty($filter.owner) && is_array($filter.owner) && in_array('-2', $filter.owner)} selected{/if}>{trans("with owner")}</option>
                    <option value="-3" data-exclusive{if !empty($filter.owner) && is_array($filter.owner) && in_array('-3', $filter.owner)} selected{/if}>{trans("no owner or logged user")}</option>
                    {foreach $users as $user}
                        {if (!is_array($filter.owner) || !in_array($user.id, $filter.owner))
                            && ($hide_disabled_users && !$user.access
                                || $hide_deleted_users && $user.deleted)}
                            {continue}
                        {/if}
                        <option
                            {if !$user.access} data-blend{/if}
                            {if $user.deleted} data-crossed{/if}
                            value="{$user.id}"
                            {if is_array($filter.owner) && in_array($user.id, $filter.owner)} selected{/if}
                        >{strip}
                            {$user.rname|trunescape:40} ({$user.login})
                        {/strip}</option>
                    {/foreach}
                </select>
            </label>
            <label class="nobr">
                {trans("Verifier")}
                <input type="hidden" name="vids" value="all">
                <select size="1" name="vids[]" OnChange="document.filter.submit();" multiple class="lms-ui-multiselect" data-default-value="{trans("No filter")}" >
                    <option value="all" data-exclusive{if !is_array($filter.verifierids) && $filter.verifierids == "all"} selected{/if}>{trans("No filter")}</option>
                    <option value="-1" data-exclusive{if !is_array($filter.verifierids) && $filter.verifierids == -1} selected{/if}>{trans("Unassigned")}</option>
                    <option value="-2" data-exclusive{if !is_array($filter.verifierids) && $filter.verifierids == -2} selected{/if}>{trans("Assigned")}</option>
                    {foreach $users as $user}
                        {if (!is_array($filter.verifierids) || !in_array($user.id, $filter.verifierids))
                            && ($hide_disabled_users && !$user.access
                                || $hide_deleted_users && $user.deleted)}
                            {continue}
                        {/if}
                        <option
                            {if !$user.access} data-blend{/if}
                            {if $user.deleted} data-crossed{/if}
                            value="{$user.id}"
                            {if is_array($filter.verifierids) && in_array($user.id, $filter.verifierids)} selected{/if}
                        >{strip}
                            {$user.rname|trunescape:40} ({$user.login})
                        {/strip}</option>
                    {/foreach}
                </select>
            </label>
            {if ConfigHelper::checkPrivilege('helpdesk_advanced_operations')}
            <label class="nobr">
            {trans("<!rt>Removed")}
            <SELECT size="1" name="r" OnChange="document.filter.submit();">
                <OPTION value=""{if $filter.removed == ""} SELECTED{/if}>{trans("— all —")}</OPTION>
                <OPTION value="-1"{if $filter.removed == "-1"} SELECTED{/if}>{trans("No")}</OPTION>
                <OPTION value="1"{if $filter.removed == "1"} SELECTED{/if}>{trans("Yes")}</OPTION>
            </SELECT>
            </label>
            {/if}
            <label class="nobr">
            {trans("<!rt>Deadline")}
            <SELECT size="1" name="d" OnChange="document.filter.submit();">
                <OPTION value=""{if $filter.deadline == ""} SELECTED{/if}>{trans("all")}</OPTION>
                <OPTION value="-1"{if $filter.deadline == "-1"} SELECTED{/if}>{trans("<!rt>Without deadline")}</OPTION>
                <OPTION value="1"{if $filter.deadline == "1"} SELECTED{/if}>{trans("<!rt>With deadline")}</OPTION>
                <OPTION value="-4"{if $filter.deadline == "-4"} SELECTED{/if}>{trans("<!rt>Not expired")}</OPTION>
                <OPTION value="-3"{if $filter.deadline == "-3"} SELECTED{/if}>{trans("<!rt>less than 7 days to deadline")}</OPTION>
                <OPTION value="-2"{if $filter.deadline == "-2"} SELECTED{/if}>{trans("<!rt>Expired")}</OPTION>
            </SELECT>
            </label>
            <label class="nobr">
                {trans("<!rt>Unread")}
                <SELECT size="1" name="unread" onChange="document.filter.submit()">
                    <option value="-1"{if $filter.unread == -1} selected{/if}>{trans("— all —")}</option>
                    <option value="0"{if $filter.unread == 0} selected{/if}>{trans("no")}</option>
                    <option value="1"{if $filter.unread == 1} selected{/if}>{trans("yes")}</option>
                </SELECT>
            </label>
            <label class="nobr">
                {trans("Primary ticket")}
                <SELECT size="1" name="parentids" onChange="document.filter.submit()">
                    <option value=""{if $filter.parentids == ""} selected{/if}>{trans("all")}</option>
                    <option value="-1"{if $filter.parentids == -1} selected{/if}>{trans("show only primary tickets")}</option>
                </SELECT>
            </label>
            <label class="nobr">
                {trans("Indicator panel")}
                <SELECT size="1" name="rights" OnChange="document.filter.submit();">
                    <option value="0"{if $filter.rights == 0} selected{/if}>{trans("— all —")}</option>
                    <option value="{$smarty.const.RT_RIGHT_INDICATOR}" {if $filter.rights == $smarty.const.RT_RIGHT_INDICATOR} selected{/if}>{trans("yes")}</option>
                </SELECT>
            </label>
            <label class="nobr">
                {trans("Network node")}
                <input type="hidden" name="nnids" value="all">
                <select name="nnids[]" size="1" multiple data-default-value="{trans("No filter")}" class="lms-ui-multiselect" {tip text="Select network node (optional)"} onchange="document.filter.submit();">
                    <option value="all" data-exclusive{if is_array($filter.netnodeids) && in_array(null, $filter.netnodeids)} selected{/if}>{trans("No filter")}</option>
                    <option value="-1" data-exclusive{if is_array($filter.netnodeids) && in_array(-1, $filter.netnodeids)} selected{/if}>{trans("Unassigned")}</option>
                    <option value="-2" data-exclusive{if is_array($filter.netnodeids) && in_array(-2, $filter.netnodeids)} selected{/if}>{trans("Assigned")}</option>
                    {foreach $netnodelist as $idx => $netnode}
                    <option value="{$netnode.id}" {if is_array($filter.netnodeids) && in_array($netnode.id, $filter.netnodeids)} selected{/if}>{$netnode.name}</OPTION>
                    {/foreach}
                </select>
            </label>
            <label class="nobr">
                {trans("Investment project")}
                <input type="hidden" name="pids" value="all">
                <SELECT size="1" name="pids[]" OnChange="document.filter.submit();" multiple class="lms-ui-multiselect" data-default-value="{trans("No filter")}">
                {foreach $projects as $project}
                    <OPTION value="{$project.id}"{if is_array($filter.projectids) && in_array($project.id, $filter.projectids)} selected{/if}>{$project.name|truncate:40:"&hellip;":true}</OPTION>
                {/foreach}
                </SELECT>
            </label>
            <label class="nobr">
                {customerlist
		    version=2
		    customOnChange="document.filter.submit();"
		    selected=$filter.cid
		    selectname="cid"
		    inputname="cid"
		}
            </label>
            <label class="nobr">
                <input type="text" name="subject" value="{$filter.subject|default:""|escape}" placeholder="{trans("Subject")}" onChange="document.filter.submit();">
            </label>
            <label class="nobr">
                {trans("Created")}
                <input type="text" name="fromdate" SIZE="14" maxlength="16" value="{if $filter.fromdate}{$filter.fromdate|date_format:"Y/m/d H:i"}{/if}"
                    placeholder="{trans("yyyy/mm/dd hh:mm")}"
                    {tip class="lms-ui-datetime"} onChange="document.filter.submit();">
                <input type="text" name="todate" size="14" maxlength="16" value="{if $filter.todate}{$filter.todate|date_format:"Y/m/d H:i"}{/if}"
                    placeholder="{trans("yyyy/mm/dd hh:mm")}"
                    {tip class="lms-ui-datetime"} onChange="document.filter.submit();">
            </label>
            <label class="nobr">
                {trans("Watched tickets")}
                <SELECT size="1" name="watching" onChange="document.filter.submit()">
                    <option value="-1"{if $filter.watching == -1} selected{/if}>{trans("no")}</option>
                    <option value="1"{if $filter.watching == 1} selected{/if}>{trans("yes")}</option>
                </SELECT>
            </label>
        </FORM>
        </div>
        {persistent_filter}
        </div>
    </TD>
</TR>
{/block}
