{% if id or classname %}
	{# if given an id or classname then we want a wrapper #}
	<div {% if id %}id="{{ id }}"{% endif %} class="{{ classname }}" style="display:none">
	<div class="row">
		<div class="term">
			<table cellpadding="0" cellspacing="0" width="100%" border="0" class="term-table"><tbody><tr>
				<td style="vertical-align: middle; text-align: center;" width="11"><div class="builder-remove">-</div></td>
				<td class="builder-controls" style="vertical-align: middle;">
					<table cellpadding="0" cellspacing="0" width="100%" border="0"><tbody><tr>
						<td style="vertical-align: middle;" width="10" nowrap="nowrap"><div class="builder-type-choice"></div></td>
						<td style="vertical-align: middle;" width="10" nowrap="nowrap"><div class="builder-op"></div></td>
						<td style="vertical-align: middle;"><div class="builder-options"></div></td>
					</tr></tbody></table>
				</td>
			</tr></tbody></table>
		</div>
	</div>
	<div class="builder-type-choice" title="{{ phrase('agent.general.choose_criteria') }}" data-rule-type="">
	</div>
{% endif %}

	{% if 'action_performer' not in no_show_fields and 0 %}
		<div class="builder-type" title="{{ phrase('agent.general.performer') }}" data-rule-type="action_performer">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
				</select>
			</div>
			<div class="builder-options">
				<select name="action_performer">
					<option value="agent">{{ phrase('agent.general.agent') }}</option>
					<option value="person">{{ phrase('agent.general.user') }}</option>
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'is_new_user' not in no_show_fields and 'new_ticket' in event_group %}
	<div class="builder-type" title="{{ phrase('agent.general.is_a_new_user') }}" data-rule-type="is_new_user">
		<div class="builder-op">
			<input type="hidden" name="op" value="is" />
		</div>
		<div class="builder-options">
			<input type="hidden" name="is_new_user" value="1" />
		</div>
	</div>
	<div class="builder-type" title="{{ phrase('agent.general.is_not_a_new_user') }}" data-rule-type="is_not_new_user">
		<div class="builder-op">
			<input type="hidden" name="op" value="is" />
		</div>
		<div class="builder-options">
			<input type="hidden" name="is_not_new_user" value="1" />
		</div>
	</div>
	{% endif %}

	{% if 'new_ticket.gateway_person' in event_group %}
		<div class="builder-type" title="{{ phrase('agent.general.to_address') }}" data-rule-type="to_address">
			<div class="builder-op">
				<input type="hidden" name="op" value="is" />
			</div>
			<div class="builder-options">
				<input type="text" name="to_address" value="" />
			</div>
		</div>
		<div class="builder-type" title="{{ phrase('agent.general.cc_address') }}" data-rule-type="cc_address">
			<div class="builder-op">
				<input type="hidden" name="op" value="is" />
			</div>
			<div class="builder-options">
				<input type="text" name="cc_address" value="" />
			</div>
		</div>
	{% endif %}

	{% if 'creation_system' not in no_show_fields and 'new_ticket' not in event_group %}
	<div class="builder-type" title="{{ phrase('agent.general.originated_interface') }}" data-rule-type="creation_system" data-term-type="GenericMenuTerm" data-term-triggers="interface,orig-interface,original-interface">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
			</select>
		</div>
		<div class="builder-options">
			<select name="creation_system">
				<option value="web">{{ phrase('agent.general.web_interface') }}</option>
				<option value="web.person">-- {{ phrase('agent.general.by_user') }}</option>
				<option value="widget.person">{{ phrase('agent.general.website_widget') }}</option>
				<option value="web.agent">-- {{ phrase('agent.general.by_agent_for_user') }}</option>
				<option value="gateway.person">{{ phrase('agent.general.email') }}</option>
			</select>
		</div>
	</div>
	{% endif %}

	{% if 'gateway_address' not in no_show_fields and term_options.gateway_addresses %}
		<div class="builder-type" title="{{ phrase('agent.general.ticket_gateway_address') }}" data-rule-type="gateway_address" data-term-type="GenericMenuTerm" data-term-triggers="gateway,address,gateway_address">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
				</select>
			</div>
			<div class="builder-options">
				<select name="gateway_address">
					{% for id,addr in term_options.gateway_addresses %}
						<option value="{{ id }}">{{ addr }}</option>
					{% endfor %}
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'gateway_account' not in no_show_fields and term_options.gateway_accounts %}
		<div class="builder-type" title="{{ phrase('agent.general.ticket_gateway_account') }}" data-rule-type="gateway_account" data-term-type="GenericMenuTerm" data-term-triggers="gateway,account,gateway_account">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
				</select>
			</div>
			<div class="builder-options">
				<select name="gateway_account">
					{% for id,name in term_options.gateway_accounts %}
					<option value="{{ id }}">{{ name }}</option>
					{% endfor %}
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'subject' not in no_show_fields %}
	<div class="builder-type" title="{{ phrase('agent.general.subject') }}" data-rule-type="subject">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="contains">{{ phrase('agent.general.contains') }}</option>
				<option value="not_contains">{{ phrase('agent.general.does_not_contain') }}</option>
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
			</select>
		</div>
		<div class="builder-options">
			<input type="text" name="subject" value="" />
		</div>
	</div>
	{% endif %}

	{% if 'sent_to_address' not in no_show_fields and 'new_ticket' in event_group %}
	<div class="builder-type" title="Ticket sent in to address" data-rule-type="sent_to_address">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
				<option value="contains">{{ phrase('agent.general.contains') }}</option>
				<option value="not_contains">{{ phrase('agent.general.does_not_contain') }}</option>
			</select>
		</div>
		<div class="builder-options">
			<input type="text" name="sent_to_address" value="" />
		</div>
	</div>
	{% endif %}

	{% if 'department' not in no_show_fields and app.departments.getPersonDepartments(app.user, 'tickets') %}
		<div class="builder-type" title="{{ phrase('agent.general.department') }}" data-rule-type="department" data-term-type="GenericMenuTerm" data-term-triggers="dep,department">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
					{% if with_change_terms %}
						<option value="changed">{{ phrase('agent.general.changed') }}</option>
						<option value="changed_to">{{ phrase('agent.general.changed_to') }}</option>
						<option value="changed_from">{{ phrase('agent.general.changed_from') }}</option>
						<option value="not_changed_to">{{ phrase('agent.general.not_changed_to') }}</option>
						<option value="not_changed_from">{{ phrase('agent.general.not_changed_from') }}</option>
					{% endif %}
				</select>
			</div>
			<div class="builder-options">
				<select name="department[]" multiple="multiple">
					{% for dep in app.departments.getPersonDepartments(app.user, 'tickets') %}
						{% if dep.children|length %}
							<optgroup label="{{ dep.title }}">
								{% for subdep in dep.children %}
									<option data-full-title="{{ dep.title }} &gt; {{ subdep.title }}" value="{{subdep.id}}">{{subdep.title}}</option>
								{% endfor %}
							</optgroup>
						{% else %}
							<option value="{{dep.id}}">{{dep.title}}</option>
						{% endif %}
					{% endfor %}
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'agent' not in no_show_fields and (not event_trigger or event_trigger != 'new_ticket') %}
	<div class="builder-type" title="{{ phrase('agent.general.assigned_agent') }}" data-rule-type="agent" data-term-type="GenericMenuTerm" data-term-triggers="agent">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
				{% if with_change_terms %}
					<option value="changed">{{ phrase('agent.general.changed') }}</option>
					<option value="changed_to">{{ phrase('agent.general.changed_to') }}</option>
					<option value="changed_from">{{ phrase('agent.general.changed_from') }}</option>
					<option value="not_changed_to">{{ phrase('agent.general.not_changed_to') }}</option>
					<option value="not_changed_from">{{ phrase('agent.general.not_changed_from') }}</option>
				{% endif %}
			</select>
		</div>
		<div class="builder-options">
			<select name="agent[]" multiple="multiple">
				<option value="0">{{ phrase('agent.general.unassigned') }}</option>
				<option value="-1">Me</option>
				<optgroup label="Agents">
					{% for id,label in term_options.agents %}
						<option value="{{id}}">{{label}}</option>
					{% endfor %}
				</optgroup>
			</select>
		</div>
	</div>
	{% endif %}

	{% if app.agent_teams.getTeamNames() and 'agent_team' not in no_show_fields and (not event_trigger or event_trigger != 'new_ticket') %}
		<div class="builder-type" title="{{ phrase('agent.general.agent_team') }}" data-rule-type="agent_team" data-term-type="GenericMenuTerm" data-term-triggers="team,agent-team">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
					{% if with_change_terms %}
						<option value="changed">{{ phrase('agent.general.changed') }}</option>
						<option value="changed_to">{{ phrase('agent.general.changed_to') }}</option>
						<option value="changed_from">{{ phrase('agent.general.changed_from') }}</option>
						<option value="not_changed_to">{{ phrase('agent.general.not_changed_to') }}</option>
						<option value="not_changed_from">{{ phrase('agent.general.not_changed_from') }}</option>
					{% endif %}
				</select>
			</div>
			<div class="builder-options">
				<select name="agent_team[]" multiple="multiple">
					<option value="0">{{ phrase('agent.general.no_team') }}</option>
					<option value="-1">Any of my teams</option>
					<optgroup label="Teams">
						{% for id,title in app.agent_teams.getTeamNames() %}
							<option value="{{id}}">{{title}}</option>
						{% endfor %}
					</optgroup>
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'participant' not in no_show_fields and (not event_trigger or event_trigger != 'new_ticket') %}
	<div class="builder-type" title="{{ phrase('agent.general.followers') }}" data-rule-type="participant" data-term-type="GenericMenuTerm" data-term-triggers="followers">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="is">{{ phrase('agent.general.include') }}</option>
				<option value="not">{{ phrase('agent.general.does_not_include') }}</option>
				{% if with_change_terms %}
					<option value="changed">{{ phrase('agent.general.changed') }}</option>
					<option value="changed_to">{{ phrase('agent.general.changed_to_include') }}</option>
					<option value="changed_from">{{ phrase('agent.general.changed_to_remove') }}</option>
				{% endif %}
			</select>
		</div>
		<div class="builder-options">
			<select name="agent">
				<option value="-1">{{ phrase('agent.general.current_agent') }}</option>
				{% for id,label in term_options.agents %}
					<option value="{{id}}">{{label}}</option>
				{% endfor %}
			</select>
		</div>
	</div>
	{% endif %}

	{% if 'label' not in no_show_fields and not event_trigger or event_trigger != 'new_ticket' %}
	<div class="builder-type" title="{{ phrase('agent.general.labels') }}" data-rule-type="label" data-rule-handler="DeskPRO.Agent.RuleBuilder.LabelsTerm" data-label-type="tickets" data-term-type="GenericInputTerm" data-term-triggers="label,labelled,labels">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
				{% if with_change_terms %}
					<option value="changed">{{ phrase('agent.general.changed') }}</option>
					<option value="changed_to">{{ phrase('agent.general.changed_to_include') }}</option>
					<option value="changed_from">{{ phrase('agent.general.changed_to_remove') }}</option>
				{% endif %}
			</select>
		</div>
		<div class="builder-options">
			{% include 'DeskPRO:Common:rulebuilder-labels-options.html.twig' %}
		</div>
	</div>
	{% endif  %}

	{% if 'status' not in no_show_fields %}
	<div class="builder-type" title="{{ phrase('agent.general.status') }}" data-rule-type="status" data-term-type="GenericMenuTerm" data-term-triggers="status">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
				{% if with_change_terms %}
					<option value="changed">{{ phrase('agent.general.changed') }}</option>
					<option value="changed_to">{{ phrase('agent.general.changed_to') }}</option>
					<option value="changed_from">{{ phrase('agent.general.changed_from') }}</option>
					<option value="not_changed_to">{{ phrase('agent.general.not_changed_to') }}</option>
					<option value="not_changed_from">{{ phrase('agent.general.not_changed_from') }}</option>
				{% endif %}
			</select>
		</div>
		<div class="builder-options">
			<select name="status[]" multiple="multiple">
				<option value="awaiting_agent">{{ phrase('agent.tickets.status_awaiting_agent') }}</option>
				<option value="awaiting_user">{{ phrase('agent.tickets.status_awaiting_user') }}</option>
				<option value="resolved">{{ phrase('agent.tickets.status_resolved') }}</option>
				{% if search_context != 'filter' %}
					<option value="closed">{{ phrase('agent.tickets.status_closed') }}</option>
					<optgroup label="Hidden Tickets">
						<option value="hidden">Any Hidden Ticket</option>
						<option value="hidden.deleted">Deleted</option>
						<option value="hidden.spam">Spam</option>
						<option value="hidden.validating">Validating</option>
					</optgroup>
				{% endif %}
			</select>
		</div>
	</div>

	<div class="builder-type" title="Ticket is on hold" data-rule-type="is_hold" data-term-type="GenericMenuTerm" data-term-triggers="is_hold">
		<div class="builder-op">
			<input type="hidden" name="op" value="is" />
		</div>
		<div class="builder-options">
			<input type="hidden" name="is_hold" value="1" />
		</div>
	</div>
	{% endif %}

	{% if 'organization' not in no_show_fields and app.getDataService('Organization').getOrganizationNames() %}
	<div class="builder-type" title="{{ phrase('agent.general.organization') }}" data-term-type="GenericMenuTerm" data-term-triggers="org,organization,company" data-rule-type="organization">
		<div class="builder-op">
			<select name="op">
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
			</select>
		</div>
		<div class="builder-options">
			<input type="text" class="select2" name="organization"
				data-multiple="true"
				data-autocomplete-url="{{ organization_autocomplete_path ? organization_autocomplete_path : path('agent_orgsearch_quicknamesearch') }}"
				data-select-width="auto"
			/>
		</div>
	</div>
	{% endif %}

	{% if 'product' not in no_show_fields and term_options.products %}
		<div class="builder-type" title="{{ phrase('agent.general.product') }}" data-rule-type="product" data-term-type="GenericMenuTerm" data-term-triggers="prod,product">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
					{% if with_change_terms %}
						<option value="changed">{{ phrase('agent.general.changed') }}</option>
						<option value="changed_to">{{ phrase('agent.general.changed_to') }}</option>
						<option value="changed_from">{{ phrase('agent.general.changed_from') }}</option>
						<option value="not_changed_to">{{ phrase('agent.general.not_changed_to') }}</option>
						<option value="not_changed_from">{{ phrase('agent.general.not_changed_from') }}</option>
					{% endif %}
				</select>
			</div>
			<div class="builder-options">
				<select name="product">
					<option value="0">None</option>
					{% for id,label in term_options.products %}
						<option value="{{id}}">{{label}}</option>
					{% endfor %}
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'category' not in no_show_fields and term_options.ticket_categories %}
		<div class="builder-type" title="{{ phrase('agent.general.category') }}" data-rule-type="category" data-term-type="GenericMenuTerm" data-term-triggers="cat,category">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
					{% if with_change_terms %}
						<option value="changed">{{ phrase('agent.general.changed') }}</option>
						<option value="changed_to">{{ phrase('agent.general.changed_to') }}</option>
						<option value="changed_from">{{ phrase('agent.general.changed_from') }}</option>
						<option value="not_changed_to">{{ phrase('agent.general.not_changed_to') }}</option>
						<option value="not_changed_from">{{ phrase('agent.general.not_changed_from') }}</option>
					{% endif %}
				</select>
			</div>
			<div class="builder-options">
				<select name="category">
					<option value="0">None</option>
					{% for id,label in term_options.ticket_categories %}
						<option value="{{id}}">{{label}}</option>
					{% endfor %}
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'urgency' not in no_show_fields %}
	<div class="builder-type" title="{{ phrase('agent.general.urgency') }}" data-rule-type="urgency" data-term-type="GenericInputTerm" data-term-triggers="urgency">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="gte">&gt;=</option>
				<option value="lte">&lt;=</option>
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
				{% if with_change_terms %}
					<optgroup label="{{ phrase('agent.general.changed') }}">
						<option value="changed">{{ phrase('agent.general.changed') }}</option>
						<option value="changed_to">{{ phrase('agent.general.changed_to') }}</option>
						<option value="changed_from">{{ phrase('agent.general.changed_from') }}</option>
						<option value="not_changed_to">{{ phrase('agent.general.not_changed_to') }}</option>
						<option value="not_changed_from">{{ phrase('agent.general.not_changed_from') }}</option>
					</optgroup>
					<optgroup label="Changed (ranged)">
						<option value="changed_to_gte">Changed to &gt;=</option>
						<option value="changed_to_lte">Changed to &lt;=</option>
						<option value="changed_from_gte">Changed from &gt;=</option>
						<option value="changed_from_lte">Changed from &lt;=</option>
						<option value="not_changed_to_gte">Not changed to &gt;=</option>
						<option value="not_changed_from_lte">Not changed from &lt;=</option>
					</optgroup>
				{% endif %}
			</select>
		</div>
		<div class="builder-options">
			<input type="text" size="4" value="" name="num" />
		</div>
	</div>
	{% endif %}

	{% if 'priority' not in no_show_fields and term_options.priorities %}
		<div class="builder-type" title="{{ phrase('agent.general.priority') }}" data-rule-type="priority" data-term-type="GenericMenuTerm" data-term-triggers="pri,priority">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
					<option value="lte">{{ phrase('agent.general.is_less_than') }}</option>
					<option value="gte">{{ phrase('agent.general.is_greater_than') }}</option>
					{% if with_change_terms %}
						<option value="changed">{{ phrase('agent.general.changed') }}</option>
						<option value="changed_to">{{ phrase('agent.general.changed_to') }}</option>
						<option value="changed_from">{{ phrase('agent.general.changed_from') }}</option>
						<option value="not_changed_to">{{ phrase('agent.general.not_changed_to') }}</option>
						<option value="not_changed_from">{{ phrase('agent.general.not_changed_from') }}</option>
					{% endif %}
				</select>
			</div>
			<div class="builder-options">
				<select name="priority">
					<option value="0">None</option>
					{% for id,label in term_options.priorities %}
						<option value="{{id}}">{{label}}</option>
					{% endfor %}
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'workflow' not in no_show_fields and term_options.ticket_workflows %}
		<div class="builder-type" title="{{ phrase('agent.general.workflow') }}" data-rule-type="workflow" data-term-type="GenericMenuTerm" data-term-triggers="work,workflow">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
					{% if with_change_terms %}
						<option value="changed">{{ phrase('agent.general.changed') }}</option>
						<option value="changed_to">{{ phrase('agent.general.changed_to') }}</option>
						<option value="changed_from">{{ phrase('agent.general.changed_from') }}</option>
						<option value="not_changed_to">{{ phrase('agent.general.not_changed_to') }}</option>
						<option value="not_changed_from">{{ phrase('agent.general.not_changed_from') }}</option>
					{% endif %}
				</select>
			</div>
			<div class="builder-options">
				<select name="workflow[]" multiple="multiple">
					<option value="0">None</option>
					{% for id,label in term_options.ticket_workflows %}
						<option value="{{id}}">{{label}}</option>
					{% endfor %}
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'language' not in no_show_fields and term_options.languages %}
	<div class="builder-type" title="{{ phrase('agent.general.language') }}" data-term-type="GenericMenuTerm" data-rule-type="language" data-term-triggers="lang,language">
		<div class="builder-op">
			<select name="op">
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
			</select>
		</div>
		<div class="builder-options">
			<select name="language">
				<option value="0">None</option>
				{% for id,title in term_options.languages %}
				<option value="{{id}}">{{title}}</option>
				{% endfor %}
			</select>
		</div>
	</div>
	{% endif %}

