3b58f9ec0d064f5bc0e0638bca4fede79ab73d09
[freeside.git] / httemplate / view / cust_main / packages / package.html
1 <TD CLASS="inv" BGCOLOR="<% $bgcolor %>" VALIGN="top">
2   <TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
3     <TR>
4       <TD COLSPAN=2>
5         <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
6            ID  ="cust_pkg<% $cust_pkg->pkgnum %>"
7         ><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
8         - 
9         <% $part_pkg->custom_comment |h %>
10       </TD>
11     </TR>
12
13 % if ( $cust_pkg->quantity > 1 ) {
14     <TR>
15       <TD COLSPAN=2>
16         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Quantity: 
17         <B><% $cust_pkg->quantity %></B>
18       </TD>
19     </TR>
20 %  }
21
22     <TR>
23       <TD COLSPAN=2>
24         <FONT SIZE=-1>
25
26 %         unless ( $cust_pkg->get('cancel') ) { 
27 %
28 %           my $br = 0;
29 %           if ( $curuser->access_right('Change customer package') ) {
30 %             $br=1;
31               (&nbsp;<%pkg_change_link($cust_pkg)%>&nbsp;)
32 %           } 
33 %
34 %           if ( $curuser->access_right('Edit customer package dates') ) {
35 %             $br=1;
36               (&nbsp;<%pkg_dates_link($cust_pkg)%>&nbsp;)
37 %           } 
38 %
39 %           if ( $curuser->access_right('Discount customer package')
40 %                && $part_pkg->can_discount
41 %                && ! scalar($cust_pkg->cust_pkg_discount_active)
42 %                && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
43 %              )
44 %           {
45 %             $br=1;
46               (&nbsp;<%pkg_discount_link($cust_pkg)%>&nbsp;)
47 %           }
48 %
49 %           if ( $curuser->access_right('Customize customer package') ) {
50 %             $br=1;
51               (&nbsp;<%pkg_customize_link($cust_pkg,$part_pkg)%>&nbsp;)
52 %           } 
53 %
54             <% $br ? '<BR>' : '' %>
55 %         } 
56
57 %         if ( $cust_pkg->num_cust_event
58 %              && (    $curuser->access_right('Billing event reports')
59 %                   || $curuser->access_right('View customer billing events')
60 %                 )
61 %            ) {
62             (&nbsp;<%pkg_event_link($cust_pkg)%>&nbsp;)
63 %         }
64
65         </FONT>
66       </TD>
67     </TR>
68
69 %   my $editi = $curuser->access_right('Edit customer package invoice details');
70 %   my $editc = $curuser->access_right('Edit customer package comments');
71 %   my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
72 %   my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
73 %   my @comments       = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
74 %
75 %   if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
76 %
77 %     my $editlink = $p. 'edit/cust_pkg_detail?pkgnum='. $cust_pkg->pkgnum.
78 %                    ';detailtype=';
79
80       <TR>
81
82 %       if ( @invoice_detail ) {
83           <TD VALIGN="top">
84             <% include('/elements/table-grid.html') %>
85               <TR>
86                 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
87                   <FONT SIZE="-1">
88                     Invoice details
89 %                   if ( $editi && ! $cust_pkg->get('cancel') ) {
90                       (<% include('/elements/popup_link.html', { 
91                                     'action'      => $editlink. 'I',
92                                     'label'       => 'edit',
93                                     'actionlabel' => 'Edit invoice details',
94                                     'color'       => '#333399',
95                                     'width'       => 763,
96                                  })
97                        %>)
98 %                   }
99                   </FONT>
100                 </TH>
101               </TR>
102 %             foreach my $cust_pkg_detail ( @invoice_detail ) {
103                 <TR>
104                   <TD><FONT SIZE="-1">&nbsp;-&nbsp;<% $cust_pkg_detail->detail |h %></FONT></TD>
105                 </TR>
106 %             }
107             </TABLE>
108           </TD>
109 %       } else {
110           <TD>
111 %           if ( $editi && ! $cust_pkg->get('cancel') ) {
112               <FONT SIZE="-1">
113                 (&nbsp;<% include('/elements/popup_link.html', { 
114                                'action'      => $editlink. 'I',
115                                'label'       => 'Add&nbsp;invoice&nbsp;details',
116                                'actionlabel' => 'Add invoice details',
117                                'color'       => '#333399',
118                                'width'       => 763,
119                             })
120                   %>&nbsp;)
121               </FONT>
122 %           }
123           </TD>
124 %       }
125
126 %       if ( @comments ) { 
127           <TD VALIGN="top">
128             <% include('/elements/table-grid.html') %>
129               <TR>
130                 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
131                   <FONT SIZE="-1">
132                     Comments
133 %                   if ( $editc ) {
134                       (<% include('/elements/popup_link.html', { 
135                                     'action'      => $editlink. 'C',
136                                     'label'       => 'edit',
137                                     'actionlabel' => 'Edit comments',
138                                     'color'       => '#333399',
139                                     'width'       => 763,
140                                  })
141                        %>)
142 %                   }
143                   </FONT>
144                 </TH>
145               </TR>
146 %             foreach my $cust_pkg_detail ( @comments ) {
147                 <TR>
148                   <TD><FONT SIZE="-1">&nbsp;-&nbsp;<% $cust_pkg_detail->detail |h %></FONT></TD>
149                 </TR>
150 %             }
151             </TABLE>
152           </TD>
153 %       } else {
154           <TD>
155 %           if ( $editc ) {
156               <FONT SIZE="-1">
157                 (&nbsp;<% include('/elements/popup_link.html', { 
158                                'action'      => $editlink. 'C',
159                                'label'       => 'Add&nbsp;comments',
160                                'actionlabel' => 'Add comments',
161                                'color'       => '#333399',
162                                'width'       => 763,
163                             })
164                   %>&nbsp;)
165               </FONT>
166 %           }
167           </TD>
168 %       }
169
170       </TR>
171 %   }
172
173   </TABLE>
174
175 </TD>
176
177 <%init>
178
179 my %opt = @_;
180
181 my $bgcolor  = $opt{'bgcolor'};
182 my $cust_pkg = $opt{'cust_pkg'};
183 my $part_pkg = $opt{'part_pkg'};
184
185 my $curuser = $FS::CurrentUser::CurrentUser;
186
187 #subroutines
188
189 #false laziness w/status.html
190 sub pkg_link {
191   my($action, $label, $cust_pkg) = @_;
192   return '' unless $cust_pkg;
193   qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
194 }
195
196 sub pkg_change_link {
197   my $cust_pkg = shift;
198   my $locationnum = $cust_pkg->locationnum;
199   include( '/elements/popup_link-cust_pkg.html',
200     'action'      => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
201     'label'       => 'Change&nbsp;package',
202     'actionlabel' => 'Change',
203     'cust_pkg'    => $cust_pkg,
204   );
205 }
206
207 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit&nbsp;dates', @_ ); }
208
209 sub pkg_discount_link {
210   my $cust_pkg = shift or return '';
211   #my $part_pkg = shift;
212   #my $custnum = $cust_pkg->custnum;
213   include( '/elements/popup_link-cust_pkg.html',
214     'action'      => $p.'edit/cust_pkg_discount.html',
215     'label'       => 'Discount',
216     'actionlabel' => 'Discount',
217     'cust_pkg'    => $cust_pkg,
218     'width'       => 616,
219   );
220 }
221
222 sub pkg_customize_link {
223   my $cust_pkg = shift or return '';
224   my $part_pkg = shift;
225   my $custnum = $cust_pkg->custnum;
226   qq!<A HREF="${p}edit/part_pkg.cgi?!.
227     "clone=". $part_pkg->pkgpart. ';'.
228     "pkgnum=". $cust_pkg->pkgnum.
229     qq!">Customize</A>!;
230 }
231
232 sub pkg_event_link {
233   my($cust_pkg) = @_;
234   qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
235   'View package events'.
236   '</a>';
237 }
238
239 </%init>