Rev 35 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/perluse strict;use cPanelUserConfig;use RollerCon;use tableViewer;use CGI qw/param cookie header start_html url/;use HTML::Tiny;my $h = HTML::Tiny->new( mode => 'html' );my $cookie_string = authenticate(1) || die;my ($EML, $PWD, $LVL) = split /&/, $cookie_string;my $user = getUser($EML);my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");print header (-cookie=>$RCAUTH_cookie);#foreach (sort keys %ENV) {# print "$_: $ENV{$_}\n<br>";#}my $change = param ('change');my $RCid = param ('RCid') // $user->{RCid};my $id = param ('id');my $role = param ('role') // "";my $noshow = param ('noshow');my $department = ($id =~ /^\d+$/) ? getShiftDepartment ($role ? $id."-".$role : $id) : "CLA";print start_html (-title => "vORC Make Shift Change", -style => {'src' => "/style.css"}), $h->open ("body");if ($change eq "lookup") {if (convertDepartments($user->{department})->{$department} < 2 and $LVL < 5 and convertDepartments($user->{department})->{VCI} < 2) {print $h->div ({ class=>"error" }, "You're not allowed to change other people's schedules.");print $h->close ("body"), $h->close ("html");die;}my $options = fetchDerbyNameWithRCid ($department);print $h->form ({ action=>url }, [$h->input ({ type=>"hidden", name=>"change", value=>"add" }),$h->input ({ type=>"hidden", name=>"id", value=>$id }),$h->input ({ type=>"hidden", name=>"role", value=>$role }),$department eq "CLA" ? $h->p ("Add User to Class ($id):") : $h->p ("Add User to Shift ($id):"),$h->select ({ name=>"RCid", id=>"pickname" }, [ $h->option, $options ]),$h->input ({ type=>"submit", value=>"Save", onClick=>"if (document.getElementById('pickname').selectedIndex === 0) { return false; }" }),$h->button ({ onClick=>"window.close();" }, "Cancel")]);} else {print $h->p ("Making a shift change...");if ($noshow eq "true") {logit ($RCid, "NO SHOW: $id");logit ($user->{RCid}, "Logged a No Show for ($RCid): $id");print $h->p ("Logged a No Show and removing the official from the shift...");} elsif ($RCid eq $user->{RCid}) {print $h->p ("So, <b>$user->{derby_name}</b>, you'd like to <b>$change</b> a shift: <b>$id</b>...");} else {my $target = getUserDerbyName ($RCid);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>...");}my $change_err = changeShift($change, $id, $role, $RCid);my $closer;if ($change_err) {print $change_err;if ($change_err =~ /conflict/ and (convertDepartments($user->{department})->{VCI} > 2 or $LVL > 4)) {print $h->form ({ action=>url }, [$h->input ({ type=>"hidden", name=>"change", value=>"override" }),$h->input ({ type=>"hidden", name=>"id", value=>$id }),$h->input ({ type=>"hidden", name=>"role", value=>$role }),$h->input ({ type=>"hidden", name=>"RCid", value=>$RCid }),$h->input ({ type=>"submit", value=>"OVERRIDE", onClick=>"if (confirm('Are you sure you want to override the conflict?')==true) { return true } else { return false }" }),]);}print $h->br, $h->button ({ onClick=>"window.close();" }, "Close");} else {print "<br>This window will close automatically in 3 seconds.";$closer = 'setTimeout(() => { window.close(); }, 3000);';}print<<tail;<SCRIPT language="JavaScript"><!--function reloadParent() {window.opener.location.reload();$closer}reloadParent();//--></SCRIPT>tailprint $h->close ("body"), $h->close ("html");}