summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2010-01-30 08:55:12 +0000
committerivan <ivan>2010-01-30 08:55:12 +0000
commit2d5f9e43a60773a9b079e96c330cb9e0e089800a (patch)
tree999756a0c9f3b1f6db2347925091f7e6d0e54ce5 /httemplate
parent76722f634186b9e6f164640700029e6f1bee5722 (diff)
discounts, RT#6679
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/edit/process/quick-cust_pkg.cgi1
-rw-r--r--httemplate/elements/select-discount.html20
-rw-r--r--httemplate/elements/tr-select-discount.html27
-rw-r--r--httemplate/misc/order_pkg.html8
-rw-r--r--httemplate/view/cust_main/packages/package.html2
-rw-r--r--httemplate/view/cust_main/packages/status.html39
6 files changed, 93 insertions, 4 deletions
diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi
index 7a0f08280..c60156746 100644
--- a/httemplate/edit/process/quick-cust_pkg.cgi
+++ b/httemplate/edit/process/quick-cust_pkg.cgi
@@ -53,6 +53,7 @@ my $cust_pkg = new FS::cust_pkg {
? str2time($cgi->param('start_date'))
: ''
),
+ 'discountnum' => scalar($cgi->param('discountnum')),
'refnum' => $refnum,
'locationnum' => $locationnum,
};
diff --git a/httemplate/elements/select-discount.html b/httemplate/elements/select-discount.html
new file mode 100644
index 000000000..e0b6e6cbe
--- /dev/null
+++ b/httemplate/elements/select-discount.html
@@ -0,0 +1,20 @@
+<% include( '/elements/select-table.html',
+ 'table' => 'discount',
+ 'name_col' => 'description',
+ 'order_by' => 'ORDER BY discountnum', #XXX weight
+ 'value' => $discountnum,
+ 'empty_label' => '(none)',
+ 'hashref' => { 'disabled' => '' },
+ %opt,
+ )
+%>
+<%init>
+
+my %opt = @_;
+my $discountnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'records'} = delete $opt{'discount'}
+ if $opt{'discount'};
+
+</%init>
+
diff --git a/httemplate/elements/tr-select-discount.html b/httemplate/elements/tr-select-discount.html
new file mode 100644
index 000000000..4ff8d1357
--- /dev/null
+++ b/httemplate/elements/tr-select-discount.html
@@ -0,0 +1,27 @@
+% if ( scalar(@{ $opt{'discount'} }) == 0 ) {
+
+ <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'discountnum' %>" VALUE="">
+
+% } else {
+
+ <TR>
+ <TD ALIGN="right"><% $opt{'label'} || '<B>Discount</B>' %></TD>
+ <TD>
+ <% include( '/elements/select-discount.html',
+ 'curr_value' => $discountnum,
+ %opt,
+ )
+ %>
+ </TD>
+ </TR>
+
+% }
+<%init>
+
+my %opt = @_;
+my $discountnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'discount'} ||= [ qsearch( 'discount', { disabled=>'' } ) ];
+
+</%init>
+
diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html
index a7571ca58..684f94e7c 100644
--- a/httemplate/misc/order_pkg.html
+++ b/httemplate/misc/order_pkg.html
@@ -60,6 +60,10 @@
});
</SCRIPT>
+% if ( $curuser->access_right('Discount customer package') ) {
+ <% include('/elements/tr-select-discount.html') %>
+% }
+
% if ( $conf->exists('pkg_referral') ) {
<% include('/elements/tr-select-part_referral.html',
'curr_value' => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
@@ -86,8 +90,10 @@
</HTML>
<%init>
+my $curuser = $FS::CurrentUser::CurrentUser;
+
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Order customer package');
+ unless $curuser->access_right('Order customer package');
my $conf = new FS::Conf;
diff --git a/httemplate/view/cust_main/packages/package.html b/httemplate/view/cust_main/packages/package.html
index 280a01682..33bcd2ad4 100644
--- a/httemplate/view/cust_main/packages/package.html
+++ b/httemplate/view/cust_main/packages/package.html
@@ -1,4 +1,4 @@
-<TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
+<TD CLASS="inv" BGCOLOR="<% $bgcolor %>" VALIGN="top">
<TABLE CLASS="inv" BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="100%">
<TR>
<TD COLSPAN=2>
diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html
index 6667a554d..40d6438f3 100644
--- a/httemplate/view/cust_main/packages/status.html
+++ b/httemplate/view/cust_main/packages/status.html
@@ -42,6 +42,8 @@
)
%>
+ <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
% unless ( $cust_pkg->get('setup') ) {
<% pkg_status_row_colspan( $cust_pkg, 'Never billed', '', 'colspan'=>$colspan, %opt ) %>
% } else {
@@ -70,10 +72,12 @@
%
% unless ( $cust_pkg->get('setup') ) { #not setup
%
-% unless ( $part_pkg->freq ) {
+% unless ( $part_pkg->freq ) {
<% pkg_status_row_colspan( $cust_pkg, 'Not&nbsp;yet&nbsp;billed&nbsp;(one-time&nbsp;charge)', '', 'colspan'=>$colspan, %opt ) %>
+ <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
<% pkg_status_row_if(
$cust_pkg,
( $part_pkg->freq ? 'Start billing' : 'Bill on' ),
@@ -94,7 +98,9 @@
% } else {
- <% pkg_status_row_colspan($cust_pkg, "Not&nbsp;yet&nbsp;billed&nbsp;($billed_or_prepaid&nbsp;". myfreq($part_pkg). ')', '', 'colspan'=>$colspan, %opt ) %>
+ <% pkg_status_row_colspan($cust_pkg, "Not&nbsp;yet&nbsp;billed&nbsp;($billed_or_prepaid&nbsp;". myfreq($part_pkg). ')', '', 'colspan'=>$colspan, %opt ) %>
+
+ <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
<% pkg_status_row_if($cust_pkg, 'Start billing', 'start_date', %opt) %>
@@ -108,6 +114,8 @@
<% pkg_status_row($cust_pkg, 'Billed', 'setup', %opt) %>
+ <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
% } else {
%
% if (scalar($cust_pkg->overlimit)) {
@@ -130,6 +138,8 @@
%>
% }
+ <% pkg_status_row_discount( $cust_pkg, %opt, 'colspan'=>$colspan ) %>
+
<% pkg_status_row($cust_pkg, 'Setup', 'setup', %opt) %>
% }
@@ -273,12 +283,37 @@ sub pkg_status_row_changed {
'size' => '-1',
'align' => 'right',
'colspan' => $opt{'colspan'},
+ #%opt,
);
}
$html;
}
+sub pkg_status_row_discount {
+ my( $cust_pkg, %opt ) = @_;
+
+ my $html;
+
+ foreach my $cust_pkg_discount ( $cust_pkg->cust_pkg_discount_active ) {
+
+ my $discount = $cust_pkg_discount->discount;
+
+ my $label = '<B>Discount</B>: '. $discount->description;
+ $label .= ' ('. ( $discount->months - $cust_pkg_discount->months_used ).
+ ' months remaining)'
+ if $discount->months;
+
+ $html .= pkg_status_row_colspan( $cust_pkg, $label, '',
+ 'colspan' => $opt{'colspan'},
+ #%opt,
+ );
+
+ }
+
+ $html;
+}
+
sub pkg_status_row_colspan {
my($cust_pkg, $title, $addl, %opt) = @_;