{% if term_options.slas %}
	{% if 'sla' not in no_show_fields %}
		<div class="builder-type" title="SLA" data-rule-type="sla" data-term-type="GenericMenuTerm" data-term-triggers="sla">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
				</select>
			</div>
			<div class="builder-options">
				<select name="sla_id">
					{% for id,title in term_options.slas %}
						<option value="{{ id }}">{{ title }}</option>
					{% endfor %}
				</select>
			</div>
		</div>
	{% endif %}

	{% if 'sla_status' not in no_show_fields %}
		<div class="builder-type" title="SLA Status" data-rule-type="sla_status" data-term-type="GenericMenuTerm" data-term-triggers="sla_status,slastatus">
			<div class="builder-op">
				<select name="op" class="op">
					<option value="is">{{ phrase('agent.general.is') }}</option>
					<option value="not">{{ phrase('agent.general.is_not') }}</option>
				</select>
			</div>
			<div class="builder-options">
				<select name="sla_status">
					<option value="ok">OK</option>
					<option value="warn">Warning</option>
					<option value="fail">Fail</option>
				</select>
				for SLA
				<select name="sla_id">
					<option value="0">Any</option>
				{% for id,title in term_options.slas %}
					<option value="{{id}}">{{title}}</option>
				{% endfor %}
				</select>
			</div>
		</div>
	{% endif %}
{% endif %}

	<div class="builder-type" title="User Waiting Time" data-rule-type="user_waiting">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="gte">{{ phrase('agent.general.is_greater_than') }}</option>
				<option value="lte">{{ phrase('agent.general.is_less_than') }}</option>
			</select>
		</div>
		<div class="builder-options">
			<input type="text" name="waiting_time" value="" style="width:50px" />
			<select name="waiting_time_unit">
				{% for scale,label in {'minutes': phrase('admin.tickets.minutes'), 'hours': phrase('admin.tickets.hours'), 'days': phrase('admin.tickets.days'), 'weeks': phrase('admin.tickets.weeks'), 'months': phrase('admin.tickets.months')} %}
					<option value="{{ scale }}">{{ label }}</option>
				{% endfor %}
			</select>
		</div>
	</div>

	<div class="builder-type" title="User Total Waiting Time" data-rule-type="total_user_waiting">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="lte">{{ phrase('agent.general.is_less_than') }}</option>
				<option value="gte">{{ phrase('agent.general.is_greater_than') }}</option>
			</select>
		</div>
		<div class="builder-options">
			<input type="text" name="waiting_time" value="" style="width:50px" />
			<select name="waiting_time_unit">
				{% for scale,label in {'minutes': phrase('admin.tickets.minutes'), 'hours': phrase('admin.tickets.hours'), 'days': phrase('admin.tickets.days'), 'weeks': phrase('admin.tickets.weeks'), 'months': phrase('admin.tickets.months')} %}
					<option value="{{ scale }}">{{ label }}</option>
				{% endfor %}
			</select>
		</div>
	</div>

	{% if 'date_created' not in no_show_fields and (not event_trigger or event_trigger != 'new_ticket') %}
	<div class="builder-type" title="{{ phrase('agent.general.date_created') }}" data-rule-type="date_created" data-rule-handler="DeskPRO.Agent.RuleBuilder.DateTerm" data-term-type="GenericDateTerm" data-term-triggers="date-created">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="lte">{{ phrase('agent.general.before') }}</option>
				<option value="gte">{{ phrase('agent.general.after') }}</option>
				<option value="between">{{ phrase('agent.general.between') }}</option>
			</select>
		</div>
		<div class="builder-options">
			{% include 'DeskPRO:Common:rulebuilder-date-options.html.twig' %}
		</div>
	</div>
	{% endif %}

	{% if search_context != 'filter' %}
    {% if 'time_created' not in no_show_fields and (not event_trigger or event_trigger != 'new_ticket') %}
    <div class="builder-type" title="{{ phrase('agent.general.time_created') }}" data-rule-type="time_created">
        <div class="builder-op">
            <select name="op" class="op">
                <option value="before">{{ phrase('agent.general.before') }}</option>
                <option value="after">{{ phrase('agent.general.after') }}</option>
            </select>
        </div>
        <div class="builder-options">
            <label>{{ phrase('agent.general.hour') }}</label>
            <select name="hour1">
                {% for hour in range(0,23) %}
                <option>{{ '%02s'|format(hour) }}</option>
                {% endfor %}
            </select>
            <label>{{ phrase('agent.general.minute') }}</label>
            <select name="minute1">
                {% for minute in range(0,59) %}
                <option>{{ '%02s'|format(minute) }}</option>
                {% endfor %}
            </select>
        </div>
    </div>
    {% endif %}
    {% endif %}

	{% if search_context != 'filter' %}
    {% if 'time_user_reply' not in no_show_fields and (not event_trigger or event_trigger != 'new_ticket') %}
    <div class="builder-type" title="{{ phrase('agent.general.time_of_last_user_reply') }}" data-rule-type="time_user_replied">
        <div class="builder-op">
            <select name="op" class="op">
                <option value="before">{{ phrase('agent.general.before') }}</option>
                <option value="after">{{ phrase('agent.general.after') }}</option>
            </select>
        </div>
        <div class="builder-options">
            <label>{{ phrase('agent.general.hour') }}</label>
            <select name="hour1">
                {% for hour in range(0,23) %}
                <option>{{ '%02s'|format(hour) }}</option>
                {% endfor %}
            </select>
            <label>{{ phrase('agent.general.minute') }}</label>
            <select name="minute1">
                {% for minute in range(0,59) %}
                <option>{{ '%02s'|format(minute) }}</option>
                {% endfor %}
            </select>
        </div>
    </div>
    {% endif %}
    {% endif %}

	{% if search_context != 'filter' %}
    {% if 'day_created' not in no_show_fields and (not event_trigger or event_trigger != 'new_ticket') %}
    <div class="builder-type" title="Week Day" data-rule-type="day_created">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="is">{{ phrase('agent.general.is') }}</option>
				<option value="not">{{ phrase('agent.general.is_not') }}</option>
			</select>
		</div>
		<div class="builder-options">
			{% set days = {
				1: 'Monday',
				2: 'Tuesday',
				3: 'Wednesday',
				4: 'Thursday',
				5: 'Friday',
				6: 'Saturday',
				0: 'Sunday'
			} %}
			<select name="days[]" multiple="multiple">
				{% for day,name in days %}
				<option value="{{ day }}">{{ name }}</option>
				{% endfor %}
			</select>
		</div>
	</div>
    {% endif %}
	{% endif %}

	{% if search_context != 'filter' %}
    {% if 'day_last_user_reply' not in no_show_fields and (not event_trigger or event_trigger != 'new_ticket') %}
    <div class="builder-type" title="{{ phrase('agent.general.day_last_user_reply') }}" data-rule-type="day_last_user_reply">
        <div class="builder-op">
            <select name="op" class="op">
                <option value="is">{{ phrase('agent.general.is') }}</option>
                <option value="not">{{ phrase('agent.general.is_not') }}</option>
            </select>
        </div>
        <div class="builder-options">
            {% set days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] %}
            {% for day in days %}
                <label>{{ day }}</label>
                <input type="checkbox" value="{{ day }}" name="days[]"/>
            {% endfor %}
        </div>
    </div>
    {% endif %}
	{% endif %}

	{% if 'date_resolved' not in no_show_fields and (not event_trigger or event_trigger == 'time_resolved') %}
	<div class="builder-type" title="{{ phrase('agent.general.date_resolved') }}" data-rule-type="date_resolved" data-rule-handler="DeskPRO.Agent.RuleBuilder.DateTerm" data-term-triggers="date-resolved">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="lte">{{ phrase('agent.general.before') }}</option>
				<option value="gte">{{ phrase('agent.general.after') }}</option>
				<option value="between">{{ phrase('agent.general.between') }}</option>
			</select>
		</div>
		<div class="builder-options">
			{% include 'DeskPRO:Common:rulebuilder-date-options.html.twig' %}
		</div>
	</div>
	{% endif %}

	{% if 'date_closed' not in no_show_fields and not event_trigger %}
	<div class="builder-type" title="{{ phrase('agent.general.date_closed') }}" data-rule-type="date_closed" data-rule-handler="DeskPRO.Agent.RuleBuilder.DateTerm">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="lte">{{ phrase('agent.general.before') }}</option>
				<option value="gte">{{ phrase('agent.general.after') }}</option>
				<option value="between">{{ phrase('agent.general.between') }}</option>
			</select>
		</div>
		<div class="builder-options">
			{% include 'DeskPRO:Common:rulebuilder-date-options.html.twig' %}
		</div>
	</div>
	{% endif %}

	{% if 'date_last_agent_reply' not in no_show_fields and (not event_trigger or event_trigger != 'new_ticket') %}
	<div class="builder-type" title="{{ phrase('agent.general.date_of_last_agent_reply') }}" data-rule-type="date_last_agent_reply" data-rule-handler="DeskPRO.Agent.RuleBuilder.DateTerm">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="lte">{{ phrase('agent.general.before') }}</option>
				<option value="gte">{{ phrase('agent.general.after') }}</option>
				<option value="between">{{ phrase('agent.general.between') }}</option>
			</select>
		</div>
		<div class="builder-options">
			{% include 'DeskPRO:Common:rulebuilder-date-options.html.twig' %}
		</div>
	</div>
	{% endif %}

	{% if 'date_last_user_reply' not in no_show_fields %}
	<div class="builder-type" title="{{ phrase('agent.general.date_of_last_user_reply') }}" data-rule-type="date_last_user_reply" data-rule-handler="DeskPRO.Agent.RuleBuilder.DateTerm">
		<div class="builder-op">
			<select name="op" class="op">
				<option value="lte">{{ phrase('agent.general.before') }}</option>
				<option value="gte">{{ phrase('agent.general.after') }}</option>
				<option value="between">{{ phrase('agent.general.between') }}</option>
			</select>
		</div>
		<div class="builder-options">
			{% include 'DeskPRO:Common:rulebuilder-date-options.html.twig' %}
		</div>
	</div>
	{% endif %}

	{% if 'robot_email' not in no_show_fields and event_trigger == 'new_ticket' or event_trigger == 'new_reply'  %}
	<div class="builder-type" title="{{ phrase('agent.general.email_sent_by_robot') }}" data-rule-type="robot_email">
		<div class="builder-op">
			<input type="hidden" name="op" value="is" />
		</div>
		<div class="builder-options">
			<input type="hidden" name="is_robot_email" value="1" />
		</div>
	</div>
	{% endif %}

	{% if 'ticket_field' not in no_show_fields and app.getTicketFieldManager().getFields() %}
		{% set op_lang = {'is': phrase('agent.general.is'), 'not': phrase('agent.general.is_not'), 'contains': phrase('agent.general.contains'), 'notcontains': phrase('agent.general.does_not_contain'), 'gt': phrase('agent.general.is_greater_than'), 'lt': phrase('agent.general.is_less_than') } %}
		{% for field in app.getTicketFieldManager().getDisplayArray() %}
			{% if field.field_def.getFilterCapabilities(search_context) %}
			<div class="builder-type" title="{{field.field_def.title}}" data-rule-group="Ticket Fields" data-rule-type="ticket_field[{{field.field_def.id}}]">
				<div class="builder-op">
					<select name="op" class="op">
						{% if search_context == 'filter' %}
							{% for op in field.field_def.getFilterCapabilities(search_context) %}
								<option value="{{op}}">{{op_lang[op]}}</option>
							{% endfor %}
						{% else %}
							{% for op in field.field_def.getSearchCapabilities(search_context) %}
								<option value="{{op}}">{{op_lang[op]}}</option>
							{% endfor %}
						{% endif %}
					</select>
				</div>
				<div class="builder-options">
					{{ form_widget(field.formViewCriteria) }}
				</div>
			</div>
			{% endif %}
		{% endfor %}
	{% endif %}

	{% if 'person' not in no_show_fields %}
		{% include 'DeskPRO:Common:people-search-criteria.html.twig' with {'with_rule_group': true, 'term_options': people_term_options, 'id': false, 'classname': false} %}
	{% endif %}

	{% if 'org' not in no_show_fields %}
		{% include 'DeskPRO:Common:org-search-criteria.html.twig' with {'with_rule_group': true, 'term_options': people_term_options, 'id': false, 'classname': false} %}
	{% endif %}

{% if id or classname %}
</div>
{% endif %}
