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)%> )
56 % # also, you can discount it
57 % if ( $curuser->access_right('Discount customer package')
58 % && ! scalar($cust_pkg->cust_pkg_discount_active)
59 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
61 ( <%pkg_discount_link($cust_pkg)%> )
65 % } elsif ( !$cust_pkg->get('cancel') and !$opt{no_links} ) {
67 % if ( $change_from ) {
68 % # This is the target package for a future change.
69 % # Nothing you can do with it besides modify/cancel the
70 % # future change, and that's on the current package.
71 % } elsif ( $supplemental ) {
72 % # Supplemental packages can't be changed independently.
73 % # Show only "Add comments" and "Add invoice details".
75 % # the usual case: links to change package definition,
76 % # discount, and customization
78 % if ( $curuser->access_right('Change customer package') ) {
80 ( <%pkg_change_link($cust_pkg)%> )
83 % if ( $curuser->access_right('Discount customer package')
84 % && $part_pkg->can_discount
85 % && ! scalar( @{ $cust_pkg->{_cust_pkg_discount_active} } )
86 % && ( ! $opt{'term_discounts'}
87 % || ! scalar($cust_pkg->part_pkg->part_pkg_discount)
92 ( <%pkg_discount_link($cust_pkg)%> )
95 % if ( $curuser->access_right('Customize customer package') ) {
97 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
100 <% $br ? '<BR>' : '' %>
103 % if ( ( $curuser->access_right('Billing event reports')
104 % || $curuser->access_right('View customer billing events')
106 % && $cust_pkg->exists_cust_event
108 ( <%pkg_event_link($cust_pkg)%> )
120 % my $change_quan_label = 'Change quantity';
121 % if ( $cust_pkg->quantity > 1 ) {
122 % $change_quan_label = 'change';
123 <% mt('Quantity:') |h %>
124 <B><% $cust_pkg->quantity %></B>
127 % if ( $curuser->access_right('Change customer package')
128 % && ! $cust_pkg->get('cancel')
130 % && $part_pkg->freq ne '0'
131 % && ! $opt{no_links}
132 % && $opt{'invoice-unitprice'}
136 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
147 % my $change_sales_label = 'Change sales person';
148 % if ( $cust_pkg->salesnum ) {
149 % $change_sales_label = 'change';
150 <% mt('Sales Person:') |h %>
151 <B><% $cust_pkg->salesperson |h %></B>
154 % if ( $curuser->access_right('Change customer package')
155 % && ! $cust_pkg->get('cancel')
157 % #&& $part_pkg->freq ne '0'
158 % && ! $opt{no_links}
162 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
170 % my $editi = $curuser->access_right('Edit customer package invoice details');
171 % my $editc = $curuser->access_right('Edit customer package comments');
172 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
173 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
174 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
176 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
178 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
183 % if ( @invoice_detail ) {
185 <& /elements/table-grid.html &>
187 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
189 <% mt('Invoice details') |h %>
190 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
191 (<& /elements/popup_link.html, {
192 'action' => $editlink. 'I',
193 'label' => emt('edit'),
194 'actionlabel' => emt('Edit invoice details'),
195 'color' => '#333399',
203 % foreach my $cust_pkg_detail ( @invoice_detail ) {
205 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
212 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
214 ( <% include('/elements/popup_link.html', {
215 'action' => $editlink. 'I',
216 'label' => emt('Add invoice details'),
217 'actionlabel' => emt('Add invoice details'),
218 'color' => '#333399',
229 <& /elements/table-grid.html &>
231 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
233 <% mt('Comments') |h %>
234 % if ( $editc && ! $opt{no_links} ) {
235 (<& /elements/popup_link.html, {
236 'action' => $editlink. 'C',
237 'label' => emt('edit'),
238 'actionlabel' => emt('Edit comments'),
239 'color' => '#333399',
247 % foreach my $cust_pkg_detail ( @comments ) {
249 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
256 % if ( $editc && ! $opt{no_links} ) {
258 ( <& /elements/popup_link.html, {
259 'action' => $editlink. 'C',
260 'label' => emt('Add comments'),
261 'actionlabel' => emt('Add comments'),
262 'color' => '#333399',
277 % if ( @cust_pkg_usage ) {
278 <TABLE CLASS="usage inv">
279 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
280 % foreach my $usage (@cust_pkg_usage) {
281 % my $part = $usage->part_pkg_usage;
282 % my $ratio = 255 * ($usage->minutes / $part->minutes);
283 % $ratio = 255 if $ratio > 255; # because rollover
284 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
286 % $trstyle = ' CLASS="shared"' if $part->shared;
288 <TD ALIGN="right"><% $part->description %>: </TD>
289 <TD <%$color%> ALIGN="right"><% sprintf('%.1f', $usage->minutes) %></TD>
290 <TD <%$color%>> / </TD>
291 <TD <%$color%>><% $part->minutes %></TD>
292 % if ( $part->shared ) {
293 <TD><I>(shared)</I></TD>
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 or $change_from ) {
322 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
324 if ( $supplemental ) {
326 } elsif ( $change_from ) {
329 $style = qq!STYLE="$style"!;
332 $cust_pkg->pkgnum =~ /^(\d+)$/;
334 my @cust_pkg_usage = qsearch({
335 'select' => 'cust_pkg_usage.*',
336 'table' => 'cust_pkg_usage',
337 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
338 'extra_sql' => " WHERE pkgnum = $1",
339 'order_by' => ' ORDER BY priority ASC, description ASC',
344 #false laziness w/status.html
346 my($action, $label, $cust_pkg) = @_;
347 return '' unless $cust_pkg;
348 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
351 sub pkg_change_link {
352 my $cust_pkg = shift;
353 my $locationnum = $cust_pkg->locationnum;
354 include( '/elements/popup_link-cust_pkg.html',
355 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
356 'label' => emt('Change package'),
357 'actionlabel' => emt('Change'),
358 'cust_pkg' => $cust_pkg,
364 sub onetime_change_link {
365 my $cust_pkg = shift;
366 my $pkgnum = $cust_pkg->pkgnum;
367 include( '/elements/popup_link-cust_pkg.html',
368 'action' => $p. "edit/quick-charge.html?change_pkgnum=$pkgnum",
369 'label' => emt('Modify one-time charge'),
370 'actionlabel' => emt('Modify'),
371 'cust_pkg' => $cust_pkg,
377 sub pkg_change_location_link {
378 my $cust_pkg = shift;
379 my $pkgpart = $cust_pkg->pkgpart;
380 include( '/elements/popup_link-cust_pkg.html',
381 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
382 "address1=;address2=;city=;county=;state=$statedefault;".
383 "zip=;country=$countrydefault",
384 'label' => emt('Change location'),
385 'actionlabel' => emt('Change'),
386 'cust_pkg' => $cust_pkg,
392 sub pkg_change_quantity_link {
393 my( $cust_pkg, $label ) = @_;
394 include( '/elements/popup_link-cust_pkg.html',
395 'action' => $p. 'edit/cust_pkg_quantity.html?',
396 'label' => emt($label),
397 'actionlabel' => emt('Change'),
398 'cust_pkg' => $cust_pkg,
404 sub pkg_change_salesnum_link {
405 my( $cust_pkg, $label ) = @_;
406 include( '/elements/popup_link-cust_pkg.html',
407 'action' => $p. 'edit/cust_pkg_salesnum.html?',
408 'label' => emt($label),
409 'actionlabel' => emt('Change'),
410 'cust_pkg' => $cust_pkg,
416 sub pkg_discount_link {
417 my $cust_pkg = shift or return '';
418 include( '/elements/popup_link-cust_pkg.html',
419 'action' => $p.'edit/cust_pkg_discount.html',
420 'label' => emt('Discount'),
421 'actionlabel' => emt('Discount'),
422 'cust_pkg' => $cust_pkg,
427 sub pkg_customize_link {
428 my $cust_pkg = shift or return '';
429 my $part_pkg = shift;
430 my $custnum = $cust_pkg->custnum;
431 qq!<A HREF="${p}edit/part_pkg.cgi?!.
432 "clone=". $part_pkg->pkgpart. ';'.
433 "pkgnum=". $cust_pkg->pkgnum.
434 qq!">!.emt('Customize').'</A>';
439 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
440 emt('View package events').