<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=UntouchedInBusinessHours</id>
	<title>UntouchedInBusinessHours - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=UntouchedInBusinessHours"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=UntouchedInBusinessHours&amp;action=history"/>
	<updated>2026-08-23T22:03:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=UntouchedInBusinessHours&amp;diff=26464&amp;oldid=prev</id>
		<title>Barton: /* Crontab Entries -- reformat */</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=UntouchedInBusinessHours&amp;diff=26464&amp;oldid=prev"/>
		<updated>2017-01-08T19:19:16Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Crontab Entries -- reformat&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:19, 8 January 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l15&quot;&gt;Line 15:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 15:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Crontab Entries ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Crontab Entries ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &amp;lt;nowiki&amp;gt;&lt;/del&gt;*/15 7-15 * * * /opt/rt3/bin/rt-crontool&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;*/15 7-15 * * * /opt/rt3/bin/rt-crontool&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;--search RT::Search::FromSQL&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;--search RT::Search::FromSQL&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;--search-arg &quot;Queue = &#039;ChangeManagement&#039; AND Status = &#039;new&#039; AND Owner = &#039;Nobody&#039; AND CF.Escalation = &#039;InTime&#039;&quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;--search-arg &quot;Queue = &#039;ChangeManagement&#039; AND Status = &#039;new&#039; AND Owner = &#039;Nobody&#039; AND CF.Escalation = &#039;InTime&#039;&quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;--condition RT::Condition::UntouchedInBusinessHours&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;--condition RT::Condition::UntouchedInBusinessHours&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;--condition-arg 8:7:15:0&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;--condition-arg 8:7:15:0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;--action RT::Action::RecordComment&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;--action RT::Action::RecordComment&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/del&gt;--template &#039;esc 1 - 8Std FirstContact&#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;    &lt;/ins&gt;--template &#039;esc 1 - 8Std FirstContact&#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &amp;lt;/nowiki&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Queue Preparation ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Queue Preparation ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key bestpractical_mediawiki1459887241:diff:1.41:old-4041:rev-26464:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Barton</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=UntouchedInBusinessHours&amp;diff=4041&amp;oldid=prev</id>
		<title>Admin: 3 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=UntouchedInBusinessHours&amp;diff=4041&amp;oldid=prev"/>
		<updated>2016-04-06T20:39:37Z</updated>

		<summary type="html">&lt;p&gt;3 revisions imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= UntouchedInBusinessHours =&lt;br /&gt;
&lt;br /&gt;
Based on the Modul/Condition [[UntouchedInHours]] and the Ideas from [[TimedNotifications]] we created a new Condition called [[UntouchedInBusinessHours]].&lt;br /&gt;
&lt;br /&gt;
Compared to [[UntouchedInHours]] we calculate within this module based on the Create Time of the Ticket and not on [[LastUpdated]] and also only within a definable Business Hours Range.&lt;br /&gt;
&lt;br /&gt;
== Problem Scenario ==&lt;br /&gt;
&lt;br /&gt;
We needed in some Change Request Queues some kind of escalation mixed with notifications based on given business hours model. This escalation should be done in two steps, first escalation should inform head of the queue and raise the ticket priority and second should inform head of IT and raise the priority again.&lt;br /&gt;
&lt;br /&gt;
== Solution ==&lt;br /&gt;
&lt;br /&gt;
As solution for this setup we found a mixture of rtcrontool / cron, [[UntouchedInHours]] and [[TimedNotifications]].&lt;br /&gt;
&lt;br /&gt;
=== Crontab Entries ===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;*/15 7-15 * * * /opt/rt3/bin/rt-crontool&lt;br /&gt;
 --search RT::Search::FromSQL&lt;br /&gt;
 --search-arg &amp;quot;Queue = &amp;#039;ChangeManagement&amp;#039; AND Status = &amp;#039;new&amp;#039; AND Owner = &amp;#039;Nobody&amp;#039; AND CF.Escalation = &amp;#039;InTime&amp;#039;&amp;quot;&lt;br /&gt;
 --condition RT::Condition::UntouchedInBusinessHours&lt;br /&gt;
 --condition-arg 8:7:15:0&lt;br /&gt;
 --action RT::Action::RecordComment&lt;br /&gt;
 --template &amp;#039;esc 1 - 8Std FirstContact&amp;#039;&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Queue Preparation ===&lt;br /&gt;
