Author: Michael J. Fuhrman
Viewers: 772
Last month viewers: 28
Package: Ladder PHP
PHP can be used to used to create and manage such type of calendars. Read this tutorial to learn how you can create appointments calendars in PHP with many nice features using the Ladder package.
1. Overall Scope:
Ladder is an object oriented data management tool that classifies data based on three basic data types: [ Folder | Item | Reference ]. Folders can contain any data type. Items only contain properties - field values. And Reference data types point to Folders. These three data types create a hierarchy which gives Ladder its name. The hierarchy is used to organize data requiring complex relationships that cannot be easily replicated in standard SQL architectures. And Ladder allows programmers to use a common set of repeatable data structures that mirror their Object Model.This blog series will demonstrate how to create an Appointment item and an Appointments folder data class in conjunction with graphical objects to create an Appointment Calendar using Ladder for PHP.
Readers of this blog should be familiar with extending objects, including files through directory structures, and JavaScript.
To begin, download Ladder for PHP and install it onto your development web server and database server. For best performance and trouble shooting - it is recommended that you install Ladder in a separate database partition. Note that Ladder for PHP was specifically designed for mySQL. Ladder for PHP will work with other SQL servers, however it may require some changes to the install scripts.
Covered in this series:
1. Overall Scope
2. Directory Layout
3. Design the Appointment data classes
4. Create the class install script
5. Create an Appointments Folder in Ladder.
6. Create the Appointment data classes
7. Create the initial pages .. List, New, Edit, View, and Delete
8. Create a Calendar panel
9. List Appointments by Date
10. Add additional features, like: Move To Date
11. Review & Follow up.
12: FAQs
2. Directory Layout
The directory layout used in this series is as follows:|-Development
|- Appointments
|...|- Install.php
|...|- CreateFolder.php
|...|
|...|- List.php
|...|- New.php
|...|- Add.php
|...|- Edit.php
|...|- Update.php
|...|- View.php
|...|- Delete.php
|
|- Shared
|...|- _app.inc
|...|- Install_Functions.inc
|...|- Classes
|...|...|-ENetArch_Ladder
|...|...|...|- [... Ladder Files ...]
3. Design the Appointment data classes
This section discusses what fields are needed to capture information concerning an appointment.There are several types of appointments and fields that can be used to capture their data. The most common type of appointment only repeats once. The appointment contains fields for the date of the appointment, the time that the appointment begins and end, and a message about what the appointment is about.
More elaborate appointments can be constructed, such appointments may capture: how often they repeat, who will attend, what resources are needed. However, for the purposes of this article the appointment that will be discussed is a simple one time appointment that only needs to relate to the creator of the appointment.
The Appointment Item Data Class will need the following fields:
01.. dTarget DATETIMELine 1 .. captures the date the appointment is to occur.
02.. nTime INTEGER
03.. nLength INTEGER
04.. szMemo STRING
Line 2 .. captures the time that the appointment is to occur on that date.
Line 3 .. captures the length of the appointment. The increments of the appointment length can vary, usually most people don't have less than 30 minute appointments. However if needed, 15 minute increments have been seen.
Line 4 .. captures the content of the appointment, ie .. what is happening at this time.
This design information will be used later when we construct the class description for Ladder, and design the PHP Classes for these data classes.
4. Create the class install script:
This section will list the scripts and additions needed to create the Appointment data classes. Following the scripts is a line by line description. In addition, checks for file updates are provided to make this script work.Just as a class has to be created in PHP before an instance can be created, so must a class be defined in Ladder before an instance can be stored. To that end, the scripts that follow describe to Ladder what each classes base type is: [ Folder | Item | Reference ] and if it is an Item Class, then what properties that Item Class contains.
Note: the Appointment classes are part of a larger package known as Common Classes.
Provided here is the script needed to create an Appointment Item and Appointments Folder data class in Ladder.
[... Install.php ...]Line 1 .. creates a global function dirPath that abstracts the location of shared libraries located else where in the web servers directory path. This method of globalizing variables requires less code for declarations and makes accessing common global variables easier.
01.. function dirPath() { return ("../"); }
02..
03.. Include_Once (dirPath() . "Shared/Install_Functions.inc");
04.. Include_Once (dirPath() . "Shared/_app.inc");
05..
06.. Function php_Main ()
07.. {
08.. $szStr =
09.. " dTarget DateTime, " .
10.. " nTime Integer, " .
11.. " nLength Integer, " .
12.. " szMemo varChar(250) " ;
13..
14.. CreateClass ("Common_Appointment", ldrGlobals::cisItem(), 0 , true, $szStr);
15..
16.. CreateClass ("Common_Appointments", ldrGlobals::cisFolder(), 0 , true);
17.. }
Line 3 .. includes a general set of functions used to install classes. This library basically abstracts Ladder's create class function:
1.. function CreateClass ($thsName, $nBaseType, $ofClass, $bAcceptsAll, $szStr)Note: if gblLadder() is not found, add the following code to _app.inc before "Main ();"
2.. {
3.. print ("Adding Class .. " . $thsName . "
");
4.. gblLadder()->CreateClass ($thsName, $nBaseType, $ofClass, $bAcceptsAll, $szStr);
5.. }
1.. function gblLadder() { global $gblLadder; return ($gblLadder); }Line 4 .. includes the _app.inc file which loads a general set of functions and the Ladder php classes.
Line 6 .. is called from _app.inc. php_Main() was created to insure that all database objects are initialized and uninitialized as each page is executed to conserve database connections.
Line 8 - 12 .. create a SQL structure statement based on the Appointment Item class's data model.
Line 14 .. adds the Appointment Item data class to Ladder's list of classes and creates a corresponding table in Ladder's database space called "Common_Appointment".
Line 16 .. adds the Appointments Folder data class to Ladder's list of classes. (Only Item data classes require additional tables to be created.)
At this point the script has told Ladder what classes of data will be stored in it. Ladder is now ready to create and manage instances of these classes.
5. Create an Appointments Folder in Ladder:
This section will provide you with a simple script which creates a folder in Ladder's Root data folder (ie RootFolder). This folder can be retrieve either via the instance ID or via Name. For the purposes of this example, the folder will be referred to by ID. Therefore the Number you receive may be different from the number I receive.Note: CreateFolder.php can be executed multiple times to create multiple Appointment folders.
[... CreateFolder.php ...] 01.. function dirPath() { return ("../"); }Line 07 .. retrieves a list of the ID's associated with the Root Folders. The first ID listed in the Array is always the RootFolder.
02..
03.. Include_Once (dirPath() . "Shared/_app.inc");
04..
05.. Function php_Main ()
06.. {
07.. $aryRoots = gblLadder()->getRoots();
08.. $fldrRoot= gblLadder()->getItem ($aryRoots [1]);
09..
10.. $clsCommon_Appointments = gblLadder()->getClass ("Common_Appointments")->ID();
11..
12.. $fldrAppoinments = $fldrRoot->Create_Folder ("Appointments", "Appointments are stored here", $clsCommon_Appointments);
13..
14.. $fldrAppoinments ->Store();
15..
16.. print ("The Appointments Folder ID is " . $fldrAppoinments->ID() . "
");
17.. }
Line 08 .. retrieves the RootFolder into fldrRoot. fldrRoot is now an instance of ldrFolder.
Line 10 .. retrieves the class "Common_Appointments" into clsCommon_Appointments. clsCommon_Appointments is an instance of Folder which extends ldrProperties, which is why the function ID() is now available. The ID is used in Line 12 when an instance of Common_Appointment is created.
Line 12 .. Creates a new instance of class Common_Appointment based on its ID value. Each instance that is created in Ladder has several properties: Name, Description, Class. Ladders helps you differentiate between a Folder, Item and Reference through unique Create Statements.
Line 14 .. Each instance created through Ladder is not stored until you call Store().
Line 16 .. Displays what ID the new instance of Common_Appointments has been assigned.
This section provided a script that creates a Common_Appointments Folder and provides the ID of that folder for future use. Save this ID as it will be used in the next blog post or two when the List, View, New, Edit, and Delete pages are created.
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.
How to Download the TonTon PHP Singleton Trait Package or Install it With PHP Composer
The Ladder PHP is available for you to download as a ZIP archive by going to the download page or install it using the PHP Composer Tool by going to the installation instructions page.
You need to be a registered user or login to post a comment
Login Immediately with your account on:
Comments:
No comments were submitted yet.