1 <TD CLASS="inv package" BGCOLOR="<% $bgcolor %>" VALIGN="top">
2 <% join('', @marker ) %>
3 <TABLE CLASS="inv package">
6 <% $opt{before_pkg_callback}
7 ? &{ $opt{before_pkg_callback} }( $cust_pkg )
10 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
11 ID ="cust_pkg<% $cust_pkg->pkgnum %>"
12 ><% $opt{show_pkgnum} ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
15 % if ( 0 && FS::part_pkg::flat->can('price_info') eq $part_pkg->can('price_info') ) {
16 % #perf hack / disabled in 4.x (feature pricing / cust_pkg_usageprice incompatible, well, harder)
18 % $part_pkg->{"_$_"} = $part_pkg->option($_) || 0
19 % foreach grep !defined($part_pkg->{"_$_"} ), qw(setup_fee recur_fee);
22 % $str = $opt{money_char} . $part_pkg->{_setup_fee}.
23 % ($part_pkg->{_recur_fee} ? ' setup' : ' one-time')
24 % if $part_pkg->{_setup_fee};
25 % $str .= ', ' if $part_pkg->{_setup_fee} && $part_pkg->{_recur_fee};
26 % $str .= $opt{money_char}. $part_pkg->{_recur_fee}.
27 % '/'. $part_pkg->freq_pretty
28 % if $part_pkg->{_recur_fee};
32 % ( $part_pkg->custom ? '(CUSTOM) ' : '' ).
34 % ( ($part_pkg->custom || $part_pkg->comment) ? ' - ' : '' ).
35 % ($str || 'No charge');
38 % $custom_comment = $part_pkg->custom_comment('cust_pkg'=>$cust_pkg);
40 <% $custom_comment ? ' - ' : '' %>
41 <% $custom_comment |h %>
50 % if ( $part_pkg->freq eq '0' and !$opt{no_links} ) {
51 % # One-time charge. Nothing you can do with this, unless:
52 % if ( $curuser->access_right('Modify one-time charge') ) {
53 ( <%onetime_change_link($cust_pkg)%> )
55 % # also, you can discount it
56 % if ( $curuser->access_right('Discount customer package')
57 % && ! scalar($cust_pkg->cust_pkg_discount_active)
58 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
60 ( <%pkg_discount_link($cust_pkg)%> )
64 % } elsif ( !$cust_pkg->get('cancel') and !$opt{no_links} ) {
66 % if ( $change_from ) {
67 % # This is the target package for a future change.
68 % # Nothing you can do with it besides modify/cancel the
69 % # future change, and that's on the current package.
70 % } elsif ( $supplemental ) {
71 % # Supplemental packages can't be changed independently.
72 % # Show only "Add comments" and "Add invoice details".
74 % # the usual case: links to change package definition,
75 % # discount, and customization
77 % if ( $curuser->access_right('Change customer package') ) {
79 ( <%pkg_change_link($cust_pkg)%> )
82 % if ( $curuser->access_right('Discount customer package')
83 % && $part_pkg->can_discount
84 % && ! scalar( @{ $cust_pkg->{_cust_pkg_discount_active} } )
85 % && ( ! $opt{'term_discounts'}
86 % || ! scalar($cust_pkg->part_pkg->part_pkg_discount)
91 ( <%pkg_discount_link($cust_pkg)%> )
94 % if ( $curuser->access_right('Customize customer package') ) {
96 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
99 <% $br ? '<BR>' : '' %>
102 % if ( ( $curuser->access_right('Billing event reports')
103 % || $curuser->access_right('View customer billing events')
105 % && $cust_pkg->exists_cust_event
107 ( <%pkg_event_link($cust_pkg)%> )
109 % } # a canceled recurring package, or else no_links is in effect
119 % my $change_quan_label = 'Change quantity';
120 % if ( $cust_pkg->quantity > 1 ) {
121 % $change_quan_label = 'change';
122 <% mt('Quantity:') |h %>
123 <B><% $cust_pkg->quantity %></B>
126 % if ( $curuser->access_right('Change customer package')
127 % && ! $cust_pkg->get('cancel')
129 % && $part_pkg->freq ne '0'
130 % && ! $opt{no_links}
131 % && $opt{'invoice-unitprice'}
135 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
146 % my $change_sales_label = 'Change sales person';
147 % if ( $cust_pkg->salesnum ) {
148 % $change_sales_label = 'change';
149 <% mt('Sales Person:') |h %>
150 <B><% $cust_pkg->salesperson |h %></B>
153 % if ( $curuser->access_right('Change customer package')
154 % && ! $cust_pkg->get('cancel')
156 % #&& $part_pkg->freq ne '0'
157 % && ! $opt{no_links}
161 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
169 % my $editi = $curuser->access_right('Edit customer package invoice details');
170 % my $editc = $curuser->access_right('Edit customer package comments');
171 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
172 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
173 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
175 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
177 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
182 % if ( @invoice_detail ) {
184 <& /elements/table-grid.html &>
186 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
188 <% mt('Invoice details') |h %>
189 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
190 (<& /elements/popup_link.html, {
191 'action' => $editlink. 'I',
192 'label' => emt('edit'),
193 'actionlabel' => emt('Edit invoice details'),
194 'color' => '#333399',
202 % foreach my $cust_pkg_detail ( @invoice_detail ) {
204 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
211 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
213 ( <% include('/elements/popup_link.html', {
214 'action' => $editlink. 'I',
215 'label' => emt('Add invoice details'),
216 'actionlabel' => emt('Add invoice details'),
217 'color' => '#333399',
228 <& /elements/table-grid.html &>
230 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
232 <% mt('Comments') |h %>
233 % if ( $editc && ! $opt{no_links} ) {
234 (<& /elements/popup_link.html, {
235 'action' => $editlink. 'C',
236 'label' => emt('edit'),
237 'actionlabel' => emt('Edit comments'),
238 'color' => '#333399',
246 % foreach my $cust_pkg_detail ( @comments ) {
248 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
255 % if ( $editc && ! $opt{no_links} ) {
257 ( <& /elements/popup_link.html, {
258 'action' => $editlink. 'C',
259 'label' => emt('Add comments'),
260 'actionlabel' => emt('Add comments'),
261 'color' => '#333399',
276 % if ( @cust_pkg_usage ) {
277 <TABLE CLASS="usage inv">
278 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
279 % foreach my $usage (@cust_pkg_usage) {
280 % my $part = $usage->part_pkg_usage;
281 % my $ratio = 255 * ($usage->minutes / $part->minutes);
282 % $ratio = 255 if $ratio > 255; # because rollover
283 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
285 % $trstyle = ' CLASS="shared"' if $part->shared;
287 <TD ALIGN="right"><% $part->description %>: </TD>
288 <TD <%$color%> ALIGN="right"><% sprintf('%.1f', $usage->minutes) %></TD>
289 <TD <%$color%>> / </TD>
290 <TD <%$color%>><% $part->minutes %></TD>
291 % if ( $part->shared ) {
292 <TD><I>(shared)</I></TD>
299 <% join('', map '</DIV>', @marker ) %>
306 my $bgcolor = $opt{'bgcolor'};
307 my $cust_pkg = $opt{'cust_pkg'};
308 my $part_pkg = $opt{'part_pkg'};
310 my $curuser = $FS::CurrentUser::CurrentUser;
312 my $countrydefault = $opt{'countrydefault'} || 'US';
313 my $statedefault = $opt{'statedefault'}
314 || ($countrydefault eq 'US' ? 'CA' : '');
316 # put a marker on the left edge of this column
317 # if this package is somehow special
318 my $supplemental = $opt{'supplemental'} || 0;
319 my $change_from = $opt{'change_from'} || 0;
321 if ( $supplemental ) {
322 push @marker, '<DIV CLASS="package-marker-supplemental">';
324 if ( $change_from ) {
325 push @marker, '<DIV CLASS="package-marker-change_from">';
328 $cust_pkg->pkgnum =~ /^(\d+)$/;
330 my @cust_pkg_usage = qsearch({
331 'select' => 'cust_pkg_usage.*',
332 'table' => 'cust_pkg_usage',
333 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
334 'extra_sql' => " WHERE pkgnum = $1",
335 'order_by' => ' ORDER BY priority ASC, description ASC',
340 #false laziness w/status.html
342 my($action, $label, $cust_pkg) = @_;
343 return '' unless $cust_pkg;
344 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
347 sub pkg_change_link {
348 my $cust_pkg = shift;
349 my $locationnum = $cust_pkg->locationnum;
350 include( '/elements/popup_link-cust_pkg.html',
351 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
352 'label' => emt('Change package'),
353 'actionlabel' => emt('Change'),
354 'cust_pkg' => $cust_pkg,
360 sub onetime_change_link {
361 my $cust_pkg = shift;
362 my $pkgnum = $cust_pkg->pkgnum;
363 include( '/elements/popup_link-cust_pkg.html',
364 'action' => $p. "edit/quick-charge.html?change_pkgnum=$pkgnum",
365 'label' => emt('Modify one-time charge'),
366 'actionlabel' => emt('Modify'),
367 'cust_pkg' => $cust_pkg,
373 sub pkg_change_location_link {
374 my $cust_pkg = shift;
375 my $pkgpart = $cust_pkg->pkgpart;
376 include( '/elements/popup_link-cust_pkg.html',
377 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
378 "address1=;address2=;city=;county=;state=$statedefault;".
379 "zip=;country=$countrydefault",
380 'label' => emt('Change location'),
381 'actionlabel' => emt('Change'),
382 'cust_pkg' => $cust_pkg,
388 sub pkg_change_quantity_link {
389 my( $cust_pkg, $label ) = @_;
390 include( '/elements/popup_link-cust_pkg.html',
391 'action' => $p. 'edit/cust_pkg_quantity.html?',
392 'label' => emt($label),
393 'actionlabel' => emt('Change'),
394 'cust_pkg' => $cust_pkg,
400 sub pkg_change_salesnum_link {
401 my( $cust_pkg, $label ) = @_;
402 include( '/elements/popup_link-cust_pkg.html',
403 'action' => $p. 'edit/cust_pkg_salesnum.html?',
404 'label' => emt($label),
405 'actionlabel' => emt('Change'),
406 'cust_pkg' => $cust_pkg,
412 sub pkg_discount_link {
413 my $cust_pkg = shift or return '';
414 include( '/elements/popup_link-cust_pkg.html',
415 'action' => $p.'edit/cust_pkg_discount.html',
416 'label' => emt('Discount'),
417 'actionlabel' => emt('Discount'),
418 'cust_pkg' => $cust_pkg,
423 sub pkg_customize_link {
424 my $cust_pkg = shift or return '';
425 my $part_pkg = shift;
426 my $custnum = $cust_pkg->custnum;
427 qq!<A HREF="${p}edit/part_pkg.cgi?!.
428 "clone=". $part_pkg->pkgpart. ';'.
429 "pkgnum=". $cust_pkg->pkgnum.
430 qq!">!.emt('Customize').'</A>';
435 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
436 emt('View package events').