2 % $cgi->param('error', $error);
3 % $cgi->redirect(popurl(3). 'edit/cust_pkg_discount.html?'. $cgi->query_string );
6 <% header("Discount applied") %>
7 <SCRIPT TYPE="text/javascript">
8 window.top.location.reload();
16 my $curuser = $FS::CurrentUser::CurrentUser;
19 unless $curuser->access_right('Discount customer package');
21 #this search is really for security wrt agent virt...
22 #maybe move it to the cust_pkg_discount->insert call?
23 my $cust_pkg = qsearchs({
24 #'select' => 'cust_pkg.*',
25 'table' => 'cust_pkg',
26 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
27 'hashref' => { 'pkgnum' => scalar($cgi->param('pkgnum')), },
28 'extra_sql' => ' AND '. $curuser->agentnums_sql,
30 die 'unknown pkgnum' unless $cust_pkg;
32 #XXX something not unlike this for custom discounts
33 #if ( $cgi->param('locationnum') == -1 ) {
34 # my $cust_location = new FS::cust_location {
35 # 'custnum' => $cust_pkg->custnum,
36 # map { $_ => scalar($cgi->param($_)) }
37 # qw( address1 address2 city county state zip country )
39 # $change{'cust_location'} = $cust_location;
42 my $cust_pkg_discount = new FS::cust_pkg_discount {
43 'pkgnum' => $cust_pkg->pkgnum,
44 'discountnum' => scalar($cgi->param('discountnum')),
46 'end_date' => '', #XXX
47 'otaker' => $curuser->username,
49 my $error = $cust_pkg_discount->insert;