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 % unless ( $cust_pkg->get('cancel') || $opt{no_links} ) {
26 % if ( $change_from ) {
27 % # This is the target package for a future change.
28 % # Nothing you can do with it besides modify/cancel the
29 % # future change, and that's on the current package.
30 % } elsif ( $supplemental or $part_pkg->freq eq '0' ) {
31 % # Supplemental packages can't be changed independently.
32 % # One-time charges don't need to be changed.
33 % # For both of those, we only show "Edit dates", "Add comments",
34 % # and "Add invoice details".
35 % if ( $curuser->access_right('Edit customer package dates') ) {
36 ( <%pkg_dates_link($cust_pkg)%> )
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('Edit customer package dates') ) {
49 ( <%pkg_dates_link($cust_pkg)%> )
52 % if ( $curuser->access_right('Discount customer package')
53 % && $part_pkg->can_discount
54 % && ! scalar($cust_pkg->cust_pkg_discount_active)
55 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
59 ( <%pkg_discount_link($cust_pkg)%> )
62 % if ( $curuser->access_right('Customize customer package') ) {
64 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
67 <% $br ? '<BR>' : '' %>
70 % if ( $cust_pkg->num_cust_event
71 % && ( $curuser->access_right('Billing event reports')
72 % || $curuser->access_right('View customer billing events')
75 ( <%pkg_event_link($cust_pkg)%> )
87 % my $change_quan_label = 'Change quantity';
88 % if ( $cust_pkg->quantity > 1 ) {
89 % $change_quan_label = 'change';
90 <% mt('Quantity:') |h %>
91 <B><% $cust_pkg->quantity %></B>
94 % if ( $curuser->access_right('Change customer package')
95 % && ! $cust_pkg->get('cancel')
97 % && $part_pkg->freq ne '0'
99 % && $opt{'invoice-unitprice'}
103 ( <% pkg_change_quantity_link($cust_pkg, $change_quan_label) %> )
114 % my $change_sales_label = 'Change sales person';
115 % if ( $cust_pkg->salesnum ) {
116 % $change_sales_label = 'change';
117 <% mt('Sales Person:') |h %>
118 <B><% $cust_pkg->salesperson |h %></B>
121 % if ( $curuser->access_right('Change customer package')
122 % && ! $cust_pkg->get('cancel')
124 % #&& $part_pkg->freq ne '0'
125 % && ! $opt{no_links}
129 ( <% pkg_change_salesnum_link($cust_pkg, $change_sales_label) %> )
137 % my $editi = $curuser->access_right('Edit customer package invoice details');
138 % my $editc = $curuser->access_right('Edit customer package comments');
139 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
140 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
141 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
143 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
145 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
150 % if ( @invoice_detail ) {
152 <& /elements/table-grid.html &>
154 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
156 <% mt('Invoice details') |h %>
157 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
158 (<& /elements/popup_link.html, {
159 'action' => $editlink. 'I',
160 'label' => emt('edit'),
161 'actionlabel' => emt('Edit invoice details'),
162 'color' => '#333399',
170 % foreach my $cust_pkg_detail ( @invoice_detail ) {
172 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
179 % if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) {
181 ( <% include('/elements/popup_link.html', {
182 'action' => $editlink. 'I',
183 'label' => emt('Add invoice details'),
184 'actionlabel' => emt('Add invoice details'),
185 'color' => '#333399',
196 <& /elements/table-grid.html &>
198 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
200 <% mt('Comments') |h %>
201 % if ( $editc && ! $opt{no_links} ) {
202 (<& /elements/popup_link.html, {
203 'action' => $editlink. 'C',
204 'label' => emt('edit'),
205 'actionlabel' => emt('Edit comments'),
206 'color' => '#333399',
214 % foreach my $cust_pkg_detail ( @comments ) {
216 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
223 % if ( $editc && ! $opt{no_links} ) {
225 ( <& /elements/popup_link.html, {
226 'action' => $editlink. 'C',
227 'label' => emt('Add comments'),
228 'actionlabel' => emt('Add comments'),
229 'color' => '#333399',
244 % if ( @cust_pkg_usage ) {
245 <TABLE CLASS="usage inv">
246 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
247 % foreach my $usage (@cust_pkg_usage) {
248 % my $part = $usage->part_pkg_usage;
249 % my $ratio = 255 * ($usage->minutes / $part->minutes);
250 % $ratio = 255 if $ratio > 255; # because rollover
251 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
253 % $trstyle = ' CLASS="shared"' if $part->shared;
255 <TD ALIGN="right"><% $part->description %>: </TD>
256 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
257 <TD <%$color%>> / </TD>
258 <TD <%$color%>><% $part->minutes %></TD>
259 % if ( $part->shared ) {
260 <TD><I>(shared)</I></TD>
273 my $bgcolor = $opt{'bgcolor'};
274 my $cust_pkg = $opt{'cust_pkg'};
275 my $part_pkg = $opt{'part_pkg'};
277 my $curuser = $FS::CurrentUser::CurrentUser;
279 my $countrydefault = $opt{'countrydefault'} || 'US';
280 my $statedefault = $opt{'statedefault'}
281 || ($countrydefault eq 'US' ? 'CA' : '');
283 # put a marker on the left edge of this column
284 # if this package is somehow special
285 my $supplemental = $opt{'supplemental'} || 0;
286 my $change_from = $opt{'change_from'} || 0;
288 if ( $supplemental or $change_from ) {
289 $style = 'border-left-width: '.($supplemental + $change_from)*30 . 'px; '.
291 if ( $supplemental ) {
293 } elsif ( $change_from ) {
296 $style = qq!STYLE="$style"!;
299 $cust_pkg->pkgnum =~ /^(\d+)$/;
301 my @cust_pkg_usage = qsearch({
302 'select' => 'cust_pkg_usage.*',
303 'table' => 'cust_pkg_usage',
304 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
305 'extra_sql' => " WHERE pkgnum = $1",
306 'order_by' => ' ORDER BY priority ASC, description ASC',
311 #false laziness w/status.html
313 my($action, $label, $cust_pkg) = @_;
314 return '' unless $cust_pkg;
315 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
318 sub pkg_change_link {
319 my $cust_pkg = shift;
320 my $locationnum = $cust_pkg->locationnum;
321 include( '/elements/popup_link-cust_pkg.html',
322 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
323 'label' => emt('Change package'),
324 'actionlabel' => emt('Change'),
325 'cust_pkg' => $cust_pkg,
331 sub pkg_change_location_link {
332 my $cust_pkg = shift;
333 my $pkgpart = $cust_pkg->pkgpart;
334 include( '/elements/popup_link-cust_pkg.html',
335 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
336 "address1=;address2=;city=;county=;state=$statedefault;".
337 "zip=;country=$countrydefault",
338 'label' => emt('Change location'),
339 'actionlabel' => emt('Change'),
340 'cust_pkg' => $cust_pkg,
346 sub pkg_change_quantity_link {
347 my( $cust_pkg, $label ) = @_;
348 include( '/elements/popup_link-cust_pkg.html',
349 'action' => $p. 'edit/cust_pkg_quantity.html?',
350 'label' => emt($label),
351 'actionlabel' => emt('Change'),
352 'cust_pkg' => $cust_pkg,
358 sub pkg_change_salesnum_link {
359 my( $cust_pkg, $label ) = @_;
360 include( '/elements/popup_link-cust_pkg.html',
361 'action' => $p. 'edit/cust_pkg_salesnum.html?',
362 'label' => emt($label),
363 'actionlabel' => emt('Change'),
364 'cust_pkg' => $cust_pkg,
370 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', emt('Edit dates'), @_ ); }
372 sub pkg_discount_link {
373 my $cust_pkg = shift or return '';
374 include( '/elements/popup_link-cust_pkg.html',
375 'action' => $p.'edit/cust_pkg_discount.html',
376 'label' => emt('Discount'),
377 'actionlabel' => emt('Discount'),
378 'cust_pkg' => $cust_pkg,
383 sub pkg_customize_link {
384 my $cust_pkg = shift or return '';
385 my $part_pkg = shift;
386 my $custnum = $cust_pkg->custnum;
387 qq!<A HREF="${p}edit/part_pkg.cgi?!.
388 "clone=". $part_pkg->pkgpart. ';'.
389 "pkgnum=". $cust_pkg->pkgnum.
390 qq!">!.emt('Customize').'</A>';
395 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
396 emt('View package events').