1 <TD CLASS="inv package" BGCOLOR="<% $bgcolor %>" VALIGN="top"
2 STYLE="border-left-width: <% $supplemental * 30 %>px">
3 <TABLE CLASS="inv package">
6 <% $opt{before_pkg_callback}
7 ? &{ $opt{before_pkg_callback} }( $cust_pkg )
10 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
11 ID ="cust_pkg<% $cust_pkg->pkgnum %>"
12 ><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
14 <% $part_pkg->custom_comment |h %>
18 % if ( $cust_pkg->quantity > 1 ) {
21 <% mt('Quantity:') |h %>
22 <B><% $cust_pkg->quantity %></B>
31 % unless ( $cust_pkg->get('cancel') || $opt{no_links} ) {
33 % if ( $supplemental or $part_pkg->freq eq '0' ) {
34 % # Supplemental packages can't be changed independently.
35 % # One-time charges don't need to be changed.
36 % # For both of those, we only show "Edit dates", "Add comments",
37 % # and "Add invoice details".
38 % if ( $curuser->access_right('Edit customer package dates') ) {
39 ( <%pkg_dates_link($cust_pkg)%> )
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('Edit customer package dates') ) {
52 ( <%pkg_dates_link($cust_pkg)%> )
55 % if ( $curuser->access_right('Discount customer package')
56 % && $part_pkg->can_discount
57 % && ! scalar($cust_pkg->cust_pkg_discount_active)
58 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
62 ( <%pkg_discount_link($cust_pkg)%> )
65 % if ( $curuser->access_right('Customize customer package') ) {
67 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
70 <% $br ? '<BR>' : '' %>
73 % if ( $cust_pkg->num_cust_event
74 % && ( $curuser->access_right('Billing event reports')
75 % || $curuser->access_right('View customer billing events')
78 ( <%pkg_event_link($cust_pkg)%> )
86 % my $editi = $curuser->access_right('Edit customer package invoice details');
87 % my $editc = $curuser->access_right('Edit customer package comments');
88 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
89 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
90 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
92 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
94 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
99 % if ( @invoice_detail ) {
101 <& /elements/table-grid.html &>
103 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
105 <% mt('Invoice details') |h %>
106 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
107 (<& /elements/popup_link.html, {
108 'action' => $editlink. 'I',
109 'label' => emt('edit'),
110 'actionlabel' => emt('Edit invoice details'),
111 'color' => '#333399',
119 % foreach my $cust_pkg_detail ( @invoice_detail ) {
121 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
128 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
130 ( <% include('/elements/popup_link.html', {
131 'action' => $editlink. 'I',
132 'label' => emt('Add invoice details'),
133 'actionlabel' => emt('Add invoice details'),
134 'color' => '#333399',
145 <& /elements/table-grid.html &>
147 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
149 <% mt('Comments') |h %>
150 % if ( $editc && ! $opt{no_links} ) {
151 (<& /elements/popup_link.html, {
152 'action' => $editlink. 'C',
153 'label' => emt('edit'),
154 'actionlabel' => emt('Edit comments'),
155 'color' => '#333399',
163 % foreach my $cust_pkg_detail ( @comments ) {
165 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
172 % if ( $editc && ! $opt{no_links} ) {
174 ( <& /elements/popup_link.html, {
175 'action' => $editlink. 'C',
176 'label' => emt('Add comments'),
177 'actionlabel' => emt('Add comments'),
178 'color' => '#333399',
188 % if ( $curuser->access_right('Change customer package')
189 % && ! $cust_pkg->get('cancel')
191 % && $part_pkg->freq ne '0'
192 % && ! $opt{no_links}
196 % if ( FS::Conf->new->exists('invoice-unitprice') ) {
198 ( <% pkg_change_quantity_link($cust_pkg) %> )
205 % if ( @cust_pkg_usage ) {
206 <TABLE CLASS="usage inv">
207 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
208 % foreach my $usage (@cust_pkg_usage) {
209 % my $part = $usage->part_pkg_usage;
210 % my $ratio = 255 * ($usage->minutes / $part->minutes);
211 % $ratio = 255 if $ratio > 255; # because rollover
212 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
214 % $trstyle = ' CLASS="shared"' if $part->shared;
216 <TD ALIGN="right"><% $part->description %>: </TD>
217 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
218 <TD <%$color%>> / </TD>
219 <TD <%$color%>><% $part->minutes %></TD>
220 % if ( $part->shared ) {
221 <TD><I>(shared)</I></TD>
234 my $bgcolor = $opt{'bgcolor'};
235 my $cust_pkg = $opt{'cust_pkg'};
236 my $part_pkg = $opt{'part_pkg'};
238 my $curuser = $FS::CurrentUser::CurrentUser;
240 my $countrydefault = $opt{'countrydefault'} || 'US';
241 my $statedefault = $opt{'statedefault'}
242 || ($countrydefault eq 'US' ? 'CA' : '');
244 my $supplemental = $opt{'supplemental'} || 0;
246 $cust_pkg->pkgnum =~ /^(\d+)$/;
248 my @cust_pkg_usage = qsearch({
249 'select' => 'cust_pkg_usage.*',
250 'table' => 'cust_pkg_usage',
251 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
252 'extra_sql' => " WHERE pkgnum = $1",
253 'order_by' => ' ORDER BY priority ASC, description ASC',
258 #false laziness w/status.html
260 my($action, $label, $cust_pkg) = @_;
261 return '' unless $cust_pkg;
262 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
265 sub pkg_change_link {
266 my $cust_pkg = shift;
267 my $locationnum = $cust_pkg->locationnum;
268 include( '/elements/popup_link-cust_pkg.html',
269 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
270 'label' => emt('Change package'),
271 'actionlabel' => emt('Change'),
272 'cust_pkg' => $cust_pkg,
278 sub pkg_change_location_link {
279 my $cust_pkg = shift;
280 my $pkgpart = $cust_pkg->pkgpart;
281 include( '/elements/popup_link-cust_pkg.html',
282 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
283 "address1=;address2=;city=;county=;state=$statedefault;".
284 "zip=;country=$countrydefault",
285 'label' => emt('Change location'),
286 'actionlabel' => emt('Change'),
287 'cust_pkg' => $cust_pkg,
293 sub pkg_change_quantity_link {
294 include( '/elements/popup_link-cust_pkg.html',
295 'action' => $p. 'edit/cust_pkg_quantity.html?',
296 'label' => emt('Change quantity'),
297 'actionlabel' => emt('Change'),
304 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', emt('Edit dates'), @_ ); }
306 sub pkg_discount_link {
307 my $cust_pkg = shift or return '';
308 include( '/elements/popup_link-cust_pkg.html',
309 'action' => $p.'edit/cust_pkg_discount.html',
310 'label' => emt('Discount'),
311 'actionlabel' => emt('Discount'),
312 'cust_pkg' => $cust_pkg,
317 sub pkg_customize_link {
318 my $cust_pkg = shift or return '';
319 my $part_pkg = shift;
320 my $custnum = $cust_pkg->custnum;
321 qq!<A HREF="${p}edit/part_pkg.cgi?!.
322 "clone=". $part_pkg->pkgpart. ';'.
323 "pkgnum=". $cust_pkg->pkgnum.
324 qq!">!.emt('Customize').'</A>';
329 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
330 emt('View package events').