Home      Products & Services      Contact Us      Links

WebHatchers will design & develop your site for you.

Website Menu Heaven: menus, buttons, etc.

Send us your questions.

site search by freefind

SEO, Google, Privacy
   and Anonymity
Browser Insanity
Popups and Tooltips
Free Website Search
HTML Form Creator
Buttons and Menus
Image Uploading
Website Poll
IM and Texting
   or Not MySQL
Personal Status Boards
Content Management
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS
Blog CMS
Customer Records
   Management CMS
Address Book CMS
Private Messaging CMS
Chat Room CMS
JavaScript Charts
   and Graphs

Free Personal Status Boards (PSB™)

Free Standard Free PSB

Free PSB Pro Version

Free Social PSB

Free Social PSB Plus (with Email)

Free Business PSB

Free Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement

Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

MC Scheduler Management—View One Caregiver

This script is called View-One-Caregiver.php

This utility displays all caregiving scheduled for one specific caregiver for the whole 2 weeks of the schedule. S/he is selected from a dropdown list of all caregivers in the group.

The MC Scheduler is a caregiving scheduler for kids and/or elders. It contains the application utilities listed above. There is a utility called Setup Scheduler which lets you enter the names of the kids and/or elders needing care. Then it saves 3 files, one with the names of the care needers, one with the names of the caregivers, and one with a blank 2-week schedule. The View Scheduler utility lets you see the schedule, with no editing.

Before you use the Edit MC Scheduler option on the main menu, you'll need to get everyone together and figure out the caregiving schedule which lasts two weeks, so you'll need to figure out who cares for whom. You'll see that the schedules are set up as half hour slots and cover 24 hours a day. When you first see the schedule it will be set up with two X characters for all slots for the whole two weeks. X means "no care needed." For most MCs or families or groups (or even babysitting co-ops), the slots from 9 p.m. to 7 a.m. will be left with the Xs (parents are "watching over" their kids by sleeping in their own rooms—but still available), so you'll need to set up caregivers for 7 in the morning to 9 at night, mostly, since after that we assume the kids and care-needing elders will be asleep. Of course, also in the daytime will be Xs for when kids are at school or soccer practice or music lessons or preschool or whatever. So even if kids are sleeping over at a different home in your group, it is assumed there are parents sleeping in a nearby room, available as needed.

The reason there are Xs over Xs and—once you fill in the slots—names over names, is that the primary caregiver is on top and the secondary caregiver is on the bottom. See Why Register for an MC? to see why caregiver choice is important—the kid should be able to choose which of these two people will care for him/her. The kid starts with the primary caregiver and chooses to switch to the secondary caregiver if he wants to. The best place for the caregiving is a space set aside for it. This allows kids to play with other kids in their group, and the chosen (primary or secondary) caregiver will be there, playing with or talking with the kids as they wish or—more often—reading a book or doing something on a computer while the kids play together.

The editing of the schedule is simple. Select one of the caregivers from the dropdown menu in Edit MC Scheduler, and click him or her wherever appropriate on the schedule either on top, as the primary caregiver or on the bottom as the secondary caregiver. Do this for the whole two weeks and then go on to the next caregiver from the dropdown menu, until all slots are filled as needed. Yes, the first scheduling meeting will be a long one. Bring snacks!

Even though we designed the Scheduler for MCs (microcommunities), there would be nothing to stop babysitting co-ops from using it. Most co-ops think in terms of one caregiver for so many kids. The American Academy of Pediatrics and the American Public Health Association recommend child-caregiver ratios of 3:1 for children from birth to 12 months, 4:1 for children from 13 to 30 months, 5:1 for children from 31 to 35 months, 7:1 for 3-year-olds, and 8:1 for 4-year-olds and older. We agree, but feel that there needs to be secondary caregivers as well—for backup. Like we say, the kids should be able to choose which of these two people will care for them.

