Source for file DBMS_FIELD_DATE.phpclass

Documentation is available at DBMS_FIELD_DATE.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_DATE.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   date
  8.   *
  9.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   ***/
  13.  
  14. /**
  15.   * requirements ---------------------------------------------------------
  16.   */
  17. require_once dirname(__FILE__)._OCSP_DIRSEP_."DBMS_FIELD.phpclass";
  18. require_once __OCSP_PHPINCPATH__."common"._OCSP_DIRSEP_."OCSP_DATE.phpclass";
  19.  
  20. /**
  21.   * Class DBMS_FIELD_DATE
  22.   *
  23.   * @project    Open CSP-Management
  24.   * @package    dbms_field
  25.   * @category   date
  26.   *
  27.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  28.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  29.   *
  30.   * @version pk-05-06-30
  31.   *
  32.   ***/
  33. class DBMS_FIELD_DATE extends DBMS_FIELD {
  34.     /**
  35.       * source file of the class
  36.       *
  37.       * @var string $classSrcFile 
  38.       * @since pk-05-01-20
  39.       ***/
  40.     var $classSrcFile=__FILE__;
  41.  
  42.     var $showDate      = TRUE;
  43.     var $showTime      = FALSE;
  44.  
  45.     /**
  46.       * @var string $lstTimeformat   format string for list entries
  47.       * @since pk-04-07-29
  48.       ***/
  49.     var $lstTimeformat = 'H:i:s';
  50.  
  51.     /**
  52.       * @var string $lstDateformat   format string for list entries
  53.       * @since pk-04-07-29
  54.       ***/
  55.     var $lstDateformat = 'd.m.Y ';
  56.  
  57.     /**
  58.       * @var string $fldTimeformat   format string for fields
  59.       * @since pk-04-07-29
  60.     ***/
  61.     var $fldTimeformat = 'H:i:s';
  62.  
  63.     /**
  64.       * @var string $fldDateformat   format string for fields
  65.       * @since pk-04-07-29
  66.       ***/
  67.     var $fldDateformat = 'd.m.Y ';
  68.  
  69.  
  70.  
  71.     /**
  72.       * @var boolean $hideCalendarBtn 
  73.       * @since pk-05-06-30
  74.       ***/
  75.     var $hideCalendarBtn=FALSE;
  76.  
  77.  
  78.         /**
  79.       * checks if a db fieldtype is compatible to the class
  80.       *
  81.       * @param string $fldType 
  82.       * @param boolean $debug 
  83.       *
  84.       * @return boolean 
  85.       *
  86.       * @since pk-08-05-19
  87.       *
  88.       */
  89.     function fldTypeIsUseable($fldType,$debug=False
  90.     {
  91.         if ($debugecho "<p><b>DBMS_FIELD_DATE::fldTypeIsUseable($fldType)</b> (".get_class($this)."/".$this->getName().")</p>";
  92.  
  93.         if (strtoupper($fldType)==strtoupper($this->dbDesc['TYPE'])) return True;
  94.  
  95.         /* ok no direct compare -> check more or other spellling */
  96.  
  97.         switch(strtoupper($fldType)) {
  98.             case "DATE":
  99.             case "DATETIME":
  100.                 return True;
  101.         }
  102.         
  103.         return False;
  104.     }
  105.     
  106.     /**
  107.       * returns an array of field to bie shown in the edit form
  108.       * by using editTbl_echoForm
  109.       *
  110.       * the array is in the form:
  111.       *
  112.       * <code>
  113.       * [_sectionName_]
  114.       *      [TITLE] -> string
  115.       *      [_rowName_]
  116.       *         [FLDLAB]  (complete html code with <td></td>)
  117.       *         [FLDVAL] (complete html code with <td></td>)
  118.       * </code>
  119.       *
  120.       * NOTE as this is not implemented in the whole classTree at the moment ensure all parents use
  121.       * editTbl_echoForm() in theire editTblForm otherwise you'll get a mismatch of field order
  122.       *
  123.       * @param boolean $debug 
  124.       *
  125.       * @returns array
  126.       *
  127.       * @since pk-06-07-16
  128.       *
  129.       ***/
  130.     function editTbl_getFieldEditArr($debug=FALSE{
  131.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DATE::editTbl_getFieldEditArr","",0);
  132.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  133.  
  134.         if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_DATE{
  135.             $a_ret['SHOW']['HIDDENFIELD'].="<input type=\"hidden\" name=\"SHOWDATE\" value=\"1\" \>";
  136.             $a_ret['SHOW']['HIDDENFIELD'].="<input type=\"hidden\" name=\"SHOWTIME\" value=\"0\" \>";
  137.         else if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_TIME{
  138.             $a_ret['SHOW']['HIDDENFIELD'].="<input type=\"hidden\" name=\"SHOWDATE\" value=\"0\" \>";
  139.             $a_ret['SHOW']['HIDDENFIELD'].="<input type=\"hidden\" name=\"SHOWTIME\" value=\"1\" \>";
  140.         else {
  141.             $a_ret['SHOW']['SHOWDATE']=array(
  142.                 'FLDLAB'=>"Datum/Zeit anzeigen:",
  143.                 'FLDVAL'=>"
  144.                         <input name=\"SHOWDATE\" type=\"checkbox\" ".($this->showDate ? "checked" "")." value=\"1\" \> Datum anzeigen
  145.                         <input name=\"SHOWTIME\" type=\"checkbox\" ".($this->showTime ? "checked" "")." value=\"1\" \> Zeit anzeigen"
  146.             );
  147.         }
  148.  
  149.  
  150.         //$a_ret['VALCHECKS']['ISHIDDEN']=TRUE; // checks are done in get value
  151.  
  152.         unset($a_ret['LAYOUT']['FLD_SIZE']);
  153.         unset($a_ret['LAYOUT']['FLD_INPUTADD']);
  154.  
  155.         if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_DATE || $this->dbDesc['TYPE'== DBMS_FLDTYPE_DATETIME{
  156.             $a_ret['LAYOUT']['FLD_DATEFORMAT']=array(
  157.                 'FLDLAB'=>"Datumsformat: <a href=\"http://at.php.net/manual/en/function.date.php\">?</a>",
  158.                 'FLDVAL'=>"
  159.                             <input name=\"fldDateformat\" value=\"".$this->lstDateformat."\" size=\"25\" \>
  160.                             <input name=\"hideCalendarBtn\" type=\"checkbox\" value=\"1\" ".($this->hideCalendarBtn ? "checked" "")." \> KalenderPopup ausblenden\n
  161.                     "
  162.             );
  163.         }
  164.         if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_TIME || $this->dbDesc['TYPE'== DBMS_FLDTYPE_DATETIME{
  165.             $a_ret['LAYOUT']['FLD_TIMEFORMAT']=array(
  166.                 'FLDLAB'=>"Zeitformat: <a href=\"http://at.php.net/manual/en/function.date.php\">?</a>",
  167.                 'FLDVAL'=>"<input name=\"fldTimeformat\" value=\"".$this->fldTimeformat."\" size=\"25\" \>"
  168.             );
  169.         }
  170.  
  171.         if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_DATE || $this->dbDesc['TYPE'== DBMS_FLDTYPE_DATETIME{
  172.             $a_ret['LIST']['LST_DATEFORMAT']=array(
  173.                 'FLDLAB'=>"Datumsformat: <a href=\"http://at.php.net/manual/en/function.date.php\">?</a>",
  174.                 'FLDVAL'=>"<input name=\"lstDateformat\" value=\"".$this->lstDateformat."\" size=\"25\" \>"
  175.             );
  176.         }
  177.         if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_TIME || $this->dbDesc['TYPE'== DBMS_FLDTYPE_DATETIME{
  178.             $a_ret['LIST']['LST_TIMEFORMAT']=array(
  179.                 'FLDLAB'=>"Zeitformat: <a href=\"http://at.php.net/manual/en/function.date.php\">?</a>",
  180.                 'FLDVAL'=>"<input name=\"lstTimeformat\" value=\"".$this->lstTimeformat."\" size=\"25\" \>"
  181.             );
  182.         }
  183.  
  184.         return $a_ret;
  185.     }
  186.  
  187.     /**
  188.       * show the filed definition form
  189.       *
  190.       * @param bool $showSize       show size input
  191.       * @param bool $showNull       show input field to handle null values
  192.       *
  193.       * @version pk-05-06-30
  194.       * @deprecated since pk-06-07-16
  195.       *
  196.       ***/
  197.     function editTblForm($showSize=TRUE,$showNull=TRUE{
  198.         $this->editTbl_echoForm(NULL,$debug);
  199.     }
  200.  
  201.     /**
  202.       * save the filed definition form
  203.       *
  204.       * @return bool 
  205.       *
  206.       * @version pk-04-12-29
  207.       * @version pk-05-01-03
  208.       * @version pk-05-06-30
  209.       *
  210.       ***/
  211.     function save({
  212.         $ret parent::save();
  213.  
  214.         if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_TIME{
  215.             $this->showTime = TRUE;
  216.             $this->showDate = FALSE;
  217.         else if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_DATE{
  218.             $this->showTime = FALSE;
  219.             $this->showDate = TRUE;
  220.             $this->hideCalendarBtn      =((isset($_POST['hideCalendarBtn']&& intval($_POST['hideCalendarBtn'])) TRUE FALSE );
  221.         else {
  222.             $this->showDate             =((isset($_POST['SHOWDATE']&& intval($_POST['SHOWDATE'])) TRUE FALSE );
  223.             $this->showTime             =((isset($_POST['SHOWTIME']&& intval($_POST['SHOWTIME'])) TRUE FALSE );
  224.             $this->hideCalendarBtn      =((isset($_POST['hideCalendarBtn']&& intval($_POST['hideCalendarBtn'])) TRUE FALSE );
  225.         }
  226.  
  227.         $this->lstDateformat=(isset($_POST['lstDateformat']$_POST['lstDateformat'$this->lstDateformat);
  228.         $this->fldDateformat=(isset($_POST['fldDateformat']$_POST['fldDateformat'$this->fldDateformat);
  229.  
  230.         $this->lstTimeformat=(isset($_POST['lstTimeformat']$_POST['lstTimeformat'$this->lstTimeformat);
  231.         $this->fldTimeformat=(isset($_POST['fldTimeformat']$_POST['fldTimeformat'$this->fldTimeformat);
  232.  
  233.         return $ret;
  234.     }
  235.  
  236.     // ###########################################################
  237.     // OBJECT HTML FORM METHODS
  238.     // ###########################################################
  239.  
  240.     /**
  241.       * returns the html code for the input
  242.       *
  243.       * @param mixed $aDateVal 
  244.       * @param string $arrName 
  245.       * @param string $nameAdd 
  246.       * @param boolean $debug 
  247.       *
  248.       * @global array $OCSP_CONF 
  249.       *
  250.       * @return string 
  251.       *
  252.       * @version pk-05-11-18
  253.       * @version pk-07-03-13 use attribute messages to get values from the date object instead of direct access
  254.       * @version pk-07-09-25 use parent params
  255.       *
  256.       * @todo DBMS_FIELD_DATE::getInputTag() only lang DE is supported
  257.       ***/
  258.     function getInputTag($aValue,$arrName="DBVAL",$nameAdd="",$debug=FALSE//$value,$arrName="DBVAL",$useCurrentDate=FALSE) {
  259.     {
  260.         global $OCSP_CONF;
  261.         if ($debug || $this->fldDebugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DATE::getInputTag() [".$this->getKey()."]",print_r($aValue,TRUE));
  262.  
  263.         if (empty($arrName)) $arrName=$this->myDataArrName;
  264.         $o_DateObj=$this->getDateObj($aValue,$debug);
  265.  
  266.         $s_ret="\n\n<!-- ________START DBMS_FIELD_DATE: ".$this->myName."____________ -->\n";
  267.  
  268.         require_once __OCSP_PHPINCPATH__."cms/languages/de.phpinc";
  269.  
  270.         if ($this->showDate{
  271.             $s_ret.="\t<input name=\"".$arrName."[".$this->myName."][DAY]\" value=\"".($o_DateObj->getDay($o_DateObj->getDay("")."\" size=\"3\" maxlength=\"2\" \>\n";
  272.             $s_ret.="\t<select name=\"".$arrName."[".$this->myName."][MONTH]\">\n";
  273.             $s_ret.="\t\t<option value=\"\">--- ??? ---</option>\n"// <pk-05-11-18 />
  274.             $i=1;
  275.             while($i 13{
  276.                 $s_ret.="\t\t<option value=\"".$i."\"";
  277.                 if ($o_DateObj->getMonth()==$i$s_ret.=" selected";
  278.                 $s_ret.=">";
  279.                 if (isset($OCSP_CONF['OCSP_CMSLANG']['DE']['MONTH_SHORT'][$i]))
  280.                 {
  281.                     $s_ret.=$OCSP_CONF['OCSP_CMSLANG']['DE']['MONTH_SHORT'][$i];
  282.                 else {
  283.                     $s_ret.=$i;
  284.                 }
  285.                 $i++;
  286.                 $s_ret.="</option>\n";
  287.             }
  288.             $s_ret.= "\t</select>\n";
  289.             $s_ret.= "\t<input name=\"".$arrName."[".$this->myName."][YEAR]\" value=\"".($o_DateObj->getYear($o_DateObj->getYear("")."\" size=\"5\" maxlength=\"4\" \>\n";
  290.  
  291.             // <pk-05-06-30>
  292.             if (!$this->hideCalendarBtn{
  293.                 $s_ret.= "\t<a href=\"#\" onClick=\"";
  294.                 $s_ret.="if (document.forms['".$this->getMyFormName()."']) frmObj=document.forms['".$this->getMyFormName()."'];";
  295.                 $s_ret.="else frmObj=document.forms[0];";
  296.                 $s_ret.= "wnd=openWindow('calendar','".$OCSP_CONF['SYSTEMURL']."forms/calendar.php?";
  297.                 $s_ret.= "form=".urlencode($this->getMyFormName());
  298.                 $s_ret.= "&field=".urlencode($arrName."[".$this->myName."]");
  299.                 $s_ret.= "&DATEARR[YEAR]='+getElemValByName(frmObj,'".$arrName."[".$this->myName."][YEAR]')+'";
  300.                 $s_ret.= "&DATEARR[MONTH]='+getSelectedOptionByName(frmObj,'".$arrName."[".$this->myName."][MONTH]')+'";
  301.                 $s_ret.= "&DATEARR[DAY]='+getElemValByName(frmObj,'".$arrName."[".$this->myName."][DAY]')+'";
  302.                 $s_ret.= "',190,220);\"><img src=\"".$OCSP_CONF['SYSIMGURL']."icons-22x22/1day.png\" border=\"0\" width=\"18\" height=\"18\" align=\"middle\" class=\"button\"></a> ";
  303.             }
  304.             // </pk-05-06-30>
  305.         }
  306.  
  307.         if ($this->showTime{
  308.             $s_ret.="<input name=\"".$arrName."[".$this->myName."][HOUR]\" value=\"".pcf_addzero($o_DateObj->getHour())."\" size=\"3\" maxlength=\"2\" \>:\n";
  309.             $s_ret.="<input name=\"".$arrName."[".$this->myName."][MIN]\"  value=\"".pcf_addzero($o_DateObj->getMinutes())"\" size=\"3\" maxlength=\"2\" \>:\n";
  310.             $s_ret.="<input name=\"".$arrName."[".$this->myName."][SEC]\"  value=\"".pcf_addzero($o_DateObj->getSeconds())"\" size=\"3\" maxlength=\"2\" \>\n";
  311.             if (!$this->showDate{
  312.                 $s_ret.="<img src=\"".$OCSP_CONF['SYSIMGURL']."icons-16x16/today.gif\" border=\"0\" class=\"button\" onClick=\"{";
  313.                 $s_ret.="var aktDate=new Date();";
  314.                 $s_ret.="if (document.forms['".$this->getMyFormName()."']) frmObj=document.forms['".$this->getMyFormName()."'];";
  315.                 $s_ret.="else frmObj=document.forms[0];";
  316.                 $s_ret.="setElemValByName(frmObj,'".$arrName."[".$this->myName."][HOUR]',aktDate.getHours());";
  317.                 $s_ret.="setElemValByName(frmObj,'".$arrName."[".$this->myName."][MIN]',aktDate.getMinutes());";
  318.                 $s_ret.="setElemValByName(frmObj,'".$arrName."[".$this->myName."][SEC]',aktDate.getSeconds());";
  319.                 $s_ret.="}\" title=\"".$this->myForm->getLangTxt('SET_NOW')."\"/>";
  320.             }
  321.         }
  322.  
  323.         if (($this->showDate&& ($this->showTime)) {
  324.             $s_ret.="<img src=\"".$OCSP_CONF['SYSIMGURL']."icons-16x16/today.gif\" border=\"0\" class=\"button\" onClick=\"{";
  325.             $s_ret.="var aktDate=new Date();";
  326.             $s_ret.="if (document.forms['".$this->getMyFormName()."']) frmObj=document.forms['".$this->getMyFormName()."'];";
  327.             $s_ret.="else frmObj=document.forms[0];";
  328.             $s_ret.="setElemValByName(frmObj,'".$arrName."[".$this->myName."][YEAR]',aktDate.getFullYear());";
  329.             $s_ret.="setElemValByName(frmObj,'".$arrName."[".$this->myName."][MONTH]',aktDate.getMonth()+1);";
  330.             $s_ret.="setElemValByName(frmObj,'".$arrName."[".$this->myName."][DAY]',aktDate.getDate());";
  331.             $s_ret.="setElemValByName(frmObj,'".$arrName."[".$this->myName."][HOUR]',aktDate.getHours());";
  332.             $s_ret.="setElemValByName(frmObj,'".$arrName."[".$this->myName."][MIN]',aktDate.getMinutes());";
  333.             $s_ret.="setElemValByName(frmObj,'".$arrName."[".$this->myName."][SEC]',aktDate.getSeconds());";
  334.             $s_ret.="}\" title=\"".$this->myForm->getLangTxt('SET_NOW')."\"/>";
  335.         }
  336.         $s_ret.="\n<!-- ________END DBMS_FIELD_DATE: ".$this->myName."____________ -->\n\n";
  337.         return $s_ret;
  338.     }
  339.  
  340.  
  341.     /**
  342.       * returns the html code for the search compare type select
  343.       *
  344.       * @param string $arrName 
  345.       *
  346.       * @returns string
  347.       *
  348.       * @since pk-04-12-29
  349.       *
  350.       ***/
  351.     function getSearchCompTypes($arrName{
  352.         $ret ="<select name=\"".$arrName."[".$this->myName."][COMPTYPE]\">";
  353.         $ret.="  <option value=\"=\">=</option>";
  354.         $ret.="  <option value=\"<\">&lt;</option>";
  355.         $ret.="  <option value=\">\">&gt;</option>";
  356.         $ret.="</select>";
  357.         return $ret;
  358.     }
  359.  
  360.     /**
  361.       * returns the field default value
  362.       * if parent::getDefaultValue() includes "NOW()"
  363.       * current date and time is set
  364.       *
  365.       * @return string 
  366.       *
  367.       * @since pk-03-12-14
  368.       *
  369.       ***/
  370.     function getDefaultValue(){
  371.         $defVal=parent::getDefaultValue();
  372.         if (strstr($defVal,"NOW()")) {
  373.             $aDate=new OCSP_DATE();
  374.             $aDate->setLinuxTime(time());
  375.             return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getDateStmt($aDate,FALSE);
  376.         else {
  377.             return $defVal;
  378.         }
  379.     }
  380.  
  381.     /**
  382.       * returns a date object created from the value
  383.       *
  384.       * @param mixed $aValue 
  385.       * @param boolen $debug 
  386.       *
  387.       * @return OCSP_DATE 
  388.       *
  389.       * @since pk-06-08-18
  390.       * @version pk-07-10-01
  391.       *
  392.       ***/
  393.     function getDateObj($aValue,$debug=FALSE{
  394.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DATE::getDateObj()","Value: ".print_r($aValue,TRUE));
  395.  
  396.         if (pcf_is_instance_of($aValue,"OCSP_DATE")) {
  397.             if ($debugechoDebugLine(__FILE__,__LINE__,"<p>aValue is already a OCSP_DATE</p>");
  398.             return $aValue;
  399.         }
  400.  
  401.         $o_Date=new OCSP_DATE(FALSE);
  402.         if (is_array($aValue)) {
  403.             if ($debugechoDebugLine(__FILE__,__LINE__,"<p>aValue is an array</p>");
  404.             $o_Date->setFromArray($aValue);
  405.             return $o_Date;
  406.         }
  407.         if (!empty($aValue)) {
  408.             if ($debugechoDebugLine(__FILE__,__LINE__,"<p>aValue is string$aValue</p>");
  409.             $o_Date->setDateStr($aValue,$debug);
  410.             return $o_Date;
  411.         }
  412.         if ($debugechoDebugLine(__FILE__,__LINE__,"<p>Returning empty Date</p>");
  413.         return $o_Date;
  414.     }
  415.  
  416.     /**
  417.       * returns the field value
  418.       *
  419.       * @param  string  $aValue     the value
  420.       * @param  array   $err        error array
  421.       * @param  string  $arrName    name of the array to access fieldsarray  gloabl ${$arrName}
  422.       * @param  bool    $debug 
  423.       *
  424.       * @return string 
  425.       *
  426.       * @since   pk-03-12-13
  427.       * @version pk-03-12-13
  428.       * @version pk-06-08-18
  429.       * @version pk-07-09-26
  430.       *
  431.       ***/
  432.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  433.         $debug ($debug || $this->fldDebug || $this->fldDbgGetValue);
  434.         if ($debug{
  435.             echo "<hr><p><b>DBMS_FIELD_DATE::getValue(\$aValue,\$err,$arrName,...)</b> (".get_class($this)."/".$this->myName.")</p>";
  436.             echo "<blockquote><pre style=\"font-size:10px;\">";print_r($aValue);echo "</pre></blockquote>";
  437.         }
  438.  
  439.         if (is_array($aValue)) {
  440.             if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_TIME{
  441.                 if (implode(":",$aValue== "::"{
  442.                     return parent::getValue(NULL,$err,$arrName,$debug)// to check for null
  443.                 else  {
  444.                     return (intval($aValue['HOUR'])).":".(intval($aValue['MIN'])).":".(intval($aValue['SEC']));
  445.                 }
  446.             }
  447.             $obj_Date=new OCSP_DATE(FALSE);
  448.             $obj_DB=$this->myForm->getDBObj();
  449.  
  450.             $obj_Date->setFromArray($aValue,$debug);
  451.             if ($obj_Date->isNULL()) {
  452.                 if (!$this->allowNull()) {
  453.                     $err['ERROR']=TRUE;
  454.                     $err[$this->myName]['MSG']=(empty($this->nullErrMsg$this->label.": NULL_NOT_ALLOWED" $this->nullErrMsg);
  455.                     $err[$this->myName]['LABEL']=$this->label;
  456.                     if ($debug || $this->fldDebug{echo "<pre style=\"font-color:red;font-weight:bolder\">";print_r($err);echo "</pre>";}
  457.                     return FALSE;
  458.                 else if (!$this->dbDesc['NULL']// <pk-06-11.27>
  459.                     if ($debugecho "<pre>Returnung DefaultValue instead of NULL</pre>";
  460.                     return $this->getDefaultValue($debug);
  461.                 else {
  462.                     if ($debugecho "<pre>Returnung NULL</pre>";
  463.                     return $obj_DB->qs_getNullStmt();
  464.                 }
  465.             }
  466.             if ($debug{
  467.                 echo "<blockquote><pre style=\"font-size:10px;\">";
  468.                 print_r($obj_DB->qs_getDateStmt($obj_Date,FALSE));
  469.                 echo "</pre></blockquote>";
  470.             }
  471.             return $obj_DB->qs_getDateStmt($obj_Date,FALSE);
  472.         else {
  473.             return parent::getValue($aValue,$err,$arrName,$debug)// to check for null
  474.         }
  475.     }
  476.  
  477.     /**
  478.       * returns the value with slashes create use in a db statement
  479.       *
  480.       * @param  string  $aValue     the value
  481.       * @param  array   $err        error array
  482.       * @param  string  $arrName    name of the global array to access field gloabl ${$arrName}
  483.       * @param  bool    $debug 
  484.       *
  485.       * @return string 
  486.       *
  487.       * @version pk-03-11-27    DB-Object used instead of DB_.. function
  488.       * @version pk-03-12-13    use $this->getValue to check the Value
  489.       *
  490.       ***/
  491.     function slashedValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  492.         if ($debug{
  493.             echo "<hr><p><b>DBMS_FIELD_DATE::slashedValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)."/".$this->myName.")</p>";
  494.             echo "<blockquote><pre style=\"font-size:10px;\">";print_r($aValue);echo "</pre></blockquote>";
  495.         }
  496.  
  497.         $obj_DB=$this->myForm->getDBObj();
  498.         if ($this->dbDesc['TYPE'== DBMS_FLDTYPE_TIME{
  499.             if ($debugecho "<blockquote><pre style=\"font-size:10px\">DBMS_FLDTYPE_TIME\n</pre></blockquote>";
  500.             return $obj_DB->qs_getSlashedValue($this->getValue($aValue,$err,$arrName,$debug));
  501.         else {
  502.             if (is_array($aValue)) {
  503.                 if ($debug{echo "<pre style=\"font-size:10px;\">";print_r($aValue);echo "</pre></blockquote>"}
  504.                 $obj_Date=new OCSP_DATE();
  505.                 $obj_Date->setFromArray($aValue);
  506.                 if ($obj_Date->isNULL()) {
  507.                     if (!$this->allowNull()) {
  508.                         $obj_Date->setLinuxTime(time());
  509.                     else {
  510.                         return $obj_DB->qs_getNullStmt();
  511.                     }
  512.                 }
  513.                 if ($debug{echo "<pre style=\"font-size:10px;\">";print_r($obj_Date);echo "</pre></blockquote>"}
  514.  
  515.                 return $obj_DB->qs_getDateStmt($obj_Date,TRUE);
  516.             else {
  517.                 $err['ERROR']=TRUE;
  518.                 $err[$this->myName]['MSG']="NO_DATE_ARRAY SUBMITTED";
  519.                 $err[$this->myName]['LABEL']=$this->label;
  520.                 return FALSE;
  521.             }
  522.         }
  523.     }
  524.  
  525.     /**
  526.       * returns the html representation of the field
  527.       *
  528.       * @param mixed $aValue the falue
  529.       * @param string $arrName name of the global array holding data values
  530.       * @param boolean $debug show debug info
  531.       *
  532.       * @return mixed   the html representation of the field
  533.       *
  534.       * @since pk-06-07-17
  535.       *
  536.       ***/
  537.     function getScreenValue($aValue=NULL,$arrName="DBVAL",$debug=FALSE{
  538.         $debug=($debug $this->fldDebug | $this->fldDbgGetValue);
  539.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DATE::getScreenValue()",$this->getName().": ".print_r($aValue,TRUE));
  540.  
  541.         $o_Date=$this->getDateObj($aValue,$debug);
  542.         if ($debugecho "<pre>".print_r($o_Date,TRUE)."</pre>";
  543.         if (is_object($o_Date&& (!$o_Date->isNULL())) {
  544.             $formatStr="";
  545.             if ($this->showDate{
  546.                 if (empty($this->fldDateformat)) $this->fldDateformat="Y-m-d";
  547.                 trim($formatStr.=$this->fldDateformat);
  548.             }
  549.             if ($this->showTime{
  550.                 if (empty($this->fldTimeformat)) $this->fldTimeformat="H:i:s";
  551.                 $formatStr.=" ".trim($this->fldTimeformat);
  552.             }
  553.             if ($debugecho "<p>Formatstring$formatStr</p>";
  554.             return trim($o_Date->dateStr($formatStr));
  555.         else {
  556.             return parent::getScreenValue(NULL,$arrName,$debug);
  557.         }
  558.     }
  559.  
  560.     /**
  561.       * returns the html representation of the field in a list (table col)
  562.       *
  563.       * @param mixed    $aValue     the falue
  564.       * @param string $arrName  name of the global array holding data values
  565.       * @param bool     $debug      show debug info
  566.       *
  567.       * @returns mixed   the html representation of the field
  568.       *
  569.       * @since pk-06-07-17
  570.       *
  571.       ***/
  572.     function getListValue($aValue=NULL,$arrName="DBVAL",$debug=FALSE{
  573.         $debug=($debug $this->fldDebug | $this->fldDbgGetValue);
  574.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DATE::getListValue()","<pre>Value:\n----\n".print_r($aValue,TRUE)."\n----</pre>");
  575.  
  576.         $o_Date=$this->getDateObj($aValue,$debug);
  577.         if (is_object($o_Date&& (!$o_Date->isNULL())) {
  578.             $formatStr="";
  579.             if ($this->showDate{
  580.                 trim($formatStr.=$this->lstDateformat);
  581.             }
  582.             if ($this->showTime{
  583.                 $formatStr.=" ".trim($this->lstTimeformat);
  584.             }
  585.             if ($debugecho $formatStr;
  586.             return trim($o_Date->dateStr($formatStr));
  587.         else {
  588.             return parent::getListValue(NULL,$arrName,$debug);
  589.         }
  590.     }
  591.  
  592.     /**
  593.       * get a where clause for the search settings
  594.       *
  595.       * $aArr array post values of the serach form
  596.       * return string where clause
  597.       **/
  598.  
  599.     function searchWhere($aArr,$debug=FALSE{
  600.         if ($debugecho "<p><b>DMBS_FIELD_INT::searchWhere($aArr,$debug)</b> (".get_class($this).")</p>";
  601.  
  602.         if (!is_array($aArr)) return "";
  603.         if ($debug{echo "<blockquote><pre>";print_r($aArr);echo "</pre></blockquote>";}
  604.  
  605.         $err="";
  606.         if ($debugecho "<pre>"print_r($aArr)echo "</pre>"}
  607.  
  608.         if (!empty($aArr['ANDOR']))  {
  609.             $ret=($aArr['ANDOR'== "OR" " OR " " AND ");
  610.  
  611.             switch($aArr['COMPTYPE']// only to verify input
  612.                 case "<":
  613.                 case ">":
  614.                 case "=":
  615.                     $ret.=$this->myTable.".".$this->myName;
  616.                     $ret.=$aArr['COMPTYPE'];
  617.                     global $TEMPDBVAL;$TEMPDBVAL=$aArr;
  618.                     $ret.=$this->slashedValue($TEMPDBVAL,$err,"TEMPDBVAL",$debug);
  619.                     unset($TEMPDBVAL);
  620.                     break;
  621.                 default:
  622.                     echo "COMPTYPE NOT FOUND";
  623.                     return "";
  624.             }
  625.             return $ret;
  626.         else return "";
  627.     }
  628. }
  629. ?>

Documentation generated on Thu, 08 Jan 2009 17:40:54 +0100 by phpDocumentor 1.4.0a2