summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-11-13 17:46:33 -0600
committerJonathan Prykop <jonathan@freeside.biz>2015-11-16 19:36:55 -0600
commitd8e06c995fcadacb3e06ba67ffcfe6d63109e2f7 (patch)
tree28a6d6b62b476065ec3bec0a1d4db53db330ea6a
parent831946cfe0fed362f6639d848714728ee5e40cf8 (diff)
RT#17480: Freeside Cancel Reason [missing file]
-rw-r--r--httemplate/misc/reason-merge.html79
1 files changed, 79 insertions, 0 deletions
diff --git a/httemplate/misc/reason-merge.html b/httemplate/misc/reason-merge.html
new file mode 100644
index 0000000..a531e58
--- /dev/null
+++ b/httemplate/misc/reason-merge.html
@@ -0,0 +1,79 @@
+% if ($success) {
+<% include('/elements/header-popup.html', 'Reason Merge Success') %>
+<SCRIPT>
+<!--
+window.top.location.reload()
+-->
+</SCRIPT>
+% } else {
+<% include('/elements/header-popup.html', 'Merge Reasons') %>
+% if ($error) {
+<P STYLE="color: red;"><% emt($error) %></P>
+% }
+% if (@reasons > 1) {
+<P>
+The following reasons will be merged into one.
+Please select one reason to merge the others into.
+</P>
+<FORM METHOD="POST" ACTION="<% "${p}misc/reason-merge.html" %>">
+<P>
+% foreach my $reason (@reasons) {
+<INPUT TYPE="hidden" NAME="reasonnum" VALUE="<% $reason->reasonnum %>">
+<INPUT TYPE="radio" NAME="destreasonnum" VALUE="<% $reason->reasonnum %>">
+<% $reason->reason %><BR>
+% }
+<P>
+<P>Caution: merging reasons cannot be undone!</P>
+<P><INPUT TYPE="submit" NAME="process_merge" value="Merge"></P>
+</FORM>
+% } else {
+<BUTTON TYPE="button" onClick="parent.cClick();">Close</BUTTON>
+% }
+% }
+
+<%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.";
+ }
+}
+
+</%init>