On to the code: This utility displays all caregiving scheduled for one specific caregiver, who is selected from a dropdown list of all caregivers in the group. The first section is at the start of the script. First, we use the checkid.php script to ensure that the session id variable is set, and send the user to register-with-captcha.php if it is not. Then we put the session variable 'username' into $U—we will be checking that it is set in a second. Then we define a named constant '_NODIRECTACCESS'. We include the config.php file (in the includes folder) which uses the PHP defined() function to check on this constant. If it is not set, we are thrown out of the config.php file like yesterday's trash.

Next we check if the session variables 'groupname', 'username', and 'userid' are set. If not, we are sent to the login-to-mc.php script. We make sure $U is still equal to the session variable 'username', that it is not an empty string, and that it's at least 6 characters long or . . . you guessed it . . . the login script. We make sure the session id is set and send them away if not.

The reason we are willing to use JavaScript to send visitors away is that none of our scripts will work without it. One cannot register, enter data, get from here to there, etc., in most of our scripts without it. What serious web surfer turns off JavaScript? In case you were not aware, many sites rely totally on JavaScript for menu functioning and some of their scripts. And what about data entry? In case you didn't know it, it is a huge convenience for the user because of the way it does input validation. A good site will validate in JavaScript as well as PHP. When the JavaScript data validation script catches unacceptable input, it can simply send focus to the input box where the bad input happened, the user fixes it, and the script is submitted. But if JavaScript is disabled, the user gets sent to PHP data validation which catches the bad data and sends the user back to the input form to redo all input from scratch. The JavaScript data validation script will not make a user restart, if well written. If you have experienced restarting data entry in a long form due to an accidental character, you know exactly what we are talking about. It's maddening! And a good way to get users to surf away from your site forever. If a person turns off THE major browser scripting language just because of a miniscule chance of encountering a scripting exploit on some web page, rather than installing good anti-spyware and anti-virus software, his Internet experience overall will be greatly diminished. Many sites have no alternatives to their script-enabled navigation, so the person is 100% screwed on those sites. But even on those with the alternative, it is always cumbersome and awkward. Besides, the scheduler editing script requires AJAX which in turn needs JavaScript, and if you cannot edit the schedule, it's useless. Point taken?

Next, we declare links to both email and print functions. The latter merely runs the window.print() method and prints out the page, while the latter explains the ease of emailing this page to someone: "To email a caregiver schedule, type Ctrl a then Ctrl c, then open your email program, select compose/write, move cursor to body of email, type Ctrl v, then fill in From, To, and Subject, then Send Message."

The PHP function days() will display the day and date for each of the 14 days the schedule covers, but only one at a time. $nu will be the 49th record in one 50-record day, and it holds the day of the week. Once $nu is incremented, $nu will be the 50th record in one 50-record day, and it holds the date of that day. We declare the variables global because they are generated outside the function. We SELECT the Time field using a WHERE clause. The result set has the day, and once we increment $nu the Time field will have the date.

Next comes a dropdown form of all the caregivers in the group. Note that in this standard HTML form there is a function called from the select tag: onchange="clik()". More on that later, but we imagine you can figure out what it does, right? After all, the purpose of the utility is to view a caregiver's schedule, and just clicking a form is useless unless you can do something with the selected person. We use the standard SELECT and mysql_fetch_array() procedure to get the names from the table.

Now we GET the person variable from the submitted form. Check out the function clik() in the JavaScript section. We use the document object model's dot notation to get the selectedIndex and options array, then use the former as the array element number of the latter to get the person's name. Next we use the window.location object to refresh the page, sticking the name into a query string. Back in the PHP section, when we GET the person's name from the query string, we've essentially let a click in a form run a PHP script, albeit with a page reload requirement.

We now use PHP's isset function to see if a selection has been made from the dropdown list. If not, the rest of the PHP will not run; if so, it will run. Next we declare an array, read the names in the kids table, and put them in the array using the array_push function, for convenience when we display them.

