my $syslog_facility = 'LOCAL6'; # matches Evergreen gateway
my $syslog_ops = 'pid';
my $profile = 901; # "Student Ecard"
+my $t_profile = 902; # "Teacher Ecard"
my $c_profile = 902; # "Classroom Databases"
my $net_access = 101; # No Access
my $ident_type = 101; # "Sch-district file" ident type
my $c_ident_value = "KCLS generated";
my $syslog_ident = 'ECARD';
my $alert_msg = 'Student Ecard: No physical checkouts. No computer/printing. No laptops.';
+my $t_alert_msg = 'Teacher Ecard: No physical checkouts. No computer/printing. No laptops.';
my $c_alert_msg = 'Classroom use only: No physical checkouts. No computer/printing. No laptops.';
my $alert2_msg = 'DO NOT MERGE OR EDIT. RECORD MANAGED CENTRALLY.';
my $alert_type = 20; # "Alerting note, no Blocks" standing penalty
my $district_code; # 3-char school district code
my $default_pass;
my $commit_mode = 'rollback'; # single xact, then rollback (for testing)
+my $is_teacher = 0;
my $is_classroom = 0;
my $purge_all = 0;
my $out_dir = '.';
'commit-mode=s' => \$commit_mode,
'purge-all' => \$purge_all,
'default-pass=s' => \$default_pass,
+ 'teacher' => \$is_teacher,
'classroom' => \$is_classroom,
'log-stdout' => \$log_stdout,
'out-dir=s' => \$out_dir,
--district-code
3-character school district code.
+ --teacher
+ Process CSV file entries as teacher accounts.
+
+ --classroom
+ Process CSV file entries as classroom accounts.
+
--home-ou
Org unit ID of the home library used for all patrons loaded
in the current file. NOTE: Only use this parameter if the
$csv->column_names($csv->fields);
while (my $phash = $csv->getline_hr($fh)) {
- $phash->{barcode} = $district_code . $phash->{student_id};
+ # Teacher cards have an extra 't' between district code and ID.
+ $phash->{barcode} = $district_code .
+ ($is_teacher ? 't' : '') . $phash->{student_id};
$row_handler->($phash);
}
my $now_date = DateTime->now;
my $now_year = $now_date->year;
- if ($is_classroom) {
+ if ($is_classroom || $is_teacher) {
# classroom cards expire after 10 years.
$now_date->set_year($now_year + 10);
$phash->{expire_date} = $now_date;
$phash->{$_} =~ s/(^\s*|\s*$)//g if $phash->{$_};
}
+ # Apply default DoB for classroom / teacher cards.
+ if ($is_classroom || $is_teacher) {
+ $phash->{dob} = '1900-01-01' unless $phash->{dob};
+ }
+
my @required = qw/student_id first_given_name family_name dob/;
# check required fields
my $barcode = $phash->{barcode};
my @user_bind = (
- $is_classroom ? 'f' : 't',
- $is_classroom ? $c_profile : $profile,
+ ($is_classroom || $is_teacher) ? 'f' : 't',
+ $is_classroom ? $c_profile : ($is_teacher ? $t_profile : $profile),
$is_classroom ? $c_ident_type : $ident_type,
$barcode, $home_ou, $net_access,
$phash->{passwd},
my @alrt_bind = (
$root_org,
$alert_type,
- $is_classroom ? $c_alert_msg : $alert_msg
+ $is_classroom ? $c_alert_msg : ($is_teacher ? $t_alert_msg : $alert_msg)
);
my @alrt2_bind = (