1 <TD CLASS="inv package" BGCOLOR="<% $bgcolor %>" VALIGN="top" <%$style%>>
2 <TABLE CLASS="inv package">
5 <% $opt{before_pkg_callback}
6 ? &{ $opt{before_pkg_callback} }( $cust_pkg )
9 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
10 ID ="cust_pkg<% $cust_pkg->pkgnum %>"
11 ><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
13 <% $part_pkg->custom_comment |h %>
17 % if ( $cust_pkg->quantity > 1 ) {
20 <% mt('Quantity:') |h %>
21 <B><% $cust_pkg->quantity %></B>
30 % unless ( $cust_pkg->get('cancel') || $opt{no_links} ) {
32 % if ( $change_from ) {
33 % # This is the target package for a future change.
34 % # Nothing you can do with it besides modify/cancel the
35 % # future change, and that's on the current package.
36 % } elsif ( $supplemental or $part_pkg->freq eq '0' ) {
37 % # Supplemental packages can't be changed independently.
38 % # One-time charges don't need to be changed.
39 % # For both of those, we only show "Add comments",
40 % # and "Add invoice details".
42 % # the usual case: links to change package definition,
43 % # discount, and customization
45 % if ( $curuser->access_right('Change customer package') ) {
47 ( <%pkg_change_link($cust_pkg)%> )
50 % if ( $curuser->access_right('Discount customer package')
51 % && $part_pkg->can_discount
52 % && ! scalar($cust_pkg->cust_pkg_discount_active)
53 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
57 ( <%pkg_discount_link($cust_pkg)%> )
60 % if ( $curuser->access_right('Customize customer package') ) {
62 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
65 <% $br ? '<BR>' : '' %>
68 % if ( $cust_pkg->num_cust_event
69 % && ( $curuser->access_right('Billing event reports')
70 % || $curuser->access_right('View customer billing events')
73 ( <%pkg_event_link($cust_pkg)%> )
81 % my $editi = $curuser->access_right('Edit customer package invoice details');
82 % my $editc = $curuser->access_right('Edit customer package comments');
83 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
84 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
85 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
87 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
89 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
94 % if ( @invoice_detail ) {
96 <& /elements/table-grid.html &>
98 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
100 <% mt('Invoice details') |h %>
101 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
102 (<& /elements/popup_link.html, {
103 'action' => $editlink. 'I',
104 'label' => emt('edit'),
105 'actionlabel' => emt('Edit invoice details'),
106 'color' => '#333399',
114 % foreach my $cust_pkg_detail ( @invoice_detail ) {
116 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
123 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
125 ( <% include('/elements/popup_link.html', {
126 'action' => $editlink. 'I',
127 'label' => emt('Add invoice details'),
128 'actionlabel' => emt('Add invoice details'),
129 'color' => '#333399',
140 <& /elements/table-grid.html &>
142 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
144 <% mt('Comments') |h %>
145 % if ( $editc && ! $opt{no_links} ) {
146 (<& /elements/popup_link.html, {
147 'action' => $editlink. 'C',
148 'label' => emt('edit'),
149 'actionlabel' => emt('Edit comments'),
150 'color' => '#333399',
158 % foreach my $cust_pkg_detail ( @comments ) {
160 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
167 % if ( $editc && ! $opt{no_links} ) {
169 ( <& /elements/popup_link.html, {
170 'action' => $editlink. 'C',
171 'label' => emt('Add comments'),
172 'actionlabel' => emt('Add comments'),
173 'color' => '#333399',
183 % if ( $curuser->access_right('Change customer package')
184 % && ! $cust_pkg->get('cancel')
186 % && $part_pkg->freq ne '0'
187 % && ! $opt{no_links}
191 % # yeah, I guess we'll let you do this on a future change package
192 % if ( FS::Conf->new->exists('invoice-unitprice') ) {
194 ( <% pkg_change_quantity_link($cust_pkg) %> )
201 % if ( @cust_pkg_usage ) {
202 <TABLE CLASS="usage inv">
203 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
204 % foreach my $usage (@cust_pkg_usage) {
205 % my $part = $usage->part_pkg_usage;
206 % my $ratio = 255 * ($usage->minutes / $part->minutes);
207 % $ratio = 255 if $ratio > 255; # because rollover
208 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
210 % $trstyle = ' CLASS="shared"' if $part->shared;
212 <TD ALIGN="right"><% $part->description %>: </TD>
213 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
214 <TD <%$color%>> / </TD>
215 <TD <%$color%>><% $part->minutes %></TD>
216 % if ( $part->shared ) {
217 <TD><I>(shared)</I></TD>
230 my $bgcolor = $opt{'bgcolor'};
231 my $cust_pkg = $opt{'cust_pkg'};
232 my $part_pkg = $opt{'part_pkg'};
234 my $curuser = $FS::CurrentUser::CurrentUser;
236 my $countrydefault = $opt{'countrydefault'} || 'US';
237 my $statedefault = $opt{'statedefault'}
238 || ($countrydefault eq 'US' ? 'CA' : '');
240 # put a marker on the left edge of this column
241 # if this package is somehow special
242 my $supplemental = $opt{'supplemental'} || 0;
243 my $change_from = $opt{'change_from'} || 0;
245 if ( $supplemental or $change_from ) {
246 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
248 if ( $supplemental ) {
250 } elsif ( $change_from ) {
253 $style = qq!STYLE="$style"!;
256 $cust_pkg->pkgnum =~ /^(\d+)$/;
258 my @cust_pkg_usage = qsearch({
259 'select' => 'cust_pkg_usage.*',
260 'table' => 'cust_pkg_usage',
261 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
262 'extra_sql' => " WHERE pkgnum = $1",
263 'order_by' => ' ORDER BY priority ASC, description ASC',
268 #false laziness w/status.html
270 my($action, $label, $cust_pkg) = @_;
271 return '' unless $cust_pkg;
272 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
275 sub pkg_change_link {
276 my $cust_pkg = shift;
277 my $locationnum = $cust_pkg->locationnum;
278 include( '/elements/popup_link-cust_pkg.html',
279 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
280 'label' => emt('Change package'),
281 'actionlabel' => emt('Change'),
282 'cust_pkg' => $cust_pkg,
288 sub pkg_change_location_link {
289 my $cust_pkg = shift;
290 my $pkgpart = $cust_pkg->pkgpart;
291 include( '/elements/popup_link-cust_pkg.html',
292 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
293 "address1=;address2=;city=;county=;state=$statedefault;".
294 "zip=;country=$countrydefault",
295 'label' => emt('Change location'),
296 'actionlabel' => emt('Change'),
297 'cust_pkg' => $cust_pkg,
303 sub pkg_change_quantity_link {
304 include( '/elements/popup_link-cust_pkg.html',
305 'action' => $p. 'edit/cust_pkg_quantity.html?',
306 'label' => emt('Change quantity'),
307 'actionlabel' => emt('Change'),
314 sub pkg_discount_link {
315 my $cust_pkg = shift or return '';
316 include( '/elements/popup_link-cust_pkg.html',
317 'action' => $p.'edit/cust_pkg_discount.html',
318 'label' => emt('Discount'),
319 'actionlabel' => emt('Discount'),
320 'cust_pkg' => $cust_pkg,
325 sub pkg_customize_link {
326 my $cust_pkg = shift or return '';
327 my $part_pkg = shift;
328 my $custnum = $cust_pkg->custnum;
329 qq!<A HREF="${p}edit/part_pkg.cgi?!.
330 "clone=". $part_pkg->pkgpart. ';'.
331 "pkgnum=". $cust_pkg->pkgnum.
332 qq!">!.emt('Customize').'</A>';
337 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
338 emt('View package events').