Top

HTML Code view of C:\GYSTDOIT\FAMED\BDAYCAL.PHP

03/28/2018 07:49:32 PM
Legend
Javascript Function Definition function name
Javascript Function Call function name
Div Tag Definition or Call DIV ID
PickList Control Definition PickList name
PickList Control Call PickList name
< HTML Tag >
Image or External Javascript URL
URL
In-page link
Comments
Javascript Functions
days_in_month
Picklist Controls
Input Controls
<?php //birthday.php
require_once 'login.php';
require 'age.php';
require 'famside.php';

$rootfamily = 'Gaffey/Dunn';
$passedparams = $_SERVER['QUERY_STRING'];
$querystring = explode( "?",$passedparams);
$qstring1 = explode( "=", $querystring[0]);
$qstring2 = explode( "=", $querystring[1]);

$today = mktime(0, 0, 0, date("m") , date("d"), date("Y"));
$currentYYYY = date('Y');
$currentMM = date('n');
$currentDD = date('j');
$calyear = $currentYYYY;

if ($qstring1[0]=='month') {
$qmonth = $qstring1[1];
$calmonth = $qmonth;
if ($qstring2[0]=='famside') {
$qfamside = $qstring2[1];
$familyside = $qfamside;
$flag = $familyside;
}

}
else {
$calmonth = $currentMM;
$familyside ='';
}



switch( $familyside) {
CASE 'M':
$famsideclause = ' AND substr(ind_id,1,1) IN (3,6,7)';
$flag =" Mom's Side";
break;
CASE 'F':
$famsideclause = ' AND substr( ind_id,1,1) IN (2,4,5,8,9)';
$flag =" Dad's Side";
break;
CASE 'D':
$famsideclause = ' AND substr( ind_id,1,1) =1 ';
$flag =" Kid's Side";
break;
DEFAULT:
$famsideclause = ' ';
$flag ='';
break;
}


$fom = date_create( $calyear . '-' . $calmonth . '-01' );

$numdays = days_in_month( $calmonth, $calyear);


$caltitle = date_format($fom , 'F Y');
$dow = date_format($fom , 'N');
$dom=0;
$offset= 7 + $dow;

// echo "DOW is $dow OFFSET is $offset NUMDAYS is $numdays Month Year is $caltitle ";

// set up array to hold daily contents
// first seven elements hold column headers
// load the array with day of the month values

$calout = [ 'Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday' ];

if ( $dow < 7 ) {
for ($j = 0; $j <= $dow; ++$j) {
$pointer = $j +$offset;
$calout[ $pointer] = ' ';
}

}


for ($j = 0; $j < $numdays+$dow; ++$j) {
$dom = $j;
$pointer = $dom +$offset;
$calout[ $pointer ] = (($dom >
0 ) && ($dom <= $numdays )) ? " $dom <br><br>" : '' ;
}



$navpanel = <<<_END1
<table border=1><tr><TD>
<a href="http://www.gystdoit.com/famed/ftd.php?branch=1"><img src="../family/ftd_icon.jpg" height="30" /> </a></td><td>
<a href="http://www.gystdoit.com/family/family_branches.htm"><img src="../family/branch_icon.jpg" height="30" target="top" /> </a></td><td>
<a href="http://www.gystdoit.com/famed/listbranch.php?member=1"><img src="../family/DBGRID.ICO" height="30" /> </a></td><td>
<a href="http://www.gystdoit.com/famed/portrait-main.php?famid=1"><img src="../family/portrait.png" height="30" /> </a></td><td>
<a href="bdaycal.php"><img src="calendar.bmp" height="30" /> </a></td><td>
<a href="findmember.php"><img src="BINOCULR.ICO" height="30" /> </a>
<a href="filesearchmain.php"><img src="clsdfold.ico" height="30" /> </a>
</td><td><a href="..\help\navhelp.htm"><img src="question.ico" height="30" /> </a>
</td><td><a href="http://www.gystdoit.com/family/Gaffey-Dunn_fpp.htm" target="_top"><img src="../family/house.gif" height="30" /> </a>
</TD> </tr></table>
_END1;


$calinks = '<table align=center style="border-spacing: 5px;">
<tr><th>january</th><th>february</th><th>march</th><th>april</th><th>may</th><th>june</th><th>july</th>';
$calinks = $calinks . '<th>august</th><th>september</th><th>october</th><th>november</th><th>december </th></tr><tr><td>';





$calinkpre = '<a href="http://www.gystdoit.com/famed/bdaycal.php?month=';
$ripcalinkpre = '<a href="http://www.gystdoit.com/famed/ripcal.php?month=';
for ($i=1; $i<13; $i++) {
$calinks = $calinks . $calinkpre . $i . '?famside=M">
Mom </a> - ';
$calinks = $calinks . $calinkpre . $i . '?famside=F">
Dad </a> - ';
$calinks = $calinks . $calinkpre . $i . '?famside=D">
Kids </a><br>';
$calinks = $calinks . $ripcalinkpre . $i . '">
Memoriam </a><br></td><td>';
}


