| Line -... |
Line 1... |
| - |
|
1 |
package RollerCon;
|
| 1 |
## RollerCon support functions...
|
2 |
## RollerCon support functions...
|
| Line 2... |
Line 3... |
| 2 |
|
3 |
|
| 3 |
use strict;
|
4 |
use strict;
|
| 4 |
use cPanelUserConfig;
|
5 |
use cPanelUserConfig;
|
| 5 |
use Exporter;
|
6 |
use Exporter 'import';
|
| 6 |
use CGI qw/:standard :netscape/;
|
7 |
use CGI qw/param header start_html url/;
|
| 7 |
use CGI::Cookie;
|
8 |
use CGI::Cookie;
|
| 8 |
use DBI;
|
9 |
use DBI;
|
| Line -... |
Line 10... |
| - |
|
10 |
use WebDB;
|
| Line 9... |
Line 11... |
| 9 |
use WebDB;
|
11 |
|
| 10 |
|
12 |
our @EXPORT = qw( $ORCUSER getRCDBH getAccessLevels authDB max authenticate getShiftDepartment getDepartments convertDepartments convertTime getSchedule getRCid getSetting getUser getUserEmail getUserDerbyName getYears printRCHeader changeShift modShiftTime signUpCount signUpEligible findConflict changeLeadShift logit );
|
| 11 |
|
13 |
|
| 12 |
my $dbh = WebDB->connect ();
|
14 |
my $dbh = WebDB->connect ();
|
| Line 251... |
Line 253... |
| 251 |
}
|
253 |
}
|
| Line 252... |
Line 254... |
| 252 |
|
254 |
|
| 253 |
return $output;
|
255 |
return $output;
|
| Line -... |
Line 256... |
| - |
|
256 |
}
|
| - |
|
257 |
|
| - |
|
258 |
sub convertTime {
|
| - |
|
259 |
my $time = shift || return;
|
| - |
|
260 |
|
| - |
|
261 |
if ($time =~ / - /) {
|
| - |
|
262 |
return join " - ", map { convertTime ($_) } split / - /, $time;
|
| - |
|
263 |
}
|
| - |
|
264 |
|
| - |
|
265 |
if ($ORCUSER->{timeformat} eq "24hr") {
|
| - |
|
266 |
if ($time =~ /^\d{1,2}:\d{2}$/) { return $time; }
|
| - |
|
267 |
} else {
|
| - |
|
268 |
my ($hr, $min) = split /:/, $time;
|
| - |
|
269 |
my $ampm = " am";
|
| - |
|
270 |
if ($hr >= 12) {
|
| - |
|
271 |
$hr -= 12 unless $hr == 12;
|
| - |
|
272 |
$ampm = " pm";
|
| - |
|
273 |
} elsif ($hr == 0) {
|
| - |
|
274 |
$hr = 12;
|
| - |
|
275 |
}
|
| - |
|
276 |
return $hr.":".$min.$ampm;
|
| - |
|
277 |
}
|
| 254 |
}
|
278 |
}
|
| 255 |
|
279 |
|
| 256 |
sub getSchedule {
|
280 |
sub getSchedule {
|
| Line 257... |
Line 281... |
| 257 |
my $RCid = shift // return "ERROR: No RCid provided to getSchedule";
|
281 |
my $RCid = shift // return "ERROR: No RCid provided to getSchedule";
|
| 258 |
my $filter = shift // "";
|
282 |
my $filter = shift // "";
|
| 259 |
|
283 |
|
| 260 |
my @whereclause;
|
284 |
my @whereclause;
|
| 261 |
if ($filter eq "all") {
|
285 |
if ($filter eq "all") {
|
| 262 |
push @whereclause, "date >= '2022-01-01'";
|
286 |
push @whereclause, "date >= '2023-01-01'";
|
| 263 |
} else {
|
287 |
} else {
|
| 264 |
push @whereclause, "date >= date(now())";
|
288 |
push @whereclause, "date >= date(now())";
|
| Line 329... |
Line 353... |
| 329 |
}
|
353 |
}
|
| 330 |
$s->{role} =~ s/\-\d$//;
|
354 |
$s->{role} =~ s/\-\d$//;
|
| Line 331... |
Line 355... |
| 331 |
|
355 |
|
| 332 |
# push @shifts, $h->li ({ class=> $s->{date} eq $dt ? "nowrap highlighted" : "nowrap shaded" }, join ' ', $s->{date}, $s->{dayofweek}, $s->{time}, $s->{location}, getDepartments()->{$s->{dept}}, $s->{role}, $s->{teams}, $s->{buttons});
|
356 |
# push @shifts, $h->li ({ class=> $s->{date} eq $dt ? "nowrap highlighted" : "nowrap shaded" }, join ' ', $s->{date}, $s->{dayofweek}, $s->{time}, $s->{location}, getDepartments()->{$s->{dept}}, $s->{role}, $s->{teams}, $s->{buttons});
|
| - |
|
357 |
# push @shifts, $h->li ({ class=> $s->{date} eq $dt ? "highlighted" : "shaded" }, join ' ', $s->{date}, $s->{dayofweek}, $s->{time}, $s->{location}, getDepartments()->{$s->{dept}}, $s->{role}, $s->{teams}, $s->{buttons});
|
| 333 |
# push @shifts, $h->li ({ class=> $s->{date} eq $dt ? "highlighted" : "shaded" }, join ' ', $s->{date}, $s->{dayofweek}, $s->{time}, $s->{location}, getDepartments()->{$s->{dept}}, $s->{role}, $s->{teams}, $s->{buttons});
|
358 |
$s->{time} = convertTime $s->{time};
|
| 334 |
push @shifts, $h->li ({ class=> $s->{date} eq $dt ? "highlighted" : "shaded" }, $h->div ({ class=>"lisp0" }, [ $h->div ({ class=>"liLeft" }, join ' ', ($s->{date}, $s->{dayofweek}, $s->{time}, $s->{location}, getDepartments()->{$s->{dept}}, $s->{role}, $s->{teams})), $h->div ({ class=>"liRight" }, $s->{buttons}) ]));
|
359 |
push @shifts, $h->li ({ class=> $s->{date} eq $dt ? "highlighted" : "shaded" }, $h->div ({ class=>"lisp0" }, [ $h->div ({ class=>"liLeft" }, join ' ', ($s->{date}, $s->{dayofweek}, $s->{time}, $s->{location}, getDepartments()->{$s->{dept}}, $s->{role}, $s->{teams})), $h->div ({ class=>"liRight" }, $s->{buttons}) ]));
|
| Line 335... |
Line 360... |
| 335 |
}
|
360 |
}
|
| 336 |
|
361 |
|
| Line 381... |
Line 406... |
| 381 |
my ($dname) = $sth->fetchrow_array();
|
406 |
my ($dname) = $sth->fetchrow_array();
|
| 382 |
return $dname;
|
407 |
return $dname;
|
| 383 |
}
|
408 |
}
|
| Line 384... |
Line 409... |
| 384 |
|
409 |
|
| 385 |
sub getYears {
|
410 |
sub getYears {
|
| 386 |
# my $sth = $dbh->prepare("select distinct year(date) from v_shift_admin_view union select year(now())");
|
411 |
my $sth = $dbh->prepare("select distinct year from (select distinct year(date) as year from v_shift_admin_view union select year(now()) as year) years order by year");
|
| 387 |
my $sth = $dbh->prepare("select distinct year(date) from v_shift_admin_view");
|
412 |
# my $sth = $dbh->prepare("select distinct year(date) from v_shift_admin_view");
|
| 388 |
$sth->execute();
|
413 |
$sth->execute();
|
| 389 |
my @years;
|
414 |
my @years;
|
| 390 |
while (my ($y) =$sth->fetchrow_array()) { push @years, $y; }
|
415 |
while (my ($y) =$sth->fetchrow_array()) { push @years, $y; }
|
| 391 |
return \@years;
|
416 |
return \@years;
|
| Line 392... |
Line 417... |
| 392 |
}
|
417 |
}
|
| 393 |
|
418 |
|
| 394 |
sub printRCHeader {
|
419 |
sub printRCHeader {
|
| 395 |
my $PAGE_TITLE = shift;
|
420 |
my $PAGE_TITLE = shift;
|
| 396 |
use CGI qw/start_html/;
|
421 |
# use CGI qw/start_html/;
|
| Line 397... |
Line 422... |
| 397 |
use HTML::Tiny;
|
422 |
use HTML::Tiny;
|
| 398 |
my $h = HTML::Tiny->new( mode => 'html' );
|
423 |
my $h = HTML::Tiny->new( mode => 'html' );
|
| Line 504... |
Line 529... |
| 504 |
$daily_count = signUpCount ('get', $user_id, $department);
|
529 |
$daily_count = signUpCount ('get', $user_id, $department);
|
| 505 |
if ($change eq "add" and $daily_count >= $MAXSHIFTS and !$leadership_change) {
|
530 |
if ($change eq "add" and $daily_count >= $MAXSHIFTS and !$leadership_change) {
|
| 506 |
return "<br>Denied! You may only sign up for $MAXSHIFTS $game_type shifts in one day!<br>\n";
|
531 |
return "<br>Denied! You may only sign up for $MAXSHIFTS $game_type shifts in one day!<br>\n";
|
| 507 |
}
|
532 |
}
|
| 508 |
# if ($change eq "add" and $game_based eq "game" and $department eq "OFF" and $game_type eq "full length") {
|
533 |
# if ($change eq "add" and $game_based eq "game" and $department eq "OFF" and $game_type eq "full length") {
|
| 509 |
# 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_id);
|
534 |
# my ($full_length_count) = $dbh->selectrow_array ("select count(*) from v_shift_officiating where RCid = ? and gtype = 'full length' and date > '2023-01-01'", undef, $user_id);
|
| 510 |
# if ($full_length_count >= 3) {
|
535 |
# if ($full_length_count >= 3) {
|
| 511 |
# return "<br>Denied! You may only sign up to officiate 3 $game_type games (total)!<br>\n";
|
536 |
# return "<br>Denied! You may only sign up to officiate 3 $game_type games (total)!<br>\n";
|
| 512 |
# }
|
537 |
# }
|
| 513 |
# }
|
538 |
# }
|
| 514 |
}
|
539 |
}
|
| Line 638... |
Line 663... |
| 638 |
}
|
663 |
}
|
| Line 639... |
Line 664... |
| 639 |
|
664 |
|
| 640 |
if ($shifttype eq "game") {
|
665 |
if ($shifttype eq "game") {
|
| 641 |
# if ($t->{gtype} !~ /^selected/ and $t->{gtype} ne "short track" and $user->{$limitkey} < $limit) {
|
666 |
# if ($t->{gtype} !~ /^selected/ and $t->{gtype} ne "short track" and $user->{$limitkey} < $limit) {
|
| 642 |
# if ($t->{gtype} eq "full length" and $dept eq "OFF") {
|
667 |
# if ($t->{gtype} eq "full length" and $dept eq "OFF") {
|
| 643 |
# 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});
|
668 |
# my ($full_length_count) = $dbh->selectrow_array ("select count(*) from v_shift_officiating where RCid = ? and gtype = 'full length' and date > '2023-01-01'", undef, $user->{RCid});
|
| 644 |
# if ($full_length_count >= 3) {
|
669 |
# if ($full_length_count >= 3) {
|
| 645 |
# return 0;
|
670 |
# return 0;
|
| 646 |
# }
|
671 |
# }
|
| 647 |
# }
|
672 |
# }
|