Location: PHPKode > projects > FiForms Framework > FiForms/FiForms-includes/FiForms_iDateTime.inc.php
<?php

/*
*******************************************************************************

    FiForms -- A collection of PHP classes designed 
    to facilitate rapid development of web-database software

    Copyright (C) 2003-2008  Daniel McFeeters

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


    The original author of this library can be contacted at the following 
    address:

    Daniel McFeeters
    182 Baker Rd.
    Faubush, KY 42544-6526
    email:databases [at] fiforms [dot] org
    http://www.fiforms.org/


iDateText class
Project Started May 4, 2003
*******************************************************************************
FiForms_iDateTime.inc.php

iDateTime Definition File

Displays a three-part input for entering a date in the form Month/Day/Year,
as well as a time input box.

*******************************************************************************
*/

require_once("FiForms_iDateText.inc.php");


require_once($GLOBALS['FIFORMS_CONFIG']['SCRIPT_PATH']."themes/".$FIFORMS_CONFIG['ICON_SET']."/iconset.php");
/* ?><code><?php */
$FIFORM_XML_INPUTS[] = 'f:iDateTime';

class iDateTime extends iDateText
{
    var $time;
    
    function iDateTime()
    {
        $this->iInput(func_get_args());
        $this->autoDate = TRUE;
    } // function iDateTime

    function getValueToSave()
    {
        parent::getValueToSave(true);
        $time = $_POST[$this->dbField."_TIME"];
        $this->valueToSave .= " ".$time;
        return true;
    }

    function drawInput()
    {
        $this->setupDate();
        $this->time = new iText($this->dbField."_TIME"," ");
        $this->time->value = substr($this->value,11);
        $this->time->class = "no_border";

        // Output only the values if readonly
        if($this->readOnly == TRUE)
        {
            if($this->month->value == "")
            {
                return('');
            }
            else
            {
                return($this->month->value."/".$this->day->value.
                    "/".$this->year->value."&#160;".
                    str_pad((((int)substr($this->time->value,0,2)+11) % 12)+1,2,"0",STR_PAD_LEFT).
                    substr($this->time->value,2)."&#160;".
                    ((floor((int)substr($this->time->value,0,2) / 12)) ? "PM" : "AM")
                    );
            }
        }
        // Output the controls in normal mode
        else
        {
            $this->icons = new iconset();
            return("<span class=\"text\">".$this->month->drawInput()."/".
                    $this->day->drawInput()."/".
                    $this->year->drawInput()." ".
                    $this->time->drawInput().
                    "<span onclick=\"return showCalendar('".
                    $this->dbField."');\" name=\"select_".
                    $this->dbField."\" ".
                    "id=\"select_".$this->dbField."\">".
                    $this->icons->down."</span>".
                    "</span>");
        }


    } // function drawInput

    function buildFromXML($input)
    {
        parent::buildFromXML($input);
        if($input->attributes->getNamedItem('default')->nodeValue 
                == "today")
        {
                $this->value = date("Y-m-d H:i:s");
        } // if default is "today"
    }
} // class iDateText

/* ?></code><?php */

?>
Return current item: FiForms Framework