summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-12-10 20:59:42 -0800
committerIvan Kohler <ivan@freeside.biz>2013-12-10 20:59:42 -0800
commit430b2c784d2ee9ea5be00b821d2dbd27279ef132 (patch)
treec8a224219c1425bd3fa03b1a54487bf1f3de7449 /httemplate
parent6ced51db0e73603461591e54b7f606467e7c7af0 (diff)
parente1157f37c618a7b9cdb2793d61999458076dc51b (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Conflicts: FS/FS/Mason.pm FS/MANIFEST
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/addr_range.html66
-rw-r--r--httemplate/edit/addr_range.html27
-rw-r--r--httemplate/edit/cust_main/billing.html4
-rw-r--r--httemplate/edit/elements/edit.html21
-rw-r--r--httemplate/edit/process/addr_range.html22
-rw-r--r--httemplate/elements/menu.html4
-rw-r--r--httemplate/misc/delete-addr_range.html21
7 files changed, 163 insertions, 2 deletions
diff --git a/httemplate/browse/addr_range.html b/httemplate/browse/addr_range.html
new file mode 100644
index 000000000..d657f32ec
--- /dev/null
+++ b/httemplate/browse/addr_range.html
@@ -0,0 +1,66 @@
+<& elements/browse.html,
+ 'title' => 'Address Ranges',
+ 'name_singular' => 'address range',
+ 'html_init' => $html_init,
+ 'html_foot' => $html_foot,
+ 'query' => { 'table' => 'addr_range',
+ 'order_by' => $order_by,
+ },
+ 'count_query' => "SELECT count(*) from addr_range",
+ 'header' => [ 'From',
+ '', # the dash
+ 'To',
+ 'Status',
+ # would be nice to show whether any addresses in the
+ # range are assigned, but that's ugly
+ ],
+ 'fields' => [ 'start',
+ sub { '&ndash;' },
+ 'end',
+ 'desc',
+ ],
+ 'links' => [
+ [ '#' ],
+ '',
+ [ '#' ],
+ ],
+ 'link_onclicks' => [ $edit_link,
+ '',
+ $edit_link,
+ '',
+ ],
+&>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration');
+# addr_ranges are ALWAYS global, else there will be chaos
+
+my $order_by = "ORDER BY inet(start)"; # Pg-ism
+# though we could also make the field itself inet-type...
+# this would simplify a lot of things.
+
+my $html_init = include('/elements/error.html');
+
+my $edit_link = sub {
+ my $addr_range = shift;
+ include('/elements/popup_link_onclick.html',
+ action => $p.'edit/addr_range.html?rangenum='.
+ $addr_range->rangenum,
+ actionlabel => 'Edit address range',
+ width => 650,
+ height => 420,
+ );
+};
+
+my $add_link = include('/elements/popup_link_onclick.html',
+ action => $p.'edit/addr_range.html',
+ actionlabel => 'Edit address range',
+ width => 650,
+ height => 420,
+);
+
+my $html_foot = qq!<A HREF="#" onclick="$add_link">
+<I>Add a new address range</I></A>!;
+
+</%init>
diff --git a/httemplate/edit/addr_range.html b/httemplate/edit/addr_range.html
new file mode 100644
index 000000000..68efa5d79
--- /dev/null
+++ b/httemplate/edit/addr_range.html
@@ -0,0 +1,27 @@
+<& elements/edit.html,
+ 'name_singular' => 'address range',
+ 'popup' => 1,
+ 'table' => 'addr_range',
+ 'labels' => { 'start' => 'From',
+ 'end' => 'To',
+ 'status' => 'Status',
+ 'rangenum'=> 'Range',
+ },
+ 'fields' => [ 'start',
+ 'end',
+ { field => 'status',
+ type => 'select',
+ labels => \%FS::addr_range::status_desc,
+ options => [ sort { $a cmp $b }
+ keys(%FS::addr_range::status_desc) ],
+ disable_empty => 1,
+ },
+ ],
+ 'delete_url' => $p.'misc/delete-addr_range.html',
+&>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration');
+
+</%init>
diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html
index da5f0f27f..1088cf5fd 100644
--- a/httemplate/edit/cust_main/billing.html
+++ b/httemplate/edit/cust_main/billing.html
@@ -679,8 +679,8 @@ my $conf = new FS::Conf;
my $payby_default = $conf->config('payby-default');
my @payby = grep /\w/, $conf->config('payby');
-#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP ))
-@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP ))
+#@payby = (qw( CARD DCRD CHEK DCHK BILL CASH WEST COMP ))
+@payby = (qw( CARD DCRD CHEK DCHK BILL CASH COMP ))
unless @payby;
my $show_term = '';
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 9e27f2a4c..16d0817eb 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -108,6 +108,9 @@ Example:
# overrides default popurl(1)."process/$table.html"
'post_url' => popurl(1).'process/something',
+ # optional link to delete this object; primary key will be appended
+ 'delete_url' => $p.'misc/delete-something.html?',
+
#we're in a popup (no title/menu/searchboxes)
'popup' => 1,
@@ -211,6 +214,7 @@ Example:
% );
% }
+
<% include('/elements/header'. ( $opt{popup} ? '-popup' : '' ). '.html',
$title,
include( '/elements/menubar.html', @menubar ),
@@ -773,6 +777,23 @@ Example:
: "Add ". ($opt{'name'} || $opt{'name_singular'})
%>"
>
+% if ( $opt{'delete_url'} and $object->get($pkey) ) {
+% my $delete_msg = 'Delete this '.
+% ($opt{'name_singular'} || $opt{'name'});
+% my $delete_url = $opt{'delete_url'};
+% $delete_url .= '?' unless $delete_url =~ /\?/;
+% $delete_url .= $object->get($pkey);
+ <SCRIPT TYPE="text/javascript">
+ function confirm_delete() {
+ if(confirm(<% $delete_msg . '?' |js_string %>)) {
+ window.location.href = <% $delete_url |js_string %>;
+ }
+ }
+ </SCRIPT>
+ <INPUT TYPE = "button"
+ VALUE = "<% $delete_msg |h %>"
+ onclick = "confirm_delete()">
+% }
% }
</FORM>
diff --git a/httemplate/edit/process/addr_range.html b/httemplate/edit/process/addr_range.html
new file mode 100644
index 000000000..6b05d23a5
--- /dev/null
+++ b/httemplate/edit/process/addr_range.html
@@ -0,0 +1,22 @@
+<& elements/process.html,
+ 'table' => 'addr_range',
+ 'popup_reload' => 'Address range changed',
+ 'precheck_callback' => sub {
+ my ($cgi) = @_;
+ my $start = NetAddr::IP->new($cgi->param('start'), 0)
+ or return 'Illegal or empty (IP address) start: '.$cgi->param('start');
+ if ( length($cgi->param('end')) ) {
+ my $end = NetAddr::IP->new($cgi->param('end'), 0)
+ or return 'Illegal or empty (IP address) end: '.$cgi->param('end');
+ if ( $end < $start ) {
+ ($start, $end) = ($end, $start);
+ $cgi->param('end', $end->addr);
+ $cgi->param('start', $start->addr);
+ }
+ $cgi->param('length', $end - $start + 1);
+ } else {
+ $cgi->param('length', 1);
+ }
+ '';
+ },
+&>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index b4fff2285..2ae216c5c 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -508,6 +508,10 @@ tie my %config_broadband, 'Tie::IxHash',
'Routers' => [ $fsurl.'browse/router.cgi', 'Broadband access routers' ],
'Address blocks' => [ $fsurl.'browse/addr_block.cgi', 'Manage address blocks and block assignments to broadband routers' ],
;
+if ( $curuser->access_right('Broadband global configuration') ) {
+ $config_broadband{'Address ranges'} =
+ [ $fsurl.'browse/addr_range.html', 'Designate special address ranges' ];
+}
tie my %config_phone, 'Tie::IxHash',
'View/Edit phone device types' => [ $fsurl.'browse/part_device.html', 'Phone device types' ],
diff --git a/httemplate/misc/delete-addr_range.html b/httemplate/misc/delete-addr_range.html
new file mode 100644
index 000000000..c6310e9b1
--- /dev/null
+++ b/httemplate/misc/delete-addr_range.html
@@ -0,0 +1,21 @@
+% if ( $error ) {
+<& /elements/errorpage-popup.html, $error &>
+% } else {
+<& /elements/header-popup.html, "Address range deleted" &>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+</BODY>
+</HTML>
+% }
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Broadband global configuration');
+
+my ($rangenum) = $cgi->keywords;
+$rangenum =~ /^\d+$/ or die "bad rangenum '$rangenum'";
+my $addr_range = FS::addr_range->by_key($rangenum);
+die "unknown rangenum $rangenum" unless $addr_range;
+my $error = $addr_range->delete;
+</%init>