#!/usr/local/bin/perl # # Display Yahrzeit Report # ;open (STDIN,"/dev/null"); $dbg++; $host = `hostname`; chop $host; $driver = "mysql"; if ($host eq "bsd7") { $BASE="/disk1/data/yi-drupal/yahrzeit"; $dsn = "DBI:$driver:database=yi-drupal;host=localhost;port=3306"; } else { $BASE="/disk1/data/yi/new/yahrzeit"; $dsn = "DBI:$driver:database=yi-drupal;host=localhost;port=3306;mysql_socket=/disk2/databases/mysql.sock"; } $BIN=$BASE."/bin"; if ($dbg) { open (LOG,">/var/tmp/yahrdbg.log"); print LOG "yahrltrs: $month\n"; } @hebrew_months= ("Nisan","Iyar","Sivan","Tammuz","Av","Elul","Tishri", "Heshvan","Kislev","Teveth","Shevat","Adar I","Adar II"); foreach (@hebrew_months) { push (@hmos,"\L$_"); } open (RPTOUT, ">$OUTDIR/summary"); # # Connect to database # if (!defined($dbh = DBI->connect($dsn, "drupaluser", "dr;pwd"))) { print "Failed to connect to database"; exit 1; } $drh = DBI->install_driver("mysql"); push(@INC,$BASE); require "getopts.pl"; require "fmtsub"; use DBI; @months = `cd $BIN; /usr/local/bin/clisp $BIN/dr-yahr-twomonths.cl`; unless (@months) { print "can't execute dr-yahr-twomonths.cl"; } print '

'."Yahrzeits for $months[0] and $months[1]

"; print < Name Relation Person observing Dates Shabbos EOT foreach $month (@months) { chop($month); $mo = 0; foreach (@hmos) { $mo++; if ("\L$month" eq substr($_,0,length($month))) { $heb_month=$hebrew_months[$mo-1]; $mno=$mo; last; } } $sth = $dbh->prepare( $sql = 'SELECT y_notify_name, y_rel, y_rel_name, ' . 'y_dt_dy, y_dt_mo, y_dt_yr , ' . 'addr_street, addr_city, addr_prov, addr_postcd ' . "FROM identity as i, yz WHERE y_dt_mo like \'$month%\' and " . 'yz.serial=i.serial order by y_dt_mo, y_dt_dy '); if ($dbg) { print LOG $sql,"\n"; } $sth->execute; @flds = split(" ","membername relation relationname y_dt_dy y_dt_mo y_dt_yr addr_street addr_city addr_prov addr_postcd"); while (my $ref = $sth->fetchrow_arrayref) { @data=(); $i =0; for $fld(@flds) { $key{$fld} = $$ref[$i++]; print LOG "$fld : $key{$fld}\n" if $dbg; } $key{yahrhebdate}= $key{y_dt_dy}." ".$key{y_dt_mo}; if (defined(y_dt_yr)) { $key{yahrhebdate}.= " ".$key{y_dt_yr}; } delete($key{y_dt_dy}); delete($key{y_dt_mo}); delete($key{y_dt_yr}); $yy=0; ($yd,$ym)=split(/[ \t]+/,$key{"yahrhebdate"},2); if($ym =~ /\s*(\d+)$/) { $yy =$1; } $ym =~ s/\s*(\d+)$//; $tmo=$mo=0; foreach (@hmos) { $mo++; if ("\L$ym" eq substr($_,0,length($ym))) { $tmo=$mo; last; } } print LOG "tmo: $tmo\n" if $dbg; if ($tmo) { if (! $yy && ( ($tmo == 12 && $ym eq "Adar") #ambiguous ADAR || (($tmo == 8 || $tmo == 9) && ($yd == 30)))) { print "Ambiguous date: $yd $ym for $key{membername}\n"; } else { $yy = $yy ? $yy : "5759"; # default to non leap year if ( $tmo == $mno || ($tmo == 13 && $mno ==12) ) { print LOG "( $tmo $yd $yy )\n" if $dbg; open (args, ">/var/tmp/yzargs"); print args "( $tmo $yd $yy )\n"; close args; @result=`cd $BIN; /usr/local/bin/clisp $BIN/get_yahrzeit.cl`; print LOG "result: ", @result, "\n" if $dbg; ($engdate,$shab,$date2,$shab2) = @result; chop($engdate); $engdate=~ s/(.*,.*),.*/$1/; print LOG "date2: $engdate\n" if $dbg; chop($shab); $key{var0}=0; if ($date2) { chop($date2); chop($shab2); $date2=~ s/,.*//; $key{var0}=1; $key{yahrshab2}= " and ".$shab2; } $key{yahrshab}= $shab; $t=$key{relation}; $key{relation}= "\L$t"; $relationname = $key{relationname}; $relation = $key{relation}; $relation = "\u$relation"; $membername = $key{membername}; $hebd = $key{yahrhebdate}; $hebd =~ s/ \d.*$//; ( $engd = $engdate ) =~ s/(...)[^ ]+ (...)[^ ]+ (.*)/$1, $2. $3/; $key{var1}=1; if ($shab =~ /NIL/) { $shab = "Yom Tov"; $key{yahrshab}= $shab; $key{var1}=0; } $shab =~ s/Shabbos //; $shab =~ s/Parashas //; $data = < $relationname $relation $membername $hebd $engd $shab EOD print $data; } %key=(); %relation=(); @mydata=(); } } else { print LOG "Unrecognized month $ym for $key{membername}\n"; } $have_data=0; @mydata = (); } $sth->finish; } print ""; close(STDOUT); exit;