From 087c45b52363e519320eef20482ca94a7a8fb5f0 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Fri, 13 Nov 2015 17:46:33 -0600 Subject: [PATCH] RT#17480: Freeside Cancel Reason [missing file] --- httemplate/misc/reason-merge.html | 79 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 httemplate/misc/reason-merge.html diff --git a/httemplate/misc/reason-merge.html b/httemplate/misc/reason-merge.html new file mode 100644 index 000000000..a531e582c --- /dev/null +++ b/httemplate/misc/reason-merge.html @@ -0,0 +1,79 @@ +% if ($success) { +<% include('/elements/header-popup.html', 'Reason Merge Success') %> + +% } else { +<% include('/elements/header-popup.html', 'Merge Reasons') %> +% if ($error) { +

<% emt($error) %>

+% } +% if (@reasons > 1) { +

+The following reasons will be merged into one. +Please select one reason to merge the others into. +

+
"> +

+% foreach my $reason (@reasons) { + + +<% $reason->reason %>
+% } +

+

Caution: merging reasons cannot be undone!

+

+
+% } else { + +% } +% } + +<%init> +my @reasonnums = $cgi->param('reasonnum'); +my $destreasonnum = $cgi->param('destreasonnum'); + +my $error; +my $class; +my @reasons; +my $destreason; +foreach my $reasonnum (@reasonnums) { + unless ($reasonnum =~ /^\d+$/) { + $error = "Invalid reasonnum $reasonnum."; + last; + } + my $reason = qsearchs('reason',{ 'reasonnum' => $reasonnum }); + unless ($reason) { + $error = "Reason $reasonnum could not be loaded."; + last; + } + my $reasontype = $reason->reasontype; + $class ||= $reasontype->class; + if ($class ne $reasontype->class) { + $error = "Selected reasons must have the same reason type class."; + last; + } + push(@reasons, $reason); + $destreason = $reason if $reasonnum eq $destreasonnum; +} + +unless ($error) { + $error = "No reasons selected." unless @reasons; + $error = "Select two or more reasons to merge." unless @reasons > 1; +} + +@reasons = () if $error; + +my $success = 0; +if ($cgi->param('process_merge') && !$error) { + if ($destreason) { + $error = $destreason->merge(\@reasons); + $success = 1 unless $error; + } else { + $error = "No desitation reason selected."; + } +} + + -- 2.11.0