Source for file DBMS_FIELD_DBMS_FORMFIELDSELECT.phpclass

Documentation is available at DBMS_FIELD_DBMS_FORMFIELDSELECT.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_DBMS_FORMFIELDSELECT.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   int
  8.   *
  9.   * @author     Peter Krebs <p.krebs@lvus.at>
  10.   * @copyright  (c) 2002-2005 by Peter Krebs and LVUS
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   ***/
  14.  
  15. pcf_require_class('DBMS_FIELD_FOREIGNKEY',dirname(__FILE__)._OCSP_DIRSEP_."DBMS_FIELD_FOREIGNKEY.phpclass");
  16.  
  17. /**
  18.   * Class file DBMS_FIELD_DBMS_FORMFIELDSELECT.phpclass
  19.   *
  20.   * @project    Open CSP-Management
  21.   * @package    dbms_field
  22.   * @category   int
  23.   *
  24.   * @author     Peter Krebs <p.krebs@lvus.at>
  25.   * @copyright  (c) 2002-2005 by Peter Krebs and LVUS
  26.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  27.   *
  28.   * @since      pk-05-10-03
  29.   *
  30.   ***/
  31.     protected $className      = "Formfield Select";
  32.     
  33.     /**
  34.       * source file of the class
  35.       *
  36.       * @var string $classSrcFile 
  37.       * @since pk-05-01-20
  38.       ***/
  39.     protected $classSrcFile=__FILE__;
  40.     
  41.     protected $lookupTable         = "T_DBMS_FORMFIELDS";
  42.     protected $lookupShowField  = "CONCAT(IFNULL(FLD_LABEL,'FLD:'),' (',FLD_NAME,')')";
  43.     protected $lookupField      = "FLD_KEY";
  44.     protected $lookupSort          = "FLD_SORTORDER";
  45.     protected $allowNullSelect    = True;
  46.     protected $nullLabel         ="--- ??? ----";
  47.  
  48.     /**
  49.       * column name of the form id
  50.       * @var string $myFormIdCol 
  51.       ***/
  52.     protected $myFormIdCol="FRM_ID";
  53.  
  54.     /**
  55.       * returns an array of field to bie shown in the edit form
  56.       * by using editTbl_echoForm
  57.       *
  58.       * the array is in the form:
  59.       *
  60.       * <code>
  61.       * [_sectionName_]
  62.       *      [TITLE] -> string
  63.       *      [_rowName_]
  64.       *         [FLDLAB]  (complete html code with <td></td>)
  65.       *         [FLDVAL] (complete html code with <td></td>)
  66.       * </code>
  67.       *
  68.       * @param boolean $debug 
  69.       *
  70.       * @returns array
  71.       *
  72.       * @since pk-07-01-09
  73.       * @version pk-08-06-26
  74.       */
  75.     function editTbl_getFieldEditArr($debug=False
  76.     {
  77.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBMS_FORMFIELDSELECT::editTbl_getFieldEditArr","",0);
  78.  
  79.         if (empty($this->lookupField))         $this->lookupField=$this->myName// <pk-06-11-29 />
  80.         if (empty($this->myFormIdCol))         $this->myFormIdCol = 'FRM_ID'
  81.         if (empty($this->lookupShowField))     $this->lookupShowField    = "CONCAT(IFNULL(FLD_LABEL,'FLD:'),' (',FLD_NAME,')')";
  82.         if (empty($this->lookupSort))        $this->lookupSort = "FLD_TABLE,FLD_SORTORDER";
  83.         
  84.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  85.  
  86.         unset($a_ret['SELECT']);
  87.         //unset($a_ret['DBLOOKUP']);
  88.         $a_ret['DBLOOKUP']['FLD_LUTBL']['FLDVAL']  'T_DBMS_FORMFIELDS';
  89.         $a_ret['DBLOOKUP']['FLD_VALFLD']['FLDVAL''FLD_KEY';
  90.         
  91.         $str_lookupWhereAdd str_replace("FRM_ID='\$*" $this->myFormIdCol ."\$' AND ","",$this->lookupWhere);
  92.         $str_lookupWhereAdd str_replace("FRM_ID='\$*" $this->myFormIdCol ."\$' ","",$str_lookupWhereAdd);
  93.         
  94.         $a_ret['DBLOOKUP']['FLD_WHEREFLD']['FLDVAL'"
  95.                 FRM_ID='\$*<input type=\"text\" size=\"20\" name=\"myFormIdCol\" value=\"" $this->myFormIdCol . "\" />\$' AND <br />                
  96.                 <textarea name=\"lookupWhereAdd\" rows=\"2\" cols=\"40\">".htmlspecialchars($str_lookupWhereAdd)."</textarea>
  97.                 <!-- {$this->lookupWhere} -->
  98.             ";
  99.         
  100.         unset($a_ret['FTBL_POPUPS']);
  101.         
  102.         return $a_ret;
  103.     }    
  104.     
  105.     /**
  106.       * @return boolean
  107.       **/
  108.     function save() {
  109.         $ret=parent::save();
  110.              
  111.         $this->lookupTable      = "T_DBMS_FORMFIELDS";
  112.         $this->lookupField      = "FLD_KEY";        
  113.         $this->myFormIdCol      = (isset($_POST['myFormIdCol']$_POST['myFormIdCol'$this->myFormIdCol);
  114.  
  115.         $this->lookupWhere        = "FRM_ID='\$*" $this->myFormIdCol ."\$' ";
  116.         if (!isset($_POST['lookupWhereAdd']&& !empty($_POST['lookupWhereAdd']))
  117.         {
  118.             $this->lookupWhere .= "AND " $_POST['lookupWhereAdd'];
  119.         }
  120.         
  121.         return $ret;
  122.     }
  123.  
  124.  
  125.     /**
  126.       * returns the where part of to select the foreign Value
  127.       *
  128.       * @param string $arrName
  129.       * @param string $append
  130.       * @param boolean $debug
  131.       * @param boolean $withWhereAnd
  132.       *
  133.       * @return string
  134.       *
  135.       **/
  136.     function getWhereStmt($arrName="DBVAL",$append="",$debug=FALSE,$withWhereAnd=TRUE) {
  137.         global ${$arrName};
  138.         $debug=($debug || $this->fldDebug || $this->fldDbgGetValue);
  139.         if ($debugecho "<hr /><p><b>DBMS_FIELD_DBMS_FORMFIELDSELECT::getWhereStmt($arrName,$append,$debug)</b> (".get_class($this)."/".$this->myName.")</p><blockquote>";
  140.  
  141.         if ($withWhereAnd{
  142.             $ret=" WHERE FRM_ID=".intval(${$arrName}[$this->myFormIdCol]);
  143.         } else {
  144.             $ret=" WHERE 1=1";
  145.         }
  146.         if ($debug) echo "<pre>2:\n$wKey</pre>";
  147.         if (!empty($append)) {
  148.             $ret .=" AND ".$append; // <pk-06-10-18 /> E_ALL
  149.         }
  150.         if ($debug) echo "<pre>3:\n$ret</pre>";
  151.         if ($debug) echo "</blockquote>";
  152.         return $ret;
  153.     }
  154.  
  155.  
  156.     /**
  157.       * returns the html code for a button to zoom to the foreign record
  158.       * first ensure FRM_ID is set in $this->editUrl
  159.       * then calls the parent method
  160.       *
  161.       * @param string $arrName
  162.       * @param boolean $debug
  163.       *
  164.       * @return string
  165.       *
  166.       * @since pk-05-10-23
  167.       *
  168.       **/
  169.     function getZoomButton($arrName="DBVAL",$debug=FALSE) {
  170.         if (empty($arrName)) $arrName = $this->myDataArrNameelse $this->myDataArrName=$arrName;
  171.  
  172.         $debug=($debug || $this->fldDebug);
  173.         if ($debugecho "<p><b>DBMS_FIELD_DBMS_FORMFIELDSELECT::getAddButton($arrName,$url,...)</b> (".get_class($this).")</p>";
  174.  
  175.         $this->editUrl=str_replace("\$*FRM_ID\$",$this->myFormIdCol,$this->editUrl);
  176.         return parent::getZoomButton($arrName,$debug);
  177.     }
  178.  
  179.  
  180. }

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