RT future ticket resolve, #13853
[freeside.git] / rt / lib / RT / Ticket_Vendor.pm
1 package RT::Ticket;
2 use strict;
3
4 sub SetPriority {
5   # Special case: Pass a value starting with 'R' to set priority 
6   # relative to the current level.  Used for bulk updates, though 
7   # it can be used anywhere else too.
8   my $Ticket = shift;
9   my $value = shift;
10   if ( $value =~ /^R([+-]?\d+)$/ ) {
11     $value = $1 + ($Ticket->Priority || 0);
12   }
13   $Ticket->SUPER::SetPriority($value);
14 }
15
16 =head2 MissingRequiredFields {
17
18 Return all custom fields with the Required flag set for which this object
19 doesn't have any non-empty values.
20
21 =cut
22
23 sub MissingRequiredFields {
24     my $self = shift;
25     my $CustomFields = $self->CustomFields;
26     my @results;
27     while ( my $CF = $CustomFields->Next ) {
28         next if !$CF->Required;
29         if ( !length($self->FirstCustomFieldValue($CF->Id) || '') )  {
30             push @results, $CF;
31         }
32     }
33     return @results;
34 }
35
36 # Declare the 'WillResolve' field
37 sub _VendorAccessible {
38     {
39         WillResolve =>
40         {read => 1, write => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
41     },
42 };
43
44 sub WillResolveObj {
45   my $self = shift;
46
47   my $time = new RT::Date( $self->CurrentUser );
48
49   if ( my $willresolve = $self->WillResolve ) {
50     $time->Set( Format => 'sql', Value => $willresolve );
51   }
52   else {
53     $time->Set( Format => 'unix', Value => -1 );
54   }
55
56   return $time;
57 }
58
59 sub WillResolveAsString {
60   my $self = shift;
61   return $self->WillResolveObj->AsString();
62 }
63
64
65 1;