no need for FS calendar buttons in RT 4.2
[freeside.git] / rt / share / html / Elements / CalendarEvent
1 <%args>
2 $Date => undef
3 $Object => undef
4 $DateTypes => undef
5 </%args>
6 <div class="tooltip">
7 <small>
8
9 % if ($IsReminder and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today) {
10      <img src="<%$RT::WebImagesURL%>/reminder.png" />
11
12 % } elsif ($DateTypes->{Resolved}
13 %           and RTx::Calendar::LocalDate($Object->ResolvedObj->Unix) eq $today) {
14          <img src="<%$RT::WebImagesURL%>/resolved.png" />
15
16 % } elsif ($DateTypes->{Starts} and $DateTypes->{Due}
17 %           and RTx::Calendar::LocalDate($Object->StartsObj->Unix) eq $today and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today ) {
18     <img src="<%$RT::WebImagesURL%>/starts_due.png" />
19
20 % } elsif ($DateTypes->{Due} and $DateTypes->{Created}
21 %           and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today and RTx::Calendar::LocalDate($Object->CreatedObj->Unix) eq $today ) {
22     <img src="<%$RT::WebImagesURL%>/created_due.png" />
23
24 % } elsif ($DateTypes->{Starts}
25 %           and RTx::Calendar::LocalDate($Object->StartsObj->Unix) eq $today) {
26     <img src="<%$RT::WebImagesURL%>/starts.png" />
27
28 % } elsif ($DateTypes->{Due}
29 %           and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today) {
30     <img src="<%$RT::WebImagesURL%>/due.png" />
31
32 % } elsif ($DateTypes->{Created}
33 %           and RTx::Calendar::LocalDate($Object->CreatedObj->Unix) eq $today) {
34     <img src="<%$RT::WebImagesURL%>/created.png" />
35
36 % } elsif ($DateTypes->{Started}
37 %           and RTx::Calendar::LocalDate($Object->StartedObj->Unix) eq $today) {
38     <img src="<%$RT::WebImagesURL%>/started.png" />
39
40 % } elsif ($DateTypes->{LastUpdated}
41 %           and RTx::Calendar::LocalDate($Object->LastUpdatedObj->Unix) eq $today) {
42     <img src="<%$RT::WebImagesURL%>/updated.png" />
43
44 % }
45
46         <a href="<%$RT::WebPath%>/Ticket/Display.html?id=<%$TicketId%>">
47            <% $Object->QueueObj->Name %> #<% $TicketId %>
48            <% $display_owner ? 'by ' . $Object->OwnerObj->Name : '' %>
49            <% length($Object->Subject) > 80 ? substr($Object->Subject, 0, 77) . "..." : $Object->Subject %></a></small><br />
50         <span class="tip">
51         <a href="<%$RT::WebPath%>/Ticket/Display.html?id=<%$TicketId%>">
52            <% $Object->QueueObj->Name %> #<% $TicketId %>
53         </a>
54         :</strong> <% $subject%><br />
55         <br />
56
57 %# logic taken from Ticket/Search/Results.tsv
58 % foreach my $attr (@display_fields) {
59 %    my $value;
60 %
61 %    if ($attr =~ /(.*)->ISO$/ and $Object->$1->Unix <= 0) {
62 %        $value = '-';
63 %    } else {
64 %        my $method = '$Object->'.$attr.'()';
65 %        $method =~ s/->ISO\(\)$/->ISO( Timezone => 'user' )/;
66 %        $value = eval $method;
67 %        if ($@) {die "<b>Check your CalendarPopupFields config in etc/RT_SiteConfig.pm</b>.<br /><br />Failed to find \"$attr\" - ". $@};
68 %    }
69         <strong><&|/l&><% $label_of{$attr} %></&>:</strong> <% $value %><br />
70 % }
71
72 <br />
73         </span>
74 </div>
75
76 <%init>
77 use RTx::Calendar;
78
79 my $today = $Date->strftime("%F");
80
81 my $TicketId;
82
83 my $ticket;
84 my $subject;
85 my $IsReminder;
86
87 if ($Object->Type eq 'reminder') {
88     $IsReminder = 1;
89     if ($Object->RefersTo->First) {
90         $ticket   = $Object->RefersTo->First->TargetObj;
91         $TicketId = $ticket->Id;
92         $subject = $Object->Subject . " (" . $ticket->Subject . ")";
93     }
94 } else {
95     $TicketId = $Object->Id;
96     $subject = $Object->Subject;
97 }
98
99 my $display_owner = $RT::CalendarDisplayOwner;
100 $display_owner ||= RT->Config->Get('CalendarDisplayOwner')
101     if RT->can('Config');
102
103
104 # 3.6 config
105 my @display_fields = @RT::CalendarPopupFields;
106  
107 # 3.8 config
108 # the if condition is weird but it doesn't work with 3.8.0 without the last part
109 @display_fields = RT->Config->Get('CalendarPopupFields')
110     if 0 == @display_fields and RT->can('Config') and RT->Config->Get('CalendarPopupFields');
111
112 # default
113 if (0 == @display_fields) {
114     @display_fields = qw(OwnerObj->Name CreatedObj->ISO StartsObj->ISO
115                          StartedObj->ISO LastUpdatedObj->ISO DueObj->ISO
116                          ResolvedObj->ISO Status Priority
117                          Requestors->MemberEmailAddressesAsString);
118 }
119
120
121 my %label_of;
122 for my $field (@display_fields) {
123     my $label = $field;
124     $label =~ s'Obj-.(?:AsString|Name|ISO)''g;
125     $label =~ s'-\>MemberEmailAddressesAsString''g;
126     $label_of{$field} = $label;
127 }
128
129 </%init>