Rev 7 | 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(2) || die;my ($EML, $PWD, $LVL) = split /&/, $cookie_string;my $user = getUser($EML);$user->{department} = convertDepartments ($user->{department});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 ('modtime') // "pick";my $RCid = param ('RCid');my $shiftid = param ('shiftid');my $department = getShiftDepartment ($shiftid);print start_html (-title => "vORC Modify Shift Time", -style => {'src' => "/style.css"}), $h->open ("body");if ($user->{department}->{$department} < 2 or $LVL < 5) {print $h->div ({ class=>"error" }, "ERROR: You're not allowed to modify this shift's time.");print $h->close ("body"), $h->close ("html");die;} elsif (!$shiftid or !$RCid) {print $h->div ({ class=>"error" }, "ERROR: Missing required fields.");print $h->close ("body"), $h->close ("html");die;} elsif ($RCid eq $user->{RCid} and ($user->{department}->{$department} < 3 or $LVL < 5)) {print $h->div ({ class=>"error" }, "ERROR: Leads aren't allowed to modify their own shift's time.");print $h->close ("body"), $h->close ("html");die;}if ($change eq "pick") {use WebDB;my $dbh = WebDB->connect ();my ($current, $shiftlength) = $dbh->selectrow_array ("select mod_time, volhours from v_shift where RCid = ? and id = ?", undef, $RCid, $shiftid);$shiftlength -= $current;my $options;print $h->p ("Modifying time for Shift ($shiftid):");print $h->p ({ class=>"hint" }, "Add or Remove volunteer time earned if someone stays late or leaves early.");print $h->form ({ action=>url }, [$h->input ({ type=>"hidden", name=>"shiftid", value=>$shiftid }),$h->input ({ type=>"hidden", name=>"RCid", value=>$RCid }),# $h->p ("Modify Time for Shift ($RCid):"),$h->input ({ name=>"modtime", type=>"number", value=>$current, step=>.25, min=>-$shiftlength, id=>"pickname" }),$h->input ({ type=>"submit", value=>"Save", onClick=>"if (document.getElementById('pickname').selectedIndex === 0) { return false; }" }),$h->input ({ type=>"reset", value=>"Cancel", onClick=>"window.close();" })]);} else {print $h->p ("Modifying Shift Time...");my $target = getUserDerbyName ($RCid);print $h->p ("So, <b>$user->{derby_name}</b>, you'd like to add/remove time from a shift for <b>$target</b>: <b>$RCid</b>...");my $change_err = modShiftTime ($shiftid, $RCid, $change);print<<tail;<SCRIPT language="JavaScript"><!--function sleep(milliseconds) {var start = new Date().getTime();for (var i = 0; i < 1e7; i++) {if ((new Date().getTime() - start) > milliseconds){break;}}}function reloadParent() {window.opener.document.Req.submit();sleep(5000);//window.close();}reloadParent();//--></SCRIPT></body></html>tailprint $h->close ("body"), $h->close ("html");}