summaryrefslogtreecommitdiff
path: root/httemplate/edit/process
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-10-13 10:10:40 -0700
committerIvan Kohler <ivan@freeside.biz>2015-10-13 10:10:40 -0700
commit2b2dd969f3c18751afc583ad1e836ab8e6f73b5d (patch)
tree72ad19092f9d3a5118add9a55067b8a97c168f46 /httemplate/edit/process
parentd31d59c63c8f4dfd52ca19a02ffcf32fcf49f497 (diff)
parentcd468ecb9a321ca96254b7204f6dc193b11cd903 (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'httemplate/edit/process')
-rw-r--r--httemplate/edit/process/change-cust_pkg.html39
-rwxr-xr-xhttemplate/edit/process/cust_credit_bill.cgi3
-rwxr-xr-xhttemplate/edit/process/cust_refund.cgi31
-rw-r--r--httemplate/edit/process/deploy_zone-fixed.html35
-rw-r--r--httemplate/edit/process/deploy_zone-mobile.html19
-rw-r--r--httemplate/edit/process/elements/process.html23
-rw-r--r--httemplate/edit/process/msg_template.html18
-rw-r--r--httemplate/edit/process/rate_detail.html1
8 files changed, 135 insertions, 34 deletions
diff --git a/httemplate/edit/process/change-cust_pkg.html b/httemplate/edit/process/change-cust_pkg.html
index 046a9795c..308ea8ffd 100644
--- a/httemplate/edit/process/change-cust_pkg.html
+++ b/httemplate/edit/process/change-cust_pkg.html
@@ -59,6 +59,40 @@ unless ($error) {
$error = $cust_pkg->change_later(\%change);
}
} else {
+
+ # for now, can't change usageprice with change_later
+ my @old_cust_pkg_usageprice = $cust_pkg->cust_pkg_usageprice;
+
+ # build new usageprice array
+ # false laziness with /edit/process/quick-cust_pkg.cgi
+ my @cust_pkg_usageprice = ();
+ foreach my $quantity_param ( grep { $cgi->param($_) && $cgi->param($_) > 0 }
+ grep /^usagepricenum(\d+)_quantity$/,
+ $cgi->param
+ )
+ {
+ $quantity_param =~ /^usagepricenum(\d+)_quantity$/ or die 'unpossible';
+ my $num = $1;
+ push @cust_pkg_usageprice, new FS::cust_pkg_usageprice {
+ usagepricepart => scalar($cgi->param("usagepricenum${num}_usagepricepart")),
+ quantity => scalar($cgi->param($quantity_param)),
+ };
+ }
+
+ # Need to figure out if usagepricepart quantities changed
+ my %oldup = map { $_->usagepricepart, $_->quantity } @old_cust_pkg_usageprice;
+ my %newup = map { $_->usagepricepart, $_->quantity } @cust_pkg_usageprice;
+ my $usagechanged = 0;
+ foreach my $up (keys %oldup) {
+ last if $usagechanged;
+ $usagechanged = 1 unless $oldup{$up} == $newup{$up};
+ }
+ foreach my $up (keys %newup) {
+ last if $usagechanged;
+ $usagechanged = 1 unless $oldup{$up} == $newup{$up};
+ }
+ $change{'cust_pkg_usageprice'} = \@cust_pkg_usageprice;
+
# special case: if there's a package change scheduled, and it matches
# the parameters the user requested this time, then change to the existing
# future package.
@@ -68,12 +102,13 @@ unless ($error) {
$change_to->pkgpart == $change{'pkgpart'} and
$change_to->locationnum == $change{'locationnum'} and
$change_to->quantity == $change{'quantity'} and
- $change_to->contract_end == $change{'contract_end'}
+ $change_to->contract_end == $change{'contract_end'} and
+ !$usagechanged
) {
%change = ( 'cust_pkg' => $change_to );
}
}
-
+
# do a package change right now
my $pkg_or_error = $cust_pkg->change( \%change );
$error = ref($pkg_or_error) ? '' : $pkg_or_error;
diff --git a/httemplate/edit/process/cust_credit_bill.cgi b/httemplate/edit/process/cust_credit_bill.cgi
index d3847dc40..db15eac18 100755
--- a/httemplate/edit/process/cust_credit_bill.cgi
+++ b/httemplate/edit/process/cust_credit_bill.cgi
@@ -12,8 +12,7 @@ die "access denied"
if ( $cgi->param('src_amount') ) {
die "access denied"
- unless ( $FS::CurrentUser::CurrentUser->access_right('Post credit') &&
- $FS::CurrentUser::CurrentUser->access_right('Delete credit') );
+ unless $FS::CurrentUser::CurrentUser->access_right('Post credit')
}
</%init>
diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi
index 52fede8ec..6ad468b6c 100755
--- a/httemplate/edit/process/cust_refund.cgi
+++ b/httemplate/edit/process/cust_refund.cgi
@@ -12,7 +12,7 @@
</BODY></HTML>
% } else {
-<% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum") %>
+<% $cgi->redirect(popurl(3). "view/cust_main.cgi?custnum=$custnum;show=payment_history") %>
% }
%}
<%init>
@@ -30,16 +30,8 @@ my $link = $cgi->param('popup') ? 'popup' : '';
my $payby = $cgi->param('payby');
-my @rights = ();
-push @rights, 'Post refund' if $payby =~ /^(BILL|CASH|MCRD|MCHK)$/;
-push @rights, 'Post check refund' if $payby eq 'BILL';
-push @rights, 'Post cash refund ' if $payby eq 'CASH';
-push @rights, 'Refund payment' if $payby =~ /^(CARD|CHEK)$/;
-push @rights, 'Refund credit card payment' if $payby eq 'CARD';
-push @rights, 'Refund Echeck payment' if $payby eq 'CHEK';
-
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
+ unless $FS::CurrentUser::CurrentUser->refund_access_right($payby);
$cgi->param('reasonnum') =~ /^(-?\d+)$/ or die "Illegal reasonnum";
my ($reasonnum, $error) = $m->comp('/misc/process/elements/reason');
@@ -63,12 +55,19 @@ if ( $error ) {
'reason' => $reason,
%options );
} else {
- my $new = new FS::cust_refund ( {
- map {
- $_, scalar($cgi->param($_));
- } fields('cust_refund') #huh? , 'paynum' )
- } );
- $error = $new->insert;
+ my %hash = map {
+ $_, scalar($cgi->param($_))
+ } fields('cust_refund');
+ my $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;
+ }
}
</%init>
diff --git a/httemplate/edit/process/deploy_zone-fixed.html b/httemplate/edit/process/deploy_zone-fixed.html
index eae3a746d..0033bbe52 100644
--- a/httemplate/edit/process/deploy_zone-fixed.html
+++ b/httemplate/edit/process/deploy_zone-fixed.html
@@ -3,12 +3,31 @@
error_redirect => popurl(2).'deploy_zone-fixed.html',
table => 'deploy_zone',
viewall_dir => 'browse',
- process_o2m => {
- 'table' => 'deploy_zone_block',
- 'fields' => [qw( censusblock censusyear )]
- },
- process_upload => {
- 'process' => 'misc/process/deploy_zone-import.html',
- 'fields' => [qw( censusyear format )],
- },
+ precheck_callback => $precheck_callback,
+ process_o2m =>
+ { 'table' => 'deploy_zone_vertex',
+ 'fields' => [qw( latitude longitude )]
+ },
+ progress_init => [
+ 'PostForm',
+ [ 'zonenum' ],
+ $fsurl.'misc/process/deploy_zone-block_lookup.cgi',
+ $fsurl.'browse/deploy_zone.html',
+ ],
&>
+<%init>
+my $precheck_callback = sub {
+ # convert the vertex list into a process_o2m-style parameter list
+ if ( $cgi->param('vertices') ) {
+ my $vertices = decode_json($cgi->param('vertices'));
+ my $i = 0;
+ foreach (@$vertices) {
+ $cgi->param("vertexnum${i}", '');
+ $cgi->param("vertexnum${i}_latitude", $_->[0]);
+ $cgi->param("vertexnum${i}_longitude", $_->[1]);
+ $i++;
+ }
+ }
+ '';
+};
+</%init>
diff --git a/httemplate/edit/process/deploy_zone-mobile.html b/httemplate/edit/process/deploy_zone-mobile.html
index 7b8f911ec..d36d5d448 100644
--- a/httemplate/edit/process/deploy_zone-mobile.html
+++ b/httemplate/edit/process/deploy_zone-mobile.html
@@ -2,8 +2,25 @@
error_redirect => popurl(2).'deploy_zone-mobile.html',
table => 'deploy_zone',
viewall_dir => 'browse',
- process_o2m =>
+ precheck_callback => $precheck_callback,
+ process_o2m =>
{ 'table' => 'deploy_zone_vertex',
'fields' => [qw( latitude longitude )]
},
&>
+<%init>
+my $precheck_callback = sub {
+ # convert the vertex list into a process_o2m-style parameter list
+ if ( $cgi->param('vertices') ) {
+ my $vertices = decode_json($cgi->param('vertices'));
+ my $i = 0;
+ foreach (@$vertices) {
+ $cgi->param("vertexnum${i}", '');
+ $cgi->param("vertexnum${i}_latitude", $_->[0]);
+ $cgi->param("vertexnum${i}_longitude", $_->[1]);
+ $i++;
+ }
+ }
+ '';
+};
+</%init>
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index 69bd605f6..fd12c61d9 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -160,7 +160,28 @@ process();
</script>
<& /elements/footer.html &>
-%} elsif ( $opt{'popup_reload'} ) {
+% } elsif ( $opt{'progress_init'} ) {
+% # some false laziness with the above
+% my ($form_name, $job_fields) = @{ $opt{'progress_init'} };
+<form name="<% $form_name %>">
+ <input type="hidden" name="<% $pkey %>" value="<% $new->get($pkey) %>">
+% foreach my $field (@$job_fields) {
+% next if $field eq $pkey;
+ <input type="hidden" name="<% $field %>" value="<% $cgi->param($field) |h %>">
+% }
+<& /elements/progress-init.html,
+ @{ $opt{'progress_init'} }
+&>
+<input type="submit" style="display:none">
+</form>
+<script>
+<&| /elements/onload.js &>
+process();
+</&>
+</script>
+<& /elements/footer.html &>
+
+% } elsif ( $opt{'popup_reload'} ) {
<% include('/elements/header-popup.html', $opt{'popup_reload'} ) %>
diff --git a/httemplate/edit/process/msg_template.html b/httemplate/edit/process/msg_template.html
index e146adf76..d8b125ae0 100644
--- a/httemplate/edit/process/msg_template.html
+++ b/httemplate/edit/process/msg_template.html
@@ -1,7 +1,7 @@
<% include( 'elements/process.html',
'table' => 'msg_template',
- 'viewall_dir' => 'browse',
- #'popup_reload'=> 1,
+ 'fields' => $fields,
+ 'viewall_url' => "browse/msg_template/$msgclass.html",
'debug' => 0,
'precheck_callback' => \&precheck_callback,
'args_callback' => \&args_callback,
@@ -11,9 +11,21 @@
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right(['Edit templates','Edit global templates']);
+my $msgclass = 'email';
+if ( $cgi->param('msgclass') =~ /^(\w+)$/ ) {
+ $msgclass = $1;
+}
+
+my $fields = [ fields('msg_template') ];
+my $class = "FS::msg_template::$msgclass";
+eval "use $class;";
+if ( $class->extension_table ) {
+ push @$fields, fields($class->extension_table);
+}
+
sub precheck_callback {
my $cgi = shift;
- # validate some fields
+ # validate locale field (for email-type records)
$cgi->param('locale') =~ /^(\w*)$/;
my $locale = $1;
return mt('Language required') if $locale eq 'new'; # the user didn't choose
diff --git a/httemplate/edit/process/rate_detail.html b/httemplate/edit/process/rate_detail.html
index 0709d5079..f8a744418 100644
--- a/httemplate/edit/process/rate_detail.html
+++ b/httemplate/edit/process/rate_detail.html
@@ -12,7 +12,6 @@ die "access denied"
my $set_default_detail = sub {
my ($cgi, $rate_detail) = @_;
-warn Dumper $rate_detail;
if (!$rate_detail->dest_regionnum) {
# then this is a global default rate
my $rate = $rate_detail->rate;