summaryrefslogtreecommitdiff
path: root/httemplate/edit/process
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/edit/process')
-rw-r--r--httemplate/edit/process/access_user.html28
-rw-r--r--httemplate/edit/process/cust_main-contacts.html2
-rwxr-xr-xhttemplate/edit/process/cust_refund.cgi46
-rw-r--r--httemplate/edit/process/elements/process.html23
-rwxr-xr-xhttemplate/edit/process/part_pkg.cgi33
-rw-r--r--httemplate/edit/process/saved_search.html2
-rw-r--r--httemplate/edit/process/tower.html2
7 files changed, 100 insertions, 36 deletions
diff --git a/httemplate/edit/process/access_user.html b/httemplate/edit/process/access_user.html
index fcd210f83..c27262017 100644
--- a/httemplate/edit/process/access_user.html
+++ b/httemplate/edit/process/access_user.html
@@ -11,7 +11,7 @@
'target_table' => 'access_group',
},
'precheck_callback' => \&precheck_callback,
- #'post_new_object_callback' => \&post_new_object_callback,
+ 'post_new_object_callback' => \&post_new_object_callback,
'noerror_callback' => \&noerror_callback,
)
%>
@@ -38,24 +38,22 @@ sub precheck_callback {
return '';
}
-#sub post_new_object_callback {
-# my( $cgi, $access_user ) = @_;
-#
-# if ( length($cgi->param('_password')) ) {
-# my $password = scalar($cgi->param('_password'));
-# my $error = $access_user->is_password_allowed($password);
-# #XXX and then bubble the error back up to the UI
-# }
-#}
+sub post_new_object_callback {
+ my( $cgi, $access_user ) = @_;
+
+ return '' unless length($cgi->param('_password'));
+
+ my $password = scalar($cgi->param('_password'));
+ my $error = $access_user->is_password_allowed($password);
+ return $error if $error;
+
+ $access_user->change_password_fields($password);
+ '';
+}
sub noerror_callback {
my( $cgi, $access_user ) = @_;
- if ( length($cgi->param('_password')) ) {
- my $password = scalar($cgi->param('_password'));
- $access_user->change_password($password);
- }
-
#handle installer checkbox
my @sched_item = $access_user->sched_item;
my $sched_item = $sched_item[0];
diff --git a/httemplate/edit/process/cust_main-contacts.html b/httemplate/edit/process/cust_main-contacts.html
index 5b8319f5a..6b7f1c2db 100644
--- a/httemplate/edit/process/cust_main-contacts.html
+++ b/httemplate/edit/process/cust_main-contacts.html
@@ -8,7 +8,7 @@
</%doc>
<% include('elements/process.html',
'table' => 'cust_main',
- 'error_redirect' => popurl(3). 'edit/cust_main-contacts.html?',
+ 'error_redirect' => popurl(3). 'edit/cust_main-contacts.html',
'agent_virt' => 1,
'skip_process' => 1, #we don't want to make any changes to cust_main
'precheck_callback' => $precheck_callback,
diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi
index 0a3d55036..1f96456e0 100755
--- a/httemplate/edit/process/cust_refund.cgi
+++ b/httemplate/edit/process/cust_refund.cgi
@@ -53,7 +53,7 @@ if ( $error ) {
'CHEK' => 'electronic check (ACH)',
);
-my( $cust_payby, $payinfo, $paycvv, $month, $year, $payname );
+my( $cust_pay, $cust_payby, $payinfo, $paycvv, $month, $year, $payname );
my $paymask = '';
if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
@@ -71,6 +71,18 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
$paycvv = $cust_payby->paycvv; # pass it if we got it, running a transaction will clear it
( $month, $year ) = $cust_payby->paydate_mon_year;
$payname = $cust_payby->payname;
+ $cgi->param(-name=>"paytype", -value=>$cust_payby->paytype) unless $cgi->param("paytype");
+
+} elsif ( $cgi->param('paynum') > 0) {
+
+ $cust_pay = qsearchs({
+ 'table' => 'cust_pay',
+ 'hashref' => { 'paynum' => $cgi->param('paynum') },
+ 'select' => 'cust_pay.*, cust_pay_batch.payname ',
+ 'addl_from' => "left join cust_pay_batch on cust_pay_batch.batchnum = cust_pay.batchnum and cust_pay_batch.custnum = $custnum ",
+ });
+ $payinfo = $cust_pay->payinfo;
+ $payname = $cust_pay->payname;
} else {
@@ -192,16 +204,19 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
my $refund = "$1$2";
$cgi->param('paynum') =~ /^(\d*)$/ or die "Illegal paynum!";
my $paynum = $1;
- my $paydate = $cgi->param('exp_year'). '-'. $cgi->param('exp_month'). '-01';
- $options{'paydate'} = $paydate if $paydate =~ /^\d{2,4}-\d{1,2}-01$/;
+ my $paydate;
+ unless ($paynum) {
+ if ($cust_payby->paydate) { $paydate = "$year-$month-01"; }
+ else { $paydate = "2037-12-01"; }
+ }
if ( $cgi->param('batch') ) {
-
+ $paydate = "2037-12-01" unless $paydate;
$error ||= $cust_main->batch_card(
'payby' => $payby,
'amount' => $refund,
'payinfo' => $payinfo,
- 'paydate' => "$year-$month-01",
+ 'paydate' => $paydate,
'payname' => $payname,
'paycode' => 'C',
map { $_ => scalar($cgi->param($_)) }
@@ -209,28 +224,23 @@ if ( (my $custpaybynum = scalar($cgi->param('custpaybynum'))) > 0 ) {
);
errorpage($error) if $error;
-#### post refund #####
my %hash = map {
$_, scalar($cgi->param($_))
} fields('cust_refund');
- $paynum = $cgi->param('paynum');
- $paynum =~ /^(\d*)$/ or die "Illegal paynum!";
- if ($paynum) {
- my $cust_pay = qsearchs('cust_pay',{ 'paynum' => $paynum });
- die "Could not find paynum $paynum" unless $cust_pay;
- $error = $cust_pay->refund(\%hash);
- } else {
- my $new = new FS::cust_refund ( \%hash );
- $error = $new->insert;
- }
- # if not a batch refund run realtime.
+
+ my $new = new FS::cust_refund ( { 'paynum' => $paynum,
+ %hash,
+ } );
+ $error = $new->insert;
+
+ # if not a batch refund run realtime.
} else {
$error = $cust_main->realtime_refund_bop( $bop, 'amount' => $refund,
'paynum' => $paynum,
'reasonnum' => scalar($cgi->param('reasonnum')),
%options );
}
-} else {
+} else { # run cash refund.
my %hash = map {
$_, scalar($cgi->param($_))
} fields('cust_refund');
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 76722c960..d2b037053 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -80,8 +80,12 @@ Example:
'precheck_callback' => sub { my( $cgi ) = @_; },
#after the new object is created
+ #return an error string or empty for no error
'post_new_object_callback' => sub { my( $cgi, $object ) = @_; },
+ #run right before replacing (not run for inserts)
+ 'edit_callback' => sub { my( $new, $old ) = @_; },
+
#after everything's inserted
'noerror_callback' => sub { my( $cgi, $object ) = @_; },
@@ -89,6 +93,9 @@ Example:
# for use with tables that are FS::option_Common (among other things)
'args_callback' => sub { my( $cgi, $object ) = @_; },
+ # if no errors after package insert or replace will update services attached to package.
+ 'update_svc' => sub { my( $cgi, $object ) = @_; },
+
'debug' => 1, #turns on debugging output
#agent virtualization
@@ -273,7 +280,7 @@ foreach my $value ( @values ) {
}
if ( $opt{'post_new_object_callback'} ) {
- &{ $opt{'post_new_object_callback'} }( $cgi, $new );
+ $error ||= &{ $opt{'post_new_object_callback'} }( $cgi, $new );
}
if ( $opt{'agent_virt'} ) {
@@ -438,6 +445,12 @@ foreach my $value ( @values ) {
}
}
+ if ( !$error and $opt{'update_svc'} ) {
+ my @args = ();
+ @args = &{ $opt{'args_callback'} }( $cgi, $new ) if $opt{'args_callback'};
+ $error = &{ $opt{'update_svc'} }( $cgi, $new, @args );
+ }
+
if ( $error ) {
$cgi->param('error', $error);
@@ -459,6 +472,14 @@ foreach my $value ( @values ) {
}
+if ($class eq "FS::tower") {
+ foreach my $part_svc_broadband_export ( FS::tower_sector->part_export_svc_broadband ) {
+ if ($part_svc_broadband_export and $part_svc_broadband_export->can('export_tower_sector')) {
+ $error = $part_svc_broadband_export->export_tower_sector($new);
+ }
+ }
+}
+
# set up redirect URLs
my $redirect;
diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi
index c4d150ba1..376491089 100755
--- a/httemplate/edit/process/part_pkg.cgi
+++ b/httemplate/edit/process/part_pkg.cgi
@@ -9,6 +9,7 @@
'edit_ext' => 'cgi',
'precheck_callback' => $precheck_callback,
'args_callback' => $args_callback,
+ 'update_svc' => $update_svc,
'process_locale' => 'pkg',
'process_m2m' => \@process_m2m,
'process_o2m' => \@process_o2m,
@@ -199,6 +200,38 @@ my $args_callback = sub {
};
+## update services upon package change.
+my $update_svc = sub {
+ my $cgi = shift @_;
+ my $new = shift @_;
+ my %args = @_;
+ my $error;
+
+ my @svcs = $new->pkg_svc();
+
+## update broadband services getting their up and down speeds from package fcc_477 options
+ foreach my $svc_part(@svcs) {
+ my @part_svc_column = qsearch('part_svc_column',{ 'svcpart' => $svc_part->{Hash}->{svcpart}, 'columnflag' => 'P' });
+
+ if ($svc_part->{Hash}->{svcdb} eq "svc_broadband" && (keys %{ $args{fcc_options} }) && @part_svc_column ) {
+ ## find provisioned services to update
+ my @svc_svcdb = qsearch({
+ 'table' => 'svc_broadband',
+ 'select' => 'svc_broadband.*, cust_svc.svcpart',
+ 'addl_from' => 'LEFT JOIN cust_svc USING (svcnum) LEFT JOIN cust_pkg USING (pkgnum)',
+ 'extra_sql' => " WHERE cust_svc.svcpart = '".$svc_part->{Hash}->{svcpart}."' AND cust_pkg.pkgpart = '".$svc_part->{Hash}->{pkgpart}."'",
+ });
+ foreach my $svc (@svc_svcdb) {
+ next if ($svc->{Hash}->{speed_down} == $args{fcc_options}->{broadband_downstream} * 1000 && $svc->{Hash}->{speed_up} == $args{fcc_options}->{broadband_upstream} * 1000);
+ $svc->{Hash}->{speed_down} = $args{fcc_options}->{broadband_downstream} * 1000;
+ $svc->{Hash}->{speed_up} = $args{fcc_options}->{broadband_upstream} * 1000;
+ $error = $svc->replace();
+ }
+ }
+ }
+ return $error;
+};
+
my $redirect_callback = sub {
#my( $cgi, $new ) = @_;
return '' unless $custnum;
diff --git a/httemplate/edit/process/saved_search.html b/httemplate/edit/process/saved_search.html
index 7ae7e0d78..51e40edad 100644
--- a/httemplate/edit/process/saved_search.html
+++ b/httemplate/edit/process/saved_search.html
@@ -10,6 +10,8 @@ my $callback = sub {
$obj->usernum( $FS::CurrentUser::CurrentUser->usernum );
# if this would change it from its existing owner, replace_check
# will refuse
+
+ ''; #no error
};
</%init>
diff --git a/httemplate/edit/process/tower.html b/httemplate/edit/process/tower.html
index cfbb4ffa3..8f62c4bec 100644
--- a/httemplate/edit/process/tower.html
+++ b/httemplate/edit/process/tower.html
@@ -6,7 +6,7 @@
sectorname ip_addr height freq_mhz direction width
downtilt v_width db_high db_low power line_loss
antenna_gain hardware_typenum
- sector_range
+ sector_range up_rate_limit down_rate_limit
)],
},
&>