summaryrefslogtreecommitdiff
path: root/httemplate/misc
diff options
context:
space:
mode:
authorivan <ivan>2009-01-10 23:56:59 +0000
committerivan <ivan>2009-01-10 23:56:59 +0000
commit705f7d564546e7211844773f3566a89f0ae87a2c (patch)
treec9210d7215cce0870207f9865dd8e9c981f63037 /httemplate/misc
parenta661ced3f9f678a645780eaa0b183d2de5f100fa (diff)
implement package changes w/location change, RT#4499
Diffstat (limited to 'httemplate/misc')
-rwxr-xr-xhttemplate/misc/change_pkg.cgi66
1 files changed, 34 insertions, 32 deletions
diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi
index d6a24fb32..c4dfca200 100755
--- a/httemplate/misc/change_pkg.cgi
+++ b/httemplate/misc/change_pkg.cgi
@@ -2,35 +2,37 @@
<% include('/elements/error.html') %>
-<FORM ACTION="<% $p %>edit/process/cust_pkg.cgi" METHOD=POST>
-<INPUT TYPE="hidden" NAME="action" VALUE="change">
-<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
-<INPUT TYPE="hidden" NAME="remove_pkg" VALUE="<% $pkgnum %>">
+<FORM ACTION="<% $p %>edit/process/change-cust_pkg.html" METHOD=POST>
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
<% ntable('#cccccc') %>
<TR>
- <TD>Current package:&nbsp;</TD>
- <TD>
- <B><% $part_pkg->pkgpart %>: <% $part_pkg->pkg %> - <% $part_pkg->comment %></B>
+ <TH ALIGN="right">Current package</TH>
+ <TD COLSPAN=7>
+ <% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %>
</TD>
</TR>
<TR>
- <TD>New package: </TD>
- <TD><% include('/elements/select-cust-part_pkg.html',
- 'cust_main' => $cust_main,
- 'element_name' => 'new_pkgpart',
- 'extra_sql' => ' AND pkgpart != '. $cust_pkg->pkgpart,
- 'curr_value' => ( $cgi->param('error')
- ? scalar($cgi->param('new_pkgpart'))
- : ''
- ),
- )
- %>
+ <TH ALIGN="right">New package</TH>
+ <TD COLSPAN=7>
+ <% include('/elements/select-cust-part_pkg.html',
+ 'cust_main' => $cust_main,
+ 'element_name' => 'pkgpart',
+ #'extra_sql' => ' AND pkgpart != '. $cust_pkg->pkgpart,
+ 'curr_value' => scalar($cgi->param('pkgpart')),
+ )
+ %>
</TD>
</TR>
+ <% include('/elements/tr-select-cust_location.html',
+ 'cgi' => $cgi,
+ 'cust_main' => $cust_main,
+ )
+ %>
+
</TABLE>
<BR>
@@ -42,28 +44,28 @@
<%init>
+my $conf = new FS::Conf;
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Change customer package');
-
-my $pkgnum;
-if ( $cgi->param('error') ) {
- $pkgnum = ($cgi->param('remove_pkg'))[0];
-} else {
- $pkgnum = $cgi->param('pkgnum');
-}
+ unless $curuser->access_right('Change customer package');
+
+my $pkgnum = scalar($cgi->param('pkgnum'));
$pkgnum =~ /^(\d+)$/ or die "illegal pkgnum $pkgnum";
$pkgnum = $1;
-my $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } )
- or die "unknown pkgnum $pkgnum";
-my $custnum = $cust_pkg->custnum;
-
-my $conf = new FS::Conf;
+my $cust_pkg =
+ qsearchs({
+ 'table' => 'cust_pkg',
+ 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
+ 'hashref' => { 'pkgnum' => $pkgnum },
+ 'extra_sql' => ' AND '. $curuser->agentnums_sql,
+ }) or die "unknown pkgnum $pkgnum";
my $cust_main = $cust_pkg->cust_main
or die "can't get cust_main record for custnum ". $cust_pkg->custnum.
" ( pkgnum ". cust_pkg->pkgnum. ")";
-my $agent = $cust_main->agent;
my $part_pkg = $cust_pkg->part_pkg;