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 ) {
30 % # then only show "Edit dates", "Add invoice details", and "Add
32 % if ( $curuser->access_right('Edit customer package dates') ) {
33 ( <%pkg_dates_link($cust_pkg)%> )
38 % if ( $curuser->access_right('Change customer package') ) {
40 ( <%pkg_change_link($cust_pkg)%> )
43 % if ( $curuser->access_right('Edit customer package dates') ) {
45 ( <%pkg_dates_link($cust_pkg)%> )
48 % if ( $curuser->access_right('Discount customer package')
49 % && $part_pkg->can_discount
50 % && ! scalar($cust_pkg->cust_pkg_discount_active)
51 % && ! scalar($cust_pkg->part_pkg->part_pkg_discount)
55 ( <%pkg_discount_link($cust_pkg)%> )
58 % if ( $curuser->access_right('Customize customer package') ) {
60 ( <%pkg_customize_link($cust_pkg,$part_pkg)%> )
63 <% $br ? '<BR>' : '' %>
66 % if ( $cust_pkg->num_cust_event
67 % && ( $curuser->access_right('Billing event reports')
68 % || $curuser->access_right('View customer billing events')
71 ( <%pkg_event_link($cust_pkg)%> )
79 % my $editi = $curuser->access_right('Edit customer package invoice details');
80 % my $editc = $curuser->access_right('Edit customer package comments');
81 % my @cust_pkg_detail = $cust_pkg->cust_pkg_detail;
82 % my @invoice_detail = grep { $_->detailtype eq 'I' } @cust_pkg_detail;
83 % my @comments = grep { $_->detailtype eq 'C' } @cust_pkg_detail;
85 % if ( scalar(@invoice_detail) || scalar(@comments) || $editi || $editc ) {
87 % my $editlink = $p. 'edit/cust_pkg_detail.html?pkgnum='. $cust_pkg->pkgnum.
92 % if ( @invoice_detail ) {
94 <& /elements/table-grid.html &>
96 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
98 <% mt('Invoice details') |h %>
99 % if ( $editi && ! $cust_pkg->get('cancel') ) {
100 (<& /elements/popup_link.html, {
101 'action' => $editlink. 'I',
102 'label' => emt('edit'),
103 'actionlabel' => emt('Edit invoice details'),
104 'color' => '#333399',
112 % foreach my $cust_pkg_detail ( @invoice_detail ) {
114 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
121 % if ( $editi && ! $cust_pkg->get('cancel') ) {
123 ( <% include('/elements/popup_link.html', {
124 'action' => $editlink. 'I',
125 'label' => emt('Add invoice details'),
126 'actionlabel' => emt('Add invoice details'),
127 'color' => '#333399',
138 <& /elements/table-grid.html &>
140 <TH BGCOLOR="#dddddd" STYLE="border-bottom: dashed 1px black; padding-bottom: 1px">
142 <% mt('Comments') |h %>
144 (<& /elements/popup_link.html, {
145 'action' => $editlink. 'C',
146 'label' => emt('edit'),
147 'actionlabel' => emt('Edit comments'),
148 'color' => '#333399',
156 % foreach my $cust_pkg_detail ( @comments ) {
158 <TD><FONT SIZE="-1"> - <% $cust_pkg_detail->detail |h %></FONT></TD>
167 ( <& /elements/popup_link.html, {
168 'action' => $editlink. 'C',
169 'label' => emt('Add comments'),
170 'actionlabel' => emt('Add comments'),
171 'color' => '#333399',
181 % if ( $curuser->access_right('Change customer package') and
182 % !$cust_pkg->get('cancel') and
184 % !$opt{'show_location'}) {
187 ( <% pkg_change_location_link($cust_pkg) %> )
193 % if ( @cust_pkg_usage ) {
194 <TABLE CLASS="usage inv">
195 <TR><TH COLSPAN=4><% mt('Included usage') %></TH></TR>
196 % foreach my $usage (@cust_pkg_usage) {
197 % my $part = $usage->part_pkg_usage;
198 % my $ratio = 255 * ($usage->minutes / $part->minutes);
199 % $ratio = 255 if $ratio > 255; # because rollover
200 % my $color = sprintf('STYLE="font-weight: bold; color: #%02x%02x00"', 255 - $ratio, $ratio);
202 % $trstyle = ' CLASS="shared"' if $part->shared;
204 <TD ALIGN="right"><% $part->description %>: </TD>
205 <TD <%$color%> ALIGN="right"><% $usage->minutes %></TD>
206 <TD <%$color%>> / </TD>
207 <TD <%$color%>><% $part->minutes %></TD>
208 % if ( $part->shared ) {
209 <TD><I>(shared)</I></TD>
222 my $bgcolor = $opt{'bgcolor'};
223 my $cust_pkg = $opt{'cust_pkg'};
224 my $part_pkg = $opt{'part_pkg'};
226 my $curuser = $FS::CurrentUser::CurrentUser;
228 my $countrydefault = $opt{'countrydefault'} || 'US';
229 my $statedefault = $opt{'statedefault'}
230 || ($countrydefault eq 'US' ? 'CA' : '');
232 my $supplemental = $opt{'supplemental'} || 0;
234 $cust_pkg->pkgnum =~ /^(\d+)$/;
236 my @cust_pkg_usage = qsearch({
237 'select' => 'cust_pkg_usage.*',
238 'table' => 'cust_pkg_usage',
239 'addl_from' => ' JOIN part_pkg_usage USING (pkgusagepart)',
240 'extra_sql' => " WHERE pkgnum = $1",
241 'order_by' => ' ORDER BY priority ASC, description ASC',
246 #false laziness w/status.html
248 my($action, $label, $cust_pkg) = @_;
249 return '' unless $cust_pkg;
250 qq!<a href="$p$action.cgi?!. $cust_pkg->pkgnum. qq!">$label</a>!;
253 sub pkg_change_link {
254 my $cust_pkg = shift;
255 my $locationnum = $cust_pkg->locationnum;
256 include( '/elements/popup_link-cust_pkg.html',
257 'action' => $p. "misc/change_pkg.cgi?locationnum=$locationnum",
258 'label' => emt('Change package'),
259 'actionlabel' => emt('Change'),
260 'cust_pkg' => $cust_pkg,
264 sub pkg_change_location_link {
265 my $cust_pkg = shift;
266 my $pkgpart = $cust_pkg->pkgpart;
267 include( '/elements/popup_link-cust_pkg.html',
268 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;".
269 "address1=;address2=;city=;county=;state=$statedefault;".
270 "zip=;country=$countrydefault",
271 'label' => emt('Change location'),
272 'actionlabel' => emt('Change'),
273 'cust_pkg' => $cust_pkg,
277 sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', emt('Edit dates'), @_ ); }
279 sub pkg_discount_link {
280 my $cust_pkg = shift or return '';
281 include( '/elements/popup_link-cust_pkg.html',
282 'action' => $p.'edit/cust_pkg_discount.html',
283 'label' => emt('Discount'),
284 'actionlabel' => emt('Discount'),
285 'cust_pkg' => $cust_pkg,
290 sub pkg_customize_link {
291 my $cust_pkg = shift or return '';
292 my $part_pkg = shift;
293 my $custnum = $cust_pkg->custnum;
294 qq!<A HREF="${p}edit/part_pkg.cgi?!.
295 "clone=". $part_pkg->pkgpart. ';'.
296 "pkgnum=". $cust_pkg->pkgnum.
297 qq!">!.emt('Customize').'</A>';
302 qq!<a href="${p}search/cust_event.html?pkgnum=!. $cust_pkg->pkgnum. qq!">!.
303 emt('View package events').