$calinks = $calinks . '</tr></table>';


$conn = new mysqli($hn, $un, $pw, $db);
if ($conn->
connect_error) die($conn->
connect_error);

$query = "SELECT ind_id, fam_id,MONTH(born) mm,DAY(born) dd, given, married, born , photo, died FROM fam_member WHERE MONTH(born)=$calmonth and (died = '0000-00-00') and (born >
'1917-01-01') AND NOT ( (MONTH(born)=7) AND (DAY(born)=1)) " . $famsideclause . " order by DAY(born);";
$result = $conn->
query($query);
if (!$result) die($conn->
error);

$rows = $result->
num_rows;

$calist = <<<_END2
<html>
<head>
<title>Family GPS Birthday Calendar </title>
<link rel="stylesheet" type="text/css" href="SPC.CSS" />
</head>
<body>
$calinks
<table align=center border=1 style="border-spacing: 5px;" >
<colgroup span=7 width="12% 12% 12% 12% 12% 12% 12%" /></colgroup>
<tr>
<td colspan=3><h4> $rootfamily Calendar </h4> </td>
<td><H3> $caltitle </H3>
</td>
<td colspan=3> $navpanel </td>
</tr>
_END2;

$pointer = $offset;
$dom = 1;


$datadomold = '';
$bdcount = 1;
$oldcontent = '';

for ($j = 0; $j < $rows; ++$j)
{
$result->
data_seek($j);
$row = $result->
fetch_array(MYSQLI_ASSOC);

// if calendar is filtered to mother side or father side exclude family members from opposite side

$branch = substr(trim($row['ind_id']),0,1);

if ( $familyside == 'M') {
if ( STRPOS($branch, '24589') ) continue;
}
elseif ($familyside == 'F') {
if (STRPOS($branch, '367') ) continue;
}
else {
if ( $familyside == 'D') {
if (STRPOS($branch, '23456789') ) continue;
}

}


if ($row['married']) {
$name = $row['married'];
}
else {
$name = $row['given'];
}


$fam_id = $row['fam_id'] ;
$names = explode(" ",$row['given']);
$surname = $names[ count( $names) - 1];
$portrait = '../family/' . $surname . '_' . $fam_id . '_portrait.svg';

$bddate = date_create( $row['born']);
$bdyear = date_format( $bddate, 'Y');
$bdmonth = date_format( $bddate, 'm');
$bddd = date_format($bddate, 'j');

if ( $bdmonth >
$currentMM) {
$ageoffset = 1;
}
else {
$ageoffset = 0;
}


$famtype = famside( $fam_id);
if ($famtype == 'D') {
$border = 'purple';
}
else {
$border = ($famtype == 'F') ? 'red' : 'blue';
}


if ($row['photo'] ) {
$content = ' <a href="' . $portrait . '"><img src="../family/' . $row['photo'] . '" width="80" style="border:2px solid ' . $border . '"><br>' ;
$content = $content . $name . '</a> <span style="color:blue;"> ' ;
}
else {
$content = '<br > <a href="' . $portrait . '">' . $name . '</a> <span style="color:blue;"> ' ;
}

//if ($row['died'] <> '00-00-0000') {
// $content = $content . (age( $row['born'],$row['died'] ) +$ageoffset) . '</span><br>';
// }
else {
$content = $content . ($currentYYYY - $bdyear) . '</span><br>';
// }


$datadom = $row['dd'];
$pointer = $offset + $datadom;

$calout[ $pointer] = $calout[ $pointer] . $content;
}


$result = count($calout);
$out = $calist;
echo $out;

$result1 = count($calout)+3;
//echo ' $calout has ' . $result1 . 'elements';

for ($j = 0; $j < 7; ++$j) {
echo '<th>' . $calout[ $j ] . '</th>';
}

echo '</tr><tr>';



for ($j = 7; $j <= $result1; ++$j) {
if ( ($j % 7) == 0) {
if ($calout[ $j ] ) {
echo '<td>' . $calout[ $j ] . '</td></tr><tr>';
}
else {
echo '</tr><tr>';
}

}
else {
echo '<td>' . $calout[ $j ] . '</td>' ;
}

}


echo '</td></tr>';


echo <<<_END
<tr><td colspan=7>
<TABLE BORDER=1 ><TR><TH colspan=3> Legend </TH>
</TR><TR><TD><img src="father.jpg" width =60 style="border:2px solid red"> <br> Father's Side </TD>
<TD> <img src="family.jpg" width =60 style="border:2px solid purple"> <br> Descendants </TD>
<TD> <img src="mother.jpg" width =60 style="border:2px solid blue"> <br> Mother's Side </TD>
</TR></TABLE>
</td></tr></table>
_END;

function days_in_month($month, $year)
{
// calculate number of days in a month
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}


?>