Source for file DBMS_FIELD_DATE.phpclass
Documentation is available at DBMS_FIELD_DATE.phpclass
* Class file DBMS_FIELD_DATE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* requirements ---------------------------------------------------------
require_once dirname(__FILE__
).
_OCSP_DIRSEP_.
"DBMS_FIELD.phpclass";
require_once __OCSP_PHPINCPATH__.
"common".
_OCSP_DIRSEP_.
"OCSP_DATE.phpclass";
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* source file of the class
* @var string $classSrcFile
* @var string $lstTimeformat format string for list entries
* @var string $lstDateformat format string for list entries
* @var string $fldTimeformat format string for fields
* @var string $fldDateformat format string for fields
* @var boolean $hideCalendarBtn
* checks if a db fieldtype is compatible to the class
if ($debug) echo
"<p><b>DBMS_FIELD_DATE::fldTypeIsUseable($fldType)</b> (".
get_class($this).
"/".
$this->getName().
")</p>";
/* ok no direct compare -> check more or other spellling */
* returns an array of field to bie shown in the edit form
* by using editTbl_echoForm
* the array is in the form:
* [FLDLAB] (complete html code with <td></td>)
* [FLDVAL] (complete html code with <td></td>)
* NOTE as this is not implemented in the whole classTree at the moment ensure all parents use
* editTbl_echoForm() in theire editTblForm otherwise you'll get a mismatch of field order
$a_ret=
parent::editTbl_getFieldEditArr($debug);
$a_ret['SHOW']['HIDDENFIELD'].=
"<input type=\"hidden\" name=\"SHOWDATE\" value=\"1\" \>";
$a_ret['SHOW']['HIDDENFIELD'].=
"<input type=\"hidden\" name=\"SHOWTIME\" value=\"0\" \>";
$a_ret['SHOW']['HIDDENFIELD'].=
"<input type=\"hidden\" name=\"SHOWDATE\" value=\"0\" \>";
$a_ret['SHOW']['HIDDENFIELD'].=
"<input type=\"hidden\" name=\"SHOWTIME\" value=\"1\" \>";
$a_ret['SHOW']['SHOWDATE']=
array(
'FLDLAB'=>
"Datum/Zeit anzeigen:",
<input name=\"SHOWDATE\" type=\"checkbox\" ".
($this->showDate ?
"checked" :
"").
" value=\"1\" \> Datum anzeigen
<input name=\"SHOWTIME\" type=\"checkbox\" ".
($this->showTime ?
"checked" :
"").
" value=\"1\" \> Zeit anzeigen"
//$a_ret['VALCHECKS']['ISHIDDEN']=TRUE; // checks are done in get value
unset
($a_ret['LAYOUT']['FLD_SIZE']);
unset
($a_ret['LAYOUT']['FLD_INPUTADD']);
$a_ret['LAYOUT']['FLD_DATEFORMAT']=
array(
'FLDLAB'=>
"Datumsformat: <a href=\"http://at.php.net/manual/en/function.date.php\">?</a>",
<input name=\"fldDateformat\" value=\"".
$this->lstDateformat.
"\" size=\"25\" \>
<input name=\"hideCalendarBtn\" type=\"checkbox\" value=\"1\" ".
($this->hideCalendarBtn ?
"checked" :
"").
" \> KalenderPopup ausblenden\n
$a_ret['LAYOUT']['FLD_TIMEFORMAT']=
array(
'FLDLAB'=>
"Zeitformat: <a href=\"http://at.php.net/manual/en/function.date.php\">?</a>",
'FLDVAL'=>
"<input name=\"fldTimeformat\" value=\"".
$this->fldTimeformat.
"\" size=\"25\" \>"
$a_ret['LIST']['LST_DATEFORMAT']=
array(
'FLDLAB'=>
"Datumsformat: <a href=\"http://at.php.net/manual/en/function.date.php\">?</a>",
'FLDVAL'=>
"<input name=\"lstDateformat\" value=\"".
$this->lstDateformat.
"\" size=\"25\" \>"
$a_ret['LIST']['LST_TIMEFORMAT']=
array(
'FLDLAB'=>
"Zeitformat: <a href=\"http://at.php.net/manual/en/function.date.php\">?</a>",
'FLDVAL'=>
"<input name=\"lstTimeformat\" value=\"".
$this->lstTimeformat.
"\" size=\"25\" \>"
* show the filed definition form
* @param bool $showSize show size input
* @param bool $showNull show input field to handle null values
* @deprecated since pk-06-07-16
* save the filed definition form
$this->hideCalendarBtn =
((isset
($_POST['hideCalendarBtn']) &&
intval($_POST['hideCalendarBtn'])) ?
TRUE :
FALSE );
$this->showDate =
((isset
($_POST['SHOWDATE']) &&
intval($_POST['SHOWDATE'])) ?
TRUE :
FALSE );
$this->showTime =
((isset
($_POST['SHOWTIME']) &&
intval($_POST['SHOWTIME'])) ?
TRUE :
FALSE );
$this->hideCalendarBtn =
((isset
($_POST['hideCalendarBtn']) &&
intval($_POST['hideCalendarBtn'])) ?
TRUE :
FALSE );
// ###########################################################
// OBJECT HTML FORM METHODS
// ###########################################################
* returns the html code for the input
* @global array $OCSP_CONF
* @version pk-07-03-13 use attribute messages to get values from the date object instead of direct access
* @version pk-07-09-25 use parent params
* @todo DBMS_FIELD_DATE::getInputTag() only lang DE is supported
function getInputTag($aValue,$arrName=
"DBVAL",$nameAdd=
"",$debug=
FALSE) //$value,$arrName="DBVAL",$useCurrentDate=FALSE) {
$s_ret=
"\n\n<!-- ________START DBMS_FIELD_DATE: ".
$this->myName.
"____________ -->\n";
$s_ret.=
"\t<input name=\"".
$arrName.
"[".
$this->myName.
"][DAY]\" value=\"".
($o_DateObj->getDay() ?
$o_DateObj->getDay() :
"").
"\" size=\"3\" maxlength=\"2\" \>\n";
$s_ret.=
"\t<select name=\"".
$arrName.
"[".
$this->myName.
"][MONTH]\">\n";
$s_ret.=
"\t\t<option value=\"\">--- ??? ---</option>\n"; // <pk-05-11-18 />
$s_ret.=
"\t\t<option value=\"".
$i.
"\"";
if ($o_DateObj->getMonth()==
$i) $s_ret.=
" selected";
if (isset
($OCSP_CONF['OCSP_CMSLANG']['DE']['MONTH_SHORT'][$i]))
$s_ret.=
$OCSP_CONF['OCSP_CMSLANG']['DE']['MONTH_SHORT'][$i];
$s_ret.=
"\t</select>\n";
$s_ret.=
"\t<input name=\"".
$arrName.
"[".
$this->myName.
"][YEAR]\" value=\"".
($o_DateObj->getYear() ?
$o_DateObj->getYear() :
"").
"\" size=\"5\" maxlength=\"4\" \>\n";
$s_ret.=
"\t<a href=\"#\" onClick=\"";
$s_ret.=
"else frmObj=document.forms[0];";
$s_ret.=
"wnd=openWindow('calendar','".
$OCSP_CONF['SYSTEMURL'].
"forms/calendar.php?";
$s_ret.=
"&DATEARR[YEAR]='+getElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][YEAR]')+'";
$s_ret.=
"&DATEARR[MONTH]='+getSelectedOptionByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][MONTH]')+'";
$s_ret.=
"&DATEARR[DAY]='+getElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][DAY]')+'";
$s_ret.=
"',190,220);\"><img src=\"".
$OCSP_CONF['SYSIMGURL'].
"icons-22x22/1day.png\" border=\"0\" width=\"18\" height=\"18\" align=\"middle\" class=\"button\"></a> ";
$s_ret.=
"<input name=\"".
$arrName.
"[".
$this->myName.
"][HOUR]\" value=\"".
pcf_addzero($o_DateObj->getHour()).
"\" size=\"3\" maxlength=\"2\" \>:\n";
$s_ret.=
"<input name=\"".
$arrName.
"[".
$this->myName.
"][MIN]\" value=\"".
pcf_addzero($o_DateObj->getMinutes()).
"\" size=\"3\" maxlength=\"2\" \>:\n";
$s_ret.=
"<input name=\"".
$arrName.
"[".
$this->myName.
"][SEC]\" value=\"".
pcf_addzero($o_DateObj->getSeconds()).
"\" size=\"3\" maxlength=\"2\" \>\n";
$s_ret.=
"<img src=\"".
$OCSP_CONF['SYSIMGURL'].
"icons-16x16/today.gif\" border=\"0\" class=\"button\" onClick=\"{";
$s_ret.=
"var aktDate=new Date();";
$s_ret.=
"else frmObj=document.forms[0];";
$s_ret.=
"setElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][HOUR]',aktDate.getHours());";
$s_ret.=
"setElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][MIN]',aktDate.getMinutes());";
$s_ret.=
"setElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][SEC]',aktDate.getSeconds());";
$s_ret.=
"}\" title=\"".
$this->myForm->getLangTxt('SET_NOW').
"\"/>";
$s_ret.=
"<img src=\"".
$OCSP_CONF['SYSIMGURL'].
"icons-16x16/today.gif\" border=\"0\" class=\"button\" onClick=\"{";
$s_ret.=
"var aktDate=new Date();";
$s_ret.=
"else frmObj=document.forms[0];";
$s_ret.=
"setElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][YEAR]',aktDate.getFullYear());";
$s_ret.=
"setElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][MONTH]',aktDate.getMonth()+1);";
$s_ret.=
"setElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][DAY]',aktDate.getDate());";
$s_ret.=
"setElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][HOUR]',aktDate.getHours());";
$s_ret.=
"setElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][MIN]',aktDate.getMinutes());";
$s_ret.=
"setElemValByName(frmObj,'".
$arrName.
"[".
$this->myName.
"][SEC]',aktDate.getSeconds());";
$s_ret.=
"}\" title=\"".
$this->myForm->getLangTxt('SET_NOW').
"\"/>";
$s_ret.=
"\n<!-- ________END DBMS_FIELD_DATE: ".
$this->myName.
"____________ -->\n\n";
* returns the html code for the search compare type select
$ret =
"<select name=\"".
$arrName.
"[".
$this->myName.
"][COMPTYPE]\">";
$ret.=
" <option value=\"=\">=</option>";
$ret.=
" <option value=\"<\"><</option>";
$ret.=
" <option value=\">\">></option>";
* returns the field default value
* if parent::getDefaultValue() includes "NOW()"
* current date and time is set
if (strstr($defVal,"NOW()")) {
$aDate->setLinuxTime(time());
return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getDateStmt($aDate,FALSE);
* returns a date object created from the value
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>aValue is already a OCSP_DATE</p>");
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>aValue is an array</p>");
$o_Date->setFromArray($aValue);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>aValue is string: $aValue</p>");
$o_Date->setDateStr($aValue,$debug);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>Returning empty Date</p>");
* returns the field value
* @param string $aValue the value
* @param array $err error array
* @param string $arrName name of the array to access fieldsarray gloabl ${$arrName}
function getValue($aValue,&$err,$arrName=
"DBVAL",$debug=
FALSE) {
echo
"<hr><p><b>DBMS_FIELD_DATE::getValue(\$aValue,\$err,$arrName,...)</b> (".
get_class($this).
"/".
$this->myName.
")</p>";
echo
"<blockquote><pre style=\"font-size:10px;\">";print_r($aValue);echo
"</pre></blockquote>";
if (implode(":",$aValue) ==
"::") {
return parent::getValue(NULL,$err,$arrName,$debug); // to check for null
return (intval($aValue['HOUR'])).
":".
(intval($aValue['MIN'])).
":".
(intval($aValue['SEC']));
$obj_DB=
$this->myForm->getDBObj();
$obj_Date->setFromArray($aValue,$debug);
if ($obj_Date->isNULL()) {
if ($debug ||
$this->fldDebug) {echo
"<pre style=\"font-color:red;font-weight:bolder\">";print_r($err);echo
"</pre>";}
} else if (!$this->dbDesc['NULL']) { // <pk-06-11.27>
if ($debug) echo
"<pre>Returnung DefaultValue instead of NULL</pre>";
if ($debug) echo
"<pre>Returnung NULL</pre>";
return $obj_DB->qs_getNullStmt();
echo
"<blockquote><pre style=\"font-size:10px;\">";
print_r($obj_DB->qs_getDateStmt($obj_Date,FALSE));
echo
"</pre></blockquote>";
return $obj_DB->qs_getDateStmt($obj_Date,FALSE);
return parent::getValue($aValue,$err,$arrName,$debug); // to check for null
* returns the value with slashes create use in a db statement
* @param string $aValue the value
* @param array $err error array
* @param string $arrName name of the global array to access field gloabl ${$arrName}
* @version pk-03-11-27 DB-Object used instead of DB_.. function
* @version pk-03-12-13 use $this->getValue to check the Value
function slashedValue($aValue,&$err,$arrName=
"DBVAL",$debug=
FALSE) {
echo
"<hr><p><b>DBMS_FIELD_DATE::slashedValue($aValue,$err,$arrName,$debug)</b> (".
get_class($this).
"/".
$this->myName.
")</p>";
echo
"<blockquote><pre style=\"font-size:10px;\">";print_r($aValue);echo
"</pre></blockquote>";
$obj_DB=
$this->myForm->getDBObj();
if ($debug) echo
"<blockquote><pre style=\"font-size:10px\">DBMS_FLDTYPE_TIME\n</pre></blockquote>";
return $obj_DB->qs_getSlashedValue($this->getValue($aValue,$err,$arrName,$debug));
if ($debug) {echo
"<pre style=\"font-size:10px;\">";print_r($aValue);echo
"</pre></blockquote>"; }
$obj_Date->setFromArray($aValue);
if ($obj_Date->isNULL()) {
$obj_Date->setLinuxTime(time());
return $obj_DB->qs_getNullStmt();
if ($debug) {echo
"<pre style=\"font-size:10px;\">";print_r($obj_Date);echo
"</pre></blockquote>"; }
return $obj_DB->qs_getDateStmt($obj_Date,TRUE);
$err[$this->myName]['MSG']=
"NO_DATE_ARRAY SUBMITTED";
* returns the html representation of the field
* @param mixed $aValue the falue
* @param string $arrName name of the global array holding data values
* @param boolean $debug show debug info
* @return mixed the html representation of the field
if ($debug) echo
"<pre>".
print_r($o_Date,TRUE).
"</pre>";
if (is_object($o_Date) &&
(!$o_Date->isNULL())) {
if ($debug) echo
"<p>Formatstring: $formatStr</p>";
return trim($o_Date->dateStr($formatStr));
* returns the html representation of the field in a list (table col)
* @param mixed $aValue the falue
* @param string $arrName name of the global array holding data values
* @param bool $debug show debug info
* @returns mixed the html representation of the field
function getListValue($aValue=
NULL,$arrName=
"DBVAL",$debug=
FALSE) {
if (is_object($o_Date) &&
(!$o_Date->isNULL())) {
if ($debug) echo
$formatStr;
return trim($o_Date->dateStr($formatStr));
* get a where clause for the search settings
* $aArr array post values of the serach form
* return string where clause
if ($debug) echo
"<p><b>DMBS_FIELD_INT::searchWhere($aArr,$debug)</b> (".
get_class($this).
")</p>";
if ($debug) {echo
"<blockquote><pre>";print_r($aArr);echo
"</pre></blockquote>";}
if ($debug) { echo
"<pre>"; print_r($aArr); echo
"</pre>"; }
if (!empty($aArr['ANDOR'])) {
$ret=
($aArr['ANDOR'] ==
"OR" ?
" OR " :
" AND ");
switch($aArr['COMPTYPE']) { // only to verify input
global $TEMPDBVAL;$TEMPDBVAL=
$aArr;
$ret.=
$this->slashedValue($TEMPDBVAL,$err,"TEMPDBVAL",$debug);
echo
"COMPTYPE NOT FOUND";
Documentation generated on Thu, 08 Jan 2009 17:40:54 +0100 by phpDocumentor 1.4.0a2