1 <TD CLASS="inv package" BGCOLOR="<% $bgcolor %>" VALIGN="top" <%$style%>>
2 <TABLE CLASS="inv package">
7 <% $opt{before_pkg_callback}
8 ? &{ $opt{before_pkg_callback} }( $cust_pkg )
11 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
12 ID ="cust_pkg<% $cust_pkg->pkgnum %>"
13 ><% $opt{show_pkgnum} ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
16 % if ( FS::part_pkg::flat->can('price_info') eq $part_pkg->can('price_info') ) {
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();
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 % # Show only "Add comments" and "Add invoice details".
72 % if ( $curuser->access_right('Edit customer package dates') ) {
73 ( <%pkg_dates_link($cust_pkg)%> )
77 % # the usual case: links to change package definition,
78 % # discount, and customization
80 % if ( $curuser->access_right('Change customer package') ) {
82 ( <%pkg_change_link($cust_pkg)%> )
85 % if ( $curuser->access_right('Edit customer package dates') ) {
87 ( <%pkg_dates_link($cust_pkg)%> )
90 % if ( $curuser->access_right('Discount customer package')
91 % && $part_pkg->can_discount
92 % && ! scalar( @{ $cust_pkg->{_cust_pkg_discount_active} } )
93 % && ( ! $opt{'term_discounts'}
94 % || ! scalar($cust_pkg->part_pkg->part_pkg_discount)
99 ( <%pkg_discount_link($cust_pkg)%> )
102 % if ( $curuser->access_right('Customize customer package') ) {
104 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
107 <% $br ? '<BR>' : '' %>
110 % if ( ( $curuser->access_right('Billing event reports')
111 % || $curuser->access_right('View customer billing events')
113 % && $cust_pkg->exists_cust_event
115 ( <%pkg_event_link($cust_pkg)%> )
127 % my $change_quan_label = 'Change quantity';
128 % if ( $cust_pkg->quantity > 1 ) {
129 % $change_quan_label = 'change';
130 <% mt('Quantity:') |h %>
131 <B><% $cust_pkg->quantity %></B>
134 % if ( $curuser->access_right('Change customer package')
135 % && ! $cust_pkg->get('cancel')
137 % && $part_pkg->freq ne '0'
138 % && ! $opt{no_links}
139 % && $opt{'invoice-unitprice'}
143 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
154 % my $change_sales_label = 'Change sales person';
155 % if ( $cust_pkg->salesnum ) {
156 % $change_sales_label = 'change';
157 <% mt('Sales Person:') |h %>
158 <B><% $cust_pkg->salesperson |h %></B>
161 % if ( $curuser->access_right('Change customer package')
162 % && ! $cust_pkg->get('cancel')
164 % #&& $part_pkg->freq ne '0'
165 % && ! $opt{no_links}
169 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
177 % my $editi = $curuser->access_right('Edit customer package invoice details');
178 % my $editc = $curuser->access_right('Edit customer package comments');
179 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
180 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
181 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
183 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
185 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
190 % if ( @invoice_detail ) {
192 <& /elements/table-grid.html &>
194 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
196 <% mt('Invoice details') |h %>
197 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
198 (<& /elements/popup_link.html, {
199 'action' => $editlink. 'I',
200 'label' => emt('edit'),
201 'actionlabel' => emt('Edit invoice details'),
202 'color' => '#333399',
210 % foreach my $cust_pkg_detail ( @invoice_detail ) {
212 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
219 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
221 ( <% include('/elements/popup_link.html', {
222 'action' => $editlink. 'I',
223 'label' => emt('Add invoice details'),
224 'actionlabel' => emt('Add invoice details'),
225 'color' => '#333399',
236 <& /elements/table-grid.html &>
238 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
240 <% mt('Comments') |h %>
241 % if ( $editc && ! $opt{no_links} ) {
242 (<& /elements/popup_link.html, {
243 'action' => $editlink. 'C',
244 'label' => emt('edit'),
245 'actionlabel' => emt('Edit comments'),
246 'color' => '#333399',
254 % foreach my $cust_pkg_detail ( @comments ) {
256 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
263 % if ( $editc && ! $opt{no_links} ) {
265 ( <& /elements/popup_link.html, {
266 'action' => $editlink. 'C',
267 'label' => emt('Add comments'),
268 'actionlabel' => emt('Add comments'),
269 'color' => '#333399',
284 % if ( @cust_pkg_usage ) {
285 <TABLE CLASS="usage inv">
286 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
287 % foreach my $usage (@cust_pkg_usage) {
288 % my $part = $usage->part_pkg_usage;
289 % my $ratio = 255 * ($usage->minutes / $part->minutes);
290 % $ratio = 255 if $ratio > 255; # because rollover
291 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
293 % $trstyle = ' CLASS="shared"' if $part->shared;
295 <TD ALIGN="right"><% $part->description %>: </TD>
296 <TD <%$color%> ALIGN="right"><% sprintf('%.1f', $usage->minutes) %></TD>
297 <TD <%$color%>> / </TD>
298 <TD <%$color%>><% $part->minutes %></TD>
299 % if ( $part->shared ) {
300 <TD><I>(shared)</I></TD>
313 my $bgcolor = $opt{'bgcolor'};
314 my $cust_pkg = $opt{'cust_pkg'};
315 my $part_pkg = $opt{'part_pkg'};
317 my $curuser = $FS::CurrentUser::CurrentUser;
319 my $countrydefault = $opt{'countrydefault'} || 'US';
320 my $statedefault = $opt{'statedefault'}
321 || ($countrydefault eq 'US' ? 'CA' : '');
323 # put a marker on the left edge of this column
324 # if this package is somehow special
325 my $supplemental = $opt{'supplemental'} || 0;
326 my $change_from = $opt{'change_from'} || 0;
328 if ( $supplemental or $change_from ) {
329 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
331 if ( $supplemental ) {
333 } elsif ( $change_from ) {
336 $style = qq!STYLE="$style"!;
339 $cust_pkg->pkgnum =~ /^(\d+)$/;
341 my @cust_pkg_usage = qsearch({
342 'select' => 'cust_pkg_usage.*',
343 'table' => 'cust_pkg_usage',
344 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
345 'extra_sql' => " WHERE pkgnum = $1",
346 'order_by' => ' ORDER BY priority ASC, description ASC',
351 #false laziness w/status.html
353 my($action, $label, $cust_pkg) = @_;
354 return '' unless $cust_pkg;
355 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
358 sub pkg_change_link {
359 my $cust_pkg = shift;
360 my $locationnum = $cust_pkg->locationnum;
361 include( '/elements/popup_link-cust_pkg.html',
362 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
363 'label' => emt('Change package'),
364 'actionlabel' => emt('Change'),
365 'cust_pkg' => $cust_pkg,
371 sub onetime_change_link {
372 my $cust_pkg = shift;
373 my $pkgnum = $cust_pkg->pkgnum;
374 include( '/elements/popup_link-cust_pkg.html',
375 'action' => $p. "edit/quick-charge.html?change_pkgnum=$pkgnum",
376 'label' => emt('Modify one-time charge'),
377 'actionlabel' => emt('Modify'),
378 'cust_pkg' => $cust_pkg,
384 sub pkg_change_location_link {
385 my $cust_pkg = shift;
386 my $pkgpart = $cust_pkg->pkgpart;
387 include( '/elements/popup_link-cust_pkg.html',
388 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
389 "address1=;address2=;city=;county=;state=$statedefault;".
390 "zip=;country=$countrydefault",
391 'label' => emt('Change location'),
392 'actionlabel' => emt('Change'),
393 'cust_pkg' => $cust_pkg,
399 sub pkg_change_quantity_link {
400 my( $cust_pkg, $label ) = @_;
401 include( '/elements/popup_link-cust_pkg.html',
402 'action' => $p. 'edit/cust_pkg_quantity.html?',
403 'label' => emt($label),
404 'actionlabel' => emt('Change'),
405 'cust_pkg' => $cust_pkg,
411 sub pkg_change_salesnum_link {
412 my( $cust_pkg, $label ) = @_;
413 include( '/elements/popup_link-cust_pkg.html',
414 'action' => $p. 'edit/cust_pkg_salesnum.html?',
415 'label' => emt($label),
416 'actionlabel' => emt('Change'),
417 'cust_pkg' => $cust_pkg,
423 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', emt('Edit dates'), @_ ); }
425 sub pkg_discount_link {
426 my $cust_pkg = shift or return '';
427 include( '/elements/popup_link-cust_pkg.html',
428 'action' => $p.'edit/cust_pkg_discount.html',
429 'label' => emt('Discount'),
430 'actionlabel' => emt('Discount'),
431 'cust_pkg' => $cust_pkg,
436 sub pkg_customize_link {
437 my $cust_pkg = shift or return '';
438 my $part_pkg = shift;
439 my $custnum = $cust_pkg->custnum;
440 qq!<A HREF="${p}edit/part_pkg.cgi?!.
441 "clone=". $part_pkg->pkgpart. ';'.
442 "pkgnum=". $cust_pkg->pkgnum.
443 qq!">!.emt('Customize').'</A>';
448 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
449 emt('View package events').