Error: Recipient Number $nd{'recipientnumber'} is too long
\n};
# print qq{\n};
# exit;
# }
$wr->dataElement('RecipientNumber', $nd{'recipientnumber'} );
$wr->dataElement('Region', $nd{'region'} );
$wr->endTag('Applicant');
my $sy = $schoolyear;
$sy =~ s/-|\s+//g; # strip dashes and spaces.
$wr->dataElement('Year', $sy ); # strip hyphen
# Vendor Info
$wr->startTag('Vendor');
$wr->dataElement('Name','Les Richardson' );
$wr->dataElement('Product','Open Administration for Schools');
$wr->dataElement('Version', "10.0 ($version)" );
$wr->dataElement('Date', $currdate );
$wr->dataElement('ReferenceDataDate', $referencedatadate );
$wr->endTag('Vendor');
$wr->startTag('PrimaryContact');
if ( $nd{email} ) {
$wr->dataElement('Email', $nd{email} );
}
$wr->startTag('PhoneNumber');
my $phone = formatPhone( $nd{'contact_phone'}, $lex{Contact} );
if ( not $phone ) {
my $error = "$lex{'Nominal Roll'}:contact_phone:Format Error:$nd{'contact_phone'}:Should be 10 digits";
push @errors, $error;
}
$wr->dataElement('Number', $phone );
if ( $nd{'contact_phone_ext'} ) {
$wr->dataElement('Extension', $nd{'contact_phone_ext'} );
}
$wr->endTag('PhoneNumber');
if ( $nd{'contact_fax'} ) {
my $fax = formatPhone( $nd{'contact_fax'}, $lex{Contact} );
$wr->startTag('FaxNumber');
$wr->dataElement('Number', $fax );
$wr->endTag('FaxNumber');
}
$wr->startTag('Addresses');
$wr->startTag('Mailing');
$wr->dataElement('Street', $nd{'contact_address'} );
$wr->dataElement('City', $nd{'contact_city'} );
$wr->dataElement('ProvinceState', $nd{'contact_province'} );
$wr->dataElement('Country', 'CA');
$wr->dataElement('PostalCode', $nd{'contact_postalcode'} );
$wr->endTag('Mailing');
$wr->dataElement('StreetSameAsMailing', 'true');
$wr->endTag('Addresses');
$wr->dataElement('FamilyName', $nd{'contact_lastname'} );
$wr->dataElement('GivenName', $nd{'contact_firstname'} );
$wr->dataElement('Title', $nd{'contact_title'} );
$wr->endTag('PrimaryContact');
$wr->dataElement('HasSecondary', 'false');
#$wr->dataElement('SecondaryContact'); # we're not doing this...
$wr->startTag('Certifier');
$wr->dataElement('FamilyName', $nd{'certifier_lastname'} );
$wr->dataElement('GivenName', $nd{'certifier_firstname'} );
$wr->dataElement('Title', $nd{'certifier_title'} );
$wr->endTag('Certifier');
$wr->dataElement('CertificationDate', $currdate );
$wr->startTag('Identification');
$wr->startTag('DeliveryOrganization', 'isRecipient' => 'true');
$wr->dataElement('Id', $nd{recipient_id} );
# New Values Here.
$wr->startTag('PhoneNumber');
my $phone = formatPhone( $nd{'recipient_phone'}, $lex{Contact} );
if ( not $phone ) {
my $error = "$lex{'Nominal Roll'} recipient_phone ".
"format error: $nd{'recipient_phone'} Should be 10 digits";
push @errors, $error;
}
$wr->dataElement('Number', $phone );
if ( $nd{'recipient_phone_ext'} ) {
$wr->dataElement('Extension', $nd{'recipient_phone_ext'} );
}
$wr->endTag('PhoneNumber');
if ( $nd{'recipient_fax'} ) {
my $fax = formatPhone( $nd{'recipient_fax'}, $lex{Contact} );
$wr->startTag('FaxNumber');
$wr->dataElement('Number', $fax );
$wr->endTag('FaxNumber');
}
$wr->startTag('Addresses');
$wr->startTag('Mailing');
$wr->dataElement('Street', $nd{'recipient_street'} );
$wr->dataElement('City', $nd{'recipient_city'} );
$wr->dataElement('ProvinceState', $nd{'recipient_province'} );
$wr->dataElement('Country', 'CA');
$wr->dataElement('PostalCode', $nd{'recipient_postalcode'} );
$wr->endTag('Mailing');
$wr->endTag('Addresses');
# End of New Values.
$wr->dataElement('Type', $nd{recipient_type} );
$wr->dataElement('Name', $nd{recipient_name} );
$wr->endTag('DeliveryOrganization');
$wr->endTag('Identification');
# previous value with xml:lang attribute
# $wr->dataElement('Name', $deliveryorg_name, [ $xml => 'lang'], 'en' );
# Reporting Orgs: not needed unless doing subreports.
# $wr->startTag('ReportingDeliveryOrganizations');
# $wr->startTag('DeliveryOrganization');
# $wr->dataElement('Id', $deliveryorg_id );
# $wr->dataElement('Type', $deliveryorg_type );
# $wr->dataElement('Name', $deliveryorg_name );
# $wr->endTag('DeliveryOrganization');
# $wr->endTag('ReportingDeliveryOrganizations');
$wr->dataElement('ReportingPeriod', 'Annual' );
# Reported Orgs
$wr->startTag('ReportedDeliveryOrganizations');
$wr->startTag('DeliveryOrganization');
$wr->dataElement('Id', $nd{deliveryorg_id} );
$wr->dataElement('Type', $nd{deliveryorg_type} );
$wr->dataElement('Name', $nd{deliveryorg_name} );
# $wr->dataElement('Name', $deliveryorg_name, [ $xml => 'lang'], 'en' );
# Get Students
my @students;
# my $sth = $dbh->prepare("select si.studnum from student_inac si
# left outer join studentall sa on si.studnum = sa.studnum
# order by sa.grade, sa.lastname, sa.firstname");
print "
Writing Student Information
\n";
my $sth = $dbh->prepare("select studnum from student_inac");
$sth->execute;
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
$wr->startTag('Clients');
while ( my $studnum = $sth->fetchrow ) {
my $ref = getStudentValues( $dbh, $studnum );
if ( $ref ) { # not skipped since PK.
mkStudent( $wr, $ref );
push @students, $studnum;
}
}
$wr->endTag('Clients');
# Display Current and Previous NR Students
my $sth = $dbh->prepare("select defaultvalue from meta where fieldid = 'serviceprovision'");
$sth->execute;
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
my $default = $sth->fetchrow;
my %srview = split(/\s+/, $default);
# foreach my $key ( sort keys %srview ) {
# print "K:$key V:$srview{$key} \n";
# }
# Current Students
print "
$lex{Current} $lex{'Nominal Roll'} $lex{Students}
\n";
my $first = 1;
my $ccount = 1;
my %grades;
$sth = $dbh->prepare("select grade from studentall where studnum = ? and grade != '' and grade != ''");
foreach my $key ( sort keys %currstuds ) {
my ($lastname, $firstname, $studnum ) = split(/:/, $key);
my $val = $currstuds{$key};
$sth->execute( $studnum );
if ( $DBI::errstr ) { print $DBI::errstr; die $DBI::errstr; }
my $gr = $sth->fetchrow;
$grades{$gr}++;
if ( $first ) {
print qq{
\n};
print qq{
Name
Grade
Service Provision
\n};
$first = 0;
}
print qq{
$ccount. $lastname, $firstname ($studnum)
};
my $sp = $srview{$val};
$sp =~ s/\_/ /g; # replace underscores with spaces
print qq{
$gr
$sp
\n};
$ccount++;
}
print qq{
\n};
# Print Students by Grade.
print qq{
\n};
print qq{
Grade
Count
\n};
my $totalstudent;
foreach my $grade ( sort {$a <=> $b} keys %grades ) {
$totalstudent += $grades{$grade};
print qq{