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 )
14 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
15 ID ="cust_pkg<% $cust_pkg->pkgnum %>"
16 ><% $opt{show_pkgnum} ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
19 % if ( 0 && FS::part_pkg::flat->can('price_info') eq $part_pkg->can('price_info') ) {
20 % #perf hack / disabled in 4.x (feature pricing / cust_pkg_usageprice incompatible, well, harder)
22 % $part_pkg->{"_$_"} = $part_pkg->option($_) || 0
23 % foreach grep !defined($part_pkg->{"_$_"} ), qw(setup_fee recur_fee);
26 % $str = $opt{money_char} . $part_pkg->{_setup_fee}.
27 % ($part_pkg->{_recur_fee} ? ' setup' : ' one-time')
28 % if $part_pkg->{_setup_fee};
29 % $str .= ', ' if $part_pkg->{_setup_fee} && $part_pkg->{_recur_fee};
30 % $str .= $opt{money_char}. $part_pkg->{_recur_fee}.
31 % '/'. $part_pkg->freq_pretty
32 % if $part_pkg->{_recur_fee};
36 % ( $part_pkg->custom ? '(CUSTOM) ' : '' ).
38 % ( ($part_pkg->custom || $part_pkg->comment) ? ' - ' : '' ).
39 % ($str || 'No charge');
42 % $custom_comment = $part_pkg->custom_comment('cust_pkg'=>$cust_pkg);
44 <% $custom_comment ? ' - ' : '' %>
45 <% $custom_comment |h %>
52 % if ( $cust_pkg->quantity > 1 ) {
55 <% mt('Quantity:') |h %>
56 <B><% $cust_pkg->quantity %></B>
58 % if ( $curuser->access_right('Change customer package')
59 % && ! $cust_pkg->get('cancel')
62 % && $part_pkg->freq ne '0'
64 % && $opt{'invoice-unitprice'}
68 ( <% pkg_change_quantity_link($cust_pkg, 'change') %> )
78 % if ( $cust_pkg->salesnum ) {
81 <% mt('Sales Person:') |h %>
82 <B><% $cust_pkg->salesperson |h %></B>
83 % if ( $curuser->access_right('Change customer package')
84 % && ! $cust_pkg->get('cancel')
87 % #&& $part_pkg->freq ne '0'
92 ( <% pkg_change_salesnum_link($cust_pkg, 'change') %> )
101 % # Invoice details & comments
103 % my $editi = $curuser->access_right('Edit customer package invoice details');
104 % my $editc = $curuser->access_right('Edit customer package comments');
105 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
106 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
107 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
109 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
111 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
116 % if ( @invoice_detail ) {
118 <& /elements/table-grid.html &>
120 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
122 <% mt('Invoice details') |h %>
123 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
124 (<& /elements/popup_link.html, {
125 'action' => $editlink. 'I',
126 'label' => emt('edit'),
127 'actionlabel' => emt('Edit invoice details'),
128 'color' => '#333399',
136 % foreach my $cust_pkg_detail ( @invoice_detail ) {
138 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
150 <& /elements/table-grid.html &>
152 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
154 <% mt('Comments') |h %>
155 % if ( $editc && ! $opt{no_links} ) {
156 (<& /elements/popup_link.html, {
157 'action' => $editlink. 'C',
158 'label' => emt('edit'),
159 'actionlabel' => emt('Edit comments'),
160 'color' => '#333399',
168 % foreach my $cust_pkg_detail ( @comments ) {
170 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
186 % if ( @cust_pkg_usage ) {
187 <TABLE CLASS="usage inv">
188 <TR><TH COLSPAN=4><% emt('Included usage') %></TH></TR>
189 % foreach my $usage (@cust_pkg_usage) {
190 % my $part = $usage->part_pkg_usage;
191 % my $ratio = 255 * ($usage->minutes / $part->minutes);
192 % $ratio = 255 if $ratio > 255; # because rollover
193 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
195 % $trstyle = ' CLASS="shared"' if $part->shared;
197 <TD ALIGN="right"><% $part->description %>: </TD>
198 <TD <%$color%> ALIGN="right"><% sprintf('%.1f', $usage->minutes) %></TD>
199 <TD <%$color%>> / </TD>
200 <TD <%$color%>><% $part->minutes %></TD>
201 % if ( $part->shared ) {
202 <TD><I>(shared)</I></TD>
211 % # Package actions dropdown
213 % unless ( $opt{no_links} ) {
215 <TABLE CLASS="inv package">
219 % my $plink = "pkgnum=$pkgnum";
220 % my $reg_recur_cond = sub { $part_pkg->freq ne '0'
223 % && ! $cust_pkg->get('cancel')
225 % my $change_cond = sub { $part_pkg->freq ne '0'
228 % && ! $cust_pkg->get('cancel')
229 % && $cust_pkg->change_to_pkgnum,
232 <& /elements/dropdown-menu.html,
233 id => 'cust_pkg'. $cust_pkg->pkgnum. '_menu',
234 bgcolor => $opt{row} % 2 ? '#ffffff' : '#eeeeee',
238 #TODO: order/group these better
240 { label => 'Package actions',
242 '<FONT STYLE="text-decoration:underline;font-weight:bold">'.
243 'Package actions</FONT>'.
244 ' <IMG SRC="'.$p.'images/arrow.down.black.png">',
247 { label => 'Modify one-time charge',
248 acl => 'Modify one-time charge',
249 condition => sub { $part_pkg->freq eq '0' },
250 url => "edit/quick-charge.html?change_$plink",
253 { label => 'Change package',
254 acl => 'Change customer package',
255 condition => $reg_recur_cond,
256 popup => "misc/change_pkg.cgi?$plink".
257 ';locationnum='. $cust_pkg->locationnum.
258 actionlabel => emt('Change package'),
264 { label => 'Discount package',
265 condition => sub { $part_pkg->freq ne '0'
268 && ! $cust_pkg->get('cancel')
271 popup => "edit/cust_pkg_discount.html?$plink".
272 actionlabel => emt('Discount package'),
276 { label => 'Customize package',
277 acl => 'Customize customer package',
278 condition => $reg_recur_cond,
279 url => "edit/part_pkg.cgi?$plink".
280 ';clone='. $part_pkg->pkgpart,
283 { label => 'View package events',
284 acl => [ 'Billing event reports',
285 'View customer billing events', ],
286 condition => sub { $cust_pkg->exists_cust_event },
287 url => "search/cust_event.html?$plink",
290 { label => 'Change quantity',
291 acl => 'Change customer package',
292 condition => sub { $part_pkg->freq ne '0'
295 && ! $cust_pkg->get('cancel')
296 && $opt{'invoice-unitprice'}
298 popup => "edit/cust_pkg_quantity.html?$plink",
300 actionlabel => emt('Change quantity'),
305 { label => 'Change sales person',
306 acl => 'Change customer package',
307 condition => sub { ! $change_from
309 && ! $cust_pkg->get('cancel')
311 popup => "edit/cust_pkg_salesnum.html?$plink",
312 actionlabel => emt('Change sales persion'),
317 { label => (@invoice_detail ? 'Edit' : 'Add').
319 acl => 'Edit customer package invoice details',
320 condition => sub { ! $cust_pkg->get('cancel') },
321 popup => "edit/cust_pkg_detail.html?$plink".
323 actionlabel => emt( (@invoice_detail ? 'Edit' : 'Add').
329 { label => (@comments ? 'Edit' : 'Add'). ' comments',
330 acl => 'Edit customer package comments',
331 popup => "edit/cust_pkg_detail.html?$plink".
333 actionlabel => emt( (@comments ? 'Edit' : 'Add').
340 condition => sub { $part_pkg->freq ne '0' },
344 { label => 'Set start date',
345 acl => 'Change package start date',
346 condition => sub { $part_pkg->freq ne '0'
349 && ! $cust_pkg->get('cancel')
350 && ! $cust_pkg->get('setup')
352 popup => "misc/change_pkg_date.html?$plink".
354 actionlabel => emt('Set start of billing for'),
359 { label => 'Set contract end',
360 acl => 'Change package contract end date',
361 condition => sub { $part_pkg->freq ne '0'
364 && ! $cust_pkg->get('cancel')
365 && ! $cust_pkg->change_to_pkgnum
367 popup => "misc/change_pkg_date.html?$plink".
368 ';field=contract_end',
369 actionlabel => emt('Set contract end for'),
375 condition => sub { $part_pkg->freq ne '0' },
379 { label => 'Change now',
380 acl => 'Change customer package',
381 condition => $change_cond,
382 url => "misc/change_pkg_now.cgi?$pkgnum",
385 { label => 'Reschedule',
386 acl => 'Change customer package',
387 condition => sub { $part_pkg->freq ne '0'
390 && ! $cust_pkg->get('cancel')
391 && $cust_pkg->change_to_pkgnum,
393 popup => "misc/change_pkg.html?$plink",
394 actionlabel => emt('Edit scheduled change for'),
395 url => "misc/change_pkg_now.cgi?$pkgnum",
401 { label => 'Abort change',
402 acl => 'Change customer package',
403 condition => $change_cond,
404 url => "misc/do_not_change_pkg.cgi?$pkgnum",
408 acl => 'Change customer package',
409 condition => $change_cond,
413 { label => 'Suspend now',
414 acl => 'Suspend customer package',
415 condition => sub { $part_pkg->freq ne '0'
418 && ! $cust_pkg->get('cancel')
419 && ! $cust_pkg->get('susp')
421 popup => "misc/cancel_pkg.html?method=suspend;$plink",
422 actionlabel => emt('Suspend now'),
428 { label => 'Suspend later',
429 acl => 'Suspend customer package later',
430 condition => sub { $part_pkg->freq ne '0'
433 && ! $cust_pkg->get('cancel')
434 && ! $cust_pkg->get('susp')
436 popup => "misc/cancel_pkg.html?method=adjourn;$plink",
437 actionlabel => emt('Suspend later'),
443 { label => $cust_pkg->dundate
444 ? 'Edit suspension delay'
447 acl => 'Delay suspension events',
448 condition => sub { $part_pkg->freq ne '0'
451 && ! $cust_pkg->get('cancel')
452 && ! $cust_pkg->get('susp')
454 popup => "misc/delay_susp_pkg.html?$plink",
455 actionlabel => emt('Delay suspend for'),
459 { label => 'Start billing',
460 acl => 'Unsuspend customer package',
461 condition => sub { $part_pkg->freq ne '0'
464 && ! $cust_pkg->get('cancel')
465 && $cust_pkg->get('susp')
466 && $cust_pkg->order_date == $cust_pkg->get('susp')
468 popup => "misc/unhold_pkg.html?$plink",
469 actionlabel => emt('Start billing'),
475 { label => 'Unsuspend now',
476 acl => 'Unsuspend customer package',
477 condition => sub { $part_pkg->freq ne '0'
480 && ! $cust_pkg->get('cancel')
481 && $cust_pkg->get('susp')
482 && $cust_pkg->order_date != $cust_pkg->get('susp')
484 'url' => "misc/unsusp_pkg.cgi?$pkgnum",
487 { label => 'Unsuspend later',
488 acl => 'Unsuspend customer package',
489 condition => sub { $part_pkg->freq ne '0'
492 && ! $cust_pkg->get('cancel')
493 && $cust_pkg->get('susp')
494 && $cust_pkg->order_date != $cust_pkg->get('susp')
496 popup => "misc/cancel_pkg.html?method=resume;$plink",
497 actionlabel => emt('Unsuspend later'),
503 condition => sub { $part_pkg->freq ne '0'
506 && ! $cust_pkg->get('cancel')
507 && ! $cust_pkg->get('susp')
512 { label => 'Cancel now',
513 acl => 'Cancel customer package immediately',
514 condition => sub { $part_pkg->freq ne '0'
517 && ! $cust_pkg->change_to_pkgnum
518 && ! $cust_pkg->get('cancel')
520 popup => "misc/cancel_pkg.html?method=cancel;$plink",
521 actionlabel => emt('Cancel now'),
526 { label => 'Cancel later',
527 acl => 'Cancel customer package later',
528 condition => sub { $part_pkg->freq ne '0'
531 && ! $cust_pkg->change_to_pkgnum
532 && ! $cust_pkg->get('cancel')
534 popup => "misc/cancel_pkg.html?method=expire;$plink",
535 actionlabel => emt('Cancel later'),
540 { label => 'Un-cancel',
541 acl => 'Un-cancel customer package',
542 condition => sub { $part_pkg->freq ne '0'
544 && ! $cust_pkg->change_custnum
545 && $cust_pkg->get('cancel')
547 popup => "misc/cancel_pkg.html?method=uncancel;$plink",
548 actionlabel => emt('Un-cancel'),
564 <% join('', map '</DIV>', @marker ) %>
572 my $bgcolor = $opt{'bgcolor'};
573 my $cust_pkg = $opt{'cust_pkg'};
574 my $part_pkg = $opt{'part_pkg'};
576 my $curuser = $FS::CurrentUser::CurrentUser;
578 my $countrydefault = $opt{'countrydefault'} || 'US';
579 my $statedefault = $opt{'statedefault'}
580 || ($countrydefault eq 'US' ? 'CA' : '');
582 # put a marker on the left edge of this column
583 # if this package is somehow special
584 my $supplemental = $opt{'supplemental'} || 0;
585 my $change_from = $opt{'change_from'} || 0;
587 if ( $supplemental ) {
588 push @marker, '<DIV CLASS="package-marker-supplemental">';
590 if ( $change_from ) {
591 push @marker, '<DIV CLASS="package-marker-change_from">';
594 $cust_pkg->pkgnum =~ /^(\d+)$/;
596 my @cust_pkg_usage = qsearch({
597 'select' => 'cust_pkg_usage.*',
598 'table' => 'cust_pkg_usage',
599 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
600 'extra_sql' => " WHERE pkgnum = $1",
601 'order_by' => ' ORDER BY priority ASC, description ASC',
606 #false laziness w/status.html
608 my($action, $label, $cust_pkg) = @_;
609 return '' unless $cust_pkg;
610 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
613 sub pkg_change_location_link {
614 my $cust_pkg = shift;
615 my $pkgpart = $cust_pkg->pkgpart;
616 include( '/elements/popup_link-cust_pkg.html',
617 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
618 "address1=;address2=;city=;county=;state=$statedefault;".
619 "zip=;country=$countrydefault",
620 'label' => emt('Change location'),
621 'actionlabel' => emt('Change'),
622 'cust_pkg' => $cust_pkg,
628 sub pkg_change_quantity_link {
629 my( $cust_pkg, $label ) = @_;
630 include( '/elements/popup_link-cust_pkg.html',
631 'action' => $p. 'edit/cust_pkg_quantity.html?',
632 'label' => emt($label),
633 'actionlabel' => emt('Change'),
634 'cust_pkg' => $cust_pkg,
640 sub pkg_change_salesnum_link {
641 my( $cust_pkg, $label ) = @_;
642 include( '/elements/popup_link-cust_pkg.html',
643 'action' => $p. 'edit/cust_pkg_salesnum.html?',
644 'label' => emt($label),
645 'actionlabel' => emt('Change'),
646 'cust_pkg' => $cust_pkg,
652 # figure out if this user will be able to edit either the setup or recurring
653 # discounts for this package
654 my $can_discount_pkg = 0;
656 if ( $part_pkg->can_discount ) {
657 #looking these up individually uses the ACL cache and is a big win for lots
659 my $discount = $curuser->access_right('Discount customer package');
660 my $waive = $curuser->access_right('Waive setup fee');
663 ( ($discount || $waive)
664 && $cust_pkg->base_setup > 0
668 && $cust_pkg->base_recur > 0
669 && $cust_pkg->freq ne '0'