diff options
Diffstat (limited to 'httemplate/edit/process')
29 files changed, 531 insertions, 106 deletions
diff --git a/httemplate/edit/process/REAL_cust_pkg.cgi b/httemplate/edit/process/REAL_cust_pkg.cgi deleted file mode 100755 index 3e0ef59c1..000000000 --- a/httemplate/edit/process/REAL_cust_pkg.cgi +++ /dev/null @@ -1,54 +0,0 @@ -%if ( $error ) { -% $cgi->param('error', $error); -<% $cgi->redirect(popurl(2). "REAL_cust_pkg.cgi?". $cgi->query_string ) %> -%} else { -% my $custnum = $new->custnum; -% 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 $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{$_}= $cgi->param($_) ? parse_datetime($cgi->param($_)) : '' - foreach qw( start_date setup bill last_bill contract_end ); - # adjourn, expire, resume not editable this way - -my @errors = (); - -push @errors, '_bill_areyousure' - if $hash{'bill'} != $old->bill # if the next bill date was changed - && $hash{'bill'} < time # to a date in the past - && ! $cgi->param('bill_areyousure'); # and it wasn't confirmed - -push @errors, '_setup_areyousure' - if ! $hash{'setup'} && $old->setup # if the setup date was removed - && ! $cgi->param('setup_areyousure'); # and it wasn't confirmed - -push @errors, '_setupadd_areyousure' - if $hash{'setup'} && ! $old->setup # if the setup date was added - && ! $cgi->param('setupadd_areyousure'); # and it wasn't confirmed - -push @errors, '_start' - if $hash{'start_date'} && !$old->start_date # if a start date was added - && $hash{'setup'}; # but there's a setup date - -my $new; -my $error; -if ( @errors ) { - $error = join(',', @errors); -} else { - $new = new FS::cust_pkg \%hash; - $error = $new->replace($old); -} - -</%init> diff --git a/httemplate/edit/process/access_user.html b/httemplate/edit/process/access_user.html index 8e7e70a06..7fc7c25e1 100644 --- a/httemplate/edit/process/access_user.html +++ b/httemplate/edit/process/access_user.html @@ -3,14 +3,15 @@ % print $cgi->redirect(popurl(2) . "access_user.html?" . $cgi->query_string); % } else { <% include( 'elements/process.html', - 'table' => 'access_user', - 'viewall_dir' => 'browse', - 'copy_on_empty' => [ '_password' ], + 'table' => 'access_user', + 'viewall_dir' => 'browse', + 'copy_on_empty' => [ '_password', '_password_encoding' ], 'clear_on_error' => [ '_password', '_password2' ], - 'process_m2m' => { 'link_table' => 'access_usergroup', - 'target_table' => 'access_group', - }, - 'precheck_callback'=> \&precheck_callback, + 'process_m2m' => { 'link_table' => 'access_usergroup', + 'target_table' => 'access_group', + }, + 'precheck_callback' => \&precheck_callback, + 'post_new_object_callback' => \&post_new_object_callback, ) %> % } @@ -26,11 +27,24 @@ if ( FS::Conf->new->exists('disable_acl_changes') ) { sub precheck_callback { my $cgi = shift; + my $o = FS::access_user->new({username => $cgi->param('username')}); if( $o->is_system_user and !$cgi->param('usernum') ) { $cgi->param('username',''); return "username '".$o->username."' reserved for system account." } + return ''; } + +sub post_new_object_callback { + my( $cgi, $access_user ) = @_; + + if ( length($cgi->param('_password')) ) { + my $password = scalar($cgi->param('_password')); + $access_user->change_password_fields($password); + } + +} + </%init> diff --git a/httemplate/edit/process/agent.cgi b/httemplate/edit/process/agent.cgi index 034c4cc50..554992958 100755 --- a/httemplate/edit/process/agent.cgi +++ b/httemplate/edit/process/agent.cgi @@ -5,6 +5,12 @@ 'process_m2m' => { 'link_table' => 'access_groupagent', 'target_table' => 'access_group', }, + 'process_m2name' => { + 'link_table' => 'agent_currency', + 'name_col' => 'currency', + 'names_list' => [ $conf->config('currencies') ], + 'param_style' => 'link_table.value checkboxes', + }, 'edit_ext' => 'cgi', 'noerror_callback' => $process_agent_pkg_class, ) @@ -14,7 +20,9 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -if ( FS::Conf->new->exists('disable_acl_changes') ) { +my $conf = new FS::Conf; + +if ( $conf->exists('disable_acl_changes') ) { errorpage('ACL changes disabled in public demo.'); die "shouldn't be reached"; } diff --git a/httemplate/edit/process/bulk-cust_svc-pkgnum.html b/httemplate/edit/process/bulk-cust_svc-pkgnum.html new file mode 100644 index 000000000..f5cf7dd07 --- /dev/null +++ b/httemplate/edit/process/bulk-cust_svc-pkgnum.html @@ -0,0 +1,39 @@ +% if ($error) { +% #$cgi->param('error', $error); +% #$cgi->redirect(popurl(3). 'misc/detach_pkg.html?'. $cgi->query_string ); +% #XXX actually redirect back and display the error instead +% errorpage_popup($error); +% } else { + + <% header(emt("Services moved")) %> + <SCRIPT TYPE="text/javascript"> + window.top.location.reload(); + </SCRIPT> + </BODY> + </HTML> + +% } +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied" unless $curuser->access_right('Bulk move customer services'); + +$cgi->param('pkgnum') =~ /^(\d+)$/ or die 'illegal pkgnum'; +my $pkgnum = $1; + +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'; + +my @svcnum = (); +foreach my $param (grep /^svcnum\d+$/, $cgi->param) { + $param =~ /^svcnum(\d+)$/ or die "guru meditation #309"; + push @svcnum, $1 if $cgi->param($param); +} + +my $error = $cust_pkg->grab_svcnums(@svcnum); + +</%init> diff --git a/httemplate/edit/process/bulk-part_pkg.html b/httemplate/edit/process/bulk-part_pkg.html new file mode 100644 index 000000000..4775a9334 --- /dev/null +++ b/httemplate/edit/process/bulk-part_pkg.html @@ -0,0 +1,30 @@ +% if ( $error ) { +% $cgi->param('error', $error); +<% $cgi->redirect(popurl(3).'/edit/bulk-part_pkg.cgi?', $cgi->query_string) %> +% } else { +<% $cgi->redirect(popurl(3).'/browse/part_pkg.cgi') %> +% } +<%init> +die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk edit package definitions'); + +my @pkgparts = $cgi->param('pkgpart') + or die "no package definitions selected"; + +my %changes; +foreach my $param (grep { /^report_option_\d+$/ } $cgi->param) { + if ( length($cgi->param($param)) ) { + if ( $cgi->param($param) == 1 ) { + $changes{$param} = 1; + } else { + $changes{$param} = ''; + } + } +} + +my $error; +foreach my $pkgpart (@pkgparts) { + my $part_pkg = FS::part_pkg->by_key($pkgpart); + my %options = ( $part_pkg->options, %changes ); + $error ||= $part_pkg->replace( options => \%options ); +} +</%init> diff --git a/httemplate/edit/process/cable_device.html b/httemplate/edit/process/cable_device.html new file mode 100644 index 000000000..97b4f81d9 --- /dev/null +++ b/httemplate/edit/process/cable_device.html @@ -0,0 +1,23 @@ +<% include( 'elements/process.html', + 'table' => 'cable_device', + 'redirect' => sub { + my( $cgi, $cable_device ) = @_; + #popurl(3).'view/svc_cable.html?'. + popurl(3).'view/svc_Common.html?svcdb=svc_cable;'. + 'svcnum='. $cable_device->svcnum. + ';devicenum='; + }, + ) +%> +<%init> + +if($cgi->param('sel_mac_addr') && !$cgi->param('mac_addr')) { + $cgi->param('mac_addr',$cgi->param('sel_mac_addr')); +} + +# :/ 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/cdr_carrier.html b/httemplate/edit/process/cdr_carrier.html new file mode 100644 index 000000000..72f018609 --- /dev/null +++ b/httemplate/edit/process/cdr_carrier.html @@ -0,0 +1,10 @@ +<& elements/process.html, + 'table' => 'cdr_carrier', + 'viewall_dir' => 'browse', +&> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +</%init> diff --git a/httemplate/edit/process/cdr_type.cgi b/httemplate/edit/process/cdr_type.cgi index b661de75d..ba9881dc4 100644 --- a/httemplate/edit/process/cdr_type.cgi +++ b/httemplate/edit/process/cdr_type.cgi @@ -10,7 +10,6 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); my %vars = $cgi->Vars; -warn Dumper(\%vars)."\n"; my %old = map { $_->cdrtypenum => $_ } qsearch('cdr_type', {}); diff --git a/httemplate/edit/process/change-cust_pkg.html b/httemplate/edit/process/change-cust_pkg.html index 2770f3283..c893f13a2 100644 --- a/httemplate/edit/process/change-cust_pkg.html +++ b/httemplate/edit/process/change-cust_pkg.html @@ -32,11 +32,11 @@ my %change = map { $_ => scalar($cgi->param($_)) } $change{'keep_dates'} = 1; if ( $cgi->param('locationnum') == -1 ) { - my $cust_location = new FS::cust_location { + my $cust_location = FS::cust_location->new({ 'custnum' => $cust_pkg->custnum, map { $_ => scalar($cgi->param($_)) } qw( address1 address2 city county state zip country ) - }; + }); $change{'cust_location'} = $cust_location; } diff --git a/httemplate/edit/process/credit-cust_bill_pkg.html b/httemplate/edit/process/credit-cust_bill_pkg.html new file mode 100644 index 000000000..8e66368d4 --- /dev/null +++ b/httemplate/edit/process/credit-cust_bill_pkg.html @@ -0,0 +1,45 @@ +%if ($error) { +% errorpage_popup($error); #XXX redirect back for correction... +%} else { +<& /elements/header-popup.html, 'Credit successful' &> + <SCRIPT TYPE="text/javascript"> + window.top.location.reload(); + </SCRIPT> + </BODY></HTML> +% } +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Credit line items'); + +my @billpkgnum_setuprecurs = + map { $_ =~ /^billpkgnum(\d+\-\w*)$/ or die 'gm#23'; $1; } + grep { $_ =~ /^billpkgnum\d+\-\w*$/ && $cgi->param($_) } $cgi->param; + +my @billpkgnums = (); +my @setuprecurs = (); +my @amounts = (); +foreach my $billpkgnum_setuprecur (@billpkgnum_setuprecurs) { + my $amount = $cgi->param("billpkgnum$billpkgnum_setuprecur-amount"); + my( $billpkgnum, $setuprecur ) = split('-', $billpkgnum_setuprecur); + push @billpkgnums, $billpkgnum; + push @setuprecurs, $setuprecur; + push @amounts, $amount; +} + +my $error = FS::cust_credit->credit_lineitems( + #the lineitems to credit + 'billpkgnums' => \@billpkgnums, + 'setuprecurs' => \@setuprecurs, + 'amounts' => \@amounts, + 'apply' => ( $cgi->param('apply') eq 'yes' ), + + #the credit + 'newreasonnum' => scalar($cgi->param('newreasonnum')), + 'newreasonnum_type' => scalar($cgi->param('newreasonnumT')), + map { $_ => scalar($cgi->param($_)) } + #fields('cust_credit') + qw( custnum _date amount reason reasonnum addlinfo ), #pkgnum eventnum +); + +</%init> diff --git a/httemplate/edit/process/currency_exchange.html b/httemplate/edit/process/currency_exchange.html new file mode 100644 index 000000000..1f6852299 --- /dev/null +++ b/httemplate/edit/process/currency_exchange.html @@ -0,0 +1,36 @@ +%if ( $error ) { +% errorpage($error); #also not super ideal +%} else { #or this +<% include('/elements/header.html', 'Exchange rates updated') %> +<% include('/elements/footer.html') %> +%} +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $conf = new FS::Conf; + +my $to_currency = $conf->config('currency') || 'USD'; + +my @currencies = sort { $a cmp $b } $conf->config('currencies'); + +#in the best of all possible worlds, i would be a single database transaction +# but here it isn't terribly important other than offending my sense of elegance +my $error = ''; +foreach my $currency (@currencies) { + + my %hash = ( 'from_currency' => $currency, + 'to_currency' => $to_currency, + ); + + my $currency_exchange = qsearchs('currency_exchange', \%hash) + || new FS::currency_exchange \%hash; + + $currency_exchange->rate( $cgi->param("$currency-$to_currency") ); + + my $method = $currency_exchange->currencyratenum ? 'replace' : 'insert'; + $error = $currency_exchange->$method() and last; +} + +</%init> diff --git a/httemplate/edit/process/cust_credit.cgi b/httemplate/edit/process/cust_credit.cgi index 776112ac0..245f31af7 100755 --- a/httemplate/edit/process/cust_credit.cgi +++ b/httemplate/edit/process/cust_credit.cgi @@ -15,7 +15,7 @@ % % $dbh->commit or die $dbh->errstr if $oldAutoCommit; % -<% header(emt('Credit sucessful')) %> +<% header(emt('Credit successful')) %> <SCRIPT TYPE="text/javascript"> window.top.location.reload(); </SCRIPT> @@ -27,7 +27,7 @@ die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Post credit'); -$cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!"; +$cgi->param('custnum') =~ /^(\d+)$/ or die "Illegal custnum!"; my $custnum = $1; $cgi->param('reasonnum') =~ /^(-?\d+)$/ or die "Illegal reasonnum"; diff --git a/httemplate/edit/process/cust_location.cgi b/httemplate/edit/process/cust_location.cgi index b9f93db8b..fd1b8740e 100644 --- a/httemplate/edit/process/cust_location.cgi +++ b/httemplate/edit/process/cust_location.cgi @@ -31,10 +31,9 @@ die "unknown locationnum $locationnum" unless $cust_location; my $new = FS::cust_location->new({ custnum => $cust_location->custnum, prospectnum => $cust_location->prospectnum, - map { $_ => scalar($cgi->param($_)) } - qw( address1 address2 city county state zip country ) + map { $_ => scalar($cgi->param($_)) } FS::cust_main->location_fields }); - -my $error = $cust_location->move_to($new); +my $error = $new->find_or_insert; +$error ||= $cust_location->move_to($new); </%init> diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 31ec4ab12..621de24bf 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -16,8 +16,8 @@ my $DEBUG = 0; </%once> <%init> -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Edit customer'); +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied" unless $curuser->access_right('Edit customer'); my $conf = new FS::Conf; @@ -62,6 +62,18 @@ $cgi->param('invoicing_list', join(',', @invoicing_list) ); $cgi->param('duplicate_of_custnum') =~ /^(\d+)$/; my $duplicate_of = $1; +# if this is enabled, enforce it +if ( $conf->exists('agent-ship_address', $cgi->param('agentnum')) ) { + my $agent = FS::agent->by_key($cgi->param('agentnum')); + my $agent_cust_main = $agent->agent_cust_main; + if ( $agent_cust_main ) { + my $agent_location = $agent_cust_main->ship_location; + foreach (qw(address1 city state zip country latitude longitude district)) { + $cgi->param("ship_$_", $agent_location->get($_)); + } + } +} + my %locations; for my $pre (qw(bill ship)) { @@ -71,10 +83,7 @@ for my $pre (qw(bill ship)) { } $hash{'custnum'} = $cgi->param('custnum'); warn Dumper \%hash if $DEBUG; - # if we can qsearchs it, then it's unchanged, so use that - $locations{$pre} = qsearchs('cust_location', \%hash) - || FS::cust_location->new( \%hash ); - + $locations{$pre} = FS::cust_location->new(\%hash); } if ( ($cgi->param('same') || '') eq 'Y' ) { @@ -156,9 +165,14 @@ foreach my $dfield (qw( $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; -my %tax_exempt = map { $_ => scalar($cgi->param("tax_$_".'_num')) } @tax_exempt; +my %options = (); +if ( $curuser->access_right('Edit customer tax exemptions') ) { + my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups'); + my @tax_exempt = grep { $cgi->param("tax_$_") eq 'Y' } @exempt_groups; + $options{'tax_exemption'} = { + map { $_ => scalar($cgi->param("tax_$_".'_num')) } @tax_exempt + }; +} #perhaps this stuff should go to cust_main.pm if ( $new->custnum eq '' or $duplicate_of ) { @@ -266,8 +280,8 @@ if ( $new->custnum eq '' or $duplicate_of ) { else { # create the customer $error ||= $new->insert( \%hash, \@invoicing_list, - 'tax_exemption'=> \%tax_exempt, - 'prospectnum' => scalar($cgi->param('prospectnum')), + %options, + prospectnum => scalar($cgi->param('prospectnum')), ); my $conf = new FS::Conf; @@ -328,7 +342,7 @@ if ( $new->custnum eq '' or $duplicate_of ) { warn Dumper({ new => $new, old => $old }) if $DEBUG; $error ||= $new->replace( $old, \@invoicing_list, - 'tax_exemption' => \%tax_exempt, + %options, ); warn "$me returned from replace" if $DEBUG; diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi index ce0ec3212..a002fa181 100755 --- a/httemplate/edit/process/cust_pay.cgi +++ b/httemplate/edit/process/cust_pay.cgi @@ -57,6 +57,8 @@ my $new = new FS::cust_pay ( { bank depositor account teller ) #} fields('cust_pay') + # gatewaynum, processor, auth, order_number + # are for realtime payments only, and can't be entered manually } ); my @rights = ('Post payment'); diff --git a/httemplate/edit/process/cust_pkg_quantity.html b/httemplate/edit/process/cust_pkg_quantity.html new file mode 100644 index 000000000..fb2657252 --- /dev/null +++ b/httemplate/edit/process/cust_pkg_quantity.html @@ -0,0 +1,33 @@ +% if ($error) { +% $cgi->param('error', $error); +% $cgi->redirect(popurl(3). 'edit/cust_pkg_quantity.html?'. $cgi->query_string ); +% } else { + + <& /elements/header-popup.html, "Quantity 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 $cust_pkg = qsearchs({ + 'table' => 'cust_pkg', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', + 'hashref' => { 'pkgnum' => scalar($cgi->param('pkgnum')), }, + 'extra_sql' => ' AND '. $curuser->agentnums_sql, +}); +die 'unknown pkgnum' unless $cust_pkg; + +$cgi->param('quantity') =~ /^(\d+)$/; +my $quantity = $1; +my $error = $cust_pkg->set_quantity($1); + +</%init> diff --git a/httemplate/edit/process/cust_svc.cgi b/httemplate/edit/process/cust_svc.cgi index e22cbb201..7cb1d6d8f 100644 --- a/httemplate/edit/process/cust_svc.cgi +++ b/httemplate/edit/process/cust_svc.cgi @@ -6,7 +6,7 @@ %} <%init> -die 'access deined' +die 'access denied' unless $FS::CurrentUser::CurrentUser->access_right('Change customer service'); my $svcnum = $cgi->param('svcnum'); diff --git a/httemplate/edit/process/detach-cust_pkg.html b/httemplate/edit/process/detach-cust_pkg.html new file mode 100644 index 000000000..ab87eb536 --- /dev/null +++ b/httemplate/edit/process/detach-cust_pkg.html @@ -0,0 +1,47 @@ +% if ($error) { +% $cgi->param('error', $error); +% $cgi->redirect(popurl(3). 'misc/detach_pkg.html?'. $cgi->query_string ); +% } else { + + <% header(emt("Package detached")) %> + <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 $cust_pkg = qsearchs({ + 'table' => 'cust_pkg', + 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', + 'hashref' => { 'pkgnum' => scalar($cgi->param('pkgnum')), }, + 'extra_sql' => ' AND '. $curuser->agentnums_sql, +}); +die 'unknown pkgnum' unless $cust_pkg; + +my $cust_location = new FS::cust_location { + map { $_ => scalar($cgi->param($_)) } FS::cust_main->location_fields +}; + +my $cust_main = new FS::cust_main { + ( map { ( $_, scalar($cgi->param($_)) ) } fields('cust_main') ), + ( map { ( "ship_$_", '' ) } FS::cust_main->location_fields ), + 'bill_location' => $cust_location, + 'ship_location' => $cust_location, +}; + +my $pkg_or_error = $cust_pkg->change( { + 'keep_dates' => 1, + 'cust_main' => $cust_main, +} ); + +my $error = ref($pkg_or_error) ? '' : $pkg_or_error; + +</%init> diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html index 2d39e9dce..0439d4e9c 100644 --- a/httemplate/edit/process/elements/process.html +++ b/httemplate/edit/process/elements/process.html @@ -70,6 +70,9 @@ Example: #return an error string or empty for no error 'precheck_callback' => sub { my( $cgi ) = @_; }, + #after the new object is created + 'post_new_object_callback' => sub { my( $cgi, $object ) = @_; }, + #after everything's inserted 'noerror_callback' => sub { my( $cgi, $object ) = @_; }, @@ -201,7 +204,7 @@ my %hash = my @values = ( 1 ); if ( $bfield ) { @values = $cgi->param($bfield); - warn join(',', @values); + #warn join(',', @values); } my $new; @@ -226,6 +229,10 @@ foreach my $value ( @values ) { } } + if ( $opt{'post_new_object_callback'} ) { + &{ $opt{'post_new_object_callback'} }( $cgi, $new ); + } + if ( $opt{'agent_virt'} ) { if ( ! $new->agentnum @@ -263,6 +270,9 @@ foreach my $value ( @values ) { if ( !$error ) { if ( $old_pkey ) { + + &{ $opt{'edit_callback'} }( $new, $old ) if $opt{'edit_callback'}; + $error = $new->replace($old, @args); } else { $error = $new->insert(@args); diff --git a/httemplate/edit/process/elements/svc_Common.html b/httemplate/edit/process/elements/svc_Common.html index 5a8afbd6c..06f4c00b1 100644 --- a/httemplate/edit/process/elements/svc_Common.html +++ b/httemplate/edit/process/elements/svc_Common.html @@ -10,5 +10,10 @@ my %opt = @_; my $table = $opt{'table'}; $opt{'fields'} ||= [ fields($table) ]; push @{ $opt{'fields'} }, qw( pkgnum svcpart ); +foreach (fields($table)) { + if ( $cgi->param($_.'_classnum') ) { + push @{ $opt{'fields'} }, $_.'_classnum'; + } +} </%init> diff --git a/httemplate/edit/process/ftp_target.html b/httemplate/edit/process/ftp_target.html deleted file mode 100644 index 35f56c490..000000000 --- a/httemplate/edit/process/ftp_target.html +++ /dev/null @@ -1,12 +0,0 @@ -<& elements/process.html, - 'table' => 'ftp_target', - 'viewall_dir' => 'browse', - 'agent_null' => 1, -&> -<%init> -my $curuser = $FS::CurrentUser::CurrentUser; - -die "access denied" - unless $curuser->access_right('Configuration'); - -</%init> diff --git a/httemplate/edit/process/part_export.cgi b/httemplate/edit/process/part_export.cgi index 6432d6b15..e0c470675 100644 --- a/httemplate/edit/process/part_export.cgi +++ b/httemplate/edit/process/part_export.cgi @@ -13,15 +13,40 @@ my $exportnum = $cgi->param('exportnum'); my $old = qsearchs('part_export', { 'exportnum'=>$exportnum } ) if $exportnum; +my %vars = $cgi->Vars; #fixup options #warn join('-', split(',',$cgi->param('options'))); my %options = map { - my @values = $cgi->param($_); - my $value = scalar(@values) > 1 ? join (' ', @values) : $values[0]; + my $value = $vars{$_}; + $value =~ s/\0/ /g; # deal with multivalued options $value =~ s/\r\n/\n/g; #browsers? (textarea) $_ => $value; } split(',', $cgi->param('options')); +# deal with multiline options +# %vars should never contain incomplete rows, but just in case it does, +# we make a list of all the row indices that contain values, and +# then write a line in each option for each row, even if it's empty. +# This ensures that all values with the same row index line up. +my %optionrows; +foreach my $option (split(',', $cgi->param('multi_options'))) { + $optionrows{$option} = {}; + my %values; # bear with me + for (keys %vars) { + /^$option(\d+)/ or next; + $optionrows{$option}{$1} = $vars{$option.$1}; + $optionrows{_ALL_}{$1} = 1 if length($vars{$option.$1}); + } +} +foreach my $option (split(',', $cgi->param('multi_options'))) { + my $value = ''; + foreach my $row (sort keys %{$optionrows{_ALL_}}) { + $value .= ($optionrows{$option}{$row} || '') . "\n"; + } + chomp($value); + $options{$option} = $value; +} + my $new = new FS::part_export ( { map { $_, scalar($cgi->param($_)); @@ -31,6 +56,7 @@ my $new = new FS::part_export ( { if ( $cgi->param('svc_machine') eq 'Y' ) { $new->machine('_SVC_MACHINE'); $new->part_export_machine_textarea( $cgi->param('part_export_machine') ); + $new->default_machine_name( $cgi->param('default_machine_name') ); } my $error; diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index c388676df..3b6562f13 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -10,6 +10,7 @@ 'precheck_callback' => $precheck_callback, 'args_callback' => $args_callback, 'process_m2m' => \@process_m2m, + 'process_o2m' => \@process_o2m, ) %> <%init> @@ -114,6 +115,19 @@ my $args_callback = sub { push @args, 'options' => \%options; ### + #part_pkg_currency + ### + + my %part_pkg_currency = ( + map { $_ => scalar($cgi->param($_)) } + #grep /._[A-Z]{3}$/, #support other options + grep /^(setup|recur)_fee_[A-Z]{3}$/, + $cgi->param + ); + + push @args, 'part_pkg_currency' => \%part_pkg_currency; + + ### #pkg_svc ### @@ -185,6 +199,15 @@ my @process_m2m = ( grep /^svc_dst_pkgpart/, $cgi->param ], }, + { 'link_table' => 'part_pkg_link', + 'target_table' => 'part_pkg', + 'base_field' => 'src_pkgpart', + 'target_field' => 'dst_pkgpart', + 'hashref' => { 'link_type' => 'supp', 'hidden' => '' }, + 'params' => [ map $cgi->param($_), + grep /^supp_dst_pkgpart/, $cgi->param + ], + }, map { my $hidden = $_; { 'link_table' => 'part_pkg_link', @@ -235,4 +258,11 @@ if ( $cgi->param('pkgpart') || ! $conf->exists('agent_defaultpkg') ) { }; } +my @process_o2m = ( + { + 'table' => 'part_pkg_msgcat', + 'fields' => [qw( locale pkg )], + }, +); + </%init> diff --git a/httemplate/edit/process/part_pkg_usage.html b/httemplate/edit/process/part_pkg_usage.html new file mode 100644 index 000000000..eb6c37b82 --- /dev/null +++ b/httemplate/edit/process/part_pkg_usage.html @@ -0,0 +1,67 @@ +% if ( $is_error ) { +% $cgi->param('error' => \%part_pkg_usage); +% # internal redirect, because it's a lot of state to pass through +<& /browse/part_pkg_usage.html &> +% } else { +% # uh, not quite sure... +<% $cgi->redirect($fsurl.'browse/part_pkg.cgi') %> +% } +<%init> +my %vars = $cgi->Vars; +my %part_pkg_usage; +my $is_error; +foreach my $pkgpart ($cgi->param('pkgpart')) { + next unless $pkgpart =~ /^\d+$/; + my $part_pkg = FS::part_pkg->by_key($pkgpart) + or die "unknown pkgpart $pkgpart"; + my %old = map { $_->pkgusagepart => $_ } $part_pkg->part_pkg_usage; + $part_pkg_usage{$pkgpart} ||= []; + my @rows; + foreach (grep /^pkgpart$pkgpart/, keys %vars) { + /^pkgpart\d+_(\w+\D)(\d+)$/ or die "misspelled field name '$_'"; + my $value = delete $vars{$_}; + my $field = $1; + my $row = $2; + $rows[$row] ||= {}; + $rows[$row]->{$field} = $value; + } + + foreach my $row (@rows) { + next if !defined($row); + my $error; + my %classes; + foreach my $class (grep /^class/, keys %$row) { + $class =~ /^class(\d+)_$/; + my $classnum = $1; + $classes{$classnum} = delete $row->{$class}; + } + my $usage = FS::part_pkg_usage->new($row); + $usage->set('pkgpart', $pkgpart); + if ( $usage->pkgusagepart and $row->{minutes} > 0 ) { + $error = $usage->replace(\%classes); + # and don't delete the existing one + delete($old{$usage->pkgusagepart}); + } elsif ( $row->{minutes} > 0 ) { + $error = $usage->insert(\%classes); + } else { + next; + } + if ( $error ) { + $usage->set('error', $error); + $is_error = 1; + } + push @{ $part_pkg_usage{$pkgpart} }, $usage; + } + + foreach my $usage (values %old) { + # all of these were not sent back by the client, so delete them + my $error = $usage->delete; + if ( $error ) { + $usage->set('error', $error); + $is_error = 1; + unshift @{ $part_pkg_usage{$pkgpart} }, $usage; + } + } + +} +</%init> diff --git a/httemplate/edit/process/payment_gateway.html b/httemplate/edit/process/payment_gateway.html index 812c988c5..157449e89 100644 --- a/httemplate/edit/process/payment_gateway.html +++ b/httemplate/edit/process/payment_gateway.html @@ -15,6 +15,7 @@ my $args_callback = sub { my @options = split(/\r?\n/, $cgi->param('gateway_options') ); pop @options if scalar(@options) % 2 && $options[-1] =~ /^\s*$/; + @options = ( {} ) if !@options; (@options) }; diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi index 2dadbccdc..fe5ee5e9e 100644 --- a/httemplate/edit/process/quick-cust_pkg.cgi +++ b/httemplate/edit/process/quick-cust_pkg.cgi @@ -70,6 +70,9 @@ my $quantity = $1 || 1; $cgi->param('refnum') =~ /^(\d*)$/ or die 'illegal refnum '. $cgi->param('refnum'); my $refnum = $1; +$cgi->param('contactnum') =~ /^(\-?\d*)$/ + or die 'illegal contactnum '. $cgi->param('contactnum'); +my $contactnum = $1; $cgi->param('locationnum') =~ /^(\-?\d*)$/ or die 'illegal locationnum '. $cgi->param('locationnum'); my $locationnum = $1; @@ -109,6 +112,7 @@ my %hash = ( : '' ), 'refnum' => $refnum, + 'contactnum' => $contactnum, 'locationnum' => $locationnum, 'discountnum' => $discountnum, #for the create a new discount case @@ -142,12 +146,22 @@ if ( $quotationnum ) { my %opt = ( 'cust_pkg' => $cust_pkg ); + if ( $contactnum == -1 ) { + my $contact = FS::contact->new({ + 'custnum' => scalar($cgi->param('custnum')), + map { $_ => scalar($cgi->param("contactnum_$_")) } qw( first last ) + }); + $opt{'contact'} = $contact; + } + if ( $locationnum == -1 ) { - my $cust_location = new FS::cust_location { + my $cust_location = FS::cust_location->new({ map { $_ => scalar($cgi->param($_)) } - qw( custnum address1 address2 city county state zip country geocode ) - }; + ('custnum', FS::cust_main->location_fields) + }); $opt{'cust_location'} = $cust_location; + } else { + $opt{'locationnum'} = $locationnum; } $error = $cust_main->order_pkg( \%opt ); diff --git a/httemplate/edit/process/svc_acct.cgi b/httemplate/edit/process/svc_acct.cgi index 41aca65ee..d4bcd35ed 100755 --- a/httemplate/edit/process/svc_acct.cgi +++ b/httemplate/edit/process/svc_acct.cgi @@ -31,6 +31,11 @@ foreach (map { $_,$_."_threshold" } qw( upbytes downbytes totalbytes )) { $cgi->param($_, FS::UI::bytecount::parse_bytecount($cgi->param($_)) ); } +#for slipip, convert '(automatic)' to null +my $ip_addr = $cgi->param('slipip'); +$ip_addr =~ s/[^\d\.]//g; +$cgi->param('slipip', $ip_addr); + #unmunge cgp_accessmodes (falze laziness-ish w/part_svc.pm::process &svc_domain) unless ( $cgi->param('cgp_accessmodes') ) { $cgi->param('cgp_accessmodes', diff --git a/httemplate/edit/process/svc_phone.html b/httemplate/edit/process/svc_phone.html index 7a3b43d32..09398fdfb 100644 --- a/httemplate/edit/process/svc_phone.html +++ b/httemplate/edit/process/svc_phone.html @@ -2,6 +2,7 @@ 'table' => 'svc_phone', 'args_callback' => $args_callback, 'value_callback' => $value_callback, + 'edit_callback' => $edit_callback, %opt, &> <%init> @@ -28,6 +29,9 @@ my $right = $opt{'bulk'} ? 'Bulk provision customer service' die "access denied" unless $FS::CurrentUser::CurrentUser->access_right($right); +$cgi->param('phonenum', $cgi->param('phonenum_manual') ) + if $cgi->param('phonenum_which') eq 'phonenum_manual'; + my $tollfreephonenum = $cgi->param('tollfreephonenum'); $cgi->param('phonenum',$tollfreephonenum) if $tollfreephonenum =~ /^\d+$/; @@ -36,10 +40,10 @@ my $args_callback = sub { my %opt = (); if ( $cgi->param('locationnum') == -1 ) { - my $cust_location = new FS::cust_location { + my $cust_location = FS::cust_location->new({ map { $_ => scalar($cgi->param($_)) } qw( custnum address1 address2 city county state zip country ) - }; + }); $opt{'cust_location'} = $cust_location; } @@ -48,8 +52,13 @@ my $args_callback = sub { }; my $value_callback = sub { - my ($field, $value) = @_; - ($field =~ /_date$/) ? parse_datetime($value) : $value; + my ($field, $value) = @_; + ($field =~ /_date$/) ? parse_datetime($value) : $value; +}; + +my $edit_callback = sub { + my( $new, $old ) = @_; + $new->sip_password( $old->sip_password ) if $new->sip_password eq '*HIDDEN*'; }; </%init> diff --git a/httemplate/edit/process/upload_target.html b/httemplate/edit/process/upload_target.html new file mode 100644 index 000000000..8755bed56 --- /dev/null +++ b/httemplate/edit/process/upload_target.html @@ -0,0 +1,25 @@ +<& elements/process.html, + 'table' => 'upload_target', + 'viewall_dir' => 'browse', + 'agent_null' => 1, + 'precheck_callback'=> \&precheck, +&> +<%init> +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" + unless $curuser->access_right('Configuration'); + +sub precheck { + my $cgi = shift; + my $protocol = $cgi->param('protocol'); + # promote whatever set of fields was selected to the "real" values + my $params = $cgi->Vars; + foreach ( keys %$params ) { + if ( $_ =~ /^${protocol}_(\w+)/ ) { + $cgi->param($1, $cgi->param($_)); + } + } +} + +</%init> |