A PHP for loop is used to go through all 700 records in the schedule, one at a time. We are checking for the selected caregiver's name—we will display who he cares for and when, when we find him (or her). We use $T=$row['Time']; to keep the name of the time slot handy in case we strike gold. if($N==1 || etc. . . . means the first record of any given day, since each day has 50 records. On the 1st day we run the days() function to display the day and date before and schedule specifics are shown. So $nu=$N+48 because this means sending 49 to the function (or 99 or 149 etc.).

The PHP continue statement is used to forget this loop iteration and continue execution at the condition evaluation and then the beginning of the next iteration. I.e., skip a loop. We use this if the loop we are on is the 49th or 50th record of any day's set of 50 records. There is no scheduling data in these records—just day and date respectively. Next we create an array $kr() where we stick the names we got using mysql_fetch_array and looking into the $row[] array by use of $row['kid'.$i], which relates to the fact that the MySQL table's column names are kid1, kid2, etc. This is for display programming convenience. We do not know if this row of data contains the caregiver name we seek, but we are about to find out. We use the strpos() function to look for $person in each of the $kr[] array values. This function will find where it is in the string, but since it might be at offset 0, we cannot use $pos != false for the comparison—we must use $pos !== false. Using != would not work as expected because the position of the search string may be 0. The statement (0 != false) evaluates to false.

Anyway, the first time we look for matches, we are just counting them. If the count is greater than 0, we display the time slot name. Let's look at if ($pos !== false && $q != $w && $pos==0){echo "".$ar[$i-1].", ";$w++;}. This is after a search. If a match was found, $pos !== false determines it. Comparing $q and $w is because we are incrementing $w and $q != $w means we are not on the last successful match yet. We determine this solely to append a comma in the display between results but it would look crummy to have a comma after the last result. We check if $pos==0 to determine if the match was at the start of the $kr[] element value. If so, it is a primary caregiver, since we always list these 1st in the MySQL table and the schedule. If it is primary, we embolden it, otherwise we do not. The $ar[$i-1] array contains actual kid's/elder's names to display. The minus 1 is because we started the for loop on 1, not 0, but the $ar() array started at 0. The rest of the if else if else if else if is simply about displaying in bold if primary and not bold if not primary (listed 1st=primary, listed 2nd=secondary), and not putting a comma at the end.

We have previously discussed the JavaScript function clik()—see above.

This script below is called View-One-Caregiver.php

if (!isset($_SESSION['groupname']) || !isset($_SESSION['userid']) || !isset($_SESSION['username']) || $_SESSION['username']<>$U || !isset($U) || $U=="" || strlen($U)<6 || !isset($_SESSION['sessionid'])){echo '<script language="javascript">alert("Please login, then select MC Scheduler."); window.location = "login-to-mc.php";</script>';}

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>View One Caregiver</title>
<meta name="description" content="View One Caregiver">
<meta name="keywords" content="View One Caregiver,MC,MC Scheduler">

background-color:#eee;overflow:hidden;white-space:nowrap;font-family:"Times New Roman", Times, serif;}
.zz{padding:7px 7px 7px 17px}
.j {position:absolute;top:40px;left:-1900px;width:10px;}
.x{border:2px solid blue;margin-top:100px;text-align:left;padding:20px;width: auto}

<body SCROLL="auto" BGCOLOR="#FFFFFF">

<div class="d">(Bold = primary caregiver)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;<a HREF="#" onclick="email()">Email</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a HREF="#" onclick="printpage()">Print</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a HREF="http://www.thebiganswer.info/MC-Scheduler.php">Return to MC Scheduler Management</a><BR></div>


