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 ><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
14 % my $custom_comment = $part_pkg->custom_comment();
15 <% $custom_comment ? ' - ' : '' %>
16 <% $custom_comment |h %>
25 % if ( $part_pkg->freq eq '0' and !$opt{no_links} ) {
26 % # One-time charge. Nothing you can do with this, unless:
27 % if ( $curuser->access_right('Modify one-time charge') ) {
28 ( <%onetime_change_link($cust_pkg)%> )
32 % } elsif ( !$cust_pkg->get('cancel') and !$opt{no_links} ) {
34 % if ( $change_from ) {
35 % # This is the target package for a future change.
36 % # Nothing you can do with it besides modify/cancel the
37 % # future change, and that's on the current package.
38 % } elsif ( $supplemental ) {
39 % # Supplemental packages can't be changed independently.
40 % # Show only "Add comments" and "Add invoice details".
42 % # the usual case: links to change package definition,
43 % # discount, and customization
45 % if ( $curuser->access_right('Change customer package') ) {
47 ( <%pkg_change_link($cust_pkg)%> )
50 % if ( $curuser->access_right('Discount customer package')
51 % && $part_pkg->can_discount
52 % && ! scalar($cust_pkg->cust_pkg_discount_active)
53 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
57 ( <%pkg_discount_link($cust_pkg)%> )
60 % if ( $curuser->access_right('Customize customer package') ) {
62 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
65 <% $br ? '<BR>' : '' %>
68 % if ( $cust_pkg->num_cust_event
69 % && ( $curuser->access_right('Billing event reports')
70 % || $curuser->access_right('View customer billing events')
73 ( <%pkg_event_link($cust_pkg)%> )
85 % my $change_quan_label = 'Change quantity';
86 % if ( $cust_pkg->quantity > 1 ) {
87 % $change_quan_label = 'change';
88 <% mt('Quantity:') |h %>
89 <B><% $cust_pkg->quantity %></B>
92 % if ( $curuser->access_right('Change customer package')
93 % && ! $cust_pkg->get('cancel')
95 % && $part_pkg->freq ne '0'
97 % && $opt{'invoice-unitprice'}
101 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
112 % my $change_sales_label = 'Change sales person';
113 % if ( $cust_pkg->salesnum ) {
114 % $change_sales_label = 'change';
115 <% mt('Sales Person:') |h %>
116 <B><% $cust_pkg->salesperson |h %></B>
119 % if ( $curuser->access_right('Change customer package')
120 % && ! $cust_pkg->get('cancel')
122 % #&& $part_pkg->freq ne '0'
123 % && ! $opt{no_links}
127 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
135 % my $editi = $curuser->access_right('Edit customer package invoice details');
136 % my $editc = $curuser->access_right('Edit customer package comments');
137 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
138 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
139 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
141 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
143 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
148 % if ( @invoice_detail ) {
150 <& /elements/table-grid.html &>
152 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
154 <% mt('Invoice details') |h %>
155 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
156 (<& /elements/popup_link.html, {
157 'action' => $editlink. 'I',
158 'label' => emt('edit'),
159 'actionlabel' => emt('Edit invoice details'),
160 'color' => '#333399',
168 % foreach my $cust_pkg_detail ( @invoice_detail ) {
170 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
177 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
179 ( <% include('/elements/popup_link.html', {
180 'action' => $editlink. 'I',
181 'label' => emt('Add invoice details'),
182 'actionlabel' => emt('Add invoice details'),
183 'color' => '#333399',
194 <& /elements/table-grid.html &>
196 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
198 <% mt('Comments') |h %>
199 % if ( $editc && ! $opt{no_links} ) {
200 (<& /elements/popup_link.html, {
201 'action' => $editlink. 'C',
202 'label' => emt('edit'),
203 'actionlabel' => emt('Edit comments'),
204 'color' => '#333399',
212 % foreach my $cust_pkg_detail ( @comments ) {
214 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
221 % if ( $editc && ! $opt{no_links} ) {
223 ( <& /elements/popup_link.html, {
224 'action' => $editlink. 'C',
225 'label' => emt('Add comments'),
226 'actionlabel' => emt('Add comments'),
227 'color' => '#333399',
242 % if ( @cust_pkg_usage ) {
243 <TABLE CLASS="usage inv">
244 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
245 % foreach my $usage (@cust_pkg_usage) {
246 % my $part = $usage->part_pkg_usage;
247 % my $ratio = 255 * ($usage->minutes / $part->minutes);
248 % $ratio = 255 if $ratio > 255; # because rollover
249 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
251 % $trstyle = ' CLASS="shared"' if $part->shared;
253 <TD ALIGN="right"><% $part->description %>: </TD>
254 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
255 <TD <%$color%>> / </TD>
256 <TD <%$color%>><% $part->minutes %></TD>
257 % if ( $part->shared ) {
258 <TD><I>(shared)</I></TD>
271 my $bgcolor = $opt{'bgcolor'};
272 my $cust_pkg = $opt{'cust_pkg'};
273 my $part_pkg = $opt{'part_pkg'};
275 my $curuser = $FS::CurrentUser::CurrentUser;
277 my $countrydefault = $opt{'countrydefault'} || 'US';
278 my $statedefault = $opt{'statedefault'}
279 || ($countrydefault eq 'US' ? 'CA' : '');
281 # put a marker on the left edge of this column
282 # if this package is somehow special
283 my $supplemental = $opt{'supplemental'} || 0;
284 my $change_from = $opt{'change_from'} || 0;
286 if ( $supplemental or $change_from ) {
287 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
289 if ( $supplemental ) {
291 } elsif ( $change_from ) {
294 $style = qq!STYLE="$style"!;
297 $cust_pkg->pkgnum =~ /^(\d+)$/;
299 my @cust_pkg_usage = qsearch({
300 'select' => 'cust_pkg_usage.*',
301 'table' => 'cust_pkg_usage',
302 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
303 'extra_sql' => " WHERE pkgnum = $1",
304 'order_by' => ' ORDER BY priority ASC, description ASC',
309 #false laziness w/status.html
311 my($action, $label, $cust_pkg) = @_;
312 return '' unless $cust_pkg;
313 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
316 sub pkg_change_link {
317 my $cust_pkg = shift;
318 my $locationnum = $cust_pkg->locationnum;
319 include( '/elements/popup_link-cust_pkg.html',
320 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
321 'label' => emt('Change package'),
322 'actionlabel' => emt('Change'),
323 'cust_pkg' => $cust_pkg,
329 sub onetime_change_link {
330 my $cust_pkg = shift;
331 my $pkgnum = $cust_pkg->pkgnum;
332 include( '/elements/popup_link-cust_pkg.html',
333 'action' => $p. "edit/quick-charge.html?change_pkgnum=$pkgnum",
334 'label' => emt('Modify one-time charge'),
335 'actionlabel' => emt('Modify'),
336 'cust_pkg' => $cust_pkg,
342 sub pkg_change_location_link {
343 my $cust_pkg = shift;
344 my $pkgpart = $cust_pkg->pkgpart;
345 include( '/elements/popup_link-cust_pkg.html',
346 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
347 "address1=;address2=;city=;county=;state=$statedefault;".
348 "zip=;country=$countrydefault",
349 'label' => emt('Change location'),
350 'actionlabel' => emt('Change'),
351 'cust_pkg' => $cust_pkg,
357 sub pkg_change_quantity_link {
358 my( $cust_pkg, $label ) = @_;
359 include( '/elements/popup_link-cust_pkg.html',
360 'action' => $p. 'edit/cust_pkg_quantity.html?',
361 'label' => emt($label),
362 'actionlabel' => emt('Change'),
363 'cust_pkg' => $cust_pkg,
369 sub pkg_change_salesnum_link {
370 my( $cust_pkg, $label ) = @_;
371 include( '/elements/popup_link-cust_pkg.html',
372 'action' => $p. 'edit/cust_pkg_salesnum.html?',
373 'label' => emt($label),
374 'actionlabel' => emt('Change'),
375 'cust_pkg' => $cust_pkg,
381 sub pkg_discount_link {
382 my $cust_pkg = shift or return '';
383 include( '/elements/popup_link-cust_pkg.html',
384 'action' => $p.'edit/cust_pkg_discount.html',
385 'label' => emt('Discount'),
386 'actionlabel' => emt('Discount'),
387 'cust_pkg' => $cust_pkg,
392 sub pkg_customize_link {
393 my $cust_pkg = shift or return '';
394 my $part_pkg = shift;
395 my $custnum = $cust_pkg->custnum;
396 qq!<A HREF="${p}edit/part_pkg.cgi?!.
397 "clone=". $part_pkg->pkgpart. ';'.
398 "pkgnum=". $cust_pkg->pkgnum.
399 qq!">!.emt('Customize').'</A>';
404 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
405 emt('View package events').