Source for file daterange.php
Documentation is available at daterange.php
* DateRange display/data reflection class
* A class to handle a simple date range from a form and reflect all other entered data
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
/** Load ancillary functions */
require_once 'inc/typeinfo.php';
/** date manipulation routines */
require_once 'inc/date.php';
/** quick select javascript object */
require_once 'inc/jsquickwalk.php';
require_once 'inc/formslib/nondbrow.php';
require_once 'inc/formslib/datefield.php';
/** default is current time period */
/** default is next time period */
/** default is previous time period */
/** default time period is one day */
/** default time period is one week */
/** default time period is one month */
/** default time period is one quarter (3 months) (alternative) */
/** default time period is one quarter (3 months) */
/** default time period is one year */
* DateRange display/data reflection class
* A class to handle a simple date range from a form and reflect all other entered data
* @author Stuart Prescott
* @copyright Copyright Stuart Prescott
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
/** @var boolean include data in hidden fields if not shown */
/** @var boolean include a submit button in the output */
function DateRange($name, $longname, $description) {
parent::nonDBRow($name, $longname, $description);
$startdate =
new DateField('startdate', T_('Start period beginning of'),
T_('Period starts at the beginning of this day'));
$startdate->isValidTest =
'is_valid_date';
$stopdate =
new DateField('stopdate', T_('Finish period end of'),
T_('Period finishes at the end of this day'));
$stopdate->isValidTest =
'is_valid_date';
* Calculate a sensible range
* this is calculated from the 'DR_*' data that we have above
* @param integer $which DR_NEXT, DR_CURRENT, DR_PREVIOUS
* @param integer $range DR_DAY, DR_WEEK, etc...
* @param integer $basetime what date is "current" date
* @return array (SimpleDate startdate, SimpleDate stopdate)
$start =
clone($basetime);
$start->addTimeParts(0,0,0,0,0,1);
$stop->addTimeParts(0,0,0,0,0,2);
$start->addTimeParts(0,0,0,0,0,-
1);
$stop->addTimeParts(0,0,0,0,0,1);
$start->addTimeParts(0,0,0,0,3);
$stop->addTimeParts(0,0,0,0,6);
$start->addTimeParts(0,0,0,0,-
3);
$stop->addTimeParts(0,0,0,0,3);
$start->addTimeParts(0,0,0,0,1);
$stop->addTimeParts(0,0,0,0,2);
$start->addTimeParts(0,0,0,0,-
1);
$stop->addTimeParts(0,0,0,0,1);
$start->addTimeParts(0,0,0,7);
$stop->addTimeParts(0,0,0,14);
$start->addTimeParts(0,0,0,-
7);
$stop->addTimeParts(0,0,0,0,7);
$start->addTimeParts(0,0,0,1);
$stop->addTimeParts(0,0,0,2);
$start->addTimeParts(0,0,0,-
1);
$stop->addTimeParts(0,0,0,0,1);
return array('startdate'=>
$start, 'stopdate'=>
$stop);
* what default values should be in the boxes
* this is calculated from the 'DR_*' data that we have above
* @param integer $which DR_NEXT, DR_CURRENT, DR_PREVIOUS
* @param integer $range DR_DAY, DR_WEEK, etc...
* @param integer $basetime what date is "current" date
* @return array (html javascript, forwards-backwards button html)
$daterange =
$this->_calcRange($which, $range, $start);
$this->fields['startdate']->setDate($daterange['startdate']->dateString());
$this->fields['stopdate']->setDate($daterange['stopdate']->dateString());
$rangePile =
array($daterange);
$maxRanges =
10; //FIXME: hardcoded magic number
for ($i=
0; $i<
$maxRanges; $i++
) {
$jswalk =
new JSQuickWalk($this->namebase,'« '.
T_('Previous'), T_('Next').
' »', array('startdate', 'stopdate'), $rangePile, $maxRanges);
//$this->extrarows[] = array('', $prevRange[0]->dateString().$prevRange[1]->dateString());
//$this->extrarows[] = array('', $nextRange[0]->dateString().$nextRange[1]->dateString());
$this->extrarows[] =
array($jswalk->displayJS(),
$jswalk->displayBack().
' | '.
$jswalk->displayFwd());
foreach ($PD as $key =>
$val) {
$t .=
'<input type="hidden" name="'.
$key.
'" value="'.
xssqw($val).
'" />';
$t .=
'<input type="submit" name="submit" value="Go" />';
return $this->fields['startdate']->date;
return $this->fields['stopdate']->date;
Documentation generated on Tue, 06 Mar 2007 10:01:14 +0000 by phpDocumentor 1.3.0