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 "Add comments",
37 % # and "Add invoice details".
39 % # the usual case: links to change package definition,
40 % # discount, and customization
42 % if ( $curuser->access_right('Change customer package') ) {
44 ( <%pkg_change_link($cust_pkg)%> )
47 % if ( $curuser->access_right('Discount customer package')
48 % && $part_pkg->can_discount
49 % && ! scalar($cust_pkg->cust_pkg_discount_active)
50 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
54 ( <%pkg_discount_link($cust_pkg)%> )
57 % if ( $curuser->access_right('Customize customer package') ) {
59 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
62 <% $br ? '<BR>' : '' %>
65 % if ( $cust_pkg->num_cust_event
66 % && ( $curuser->access_right('Billing event reports')
67 % || $curuser->access_right('View customer billing events')
70 ( <%pkg_event_link($cust_pkg)%> )
78 % my $editi = $curuser->access_right('Edit customer package invoice details');
79 % my $editc = $curuser->access_right('Edit customer package comments');
80 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
81 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
82 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
84 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
86 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
91 % if ( @invoice_detail ) {
93 <& /elements/table-grid.html &>
95 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
97 <% mt('Invoice details') |h %>
98 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
99 (<& /elements/popup_link.html, {
100 'action' => $editlink. 'I',
101 'label' => emt('edit'),
102 'actionlabel' => emt('Edit invoice details'),
103 'color' => '#333399',
111 % foreach my $cust_pkg_detail ( @invoice_detail ) {
113 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
120 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
122 ( <% include('/elements/popup_link.html', {
123 'action' => $editlink. 'I',
124 'label' => emt('Add invoice details'),
125 'actionlabel' => emt('Add invoice details'),
126 'color' => '#333399',
137 <& /elements/table-grid.html &>
139 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
141 <% mt('Comments') |h %>
142 % if ( $editc && ! $opt{no_links} ) {
143 (<& /elements/popup_link.html, {
144 'action' => $editlink. 'C',
145 'label' => emt('edit'),
146 'actionlabel' => emt('Edit comments'),
147 'color' => '#333399',
155 % foreach my $cust_pkg_detail ( @comments ) {
157 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
164 % if ( $editc && ! $opt{no_links} ) {
166 ( <& /elements/popup_link.html, {
167 'action' => $editlink. 'C',
168 'label' => emt('Add comments'),
169 'actionlabel' => emt('Add comments'),
170 'color' => '#333399',
180 % if ( $curuser->access_right('Change customer package')
181 % && ! $cust_pkg->get('cancel')
183 % && $part_pkg->freq ne '0'
184 % && ! $opt{no_links}
188 % if ( FS::Conf->new->exists('invoice-unitprice') ) {
190 ( <% pkg_change_quantity_link($cust_pkg) %> )
197 % if ( @cust_pkg_usage ) {
198 <TABLE CLASS="usage inv">
199 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
200 % foreach my $usage (@cust_pkg_usage) {
201 % my $part = $usage->part_pkg_usage;
202 % my $ratio = 255 * ($usage->minutes / $part->minutes);
203 % $ratio = 255 if $ratio > 255; # because rollover
204 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
206 % $trstyle = ' CLASS="shared"' if $part->shared;
208 <TD ALIGN="right"><% $part->description %>: </TD>
209 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
210 <TD <%$color%>> / </TD>
211 <TD <%$color%>><% $part->minutes %></TD>
212 % if ( $part->shared ) {
213 <TD><I>(shared)</I></TD>
226 my $bgcolor = $opt{'bgcolor'};
227 my $cust_pkg = $opt{'cust_pkg'};
228 my $part_pkg = $opt{'part_pkg'};
230 my $curuser = $FS::CurrentUser::CurrentUser;
232 my $countrydefault = $opt{'countrydefault'} || 'US';
233 my $statedefault = $opt{'statedefault'}
234 || ($countrydefault eq 'US' ? 'CA' : '');
236 my $supplemental = $opt{'supplemental'} || 0;
238 $cust_pkg->pkgnum =~ /^(\d+)$/;
240 my @cust_pkg_usage = qsearch({
241 'select' => 'cust_pkg_usage.*',
242 'table' => 'cust_pkg_usage',
243 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
244 'extra_sql' => " WHERE pkgnum = $1",
245 'order_by' => ' ORDER BY priority ASC, description ASC',
250 #false laziness w/status.html
252 my($action, $label, $cust_pkg) = @_;
253 return '' unless $cust_pkg;
254 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
257 sub pkg_change_link {
258 my $cust_pkg = shift;
259 my $locationnum = $cust_pkg->locationnum;
260 include( '/elements/popup_link-cust_pkg.html',
261 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
262 'label' => emt('Change package'),
263 'actionlabel' => emt('Change'),
264 'cust_pkg' => $cust_pkg,
270 sub pkg_change_location_link {
271 my $cust_pkg = shift;
272 my $pkgpart = $cust_pkg->pkgpart;
273 include( '/elements/popup_link-cust_pkg.html',
274 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
275 "address1=;address2=;city=;county=;state=$statedefault;".
276 "zip=;country=$countrydefault",
277 'label' => emt('Change location'),
278 'actionlabel' => emt('Change'),
279 'cust_pkg' => $cust_pkg,
285 sub pkg_change_quantity_link {
286 include( '/elements/popup_link-cust_pkg.html',
287 'action' => $p. 'edit/cust_pkg_quantity.html?',
288 'label' => emt('Change quantity'),
289 'actionlabel' => emt('Change'),
296 sub pkg_discount_link {
297 my $cust_pkg = shift or return '';
298 include( '/elements/popup_link-cust_pkg.html',
299 'action' => $p.'edit/cust_pkg_discount.html',
300 'label' => emt('Discount'),
301 'actionlabel' => emt('Discount'),
302 'cust_pkg' => $cust_pkg,
307 sub pkg_customize_link {
308 my $cust_pkg = shift or return '';
309 my $part_pkg = shift;
310 my $custnum = $cust_pkg->custnum;
311 qq!<A HREF="${p}edit/part_pkg.cgi?!.
312 "clone=". $part_pkg->pkgpart. ';'.
313 "pkgnum=". $cust_pkg->pkgnum.
314 qq!">!.emt('Customize').'</A>';
319 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
320 emt('View package events').