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 % # Show only "Add comments" and "Add invoice details".
40 % if ( $curuser->access_right('Edit customer package dates') ) {
41 ( <%pkg_dates_link($cust_pkg)%> )
44 % # the usual case: links to change package definition,
45 % # discount, and customization
47 % if ( $curuser->access_right('Change customer package') ) {
49 ( <%pkg_change_link($cust_pkg)%> )
52 % if ( $curuser->access_right('Edit customer package dates') ) {
54 ( <%pkg_dates_link($cust_pkg)%> )
57 % if ( $curuser->access_right('Discount customer package')
58 % && $part_pkg->can_discount
59 % && ! scalar($cust_pkg->cust_pkg_discount_active)
60 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
64 ( <%pkg_discount_link($cust_pkg)%> )
67 % if ( $curuser->access_right('Customize customer package') ) {
69 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
72 <% $br ? '<BR>' : '' %>
75 % if ( $cust_pkg->num_cust_event
76 % && ( $curuser->access_right('Billing event reports')
77 % || $curuser->access_right('View customer billing events')
80 ( <%pkg_event_link($cust_pkg)%> )
92 % my $change_quan_label = 'Change quantity';
93 % if ( $cust_pkg->quantity > 1 ) {
94 % $change_quan_label = 'change';
95 <% mt('Quantity:') |h %>
96 <B><% $cust_pkg->quantity %></B>
99 % if ( $curuser->access_right('Change customer package')
100 % && ! $cust_pkg->get('cancel')
102 % && $part_pkg->freq ne '0'
103 % && ! $opt{no_links}
104 % && $opt{'invoice-unitprice'}
108 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
119 % my $change_sales_label = 'Change sales person';
120 % if ( $cust_pkg->salesnum ) {
121 % $change_sales_label = 'change';
122 <% mt('Sales Person:') |h %>
123 <B><% $cust_pkg->salesperson |h %></B>
126 % if ( $curuser->access_right('Change customer package')
127 % && ! $cust_pkg->get('cancel')
129 % #&& $part_pkg->freq ne '0'
130 % && ! $opt{no_links}
134 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
142 % my $editi = $curuser->access_right('Edit customer package invoice details');
143 % my $editc = $curuser->access_right('Edit customer package comments');
144 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
145 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
146 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
148 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
150 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
155 % if ( @invoice_detail ) {
157 <& /elements/table-grid.html &>
159 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
161 <% mt('Invoice details') |h %>
162 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
163 (<& /elements/popup_link.html, {
164 'action' => $editlink. 'I',
165 'label' => emt('edit'),
166 'actionlabel' => emt('Edit invoice details'),
167 'color' => '#333399',
175 % foreach my $cust_pkg_detail ( @invoice_detail ) {
177 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
184 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
186 ( <% include('/elements/popup_link.html', {
187 'action' => $editlink. 'I',
188 'label' => emt('Add invoice details'),
189 'actionlabel' => emt('Add invoice details'),
190 'color' => '#333399',
201 <& /elements/table-grid.html &>
203 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
205 <% mt('Comments') |h %>
206 % if ( $editc && ! $opt{no_links} ) {
207 (<& /elements/popup_link.html, {
208 'action' => $editlink. 'C',
209 'label' => emt('edit'),
210 'actionlabel' => emt('Edit comments'),
211 'color' => '#333399',
219 % foreach my $cust_pkg_detail ( @comments ) {
221 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
228 % if ( $editc && ! $opt{no_links} ) {
230 ( <& /elements/popup_link.html, {
231 'action' => $editlink. 'C',
232 'label' => emt('Add comments'),
233 'actionlabel' => emt('Add comments'),
234 'color' => '#333399',
249 % if ( @cust_pkg_usage ) {
250 <TABLE CLASS="usage inv">
251 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
252 % foreach my $usage (@cust_pkg_usage) {
253 % my $part = $usage->part_pkg_usage;
254 % my $ratio = 255 * ($usage->minutes / $part->minutes);
255 % $ratio = 255 if $ratio > 255; # because rollover
256 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
258 % $trstyle = ' CLASS="shared"' if $part->shared;
260 <TD ALIGN="right"><% $part->description %>: </TD>
261 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
262 <TD <%$color%>> / </TD>
263 <TD <%$color%>><% $part->minutes %></TD>
264 % if ( $part->shared ) {
265 <TD><I>(shared)</I></TD>
278 my $bgcolor = $opt{'bgcolor'};
279 my $cust_pkg = $opt{'cust_pkg'};
280 my $part_pkg = $opt{'part_pkg'};
282 my $curuser = $FS::CurrentUser::CurrentUser;
284 my $countrydefault = $opt{'countrydefault'} || 'US';
285 my $statedefault = $opt{'statedefault'}
286 || ($countrydefault eq 'US' ? 'CA' : '');
288 # put a marker on the left edge of this column
289 # if this package is somehow special
290 my $supplemental = $opt{'supplemental'} || 0;
291 my $change_from = $opt{'change_from'} || 0;
293 if ( $supplemental or $change_from ) {
294 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
296 if ( $supplemental ) {
298 } elsif ( $change_from ) {
301 $style = qq!STYLE="$style"!;
304 $cust_pkg->pkgnum =~ /^(\d+)$/;
306 my @cust_pkg_usage = qsearch({
307 'select' => 'cust_pkg_usage.*',
308 'table' => 'cust_pkg_usage',
309 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
310 'extra_sql' => " WHERE pkgnum = $1",
311 'order_by' => ' ORDER BY priority ASC, description ASC',
316 #false laziness w/status.html
318 my($action, $label, $cust_pkg) = @_;
319 return '' unless $cust_pkg;
320 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
323 sub pkg_change_link {
324 my $cust_pkg = shift;
325 my $locationnum = $cust_pkg->locationnum;
326 include( '/elements/popup_link-cust_pkg.html',
327 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
328 'label' => emt('Change package'),
329 'actionlabel' => emt('Change'),
330 'cust_pkg' => $cust_pkg,
336 sub onetime_change_link {
337 my $cust_pkg = shift;
338 my $pkgnum = $cust_pkg->pkgnum;
339 include( '/elements/popup_link-cust_pkg.html',
340 'action' => $p. "edit/quick-charge.html?change_pkgnum=$pkgnum",
341 'label' => emt('Modify one-time charge'),
342 'actionlabel' => emt('Modify'),
343 'cust_pkg' => $cust_pkg,
349 sub pkg_change_location_link {
350 my $cust_pkg = shift;
351 my $pkgpart = $cust_pkg->pkgpart;
352 include( '/elements/popup_link-cust_pkg.html',
353 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
354 "address1=;address2=;city=;county=;state=$statedefault;".
355 "zip=;country=$countrydefault",
356 'label' => emt('Change location'),
357 'actionlabel' => emt('Change'),
358 'cust_pkg' => $cust_pkg,
364 sub pkg_change_quantity_link {
365 my( $cust_pkg, $label ) = @_;
366 include( '/elements/popup_link-cust_pkg.html',
367 'action' => $p. 'edit/cust_pkg_quantity.html?',
368 'label' => emt($label),
369 'actionlabel' => emt('Change'),
370 'cust_pkg' => $cust_pkg,
376 sub pkg_change_salesnum_link {
377 my( $cust_pkg, $label ) = @_;
378 include( '/elements/popup_link-cust_pkg.html',
379 'action' => $p. 'edit/cust_pkg_salesnum.html?',
380 'label' => emt($label),
381 'actionlabel' => emt('Change'),
382 'cust_pkg' => $cust_pkg,
388 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', emt('Edit dates'), @_ ); }
390 sub pkg_discount_link {
391 my $cust_pkg = shift or return '';
392 include( '/elements/popup_link-cust_pkg.html',
393 'action' => $p.'edit/cust_pkg_discount.html',
394 'label' => emt('Discount'),
395 'actionlabel' => emt('Discount'),
396 'cust_pkg' => $cust_pkg,
401 sub pkg_customize_link {
402 my $cust_pkg = shift or return '';
403 my $part_pkg = shift;
404 my $custnum = $cust_pkg->custnum;
405 qq!<A HREF="${p}edit/part_pkg.cgi?!.
406 "clone=". $part_pkg->pkgpart. ';'.
407 "pkgnum=". $cust_pkg->pkgnum.
408 qq!">!.emt('Customize').'</A>';
413 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
414 emt('View package events').