Subversion Repositories ORC

Rev

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

Rev 2 Rev 7
Line 1... Line 1...
1
#!/usr/bin/perl -w
1
#!/usr/bin/perl
2
 
2
 
3
use strict;
3
use strict;
4
use lib "/home/rollerco/perl5/lib/perl5";
-
 
5
use RollerCon;
4
use RollerCon;
6
use scanFunctions;
5
use tableViewer;
7
use CGI;
6
use CGI qw/param cookie header start_html url/;
8
use CGI::Cookie;
7
use HTML::Tiny;
-
 
8
my $h = HTML::Tiny->new( mode => 'html' );
9
 
9
 
10
my $cookie_string = authenticate(1) || die;
10
my $cookie_string = authenticate(1) || die;
11
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
11
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
12
my $user = getUser($EML);
12
my $user = getUser($EML);
13
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
13
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
14
 
14
 
15
print CGI::header(-cookie=>$RCAUTH_cookie);
15
print header (-cookie=>$RCAUTH_cookie);
16
 
16
 
17
#foreach (sort keys %ENV) {
17
#foreach (sort keys %ENV) {
18
#	print "$_: $ENV{$_}\n<br>";
18
#	print "$_: $ENV{$_}\n<br>";
19
#}
19
#}
20
my $query = new CGI;
-
 
21
my $change = $query->param('change');
20
my $change = param ('change');
22
my $RCid = $query->param('RCid');
21
my $RCid   = param ('RCid') // $user->{RCid};
23
my $id = $query->param('id');
22
my $id     = param ('id');
24
my $role = $query->param('role');
23
my $role   = param ('role') // "";
25
my $noshow = $query->param('noshow');
24
my $noshow = param ('noshow');
-
 
25
my $department = getShiftDepartment ($role ? $id."-".$role : $id);
26
 
26
 
27
	print<<page1;
-
 
28
	<html><head><title>RollerCon Officials Schedule Manager - Shift Change</title>
-
 
29
	<link rel="stylesheet" type="text/css" href="/rollercon.css">
-
 
30
	</head>
-
 
31
	<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000" onload="reloadParent()">
27
print start_html (-title => "vORC Make Shift Change", -style => {'src' => "/style.css"}), $h->open ("body");
32
	<TABLE>
-
 
33
page1
-
 
34
 
28
 
35
 
29
 
