2 <% include('/elements/header-popup.html', 'Reason Merge Success') %>
4 window.top.location.reload()
7 <% include('/elements/header-popup.html', 'Merge Reasons') %>
9 <P STYLE="color: red;"><% emt($error) %></P>
13 The following reasons will be merged into one.
14 Please select one reason to merge the others into.
16 <FORM METHOD="POST" ACTION="<% "${p}misc/reason-merge.html" %>">
18 % foreach my $reason (@reasons) {
19 <INPUT TYPE="hidden" NAME="reasonnum" VALUE="<% $reason->reasonnum %>">
20 <INPUT TYPE="radio" NAME="destreasonnum" VALUE="<% $reason->reasonnum %>">
21 <% $reason->reason %><BR>
24 <P>Caution: merging reasons cannot be undone!</P>
25 <P><INPUT TYPE="submit" NAME="process_merge" value="Merge"></P>
28 <BUTTON TYPE="button" onClick="parent.cClick();">Close</BUTTON>
33 my @reasonnums = $cgi->param('reasonnum');
34 my $destreasonnum = $cgi->param('destreasonnum');
40 foreach my $reasonnum (@reasonnums) {
41 unless ($reasonnum =~ /^\d+$/) {
42 $error = "Invalid reasonnum $reasonnum.";
45 my $reason = qsearchs('reason',{ 'reasonnum' => $reasonnum });
47 $error = "Reason $reasonnum could not be loaded.";
50 my $reasontype = $reason->reasontype;
51 $class ||= $reasontype->class;
52 if ($class ne $reasontype->class) {
53 $error = "Selected reasons must have the same reason type class.";
56 push(@reasons, $reason);
57 $destreason = $reason if $reasonnum eq $destreasonnum;
61 $error = "No reasons selected." unless @reasons;
62 $error = "Select two or more reasons to merge." unless @reasons > 1;
65 @reasons = () if $error;
68 if ($cgi->param('process_merge') && !$error) {
70 $error = $destreason->merge(\@reasons);
71 $success = 1 unless $error;
73 $error = "No destination reason selected.";