&lt;br /&gt;
To make sure to escalate in the correct order, we added to each change queue a [[CustomField]] and a Custom Scrip&lt;br /&gt;
&lt;br /&gt;
==== CustomFields ====&lt;br /&gt;
&lt;br /&gt;
For each Change Queue we added a [[CustomField]] Escalation which will be filled at ticket creation with the Value &amp;quot;[[InTime]]&amp;quot; and updated after first escalation with the Value &amp;quot;[[FirstEscalation]]&amp;quot; and after second escalation with the value &amp;quot;[[SecondEscalation]]&amp;quot; This values are used inside the search as additional Search Argument.&lt;br /&gt;
&lt;br /&gt;
==== Custom Scrip ====&lt;br /&gt;
&lt;br /&gt;
We added to all change queues a simple scrip which set the CF Escalation at ticket create time to &amp;quot;[[InTime]]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Scrip: 001_[[OnCreateSetEscalationCF]]&lt;br /&gt;
&lt;br /&gt;
Condition: [[OnCreate]] Action: [[UserDefined]] Template: Blank&lt;br /&gt;
&lt;br /&gt;
Custom action preparation code:&lt;br /&gt;
&lt;br /&gt;
return 1;&lt;br /&gt;
&lt;br /&gt;
Custom action cleanup code:&lt;br /&gt;
&lt;br /&gt;
$self-&amp;amp;gt;[[TicketObj]]-&amp;amp;gt;[[AddCustomFieldValue]](Field =&amp;amp;gt; &amp;#039;Escalation&amp;#039;, Value =&amp;amp;gt; &amp;#039;[[InTime]]&amp;#039;, [[RecordTransaction]] =&amp;amp;gt; 0); return 1;&lt;br /&gt;
&lt;br /&gt;
==== Templates ====&lt;br /&gt;
&lt;br /&gt;
Based on the ideas from we create some templates for the escalation, which will sent out a mail and raise the priority by 10 and update the [[CustomField]] &amp;quot;Escalation&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Template: esc 1 - 8Std [[FirstContact]]&lt;br /&gt;
&lt;br /&gt;
Subject: Escalation 1 for Ticket #: {$Ticket-&amp;amp;gt;id} - {$Ticket-&amp;amp;gt;Subject()}!&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;RT-Send-Cc: head1@company.com&lt;br /&gt;
 &lt;br /&gt;
 Hello,&lt;br /&gt;
 &lt;br /&gt;
 this is an automated Escalation Mail from the Request Tracker.&lt;br /&gt;
 &lt;br /&gt;
 !!!! FIRST ESCALATION !!!!&lt;br /&gt;
 &lt;br /&gt;
 The following Change Request is older than 8 hours without being attended to.&lt;br /&gt;
 &lt;br /&gt;
 Ticket Id: {$Ticket-&amp;amp;gt;id}&lt;br /&gt;
 Queue name: {$Ticket-&amp;amp;gt;QueueObj-&amp;amp;gt;Name}&lt;br /&gt;
 Escalation: {$Ticket-&amp;amp;gt;AddCustomFieldValue(Field =&amp;amp;gt;&amp;#039;Escalation&amp;#039;, Value =&amp;amp;gt; &amp;#039;FirstEscalation&amp;#039;,RecordTransaction =&amp;amp;gt; 0)}&lt;br /&gt;
 Priority: {$Ticket-&amp;amp;gt;SetPriority($Ticket-&amp;amp;gt;Priority + 10)}&lt;br /&gt;
 Subject: {$Ticket-&amp;amp;gt;Subject()}&lt;br /&gt;
 Requestor: {$Ticket-&amp;amp;gt;RequestorAddresses}&lt;br /&gt;
 Ticket URL: {$RT::WebURL}Ticket/Display.html?id={$Ticket-&amp;amp;gt;id}&lt;br /&gt;
 &lt;br /&gt;
 Please take care of the Change Request immediately.&lt;br /&gt;
 &lt;br /&gt;
 Thank you&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== RT::Condition::UntouchedInBusinessHours ===&lt;br /&gt;
&lt;br /&gt;
After all the preparation, we implemented our new Condition to RT under RT_HOME/local/lib/RT/Condition called [[UntouchedInBusinessHours]].pm&lt;br /&gt;
&lt;br /&gt;
You can download the file here: [http://www.systemaniacs.de/wordpress/wp-content/uploads/2008/11/untouchedinbusinesshours.pm http://www.brumm.me/rt/UntouchInBusinessHours.pm]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
package RT::Condition::[[UntouchedInBusinessHours]];&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;require RT::Condition::Generic;&lt;br /&gt;
  &lt;br /&gt;
  use strict;&lt;br /&gt;
  use Time::Local;&lt;br /&gt;
  use vars qw/@ISA/;&lt;br /&gt;
  &lt;br /&gt;
  @ISA = qw(RT::Condition::Generic);&lt;br /&gt;
  &lt;br /&gt;
  =head1 NAME&lt;br /&gt;
  &lt;br /&gt;
  L&amp;amp;lt;RT::Condition::UntouchedInBusinessHours&amp;amp;gt; - Check for untouched Tickets within business hours&lt;br /&gt;
  &lt;br /&gt;
  =head1 SYNOPSIS&lt;br /&gt;
  &lt;br /&gt;
  =head2 CLI&lt;br /&gt;
  &lt;br /&gt;
    rt-crontool&lt;br /&gt;
  	--search RT::Search::ModuleName&lt;br /&gt;
  	--search-arg &amp;quot;The Search Argument&amp;quot;&lt;br /&gt;
  	--condition RT::Condition::UntouchedInBusinessHours&lt;br /&gt;
  	--condition-arg &amp;quot;The Condition Argument&amp;quot;&lt;br /&gt;
  	--action RT::Action:ActionModule&lt;br /&gt;
  	--template &amp;#039;Template Name or ID&amp;#039;&lt;br /&gt;
  &lt;br /&gt;
  =head1 DESCRIPTION&lt;br /&gt;
  &lt;br /&gt;
  L&amp;amp;lt;RT::Condition::UntouchedInBusinessHours&amp;amp;gt; is a RT Condition which will check&lt;br /&gt;
  for untouched Tickets within business hours.&lt;br /&gt;
  Untouched means in this case really untouched from time of ticket creation.&lt;br /&gt;
  &lt;br /&gt;
  =head1 CONFIGURATION&lt;br /&gt;
  &lt;br /&gt;
  =head2 Condition Argument&lt;br /&gt;
  &lt;br /&gt;
  The L&amp;amp;lt;RT::Condition::UntouchedInBusinessHours&amp;amp;gt; need exactly 4 arguments to work.&lt;br /&gt;
  Each part of the argument is separated by colons.&lt;br /&gt;
  &lt;br /&gt;
  	--condition RT::Condition::UntouchedInBusinessHours&lt;br /&gt;
  	--condition-arg 1:7:15:0&lt;br /&gt;
  &lt;br /&gt;
  	1 is the time in hours for escalation&lt;br /&gt;
  	7 is the start hour of the working day&lt;br /&gt;
  	15 is the end of of the working day&lt;br /&gt;
  	0 is a 5 day week from monday to friday&lt;br /&gt;
  	1 is a 7 day week from monday to sunday&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  =head2 Example cron call&lt;br /&gt;
  &lt;br /&gt;
  	rt-crontool&lt;br /&gt;
  		--search RT::Search::FromSQL&lt;br /&gt;
  		--search-arg &amp;quot;Queue = &amp;#039;General&amp;#039; AND ( Status = &amp;#039;new&amp;#039; ) AND Owner = &amp;#039;Nobody&amp;#039;&amp;quot;&lt;br /&gt;
  		--condition RT::Condition::UntouchedInBusinessHours&lt;br /&gt;
  		--condition-arg 1:7:15:0&lt;br /&gt;
  		--action RT::Action::RecordComment&lt;br /&gt;
  		--template &amp;#039;Unowned tickets&amp;#039;&lt;br /&gt;
  &lt;br /&gt;
  =head1 Limitations&lt;br /&gt;
  &lt;br /&gt;
  At this moment only week/weekends from mo-fr/sa-su are supported. If you have different scenario&lt;br /&gt;
  (like arabic countries) you have to change inside the source code ($wd =~ m/(Sun|Sat)/io)&lt;br /&gt;
  &lt;br /&gt;
  Also no public holidays are excluded.&lt;br /&gt;
  &lt;br /&gt;
  =head1 NOTES&lt;br /&gt;
  &lt;br /&gt;
  =head2 Reporting&lt;br /&gt;
  &lt;br /&gt;
  Send reports to L&amp;amp;lt;/AUTHOR&amp;amp;gt; or to the RT mailing lists.&lt;br /&gt;
  &lt;br /&gt;
  =head2 AUTHOR&lt;br /&gt;
  &lt;br /&gt;
      Torsten Brumm &amp;amp;lt;torsten.brumm@googlemail.com&amp;amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  =head2 COPYRIGHT&lt;br /&gt;
  &lt;br /&gt;
  This program is free software; you can redistribute&lt;br /&gt;
  it and/or modify it under the same terms as Perl itself.&lt;br /&gt;
  &lt;br /&gt;
  The full text of the license can be found in the&lt;br /&gt;
  Perl distribution.&lt;br /&gt;
  &lt;br /&gt;
  =cut&lt;br /&gt;
  &lt;br /&gt;
  my ($est, $tc, $bsh, $beh, $te, $we);&lt;br /&gt;
  my ($sec,$min,$hour,$mday,$mon,$year,$wd);&lt;br /&gt;
  my $ActualDate;&lt;br /&gt;
  my $ticketObj;&lt;br /&gt;
  my $tickid;&lt;br /&gt;
  my $EscalationDate;&lt;br /&gt;
  &lt;br /&gt;
  sub IsApplicable {&lt;br /&gt;
  	my $self = shift;&lt;br /&gt;
  	$ticketObj = $self-&amp;amp;gt;TicketObj;&lt;br /&gt;
  	$tickid = $ticketObj-&amp;amp;gt;Id;&lt;br /&gt;
  	$tc = $ticketObj-&amp;amp;gt;CreatedObj-&amp;amp;gt;Unix;&lt;br /&gt;
  	($est, $bsh, $beh, $we) = split(/:/, $self-&amp;amp;gt;Argument);&lt;br /&gt;
  	$ActualDate = local_actual_date_sec(RT::Date-&amp;amp;gt;new($RT::SystemUser));&lt;br /&gt;
  	$EscalationDate = escalate(normalize($tc, $bsh, $beh, $we), $bsh, $beh, $est, $we);&lt;br /&gt;
  	if ( $EscalationDate &amp;amp;lt;= $ActualDate ) {&lt;br /&gt;
  		return 1;&lt;br /&gt;
  	}&lt;br /&gt;
  	return undef;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  sub local_actual_date_sec {&lt;br /&gt;
         my $self = shift;&lt;br /&gt;
         $self-&amp;amp;gt;SetToNow;&lt;br /&gt;
         my $Ausgabe_local_actual_date_sec = $self-&amp;amp;gt;Unix;&lt;br /&gt;
         return ($self-&amp;amp;gt;Unix);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  sub escalate {&lt;br /&gt;
  	my ($tc, $bs, $be, $et, $we) = @_;&lt;br /&gt;
  	my ($rs, $es);&lt;br /&gt;
  	my $bar = 60*60;&lt;br /&gt;
  	$rs = $es = $et*$bar;&lt;br /&gt;
  	my $elapsed = 0;&lt;br /&gt;
  	my ($sec,$min,$hour,$mday,$mon,$year,$wd) = fromepoch($tc);&lt;br /&gt;
  	my $beepo = timegm(0,0,$be,$mday,$mon,$year);&lt;br /&gt;
  	my ($besec,$bemin,$behour,$bemday,$bemon,$beyear,$bewd) = fromepoch($beepo);&lt;br /&gt;
  	my $foo = $beepo-$tc;&lt;br /&gt;
  	if ($es &amp;amp;lt; $foo) { # escalate on the same day within BH&lt;br /&gt;
  		return $tc+$es;&lt;br /&gt;
  	}&lt;br /&gt;
  &lt;br /&gt;
  	if ($hour &amp;amp;lt; $behour) {&lt;br /&gt;
  		$elapsed += $foo;&lt;br /&gt;
  		$rs -= $foo;&lt;br /&gt;
  		($sec,$min,$hour,$mday,$mon,$year,$wd) = fromepoch($tc+86400);&lt;br /&gt;
  		$tc = timegm(0,0,$bs,$mday,$mon,$year);&lt;br /&gt;
  		$tc = normalize($tc, $bs, $be, $we);&lt;br /&gt;
  		($sec,$min,$hour,$mday,$mon,$year,$wd) = fromepoch($tc);&lt;br /&gt;
  	}&lt;br /&gt;
  &lt;br /&gt;
  	while(int($rs / ($bar*($be -$bs)))) {&lt;br /&gt;
  		$elapsed += ($bar * ($be -$bs));&lt;br /&gt;
  		$rs -= ($bar * ($be - $bs));&lt;br /&gt;
  		($sec,$min,$hour,$mday,$mon,$year,$wd) = fromepoch($tc+86400);&lt;br /&gt;
  		$tc = timegm(0,0,$bs,$mday,$mon,$year);&lt;br /&gt;
  		$tc = normalize($tc, $bs, $be, $we);&lt;br /&gt;
  		($sec,$min,$hour,$mday,$mon,$year,$wd) = fromepoch($tc);&lt;br /&gt;
  	}&lt;br /&gt;
  &lt;br /&gt;
  	$tc = normalize($tc+$rs, $bs, $be);&lt;br /&gt;
  	return $tc;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  sub normalize {&lt;br /&gt;
  	my ($time, $bs, $be, $we) = @_;&lt;br /&gt;
  	my ($sec,$min,$hour,$mday,$mon,$year,$wd) = fromepoch($time);&lt;br /&gt;
  	my $bens = timegm(0,0,$bs,$mday,$mon,$year);&lt;br /&gt;
  	my $bend = timegm(0,0,$be,$mday,$mon,$year);&lt;br /&gt;
  	if ($time &amp;amp;gt;= $bend) {&lt;br /&gt;
  		($sec,$min,$hour,$mday,$mon,$year,$wd) = fromepoch($time+86400);&lt;br /&gt;
  		$time = $bens = timegm(0,0,$bs,$mday,$mon,$year);&lt;br /&gt;
  		$bend = timegm(0,0,$be,$mday,$mon,$year);&lt;br /&gt;
  	}&lt;br /&gt;
  	if ($time &amp;amp;lt; $bens) {&lt;br /&gt;
  		$time = timegm(0,0,$bs,$mday,$mon,$year);&lt;br /&gt;
  	}&lt;br /&gt;
  	if (! $we) {&lt;br /&gt;
  		while ($wd =~ m/(Sun|Sat)/io) {&lt;br /&gt;
  			($sec,$min,$hour,$mday,$mon,$year,$wd) = fromepoch($time + 86400);&lt;br /&gt;
  			$time = timegm(0,0,$bs,$mday,$mon,$year);&lt;br /&gt;
  		}&lt;br /&gt;
  	}&lt;br /&gt;
  	return $time;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  sub fromepoch {&lt;br /&gt;
  	my ($t) = @_;&lt;br /&gt;
  	my @time = gmtime($t);&lt;br /&gt;
  	my $ss = ($time[0]&amp;amp;lt;10) ? &amp;quot;0&amp;quot;.$time[0] : $time[0];&lt;br /&gt;
  	my $mm = ($time[1]&amp;amp;lt;10) ? &amp;quot;0&amp;quot;.$time[1] : $time[1];&lt;br /&gt;
  	my $hh = ($time[2]&amp;amp;lt;10) ? &amp;quot;0&amp;quot;.$time[2] : $time[2];&lt;br /&gt;
  	my $day = $time[3];&lt;br /&gt;
  	my $month = ($time[4] &amp;amp;lt; 10) ? &amp;quot;0&amp;quot;.($time[4]) : $time[4];&lt;br /&gt;
  	my $wday = (&amp;quot;Sun&amp;quot;,&amp;quot;Mon&amp;quot;,&amp;quot;Tue&amp;quot;,&amp;quot;Wed&amp;quot;,&amp;quot;Thu&amp;quot;,&amp;quot;Fri&amp;quot;,&amp;quot;Sat&amp;quot;)[$time[6]];&lt;br /&gt;
  	my $year = $time[5] + 1900;&lt;br /&gt;
  	my $offset = timelocal(localtime) - timelocal(gmtime);&lt;br /&gt;
  	my $sign =&amp;quot;+&amp;quot;;&lt;br /&gt;
  	if ($offset &amp;amp;lt; 0) {&lt;br /&gt;
  		$sign =&amp;quot;-&amp;quot;;&lt;br /&gt;
  		$offset *= -1;&lt;br /&gt;
  	}&lt;br /&gt;
  	my $offseth = int($offset/3600);&lt;br /&gt;
  	my $offsetm = int(($offset - $offseth*3600)/60);&lt;br /&gt;
  	my $tz = sprintf (&amp;quot;%s%0.2d%0.2d&amp;quot;, $sign, $offseth, $offsetm);&lt;br /&gt;
  	return ($ss, $mm, $hh, $day, $month, $year, $wday);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  eval &amp;quot;require RT::Condition::UntouchedInBusinessHours_Vendor&amp;quot;;&lt;br /&gt;
  die $@ if ($@ &amp;amp;amp;&amp;amp;amp; $@ !~ qr{^Can&amp;#039;t locate RT/Condition/UntouchedInBusinessHours_Vendor.pm});&lt;br /&gt;
  eval &amp;quot;require RT::Condition::UntouchedInBusinessHours_Local&amp;quot;;&lt;br /&gt;
  die $@ if ($@ &amp;amp;amp;&amp;amp;amp; $@ !~ qr{^Can&amp;#039;t locate RT/Condition/UntouchedInBusinessHours_Local.pm});&lt;br /&gt;
  &lt;br /&gt;
  1;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>