diff options
Diffstat (limited to 'httemplate/edit/process')
-rwxr-xr-x | httemplate/edit/process/REAL_cust_pkg.cgi | 11 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_main.cgi | 152 | ||||
-rw-r--r-- | httemplate/edit/process/cust_main_attach.cgi | 99 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_main_county-collapse.cgi | 67 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_pay.cgi | 6 | ||||
-rw-r--r-- | httemplate/edit/process/cust_tax_adjustment.html | 41 | ||||
-rwxr-xr-x | httemplate/edit/process/domreg.cgi | 62 | ||||
-rw-r--r-- | httemplate/edit/process/elements/ApplicationCommon.html | 2 | ||||
-rw-r--r-- | httemplate/edit/process/part_device.html | 11 | ||||
-rw-r--r-- | httemplate/edit/process/part_export.cgi | 3 | ||||
-rwxr-xr-x | httemplate/edit/process/part_pkg.cgi | 44 | ||||
-rw-r--r-- | httemplate/edit/process/part_pkg_report_option.html | 11 | ||||
-rw-r--r-- | httemplate/edit/process/part_pkg_taxclass.html | 58 | ||||
-rw-r--r-- | httemplate/edit/process/payment_gateway.html | 39 | ||||
-rw-r--r-- | httemplate/edit/process/phone_device.html | 18 | ||||
-rw-r--r-- | httemplate/edit/process/quick-charge.cgi | 8 | ||||
-rw-r--r-- | httemplate/edit/process/quick-cust_pkg.cgi | 13 | ||||
-rwxr-xr-x | httemplate/edit/process/svc_domain.cgi | 4 |
18 files changed, 467 insertions, 182 deletions
diff --git a/httemplate/edit/process/REAL_cust_pkg.cgi b/httemplate/edit/process/REAL_cust_pkg.cgi index ebcb7e4..d4ba976 100755 --- a/httemplate/edit/process/REAL_cust_pkg.cgi +++ b/httemplate/edit/process/REAL_cust_pkg.cgi @@ -3,16 +3,23 @@ <% $cgi->redirect(popurl(2). "REAL_cust_pkg.cgi?". $cgi->query_string ) %> %} else { % my $custnum = $new->custnum; -<% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum#cust_pkg$pkgnum" ) %> +% my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/ +% ? '' +% : ';show=packages'; +% my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment +<% $cgi->redirect(popurl(3). "view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag" ) %> %} <%init> +my $curuser = $FS::CurrentUser::CurrentUser; + die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates'); + unless $curuser->access_right('Edit customer package dates'); my $pkgnum = $cgi->param('pkgnum') or die; my $old = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum}); my %hash = $old->hash; +$hash{'start_date'} = $cgi->param('start_date') ? str2time($cgi->param('start_date')) : ''; $hash{'setup'} = $cgi->param('setup') ? str2time($cgi->param('setup')) : ''; $hash{'bill'} = $cgi->param('bill') ? str2time($cgi->param('bill')) : ''; $hash{'last_bill'} = diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 097d382..f72ca0a 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -19,6 +19,8 @@ my $DEBUG = 0; die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Edit customer'); +my $conf = new FS::Conf; + my $error = ''; #unmunge stuff @@ -27,8 +29,7 @@ $cgi->param('tax','') unless defined $cgi->param('tax'); $cgi->param('refnum', (split(/:/, ($cgi->param('refnum'))[0] ))[0] ); -#my $payby = $cgi->param('payby'); -my $payby = $cgi->param('select'); # XXX key +my $payby = $cgi->param('payby'); my %noauto = ( 'CARD' => 'DCRD', @@ -72,55 +73,83 @@ if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) { ); } -if ( $cgi->param('birthdate') && $cgi->param('birthdate') =~ /^([ 0-9\-\/]{0,10})$/) { - my $conf = new FS::Conf; - my $format = $conf->config('date_format') || "%m/%d/%Y"; - my $parser = DateTime::Format::Strptime->new(pattern => $format, - time_zone => 'floating', - ); - my $dt = $parser->parse_datetime($1); - if ($dt) { - $new->setfield('birthdate', $dt->epoch); - $cgi->param('birthdate', $dt->epoch); - } else { -# $error ||= $cgi->param('birthdate') . " is an invalid birthdate:" . $parser->errmsg; - $error ||= "Invalid birthdate: " . $cgi->param('birthdate') . "."; - $cgi->param('birthdate', ''); +my %usedatetime = ( 'birthdate' => 1 ); + +foreach my $dfield (qw( birthdate signupdate )) { + + if ( $cgi->param($dfield) && $cgi->param($dfield) =~ /^([ 0-9\-\/]{0,10})$/) { + + my $value = $1; + my $parsed = ''; + + if ( exists $usedatetime{$dfield} && $usedatetime{$dfield} ) { + + my $format = $conf->config('date_format') || "%m/%d/%Y"; + my $parser = DateTime::Format::Strptime->new( pattern => $format, + time_zone => 'floating', + ); + my $dt = $parser->parse_datetime($value); + if ( $dt ) { + $parsed = $dt->epoch; + } else { + # $error ||= $cgi->param('birthdate') . " is an invalid birthdate:" . $parser->errmsg; + $error ||= "Invalid $dfield: $value"; + } + + } else { + + $parsed = str2time($value) + or $error ||= "Invalid $dfield: $value"; + + } + + $new->setfield( $dfield, $parsed ); + $cgi->param( $dfield, $parsed ); + } + } $new->setfield('paid', $cgi->param('paid') ) if $cgi->param('paid'); +my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups'); +my @tax_exempt = grep { $cgi->param("tax_$_") eq 'Y' } @exempt_groups; + #perhaps this stuff should go to cust_main.pm -my $cust_pkg = ''; -my $svc_acct = ''; if ( $new->custnum eq '' ) { + my $cust_pkg = ''; + my $svc; + if ( $cgi->param('pkgpart_svcpart') ) { + my $x = $cgi->param('pkgpart_svcpart'); $x =~ /^(\d+)_(\d+)$/ or die "illegal pkgpart_svcpart $x\n"; my($pkgpart, $svcpart) = ($1, $2); + my $part_pkg = qsearchs('part_pkg', { 'pkgpart' => $pkgpart } ); #false laziness: copied from FS::cust_pkg::order (which should become a #FS::cust_main method) my(%part_pkg); # generate %part_pkg # $part_pkg{$pkgpart} is true iff $custnum may purchase $pkgpart my $agent = qsearchs('agent',{'agentnum'=> $new->agentnum }); - #my($type_pkgs); - #foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) { - # my($pkgpart)=$type_pkgs->pkgpart; - # $part_pkg{$pkgpart}++; - #} - # $pkgpart_href->{PKGPART} is true iff $custnum may purchase $pkgpart - my $pkgpart_href = $agent->pkgpart_hashref; - #eslaf - - # this should wind up in FS::cust_pkg! - $error ||= "Agent ". $new->agentnum. " (type ". $agent->typenum. ") can't ". - "purchase pkgpart ". $pkgpart - #unless $part_pkg{ $pkgpart }; - unless $pkgpart_href->{ $pkgpart }; + + if ( $agent ) { + # $pkgpart_href->{PKGPART} is true iff $custnum may purchase $pkgpart + my $pkgpart_href = $agent->pkgpart_hashref + if $agent; + #eslaf + + # this should wind up in FS::cust_pkg! + $error ||= "Agent ". $new->agentnum. " (type ". $agent->typenum. + ") can't purchase pkgpart ". $pkgpart + #unless $part_pkg{ $pkgpart }; + unless $pkgpart_href->{ $pkgpart } + || $agent->agentnum == $part_pkg->agentnum; + } else { + $error = 'Select agent'; + } $cust_pkg = new FS::cust_pkg ( { #later 'custnum' => $custnum, @@ -132,33 +161,52 @@ if ( $new->custnum eq '' ) { #$error ||= $cust_svc->check; - my %svc_acct = ( - 'svcpart' => $svcpart, - 'username' => $cgi->param('username'), - '_password' => $cgi->param('_password'), - 'popnum' => $cgi->param('popnum'), - ); - $svc_acct{'domsvc'} = $cgi->param('domsvc') - if $cgi->param('domsvc'); + my $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } ); + my $svcdb = $part_svc->svcdb; + + if ( $svcdb eq 'svc_acct' ) { + + my %svc_acct = ( + 'svcpart' => $svcpart, + 'username' => scalar($cgi->param('username')), + '_password' => scalar($cgi->param('_password')), + 'popnum' => scalar($cgi->param('popnum')), + ); + $svc_acct{'domsvc'} = $cgi->param('domsvc') + if $cgi->param('domsvc'); + + $svc = new FS::svc_acct \%svc_acct; + + #and just in case you were silly + $svc->svcpart($svcpart); + $svc->username($cgi->param('username')); + $svc->_password($cgi->param('_password')); + $svc->popnum($cgi->param('popnum')); + + } elsif ( $svcdb eq 'svc_phone' ) { + + my %svc_phone = ( + 'svcpart' => $svcpart, + map { $_ => scalar($cgi->param($_)) } + qw( countrycode phonenum sip_password pin phone_name ) + ); - $svc_acct = new FS::svc_acct \%svc_acct; + $svc = new FS::svc_phone \%svc_phone; - #and just in case you were silly - $svc_acct->svcpart($svcpart); - $svc_acct->username($cgi->param('username')); - $svc_acct->_password($cgi->param('_password')); - $svc_acct->popnum($cgi->param('popnum')); + } else { + die "$svcdb not handled on new customer yet"; + } #$error ||= $svc_acct->check; - } elsif ( $cgi->param('username') ) { #good thing to catch - $error = "Can't assign username without a package!"; } use Tie::RefHash; tie my %hash, 'Tie::RefHash'; - %hash = ( $cust_pkg => [ $svc_acct ] ) if $cust_pkg; - $error ||= $new->insert( \%hash, \@invoicing_list ); + %hash = ( $cust_pkg => [ $svc ] ) if $cust_pkg; + $error ||= $new->insert( \%hash, \@invoicing_list, + 'tax_exemption' => \@tax_exempt, + ); my $conf = new FS::Conf; if ( $conf->exists('backend-realtime') && ! $error ) { @@ -201,7 +249,9 @@ if ( $new->custnum eq '' ) { local($FS::cust_main::DEBUG) = $DEBUG if $DEBUG; local($FS::Record::DEBUG) = $DEBUG if $DEBUG; - $error ||= $new->replace($old, \@invoicing_list); + $error ||= $new->replace( $old, \@invoicing_list, + 'tax_exemption' => \@tax_exempt, + ); warn "$me returned from replace" if $DEBUG; diff --git a/httemplate/edit/process/cust_main_attach.cgi b/httemplate/edit/process/cust_main_attach.cgi new file mode 100644 index 0000000..98f4d09 --- /dev/null +++ b/httemplate/edit/process/cust_main_attach.cgi @@ -0,0 +1,99 @@ +%if ($error) { +% $cgi->param('error', $error); +<% $cgi->redirect(popurl(2). 'cust_main_attach.cgi?'. $cgi->query_string ) %> +%} else { +% my $act = 'added'; +% $act = 'updated' if ($attachnum); +% $act = 'purged' if($attachnum and $purge); +% $act = 'undeleted' if($attachnum and $undelete); +% $act = 'deleted' if($attachnum and $delete); +<% header('Attachment ' . $act ) %> + <SCRIPT TYPE="text/javascript"> + window.top.location.reload(); + </SCRIPT> + </BODY></HTML> +% } +<%init> + +my $error; +$cgi->param('custnum') =~ /^(\d+)$/ + or die "Illegal custnum: ". $cgi->param('custnum'); +my $custnum = $1; + +$cgi->param('attachnum') =~ /^(\d*)$/ + or die "Illegal attachnum: ". $cgi->param('attachnum'); +my $attachnum = $1; + +my $curuser = $FS::CurrentUser::CurrentUser; +my $otaker = $curuser->name; +$otaker = $curuser->username if ($otaker eq "User, Legacy"); + +my $delete = $cgi->param('delete'); +my $undelete = $cgi->param('undelete'); +my $purge = $cgi->param('purge'); + +my $new = new FS::cust_attachment ( { + attachnum => $attachnum, + custnum => $custnum, + _date => time, + otaker => $otaker, + disabled => '', +}); +my $old; + +if($attachnum) { + $old = qsearchs('cust_attachment', { attachnum => $attachnum }); + if(!$old) { + $error = "Attachnum '$attachnum' not found"; + } + elsif($purge) { # do nothing + } + else { + map { $new->$_($old->$_) } + ('_date', 'otaker', 'body', 'disabled'); + $new->filename($cgi->param('filename') || $old->filename); + $new->mime_type($cgi->param('mime_type') || $old->mime_type); + if($delete and not $old->disabled) { + $new->disabled(time); + } + if($undelete and $old->disabled) { + $new->disabled(''); + } + } +} +else { # This is a new attachment, so require a file. + + my $filename = $cgi->param('file'); + if($filename) { + $new->filename($filename); + $new->mime_type($cgi->uploadInfo($filename)->{'Content-Type'}); + + local $/; + my $fh = $cgi->upload('file'); + $new->body(<$fh>); + } + else { + $error = 'No file uploaded'; + } +} +my $action = 'Add'; +$action = 'Edit' if $attachnum; +$action = 'Delete' if $attachnum and $delete; +$action = 'Undelete' if $attachnum and $undelete; +$action = 'Purge' if $attachnum and $purge; + +$error = 'access denied' unless $curuser->access_right($action . ' attachment'); + +if(!$error) { + if($old and $old->disabled and $purge) { + $error = $old->delete; + } + elsif($old) { + $error = $new->replace($old); + } + else { + $error = $new->insert; + } +} + +</%init> diff --git a/httemplate/edit/process/cust_main_county-collapse.cgi b/httemplate/edit/process/cust_main_county-collapse.cgi index a917825..18bd1fd 100755 --- a/httemplate/edit/process/cust_main_county-collapse.cgi +++ b/httemplate/edit/process/cust_main_county-collapse.cgi @@ -1,44 +1,37 @@ -% -% -%my($query) = $cgi->keywords; -%$query =~ /^(\d+)$/ or die "Illegal taxnum!"; -%my $taxnum = $1; -%my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } ) -% or die "Unknown taxnum $taxnum"; -% -%#really should do this in a .pm & start transaction -% -%foreach my $delete ( qsearch('cust_main_county', { -% 'country' => $cust_main_county->country, -% 'state' => $cust_main_county->state -% } ) ) { -%# unless ( qsearch('cust_main',{ -%# 'state' => $cust_main_county->getfield('state'), -%# 'county' => $cust_main_county->getfield('county'), -%# 'country' => $cust_main_county->getfield('country'), -%# } ) ) { -% my $error = $delete->delete; -% die $error if $error; -%# } else { -% #should really fix the $cust_main record -%# } -% -%} -% -%$cust_main_county->taxnum(''); -%$cust_main_county->county(''); -%my $error = $cust_main_county->insert; -%die $error if $error; -% -%print $cgi->redirect(popurl(3). "browse/cust_main_county.cgi"); -% -% +<% $cgi->redirect(popurl(3). "browse/cust_main_county.cgi") %> <%init> -#this isn't actually linked from anywhere just now, but it will be again soon - die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/ or die "Illegal taxnum!"; +my $taxnum = $1; +my $cust_main_county = qsearchs('cust_main_county', { 'taxnum' => $taxnum } ) + or die "Unknown taxnum $taxnum"; + +#really should do this in a .pm & start transaction + +foreach my $delete ( qsearch('cust_main_county', { + 'country' => $cust_main_county->country, + 'state' => $cust_main_county->state + } ) ) { +# unless ( qsearch('cust_main',{ +# 'state' => $cust_main_county->getfield('state'), +# 'county' => $cust_main_county->getfield('county'), +# 'country' => $cust_main_county->getfield('country'), +# } ) ) { + my $error = $delete->delete; + die $error if $error; +# } else { + #should really fix the $cust_main record +# } + +} + +$cust_main_county->taxnum(''); +$cust_main_county->county(''); +my $error = $cust_main_county->insert; +die $error if $error; </%init> diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi index 647f6fc..a310c53 100755 --- a/httemplate/edit/process/cust_pay.cgi +++ b/httemplate/edit/process/cust_pay.cgi @@ -7,7 +7,7 @@ % if ( $cgi->param('apply') eq 'yes' ) { % my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum }) % or die "unknown custnum $linknum"; -% $cust_main->apply_payments; +% $cust_main->apply_payments( 'manual' => 1 ); % } % if ( $link eq 'popup' ) { % @@ -46,7 +46,9 @@ my $new = new FS::cust_pay ( { _date => $_date, map { $_, scalar($cgi->param($_)); - } qw(paid payby payinfo paybatch) + } qw( paid payby payinfo paybatch + pkgnum + ) #} fields('cust_pay') } ); diff --git a/httemplate/edit/process/cust_tax_adjustment.html b/httemplate/edit/process/cust_tax_adjustment.html new file mode 100644 index 0000000..204b5b9 --- /dev/null +++ b/httemplate/edit/process/cust_tax_adjustment.html @@ -0,0 +1,41 @@ +% if ( $error ) { +% $cgi->param('error', $error ); +<% $cgi->redirect($p.'cust_tax_adjustment.html?'. $cgi->query_string) %> +% } else { +<% header("Tax adjustment added") %> + <SCRIPT TYPE="text/javascript"> + //window.top.location.reload(); + parent.cClick(); + </SCRIPT> + </BODY></HTML> +% } +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Add customer tax adjustment'); + +my $error = ''; +my $conf = new FS::conf; +my $param = $cgi->Vars; + +$param->{"custnum"} =~ /^(\d+)$/ + or $error .= "Illegal customer number " . $param->{"custnum"} . " "; +my $custnum = $1; + +$param->{"amount"} =~ /^\s*(\d*(?:\.?\d{1,2}))\s*$/ + or $error .= "Illegal amount " . $param->{"amount"} . " "; +my $amount = $1; + +unless ( $error ) { + + my $cust_tax_adjustment = new FS::cust_tax_adjustment { + 'custnum' => $custnum, + 'taxname' => $param->{'taxname'}, + 'amount' => $amount, + 'comment' => $param->{'comment'}, + }; + $error = $cust_tax_adjustment->insert; + +} + +</%init> diff --git a/httemplate/edit/process/domreg.cgi b/httemplate/edit/process/domreg.cgi new file mode 100755 index 0000000..a95474e --- /dev/null +++ b/httemplate/edit/process/domreg.cgi @@ -0,0 +1,62 @@ +%if ($error) { +% $cgi->param('error', $error); +% errorpage($error); +%} else { +<% $cgi->redirect(popurl(3). "view/svc_domain.cgi?$svcnum") %> +%} +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? + +$cgi->param('op') =~ /^(register|transfer|revoke|renew)$/ or die "Illegal operation"; +my $operation = $1; +#my($query) = $cgi->keywords; +#$query =~ /^(\d+)$/; +$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +my $svcnum = $1; +my $svc_domain = qsearchs({ + 'select' => 'svc_domain.*', + 'table' => 'svc_domain', + 'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '. + ' LEFT JOIN cust_pkg USING ( pkgnum ) '. + ' LEFT JOIN cust_main USING ( custnum ) ', + 'hashref' => {'svcnum'=>$svcnum}, + 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +}); +die "Unknown svcnum" unless $svc_domain; + +my $cust_svc = qsearchs('cust_svc',{'svcnum'=>$svcnum}); +my $part_svc = qsearchs('part_svc',{'svcpart'=> $cust_svc->svcpart } ); +die "Unknown svcpart" unless $part_svc; + +my $error = ''; + +my @exports = $part_svc->part_export(); + +my $registrar; +my $export; + +# Find the first export that does domain registration +foreach (@exports) { + $export = $_ if $_->can('registrar'); +} + +my $period = 1; # Current OpenSRS export can only handle 1 year registrations + +# If we have a domain registration export, get the registrar object +if ($export) { + if ($operation eq 'register') { + $error = $export->register( $svc_domain, $period ); + } elsif ($operation eq 'transfer') { + $error = $export->transfer( $svc_domain ); + } elsif ($operation eq 'revoke') { + $error = $export->revoke( $svc_domain ); + } elsif ($operation eq 'renew') { + $cgi->param('period') =~ /^(\d+)$/ or die "Illegal renewal period!"; + $period = $1; + $error = $export->renew( $svc_domain, $period ); + } +} + +</%init> diff --git a/httemplate/edit/process/elements/ApplicationCommon.html b/httemplate/edit/process/elements/ApplicationCommon.html index 2782dc2..e0c5bd7 100644 --- a/httemplate/edit/process/elements/ApplicationCommon.html +++ b/httemplate/edit/process/elements/ApplicationCommon.html @@ -72,6 +72,6 @@ my $new; #} -my $error = $new->insert; +my $error = $new->insert( 'manual' => 1 ); </%init> diff --git a/httemplate/edit/process/part_device.html b/httemplate/edit/process/part_device.html new file mode 100644 index 0000000..2b7e1da --- /dev/null +++ b/httemplate/edit/process/part_device.html @@ -0,0 +1,11 @@ +<% include( 'elements/process.html', + 'table' => 'part_device', + 'viewall_dir' => 'browse', + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/process/part_export.cgi b/httemplate/edit/process/part_export.cgi index b5f82e8..209419f 100644 --- a/httemplate/edit/process/part_export.cgi +++ b/httemplate/edit/process/part_export.cgi @@ -16,7 +16,8 @@ my $old = qsearchs('part_export', { 'exportnum'=>$exportnum } ) if $exportnum; #fixup options #warn join('-', split(',',$cgi->param('options'))); my %options = map { - my $value = $cgi->param($_); + my @values = $cgi->param($_); + my $value = scalar(@values) > 1 ? join (' ', @values) : $values[0]; $value =~ s/\r\n/\n/g; #browsers? (textarea) $_ => $value; } split(',', $cgi->param('options')); diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 96c5b36..019224c 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -93,6 +93,7 @@ my $args_callback = sub { } ( $optionname => $value ); } + grep { $_ !~ /^report_option_/ } @options; foreach ( split(',', $cgi->param('taxproductnums') ) ) { @@ -102,6 +103,11 @@ my $args_callback = sub { $options{"usage_taxproductnum_$_"} = $value; } + foreach ( $cgi->param('report_option') ) { + $error ||= "Illegal optional report class: $_" unless ( $_ =~ /^\d*$/ ); + $options{"report_option_$_"} = 1; + } + $options{$_} = scalar( $cgi->param($_) ) for (qw( setup_fee recur_fee )); @@ -134,7 +140,13 @@ my $args_callback = sub { my $redirect_callback = sub { #my( $cgi, $new ) = @_; return '' unless $custnum; - popurl(3). "view/cust_main.cgi?keywords=$custnum;dummy="; + my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/ + ? '' + : ';show=packages'; + #my $frag = "cust_pkg$pkgnum"; #hack for IE ignoring real #fragment + + #can we link back to the specific customized package? it would be nice... + popurl(3). "view/cust_main.cgi?custnum=$custnum$show;dummy="; }; #these should probably move to @args above and be processed by part_pkg.pm... @@ -152,16 +164,28 @@ my @process_m2m = ( 'target_table' => 'part_pkg', 'base_field' => 'src_pkgpart', 'target_field' => 'dst_pkgpart', - 'hashref' => { 'link_type' => 'bill' }, - 'params' => [ map $cgi->param($_), grep /^bill_dst_pkgpart/, $cgi->param ], - }, - { 'link_table' => 'part_pkg_link', - 'target_table' => 'part_pkg', - 'base_field' => 'src_pkgpart', - 'target_field' => 'dst_pkgpart', - 'hashref' => { 'link_type' => 'svc' }, - 'params' => [ map $cgi->param($_), grep /^svc_dst_pkgpart/, $cgi->param ], + 'hashref' => { 'link_type' => 'svc', 'hidden' => '' }, + 'params' => [ map $cgi->param($_), + grep /^svc_dst_pkgpart/, $cgi->param + ], }, + map { + my $hidden = $_; + { 'link_table' => 'part_pkg_link', + 'target_table' => 'part_pkg', + 'base_field' => 'src_pkgpart', + 'target_field' => 'dst_pkgpart', + 'hashref' => { 'link_type' => 'bill', 'hidden' => $hidden }, + 'params' => [ map { $cgi->param($_) } + grep { my $param = "bill_dst_pkgpart__hidden"; + my $digit = ''; + (($digit) = /^bill_dst_pkgpart(\d+)/ ) && + $cgi->param("$param$digit") eq $hidden; + } + $cgi->param + ], + }, + } ( '', 'Y' ), ); foreach my $override_class ($cgi->param) { diff --git a/httemplate/edit/process/part_pkg_report_option.html b/httemplate/edit/process/part_pkg_report_option.html new file mode 100644 index 0000000..052aabd --- /dev/null +++ b/httemplate/edit/process/part_pkg_report_option.html @@ -0,0 +1,11 @@ +<% include( 'elements/process.html', + 'table' => 'part_pkg_report_option', + 'viewall_dir' => 'browse', + ) +%> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/process/part_pkg_taxclass.html b/httemplate/edit/process/part_pkg_taxclass.html index 8f149bb..b37279f 100644 --- a/httemplate/edit/process/part_pkg_taxclass.html +++ b/httemplate/edit/process/part_pkg_taxclass.html @@ -1,53 +1,17 @@ -% if ( $error ) { -% $cgi->param('error', $error); -<% $cgi->redirect(popurl(2). "part_pkg_taxclass.html?". $cgi->query_string ) %> -%} else { -<% $cgi->redirect(popurl(3). "browse/cust_main_county.cgi?taxclass=". uri_escape($part_pkg_taxclass->taxclass) ) %> -%} +<% include( 'elements/process.html', + 'table' => 'part_pkg_taxclass', + 'redirect' => sub { + my( $cgi, $part_pkg_taxclass ) = @_; + + popurl(3). 'browse/cust_main_county.cgi?'. + 'taxclass='. uri_escape($part_pkg_taxclass->taxclass). + ';dummy='; + }, + ) +%> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $part_pkg_taxclass = new FS::part_pkg_taxclass { - 'taxclass' => $cgi->param('taxclass'), -}; - -#maybe this whole thing should be in a transaction. at some point, no biggie -#none of the follow-up stuff will fail unless there's a more serious problem -#than a hanging record in part_pkg_taxclass... - -my $error = $part_pkg_taxclass->insert; - -unless ( $error ) { - #auto-add the new taxclass to any regions that have taxclasses already - - my $sth = dbh->prepare(" - SELECT country, state, county FROM cust_main_county - WHERE taxclass IS NOT NULL AND taxclass != '' - GROUP BY country, state, county - ") or die dbh->errstr; - $sth->execute or die $sth->errstr; - - while ( my $row = $sth->fetchrow_hashref ) { - warn "inserting for $row"; - my $cust_main_county = new FS::cust_main_county { - 'country' => $row->{country}, - 'state' => $row->{state}, - 'county' => $row->{county}, - 'tax' => 0, - 'taxclass' => $part_pkg_taxclass->taxclass, - #exempt_amount - #taxname - #setuptax - #recurtax - }; - $error = $cust_main_county->insert; - #last if $error; - die $error if $error; - } - - -} - </%init> diff --git a/httemplate/edit/process/payment_gateway.html b/httemplate/edit/process/payment_gateway.html index b16bc3d..812c988 100644 --- a/httemplate/edit/process/payment_gateway.html +++ b/httemplate/edit/process/payment_gateway.html @@ -1,35 +1,22 @@ -%if ( $error ) { -% $cgi->param('error', $error); -<% $cgi->redirect(popurl(2). "payment_gateway.html?". $cgi->query_string ) %> -%} else { -<% $cgi->redirect(popurl(3). "browse/payment_gateway.html") %> -%} +<% include( 'elements/process.html', + 'table' => 'payment_gateway', + 'viewall_dir' => 'browse', + 'args_callback' => $args_callback, + ) +%> <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $gatewaynum = $cgi->param('gatewaynum'); +my $args_callback = sub { + my ( $cgi, $new ) = @_; -my $old = qsearchs('payment_gateway',{'gatewaynum'=>$gatewaynum}) if $gatewaynum; + my @options = split(/\r?\n/, $cgi->param('gateway_options') ); + pop @options + if scalar(@options) % 2 && $options[-1] =~ /^\s*$/; + (@options) +}; -my $new = new FS::payment_gateway ( { - map { - $_, scalar($cgi->param($_)); - } fields('payment_gateway') -} ); - -my @options = split(/\r?\n/, $cgi->param('gateway_options') ); -pop @options - if scalar(@options) % 2 && $options[-1] =~ /^\s*$/; -my %options = @options; - -my $error; -if ( $gatewaynum ) { - $error=$new->replace($old, \%options); -} else { - $error=$new->insert(\%options); - $gatewaynum=$new->getfield('gatewaynum'); -} </%init> diff --git a/httemplate/edit/process/phone_device.html b/httemplate/edit/process/phone_device.html new file mode 100644 index 0000000..df9d5e7 --- /dev/null +++ b/httemplate/edit/process/phone_device.html @@ -0,0 +1,18 @@ +<% include( 'elements/process.html', + 'table' => 'phone_device', + 'redirect' => sub { + my( $cgi, $phone_device ) = @_; + popurl(3).'view/svc_phone.cgi?'. + 'svcnum='. $phone_device->svcnum. + ';devicenum='; + }, + ) +%> +<%init> + +# :/ needs agent-virt so you can't futz with arbitrary devices + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? + +</%init> diff --git a/httemplate/edit/process/quick-charge.cgi b/httemplate/edit/process/quick-charge.cgi index 8fa57dd..827530e 100644 --- a/httemplate/edit/process/quick-charge.cgi +++ b/httemplate/edit/process/quick-charge.cgi @@ -27,7 +27,7 @@ $param->{"custnum"} =~ /^(\d+)$/ or $error .= "Illegal customer number " . $param->{"custnum"} . " "; my $custnum = $1; -$param->{"amount"} =~ /^\s*(\d+(\.\d{1,2})?)\s*$/ +$param->{"amount"} =~ /^\s*(\d*(?:\.?\d{1,2}))\s*$/ or $error .= "Illegal amount " . $param->{"amount"} . " "; my $amount = $1; @@ -55,6 +55,12 @@ unless ( $error ) { $error ||= $cust_main->charge( { 'amount' => $amount, 'quantity' => $quantity, + 'bill_now' => scalar($cgi->param('bill_now')), + 'invoice_terms' => scalar($cgi->param('invoice_terms')), + 'start_date' => ( scalar($cgi->param('start_date')) + ? str2time($cgi->param('start_date')) + : '' + ), 'pkg' => scalar($cgi->param('pkg')), 'setuptax' => scalar($cgi->param('setuptax')), 'taxclass' => scalar($cgi->param('taxclass')), diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 9c24743..7a0f082 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -3,12 +3,15 @@ <% $cgi->redirect(popurl(3). 'misc/order_pkg.html?'. $cgi->query_string ) %> %} else { % my $frag = "cust_pkg". $cust_pkg->pkgnum; +% my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/ +% ? '' +% : ';show=packages'; <% header('Package ordered') %> <SCRIPT TYPE="text/javascript"> // XXX fancy ajax rebuild table at some point, but a page reload will do for now // XXX chop off trailing #target and replace... ? - window.top.location = '<% popurl(3). "view/cust_main.cgi?keywords=$custnum;fragment=$frag#$frag" %>'; + window.top.location = '<% popurl(3). "view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag" %>'; </SCRIPT> @@ -16,8 +19,10 @@ %} <%init> +my $curuser = $FS::CurrentUser::CurrentUser; + die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Order customer package'); + unless $curuser->access_right('Order customer package'); #untaint custnum (probably not necessary, searching for it is escape enough) $cgi->param('custnum') =~ /^(\d+)$/ @@ -44,6 +49,10 @@ my $locationnum = $1; my $cust_pkg = new FS::cust_pkg { 'custnum' => $custnum, 'pkgpart' => $pkgpart, + 'start_date' => ( scalar($cgi->param('start_date')) + ? str2time($cgi->param('start_date')) + : '' + ), 'refnum' => $refnum, 'locationnum' => $locationnum, }; diff --git a/httemplate/edit/process/svc_domain.cgi b/httemplate/edit/process/svc_domain.cgi index 9993a87..59b5180 100755 --- a/httemplate/edit/process/svc_domain.cgi +++ b/httemplate/edit/process/svc_domain.cgi @@ -18,8 +18,8 @@ my $svcnum = $1; my $new = new FS::svc_domain ( { map { $_, scalar($cgi->param($_)); - #} qw(svcnum pkgnum svcpart domain action purpose) - } ( fields('svc_domain'), qw( pkgnum svcpart action purpose ) ) + #} qw(svcnum pkgnum svcpart domain action) + } ( fields('svc_domain'), qw( pkgnum svcpart action ) ) } ); my $error = ''; |