Subversion Repositories VORC

Rev

Rev 56 | Rev 99 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 56 Rev 98
Line 31... Line 31...
31
my $noshow = param ('noshow');
31
my $noshow = param ('noshow');
32
my $department = ($id =~ /^\d+$/) ? getShiftDepartment ($role ? $id."-".$role : $id) : "CLA";
32
my $department = ($id =~ /^\d+$/) ? getShiftDepartment ($role ? $id."-".$role : $id) : "CLA";
Line 33... Line 33...
33
 
33
 
Line -... Line 34...
-
 
34
print start_html (-title => "vORC Make Shift Change", -style => {'src' => "/style.css"}), $h->open ("body");
Line 34... Line 35...
34
print start_html (-title => "vORC Make Shift Change", -style => {'src' => "/style.css"}), $h->open ("body");
35
 
35
 
36
my $WARNING = getUser ($RCid) ? "" : $h->p ({ class => "error" }, "User [$RCid] Not Found!");
36
 
37
 
37
if ($change eq "lookup") {
38
if ($change eq "lookup" or $WARNING) {
38
	if (convertDepartments($user->{department})->{$department} < 2 and $LVL < 5 and convertDepartments($user->{department})->{VCI} < 2) {
39
	if (convertDepartments($user->{department})->{$department} < 2 and $LVL < 5 and convertDepartments($user->{department})->{VCI} < 2) {
39
    print $h->div ({ class=>"error" }, "You're not allowed to change other people's schedules.");
40
    print $h->div ({ class=>"error" }, "You're not allowed to change other people's schedules.");
Line 40... Line 41...
40
    print $h->close ("body"), $h->close ("html");
41
    print $h->close ("body"), $h->close ("html");
Line 41... Line 42...
41
	  die;
42
	  exit;
42
	}
43
	}
43
	
44
	
44
	my $options = fetchDerbyNameWithRCid ($department);
45
	my $options = fetchDerbyNameWithRCid ({ DATALIST=>1 }, $department);
45
  
46
  
-
 
47
  print $WARNING, $h->form ({ action=>url }, [
46
  print $h->form ({ action=>url }, [
48
    $h->input ({ type=>"hidden", name=>"change", value=>"add" }),
47
    $h->input ({ type=>"hidden", name=>"change", value=>"add" }),
49
    $h->input ({ type=>"hidden", name=>"id", value=>$id }),
48
    $h->input ({ type=>"hidden", name=>"id", value=>$id }),
50
    $h->input ({ type=>"hidden", name=>"role", value=>$role }),
49
    $h->input ({ type=>"hidden", name=>"role", value=>$role }),
51
    $department eq "CLA" ? $h->p ("Add User to Class ($id):") : $h->p ("Add User to Shift ($id):"),
-
 
52
    $h->input ({ name => "RCid-picker", id=>"pickname", list => "eligibleusers" }).$h->datalist ({ id => "eligibleusers" }, [$options]),
-
 
53
    $h->input ({ type=>"hidden", name=>"RCid", id=>"pickname-hidden" }),
-
 
54
    $h->input ({ type=>"submit", value=>"Save", onClick=>"if (isInt(document.getElementById('pickname').value)) { return false } else { return isInt(document.getElementById('pickname-hidden').value) };" }),
-
 
55
    $h->button ({ onClick=>"window.close();" }, "Cancel")
-
 
56
  ]);
-
 
57
  print<<JAVASCRIPT;
-
 
58
	<SCRIPT language="JavaScript">
-
 
59
	<!--
-
 
60
	function isInt(value) {
-
 
61
	  if (value == '') { return false; }
-
 
62
    return !isNaN(value) && (function(x) { return (x | 0) === x; })(parseFloat(value))
-
 
63
  }
-
 
64
  document.querySelector('input[list]').addEventListener('input', function(e) {
-
 
65
    var input = e.target,
-
 
66
        list = input.getAttribute('list'),
-
 
67
        options = document.querySelectorAll('#' + list + ' option'),
-
 
68
        hiddenInput = document.getElementById(input.getAttribute('id') + '-hidden'),
-
 
69
        inputValue = input.value;
-
 
70
 
-
 
71
    hiddenInput.value = inputValue;
-
 
72
 
-
 
73
    for(var i = 0; i < options.length; i++) {
-
 
74
        var option = options[i];
-
 
75
 
-
 
76
        if(option.innerText === inputValue) {
-
 
77
            hiddenInput.value = option.getAttribute('data-value');
-
 
78
            break;
-
 
79
        }
-
 
80
    }
Line 50... Line 81...
50
    $department eq "CLA" ? $h->p ("Add User to Class ($id):") : $h->p ("Add User to Shift ($id):"),
81
  });
51
    $h->select ({ name=>"RCid", id=>"pickname" }, [ $h->option, $options ]),
82
	//-->
Line 52... Line 83...
52
    $h->input ({ type=>"submit", value=>"Save", onClick=>"if (document.getElementById('pickname').selectedIndex === 0) { return false; }" }),
83
	</SCRIPT>