From f424f11eb366fe64f5f7bb42b21745e22537cab1 Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 14 Dec 2010 07:29:13 +0000 Subject: cust_location editing features, RT#10766 --- httemplate/edit/cust_location.cgi | 54 +++++++++++++++++++++++++++++++ httemplate/edit/process/cust_location.cgi | 38 ++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100755 httemplate/edit/cust_location.cgi create mode 100644 httemplate/edit/process/cust_location.cgi (limited to 'httemplate/edit') diff --git a/httemplate/edit/cust_location.cgi b/httemplate/edit/cust_location.cgi new file mode 100755 index 000000000..80b27c2b3 --- /dev/null +++ b/httemplate/edit/cust_location.cgi @@ -0,0 +1,54 @@ +<% include('/elements/header-popup.html', "Edit Location") %> + +<% include('/elements/error.html') %> + +
+ + +<% ntable('#cccccc') %> +<% include('/elements/location.html', + 'object' => $cust_location, + 'no_asterisks' => 1, + ) %> + + +
+ + + +
+ + + +<%init> + +my $conf = new FS::Conf; + +my $curuser = $FS::CurrentUser::CurrentUser; + +# it's the same access right you'd need to do this by editing packages +die "access denied" + unless $curuser->access_right('Change customer package'); + +my $locationnum = scalar($cgi->param('locationnum')); +my $cust_location = qsearchs({ + 'select' => 'cust_location.*', + 'table' => 'cust_location', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', + 'hashref' => { 'locationnum' => $locationnum }, + 'extra_sql' => ' AND '. $curuser->agentnums_sql, + }) or die "unknown locationnum $locationnum"; + +die "can't edit disabled locationnum $locationnum" if $cust_location->disabled; + +my $cust_main = qsearchs('cust_main', { 'custnum' => $cust_location->custnum }) + or die "can't get cust_main record for custnum ". $cust_location->custnum; + +my @cust_pkgs = qsearch('cust_pkg', { 'locationnum' => $locationnum }); + + diff --git a/httemplate/edit/process/cust_location.cgi b/httemplate/edit/process/cust_location.cgi new file mode 100644 index 000000000..790fc8ea4 --- /dev/null +++ b/httemplate/edit/process/cust_location.cgi @@ -0,0 +1,38 @@ +% if ($error) { +% $cgi->param('error', Dumper($error)); +% $cgi->redirect(popurl(3). 'edit/cust_location.cgi?'. $cgi->query_string ); +% } else { + + <% header("Location changed") %> + + + + +% } +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Change customer package'); + +my $locationnum = $cgi->param('locationnum'); +my $cust_location = qsearchs({ + 'select' => 'cust_location.*', + 'table' => 'cust_location', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', + 'hashref' => { 'locationnum' => $locationnum }, + 'extra_sql' => ' AND '. $curuser->agentnums_sql, +}); +die "unknown locationnum $locationnum" unless $cust_location; + +my $new = { + map { $_ => scalar($cgi->param($_)) } + qw( address1 address2 city county state zip country ) +}; + +my $error = $cust_location->move_to($new); + + -- cgit v1.2.1