import rt 2.0.14
[freeside.git] / rt / webrt / Admin / Elements / ModifyKeywordSelect
1   <FORM NAME="ModifyKeywordSelect" METHOD=POST ACTION="<%$RT::WebPath%>/Admin/KeywordSelects/Modify.html">
2
3     [<%$title |n %>]
4     <BR>
5       
6       <INPUT TYPE="hidden" NAME="id" VALUE="<% $id %>">
7         Keyword 
8         <SELECT NAME="Parent">
9           
10 %while ( $parent = $parents->Next ) {
11           
12           <OPTION VALUE="<% $parent->id %>" <% defined($KeywordSelect->Parent) && $parent->id == $KeywordSelect->Parent ? ' SELECTED' : '' %>><% $parent->Name %></OPTION>
13           
14 % }
15           
16         </SELECT>
17         <BR>
18           Object 
19           <SELECT NAME="ObjectType">
20             <OPTION SELECTED>Ticket</OPTION>
21           </SELECT>
22           <BR>
23             
24 <SCRIPT>
25 function addOption(text, value, defaultselected, selected) {
26   var option = new Option(text, value, defaultselected, selected )
27   var length = document.ModifyKeywordSelect.ObjectValue.length;
28   document.ModifyKeywordSelect.ObjectValue.options[length] = option
29 }
30 function ChangeObjectValue(what) {
31   Value = what.options[what.selectedIndex].value
32   if ( Value == "(none)" ) {
33     document.ModifyKeywordSelect.ObjectValue.options.length = 0
34     addOption("(n/a)", "", false, false)
35   }
36   if ( Value == "Queue" ) {
37     document.ModifyKeywordSelect.ObjectValue.options.length = 0
38 %foreach $queue ( keys %queues ) {
39     addOption("<% $queues{$queue} %>", "<% $queue %>", false, <% $queue == $KeywordSelect->ObjectValue ? 'true' : 'false' %> )
40 %}
41   }
42 }
43 </SCRIPT>
44             
45             Limit to <SELECT NAME="ObjectField" onChange="ChangeObjectValue(this)">
46               <OPTION VALUE="" <% $KeywordSelect->ObjectField ? '' : ' SELECTED' %>>(none)</OPTION>
47               <OPTION VALUE="Queue" <% $KeywordSelect->ObjectField eq 'Queue' ? ' SELECTED' : '' %>>Queue</OPTION>
48             </SELECT> 
49             <SELECT NAME="ObjectValue">
50               <OPTION VALUE="<% $KeywordSelect->ObjectValue %>">
51                 <% $KeywordSelect->ObjectField ? $queues{$KeywordSelect->ObjectValue} : "(n/a)" %></OPTION>
52             </SELECT><BR>
53               <INPUT TYPE="hidden" NAME="SingleMagic" VALUE="1">
54                 <INPUT TYPE="checkbox" NAME="Single" VALUE="1" <% $KeywordSelect->Single ? ' CHECKED' : '' %>>Allow single selection only<BR>
55                     Limit to <INPUT TYPE="text" NAME="Generations" SIZE="2" VALUE="<% $KeywordSelect->Generations %>"> generations (0 = no limit)<BR>
56                         <& /Elements/Submit, Label => $submit &>
57
58 </FORM>
59
60 <%INIT>
61
62
63 my $KeywordSelect = new RT::KeywordSelect($session{CurrentUser});
64   
65 my($title, $submit);
66   
67 if ( $Create ) {
68       $title = "Create a new KeywordSelect";
69       $submit = "Create";
70       $id = "new";
71 } else {
72     if  ( $id eq 'new' ) {
73         $id = $KeywordSelect->Create (
74                                       Parent      => $Parent,
75                                       ObjectType  => $ObjectType,
76                                       ObjectField => $ObjectField,
77                                       ObjectValue => $ObjectValue,
78                                       Single      => $Single,
79                                       Generations => $Generations,
80                                      ) or Abort "can't create KeywordSelect";
81     } else {
82         $KeywordSelect->Load($id) || Abort("Can't load keyword id $id");
83         #false laziness
84         $KeywordSelect->SetParent($Parent) if defined($Parent);
85         $KeywordSelect->SetObjectType($ObjectType) if defined($ObjectType);
86         $KeywordSelect->SetObjectField($ObjectField) if defined($ObjectField);
87         $KeywordSelect->SetObjectValue($ObjectValue) if defined($ObjectValue);
88         $KeywordSelect->SetSingle($Single) if defined($SingleMagic);
89         $KeywordSelect->SetGenerations($Generations) if defined($Generations);
90     }
91     $title = "Modify the KeywordSelect <B>". $KeywordSelect->KeywordObj->Name. "</B>";
92     $submit = "Modify";
93     
94 }
95   
96   my $parents = new RT::Keywords($session{CurrentUser});
97   $parents->UnLimit;
98   my $parent;
99
100 my $queues = new RT::Queues($session{CurrentUser});
101 $queues->UnLimit;
102
103 my %queues;
104 my $queue;
105 $queues{$queue->id} = $queue->Name while $queue = $queues->Next;
106
107 </%INIT>
108
109 <%ARGS>
110 $id => undef
111 $Create => undef
112 $Parent => undef
113 $ObjectType => undef
114 $ObjectField => undef
115 $ObjectValue => undef
116 $Single => undef
117 $SingleMagic => undef
118 $Generations => undef
119 </%ARGS>
120