import rt 2.0.14
[freeside.git] / rt / webrt / Ticket / Elements / Tabs
diff --git a/rt/webrt/Ticket/Elements/Tabs b/rt/webrt/Ticket/Elements/Tabs
new file mode 100755 (executable)
index 0000000..8cce197
--- /dev/null
@@ -0,0 +1,126 @@
+<& /Elements/Tabs, tabs => $tabs, actions => $actions, current_tab => $current_tab, tabs_scalar => $tabs_scalar &>
+<%INIT>
+       
+  my $id = $Ticket->id();
+  my $tabs_scalar = '';
+  my $tabs = {
+                A => { title => 'Display',
+                       path => "Ticket/Display.html?id=".$id,
+                     },
+             
+             Ab => { title => 'History',
+                     path => "Ticket/History.html?id=".$id,
+                      },
+             B => { title => 'Basics',
+                    path => "Ticket/Modify.html?id=".$id,
+                  },
+             
+             C => { title => 'Dates',
+                    path => "Ticket/ModifyDates.html?id=".$id,
+                  },
+             
+             D => { title => 'People',
+                    path => "Ticket/ModifyPeople.html?id=".$id,
+                  },
+             E => { title => 'Links',
+                    path => "Ticket/ModifyLinks.html?id=".$id,
+                  },
+             F => { title => 'Jumbo',
+                    path => "Ticket/ModifyAll.html?id=".$id,
+                  },
+             
+            };
+
+my $actions;
+if ($Ticket->CurrentUserHasRight('ModifyTicket') or 
+    $Ticket->CurrentUserHasRight('CommentOnTicket')) {
+    $actions->{'Comment'} = 
+      { 
+       title => 'Comment',
+       path => "Ticket/Update.html?Action=Comment&id=".$id,
+      }
+  };
+
+if ($Ticket->CurrentUserHasRight('ModifyTicket') or 
+    $Ticket->CurrentUserHasRight('ReplyToTicket')) {
+    $actions->{'Reply'} = 
+      { 
+       title => 'Reply',
+       path => "Ticket/Update.html?Action=Respond&id=".$id,
+      }
+  };
+
+if ($Ticket->CurrentUserHasRight('OwnTicket')) {
+    if ($Ticket->OwnerObj->id == $RT::Nobody->id)  {
+       $actions->{'Take'} =    
+         { 
+          path => "Ticket/Display.html?Action=Take&id=".$id,
+          title => 'Take'
+         };
+    }
+    elsif ( $Ticket->OwnerObj->id != $session{CurrentUser}->id) {
+       $actions->{'Steal'} =   
+         { 
+          path => "Ticket/Display.html?Action=Steal&id=".$id,
+          title => 'Steal' 
+         };
+    }
+}
+
+if ($Ticket->CurrentUserHasRight('ModifyTicket')) {
+    if ($Ticket->Status ne 'resolved') {
+       $actions->{'Resolve'} = 
+         { 
+
+           path => "Ticket/Update.html?Action=Comment&DefaultStatus=resolved&id=".$id,
+          title => 'Resolve'
+         };
+    }  
+    if ($Ticket->Status ne 'open') {   
+       $actions->{'Open'} = 
+         { 
+          path => "Ticket/Display.html?Status=open&id=". $id,
+          title => 'Open'
+         };
+    }
+}
+
+
+
+
+if (defined $session{'tickets'}) {
+    my $items = $session{'tickets'}->ItemsArrayRef();
+    my @indexs = grep(($items->[$_]->id == $Ticket->Id), 0 .. $#{$items});
+
+    if ($items->[0]) {
+
+    if ($items->[$indexs[0]]->id == $Ticket->Id) {
+       # Don't display prev links if we're on the first ticket
+       if ( $items->[0]->id != $Ticket->id ) {
+           $tabs_scalar .= '[<A HREF="Display.html?id='.
+             $items->[0]->id.
+               '">&lt;&lt; First</a>] ';
+           $tabs_scalar .= '[<A HREF="Display.html?id='.
+             $items->[$indexs[0]-1]->id.
+               '">&lt; Prev</a>] ';
+       }
+       # Don't display next links if we're on the last ticket
+       if ( $Ticket->id != $items->[-1]->id ) {
+           $tabs_scalar .= '[<A HREF="Display.html?id='.
+             $items->[$indexs[0]+1]->id.
+               '">Next &gt;</a>] ';
+           $tabs_scalar .= '[<A HREF="Display.html?id='.
+             $items->[-1]->id.
+               '">Last &gt;&gt</a>]';
+       }
+       $tabs_scalar .= "<BR><BR>";
+    }
+    }
+}
+</%INIT>
+
+  
+<%ARGS>
+$Ticket => undef
+$current_tab => undef
+</%ARGS>