36
if ($change eq "lookup") {
30
if ($change eq "lookup") {
37
	if ($LVL < 2) {
31
	if (convertDepartments($user->{department})->{$department} < 2 and $LVL < 5) {
38
		print<<errorout;
-
 
39
		<TR>
-
 
40
			<TD valign=top><font color=red><b>ERROR: </b></font>You're not allowed to change other people's schedules.</td>
32
    print $h->div ({ class=>"error" }, "You're not allowed to change other people's schedules.");
41
			<TD valign=top></TD>
33
    print $h->close ("body"), $h->close ("html");
42
		</TR>
-
 
43
			
-
 
44
	</TABLE>
-
 
45
errorout
-
 
46
	die;
34
	  die;
47
	} else {
35
	}
48
		
36
	
49
	}
-
 
50
	my $options = fetchDerbyNameWithRCid();
37
	my $options = fetchDerbyNameWithRCid ($department);
51
	
38
  
52
	print<<page2;
-
 
53
<FORM action=make_shift_change.pl>
39
  print $h->form ({ action=>url }, [
54
<INPUT type=hidden name=change value=add>
40
    $h->input ({ type=>"hidden", name=>"change", value=>"add" }),
55
<INPUT type=hidden name=id value=$id>
41
    $h->input ({ type=>"hidden", name=>"id", value=>$id }),
56
<INPUT type=hidden name=role value=$role>
42
    $h->input ({ type=>"hidden", name=>"role", value=>$role }),
57
		<TR>
-
 
58
			<TD valign=top>Add User to Shift (Game $id / Role $role):</td>
43
    $h->p ("Add User to Shift ($id):"),
59
		</tr><tr>
-
 
60
			<TD valign=top><SELECT name=RCid>$options</SELECT> </TD>
44
    $h->select ({ name=>"RCid", id=>"pickname" }, [ $h->option, $options ]),
61
		</TR><tr>
-
 
62
		  <td><input type=submit name=Save> <input type=reset name=Cancel onClick=window.close();></td>
45
    $h->input ({ type=>"submit", value=>"Save", onClick=>"if (document.getElementById('pickname').selectedIndex === 0) { return false; }" }),
63
		  </tr>
46
    $h->button ({ onClick=>"window.close();" }, "Cancel")
64
</FORM>
-
 
65
	</TABLE>
-
 
66
 
-
 
67
page2
47
  ]);
68
	
48
 
69
} else {
49
} else {
70
	print<<page1;
-
 
71
		<TR>
-
 
72
			<TD valign=top>Making a shift change...</td>
50
	print $h->p ("Making a shift change...");
73
			<TD valign=top></TD>
-
 
74
		</TR>
-
 
75
			
-
 
76
	</TABLE>
-
 
77
page1
-
 
78
 
51
 
79
if ($noshow eq "true") {
52
  if ($noshow eq "true") {
80
  logit($RCid, "NO SHOW: Game ($id): $role");
53
    logit ($RCid, "NO SHOW: $id");
81
  logit($user->{RCid}, "Logged a No Show for ($RCid): Game ($id): $role");
54
    logit ($user->{RCid}, "Logged a No Show for ($RCid): $id");
82
  print "Logged a No Show and removing the official from the shift...";
55
    print $h->p ("Logged a No Show and removing the official from the shift...");
83
  #logit
-
 
84
} elsif ($RCid eq $user->{RCid}) {
56
  } elsif ($RCid eq $user->{RCid}) {
85
  print "So, <b>$user->{derby_name}</b>, you\'d like to <b>$change</b> a shift where you are <b>$role</b> for game <b>$id</b>...";
57
    print $h->p ("So, <b>$user->{derby_name}</b>, you'd like to <b>$change</b> a shift: <b>$id</b>...");
86
} else {
58
  } else {
87
  my $target = getUserDerbyName($RCid);
59
    my $target = getUserDerbyName ($RCid);
88
  print "So, <b>$user->{derby_name}</b>, you\'d like to <b>$change</b> a shift where <b>$target</b> is <b>$role</b> for game <b>$id</b>...";  
60
    print $h->p ("So, <b>$user->{derby_name}</b>, you'd like to <b>$change</b> a shift for <b>$target</b>: <b>$id</b>...");
-
 
61
  }
89
}
62
  
90
 
63
  
91
	my $change_err = changeShift($change, $id, $role, $RCid);
64
	my $change_err = changeShift($change, $id, $role, $RCid);
-
 
65
	my $closer;
-
 
66
	if ($change_err) {
-
 
67
	  print $change_err;
-
 
68
	  print $h->br, $h->button ({ onClick=>"window.close();" }, "Close");
-
 
69
	} else {
-
 
70
	  print "<br>This window will close automatically in 3 seconds.";
-
 
71
 	  $closer = 'setTimeout(() => { window.close(); }, 3000);';
92
 
72
	}
93
 
73
  
94
	print<<tail;
74
	print<<tail;
95
	<SCRIPT language="JavaScript">
75
	<SCRIPT language="JavaScript">
96
	<!-- 
76
	<!--
97
			function sleep(milliseconds) {
77
			function reloadParent() {
98
			  var start = new Date().getTime();
78
	      window.opener.location.reload();
99
			  for (var i = 0; i < 1e7; i++) {
-
 
100
			    if ((new Date().getTime() - start) > milliseconds){
-
 
101
			      break;
79
	      $closer
102
			    }
-
 
103
			  }
-
 
104
			}
80
			}
105
	 
81
			
106
			function reloadParent() {
82
			reloadParent();
107
	      window.opener.document.Req.submit();
-
 
108
	      sleep(5000);			
-
 
109
	      //window.close();
-
 
110
			}
-
 
111
	//-->
83
	//-->
112
	</SCRIPT>
84
	</SCRIPT>
113
 
-
 
114
	</body></html>
-
 
115
 
-
 
116
tail
85
tail
-
 
86
  print $h->close ("body"), $h->close ("html");
117
}
87
}
118
88