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 "Edit dates", "Add comments",
33 % # and "Add invoice details".
34 % if ( $curuser->access_right('Edit customer package dates') ) {
35 ( <%pkg_dates_link($cust_pkg)%> )
38 % # the usual case: links to change package definition,
39 % # discount, and customization
41 % if ( $curuser->access_right('Change customer package') ) {
43 ( <%pkg_change_link($cust_pkg)%> )
46 % if ( $curuser->access_right('Edit customer package dates') ) {
48 ( <%pkg_dates_link($cust_pkg)%> )
51 % if ( $curuser->access_right('Discount customer package')
52 % && $part_pkg->can_discount
53 % && ! scalar($cust_pkg->cust_pkg_discount_active)
54 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
58 ( <%pkg_discount_link($cust_pkg)%> )
61 % if ( $curuser->access_right('Customize customer package') ) {
63 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
66 <% $br ? '<BR>' : '' %>
69 % if ( $cust_pkg->num_cust_event
70 % && ( $curuser->access_right('Billing event reports')
71 % || $curuser->access_right('View customer billing events')
74 ( <%pkg_event_link($cust_pkg)%> )
82 % my $editi = $curuser->access_right('Edit customer package invoice details');
83 % my $editc = $curuser->access_right('Edit customer package comments');
84 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
85 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
86 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
88 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
90 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
95 % if ( @invoice_detail ) {
97 <& /elements/table-grid.html &>
99 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
101 <% mt('Invoice details') |h %>
102 % if ( $editi && ! $cust_pkg->get('cancel') ) {
103 (<& /elements/popup_link.html, {
104 'action' => $editlink. 'I',
105 'label' => emt('edit'),
106 'actionlabel' => emt('Edit invoice details'),
107 'color' => '#333399',
115 % foreach my $cust_pkg_detail ( @invoice_detail ) {
117 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
124 % if ( $editi && ! $cust_pkg->get('cancel') ) {
126 ( <% include('/elements/popup_link.html', {
127 'action' => $editlink. 'I',
128 'label' => emt('Add invoice details'),
129 'actionlabel' => emt('Add invoice details'),
130 'color' => '#333399',
141 <& /elements/table-grid.html &>
143 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
145 <% mt('Comments') |h %>
147 (<& /elements/popup_link.html, {
148 'action' => $editlink. 'C',
149 'label' => emt('edit'),
150 'actionlabel' => emt('Edit comments'),
151 'color' => '#333399',
159 % foreach my $cust_pkg_detail ( @comments ) {
161 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
170 ( <& /elements/popup_link.html, {
171 'action' => $editlink. 'C',
172 'label' => emt('Add comments'),
173 'actionlabel' => emt('Add comments'),
174 'color' => '#333399',
184 % if ( $curuser->access_right('Change customer package') and
185 % !$cust_pkg->get('cancel') and
187 % $part_pkg->freq ne '0' ) {
189 % if ( !$opt{'show_location'} ) {
191 ( <% pkg_change_location_link($cust_pkg) %> )
194 % if ( FS::Conf->new->exists('invoice-unitprice') ) {
196 ( <% pkg_change_quantity_link($cust_pkg) %> )
203 % if ( @cust_pkg_usage ) {
204 <TABLE CLASS="usage inv">
205 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
206 % foreach my $usage (@cust_pkg_usage) {
207 % my $part = $usage->part_pkg_usage;
208 % my $ratio = 255 * ($usage->minutes / $part->minutes);
209 % $ratio = 255 if $ratio > 255; # because rollover
210 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
212 % $trstyle = ' CLASS="shared"' if $part->shared;
214 <TD ALIGN="right"><% $part->description %>: </TD>
215 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
216 <TD <%$color%>> / </TD>
217 <TD <%$color%>><% $part->minutes %></TD>
218 % if ( $part->shared ) {
219 <TD><I>(shared)</I></TD>
232 my $bgcolor = $opt{'bgcolor'};
233 my $cust_pkg = $opt{'cust_pkg'};
234 my $part_pkg = $opt{'part_pkg'};
236 my $curuser = $FS::CurrentUser::CurrentUser;
238 my $countrydefault = $opt{'countrydefault'} || 'US';
239 my $statedefault = $opt{'statedefault'}
240 || ($countrydefault eq 'US' ? 'CA' : '');
242 my $supplemental = $opt{'supplemental'} || 0;
244 $cust_pkg->pkgnum =~ /^(\d+)$/;
246 my @cust_pkg_usage = qsearch({
247 'select' => 'cust_pkg_usage.*',
248 'table' => 'cust_pkg_usage',
249 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
250 'extra_sql' => " WHERE pkgnum = $1",
251 'order_by' => ' ORDER BY priority ASC, description ASC',
256 #false laziness w/status.html
258 my($action, $label, $cust_pkg) = @_;
259 return '' unless $cust_pkg;
260 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
263 sub pkg_change_link {
264 my $cust_pkg = shift;
265 my $locationnum = $cust_pkg->locationnum;
266 include( '/elements/popup_link-cust_pkg.html',
267 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
268 'label' => emt('Change package'),
269 'actionlabel' => emt('Change'),
270 'cust_pkg' => $cust_pkg,
274 sub pkg_change_location_link {
275 my $cust_pkg = shift;
276 my $pkgpart = $cust_pkg->pkgpart;
277 include( '/elements/popup_link-cust_pkg.html',
278 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
279 "address1=;address2=;city=;county=;state=$statedefault;".
280 "zip=;country=$countrydefault",
281 'label' => emt('Change location'),
282 'actionlabel' => emt('Change'),
283 'cust_pkg' => $cust_pkg,
287 sub pkg_change_quantity_link {
288 include( '/elements/popup_link-cust_pkg.html',
289 'action' => $p. 'edit/cust_pkg_quantity.html?',
290 'label' => emt('Change quantity'),
291 'actionlabel' => emt('Change'),
298 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', emt('Edit dates'), @_ ); }
300 sub pkg_discount_link {
301 my $cust_pkg = shift or return '';
302 include( '/elements/popup_link-cust_pkg.html',
303 'action' => $p.'edit/cust_pkg_discount.html',
304 'label' => emt('Discount'),
305 'actionlabel' => emt('Discount'),
306 'cust_pkg' => $cust_pkg,
311 sub pkg_customize_link {
312 my $cust_pkg = shift or return '';
313 my $part_pkg = shift;
314 my $custnum = $cust_pkg->custnum;
315 qq!<A HREF="${p}edit/part_pkg.cgi?!.
316 "clone=". $part_pkg->pkgpart. ';'.
317 "pkgnum=". $cust_pkg->pkgnum.
318 qq!">!.emt('Customize').'</A>';
323 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
324 emt('View package events').