summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2010-01-30 07:38:32 +0000
committerivan <ivan>2010-01-30 07:38:32 +0000
commit0fcdc36642e1430f02ebf5326740e231883bd41f (patch)
treee5633883c65370134141202c40c616d35481d434 /httemplate
parent11b586f0fad8164514d272cee321e12bde6a49ef (diff)
discounts, RT#6679
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/discount.html28
-rw-r--r--httemplate/edit/discount.html137
-rw-r--r--httemplate/edit/elements/edit.html3
-rw-r--r--httemplate/edit/process/discount.html28
-rw-r--r--httemplate/elements/menu.html17
-rw-r--r--httemplate/elements/tr-input-text.html2
6 files changed, 209 insertions, 6 deletions
diff --git a/httemplate/browse/discount.html b/httemplate/browse/discount.html
new file mode 100644
index 000000000..f7ef0b30f
--- /dev/null
+++ b/httemplate/browse/discount.html
@@ -0,0 +1,28 @@
+<% include( 'elements/browse.html',
+ 'title' => 'Discounts',
+ 'name' => 'discounts',
+ 'menubar' => [ 'Add a new discount' =>
+ $p.'edit/discount.html',
+ ],
+ 'query' => { 'table' => 'discount', },
+ 'count_query' => 'SELECT COUNT(*) FROM discount',
+ 'disableable' => 1,
+ 'disabled_statuspos' => 2,
+ 'header' => [ '#', 'Name', 'Discount', ],
+ 'fields' => [ 'discountnum',
+ 'name',
+ 'description',
+ ],
+ 'links' => [ $link,
+ $link,
+ ],
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $link = [ "${p}edit/discount.html?", 'discountnum' ];
+
+</%init>
diff --git a/httemplate/edit/discount.html b/httemplate/edit/discount.html
new file mode 100644
index 000000000..24d8fa507
--- /dev/null
+++ b/httemplate/edit/discount.html
@@ -0,0 +1,137 @@
+<% include( 'elements/edit.html',
+ 'name' => 'Discount',
+ 'table' => 'discount',
+ 'fields' => [
+ 'name',
+ { field => 'disabled', type => 'checkbox', value=>'Y', },
+ { field => '_type', type => 'select',
+ options => \@_type_options,
+ onchange => '_type_changed',
+ },
+ { field => 'amount', type => 'money',
+ default => '0.00',
+ #cell_style => $amount_style,
+ },
+ { field => 'percent', type => 'percentage',
+ default => 0,
+ #cell_style => $percent_style,
+ },
+ { field => 'months', type => 'text', size => 2,
+ postfix => '<BR><FONT SIZE="-1"><I>(blank for non-expiring discount)</I></FONT>',
+ },
+ ],
+ 'labels' => {
+ 'discountnum' => 'Discount #',
+ 'name' => 'Name&nbsp;',
+ 'disabled' => 'Disabled&nbsp;',
+ '_type' => 'Type&nbsp;',
+ 'amount' => 'Amount&nbsp;',
+ 'percent' => 'Percentage&nbsp;',
+ 'months' => '# of Months',
+ },
+ 'viewall_dir' => 'browse',
+ 'new_callback' => $new_callback,
+ 'edit_callback' => $edit_callback,
+ 'error_callback' => $error_callback,
+ 'html_init' => $javascript,
+ 'body_etc' => 'onLoad="_type_changed(document.edit_topform._type)"',
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my @_type_options = ( 'Amount', 'Percentage' );
+
+#my $amount_style = '';
+#my $percent_style = '';
+
+#my $hide = 'display:none;visibility:hidden';
+my $select = 'Select discount type';
+
+my $new_callback = sub {
+ #my( $cgi, $object, $fields_listref, $opt_hashref ) = @_;
+
+ #$amount_style = $hide;
+ #$percent_style = $hide;
+ unshift @_type_options, $select;
+};
+
+my $edit_callback = sub {
+ #my( $cgi, $object, $fields_listref, $opt_hashref ) = @_;
+ my( $cgi, $object ) = @_;
+
+ if ( $object->amount > 0 && $object->percent == 0 ) {
+ $object->set('_type', 'Amount');
+ #$percent_style = $hide;
+ } elsif ( $object->amount == 0 && $object->percent > 0 ) {
+ $object->set('_type', 'Percentage');
+ #$amount_style = $hide;
+ } elsif ( $object->amount == 0 && $object->percent == 0 ) {
+ #$amount_style = $hide;
+ #$percent_style = $hide;
+ unshift @_type_options, $select;
+ } else {
+ die "discount.amount and discount.percent not yet handled by web UI";
+ }
+
+};
+
+my $error_callback = sub {
+ #my( $cgi, $object, $fields_listref, $opt_hashref ) = @_;
+ my( $cgi, $object ) = @_;
+
+ if ( $cgi->param('_type') eq 'Amount' ) {
+ $object->set('_type', 'Amount');
+ #A$percent_style = $hide;
+ } elsif ( $cgi->param('_type') eq 'Percentage' ) {
+ $object->set('_type', 'Percentage');
+ #$amount_style = $hide;
+ } else {
+ #$amount_style = $hide;
+ #$percent_style = $hide;
+ unshift @_type_options, $select;
+ }
+
+};
+
+my $javascript = <<END;
+ <SCRIPT TYPE="text/javascript">
+ function _type_changed(what) {
+ var _type = what.options[what.selectedIndex].value;
+
+ if ( _type == '$select' ) {
+ document.getElementById('amount_label').style.display = 'none';
+ document.getElementById('amount_label').style.visibility = 'hidden';
+ document.getElementById('amount_input0').style.display = 'none';
+ document.getElementById('amount_input0').style.visibility = 'hidden';
+ document.getElementById('percent_label').style.display = 'none';
+ document.getElementById('percent_label').style.visibility = 'hidden';
+ document.getElementById('percent_input0').style.display = 'none';
+ document.getElementById('percent_input0').style.visibility = 'hidden';
+ } else if ( _type == 'Amount' ) {
+ document.getElementById('amount_label').style.display = '';
+ document.getElementById('amount_label').style.visibility = '';
+ document.getElementById('amount_input0').style.display = '';
+ document.getElementById('amount_input0').style.visibility = '';
+ document.getElementById('percent_label').style.display = 'none';
+ document.getElementById('percent_label').style.visibility = 'hidden';
+ document.getElementById('percent_input0').style.display = 'none';
+ document.getElementById('percent_input0').style.visibility = 'hidden';
+ } else if ( _type == 'Percentage' ) {
+ document.getElementById('amount_label').style.display = 'none';
+ document.getElementById('amount_label').style.visibility = 'hidden';
+ document.getElementById('amount_input0').style.display = 'none';
+ document.getElementById('amount_input0').style.visibility = 'hidden';
+ document.getElementById('percent_label').style.display = '';
+ document.getElementById('percent_label').style.visibility = '';
+ document.getElementById('percent_input0').style.display = '';
+ document.getElementById('percent_input0').style.visibility = '';
+ }
+
+ }
+ </SCRIPT>
+END
+
+</%init>
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 4fe32c15d..3e8b6b8ed 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -250,6 +250,7 @@ Example:
% #text and derivitives
% 'size' => $f->{'size'},
% 'maxlength' => $f->{'maxlength'},
+% 'postfix' => $f->{'postfix'},
%
% #checkbox, title, fixed, hidden
% #& deprecated weird value hashref used only by reason.html
@@ -372,7 +373,7 @@ Example:
% $table = $f->{'m2name_table'};
% $col = $f->{'m2name_namecol'};
% } elsif ( $f->{'o2m_table'} ) {
-% $table = $f->{'o2m_table'};
+% $table = $f->{'o2m_tbekable'};
% $col = dbdef->table($f->{'o2m_table'})->primary_key;
% } elsif ( $f->{'m2m_method'} ) {
% $table = $f->{'m2m_method'};
diff --git a/httemplate/edit/process/discount.html b/httemplate/edit/process/discount.html
new file mode 100644
index 000000000..54307b708
--- /dev/null
+++ b/httemplate/edit/process/discount.html
@@ -0,0 +1,28 @@
+<% include( 'elements/process.html',
+ 'table' => 'discount',
+ 'viewall_dir' => 'browse',
+ 'precheck_callback' => $precheck_callback,
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $precheck_callback = sub {
+ my( $cgi ) = @_;
+
+ if ( $cgi->param('_type') eq 'Select discount type' ) {
+ return 'Please select a discount type';
+ } elsif ( $cgi->param('_type') eq 'Amount' ) {
+ $cgi->param('percent', '0');
+ return 'Amount must be greater than 0' unless $cgi->param('amount') > 0;
+ } elsif ( $cgi->param('_type') eq 'Percentage' ) {
+ $cgi->param('amount', '0.00');
+ return 'Percentage must be greater than 0' unless $cgi->param('percent') > 0;
+ }
+
+ '';
+};
+
+</%init>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 573741e21..5090abc73 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -347,18 +347,27 @@ if ( $curuser->access_right('Configuration') ) {
$config_export_svc{'Service definitions'} = [ $fsurl.'browse/part_svc.cgi', 'Services are items you offer to your customers' ];
}
+tie my %config_pkg_reason, 'Tie::IxHash',
+ 'Cancel reasons' => [ $fsurl.'browse/reason.html?class=C', 'Cancel reasons explain why a service was cancelled.' ],
+ 'Cancel reason types' => [ $fsurl.'browse/reason_type.html?class=C', 'Cancel reason types define groups of reasons.' ],
+ 'Suspend reasons' => [ $fsurl.'browse/reason.html?class=S', 'Suspend reasons explain why a service was suspended.' ],
+ 'Suspend reason types' => [ $fsurl.'browse/reason_type.html?class=S', 'Suspend reason types define groups of reasons.' ],
+;
+
tie my %config_pkg, 'Tie::IxHash', ();
$config_pkg{'Package definitions'} = [ $fsurl.'browse/part_pkg.cgi', 'One or more services are grouped together into a package and given pricing information. Customers purchase packages, not services' ]
if $curuser->access_right('Edit package definitions')
|| $curuser->access_right('Edit global package definitions');
if ( $curuser->access_right('Configuration') ) {
+
+ #package grouping sub-menu?
$config_pkg{'Package classes'} = [ $fsurl.'browse/pkg_class.html', 'Package classes define groups of packages, for taxation, ordering convenience and reporting.' ];
$config_pkg{'Package categories'} = [ $fsurl.'browse/pkg_category.html', 'Package categories define groups of package classes.' ];
$config_pkg{'Package report classes'} = [ $fsurl.'browse/part_pkg_report_option.html', 'Package classes define optional groups of packages for reporting only.' ];
- $config_pkg{'Cancel reasons'} = [ $fsurl.'browse/reason.html?class=C', 'Cancel reasons explain why a service was cancelled.' ];
- $config_pkg{'Cancel reason types'} = [ $fsurl.'browse/reason_type.html?class=C', 'Cancel reason types define groups of reasons.' ];
- $config_pkg{'Suspend reasons'} = [ $fsurl.'browse/reason.html?class=S', 'Suspend reasons explain why a service was suspended.' ];
- $config_pkg{'Suspend reason types'} = [ $fsurl.'browse/reason_type.html?class=S', 'Suspend reason types define groups of reasons.' ];
+ #eo package grouping sub-menu
+
+ $config_pkg{'Discounts'} = [ $fsurl.'browse/discount.html', '' ];
+ $config_pkg{'Cancel/Suspend Reasons'} = [ \%config_pkg_reason, '' ];
}
tie my %config_cust, 'Tie::IxHash',
diff --git a/httemplate/elements/tr-input-text.html b/httemplate/elements/tr-input-text.html
index 14f1425df..81efa1fe5 100644
--- a/httemplate/elements/tr-input-text.html
+++ b/httemplate/elements/tr-input-text.html
@@ -1,6 +1,6 @@
<% include('tr-td-label.html', @_ ) %>
- <TD <% $cell_style %>><% include('input-text.html', @_ ) %></TD>
+ <TD <% $cell_style %> ID="<% $opt{input_id} || $opt{id}.'_input0' %>"><% include('input-text.html', @_ ) %></TD>
</TR>