<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style id="owaParaStyle" type="text/css">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
</head>
<body>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Yep, I think it would be cool.<br>
But you should also help me dealing with assumption #2: I'd like to disallow the modification of the tickets' attributes involved. Maybe not to everyone; maybe we could work with ACEs, splitting the ModifyTicket right in ModifyTicket and ModifyDates, or something
like that.<br>
What do you think?<br>
<br>
<br>
<div style="font-family:Times New Roman; color:#000000; font-size:16px"><br>
<br>
<div align="left">
<p style="font-family:Calibri,Sans-Serif; font-size:10pt"><span style="color:#000000; font-weight:bold">Alberto Scotto</span>
<span style="color:#808080"></span><br>
<br>
<span style="color:#000000"><img border="0" alt="Blue" src="cid:939659c70fa14cd191771cdfa735ba23" style="margin:0px">
</span><br>
<span style="color:#808080">Via Cardinal Massaia, 83<br>
10147 - Torino - ITALY <br>
phone: +39 011 29100 <br>
<a href="al.scotto@reply.it" target="" style="color:blue; text-decoration:underline">al.scotto@reply.it</a>
<br>
<a title="" href="www.reply.it" target="" style="color:blue; text-decoration:underline">www.reply.it</a>
</span><br>
</p>
</div>
<hr tabindex="-1">
<div id="divRpF898768" style="direction:ltr"><font color="#000000" face="Tahoma" size="2"><b>Inizio:</b> Ruslan Zakirov [ruslan.zakirov@gmail.com]<br>
<b>Inviato:</b> sabato 9 giugno 2012 13.21<br>
<b>Fine:</b> Scotto Alberto<br>
<b>Cc:</b> rt-users@lists.bestpractical.com<br>
<b>Oggetto:</b> Re: [rt-users] [SLA] Custom (and very imperfect) solution for parking stalled tickets<br>
</font><br>
</div>
<div></div>
<div>
<p>I'm glad if it works for you. Would like to see functionality in extension. Your solution needs refactoring to be merged. If you like I can guide you and help put it into shape for merge.<br>
</p>
<p>Ruslan from phone.</p>
<div class="gmail_quote">08.06.2012 2:24 пользователь "Scotto Alberto" <<a href="mailto:al.scotto@reply.it" target="_blank">al.scotto@reply.it</a>> написал:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="direction:ltr; font-size:10pt; font-family:Tahoma">Working with the SLA Extension, I came across the problem of stalled tickets: by default, there is no way to stop the "timer" for the due date when a ticket becomes stalled, as stated by the author
in<br>
<a href="http://www.gossamer-threads.com/lists/rt/users/105845#105845" target="_blank">http://www.gossamer-threads.com/lists/rt/users/105845#105845</a>
<br>
<br>
So I've just implemented a small customization (very imperfect indeed) and I want to share it with all of you. Feel free to contribute, and please share your improvements.<br>
<br>
First of all, a few assumptions (aka limitations):<br>
- in $RT::ServiceBusinessHours we defined only 'Default' ServiceBusinessHours<br>
- users will not modify the date fields we set, otherwise everything would screw up<br>
<br>
The idea is to move the due date forward as soon as the ticket exits the stalled status. To compute the new due date we need to know when the tickets became stalled. So, we first have to save somewhere the time when it became stalled: we temporarly save it
in the Resolved attribute (very dirty, I know..!), which shouldn't be used while stalled.<br>
<br>
This solution includes two actions, two conditions, and two scrips which put everything together.<br>
<br>
Conditions, which you can easily build thanks to sbin/rt-setup-database and the ExecModule StatusChange:<br>
- on stalled<br>
- on un-stall<br>
<br>
Actions (the code is below):<br>
- Set resolved temporarly <br>
- Update due date on un-stall <br>
<br>
Scrips:<br>
- On stalled Set resolved temporarly<br>
- On un-stall Update due date<br>
<br>
<br>
I think the most important improvement would be to avoid the use of the Resolved attribute as temporary. Instead, it would be better to define a new private attribute in Ticket.pm; consequently, a new column in the DB, etc.<br>
<br>
Of course, I will appreciate any suggestions, comments, etc.<br>
<br>
Thanks<br>
<br>
AS<br>
<br>
<br>
======== Action1. Set resolved temporarly =====<br>
my $tkt = $self->TicketObj;<br>
my $id = $tkt->Id;<br>
my $stalled_date = RT::Date->new( $RT::SystemUser );<br>
$stalled_date->SetToNow;<br>
my ($status, $msg) = $tkt->_Set(<br>
Field => 'Resolved',<br>
Value => $stalled_date->ISO,<br>
RecordTransaction => 0<br>
);<br>
unless ( $status ) {<br>
$RT::Logger->error("Unable to set Resolved date to ticket #$id: $msg");<br>
return 0;<br>
}<br>
$RT::Logger->debug("Set Resolved date of ticket #". $id . " to ". $stalled_date->ISO);<br>
return 1;<br>
===================================<br>
<br>
======== Action2. Update due date on un-stall =====<br>
my $t = $self->TicketObj;<br>
my $id = $t->Id;<br>
use Business::Hours;<br>
<br>
my $now = RT::Date->new( $RT::SystemUser );<br>
$now->SetToNow;<br>
my $bhours = Business::Hours->new();<br>
$bhours->business_hours( %{ $RT::ServiceBusinessHours{ 'Default' } } );<br>
my $delta = $bhours->between($t->ResolvedObj->Unix, $now->Unix);<br>
my $new_due = $bhours->add_seconds($t->DueObj->Unix, $delta);<br>
<br>
my $due_date = RT::Date->new( $RT::SystemUser );<br>
$due_date->Set(Format => 'unix', Value => $new_due );<br>
# finally set new due date<br>
my ($status, $msg) = $t->_Set(<br>
Field => 'Due',<br>
Value => $due_date->ISO,<br>
RecordTransaction => 0<br>
);<br>
# if the two transitions (*->stalled and stalled->*) take place out of hours,<br>
# in the same interval, then $delta will be 0<br>
if( !($t->DueObj->Diff($due_date)) ) {<br>
$RT::Logger->debug("Unable to set Due date to ticket #$id: new_due_date = old_due_date " . $due_date->ISO);<br>
}<br>
elsif ( !($status) ) {<br>
$RT::Logger->error("Unable to set Due date to ticket #$id: $msg");<br>
return 0;<br>
}<br>
# reset Resolved date<br>
($status, $msg) = $t->_Set(<br>
Field => 'Resolved',<br>
Value => 0,<br>
RecordTransaction => 0<br>
);<br>
unless ( $status ) {<br>
$RT::Logger->error("Unable to reset Resolved date to ticket #$id: $msg");<br>
}<br>
$RT::Logger->debug("Due date updated after un-stalling ticket #". $id );<br>
return 1;<br>
==============================</div>
<br>
<br>
<div align="left">
<p style="font-family:Calibri,Sans-Serif; font-size:10pt"><span style="font-weight:bold">Alberto Scotto</span>
<span style="color:#808080"></span><br>
<br>
<span style=""><img alt="Blue" src="cid:bfeb0dedcce94e11bf9e9d043f8677dc" border="0" style="margin:0px">
</span><br>
<span style="color:#808080">Via Cardinal Massaia, 83<br>
10147 - Torino - ITALY <br>
phone: +39 011 29100 <br>
<a href="http://al.scotto@reply.it" target="_blank" style="color:blue; text-decoration:underline">al.scotto@reply.it</a>
<br>
<a title="" href="http://www.reply.it" target="_blank" style="color:blue; text-decoration:underline">www.reply.it</a>
</span><br>
</p>
</div>
<br>
<hr>
<font color="Gray" face="Arial" size="1"><br>
--<br>
The information transmitted is intended for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information
by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.<br>
</font></div>
</blockquote>
</div>
</div>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
--<br>
The information transmitted is intended for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information
by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.<br>
</font>
</body>
</html>