DueDateinBusinessHours
Comments0
833pages on
this wiki
this wiki
Description: set ticket to be due in a specified number of business hours (so that weekends and nights are excluded)
Uses Jesse Vincent's Business::Hours library, available from CPAN
Condition: On Ticket Creation Template: Global template: Blank Action: User Defined Custom Action Preparation Code: return 1; Custom Action Cleanup Code: my $duedate = RT::Date->new($RT::SystemUser); my $hoursuntildue = 4; use Business::Hours; my $hours = Business::Hours->new(); my $curtime = time; my $bus_hours_duetime = $hours->add_seconds ($curtime, ($hoursuntildue*60*60)); $duedate->Set(Format=>'unix', Value=>$bus_hours_duetime); $self->TicketObj->SetDue($duedate->ISO); return(1);
This takes care of the case in which TimeLeft is modified after ticket creation:
Description: Upon editing, convert TimeLeft into business days
Condition: User Defined
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate
Custom Condition:
if ($self->TransactionObj->Field eq 'TimeLeft') {
return(1);
} else {
return(undef);
}
Custom Action Preparation Code: return 1;
Custom action cleanup code:
my $duedate = RT::Date->new($RT::SystemUser);
my $hoursperday = 9;
my $hoursuntildue = $self->TransactionObj->NewValue()*$hoursperday;
use Business::Hours;
my $hours = Business::Hours->new();
my $curtime = time;
my $bus_hours_duetime = $hours->add_seconds ($curtime, ($hoursuntildue*60*60));
$duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
$self->TicketObj->SetDue($duedate->ISO);
return(1);