R
E
S
O
U
R
C
E
S
       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
_______________________

HOME
SEO, Google, Privacy
   and Anonymity
Browser Insanity
JavaScript
Popups and Tooltips
Free Website Search
HTML Form Creator
Animation
Buttons and Menus
Counters
Captchas
Image Uploading
CSS and HTML
PHP
AJAX
XPATH
Website Poll
IM and Texting
Databases—MySQL
   or Not MySQL
Personal Status Boards
Content Management
   Systems
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—Replace This Week With Next Week

This script is called replace-135W-790_________O8-6IY-Uv42ee.php

This utility is used by Edit MC Scheduler to change the MySQL table data by copying "next week" onto "this week", which means the last 350 records are used to replace the first 350 records so we now have 2 weeks which are both the same as "next week", however, this action is performed once a week on Sunday when the "this week" data is no longer relevant. It is history. The last day of "this week" was yesterday, Saturday.

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 is used by Edit MC Scheduler to change the MySQL table data by copying "next week" onto "this week", which means the last 350 records are used to replace the first 350 records so we now have 2 weeks which are both the same as "next week", however, this action is performed once a week on Sunday when the "this week" data is no longer relevant. It is history. The last day of "this week" was yesterday, Saturday. 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 check the number of records in the kids MySQL table, using the SELECT FROM statement and the mysql_num_rows() function. Then we put kid1,kid2,kid3 . . . (etc.) into the variable $f, depending on the number of care needed fields. These columns are named kid1 and can go as high as kid99, the limit.

Next we SELECT one row at a time going from record 351 all the way up to record 700. This is "next week" and it will be stuck in the table in place of "this week"—record 1 to 350. Notice the MySQL query "SELECT ".$f." FROM $a WHERE N='$b'". Recall that $f is the comma-separated list of columns, $a is the table name, N is a field having only one integer: from 1 through 700 (in rows 1 through 700), and $b is the current for loop value. This is for programming convenience, as you can see. Once the result set returns, the mysql_fetch_array() function sticks it into $row, for our use, and keeps doing this until the row's data is all in the $row array. We stick this data, a field at a time, into the $ara array. We use "UPDATE $a SET ".$m."='".$e."' WHERE N='$c'" to copy the row data, a field at a time, into the table in records 1 through 350. The $m variable contains the name of the field from kid1 up to kid(?). The $e variable contains the contents of the saved array element.

The 49th record of each 50-record day (there are 14 days in the schedule) is the day of the week, which will stay the same, so it is left alone. But the 50th record of each of the 14 50-record days has a date in it, and they will all be wrong after this script is run. Why? Records 1-350 have last week's dates since it is Sunday and the preceding week is history. This week will need dates that are a week more than what they are now. The same is true of the "next week" which is records 351-700. It wasn't changed, but the group will need to get together and make needed changes since although caregivers will have similar availability schedules, they will not likely be identical. The same is true of the kids/elders. Their care needing schedules won't be identical either. So the "next week" days (8-14) will need dates that are a week more than what they are now as well. So let us proceed:

We get the old day 1 date from record 50, put it in $g, and use the str_replace() function to change the hyphens to slashes since these seem to work better in the object oriented new DateTime constructor method. The $date->format('m-d-Y') method returns the date formatted according to a given format. The date_add() method adds an amount of days, months, years, hours, minutes and seconds to a DateTime object. The date_interval_create_from_date_string() method sets up a DateInterval from the relative parts of the string. We first set up the $dates() array, then get the date that is a week too early since it is now history. We use the new DateTime() method which returns a new DateTime object, then format it the way we want it in our MySQL table. Then we use a for loop to add 7 to the first date but 1 to all the rest (since we are adding to the $date object with the date_add() method, which starts by getting 7 added to it so the 1 value increments the value that already is plus 7), and we stick these dates into the $dates() array, ensuring we get our proper format.

We stick these array-stored dates into the table every 50th record, where dates are stored. This requires UPDATE. Then we return to the Edit MC Scheduler utility.

This script below is called replace-135W-790_________O8-6IY-Uv42ee.php


<?php
include_once"checkid.php";
$U=$_SESSION['username'];
define('_NODIRECTACCESS', TRUE);
include_once"includes/config.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>';}
?>

<?php

$a=$U."_kids";
$nm = mysql_query("SELECT username FROM $a") or die(mysql_error());
$nb = mysql_num_rows($nm);
$q=$nb;$n=$q;$f="kid1";$ara=array();
for($b = 2; $b <= $q; $b++){$f=$f.", kid".$b;}
$a=$U."_scheduler1";

for($b = 351; $b <= 700; $b++){
$res = mysql_query("SELECT ".$f." FROM $a WHERE N='$b'") or die(mysql_error());
while($row = mysql_fetch_array($res)){
for($i = 1; $i <= $n; $i++){$m="kid".$i;$ara[$i-1]=$row[$m];}}
for($i = 1; $i <= $n; $i++){$m="kid".$i;$e=$ara[$i-1];$c=$b-350;
mysql_query("UPDATE $a SET ".$m."='".$e."' WHERE N='$c'") or die(mysql_error());}}

$res = mysql_query("SELECT Time FROM $a WHERE Day='1' AND N='50' LIMIT 1") or die(mysql_error());
$row = mysql_fetch_array($res);
$dates=array();
$g=$row['Time'];
$g=str_replace("-","/",$g);
$dates[0]=$g;
$da=$dates[0];
$d=7;
$date = new DateTime($da);
$da= $date->format('m-d-Y');
for($i = 0; $i <= 13; $i++){
date_add($date, date_interval_create_from_date_string($d.' days'));
$datee= $date->format('m-d-Y');
$dates[$i]=$datee;$d=1;}

if (isset($dates[0])){
mysql_query("UPDATE $a SET Time='$dates[0]' WHERE N='50'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[1]' WHERE N='100'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[2]' WHERE N='150'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[3]' WHERE N='200'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[4]' WHERE N='250'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[5]' WHERE N='300'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[6]' WHERE N='350'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[7]' WHERE N='400'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[8]' WHERE N='450'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[9]' WHERE N='500'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[10]' WHERE N='550'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[11]' WHERE N='600'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[12]' WHERE N='650'") or die(mysql_error());
mysql_query("UPDATE $a SET Time='$dates[13]' WHERE N='700'") or die(mysql_error());
}

?>

<html>
<head>
<script language="javascript">
alert("copying next week onto this week");
location.href="http://www.thebiganswer.info/Edit-Scheduler.php";
</script>
</head>
<body>
</body>
</html>