NEW VERSION 2.1
===============
This cass implements a popup calendar in Manuel Lamos' Forms Generation and Validation master class.
NEW FEATURES IN THIS VERSION
a) PHP5 only (sorry)
b) Doesn't need any external javascript file inclusion
c) Allows manual input of the date in the filed and/or calendar direct selection
d) supports image button for popping out the calendar
e) implements the ValidateInput method
f) major rewrite to be fully coherent with the master class
g) if allowedManual then javascript validation code is automatically generated
Here is an implementation example and the parameters the control accepts
require_once("classes/cal_class.php");
$form->AddInput(array(
"TYPE"=>"custom",
"NAME"=>"born",
"ID"=>"born",
"CustomClass"=>"form_calendar_class",
"STARTDATE"=>"2005-2-12", // lowest acceptable value: default no limit
"ENDDATE"=>"today", // highest acceptable value default no limit
// magic "today" in any date definition
// parametr sets the value to today
"LABEL"=>"Bith's date", // the control label
"VALUE"=>"2005-11-27", // date in SQL format
"VALIDDAYS"=>"1,2,3", // means Mon Tue Wen are valid days
// 0= Sunday 6=Saturday
// default: all week is valid
"Accessible"=>0, // 0 = not Accessible - displays the date but
// doesn't allow any change 1=editable default 0
"AllowManual"=>true, // allows the user to manually type the date in the field
// it also shows the button/icon to display the calendar for
// point and click selection
"LANG"=>"en", // language for the calendar
// valid are "it" (default) for
// italian and "en" for english
"FORMAT"=>"1", // date format: 1 = MM/DD/YYY
// 2 (defaulr) = DD/MM/YYY
// when you set LANG it defaults to
// the correct diplay "it" (default) for
// DD/MM/YYYY display and "en" for
// MM/DD/YYYY
"SELBG"=>"Green", // today's background color default Green
"MONTHBG"=>"Red", // month's name background color
"MONTHTX"=>"White", // month's name text color
"WEEKBG"=>"Orange", // week's name background color
"WEEKTX"=>"Green", // week's name text color
"TODAY"=>"Yellow", // today's higlight color
"OFFMONTH"=>"AntiqueWhite", // off month days color
"WEEKEND"=>"LightGray", // weekend's highlight color
"CLASS"=>"theCSSClass", // CSS class for the input field
"OPTIONAL"=>1, // is the field optional? 0=no=default - 1 = yes
"NotEmptyErrorMessage"=>"Your text", // text for validation failure
"NotEmpty"=>1 // 0 = no = default - 1 = yes
"InvalidStartMessage"=>"Your custom start error message",
"InvalidEndMessage"=>"Your custom end error message",
"CalendarIcon"=>"images/icons/b_calendar.png" // complete path to the image to be displayed
// instead of button
// if not specified a button will be displayed
));
You can take off the SQL parameter from the $_POST as
_sql___{your-field-name}_calendar
p.e. in case the NAME is "birth" the SQL param will be
_sql__birth_calendar
^^
Please pay attention to the fact that after _sql there are 2
underscores
Any valid forms' class tag for text fields should work
If you find any bug or fix any functionality, please let me know.
And if you like it, I'd love to hear it.
Best Regards
Alessandro Bianchi
Italy 30-04-2006
HERE FOLLOWS THE ORIGINAL VERSION 1 README FILE - PLEASE READ CAREFYLLY
=======================================================================
This is the original Andrea's Bersi release notes for his code:
/*
This new version of the little toy, at 19 november 2005, let you to set as link not all days of the week
NB: THERE IS A LITTLE BUG IN THE CORE JAVASCRIPT: SOMETIME , in the previous month, the days linkable are not
active;
please report any other bug or problem at andreabersi@gmail.com
Ciao
Andrea Bersi
AOSTA (ITALY)
http://abmcr.altervista.org
*/
/********************************************
ADAPTATION NOTES AND EXAMPLES
This is a wonderful piece of software, but I use Manuel Lamos'
Form Generation and validation class.
I don't feel confortable with the date plugin so when I sow Andrea' work
I decided to port it in a plugin fashion.
The goal was to have a class that can drive the user to only select the
required days and to accept and provide data in SQL format, just to avoid
any conversion work.
All the merit for the class functionality goes to Andrea Bersi as above.
The main changes in the class are as follows:
- it accepts SQL formatted date (p.e. 2005-11-19)
- in the output is included an hidden field preformatted in SQL ready to use.
That required to add a simple function to the javascript file, the field
displays the date in the desired formatting
- introduced the requested methods to suite to Manuel's form_custom_class
Here is an implementation example and the parameters the control accepts
require_once("classes/cal_class.php");
echo '<script language="javascript" type="text/javascript" src="classes/calendar.core.js"></script>';
$form->AddInput(array(
"TYPE"=>"custom",
"NAME"=>"born",
"ID"=>"born",
"CustomClass"=>"form_calendar_class",
"STARTDATE"=>"2005-2-12", // lowest acceptable value: default no limit
"ENDDATE"=>"today", // highest acceptable value default no limit
// magic "today" in any date definition
// parametr sets the value to today
"LABEL"=>"Bith's date", // the control label
"VALUE"=>"2005-11-27", // date in SQL format
"VALIDDAYS"=>"1,2,3", // means Mon Tue Wen are valid days
// 0= Sunday 6=Saturday
// default: all week is valid
"Accessible"=>0, // 0 = non editable 1=editable default 0
"LANG"=>"en", // language for the calendar
// valid are "it" (default) for
// italian and "en" for english
"FORMAT"=>"1", // date format: 1 = MM/DD/YYY
// 2 (defaulr) = DD/MM/YYY
// when you set LANG it defaults to
// the correct diplay "it" (default) for
// DD/MM/YYYY display and "en" for
// MM/DD/YYYY
"SELBG"=>"Green", // today's background color default Green
"MONTHBG"=>"Red", // month's name background color
"MONTHTX"=>"White", // month's name text color
"WEEKBG"=>"Orange", // week's name background color
"WEEKTX"=>"Green", // week's name text color
"TODAY"=>"Yellow", // today's higlight color
"OFFMONTH"=>"AntiqueWhite", // off month days color
"WEEKEND"=>"LightGray", // weekend's highlight color
"CLASS"=>"theCSSClass", // CSS class for the input field
"OPTIONAL"=>1, // is the field optional? 0=no=default - 1 = yes
"NotEmptyErrorMessage"=>"Your text", // text for validation failure
"NotEmpty"=>1 // 0 = no = default - 1 = yes
));
You can take off the SQL parameter from the $_POST as
_sql___{your-field-name}_calendar
p.e. in case the NAME is "birth" the SQL param will be
_sql__birth_calendar
^^
Please pay attention to the fact that after _sql there are 2
underscores
Alessandro Bianchi
19-9-2005
alex at skynet-srl.com
***********************************************/
FAQ:
Q: I try to run the example but it complains about a form.php file that is not included in the class. How do I get it?
A: The forms.php is the master class provided from Forms Validation and Generation Class by Manuel Lemos. You need to install it and place the plugin class at the root level where if finds the forms.php
Q: I don't want to use a plugin: How may I use your class as stand alone?
A: My class is deeply chained with Manuel Lemos' one. If you need a stand alone calendar class, look at cal_date class. It is the original code I started from, and it works pretty well |