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>
15 <% $part_pkg->custom_comment |h %>
24 % unless ( $cust_pkg->get('cancel') || $opt{no_links} ) {
26 % if ( $change_from ) {
27 % # This is the target package for a future change.
28 % # Nothing you can do with it besides modify/cancel the
29 % # future change, and that's on the current package.
30 % } elsif ( $supplemental or $part_pkg->freq eq '0' ) {
31 % # Supplemental packages can't be changed independently.
32 % # One-time charges don't need to be changed.
33 % # For both of those, we only show "Add comments",
34 % # and "Add invoice details".
36 % # the usual case: links to change package definition,
37 % # discount, and customization
39 % if ( $curuser->access_right('Change customer package') ) {
41 ( <%pkg_change_link($cust_pkg)%> )
44 % if ( $curuser->access_right('Discount customer package')
45 % && $part_pkg->can_discount
46 % && ! scalar($cust_pkg->cust_pkg_discount_active)
47 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
51 ( <%pkg_discount_link($cust_pkg)%> )
54 % if ( $curuser->access_right('Customize customer package') ) {
56 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
59 <% $br ? '<BR>' : '' %>
62 % if ( $cust_pkg->num_cust_event
63 % && ( $curuser->access_right('Billing event reports')
64 % || $curuser->access_right('View customer billing events')
67 ( <%pkg_event_link($cust_pkg)%> )
79 % my $change_quan_label = 'Change quantity';
80 % if ( $cust_pkg->quantity > 1 ) {
81 % $change_quan_label = 'change';
82 <% mt('Quantity:') |h %>
83 <B><% $cust_pkg->quantity %></B>
86 % if ( $curuser->access_right('Change customer package')
87 % && ! $cust_pkg->get('cancel')
89 % && $part_pkg->freq ne '0'
91 % && $opt{'invoice-unitprice'}
95 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
106 % my $change_sales_label = 'Change sales person';
107 % if ( $cust_pkg->salesnum ) {
108 % $change_sales_label = 'change';
109 <% mt('Sales Person:') |h %>
110 <B><% $cust_pkg->salesperson %></B>
113 % if ( $curuser->access_right('Change customer package')
114 % && ! $cust_pkg->get('cancel')
116 % #&& $part_pkg->freq ne '0'
117 % && ! $opt{no_links}
121 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
129 % my $editi = $curuser->access_right('Edit customer package invoice details');
130 % my $editc = $curuser->access_right('Edit customer package comments');
131 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
132 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
133 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
135 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
137 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
142 % if ( @invoice_detail ) {
144 <& /elements/table-grid.html &>
146 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
148 <% mt('Invoice details') |h %>
149 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
150 (<& /elements/popup_link.html, {
151 'action' => $editlink. 'I',
152 'label' => emt('edit'),
153 'actionlabel' => emt('Edit invoice details'),
154 'color' => '#333399',
162 % foreach my $cust_pkg_detail ( @invoice_detail ) {
164 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
171 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
173 ( <% include('/elements/popup_link.html', {
174 'action' => $editlink. 'I',
175 'label' => emt('Add invoice details'),
176 'actionlabel' => emt('Add invoice details'),
177 'color' => '#333399',
188 <& /elements/table-grid.html &>
190 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
192 <% mt('Comments') |h %>
193 % if ( $editc && ! $opt{no_links} ) {
194 (<& /elements/popup_link.html, {
195 'action' => $editlink. 'C',
196 'label' => emt('edit'),
197 'actionlabel' => emt('Edit comments'),
198 'color' => '#333399',
206 % foreach my $cust_pkg_detail ( @comments ) {
208 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
215 % if ( $editc && ! $opt{no_links} ) {
217 ( <& /elements/popup_link.html, {
218 'action' => $editlink. 'C',
219 'label' => emt('Add comments'),
220 'actionlabel' => emt('Add comments'),
221 'color' => '#333399',
236 % if ( @cust_pkg_usage ) {
237 <TABLE CLASS="usage inv">
238 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
239 % foreach my $usage (@cust_pkg_usage) {
240 % my $part = $usage->part_pkg_usage;
241 % my $ratio = 255 * ($usage->minutes / $part->minutes);
242 % $ratio = 255 if $ratio > 255; # because rollover
243 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
245 % $trstyle = ' CLASS="shared"' if $part->shared;
247 <TD ALIGN="right"><% $part->description %>: </TD>
248 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
249 <TD <%$color%>> / </TD>
250 <TD <%$color%>><% $part->minutes %></TD>
251 % if ( $part->shared ) {
252 <TD><I>(shared)</I></TD>
265 my $bgcolor = $opt{'bgcolor'};
266 my $cust_pkg = $opt{'cust_pkg'};
267 my $part_pkg = $opt{'part_pkg'};
269 my $curuser = $FS::CurrentUser::CurrentUser;
271 my $countrydefault = $opt{'countrydefault'} || 'US';
272 my $statedefault = $opt{'statedefault'}
273 || ($countrydefault eq 'US' ? 'CA' : '');
275 # put a marker on the left edge of this column
276 # if this package is somehow special
277 my $supplemental = $opt{'supplemental'} || 0;
278 my $change_from = $opt{'change_from'} || 0;
280 if ( $supplemental or $change_from ) {
281 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
283 if ( $supplemental ) {
285 } elsif ( $change_from ) {
288 $style = qq!STYLE="$style"!;
291 $cust_pkg->pkgnum =~ /^(\d+)$/;
293 my @cust_pkg_usage = qsearch({
294 'select' => 'cust_pkg_usage.*',
295 'table' => 'cust_pkg_usage',
296 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
297 'extra_sql' => " WHERE pkgnum = $1",
298 'order_by' => ' ORDER BY priority ASC, description ASC',
303 #false laziness w/status.html
305 my($action, $label, $cust_pkg) = @_;
306 return '' unless $cust_pkg;
307 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
310 sub pkg_change_link {
311 my $cust_pkg = shift;
312 my $locationnum = $cust_pkg->locationnum;
313 include( '/elements/popup_link-cust_pkg.html',
314 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
315 'label' => emt('Change package'),
316 'actionlabel' => emt('Change'),
317 'cust_pkg' => $cust_pkg,
323 sub pkg_change_location_link {
324 my $cust_pkg = shift;
325 my $pkgpart = $cust_pkg->pkgpart;
326 include( '/elements/popup_link-cust_pkg.html',
327 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
328 "address1=;address2=;city=;county=;state=$statedefault;".
329 "zip=;country=$countrydefault",
330 'label' => emt('Change location'),
331 'actionlabel' => emt('Change'),
332 'cust_pkg' => $cust_pkg,
338 sub pkg_change_quantity_link {
339 my( $cust_pkg, $label ) = @_;
340 include( '/elements/popup_link-cust_pkg.html',
341 'action' => $p. 'edit/cust_pkg_quantity.html?',
342 'label' => emt($label),
343 'actionlabel' => emt('Change'),
344 'cust_pkg' => $cust_pkg,
350 sub pkg_change_salesnum_link {
351 my( $cust_pkg, $label ) = @_;
352 include( '/elements/popup_link-cust_pkg.html',
353 'action' => $p. 'edit/cust_pkg_salesnum.html?',
354 'label' => emt($label),
355 'actionlabel' => emt('Change'),
356 'cust_pkg' => $cust_pkg,
362 sub pkg_discount_link {
363 my $cust_pkg = shift or return '';
364 include( '/elements/popup_link-cust_pkg.html',
365 'action' => $p.'edit/cust_pkg_discount.html',
366 'label' => emt('Discount'),
367 'actionlabel' => emt('Discount'),
368 'cust_pkg' => $cust_pkg,
373 sub pkg_customize_link {
374 my $cust_pkg = shift or return '';
375 my $part_pkg = shift;
376 my $custnum = $cust_pkg->custnum;
377 qq!<A HREF="${p}edit/part_pkg.cgi?!.
378 "clone=". $part_pkg->pkgpart. ';'.
379 "pkgnum=". $cust_pkg->pkgnum.
380 qq!">!.emt('Customize').'</A>';
385 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
386 emt('View package events').