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')
226 <& /elements/dropdown-menu.html,
227 id => 'cust_pkg'. $cust_pkg->pkgnum. '_menu',
228 bgcolor => $opt{row} % 2 ? '#ffffff' : '#eeeeee',
232 #TODO: order/group these better
234 { label => 'Package actions',
235 content => '<FONT STYLE="text-decoration:underline"><B>Package actions</B></FONT> <IMG SRC="'.$p. 'images/arrow.down.black.png">',
238 { label => 'Modify one-time charge',
239 acl => 'Modify one-time charge',
240 condition => sub { $part_pkg->freq eq '0' },
241 url => "edit/quick-charge.html?change_$plink",
244 { label => 'Change package',
245 acl => 'Change customer package',
246 condition => $reg_recur_cond,
247 popup => "misc/change_pkg.cgi?$plink".
248 ';locationnum='. $cust_pkg->locationnum.
249 actionlabel => emt('Change package'),
255 { label => 'Discount package',
256 condition => sub { $part_pkg->freq ne '0'
259 && ! $cust_pkg->get('cancel')
262 popup => "edit/cust_pkg_discount.html?$plink".
263 actionlabel => emt('Discount package'),
267 { label => 'Customize package',
268 acl => 'Customize customer package',
269 condition => $reg_recur_cond,
270 url => "edit/part_pkg.cgi?$plink".
271 ';clone='. $part_pkg->pkgpart,
274 { label => 'View package events',
275 acl => [ 'Billing event reports',
276 'View customer billing events', ],
277 condition => sub { $cust_pkg->exists_cust_event },
278 url => "search/cust_event.html?$plink",
281 { label => 'Change quantity',
282 acl => 'Change customer package',
283 condition => sub { $part_pkg->freq ne '0'
286 && ! $cust_pkg->get('cancel')
287 && $opt{'invoice-unitprice'}
289 popup => "edit/cust_pkg_quantity.html?$plink",
291 actionlabel => emt('Change quantity'),
296 { label => 'Change sales person',
297 acl => 'Change customer package',
298 condition => sub { ! $change_from
300 && ! $cust_pkg->get('cancel')
302 popup => "edit/cust_pkg_salesnum.html?$plink",
303 actionlabel => emt('Change sales persion'),
308 { label => (@invoice_detail ? 'Edit' : 'Add').
310 acl => 'Edit customer package invoice details',
311 condition => sub { ! $cust_pkg->get('cancel') },
312 popup => "edit/cust_pkg_detail.html?$plink".
314 actionlabel => emt( (@invoice_detail ? 'Edit' : 'Add').
320 { label => (@comments ? 'Edit' : 'Add'). ' comments',
321 acl => 'Edit customer package comments',
322 popup => "edit/cust_pkg_detail.html?$plink".
324 actionlabel => emt( (@comments ? 'Edit' : 'Add').
345 <% join('', map '</DIV>', @marker ) %>
353 my $bgcolor = $opt{'bgcolor'};
354 my $cust_pkg = $opt{'cust_pkg'};
355 my $part_pkg = $opt{'part_pkg'};
357 my $curuser = $FS::CurrentUser::CurrentUser;
359 my $countrydefault = $opt{'countrydefault'} || 'US';
360 my $statedefault = $opt{'statedefault'}
361 || ($countrydefault eq 'US' ? 'CA' : '');
363 # put a marker on the left edge of this column
364 # if this package is somehow special
365 my $supplemental = $opt{'supplemental'} || 0;
366 my $change_from = $opt{'change_from'} || 0;
368 if ( $supplemental ) {
369 push @marker, '<DIV CLASS="package-marker-supplemental">';
371 if ( $change_from ) {
372 push @marker, '<DIV CLASS="package-marker-change_from">';
375 $cust_pkg->pkgnum =~ /^(\d+)$/;
377 my @cust_pkg_usage = qsearch({
378 'select' => 'cust_pkg_usage.*',
379 'table' => 'cust_pkg_usage',
380 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
381 'extra_sql' => " WHERE pkgnum = $1",
382 'order_by' => ' ORDER BY priority ASC, description ASC',
387 #false laziness w/status.html
389 my($action, $label, $cust_pkg) = @_;
390 return '' unless $cust_pkg;
391 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
394 sub pkg_change_location_link {
395 my $cust_pkg = shift;
396 my $pkgpart = $cust_pkg->pkgpart;
397 include( '/elements/popup_link-cust_pkg.html',
398 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
399 "address1=;address2=;city=;county=;state=$statedefault;".
400 "zip=;country=$countrydefault",
401 'label' => emt('Change location'),
402 'actionlabel' => emt('Change'),
403 'cust_pkg' => $cust_pkg,
409 sub pkg_change_quantity_link {
410 my( $cust_pkg, $label ) = @_;
411 include( '/elements/popup_link-cust_pkg.html',
412 'action' => $p. 'edit/cust_pkg_quantity.html?',
413 'label' => emt($label),
414 'actionlabel' => emt('Change'),
415 'cust_pkg' => $cust_pkg,
421 sub pkg_change_salesnum_link {
422 my( $cust_pkg, $label ) = @_;
423 include( '/elements/popup_link-cust_pkg.html',
424 'action' => $p. 'edit/cust_pkg_salesnum.html?',
425 'label' => emt($label),
426 'actionlabel' => emt('Change'),
427 'cust_pkg' => $cust_pkg,
433 # figure out if this user will be able to edit either the setup or recurring
434 # discounts for this package
435 my $can_discount_pkg = 0;
437 if ( $part_pkg->can_discount ) {
438 #looking these up individually uses the ACL cache and is a big win for lots
440 my $discount = $curuser->access_right('Discount customer package');
441 my $waive = $curuser->access_right('Waive setup fee');
444 ( ($discount || $waive)
445 && $cust_pkg->base_setup > 0
449 && $cust_pkg->base_recur > 0
450 && $cust_pkg->freq ne '0'