Difference between revisions of "DueDateinBusinessHours"

From Request Tracker Wiki
Jump to navigation Jump to search
 
m (3 revisions imported)
 
(2 intermediate revisions by 2 users not shown)
Line 19: Line 19:
 
  $self->TicketObj->SetDue($duedate->ISO);
 
  $self->TicketObj->SetDue($duedate->ISO);
 
  return(1);
 
  return(1);
 
 
  
 
This takes care of the case in which [[TimeLeft]] is modified after ticket creation:
 
This takes care of the case in which [[TimeLeft]] is modified after ticket creation:
Line 28: Line 26:
 
  Condition: User Defined
 
  Condition: User Defined
 
  Action: User Defined
 
  Action: User Defined
  Template: -
+
  Template: Global template: Blank
 
  Stage: TransactionCreate
 
  Stage: TransactionCreate
 
   
 
   

Latest revision as of 16:08, 6 April 2016

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, ($hoursuntildue6060));
$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, ($hoursuntildue60*60));
 $duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
 $self->TicketObj->SetDue($duedate->ISO);
 return(1);