From 6fc8a42e503e4e1f12659e1cfef7f5f26577034f Mon Sep 17 00:00:00 2001 From: mark Date: Wed, 29 Dec 2010 22:56:47 +0000 Subject: cust_location editing features, RT#10766 --- httemplate/edit/cust_location.cgi | 54 +++++++++++++ httemplate/edit/process/cust_location.cgi | 38 ++++++++++ httemplate/elements/tr-select-cust_location.html | 1 + httemplate/misc/disable-cust_location.cgi | 35 +++++++++ httemplate/view/cust_main/packages.html | 96 +++++------------------- httemplate/view/cust_main/packages/location.html | 13 ++++ httemplate/view/cust_main/packages/section.html | 95 +++++++++++++++++++++++ 7 files changed, 255 insertions(+), 77 deletions(-) create mode 100755 httemplate/edit/cust_location.cgi create mode 100644 httemplate/edit/process/cust_location.cgi create mode 100755 httemplate/misc/disable-cust_location.cgi create mode 100755 httemplate/view/cust_main/packages/section.html (limited to 'httemplate') 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); + + diff --git a/httemplate/elements/tr-select-cust_location.html b/httemplate/elements/tr-select-cust_location.html index f2b267a8b..6de034669 100644 --- a/httemplate/elements/tr-select-cust_location.html +++ b/httemplate/elements/tr-select-cust_location.html @@ -151,6 +151,7 @@ Example: % push @locations, $cust_location % if !$cust_main && $cust_location && $cust_location->locationnum>0; % foreach my $loc ( sort $location_sort @locations ) { +% next if $loc->disabled;