1 <TD CLASS="inv package" BGCOLOR="<% $bgcolor %>" VALIGN="top"
2 STYLE="border-left-width: <% $supplemental * 30 %>px">
3 <TABLE CLASS="inv package">
6 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
7 ID ="cust_pkg<% $cust_pkg->pkgnum %>"
8 ><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
10 <% $part_pkg->custom_comment |h %>
14 % if ( $cust_pkg->quantity > 1 ) {
17 <% mt('Quantity:') |h %>
18 <B><% $cust_pkg->quantity %></B>
27 % unless ( $cust_pkg->get('cancel') ) {
29 % if ( $supplemental or $part_pkg->freq eq '0' ) {
30 % # Supplemental packages can't be changed independently.
31 % # One-time charges don't need to be changed.
32 % # For both of those, we only show "Add comments",
33 % # and "Add invoice details".
35 % # the usual case: links to change package definition,
36 % # discount, and customization
38 % if ( $curuser->access_right('Change customer package') ) {
40 ( <%pkg_change_link($cust_pkg)%> )
43 % if ( $curuser->access_right('Discount customer package')
44 % && $part_pkg->can_discount
45 % && ! scalar($cust_pkg->cust_pkg_discount_active)
46 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
50 ( <%pkg_discount_link($cust_pkg)%> )
53 % if ( $curuser->access_right('Customize customer package') ) {
55 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
58 <% $br ? '<BR>' : '' %>
61 % if ( $cust_pkg->num_cust_event
62 % && ( $curuser->access_right('Billing event reports')
63 % || $curuser->access_right('View customer billing events')
66 ( <%pkg_event_link($cust_pkg)%> )
74 % my $editi = $curuser->access_right('Edit customer package invoice details');
75 % my $editc = $curuser->access_right('Edit customer package comments');
76 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
77 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
78 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
80 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
82 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
87 % if ( @invoice_detail ) {
89 <& /elements/table-grid.html &>
91 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
93 <% mt('Invoice details') |h %>
94 % if ( $editi && ! $cust_pkg->get('cancel') ) {
95 (<& /elements/popup_link.html, {
96 'action' => $editlink. 'I',
97 'label' => emt('edit'),
98 'actionlabel' => emt('Edit invoice details'),
107 % foreach my $cust_pkg_detail ( @invoice_detail ) {
109 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
116 % if ( $editi && ! $cust_pkg->get('cancel') ) {
118 ( <% include('/elements/popup_link.html', {
119 'action' => $editlink. 'I',
120 'label' => emt('Add invoice details'),
121 'actionlabel' => emt('Add invoice details'),
122 'color' => '#333399',
133 <& /elements/table-grid.html &>
135 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
137 <% mt('Comments') |h %>
139 (<& /elements/popup_link.html, {
140 'action' => $editlink. 'C',
141 'label' => emt('edit'),
142 'actionlabel' => emt('Edit comments'),
143 'color' => '#333399',
151 % foreach my $cust_pkg_detail ( @comments ) {
153 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
162 ( <& /elements/popup_link.html, {
163 'action' => $editlink. 'C',
164 'label' => emt('Add comments'),
165 'actionlabel' => emt('Add comments'),
166 'color' => '#333399',
176 % if ( $curuser->access_right('Change customer package') and
177 % !$cust_pkg->get('cancel') and
179 % $part_pkg->freq ne '0' ) {
181 % if ( FS::Conf->new->exists('invoice-unitprice') ) {
183 ( <% pkg_change_quantity_link($cust_pkg) %> )
190 % if ( @cust_pkg_usage ) {
191 <TABLE CLASS="usage inv">
192 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
193 % foreach my $usage (@cust_pkg_usage) {
194 % my $part = $usage->part_pkg_usage;
195 % my $ratio = 255 * ($usage->minutes / $part->minutes);
196 % $ratio = 255 if $ratio > 255; # because rollover
197 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
199 % $trstyle = ' CLASS="shared"' if $part->shared;
201 <TD ALIGN="right"><% $part->description %>: </TD>
202 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
203 <TD <%$color%>> / </TD>
204 <TD <%$color%>><% $part->minutes %></TD>
205 % if ( $part->shared ) {
206 <TD><I>(shared)</I></TD>
219 my $bgcolor = $opt{'bgcolor'};
220 my $cust_pkg = $opt{'cust_pkg'};
221 my $part_pkg = $opt{'part_pkg'};
223 my $curuser = $FS::CurrentUser::CurrentUser;
225 my $countrydefault = $opt{'countrydefault'} || 'US';
226 my $statedefault = $opt{'statedefault'}
227 || ($countrydefault eq 'US' ? 'CA' : '');
229 my $supplemental = $opt{'supplemental'} || 0;
231 $cust_pkg->pkgnum =~ /^(\d+)$/;
233 my @cust_pkg_usage = qsearch({
234 'select' => 'cust_pkg_usage.*',
235 'table' => 'cust_pkg_usage',
236 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
237 'extra_sql' => " WHERE pkgnum = $1",
238 'order_by' => ' ORDER BY priority ASC, description ASC',
243 #false laziness w/status.html
245 my($action, $label, $cust_pkg) = @_;
246 return '' unless $cust_pkg;
247 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
250 sub pkg_change_link {
251 my $cust_pkg = shift;
252 my $locationnum = $cust_pkg->locationnum;
253 include( '/elements/popup_link-cust_pkg.html',
254 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
255 'label' => emt('Change package'),
256 'actionlabel' => emt('Change'),
257 'cust_pkg' => $cust_pkg,
261 sub pkg_change_location_link {
262 my $cust_pkg = shift;
263 my $pkgpart = $cust_pkg->pkgpart;
264 include( '/elements/popup_link-cust_pkg.html',
265 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
266 "address1=;address2=;city=;county=;state=$statedefault;".
267 "zip=;country=$countrydefault",
268 'label' => emt('Change location'),
269 'actionlabel' => emt('Change'),
270 'cust_pkg' => $cust_pkg,
274 sub pkg_change_quantity_link {
275 include( '/elements/popup_link-cust_pkg.html',
276 'action' => $p. 'edit/cust_pkg_quantity.html?',
277 'label' => emt('Change quantity'),
278 'actionlabel' => emt('Change'),
285 sub pkg_discount_link {
286 my $cust_pkg = shift or return '';
287 include( '/elements/popup_link-cust_pkg.html',
288 'action' => $p.'edit/cust_pkg_discount.html',
289 'label' => emt('Discount'),
290 'actionlabel' => emt('Discount'),
291 'cust_pkg' => $cust_pkg,
296 sub pkg_customize_link {
297 my $cust_pkg = shift or return '';
298 my $part_pkg = shift;
299 my $custnum = $cust_pkg->custnum;
300 qq!<A HREF="${p}edit/part_pkg.cgi?!.
301 "clone=". $part_pkg->pkgpart. ';'.
302 "pkgnum=". $cust_pkg->pkgnum.
303 qq!">!.emt('Customize').'</A>';
308 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
309 emt('View package events').