summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authormark <mark>2010-12-14 07:29:13 +0000
committermark <mark>2010-12-14 07:29:13 +0000
commitf424f11eb366fe64f5f7bb42b21745e22537cab1 (patch)
tree753152c3f27fb84ef5757fb59d0567ff0eabae2b /httemplate/edit
parent93f811c014058da26e734fc621028741b156c5d7 (diff)
cust_location editing features, RT#10766
Diffstat (limited to 'httemplate/edit')
-rwxr-xr-xhttemplate/edit/cust_location.cgi54
-rw-r--r--httemplate/edit/process/cust_location.cgi38
2 files changed, 92 insertions, 0 deletions
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') %>
+
+<FORM NAME="EditLocationForm"
+ACTION="<% $p %>edit/process/cust_location.cgi" METHOD=POST>
+<INPUT TYPE="hidden" NAME="locationnum" VALUE="<% $locationnum %>">
+
+<% ntable('#cccccc') %>
+<% include('/elements/location.html',
+ 'object' => $cust_location,
+ 'no_asterisks' => 1,
+ ) %>
+</TABLE>
+
+<BR>
+<SCRIPT TYPE="text/javascript">
+function areyousure() {
+ return confirm('Modify this service location?');
+}
+</SCRIPT>
+<INPUT TYPE="submit" VALUE="Submit" onclick="return areyousure()">
+
+</FORM>
+</BODY>
+</HTML>
+
+<%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 });
+
+</%init>
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") %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+ </BODY>
+ </HTML>
+
+% }
+<%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);
+
+</%init>