This commit was generated by cvs2svn to compensate for changes in r2526,
[freeside.git] / rt / webrt / Ticket / Display.html
1 %# $Header: /home/cvs/cvsroot/freeside/rt/webrt/Ticket/Attic/Display.html,v 1.1 2002-08-12 06:17:09 ivan Exp $
2 %# Copyright 1996-2000 Jesse Vincent <jesse@fsck.com>
3
4 <& /Elements/Header, Title => "Ticket #".$Ticket->Id ." ".$Ticket->Subject &>
5 <& /Ticket/Elements/Tabs, Ticket => $Ticket, current_tab => 'Ticket/Display.html?id='.$Ticket->id &>
6
7 <& /Elements/ListActions, actions => \@Actions &>
8
9 <& /Ticket/Elements/ShowSummary,  Ticket => $Ticket &>
10
11
12 <BR>
13 <& /Ticket/Elements/ShowHistory , 
14       Ticket => $Ticket, 
15       Collapsed => $ARGS{'Collapsed'}, 
16       ShowHeaders => $ARGS{'ShowHeaders'} &> 
17
18   
19 <%ARGS>
20 $id => undef
21 $Create => undef
22 $ShowHeaders => undef
23 $Collapsed => undef
24 </%ARGS>
25
26 <%INIT>
27
28   
29   my ($linkid, $message, $tid, $Ticket, @Actions);  
30
31 $Ticket = new RT::Ticket($session{'CurrentUser'});
32
33 unless ($id) {
34     Abort('No ticket specified');
35 }
36
37 if ($ARGS{'id'} eq 'new') {
38     # {{{ Create a new ticket
39     
40     my $Queue = new RT::Queue($session{'CurrentUser'}); 
41     unless ($Queue->Load($ARGS{'Queue'})) {
42         Abort('Queue not found');
43     }
44     
45     unless ($Queue->CurrentUserHasRight('CreateTicket')) {
46         Abort('You have no permission to create tickets in that queue.');
47     }
48    
49     my $due = new RT::Date($session{'CurrentUser'});
50     $due->Set(Format => 'unknown', Value => $ARGS{'Due'});
51     my $starts = new RT::Date($session{'CurrentUser'});
52     $starts->Set(Format => 'unknown', Value => $ARGS{'Starts'});
53     
54  
55     my @Requestors = split(/,/,$ARGS{'Requestors'});
56     my @Cc = split(/,/,$ARGS{'Cc'});
57     my @AdminCc = split(/,/,$ARGS{'AdminCc'});
58     
59     my $MIMEObj = MakeMIMEEntity( Subject => $ARGS{'Subject'},
60                                   From => $ARGS{'From'},
61                                   Cc => $ARGS{'Cc'},
62                                   Body => $ARGS{'Content'},
63                                   AttachmentFieldName => 'Attach');
64  
65                                   
66     my %create_args = ( 
67                        Queue=>$ARGS{Queue},
68                        Owner=>$ARGS{ValueOfOwner},
69                        InitialPriority=> $ARGS{InitialPriority},
70                        FinalPriority=> $ARGS{FinalPriority},
71                        TimeLeft => $ARGS{TimeLeft},
72                        TimeWorked => $ARGS{TimeWorked},
73                        Requestor=> \@Requestors,
74                        Cc => \@Cc,
75                        AdminCc => \@AdminCc,
76                        Subject=>$ARGS{Subject},
77                        Status=>$ARGS{Status},
78                        Due => $due->ISO,
79                        Starts => $starts->ISO,
80                        MIMEObj => $MIMEObj        
81                       );         
82
83     
84     # we need to get any KeywordSelect-<integer> fields into %create_args..
85     grep { $_ =~ /^KeywordSelect-/ && {$create_args{$_} = $ARGS{$_}}} %ARGS;
86
87     my ($id, $Trans, $ErrMsg)= $Ticket->Create(%create_args);
88     unless ($id && $Trans) {
89         Abort($ErrMsg);
90     }
91     my @linktypes = qw( DependsOn MemberOf RefersTo );
92     
93     foreach my $linktype (@linktypes) {
94       foreach my $luri (split (/ /,$ARGS{"new-$linktype"})) {
95         $luri =~ s/\s*$//; # Strip trailing whitespace
96         my ($val, $msg) = $Ticket->AddLink( Target => $luri,
97                                             Type => $linktype);
98         push @Actions, $msg;
99       }
100       
101       foreach my $luri (split (/ /,$ARGS{"$linktype-new"})) {
102         my ($val, $msg) = $Ticket->AddLink( Base => $luri,
103                                             Type => $linktype);
104         
105         push @Actions, $msg;
106       }
107     }
108     # don't try to change queue to the current queue
109     delete $ARGS{'Queue'};
110
111     push(@Actions, $ErrMsg);
112     unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
113       Abort("No permission to view newly created ticket #".$Ticket->id.".");
114     }
115     # }}}
116 }
117
118 else { 
119     $Ticket = LoadTicket($ARGS{'id'});
120     unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
121         Abort("No permission to view ticket");
122     }
123
124
125 if (defined $ARGS{'Action'}) {
126   if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
127     my $action = $1;
128     my ($res, $msg)=$Ticket->$action();
129     push(@Actions, $msg);
130   }
131 }
132     $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;
133
134     if ($ARGS{'UpdateContent'} &&
135         $ARGS{'UpdateContent'} ne '' &&
136         $ARGS{'UpdateContent'} ne  "-- \n" .
137                                 $session{'CurrentUser'}->UserObj->Signature
138        ) {
139             ProcessUpdateMessage(ARGSRef=>\%ARGS, 
140                                  Actions=>\@Actions, 
141                                  TicketObj=>$Ticket);
142         }
143 #Process status updates
144 my @BasicActions = ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$Ticket);
145
146 push (@Actions, @BasicActions);
147 }
148 </%INIT>
149
150
151
152