PHP Classes
PHP Classes
elePHPant
Icontem

Creating an Appointment Calendar - Part 06 - Appointment Calendar package blog

Recommend this page to a friend!
  All package blogs All package blogs   Appointment Calendar Appointment Calendar   Blog Appointment Calendar package blog   RSS 1.0 feed RSS 2.0 feed   Blog Creating an Appointme...  
  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  

Author:

Updated on: 2010-04-11

Posted on:

Package: Appointment Calendar

One of the design considerations needed was a way to sort appointments for a specific day. This post will extend the Appointments data class to include a function to identify appointments by a specific date.


 



12. List Appointments by Date:
===============================

Welcome back to the sixth part of "Creating an Appointment Calendar". The previous post created the interface for the Appointment Calendar. One of the design considerations needed was a way to sort appointments for a specific day. This post will extend the Appointments data class to include a function to identify appointments by a specific date.

----------

This function retrieves a list of ID's which correlate to appointments in the Folder, based on a date given.


01.. Function List_ByDate ($dTarget)
02.. {
03.. $fldrClass = gblLadder()->getClass ("Common_Appointment");
04..
05.. $clsCommon_Appointment = $fldrClass->ID();
06.. $itmDef = $fldrClass->getItem ("", ldrGlobals::cClass_Ladder_Defination());
07.. $szTable = $itmDef->Field ("szTable");
08..
09.. $dGet = Date_Create ($dTarget);
10..
11.. $dPrev = clone $dGet;
12.. $dNext = clone $dGet;
13..
14.. $dPrev->Modify("-1 Days");
15.. $dNext->Modify("+1 Days");
16..
17.. $szSQL =
18.. " SELECT a.ID " .
19.. " FROM " .
20.. ldrGlobals::cLadder_Table_Links() . " a, " .
21.. $szTable . " b " .
22.. " WHERE " .
23.. " a.Leaf = b.ID AND " .
24.. " a.Class = " . $cClass_Common_Apt . " AND " .
25.. " b.dTarget Between '" . $dPrev->Format("Y-m-d") . "' AND '" .
26.. $dNext->Format("Y-m-d") . "' " .
27.. " ORDER BY " .
28.. " b.nTime ASC ";
29..
30.. // print ($szSQL);
31..
32.. $rs = mysql_query ($szSQL, $gblLadder->cn);
33..
34.. $aryIDs = Array();
35..
36.. if ($rs != null)
37.. {
38.. $rowCount = mysql_num_rows ($rs);
39..
40.. $aryIDs = Array ();
41.. for ($t=0; $t<$rowCount; $t++)
42.. {
43.. $row = mysql_fetch_row ($rs);
44.. $aryIDs[$t+1] = $row["0"];
45.. }
46..
47.. mysql_free_result($rs);
48.. $rs = null;
49.. }
50..
51.. return ($aryIDs);
52.. }

----------

Line 3 .. retrieves the Common_Appointment class folder from Ladder.

Line 5 .. gets the Common_Appointment class Folder's ID

Line 6 .. provides a glimpse into the inner workings of Ladder. The Definition class captures the information about every class created in Ladder, is either a Folder, Item or Reference. If the class is overloading another class. And most importantly, which table the class is assigned to.

Line 7 .. retrieves the table that the Item class is assigned to.

Line 9 .. makes sure that the date provided in a PHP date.

Lines 11 - 12 .. clone the date so that it can be manipulated.

Lines 14 - 15 .. adjust the date so that Appointments within the target class can be found.

Lines 17 - 28 .. create a SQL query statement that searches Ladder for Appointments contained in the Appointments Folder with dates between the target date.

Line 32 .. executes the SQL query statement

Line 34 .. initializes $aryIDs as an Array so that it can be returned either with or without ID's in it.

Lines 36 - 49 .. fill $aryIDs with the IDs of the Appointments that are found.

======================================
Next Post
======================================

The next post will describe how to extend the ldrFolder and ldrItem classes so that PHP classes for Common_Appointment and Common_Appointments can be created.


/* =======================================
Copyright 1998 - 2010 - E Net Arch
This program is distributed under the terms of the GNU
General Public License (or the Lesser GPL).
======================================= */



You need to be a registered user or login to post a comment

1,534,284 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on:

FacebookGmail
HotmailStackOverflow
GitHubYahoo


Comments:

No comments were submitted yet.



  Post a comment Post a comment   See comments See comments (0)   Trackbacks (0)  
  All package blogs All package blogs   Appointment Calendar Appointment Calendar   Blog Appointment Calendar package blog   RSS 1.0 feed RSS 2.0 feed   Blog Creating an Appointme...