| 7 |
- |
1 |
#!/usr/bin/perl
|
|
|
2 |
|
|
|
3 |
use strict;
|
| 8 |
- |
4 |
use cPanelUserConfig;
|
| 7 |
- |
5 |
use RollerCon;
|
|
|
6 |
use tableViewer;
|
|
|
7 |
use CGI qw/param cookie header start_html url/;
|
|
|
8 |
use HTML::Tiny;
|
|
|
9 |
my $h = HTML::Tiny->new( mode => 'html' );
|
|
|
10 |
|
|
|
11 |
my $cookie_string = authenticate(1) || die;
|
|
|
12 |
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
13 |
my $user = getUser($EML);
|
|
|
14 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
15 |
|
|
|
16 |
print header (-cookie=>$RCAUTH_cookie);
|
|
|
17 |
|
|
|
18 |
#foreach (sort keys %ENV) {
|
|
|
19 |
# print "$_: $ENV{$_}\n<br>";
|
|
|
20 |
#}
|
|
|
21 |
my $change = param ('change');
|
|
|
22 |
my $RCid = param ('RCid') // $user->{RCid};
|
|
|
23 |
my $id = param ('id');
|
|
|
24 |
my $role = param ('role') // "";
|
|
|
25 |
my $noshow = param ('noshow');
|
| 35 |
- |
26 |
my $department = ($id =~ /^\d+$/) ? getShiftDepartment ($role ? $id."-".$role : $id) : "CLA";
|
| 7 |
- |
27 |
|
|
|
28 |
print start_html (-title => "vORC Make Shift Change", -style => {'src' => "/style.css"}), $h->open ("body");
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
if ($change eq "lookup") {
|
| 35 |
- |
32 |
if (convertDepartments($user->{department})->{$department} < 2 and $LVL < 5 and convertDepartments($user->{department})->{VCI} < 2) {
|
| 7 |
- |
33 |
print $h->div ({ class=>"error" }, "You're not allowed to change other people's schedules.");
|
|
|
34 |
print $h->close ("body"), $h->close ("html");
|
|
|
35 |
die;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
my $options = fetchDerbyNameWithRCid ($department);
|
|
|
39 |
|
|
|
40 |
print $h->form ({ action=>url }, [
|
|
|
41 |
$h->input ({ type=>"hidden", name=>"change", value=>"add" }),
|
|
|
42 |
$h->input ({ type=>"hidden", name=>"id", value=>$id }),
|
|
|
43 |
$h->input ({ type=>"hidden", name=>"role", value=>$role }),
|
| 35 |
- |
44 |
$department eq "CLA" ? $h->p ("Add User to Class ($id):") : $h->p ("Add User to Shift ($id):"),
|
| 7 |
- |
45 |
$h->select ({ name=>"RCid", id=>"pickname" }, [ $h->option, $options ]),
|
|
|
46 |
$h->input ({ type=>"submit", value=>"Save", onClick=>"if (document.getElementById('pickname').selectedIndex === 0) { return false; }" }),
|
|
|
47 |
$h->button ({ onClick=>"window.close();" }, "Cancel")
|
|
|
48 |
]);
|
|
|
49 |
|
|
|
50 |
} else {
|
|
|
51 |
print $h->p ("Making a shift change...");
|
|
|
52 |
|
|
|
53 |
if ($noshow eq "true") {
|
|
|
54 |
logit ($RCid, "NO SHOW: $id");
|
|
|
55 |
logit ($user->{RCid}, "Logged a No Show for ($RCid): $id");
|
|
|
56 |
print $h->p ("Logged a No Show and removing the official from the shift...");
|
|
|
57 |
} elsif ($RCid eq $user->{RCid}) {
|
|
|
58 |
print $h->p ("So, <b>$user->{derby_name}</b>, you'd like to <b>$change</b> a shift: <b>$id</b>...");
|
|
|
59 |
} else {
|
|
|
60 |
my $target = getUserDerbyName ($RCid);
|
|
|
61 |
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>...");
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
my $change_err = changeShift($change, $id, $role, $RCid);
|
|
|
66 |
my $closer;
|
|
|
67 |
if ($change_err) {
|
|
|
68 |
print $change_err;
|
| 46 |
- |
69 |
if ($change_err =~ /conflict/ and (convertDepartments($user->{department})->{VCI} > 2 or $LVL > 4)) {
|
|
|
70 |
print $h->form ({ action=>url }, [
|
|
|
71 |
$h->input ({ type=>"hidden", name=>"change", value=>"override" }),
|
|
|
72 |
$h->input ({ type=>"hidden", name=>"id", value=>$id }),
|
|
|
73 |
$h->input ({ type=>"hidden", name=>"role", value=>$role }),
|
|
|
74 |
$h->input ({ type=>"hidden", name=>"RCid", value=>$RCid }),
|
|
|
75 |
$h->input ({ type=>"submit", value=>"OVERRIDE", onClick=>"if (confirm('Are you sure you want to override the conflict?')==true) { return true } else { return false }" }),
|
|
|
76 |
]);
|
|
|
77 |
}
|
| 7 |
- |
78 |
print $h->br, $h->button ({ onClick=>"window.close();" }, "Close");
|
|
|
79 |
} else {
|
|
|
80 |
print "<br>This window will close automatically in 3 seconds.";
|
|
|
81 |
$closer = 'setTimeout(() => { window.close(); }, 3000);';
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
print<<tail;
|
|
|
85 |
<SCRIPT language="JavaScript">
|
|
|
86 |
<!--
|
|
|
87 |
function reloadParent() {
|
|
|
88 |
window.opener.location.reload();
|
|
|
89 |
$closer
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
reloadParent();
|
|
|
93 |
//-->
|
|
|
94 |
</SCRIPT>
|
|
|
95 |
tail
|
|
|
96 |
print $h->close ("body"), $h->close ("html");
|
| 2 |
- |
97 |
}
|