| Line 52... |
Line 52... |
| 52 |
}
|
52 |
}
|
| Line 53... |
Line 53... |
| 53 |
|
53 |
|
| 54 |
my $tempDepartments = convertDepartments ($RCDBIDHASH->{department});
|
54 |
my $tempDepartments = convertDepartments ($RCDBIDHASH->{department});
|
| Line 55... |
Line 55... |
| 55 |
my $MAXACCESS = scalar keys %{ $tempDepartments } ? max ($RCDBIDHASH->{'access'}, values %{ $tempDepartments }) : $RCDBIDHASH->{'access'};
|
55 |
my $MAXACCESS = scalar keys %{ $tempDepartments } ? max ($RCDBIDHASH->{'access'}, values %{ $tempDepartments }) : $RCDBIDHASH->{'access'};
|
| 56 |
|
56 |
|
| 57 |
if (!$RCDBIDHASH) {
|
57 |
if (!$RCDBIDHASH->{'RCid'}) {
|
| 58 |
$result->{ERRMSG} = "User-ID/Email Address not found!";
|
58 |
$result->{ERRMSG} = "Email Address not found!";
|
| 59 |
$result->{cookie_string} = '';
|
59 |
$result->{cookie_string} = '';
|
| 60 |
$result->{RCid} = '';
|
60 |
$result->{RCid} = '';
|
| 61 |
logit(0, "Account not found: $id");
|
61 |
logit(0, "Account not found: $id");
|
| Line 107... |
Line 107... |
| 107 |
my $sth = $dbh->prepare("select * from official where email = '?'");
|
107 |
my $sth = $dbh->prepare("select * from official where email = '?'");
|
| Line 108... |
Line 108... |
| 108 |
|
108 |
|
| 109 |
my $query = new CGI;
|
109 |
my $query = new CGI;
|
| 110 |
# Check to see if the user has already logged in (there should be cookies with their authentication)?
|
110 |
# Check to see if the user has already logged in (there should be cookies with their authentication)?
|
| 111 |
my $RCAUTH = $query->cookie('RCAUTH');
|
111 |
my $RCAUTH = $query->cookie('RCAUTH');
|
| 112 |
$FORM{'ID'} = $query->param('id') || '';
|
112 |
$FORM{'ID'} = WebDB::trim $query->param('id') || '';
|
| 113 |
$FORM{'PASS'} = $query->param('pass') || '';
|
113 |
$FORM{'PASS'} = WebDB::trim $query->param('pass') || '';
|
| Line 114... |
Line 114... |
| 114 |
$FORM{'SUB'} = $query->param('login') || '';
|
114 |
$FORM{'SUB'} = $query->param('login') || '';
|
| 115 |
|
115 |
|
| 116 |
if ($FORM{'SUB'}) {
|
116 |
if ($FORM{'SUB'}) {
|
| Line 155... |
Line 155... |
| 155 |
<TABLE>
|
155 |
<TABLE>
|
| 156 |
</TD></TR>
|
156 |
</TD></TR>
|
| 157 |
<TR><TD colspan=2> </TD></TR>
|
157 |
<TR><TD colspan=2> </TD></TR>
|
| 158 |
$authenticated->{ERRMSG}
|
158 |
$authenticated->{ERRMSG}
|
| 159 |
<TR>
|
159 |
<TR>
|
| 160 |
<TD align=right><B>User ID:</TD><TD><INPUT type=text id=login name=id></TD>
|
160 |
<TD align=right><B>Email Address:</TD><TD><INPUT type=text id=login name=id></TD>
|
| 161 |
</TR>
|
161 |
</TR>
|
| 162 |
<TR>
|
162 |
<TR>
|
| 163 |
<TD align=right><B>Password:</TD><TD><INPUT type=password name=pass></TD>
|
163 |
<TD align=right><B>Password:</TD><TD><INPUT type=password name=pass></TD>
|
| 164 |
</TR>
|
164 |
</TR>
|
| 165 |
<TR><TD></TD><TD><INPUT type=submit name=login value=Submit></TD></TR>
|
165 |
<TR><TD></TD><TD><INPUT type=submit name=login value=Submit></TD></TR>
|
| Line 196... |
Line 196... |
| 196 |
my $shiftID = shift // "";
|
196 |
my $shiftID = shift // "";
|
| 197 |
my $dept;
|
197 |
my $dept;
|
| Line 198... |
Line 198... |
| 198 |
|
198 |
|
| 199 |
if ($shiftID =~ /^\d+$/) {
|
199 |
if ($shiftID =~ /^\d+$/) {
|
| 200 |
($dept) = $dbh->selectrow_array ("select dept from shift where id = ?", undef, $shiftID);
|
- |
|
| 201 |
} elsif ($shiftID =~ /^\d+-ANN/) {
|
- |
|
| 202 |
$dept = "ANN";
|
200 |
($dept) = $dbh->selectrow_array ("select dept from shift where id = ?", undef, $shiftID);
|
| 203 |
} else {
|
201 |
} else {
|
| - |
|
202 |
my ($id, $role) = split /-/, $shiftID;
|
| 204 |
$dept = "OFF";
|
203 |
($dept) = $dbh->selectrow_array ("select distinct department from staff_template where role like ?", undef, $role);
|
| - |
|
204 |
}
|
| - |
|
205 |
# } elsif ($shiftID =~ /^\d+-ANN/) {
|
| - |
|
206 |
# $dept = "ANN";
|
| - |
|
207 |
# } else {
|
| - |
|
208 |
# $dept = "OFF";
|
| Line 205... |
Line 209... |
| 205 |
}
|
209 |
# }
|
| 206 |
|
210 |
|
| Line 207... |
Line 211... |
| 207 |
return $dept;
|
211 |
return $dept;
|
| Line 328... |
Line 332... |
| 328 |
} else {
|
332 |
} else {
|
| 329 |
return $h->p ({ class=>"hint" }, "[nothing scheduled at the moment]");
|
333 |
return $h->p ({ class=>"hint" }, "[nothing scheduled at the moment]");
|
| 330 |
}
|
334 |
}
|
| 331 |
}
|
335 |
}
|
| Line -... |
Line 336... |
| - |
|
336 |
|
| - |
|
337 |
sub getRCid {
|
| - |
|
338 |
my $derbyname = shift;
|
| - |
|
339 |
($derbyname) = $dbh->selectrow_array ("select RCid from official where derby_name = ?", undef, $derbyname);
|
| - |
|
340 |
return $derbyname;
|
| - |
|
341 |
}
|
| 332 |
|
342 |
|
| 333 |
sub getSetting {
|
343 |
sub getSetting {
|
| 334 |
my $k = shift;
|
344 |
my $k = shift;
|
| 335 |
my ($value) = $dbh->selectrow_array ("select setting.value from setting where setting.key = ?", undef, $k);
|
345 |
my ($value) = $dbh->selectrow_array ("select setting.value from setting where setting.key = ?", undef, $k);
|
| 336 |
return $value;
|
346 |
return defined $value ? $value : undef;
|
| Line 337... |
Line 347... |
| 337 |
}
|
347 |
}
|
| 338 |
|
348 |
|
| Line 442... |
Line 452... |
| 442 |
# Managers can sign up for as many shifts within their own department as they like...
|
452 |
# Managers can sign up for as many shifts within their own department as they like...
|
| 443 |
$leadership_change = 1;
|
453 |
$leadership_change = 1;
|
| 444 |
}
|
454 |
}
|
| Line 445... |
Line 455... |
| 445 |
|
455 |
|
| 446 |
if ($change eq "add" and convertDepartments(getUser($user_id)->{department})->{$department} < 1) {
|
456 |
if ($change eq "add" and convertDepartments(getUser($user_id)->{department})->{$department} < 1) {
|
| 447 |
return "<br>Denied! User ($user_id) is not a member of Department ($department)!<br>\n";
|
457 |
return "<br>Denied! User ($user_id) is not a member of Department ($department)!<br>\n" unless $department eq "CMP";
|
| Line 448... |
Line 458... |
| 448 |
}
|
458 |
}
|
| 449 |
|
459 |
|
| 450 |
if ($change eq "add" and findConflict ($user_id, $shift_id, $game_based)) {
|
460 |
if ($change eq "add" and findConflict ($user_id, $shift_id, $game_based)) {
|
| Line 451... |
Line 461... |
| 451 |
return "<br>Denied! There is a conflict with that shift's time!<br>\n";
|
461 |
return "<br>Denied! There is a conflict with that shift's time!<br>\n";
|
| 452 |
}
|
462 |
}
|
| 453 |
|
463 |
|
| 454 |
my ($game_type) = $dbh->selectrow_array ("select type from ".$game_based." where id = ?", undef, $shift_id);
|
464 |
my ($game_type) = $dbh->selectrow_array ("select type from ".$game_based." where id = ?", undef, $shift_id);
|
| Line 455... |
Line 465... |
| 455 |
if ($game_type =~ /^selected/ and !$leadership_change) {
|
465 |
if ($game_type =~ /^selected/ and !$leadership_change) {
|
| 456 |
return "<br>Denied! Only leadership can make changes to 'selected staffing' shifts!<br>\n";
|
466 |
return "<br>Denied! Only leadership can make changes to 'selected staffing' shifts!<br>\n" unless $department eq "CMP";
|
| 457 |
}
|
467 |
}
|
| Line 458... |
Line 468... |
| 458 |
|
468 |
|
| - |
|
469 |
if ($change eq "add" and $game_type eq "lead" and convertDepartments(getUser($user_id)->{department})->{$department} < 2 and $ORCUSER->{access} < 3) {
|
| - |
|
470 |
return "<br>Denied! Shift reserved for leadership staff!<br>\n";
|
| - |
|
471 |
}
|
| - |
|
472 |
|
| 459 |
if ($change eq "add" and $game_type eq "lead" and convertDepartments(getUser($user_id)->{department})->{$department} < 2 and $ORCUSER->{access} < 3) {
|
473 |
# my $MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY");
|
| 460 |
return "<br>Denied! Shift reserved for leadership staff!<br>\n";
|
474 |
my $MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY_".$department);
|
| 461 |
}
|
475 |
$MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY") unless defined $MAXSHIFTS;
|
| 462 |
|
476 |
if ($game_type eq "lead" and $department eq "OFF") { $MAXSHIFTS = 99; }
|
| Line 463... |
Line 477... |
| 463 |
my $MAXSHIFTS = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY");
|
477 |
|
| Line 484... |
Line 498... |
| 484 |
}
|
498 |
}
|
| 485 |
}
|
499 |
}
|
| Line 486... |
Line 500... |
| 486 |
|
500 |
|
| 487 |
print "<br>attempting to make DB changes...<br>";
|
501 |
print "<br>attempting to make DB changes...<br>";
|
| 488 |
if ($sth->execute (@DBARGS)) {
|
502 |
if ($sth->execute (@DBARGS)) {
|
| 489 |
$daily_count = signUpCount ($change, $user_id) unless $leadership_change;
|
503 |
$daily_count = signUpCount ($change, $user_id, $department) unless $leadership_change;
|
| 490 |
logit ($user_id, "Shift ".ucfirst($change).": $shift_id -> $role");
|
504 |
logit ($user_id, "Shift ".ucfirst($change).": $shift_id -> $role");
|
| 491 |
print "Success!...<br>You've signed up for $daily_count shifts today (you're currently allowed to sign up for $MAXSHIFTS per day).<br>\n";
|
505 |
print "Success!...<br>You've signed up for $daily_count shifts today (you're currently allowed to sign up for $MAXSHIFTS per day).<br>\n";
|
| 492 |
return;
|
506 |
return;
|
| 493 |
} else {
|
507 |
} else {
|
| Line 569... |
Line 583... |
| 569 |
my $dept = $t->{dept} // "";
|
583 |
my $dept = $t->{dept} // "";
|
| Line 570... |
Line 584... |
| 570 |
|
584 |
|
| 571 |
my $limit = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY_".$dept);
|
585 |
my $limit = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY_".$dept);
|
| Line -... |
Line 586... |
| - |
|
586 |
$limit = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY") unless defined $limit;
|
| - |
|
587 |
|
| - |
|
588 |
if ($t->{type} eq "lead" and $dept eq "OFF") { $limit = 99; }
|
| - |
|
589 |
|
| 572 |
$limit = getSetting ("MAX_SHIFT_SIGNUP_PER_DAY") unless defined $limit;
|
590 |
return 0 unless $limit > 0;
|
| Line 573... |
Line 591... |
| 573 |
|
591 |
|
| Line 574... |
Line 592... |
| 574 |
my $limitkey = $dept ? "sign_ups_today_".$dept : "sign_ups_today";
|
592 |
my $limitkey = $dept ? "sign_ups_today_".$dept : "sign_ups_today";
|
| 575 |
|
593 |
|
| 576 |
if (findConflict ($user->{RCid}, $t->{id}, $shifttype)) { return 0; }
|
594 |
if (findConflict ($user->{RCid}, $t->{id}, $shifttype)) { return 0; }
|
| Line 577... |
Line 595... |
| 577 |
|
595 |
|
| 578 |
if (!exists $user->{$limitkey}) {
|
596 |
if (!exists $user->{$limitkey}) {
|
| - |
|
597 |
$user->{$limitkey} = signUpCount('get', $user->{RCid}, $dept);
|
| - |
|
598 |
}
|
| - |
|
599 |
|
| - |
|
600 |
if ($shifttype eq "game") {
|
| - |
|
601 |
# if ($t->{gtype} !~ /^selected/ and $t->{gtype} ne "short track" and $user->{$limitkey} < $limit) {
|
| - |
|
602 |
if ($t->{signup} eq "full length" and $dept eq "OFF") {
|
| 579 |
$user->{$limitkey} = signUpCount('get', $user->{RCid}, $dept);
|
603 |
my ($full_length_count) = $dbh->selectrow_array ("select count(*) from v_shift_officiating where RCid = ? and gtype = 'full length' and date > '2022-01-01'", undef, $user->{RCid});
|
| 580 |
}
|
604 |
if ($full_length_count >= 2) {
|
| 581 |
|
605 |
return 0;
|
| 582 |
if ($shifttype eq "game") {
|
606 |
}
|
| 583 |
# if ($t->{gtype} !~ /^selected/ and $t->{gtype} ne "short track" and $user->{$limitkey} < $limit) {
|
607 |
}
|