1 <TD CLASS="inv package" BGCOLOR="<% $bgcolor %>" VALIGN="top" <%$style%>>
2 <TABLE CLASS="inv package">
7 <% $opt{before_pkg_callback}
8 ? &{ $opt{before_pkg_callback} }( $cust_pkg )
11 <A NAME="cust_pkg<% $cust_pkg->pkgnum %>"
12 ID ="cust_pkg<% $cust_pkg->pkgnum %>"
13 ><% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B></A>
15 <% $part_pkg->custom_comment |h %>
24 % if ( $part_pkg->freq eq '0' and !$opt{no_links} ) {
25 % # One-time charge. Nothing you can do with this, unless:
26 % if ( $curuser->access_right('Modify one-time charge') ) {
27 ( <%onetime_change_link($cust_pkg)%> )
31 % } elsif ( !$cust_pkg->get('cancel') and !$opt{no_links} ) {
33 % if ( $change_from ) {
34 % # This is the target package for a future change.
35 % # Nothing you can do with it besides modify/cancel the
36 % # future change, and that's on the current package.
37 % } elsif ( $supplemental ) {
38 % # Show only "Add comments" and "Add invoice details".
39 % if ( $curuser->access_right('Edit customer package dates') ) {
40 ( <%pkg_dates_link($cust_pkg)%> )
43 % # the usual case: links to change package definition,
44 % # discount, and customization
46 % if ( $curuser->access_right('Change customer package') ) {
48 ( <%pkg_change_link($cust_pkg)%> )
51 % if ( $curuser->access_right('Edit customer package dates') ) {
53 ( <%pkg_dates_link($cust_pkg)%> )
56 % if ( $curuser->access_right('Discount customer package')
57 % && $part_pkg->can_discount
58 % && ! scalar($cust_pkg->cust_pkg_discount_active)
59 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
63 ( <%pkg_discount_link($cust_pkg)%> )
66 % if ( $curuser->access_right('Customize customer package') ) {
68 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
71 <% $br ? '<BR>' : '' %>
74 % if ( $cust_pkg->num_cust_event
75 % && ( $curuser->access_right('Billing event reports')
76 % || $curuser->access_right('View customer billing events')
79 ( <%pkg_event_link($cust_pkg)%> )
91 % my $change_quan_label = 'Change quantity';
92 % if ( $cust_pkg->quantity > 1 ) {
93 % $change_quan_label = 'change';
94 <% mt('Quantity:') |h %>
95 <B><% $cust_pkg->quantity %></B>
98 % if ( $curuser->access_right('Change customer package')
99 % && ! $cust_pkg->get('cancel')
101 % && $part_pkg->freq ne '0'
102 % && ! $opt{no_links}
103 % && $opt{'invoice-unitprice'}
107 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
118 % my $change_sales_label = 'Change sales person';
119 % if ( $cust_pkg->salesnum ) {
120 % $change_sales_label = 'change';
121 <% mt('Sales Person:') |h %>
122 <B><% $cust_pkg->salesperson |h %></B>
125 % if ( $curuser->access_right('Change customer package')
126 % && ! $cust_pkg->get('cancel')
128 % #&& $part_pkg->freq ne '0'
129 % && ! $opt{no_links}
133 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
141 % my $editi = $curuser->access_right('Edit customer package invoice details');
142 % my $editc = $curuser->access_right('Edit customer package comments');
143 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
144 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
145 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
147 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
149 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
154 % if ( @invoice_detail ) {
156 <& /elements/table-grid.html &>
158 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
160 <% mt('Invoice details') |h %>
161 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
162 (<& /elements/popup_link.html, {
163 'action' => $editlink. 'I',
164 'label' => emt('edit'),
165 'actionlabel' => emt('Edit invoice details'),
166 'color' => '#333399',
174 % foreach my $cust_pkg_detail ( @invoice_detail ) {
176 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
183 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
185 ( <% include('/elements/popup_link.html', {
186 'action' => $editlink. 'I',
187 'label' => emt('Add invoice details'),
188 'actionlabel' => emt('Add invoice details'),
189 'color' => '#333399',
200 <& /elements/table-grid.html &>
202 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
204 <% mt('Comments') |h %>
205 % if ( $editc && ! $opt{no_links} ) {
206 (<& /elements/popup_link.html, {
207 'action' => $editlink. 'C',
208 'label' => emt('edit'),
209 'actionlabel' => emt('Edit comments'),
210 'color' => '#333399',
218 % foreach my $cust_pkg_detail ( @comments ) {
220 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
227 % if ( $editc && ! $opt{no_links} ) {
229 ( <& /elements/popup_link.html, {
230 'action' => $editlink. 'C',
231 'label' => emt('Add comments'),
232 'actionlabel' => emt('Add comments'),
233 'color' => '#333399',
248 % if ( @cust_pkg_usage ) {
249 <TABLE CLASS="usage inv">
250 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
251 % foreach my $usage (@cust_pkg_usage) {
252 % my $part = $usage->part_pkg_usage;
253 % my $ratio = 255 * ($usage->minutes / $part->minutes);
254 % $ratio = 255 if $ratio > 255; # because rollover
255 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
257 % $trstyle = ' CLASS="shared"' if $part->shared;
259 <TD ALIGN="right"><% $part->description %>: </TD>
260 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
261 <TD <%$color%>> / </TD>
262 <TD <%$color%>><% $part->minutes %></TD>
263 % if ( $part->shared ) {
264 <TD><I>(shared)</I></TD>
277 my $bgcolor = $opt{'bgcolor'};
278 my $cust_pkg = $opt{'cust_pkg'};
279 my $part_pkg = $opt{'part_pkg'};
281 my $curuser = $FS::CurrentUser::CurrentUser;
283 my $countrydefault = $opt{'countrydefault'} || 'US';
284 my $statedefault = $opt{'statedefault'}
285 || ($countrydefault eq 'US' ? 'CA' : '');
287 # put a marker on the left edge of this column
288 # if this package is somehow special
289 my $supplemental = $opt{'supplemental'} || 0;
290 my $change_from = $opt{'change_from'} || 0;
292 if ( $supplemental or $change_from ) {
293 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
295 if ( $supplemental ) {
297 } elsif ( $change_from ) {
300 $style = qq!STYLE="$style"!;
303 $cust_pkg->pkgnum =~ /^(\d+)$/;
305 my @cust_pkg_usage = qsearch({
306 'select' => 'cust_pkg_usage.*',
307 'table' => 'cust_pkg_usage',
308 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
309 'extra_sql' => " WHERE pkgnum = $1",
310 'order_by' => ' ORDER BY priority ASC, description ASC',
315 #false laziness w/status.html
317 my($action, $label, $cust_pkg) = @_;
318 return '' unless $cust_pkg;
319 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
322 sub pkg_change_link {
323 my $cust_pkg = shift;
324 my $locationnum = $cust_pkg->locationnum;
325 include( '/elements/popup_link-cust_pkg.html',
326 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
327 'label' => emt('Change package'),
328 'actionlabel' => emt('Change'),
329 'cust_pkg' => $cust_pkg,
335 sub onetime_change_link {
336 my $cust_pkg = shift;
337 my $pkgnum = $cust_pkg->pkgnum;
338 include( '/elements/popup_link-cust_pkg.html',
339 'action' => $p. "edit/quick-charge.html?change_pkgnum=$pkgnum",
340 'label' => emt('Modify one-time charge'),
341 'actionlabel' => emt('Modify'),
342 'cust_pkg' => $cust_pkg,
348 sub pkg_change_location_link {
349 my $cust_pkg = shift;
350 my $pkgpart = $cust_pkg->pkgpart;
351 include( '/elements/popup_link-cust_pkg.html',
352 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
353 "address1=;address2=;city=;county=;state=$statedefault;".
354 "zip=;country=$countrydefault",
355 'label' => emt('Change location'),
356 'actionlabel' => emt('Change'),
357 'cust_pkg' => $cust_pkg,
363 sub pkg_change_quantity_link {
364 my( $cust_pkg, $label ) = @_;
365 include( '/elements/popup_link-cust_pkg.html',
366 'action' => $p. 'edit/cust_pkg_quantity.html?',
367 'label' => emt($label),
368 'actionlabel' => emt('Change'),
369 'cust_pkg' => $cust_pkg,
375 sub pkg_change_salesnum_link {
376 my( $cust_pkg, $label ) = @_;
377 include( '/elements/popup_link-cust_pkg.html',
378 'action' => $p. 'edit/cust_pkg_salesnum.html?',
379 'label' => emt($label),
380 'actionlabel' => emt('Change'),
381 'cust_pkg' => $cust_pkg,
387 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', emt('Edit dates'), @_ ); }
389 sub pkg_discount_link {
390 my $cust_pkg = shift or return '';
391 include( '/elements/popup_link-cust_pkg.html',
392 'action' => $p.'edit/cust_pkg_discount.html',
393 'label' => emt('Discount'),
394 'actionlabel' => emt('Discount'),
395 'cust_pkg' => $cust_pkg,
400 sub pkg_customize_link {
401 my $cust_pkg = shift or return '';
402 my $part_pkg = shift;
403 my $custnum = $cust_pkg->custnum;
404 qq!<A HREF="${p}edit/part_pkg.cgi?!.
405 "clone=". $part_pkg->pkgpart. ';'.
406 "pkgnum=". $cust_pkg->pkgnum.
407 qq!">!.emt('Customize').'</A>';
412 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
413 emt('View package events').