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 % if ( $part_pkg->freq eq '0' and !$opt{no_links} ) {
25 % # One-time charge. Nothing you can do with this, unless:
26 % if ( $curuser->access_right('Modify one-time charge') ) {
27 ( <%onetime_change_link($cust_pkg)%> )
31 % } elsif ( !$cust_pkg->get('cancel') and !$opt{no_links} ) {
33 % if ( $change_from ) {
34 % # This is the target package for a future change.
35 % # Nothing you can do with it besides modify/cancel the
36 % # future change, and that's on the current package.
37 % } elsif ( $supplemental ) {
38 % # Supplemental packages can't be changed independently.
39 % # Show only "Add comments" and "Add invoice details".
41 % # the usual case: links to change package definition,
42 % # discount, and customization
44 % if ( $curuser->access_right('Change customer package') ) {
46 ( <%pkg_change_link($cust_pkg)%> )
49 % if ( $curuser->access_right('Discount customer package')
50 % && $part_pkg->can_discount
51 % && ! scalar($cust_pkg->cust_pkg_discount_active)
52 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
56 ( <%pkg_discount_link($cust_pkg)%> )
59 % if ( $curuser->access_right('Customize customer package') ) {
61 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
64 <% $br ? '<BR>' : '' %>
67 % if ( $cust_pkg->num_cust_event
68 % && ( $curuser->access_right('Billing event reports')
69 % || $curuser->access_right('View customer billing events')
72 ( <%pkg_event_link($cust_pkg)%> )
84 % my $change_quan_label = 'Change quantity';
85 % if ( $cust_pkg->quantity > 1 ) {
86 % $change_quan_label = 'change';
87 <% mt('Quantity:') |h %>
88 <B><% $cust_pkg->quantity %></B>
91 % if ( $curuser->access_right('Change customer package')
92 % && ! $cust_pkg->get('cancel')
94 % && $part_pkg->freq ne '0'
96 % && $opt{'invoice-unitprice'}
100 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
111 % my $change_sales_label = 'Change sales person';
112 % if ( $cust_pkg->salesnum ) {
113 % $change_sales_label = 'change';
114 <% mt('Sales Person:') |h %>
115 <B><% $cust_pkg->salesperson |h %></B>
118 % if ( $curuser->access_right('Change customer package')
119 % && ! $cust_pkg->get('cancel')
121 % #&& $part_pkg->freq ne '0'
122 % && ! $opt{no_links}
126 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
134 % my $editi = $curuser->access_right('Edit customer package invoice details');
135 % my $editc = $curuser->access_right('Edit customer package comments');
136 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
137 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
138 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
140 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
142 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
147 % if ( @invoice_detail ) {
149 <& /elements/table-grid.html &>
151 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
153 <% mt('Invoice details') |h %>
154 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
155 (<& /elements/popup_link.html, {
156 'action' => $editlink. 'I',
157 'label' => emt('edit'),
158 'actionlabel' => emt('Edit invoice details'),
159 'color' => '#333399',
167 % foreach my $cust_pkg_detail ( @invoice_detail ) {
169 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
176 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
178 ( <% include('/elements/popup_link.html', {
179 'action' => $editlink. 'I',
180 'label' => emt('Add invoice details'),
181 'actionlabel' => emt('Add invoice details'),
182 'color' => '#333399',
193 <& /elements/table-grid.html &>
195 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
197 <% mt('Comments') |h %>
198 % if ( $editc && ! $opt{no_links} ) {
199 (<& /elements/popup_link.html, {
200 'action' => $editlink. 'C',
201 'label' => emt('edit'),
202 'actionlabel' => emt('Edit comments'),
203 'color' => '#333399',
211 % foreach my $cust_pkg_detail ( @comments ) {
213 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
220 % if ( $editc && ! $opt{no_links} ) {
222 ( <& /elements/popup_link.html, {
223 'action' => $editlink. 'C',
224 'label' => emt('Add comments'),
225 'actionlabel' => emt('Add comments'),
226 'color' => '#333399',
241 % if ( @cust_pkg_usage ) {
242 <TABLE CLASS="usage inv">
243 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
244 % foreach my $usage (@cust_pkg_usage) {
245 % my $part = $usage->part_pkg_usage;
246 % my $ratio = 255 * ($usage->minutes / $part->minutes);
247 % $ratio = 255 if $ratio > 255; # because rollover
248 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
250 % $trstyle = ' CLASS="shared"' if $part->shared;
252 <TD ALIGN="right"><% $part->description %>: </TD>
253 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
254 <TD <%$color%>> / </TD>
255 <TD <%$color%>><% $part->minutes %></TD>
256 % if ( $part->shared ) {
257 <TD><I>(shared)</I></TD>
270 my $bgcolor = $opt{'bgcolor'};
271 my $cust_pkg = $opt{'cust_pkg'};
272 my $part_pkg = $opt{'part_pkg'};
274 my $curuser = $FS::CurrentUser::CurrentUser;
276 my $countrydefault = $opt{'countrydefault'} || 'US';
277 my $statedefault = $opt{'statedefault'}
278 || ($countrydefault eq 'US' ? 'CA' : '');
280 # put a marker on the left edge of this column
281 # if this package is somehow special
282 my $supplemental = $opt{'supplemental'} || 0;
283 my $change_from = $opt{'change_from'} || 0;
285 if ( $supplemental or $change_from ) {
286 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
288 if ( $supplemental ) {
290 } elsif ( $change_from ) {
293 $style = qq!STYLE="$style"!;
296 $cust_pkg->pkgnum =~ /^(\d+)$/;
298 my @cust_pkg_usage = qsearch({
299 'select' => 'cust_pkg_usage.*',
300 'table' => 'cust_pkg_usage',
301 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
302 'extra_sql' => " WHERE pkgnum = $1",
303 'order_by' => ' ORDER BY priority ASC, description ASC',
308 #false laziness w/status.html
310 my($action, $label, $cust_pkg) = @_;
311 return '' unless $cust_pkg;
312 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
315 sub pkg_change_link {
316 my $cust_pkg = shift;
317 my $locationnum = $cust_pkg->locationnum;
318 include( '/elements/popup_link-cust_pkg.html',
319 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
320 'label' => emt('Change package'),
321 'actionlabel' => emt('Change'),
322 'cust_pkg' => $cust_pkg,
328 sub onetime_change_link {
329 my $cust_pkg = shift;
330 my $pkgnum = $cust_pkg->pkgnum;
331 include( '/elements/popup_link-cust_pkg.html',
332 'action' => $p. "edit/quick-charge.html?change_pkgnum=$pkgnum",
333 'label' => emt('Modify one-time charge'),
334 'actionlabel' => emt('Modify'),
335 'cust_pkg' => $cust_pkg,
341 sub pkg_change_location_link {
342 my $cust_pkg = shift;
343 my $pkgpart = $cust_pkg->pkgpart;
344 include( '/elements/popup_link-cust_pkg.html',
345 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
346 "address1=;address2=;city=;county=;state=$statedefault;".
347 "zip=;country=$countrydefault",
348 'label' => emt('Change location'),
349 'actionlabel' => emt('Change'),
350 'cust_pkg' => $cust_pkg,
356 sub pkg_change_quantity_link {
357 my( $cust_pkg, $label ) = @_;
358 include( '/elements/popup_link-cust_pkg.html',
359 'action' => $p. 'edit/cust_pkg_quantity.html?',
360 'label' => emt($label),
361 'actionlabel' => emt('Change'),
362 'cust_pkg' => $cust_pkg,
368 sub pkg_change_salesnum_link {
369 my( $cust_pkg, $label ) = @_;
370 include( '/elements/popup_link-cust_pkg.html',
371 'action' => $p. 'edit/cust_pkg_salesnum.html?',
372 'label' => emt($label),
373 'actionlabel' => emt('Change'),
374 'cust_pkg' => $cust_pkg,
380 sub pkg_discount_link {
381 my $cust_pkg = shift or return '';
382 include( '/elements/popup_link-cust_pkg.html',
383 'action' => $p.'edit/cust_pkg_discount.html',
384 'label' => emt('Discount'),
385 'actionlabel' => emt('Discount'),
386 'cust_pkg' => $cust_pkg,
391 sub pkg_customize_link {
392 my $cust_pkg = shift or return '';
393 my $part_pkg = shift;
394 my $custnum = $cust_pkg->custnum;
395 qq!<A HREF="${p}edit/part_pkg.cgi?!.
396 "clone=". $part_pkg->pkgpart. ';'.
397 "pkgnum=". $cust_pkg->pkgnum.
398 qq!">!.emt('Customize').'</A>';
403 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
404 emt('View package events').