| Line 8... |
Line 8... |
| 8 |
use DBI;
|
8 |
use DBI;
|
| 9 |
use WebDB;
|
9 |
use WebDB;
|
| Line 10... |
Line 10... |
| 10 |
|
10 |
|
| - |
|
11 |
|
| - |
|
12 |
my $dbh = WebDB->connect ();
|
| - |
|
13 |
sub getRCDBH {
|
| 11 |
|
14 |
return $dbh;
|
| 12 |
my $dbh = WebDB->connect ();
|
15 |
}
|
| 13 |
our $ORCUSER;
|
16 |
our $ORCUSER;
|
| 14 |
use constant {
|
17 |
use constant {
|
| 15 |
USER => 1,
|
18 |
USER => 1,
|
| Line 305... |
Line 308... |
| 305 |
$s->{buttons} = $h->button ({ onClick=>"if (confirm('Really? You want to drop this shift?')==true) { window.open('make_shift_change.pl?change=del&id=$s->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }" }, "DROP");
|
308 |
$s->{buttons} = $h->button ({ onClick=>"if (confirm('Really? You want to drop this shift?')==true) { window.open('make_shift_change.pl?change=del&id=$s->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }" }, "DROP");
|
| 306 |
if ($ORCUSER->{department}->{$s->{dept}} >= 2 or $ORCUSER->{access} >= 5) {
|
309 |
if ($ORCUSER->{department}->{$s->{dept}} >= 2 or $ORCUSER->{access} >= 5) {
|
| 307 |
# NO SHOW
|
310 |
# NO SHOW
|
| 308 |
$s->{buttons} .= " ".$h->button ({ onClick=>"if (confirm('Really? They were a no show?')==true) { window.open('make_shift_change.pl?noshow=true&change=del&RCid=$RCid&id=$s->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }" }, "NO SHOW");
|
311 |
$s->{buttons} .= " ".$h->button ({ onClick=>"if (confirm('Really? They were a no show?')==true) { window.open('make_shift_change.pl?noshow=true&change=del&RCid=$RCid&id=$s->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false; }" }, "NO SHOW");
|
| 309 |
}
|
312 |
}
|
| 310 |
$hours += $s->{volhours};
|
313 |
$hours += $s->{volhours} unless $s->{dept} eq "CLA";
|
| 311 |
}
|
314 |
}
|
| Line 312... |
Line 315... |
| 312 |
|
315 |
|
| 313 |
} elsif (($RCid == $ORCUSER->{RCid} and $s->{signup} !~ /^selected/ and $now < $cutoff) or ($ORCUSER->{department}->{$s->{dept}} >= 2 or $ORCUSER->{access} >= 5)) {
|
316 |
} elsif (($RCid == $ORCUSER->{RCid} and $s->{signup} !~ /^selected/ and $now < $cutoff) or ($ORCUSER->{department}->{$s->{dept}} >= 2 or $ORCUSER->{access} >= 5)) {
|
| 314 |
# it's a game shift
|
317 |
# it's a game shift
|
| Line 420... |
Line 423... |
| 420 |
}
|
423 |
}
|
| Line 421... |
Line 424... |
| 421 |
|
424 |
|
| 422 |
sub changeShift {
|
425 |
sub changeShift {
|
| 423 |
my ($change, $shift_id, $role, $user_id) = @_;
|
426 |
my ($change, $shift_id, $role, $user_id) = @_;
|
| 424 |
my $leadership_change = 0;
|
427 |
my $leadership_change = 0;
|
| - |
|
428 |
# my $department = getShiftDepartment ($role ? $shift_id."-".$role : $shift_id);
|
| - |
|
429 |
my $department;
|
| - |
|
430 |
if ($shift_id =~ /^\d+$/) {
|
| - |
|
431 |
$department = getShiftDepartment ($role ? $shift_id."-".$role : $shift_id);
|
| - |
|
432 |
} else {
|
| - |
|
433 |
$department = "CLA";
|
| - |
|
434 |
($shift_id) = $dbh->selectrow_array ("select min(id) from v_shift where date = ? and start_time = ? and location = ? and isnull(RCid) = 1", undef, split /\|/, $shift_id);
|
| 425 |
my $department = getShiftDepartment ($role ? $shift_id."-".$role : $shift_id);
|
435 |
}
|
| 426 |
my $game_based = $role ? "game" : "shift";
|
436 |
my $game_based = $role ? "game" : "shift";
|
| Line 427... |
Line 437... |
| 427 |
my $sth;
|
437 |
my $sth;
|
| 428 |
|
438 |
|
| 429 |
if ($change eq "add") {
|
439 |
if ($change eq "add") {
|
| 430 |
my $taken;
|
440 |
my $taken;
|
| - |
|
441 |
if ($game_based eq "game") {
|
| - |
|
442 |
($taken) = $dbh->selectrow_array ("select count(*) from assignment where Gid = ? and role = ?", undef, $shift_id, $role);
|
| 431 |
if ($game_based eq "game") {
|
443 |
} elsif ($department eq "CLA") {
|
| 432 |
($taken) = $dbh->selectrow_array ("select count(*) from assignment where Gid = ? and role = ?", undef, $shift_id, $role);
|
444 |
($taken) = $shift_id ? 0 : 1;
|
| 433 |
} else {
|
445 |
} else {
|
| 434 |
($taken) = $dbh->selectrow_array ("select count(*) from shift where id = ? and isnull(assignee_id) = 0", undef, $shift_id);
|
446 |
($taken) = $dbh->selectrow_array ("select count(*) from shift where id = ? and isnull(assignee_id) = 0", undef, $shift_id);
|
| 435 |
}
|
447 |
}
|
| 436 |
if ($taken) {
|
448 |
if ($taken) {
|
| 437 |
return "<br>Denied! This shift is already taken ($shift_id).<br>\n";
|
449 |
return ($department eq "CLA") ? "<br>Denied! This class is already full ($shift_id).<br>\n" : "<br>Denied! This shift is already taken ($shift_id).<br>\n";
|
| Line 438... |
Line 450... |
| 438 |
}
|
450 |
}
|
| 439 |
}
|
451 |
}
|
| 440 |
|
452 |
|
| 441 |
if (lc ($user_id) ne lc ($ORCUSER->{RCid})) { # they're changing someone else's schedule...
|
453 |
if (lc ($user_id) ne lc ($ORCUSER->{RCid})) { # they're changing someone else's schedule...
|
| 442 |
if ($ORCUSER->{department}->{$department} >= 2 or $ORCUSER->{access} >= 5) {
|
454 |
if ($ORCUSER->{department}->{$department} >= 2 or $ORCUSER->{access} >= 5 or $ORCUSER->{department}->{VCI} >= 2) {
|
| 443 |
# the user making the change is either a lead in the dept or a sysadmin
|
455 |
# the user making the change is either a lead in the dept, a sysadmin, or a VCI lead
|
| 444 |
logit ($ORCUSER->{RCid}, "$ORCUSER->{derby_name} changed someone else's schedule. ($change, $shift_id, $role, $user_id)");
|
456 |
logit ($ORCUSER->{RCid}, "$ORCUSER->{derby_name} changed someone else's schedule. ($change, $shift_id, $role, $user_id)");
|
| 445 |
logit ($user_id, "Schedule was changed by $ORCUSER->{derby_name}. ($change, $shift_id, $role, $user_id)");
|
457 |
logit ($user_id, "Schedule was changed by $ORCUSER->{derby_name}. ($change, $shift_id, $role, $user_id)");
|
| Line 473... |
Line 485... |
| 473 |
# my $MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY");
|
485 |
# my $MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY");
|
| 474 |
my $MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY_".$department);
|
486 |
my $MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY_".$department);
|
| 475 |
$MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY") unless defined $MAXSHIFTS;
|
487 |
$MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY") unless defined $MAXSHIFTS;
|
| 476 |
if ($game_type eq "lead" and $department eq "OFF") { $MAXSHIFTS = 99; }
|
488 |
if ($game_type eq "lead" and $department eq "OFF") { $MAXSHIFTS = 99; }
|
| Line -... |
Line 489... |
| - |
|
489 |
|
| - |
|
490 |
my $daily_count;
|
| - |
|
491 |
if ($department eq "CLA") {
|
| - |
|
492 |
# MVP Class Sign-up
|
| - |
|
493 |
$MAXSHIFTS = getSetting ("MAX_CLASS_SIGNUP");
|
| - |
|
494 |
($daily_count) = $dbh->selectrow_array ("select count(*) from v_shift where RCid = ? and dept = 'CLA'", undef, $user_id);
|
| - |
|
495 |
if ($change eq "add" and $daily_count >= $MAXSHIFTS and !$leadership_change) {
|
| - |
|
496 |
return "<br>Denied! You may only sign up for $MAXSHIFTS Classes!<br>\n";
|
| - |
|
497 |
}
|
| 477 |
|
498 |
} else {
|
| 478 |
my $daily_count = signUpCount ('get', $user_id, $department);
|
499 |
$daily_count = signUpCount ('get', $user_id, $department);
|
| 479 |
if ($change eq "add" and $daily_count >= $MAXSHIFTS and !$leadership_change) {
|
500 |
if ($change eq "add" and $daily_count >= $MAXSHIFTS and !$leadership_change) {
|
| - |
|
501 |
return "<br>Denied! You may only sign up for $MAXSHIFTS $game_type shifts in one day!<br>\n";
|
| 480 |
return "<br>Denied! You may only sign up for $MAXSHIFTS $game_type shifts in one day!<br>\n";
|
502 |
}
|
| 481 |
}
|
503 |
}
|
| 482 |
|
504 |
|
| 483 |
my @DBARGS;
|
505 |
my @DBARGS;
|
| 484 |
if ($game_based eq "game") {
|
506 |
if ($game_based eq "game") {
|
| 485 |
if ($change eq "add") {
|
507 |
if ($change eq "add") {
|
| 486 |
$sth = $dbh->prepare("insert into assignment (Gid, role, RCid) values (?, ?, ?)");
|
508 |
$sth = $dbh->prepare("insert into assignment (Gid, role, RCid) values (?, ?, ?)");
|
| 487 |
} elsif ($change eq "del") {
|
509 |
} elsif ($change eq "del") {
|
| 488 |
$sth = $dbh->prepare("delete from assignment where Gid = ? and role = ? and RCid= ?");
|
510 |
$sth = $dbh->prepare("delete from assignment where Gid = ? and role = ? and RCid= ?");
|
| 489 |
}
|
511 |
}
|
| 490 |
@DBARGS = ($shift_id, $role, $user_id);
|
512 |
@DBARGS = ($shift_id, $role, $user_id);
|
| 491 |
} else {
|
513 |
} else {
|
| 492 |
if ($change eq "add") {
|
514 |
if ($change eq "add") {
|
| 493 |
$sth = $dbh->prepare("update shift set assignee_id = ? where id = ?");
|
515 |
$sth = $dbh->prepare("update shift set assignee_id = ? where id = ? and isnull(assignee_id) = 1");
|
| 494 |
@DBARGS = ($user_id, $shift_id);
|
516 |
@DBARGS = ($user_id, $shift_id);
|
| 495 |
} elsif ($change eq "del") {
|
517 |
} elsif ($change eq "del") {
|
| 496 |
$sth = $dbh->prepare("update shift set assignee_id = null where id = ?");
|
518 |
$sth = $dbh->prepare("update shift set assignee_id = null where id = ?");
|
| 497 |
@DBARGS = ($shift_id);
|
519 |
@DBARGS = ($shift_id);
|
| Line 589... |
Line 611... |
| 589 |
|
611 |
|
| Line 590... |
Line 612... |
| 590 |
return 0 unless $limit > 0;
|
612 |
return 0 unless $limit > 0;
|
| Line -... |
Line 613... |
| - |
|
613 |
|
| - |
|
614 |
my $limitkey = $dept ? "sign_ups_today_".$dept : "sign_ups_today";
|
| - |
|
615 |
|
| - |
|
616 |
if ($shifttype eq "class") {
|
| - |
|
617 |
($t->{id}) = $dbh->selectrow_array ("select min(id) from v_shift where isnull(RCid) = 1 and dept = ? and date = ? and location = ? and start_time = ?", undef, "CLA", $t->{date}, $t->{location}, $t->{start_time});
|
| - |
|
618 |
$t->{dept} = "CLA";
|
| 591 |
|
619 |
$t->{type} = "open";
|
| Line 592... |
Line 620... |
| 592 |
my $limitkey = $dept ? "sign_ups_today_".$dept : "sign_ups_today";
|
620 |
}
|
| 593 |
|
621 |
|
| 594 |
if (findConflict ($user->{RCid}, $t->{id}, $shifttype)) { return 0; }
|
622 |
if (findConflict ($user->{RCid}, $t->{id}, $shifttype)) { return 0; }
|
| Line 609... |
Line 637... |
| 609 |
return 1;
|
637 |
return 1;
|
| 610 |
} else {
|
638 |
} else {
|
| 611 |
return 0;
|
639 |
return 0;
|
| 612 |
}
|
640 |
}
|
| 613 |
} else {
|
641 |
} else {
|
| - |
|
642 |
if ($dept eq "CLA") {
|
| - |
|
643 |
# MVP Class Sign-up
|
| - |
|
644 |
my $class_limit = getSetting ("MAX_CLASS_SIGNUP");
|
| - |
|
645 |
my ($class_count) = $dbh->selectrow_array ("select count(*) from v_shift where RCid = ? and dept = 'CLA'", undef, $user->{RCid});
|
| - |
|
646 |
return 0 unless $class_count < $class_limit;
|
| - |
|
647 |
}
|
| 614 |
if ($user->{department}->{$t->{dept}} < 1) { return 0; }
|
648 |
if ($user->{department}->{$t->{dept}} < 1) { return 0; }
|
| 615 |
if ($t->{type} eq "lead" and $user->{department}->{$t->{dept}} < 2) { return 0; }
|
649 |
if ($t->{type} eq "lead" and $user->{department}->{$t->{dept}} < 2) { return 0; }
|
| 616 |
if ($t->{type} eq "manager" and $user->{department}->{$t->{dept}} < 3) { return 0; }
|
650 |
if ($t->{type} eq "manager" and $user->{department}->{$t->{dept}} < 3) { return 0; }
|
| 617 |
if ($t->{type} !~ /^selected/ and $user->{$limitkey} < $limit) {
|
651 |
if ($t->{type} !~ /^selected/ and $user->{$limitkey} < $limit) {
|
| 618 |
return 1;
|
652 |
return 1;
|