| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 #!/usr/local/bin/perl 2 3 # 4 # Display Yahrzeit Report 5 # 6 7 ;open (STDIN,"/dev/null"); 8 $dbg++; 9 10 $host = `hostname`; 11 chop $host; 12 $driver = "mysql"; 13 if ($host eq "bsd7") 14 { 15 $BASE="/disk1/data/yi-drupal/yahrzeit"; 16 $dsn = "DBI:$driver:database=yi-drupal;host=localhost;port=3306"; 17 } 18 else 19 { 20 $BASE="/disk1/data/yi/new/yahrzeit"; 21 $dsn = "DBI:$driver:database=yi-drupal;host=localhost;port=3306;mysql_socket=/disk2/databases/mysql.sock"; 22 23 } 24 $BIN=$BASE."/bin"; 25 26 if ($dbg) { 27 open (LOG,">/var/tmp/yahrdbg.log"); 28 print LOG "yahrltrs: $month\n"; 29 } 30 @hebrew_months= ("Nisan","Iyar","Sivan","Tammuz","Av","Elul","Tishri", 31 "Heshvan","Kislev","Teveth","Shevat","Adar I","Adar II"); 32 foreach (@hebrew_months) { 33 push (@hmos,"\L$_"); 34 } 35 36 37 open (RPTOUT, ">$OUTDIR/summary"); 38 # 39 # Connect to database 40 # 41 42 if (!defined($dbh = DBI->connect($dsn, "drupaluser", "dr;pwd"))) { 43 print "Failed to connect to database"; 44 exit 1; 45 } 46 47 $drh = DBI->install_driver("mysql"); 48 push(@INC,$BASE); 49 require "getopts.pl"; 50 require "fmtsub"; 51 use DBI; 52 @months = `cd $BIN; /usr/local/bin/clisp $BIN/dr-yahr-twomonths.cl`; 53 54 unless (@months) { 55 print "can't execute dr-yahr-twomonths.cl"; 56 } 57 58 print '<h3 style="text-align: center">'."Yahrzeits for $months[0] and $months[1]</h3>"; 59 print <<EOT ; 60 <table id="yahrzeit" border="1" width="866" cellspacing="0" cellpadding="5"> 61 <tr> 62 <th>Name</th> 63 <th>Relation</th> 64 <th>Person observing</th> 65 <th colspan="2">Dates</th> 66 <th>Shabbos</th> 67 </tr> 68 EOT 69 foreach $month (@months) { 70 chop($month); 71 $mo = 0; 72 foreach (@hmos) { 73 $mo++; 74 if ("\L$month" eq substr($_,0,length($month))) { 75 $heb_month=$hebrew_months[$mo-1]; 76 $mno=$mo; 77 last; 78 } 79 } 80 81 $sth = $dbh->prepare( $sql = 'SELECT y_notify_name, y_rel, y_rel_name, ' 82 . 'y_dt_dy, y_dt_mo, y_dt_yr , ' 83 . 'addr_street, addr_city, addr_prov, addr_postcd ' 84 . "FROM identity as i, yz WHERE y_dt_mo like \'$month%\' and " 85 . 'yz.serial=i.serial order by y_dt_mo, y_dt_dy '); 86 87 if ($dbg) { print LOG $sql,"\n"; } 88 $sth->execute; 89 90 @flds = split(" ","membername relation relationname y_dt_dy y_dt_mo y_dt_yr addr_street addr_city addr_prov addr_postcd"); 91 92 while (my $ref = $sth->fetchrow_arrayref) { 93 @data=(); 94 $i =0; 95 for $fld(@flds) { 96 $key{$fld} = $$ref[$i++]; 97 print LOG "$fld : $key{$fld}\n" if $dbg; 98 } 99 $key{yahrhebdate}= $key{y_dt_dy}." ".$key{y_dt_mo}; 100 101 if (defined(y_dt_yr)) { 102 $key{yahrhebdate}.= " ".$key{y_dt_yr}; 103 } 104 delete($key{y_dt_dy}); 105 delete($key{y_dt_mo}); 106 delete($key{y_dt_yr}); 107 108 $yy=0; 109 ($yd,$ym)=split(/[ \t]+/,$key{"yahrhebdate"},2); 110 if($ym =~ /\s*(\d+)$/) { $yy =$1; } 111 $ym =~ s/\s*(\d+)$//; 112 113 $tmo=$mo=0; 114 foreach (@hmos) { 115 $mo++; 116 if ("\L$ym" eq substr($_,0,length($ym))) { 117 $tmo=$mo; 118 last; 119 } 120 } 121 print LOG "tmo: $tmo\n" if $dbg; 122 if ($tmo) { 123 if (! $yy && ( ($tmo == 12 && $ym eq "Adar") #ambiguous ADAR 124 || (($tmo == 8 || $tmo == 9) && ($yd == 30)))) { 125 print "Ambiguous date: $yd $ym for $key{membername}\n"; 126 } else { 127 $yy = $yy ? $yy : "5759"; # default to non leap year 128 if ( $tmo == $mno || ($tmo == 13 && $mno ==12) ) { 129 print LOG "( $tmo $yd $yy )\n" if $dbg; 130 open (args, ">/var/tmp/yzargs"); 131 print args "( $tmo $yd $yy )\n"; 132 close args; 133 @result=`cd $BIN; /usr/local/bin/clisp $BIN/get_yahrzeit.cl`; 134 print LOG "result: ", @result, "\n" if $dbg; 135 ($engdate,$shab,$date2,$shab2) = @result; 136 137 chop($engdate); 138 $engdate=~ s/(.*,.*),.*/$1/; 139 print LOG "date2: $engdate\n" if $dbg; 140 chop($shab); 141 $key{var0}=0; 142 if ($date2) { 143 chop($date2); 144 chop($shab2); 145 146 $date2=~ s/,.*//; 147 $key{var0}=1; 148 $key{yahrshab2}= " and ".$shab2; 149 } 150 $key{yahrshab}= $shab; 151 $t=$key{relation}; 152 $key{relation}= "\L$t"; 153 $relationname = $key{relationname}; 154 $relation = $key{relation}; 155 $relation = "\u$relation"; 156 $membername = $key{membername}; 157 $hebd = $key{yahrhebdate}; 158 $hebd =~ s/ \d.*$//; 159 ( $engd = $engdate ) =~ s/(...)[^ ]+ (...)[^ ]+ (.*)/$1, $2. $3/; 160 $key{var1}=1; 161 if ($shab =~ /NIL/) { 162 $shab = "Yom Tov"; 163 $key{yahrshab}= $shab; 164 $key{var1}=0; 165 } 166 $shab =~ s/Shabbos //; 167 $shab =~ s/Parashas //; 168 $data = <<EOD ; 169 <tr> 170 <td>$relationname</td> 171 <td>$relation</td> 172 <td>$membername</td> 173 <td>$hebd</td> 174 <td>$engd</td> 175 <td>$shab</td> 176 </tr> 177 EOD 178 print $data; 179 } 180 %key=(); %relation=(); @mydata=(); 181 } 182 } else { 183 print LOG "Unrecognized month $ym for $key{membername}\n"; 184 } 185 $have_data=0; 186 @mydata = (); 187 } 188 $sth->finish; 189 } 190 print "</table>"; 191 192 193 close(STDOUT); 194 exit; 195 196 197 198 199
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |