Source for file CLIENT_DEP_TREE_NODE.phpclass

Documentation is available at CLIENT_DEP_TREE_NODE.phpclass

  1. <?php
  2. /**
  3.   * Class file CLIENT_DEP_TREE_NODE.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    client
  7.   *
  8.   * @author     Peter Krebs (pk) <p.krebs@wpus.at>
  9.   * @copyright  (c) 2002-2003 by Peter Krebs and Landesverlag Unternehmensservice
  10.   * @copyright  (c) 2005 by WURM & Parnter Unternehmensservice GmbH
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   ***/
  14.  
  15. require_once $GLOBALS['OCSP']['PHPINCPATH'].'db/dbms_tree_node.phpclass';
  16.  
  17.     /**
  18.       * @var  string  $myGlobalTreeKey      index in $GLOABLS['DBMS_TREE'][]
  19.       ***/
  20.     var $myGlobalTreeKey = "T_CLI_DEPARTMENT";
  21.  
  22.     /**
  23.       * @staticvar string $myTable 
  24.       */
  25.     var $myTable="T_CLI_DEPARTMENT";
  26.  
  27.     /**
  28.       * @staticvar  string  $myIdFld        id column = root
  29.       ***/
  30.     var $myIdFld        ="CDEP_ID";
  31.  
  32.     /**
  33.       * @staticvar  string  $myParentFld    name of the parent column
  34.       ***/
  35.     var $myParentFld    ="CDEP_PARENT";
  36.  
  37.     /**
  38.       * @staticvar  string  $mySortFld      name of the sort field
  39.       ***/
  40.     var $mySortFld      ="CDEP_NAME";
  41.  
  42.     /**
  43.       * @var  string  $myChildClass 
  44.       ***/
  45.     var $myChildClass = "CLIENT_DEP_TREE_NODE";
  46.  
  47.     /**
  48.       * @var string $classSrcFile source file of the class
  49.       * @since pk-05-02-02
  50.       ***/
  51.     var $myClassSrcFile=__FILE__;
  52.  
  53.     /**
  54.       * wether getname should only return
  55.       * CDEP_NAME or CDEP_LONGNAME (CDEP_NAME)
  56.       *
  57.       * @var boolean $getFullName 
  58.       * @since pk-05-04-08
  59.       *
  60.       ***/
  61.     var $getFullName=FALSE;
  62.  
  63.     /**
  64.       * @var CLIENT $myCliObj 
  65.       * @since pk-07-01-12
  66.       ***/
  67.     var $myCliObj=NULL;
  68.  
  69.     // ~~~~~~~~~~~~~~~~~~~~~~~ constructor and objectvalue methodes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  70.  
  71.     /**
  72.       * returns the client id CLI_ID
  73.       *
  74.       * @returns int
  75.       *
  76.       * @since pk-07-01-13
  77.       *
  78.       ***/
  79.     function getCliId({
  80.         return $this->getDBField('CLI_ID');
  81.     }
  82.  
  83.     /**
  84.       * sets the client id
  85.       *
  86.       * @param int $aId 
  87.       *
  88.       * @since pk-07-01-13
  89.       *
  90.       ***/
  91.     function setCliId($aId{
  92.         if (intval($aId)) {
  93.             $this->setDBField('CLI_ID',intval($aId));
  94.             if (pcf_is_instance_of($this->myCliObj,'CLIENT'))
  95.                 if (intval($this->myCliObj->getId()) && ($this->myCliObj->getId(!= $this->getCliId())) {
  96.                 // we have the wrong client
  97.                 $s_className=strtoupper(get_class($this->myCliObj));
  98.                 $s_cmd="\$this->myCliObj=new ".$s_className."(".$this->getCliId().");";
  99.                 echoDebug(__FILE__,"<p>$s_cmd</p>");
  100.                 eval($s_cmd);
  101.             }
  102.         }
  103.     }
  104.  
  105.     /**
  106.       * inserts a new row to the table
  107.       * if a manager is set the mangers CDEP_ID is set to the new value
  108.       *
  109.       * @param string $gDBIDX Index of $GLOBALS to the db object
  110.       * @param bool   $debug  show debug info
  111.       *
  112.       * @return int   returns the autoIncFld ID if exists or 1 on success
  113.       *
  114.       ***/
  115.     function dbInsert($gDBIDX="USRDB",$debug=FALSE{
  116.         if ($debugecho "<hr><p><b>DBMS_TABLEOBJ::dbInsert($gDBIDX,$debug)</b> (".get_class($this).")</p>";
  117.  
  118.         if ($this->{$this->myIdFldparent::dbInsert($gDBIDX,$debug)) {
  119.             if (intval($this->CDEP_MANGER)) {
  120.                 $cmd ="UPDATE T_CLI_STAFF SET CDEP_ID=".$this->{$this->myIdFld};
  121.                 $cmd.=" WHERE CST_ID=".intval($this->CDEP_MANAGER);
  122.                 $cmd.="   AND CLI_ID=".intval($this->CLI_ID);
  123.             }
  124.         }
  125.         return $this->{$this->myIdFld};
  126.     }
  127.  
  128.     /**
  129.       * echos the tree within a table
  130.       *
  131.       * @param int $aktNode 
  132.       * @param string $link 
  133.       * @param boolean $debug 
  134.       *
  135.       ***/
  136.     function writeTree($level=1,&$rootPath,$link="index.php?",$debug=FALSE{
  137.         if ($debugecho "<p><b>CLIENT_DEP_TREE_NODE::writeTree($level,\$rootPath,$link,...)</b> (".get_class($this).")</p>";
  138.  
  139.         $border=($debug "1" "0");
  140.  
  141.         if (!sizeof($this->myChildren)) $this->populateChildren(TRUE,$debug);
  142.         foreach($this->myChildren as $orderNr => $id{
  143.             if (!is_object($rootPath[$level]|| $id != $rootPath[$level]->getId()) {
  144.                 echo "<tr><td class=\"treeNode\"><a href=\"".pcf_HTML_changeURI_GetValue($link,'CDEP_ID',$id)."\">";
  145.                 $GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id]->getFullName=$this->getFullName;
  146.                 echo $GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id]->getName();
  147.                 echo "</a></td></tr>\n";
  148.             else {
  149.                 echo "<tr><td class=\"treeNodeOn\"><a href=\"".pcf_HTML_changeURI_GetValue($link,'CDEP_ID',$id)."\">";
  150.                 $GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id]->getFullName=$this->getFullName;
  151.                 echo $GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id]->getName();
  152.                 echo "</a></td></tr>\n";
  153.                 echo "<tr><td class=\"treeIntend\" align=\"right\"><table width=\"95%\" border=\"$border\">";
  154.                 $GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id]->writeTree($level+1,$rootPath,$link,$debug);
  155.                 echo "</table></td></tr>\n";
  156.             }
  157.         }
  158.     }
  159.  
  160.  
  161.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  162.     // layout functions
  163.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  164.  
  165.     /**
  166.       * returns the name of a node
  167.       *
  168.       * @param bool $filtered 
  169.       * @param bool $debug 
  170.       *
  171.       * @returns string
  172.       *
  173.       ***/
  174.     function getName($debug=FALSE{
  175.         if ($debugecho "<p><b>CLIENT_DEP_TREE_NODE::getName(...)</b> (".get_class($this).")</p>";
  176.         if ($this->getFullName{
  177.             return $this->CDEP_LONGNAME." (".$this->CDEP_NAME.")";
  178.         else {
  179.             return $this->CDEP_NAME;
  180.         }
  181.     }
  182.  
  183.  
  184. }
  185.  
  186. ?>

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