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 ( 0 && FS::part_pkg::flat->can('price_info') eq $part_pkg->can('price_info') ) {
17 % #perf hack / disabled in 4.x (feature pricing / cust_pkg_usageprice incompatible, well, harder)
19 % $part_pkg->{"_$_"} = $part_pkg->option($_) || 0
20 % foreach grep !defined($part_pkg->{"_$_"} ), qw(setup_fee recur_fee);
23 % $str = $opt{money_char} . $part_pkg->{_setup_fee}.
24 % ($part_pkg->{_recur_fee} ? ' setup' : ' one-time')
25 % if $part_pkg->{_setup_fee};
26 % $str .= ', ' if $part_pkg->{_setup_fee} && $part_pkg->{_recur_fee};
27 % $str .= $opt{money_char}. $part_pkg->{_recur_fee}.
28 % '/'. $part_pkg->freq_pretty
29 % if $part_pkg->{_recur_fee};
33 % ( $part_pkg->custom ? '(CUSTOM) ' : '' ).
35 % ( ($part_pkg->custom || $part_pkg->comment) ? ' - ' : '' ).
36 % ($str || 'No charge');
39 % $custom_comment = $part_pkg->custom_comment('cust_pkg'=>$cust_pkg);
41 <% $custom_comment ? ' - ' : '' %>
42 <% $custom_comment |h %>
51 % if ( $part_pkg->freq eq '0' and !$opt{no_links} ) {
52 % # One-time charge. Nothing you can do with this, unless:
53 % if ( $curuser->access_right('Modify one-time charge') ) {
54 ( <%onetime_change_link($cust_pkg)%> )
58 % } elsif ( !$cust_pkg->get('cancel') and !$opt{no_links} ) {
60 % if ( $change_from ) {
61 % # This is the target package for a future change.
62 % # Nothing you can do with it besides modify/cancel the
63 % # future change, and that's on the current package.
64 % } elsif ( $supplemental ) {
65 % # Supplemental packages can't be changed independently.
66 % # Show only "Add comments" and "Add invoice details".
68 % # the usual case: links to change package definition,
69 % # discount, and customization
71 % if ( $curuser->access_right('Change customer package') ) {
73 ( <%pkg_change_link($cust_pkg)%> )
76 % if ( $curuser->access_right('Discount customer package')
77 % && $part_pkg->can_discount
78 % && ! scalar( @{ $cust_pkg->{_cust_pkg_discount_active} } )
79 % && ( ! $opt{'term_discounts'}
80 % || ! scalar($cust_pkg->part_pkg->part_pkg_discount)
85 ( <%pkg_discount_link($cust_pkg)%> )
88 % if ( $curuser->access_right('Customize customer package') ) {
90 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
93 <% $br ? '<BR>' : '' %>
96 % if ( ( $curuser->access_right('Billing event reports')
97 % || $curuser->access_right('View customer billing events')
99 % && $cust_pkg->exists_cust_event
101 ( <%pkg_event_link($cust_pkg)%> )
113 % my $change_quan_label = 'Change quantity';
114 % if ( $cust_pkg->quantity > 1 ) {
115 % $change_quan_label = 'change';
116 <% mt('Quantity:') |h %>
117 <B><% $cust_pkg->quantity %></B>
120 % if ( $curuser->access_right('Change customer package')
121 % && ! $cust_pkg->get('cancel')
123 % && $part_pkg->freq ne '0'
124 % && ! $opt{no_links}
125 % && $opt{'invoice-unitprice'}
129 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
140 % my $change_sales_label = 'Change sales person';
141 % if ( $cust_pkg->salesnum ) {
142 % $change_sales_label = 'change';
143 <% mt('Sales Person:') |h %>
144 <B><% $cust_pkg->salesperson |h %></B>
147 % if ( $curuser->access_right('Change customer package')
148 % && ! $cust_pkg->get('cancel')
150 % #&& $part_pkg->freq ne '0'
151 % && ! $opt{no_links}
155 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
163 % my $editi = $curuser->access_right('Edit customer package invoice details');
164 % my $editc = $curuser->access_right('Edit customer package comments');
165 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
166 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
167 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
169 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
171 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
176 % if ( @invoice_detail ) {
178 <& /elements/table-grid.html &>
180 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
182 <% mt('Invoice details') |h %>
183 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
184 (<& /elements/popup_link.html, {
185 'action' => $editlink. 'I',
186 'label' => emt('edit'),
187 'actionlabel' => emt('Edit invoice details'),
188 'color' => '#333399',
196 % foreach my $cust_pkg_detail ( @invoice_detail ) {
198 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
205 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
207 ( <% include('/elements/popup_link.html', {
208 'action' => $editlink. 'I',
209 'label' => emt('Add invoice details'),
210 'actionlabel' => emt('Add invoice details'),
211 'color' => '#333399',
222 <& /elements/table-grid.html &>
224 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
226 <% mt('Comments') |h %>
227 % if ( $editc && ! $opt{no_links} ) {
228 (<& /elements/popup_link.html, {
229 'action' => $editlink. 'C',
230 'label' => emt('edit'),
231 'actionlabel' => emt('Edit comments'),
232 'color' => '#333399',
240 % foreach my $cust_pkg_detail ( @comments ) {
242 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
249 % if ( $editc && ! $opt{no_links} ) {
251 ( <& /elements/popup_link.html, {
252 'action' => $editlink. 'C',
253 'label' => emt('Add comments'),
254 'actionlabel' => emt('Add comments'),
255 'color' => '#333399',
270 % if ( @cust_pkg_usage ) {
271 <TABLE CLASS="usage inv">
272 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
273 % foreach my $usage (@cust_pkg_usage) {
274 % my $part = $usage->part_pkg_usage;
275 % my $ratio = 255 * ($usage->minutes / $part->minutes);
276 % $ratio = 255 if $ratio > 255; # because rollover
277 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
279 % $trstyle = ' CLASS="shared"' if $part->shared;
281 <TD ALIGN="right"><% $part->description %>: </TD>
282 <TD <%$color%> ALIGN="right"><% sprintf('%.1f', $usage->minutes) %></TD>
283 <TD <%$color%>> / </TD>
284 <TD <%$color%>><% $part->minutes %></TD>
285 % if ( $part->shared ) {
286 <TD><I>(shared)</I></TD>
299 my $bgcolor = $opt{'bgcolor'};
300 my $cust_pkg = $opt{'cust_pkg'};
301 my $part_pkg = $opt{'part_pkg'};
303 my $curuser = $FS::CurrentUser::CurrentUser;
305 my $countrydefault = $opt{'countrydefault'} || 'US';
306 my $statedefault = $opt{'statedefault'}
307 || ($countrydefault eq 'US' ? 'CA' : '');
309 # put a marker on the left edge of this column
310 # if this package is somehow special
311 my $supplemental = $opt{'supplemental'} || 0;
312 my $change_from = $opt{'change_from'} || 0;
314 if ( $supplemental or $change_from ) {
315 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
317 if ( $supplemental ) {
319 } elsif ( $change_from ) {
322 $style = qq!STYLE="$style"!;
325 $cust_pkg->pkgnum =~ /^(\d+)$/;
327 my @cust_pkg_usage = qsearch({
328 'select' => 'cust_pkg_usage.*',
329 'table' => 'cust_pkg_usage',
330 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
331 'extra_sql' => " WHERE pkgnum = $1",
332 'order_by' => ' ORDER BY priority ASC, description ASC',
337 #false laziness w/status.html
339 my($action, $label, $cust_pkg) = @_;
340 return '' unless $cust_pkg;
341 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
344 sub pkg_change_link {
345 my $cust_pkg = shift;
346 my $locationnum = $cust_pkg->locationnum;
347 include( '/elements/popup_link-cust_pkg.html',
348 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
349 'label' => emt('Change package'),
350 'actionlabel' => emt('Change'),
351 'cust_pkg' => $cust_pkg,
357 sub onetime_change_link {
358 my $cust_pkg = shift;
359 my $pkgnum = $cust_pkg->pkgnum;
360 include( '/elements/popup_link-cust_pkg.html',
361 'action' => $p. "edit/quick-charge.html?change_pkgnum=$pkgnum",
362 'label' => emt('Modify one-time charge'),
363 'actionlabel' => emt('Modify'),
364 'cust_pkg' => $cust_pkg,
370 sub pkg_change_location_link {
371 my $cust_pkg = shift;
372 my $pkgpart = $cust_pkg->pkgpart;
373 include( '/elements/popup_link-cust_pkg.html',
374 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
375 "address1=;address2=;city=;county=;state=$statedefault;".
376 "zip=;country=$countrydefault",
377 'label' => emt('Change location'),
378 'actionlabel' => emt('Change'),
379 'cust_pkg' => $cust_pkg,
385 sub pkg_change_quantity_link {
386 my( $cust_pkg, $label ) = @_;
387 include( '/elements/popup_link-cust_pkg.html',
388 'action' => $p. 'edit/cust_pkg_quantity.html?',
389 'label' => emt($label),
390 'actionlabel' => emt('Change'),
391 'cust_pkg' => $cust_pkg,
397 sub pkg_change_salesnum_link {
398 my( $cust_pkg, $label ) = @_;
399 include( '/elements/popup_link-cust_pkg.html',
400 'action' => $p. 'edit/cust_pkg_salesnum.html?',
401 'label' => emt($label),
402 'actionlabel' => emt('Change'),
403 'cust_pkg' => $cust_pkg,
409 sub pkg_discount_link {
410 my $cust_pkg = shift or return '';
411 include( '/elements/popup_link-cust_pkg.html',
412 'action' => $p.'edit/cust_pkg_discount.html',
413 'label' => emt('Discount'),
414 'actionlabel' => emt('Discount'),
415 'cust_pkg' => $cust_pkg,
420 sub pkg_customize_link {
421 my $cust_pkg = shift or return '';
422 my $part_pkg = shift;
423 my $custnum = $cust_pkg->custnum;
424 qq!<A HREF="${p}edit/part_pkg.cgi?!.
425 "clone=". $part_pkg->pkgpart. ';'.
426 "pkgnum=". $cust_pkg->pkgnum.
427 qq!">!.emt('Customize').'</A>';
432 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
433 emt('View package events').