JBAS-1643 Teacher cards pad ID to 4 chars min.
authorBill Erickson <berickxx@gmail.com>
Thu, 27 Oct 2016 20:35:22 +0000 (16:35 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl

index c9edc78..45ef109 100755 (executable)
@@ -252,9 +252,18 @@ sub iterate_csv_rows {
     $csv->column_names($csv->fields);
 
     while (my $phash = $csv->getline_hr($fh)) {
+
+        # If the ID value is less than 4 characters, pad the value 
+        # with zeros to be 4 characters long.  This will effect
+        # the barcode and password.
+        # Only do this for teacher accounts.
+        $phash->{student_id} = sprintf('%0.4d', $phash->{student_id})
+            if $is_teacher && length($phash->{student_id}) < 4;
+
         # Teacher cards have an extra 't' between district code and ID.
         $phash->{barcode} = $district_code . 
             ($is_teacher ? 't' : '') . $phash->{student_id};
+
         $row_handler->($phash);
     }