function days(){
global $nu,$a;
$resp = mysql_query("SELECT Time FROM $a WHERE N='$nu' LIMIT 1") or die(mysql_error());
$roww = mysql_fetch_array($resp);
echo "<tr><td colspan='3'><BR><BR><b class='w'>".$roww['Time']." ";
$resp = mysql_query("SELECT Time FROM $a WHERE N='$nu' LIMIT 1") or die(mysql_error());
$roww = mysql_fetch_array($resp);
echo $roww['Time']."</b><BR><BR></td></tr>";}

echo '<div class="b">
<form action="#">
<select id="mySelect" onchange="clik()">
<option value="Select Caregiver">Select Caregiver</option>';
$nr = mysql_query("SELECT username FROM $a") or die(mysql_error());
while ($row = mysql_fetch_array($nr)){
echo '<option value="'.$row[0].'">'.$row[0].'</option>';}
echo '</select></form></div>';

if (isset($p)){
$person=$p;echo "<center><div class='x' align='left'><BR><span class='y'>".$person."</span><table>";
$nm = mysql_query("SELECT username FROM $a") or die(mysql_error());
$nb = mysql_num_rows($nm);
while ($row = mysql_fetch_array($nm)){
array_push ($ar, $row[0]);}

for($N = 1; $N <= 700; $N++){
$res = mysql_query("SELECT * FROM $a WHERE N='$N' LIMIT 1") or die(mysql_error());
while($row = mysql_fetch_array($res)){
if($N==1 || $N==51 || $N==101 || $N==151 || $N==201 || $N==251 || $N==301 || $N==351 || $N==401 || $N==451 || $N==501 || $N==551 || $N==601 || $N==651){$nu=$N+48;days();}

if($N==49 || $N==99 || $N==149 || $N==199 || $N==249 || $N==299 || $N==349 || $N==399 || $N==449 || $N==499 || $N==549 || $N==599 || $N==649 || $N==699){continue;}
if($N==50 || $N==100 || $N==150 || $N==200 || $N==250 || $N==300 || $N==350 || $N==400 || $N==450 || $N==500 || $N==550 || $N==600 || $N==650 || $N==700){continue;}

for($i = 1; $i < $nn; $i++){$kr[$i]=$row['kid'.$i];}
for($i = 1; $i < $nn; $i++){$pos = strpos($kr[$i], $person);if ($pos !== false){$q++;}}
if($q>0){echo "<tr><td>".$T.":</td><td> ";}
for($i = 1; $i < $nn; $i++){$pos = strpos($kr[$i], $person);if ($pos !== false && $q != $w && $pos==0){echo "<B>".$ar[$i-1]."</B>, ";$w++;}else if ($pos !== false && $q != $w && $pos>0){echo $ar[$i-1].", ";$w++;}else if ($pos !== false && $pos==0){echo "<B>".$ar[$i-1]."</B>";}else if ($pos !== false){echo $ar[$i-1];}}
if($q>0){echo "</td></tr>";}
echo "</table></div></center>";

echo '<center><div class="t" align="center">View One Caregiver, '.$U.'</div><center>';



<script language="javascript">
function clik(){
var u=document.getElementById("mySelect").selectedIndex;
var s=document.getElementById("mySelect").options;
var person=s[u].text;
if (person != "" && person != "Select Caregiver"){window.location = "View-One-Caregiver.php?person="+person;}}

function email(){alert("To email a caregiver schedule, type Ctrl a then Ctrl c, then\nopen your email program, select compose/write, move cursor to body of email,\ntype Ctrl v, then fill in From, To, and Subject, then Send Message.");}

function printpage(){window.print();}

mactest=(navigator.userAgent.indexOf("Mac")!=-1) //My browser sniffers
Netscape=(navigator.appName.indexOf("Netscape") != -1)
msafari=(navigator.userAgent.indexOf("Safari")!= -1)
wsafari=0; if(!mactest&&msafari){wsafari=1;msafari=0}
is_opera = 0; if(window.opera){is_opera=1}
is_ie_mac = 0; is_ie=0;if(document.all){is_ie=1}