1 <TD CLASS="inv package" BGCOLOR="<% $bgcolor %>" VALIGN="top" <%$style%>>
2 <TABLE CLASS="inv package">
5 <% $opt{before_pkg_callback}
6 ? &{ $opt{before_pkg_callback} }( $cust_pkg )
9 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
10 ID ="cust_pkg<% $cust_pkg->pkgnum %>"
11 ><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
13 <% $part_pkg->custom_comment |h %>
17 % if ( $cust_pkg->quantity > 1 ) {
20 <% mt('Quantity:') |h %>
21 <B><% $cust_pkg->quantity %></B>
30 % unless ( $cust_pkg->get('cancel') || $opt{no_links} ) {
32 % if ( $change_from ) {
33 % # This is the target package for a future change.
34 % # Nothing you can do with it besides modify/cancel the
35 % # future change, and that's on the current package.
36 % } elsif ( $supplemental or $part_pkg->freq eq '0' ) {
37 % # Supplemental packages can't be changed independently.
38 % # One-time charges don't need to be changed.
39 % # For both of those, we only show "Edit dates", "Add comments",
40 % # and "Add invoice details".
41 % if ( $curuser->access_right('Edit customer package dates') ) {
42 ( <%pkg_dates_link($cust_pkg)%> )
45 % # the usual case: links to change package definition,
46 % # discount, and customization
48 % if ( $curuser->access_right('Change customer package') ) {
50 ( <%pkg_change_link($cust_pkg)%> )
53 % if ( $curuser->access_right('Edit customer package dates') ) {
55 ( <%pkg_dates_link($cust_pkg)%> )
58 % if ( $curuser->access_right('Discount customer package')
59 % && $part_pkg->can_discount
60 % && ! scalar($cust_pkg->cust_pkg_discount_active)
61 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
65 ( <%pkg_discount_link($cust_pkg)%> )
68 % if ( $curuser->access_right('Customize customer package') ) {
70 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
73 <% $br ? '<BR>' : '' %>
76 % if ( $cust_pkg->num_cust_event
77 % && ( $curuser->access_right('Billing event reports')
78 % || $curuser->access_right('View customer billing events')
81 ( <%pkg_event_link($cust_pkg)%> )
89 % my $editi = $curuser->access_right('Edit customer package invoice details');
90 % my $editc = $curuser->access_right('Edit customer package comments');
91 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
92 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
93 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
95 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
97 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
102 % if ( @invoice_detail ) {
104 <& /elements/table-grid.html &>
106 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
108 <% mt('Invoice details') |h %>
109 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
110 (<& /elements/popup_link.html, {
111 'action' => $editlink. 'I',
112 'label' => emt('edit'),
113 'actionlabel' => emt('Edit invoice details'),
114 'color' => '#333399',
122 % foreach my $cust_pkg_detail ( @invoice_detail ) {
124 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
131 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
133 ( <% include('/elements/popup_link.html', {
134 'action' => $editlink. 'I',
135 'label' => emt('Add invoice details'),
136 'actionlabel' => emt('Add invoice details'),
137 'color' => '#333399',
148 <& /elements/table-grid.html &>
150 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
152 <% mt('Comments') |h %>
153 % if ( $editc && ! $opt{no_links} ) {
154 (<& /elements/popup_link.html, {
155 'action' => $editlink. 'C',
156 'label' => emt('edit'),
157 'actionlabel' => emt('Edit comments'),
158 'color' => '#333399',
166 % foreach my $cust_pkg_detail ( @comments ) {
168 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
175 % if ( $editc && ! $opt{no_links} ) {
177 ( <& /elements/popup_link.html, {
178 'action' => $editlink. 'C',
179 'label' => emt('Add comments'),
180 'actionlabel' => emt('Add comments'),
181 'color' => '#333399',
191 % if ( $curuser->access_right('Change customer package')
192 % && ! $cust_pkg->get('cancel')
194 % && $part_pkg->freq ne '0'
195 % && ! $opt{no_links}
199 % # yeah, I guess we'll let you do this on a future change package
200 % if ( FS::Conf->new->exists('invoice-unitprice') ) {
202 ( <% pkg_change_quantity_link($cust_pkg) %> )
209 % if ( @cust_pkg_usage ) {
210 <TABLE CLASS="usage inv">
211 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
212 % foreach my $usage (@cust_pkg_usage) {
213 % my $part = $usage->part_pkg_usage;
214 % my $ratio = 255 * ($usage->minutes / $part->minutes);
215 % $ratio = 255 if $ratio > 255; # because rollover
216 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
218 % $trstyle = ' CLASS="shared"' if $part->shared;
220 <TD ALIGN="right"><% $part->description %>: </TD>
221 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
222 <TD <%$color%>> / </TD>
223 <TD <%$color%>><% $part->minutes %></TD>
224 % if ( $part->shared ) {
225 <TD><I>(shared)</I></TD>
238 my $bgcolor = $opt{'bgcolor'};
239 my $cust_pkg = $opt{'cust_pkg'};
240 my $part_pkg = $opt{'part_pkg'};
242 my $curuser = $FS::CurrentUser::CurrentUser;
244 my $countrydefault = $opt{'countrydefault'} || 'US';
245 my $statedefault = $opt{'statedefault'}
246 || ($countrydefault eq 'US' ? 'CA' : '');
248 # put a marker on the left edge of this column
249 # if this package is somehow special
250 my $supplemental = $opt{'supplemental'} || 0;
251 my $change_from = $opt{'change_from'} || 0;
253 if ( $supplemental or $change_from ) {
254 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
256 if ( $supplemental ) {
258 } elsif ( $change_from ) {
261 $style = qq!STYLE="$style"!;
264 $cust_pkg->pkgnum =~ /^(\d+)$/;
266 my @cust_pkg_usage = qsearch({
267 'select' => 'cust_pkg_usage.*',
268 'table' => 'cust_pkg_usage',
269 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
270 'extra_sql' => " WHERE pkgnum = $1",
271 'order_by' => ' ORDER BY priority ASC, description ASC',
276 #false laziness w/status.html
278 my($action, $label, $cust_pkg) = @_;
279 return '' unless $cust_pkg;
280 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
283 sub pkg_change_link {
284 my $cust_pkg = shift;
285 my $locationnum = $cust_pkg->locationnum;
286 include( '/elements/popup_link-cust_pkg.html',
287 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
288 'label' => emt('Change package'),
289 'actionlabel' => emt('Change'),
290 'cust_pkg' => $cust_pkg,
296 sub pkg_change_location_link {
297 my $cust_pkg = shift;
298 my $pkgpart = $cust_pkg->pkgpart;
299 include( '/elements/popup_link-cust_pkg.html',
300 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
301 "address1=;address2=;city=;county=;state=$statedefault;".
302 "zip=;country=$countrydefault",
303 'label' => emt('Change location'),
304 'actionlabel' => emt('Change'),
305 'cust_pkg' => $cust_pkg,
311 sub pkg_change_quantity_link {
312 include( '/elements/popup_link-cust_pkg.html',
313 'action' => $p. 'edit/cust_pkg_quantity.html?',
314 'label' => emt('Change quantity'),
315 'actionlabel' => emt('Change'),
322 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', emt('Edit dates'), @_ ); }
324 sub pkg_discount_link {
325 my $cust_pkg = shift or return '';
326 include( '/elements/popup_link-cust_pkg.html',
327 'action' => $p.'edit/cust_pkg_discount.html',
328 'label' => emt('Discount'),
329 'actionlabel' => emt('Discount'),
330 'cust_pkg' => $cust_pkg,
335 sub pkg_customize_link {
336 my $cust_pkg = shift or return '';
337 my $part_pkg = shift;
338 my $custnum = $cust_pkg->custnum;
339 qq!<A HREF="${p}edit/part_pkg.cgi?!.
340 "clone=". $part_pkg->pkgpart. ';'.
341 "pkgnum=". $cust_pkg->pkgnum.
342 qq!">!.emt('Customize').'</A>';
347 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
348 emt('View package events').