2 <SCRIPT TYPE="text/javascript">
3 function sh_add<% $name %>()
6 %if ($curuser->access_right($access_right)){
7 if (document.getElementById('<% $name %>').selectedIndex == 0){
8 <% $controlledbutton ? $controlledbutton.'.disabled = true;' : ';' %>
10 <% $controlledbutton ? $controlledbutton.'.disabled = false;' : ';' %>
13 if (document.getElementById('<% $name %>').selectedIndex ==
14 (document.getElementById('<% $name %>').length - 1)) {
15 document.getElementById('new<% $name %>').disabled = false;
16 document.getElementById('new<% $name %>').style.display = 'inline';
17 document.getElementById('new<% $name %>Label').style.display = 'inline';
18 document.getElementById('new<% $name %>T').disabled = false;
19 document.getElementById('new<% $name %>T').style.display = 'inline';
20 document.getElementById('new<% $name %>TLabel').style.display = 'inline';
22 document.getElementById('new<% $name %>').disabled = true;
23 document.getElementById('new<% $name %>').style.display = 'none';
24 document.getElementById('new<% $name %>Label').style.display = 'none';
25 document.getElementById('new<% $name %>T').disabled = true;
26 document.getElementById('new<% $name %>T').style.display = 'none';
27 document.getElementById('new<% $name %>TLabel').style.display = 'none';
36 <TD ALIGN="right">Reason</TD>
38 <SELECT id="<% $name %>" name="<% $name %>" onFocus="sh_add<% $name %>()" onChange="sh_add<% $name %>()">
39 % my @reasons = qsearch( { table =>'reason',
41 % extra_sql => $extra_sql,
42 % addl_from => 'LEFT JOIN reason_type ON reason_type.typenum = reason.reason_type',
44 <OPTION VALUE="" <% ($init_reason eq "") ? 'SELECTED' : '' %>>Select Reason...</OPTION>
45 % foreach my $reason (@reasons) {
46 <OPTION VALUE="<% $reason->reasonnum %>" <% ($init_reason == $reason->reasonnum) ? 'SELECTED' : '' %>><% $reason->reason %></OPTION>
48 % if ($curuser->access_right($access_right)) {
49 <OPTION VALUE="-1" <% ($init_reason == -1) ? 'SELECTED' : '' %>>Add new reason</OPTION>
58 <P id="new<% $name %>TLabel" style="display:<% $display %>">Reason Type</P>
61 <SELECT id="new<% $name %>T" name="new<% $name %>T" disabled="<% $disabled %>" style="display:<% $display %>">
62 % for my $type (qsearch( 'reason_type', { 'class' => $class } )){
63 <OPTION VALUE="<% $type->typenum %>" <% ($init_type == $type->typenum) ? 'SELECTED' : '' %>><% $type->type %></OPTION>
71 <P id="new<% $name %>Label" style="display:<% $display %>">New Reason</P>
73 <TD><INPUT id="new<% $name %>" name="new<% $name %>" type="text" value="<% $init_newreason %>" disabled="<% $disabled %>" style="display:<% $display %>"></TD>
77 my($name, $class, $init_reason, $init_type, $init_newreason, $controlledbutton) = @_;
78 my($extra_sql, $curuser, $access_right, $display, $disabled);
81 $access_right='Add on-the-fly cancel reason';
82 }elsif ($class eq 'S') {
83 $access_right='Add on-the-fly suspend reason';
85 print "illegal class: $class";
88 if ($init_reason == -1){
96 $extra_sql = "WHERE class = '$class' ORDER BY reason_type";
97 $curuser = $FS::CurrentUser::CurrentUser;