Source for file DBMS_FIELD_DBLOOKUPPOPUPSELECT.phpclass

Documentation is available at DBMS_FIELD_DBLOOKUPPOPUPSELECT.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_DBLOOKUPPOPUPSELECT.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   any
  8.   *
  9.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @since pk-06-02-10
  13.   * @version $Id: DBMS_FIELD_DBLOOKUPPOPUPSELECT.phpclass,v 1.4 2008/08/08 02:00:42 pitlinz Exp $
  14.   */
  15.  
  16.  
  17. pcf_require_class('DBMS_FIELD_DBLOOKUPSELECTLIST',dirname(__FILE__"/");
  18.  
  19.  
  20. /**
  21.   * Class DBMS_FIELD_DBLOOKUPPOPUPSELECT
  22.   *
  23.   * handels select fields (&lt;SELECT&gt;) where the values are selected form the database
  24.   *
  25.   * @project    Open CSP-Management
  26.   * @package    dbms_field
  27.   * @category   any
  28.   *
  29.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  30.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  31.   *
  32.   * @since pk-06-02-10
  33.   * @version $Id: DBMS_FIELD_DBLOOKUPPOPUPSELECT.phpclass,v 1.4 2008/08/08 02:00:42 pitlinz Exp $
  34.   */
  35.  
  36.     // ###########################################################
  37.     // OBJECT (CONST) VAR DECLARATION
  38.     // ###########################################################
  39.  
  40.      var $className       = "LookupDbPopUp";
  41.  
  42.     /**
  43.       * source file of the class
  44.       *
  45.       * @var string $classSrcFile 
  46.       ***/
  47.     var $classSrcFile=__FILE__;
  48.  
  49.     /**
  50.       * @var int $popUp_frmId 
  51.       ***/
  52.     var $popUp_frmId=0;
  53.     /**
  54.       * @var int $popUp_url 
  55.       ***/
  56.     var $popUp_url="";
  57.     /**
  58.       * @var int $popUp_width 
  59.       ***/
  60.     var $popUp_width=350;
  61.     /**
  62.       * @var int $popUp_height 
  63.       ***/
  64.     var $popUp_height=500;
  65.  
  66.     // ###########################################################
  67.     // OBJECT SETTINGS METHODS
  68.     // ###########################################################
  69.  
  70.     /**
  71.       * returns an array of field to bie shown in the edit form
  72.       * by using editTbl_echoForm
  73.       *
  74.       * the array is in the form:
  75.       *
  76.       * <code>
  77.       * [_sectionName_]
  78.       *      [TITLE] -> string
  79.       *      [_rowName_]
  80.       *         [FLDLAB]  (complete html code with <td></td>)
  81.       *         [FLDVAL] (complete html code with <td></td>)
  82.       * </code>
  83.       *
  84.       * @param boolean $debug 
  85.       *
  86.       * @returns array
  87.       *
  88.       * @since pk-06-04-26
  89.       *
  90.       ***/
  91.     function editTbl_getFieldEditArr($debug=FALSE{
  92.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBLOOKUPPOPUPSELECT::editTbl_getFieldEditArr","",0);
  93.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  94.  
  95.         $a_ret['SELECT']['FLD_RADCHKBOX']=NULL// unset parent value
  96.         $a_ret['DBLOOKUP']['FLD_LSTADDVALUES']=array(
  97.             'FLDLAB'=>"Werte hinzuf&uuml;gen",
  98.             'FLDVAL'=>"<input name=\"allowAddValues\" type=\"checkbox\"".($this->allowAddValues ? "checked" "")." value=\"1\">ja fals im Formular m&ouml;glich"
  99.         );
  100.         $a_ret['DBLOOKUP']['FLD_LSTEDITVALUES']=array(
  101.             'FLDLAB'=>"Werte bearbeiten",
  102.             'FLDVAL'=>"<input name=\"allowEditValues\" type=\"checkbox\"".($this->allowEditValues ? "checked" "")." value=\"1\">ja fals im Formular m&ouml;glich"
  103.         );
  104.  
  105.         $a_ret['LOOKUPFORM']=array(
  106.             'TITLE'=>"Popup Formular",
  107.             'FLD_POPFORM'=>array(
  108.                 'FLDLAB'=>"Popup Formular"
  109.             ),
  110.             'FLD_POPLINK'=>array(
  111.                 'FLDLAB'=>"URL <a href=\"".$GLOBALS['OCSP']['SYSTEMURL']."help/templatevars.html\" target=\"_blank\">?</a>",
  112.                 'FLDVAL'=>"<input name=\"popUp_url\" value=\"".$this->popUp_url."\" size=\"40\">"
  113.             ),
  114.             'FLD_POPUPSIZE'=>array(
  115.                 'FLDLAB'=>"Popup Gr&ouml;&szlig;e",
  116.                 'FLDVAL'=>"
  117.                             width:  <input name=\"popUp_width\"  value=\"".$this->popUp_width."\" size=\"4\"> px
  118.                             height: <input name=\"popUp_height\" value=\"".$this->popUp_height."\" size=\"4\"> px
  119.                           "
  120.             )
  121.         );
  122.         $a_ret['LOOKUPFORM']['FLD_POPFORM']['FLDVAL']="<select name=\"popUp_frmId\" size=\"1\">\n";
  123.         $s_query="SELECT FRM_ID,FRM_NAME,FRM_TABLES FROM T_DBMS_FORM ORDER BY FRM_TABLES,FRM_NAME";
  124.         $b_found=FALSE;
  125.         if ($o_cursor=$GLOBALS['USRDB']->query($s_query)) {
  126.             while($a_row=$o_cursor->fetchArrayFld()) {
  127.                 $a_ret['LOOKUPFORM']['FLD_POPFORM']['FLDVAL'].="\t<option value=\"".$a_row['FRM_ID']."\" title=\"".$a_row['FRM_TABLES']."\"";
  128.                 if ($this->popUp_frmId == $a_row['FRM_ID']{
  129.                     $a_ret['LOOKUPFORM']['FLD_POPFORM']['FLDVAL'].=" selected";
  130.                     $b_found=TRUE;
  131.                 }
  132.                 $a_ret['LOOKUPFORM']['FLD_POPFORM']['FLDVAL'].=">".$a_row['FRM_NAME']." (".$a_row['FRM_ID'].")</option>\n";
  133.             }
  134.         }
  135.         if (!$b_found{
  136.             $a_ret['LOOKUPFORM']['FLD_POPFORM']['FLDVAL'].="\t<option value=\"\" selected>[URL]</option>\n";
  137.         }
  138.         $a_ret['LOOKUPFORM']['FLD_POPFORM']['FLDVAL'].="</select>";
  139.         if ($GLOBALS['USER']->isGroupMember($GLOBALS['GROUPS']['DBMS'])) {
  140.             $a_ret['LOOKUPFORM']['FLD_POPFORM']['FLDVAL'].="<a onClick=\"
  141.                                                         var frmId=getSelectedOptionByName(document.forms['frmEdit'],'popUp_frmId');
  142.                                                         if (frmId=='') {
  143.                                                             alert('W&auml;hlen Sie zuerst ein Formular aus');
  144.                                                         } else {
  145.                                                             var link='".$GLOBALS['PROJECT']['ADMINURL']."dbms/fieldList.php?';
  146.                                                             link=link+'&FRM_ID='+frmId;
  147.                                                             openLinkWnd(link);
  148.                                                         }
  149.                                                     \" title=\"Formular bearbeiten\">
  150.                                                         <img src=\"".$GLOBALS['OCSP']['SYSIMGURL']."icons-16x16/utilities.png\" border=\"0\" class=\"button\">
  151.                                                     </a>";
  152.         }
  153.         return $a_ret;
  154.  
  155.     }
  156.  
  157.  
  158.     /**
  159.       * save the filed definition form
  160.       *
  161.       * @returns boolean
  162.       *
  163.       * @version pk-04-12-31
  164.       * @version pk-06-02-06 popUp_frmId
  165.       *
  166.       ***/
  167.     function save({
  168.         $ret=parent::save();
  169.         $this->popUp_frmId      =(intval($_POST['popUp_frmId']));
  170.         $this->popUp_url        =$_POST['popUp_url'];
  171.         $this->popUp_width      =(intval($_POST['popUp_width']));
  172.         $this->popUp_height     =(intval($_POST['popUp_height']));
  173.         return $ret;
  174.     }
  175.  
  176.     // ###########################################################
  177.     // OBJECT DATA METHODS
  178.     // ###########################################################
  179.  
  180.  
  181.  
  182.     // ###########################################################
  183.     // OBJECT HTML FORM METHODS
  184.     // ###########################################################
  185.  
  186.     /**
  187.       * return a javascript code sequence to popup a input or edit dialog
  188.       *
  189.       * if $selName isset this is used instead of $this->myName
  190.       *
  191.       * if $mode is different from FRM_MODE_NEW the popup must get
  192.       * the value through javascript
  193.       *
  194.       * see $GLOBALS['OCSP']['SYSTEMURL']."forms/popup_form.php" for details
  195.       *
  196.       * if !empty $setMethod popup_form.php calls this method after adding
  197.       * the option instead of selecting the option
  198.       *
  199.       * @param int $mode 
  200.       * @param string $selName since 06-02-10 (name of the select element if different from $this->myName)
  201.       * @param string $setMethod (js method template to call instead of directly setting the value)
  202.       * @param boolean $debug 
  203.       *
  204.       * @returns string
  205.       *
  206.       * @since pk-06-02-06
  207.       * @version pk-06-04-29
  208.       *
  209.       ***/
  210.     function getPopupLinkJs($mode=FRM_MODE_LIST,$selName="",$setMethod="",$debug=FALSE{
  211.         if ($debugecho "<p><b>DBMS_FIELD_DBLOOKUPPOPUPSELECT::getPopupLinkJs(...)</b> (".get_class($this)."/".$this->myName.")</p>";
  212.  
  213.         if (empty($this->popUp_url)) {
  214.             $s_url=$GLOBALS['OCSP']['SYSTEMURL']."forms/popup_form.php?";
  215.         else {
  216.             $s_url=pcf_tmpl_parse($this->popUp_url,NULL,$debug);
  217.         }
  218.  
  219.         $a_args['FRMID']    =$this->popUp_frmId;
  220.         $a_args['FRMMODE']  =$mode;
  221.         $a_args['ARRNAME']  =$this->myDataArrName;
  222.         $a_args['ARRFLD']   =$this->myName// the form, data array name
  223.         $a_args['SELFLD']   =(empty($selName$this->myName : $selName)// optional name for use in js
  224.         $a_args['SETMETHOD']=$setMethod;
  225.         $a_args['TBL']      =$this->lookupTable;
  226.         $a_args['OPENERFRM']=$this->getFrmId();
  227.         $a_args['OFRMNAME'=$this->getMyFormName();
  228.         $a_args['OTBL']     =$this->getTable();
  229.         $a_args['OGET']     =$_GET;
  230.         //$a_args['OPOST']    =$_POST;
  231.  
  232.         //$a_args['SHOWFIELD']=$this->lookupShowField;
  233.         //$a_args['LUWHERE']  =$this->lookupWhere;
  234.         //$a_args['KEYFIELD'] =$this->lookupField;
  235.  
  236.  
  237.         require_once __OCSP_PHPINCPATH__."common/pcf_md5.phpinc";
  238.         $s_url=pcf_HTML_changeURI_GetValue($s_url,"ARGS",urlencode(pcfmd5_encrypt(serialize($a_args))));
  239.  
  240.         if ($this->reloadFormOnChange{
  241.             $s_url=pcf_HTML_changeURI_GetValue($s_url,"OPENERRELOAD","1");
  242.         else {
  243.             $s_url=pcf_HTML_changeURI_GetValue($s_url,"OPENERRELOAD","");
  244.         }
  245.         $s_url=pcf_HTML_changeURI_GetValue($s_url,session_name(),session_id());
  246.  
  247.         $s_jCmd="\nvar url_".$this->myName."='';\n";
  248.         while(strlen($s_url)>0{
  249.             $s_jCmd.="url_".$this->myName."=url_".$this->myName."+'".substr($s_url,0,32)."';\n";
  250.             $s_url=substr($s_url,32);
  251.         }
  252.  
  253.         $s_jCmd.="var opt_".$this->myName."='width=".$this->popUp_width.",height=".$this->popUp_height.",toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes';\n";
  254.         $s_jCmd.="hWnd_".$this->myName."=window.open(url_".$this->myName.",'".$this->myName."', opt_".$this->myName.");\n";
  255.         $s_jCmd.="hWnd_".$this->myName.".focus();\n";
  256.  
  257.         if ($debugecho "<blockquote><pre>".htmlspecialchars($s_jCmd)."</pre></blockquote>";
  258.  
  259.         return $s_jCmd;
  260.     }
  261.  
  262.  
  263.     /**
  264.       * overwrite the parent method as we use the searchform
  265.       *
  266.       * @param boolean $debug 
  267.       *
  268.       * @returns string
  269.       *
  270.       * @since pk-06-04-26
  271.       *
  272.       ***/
  273.     function getNewBtn($arrName,$debug=FALSE{
  274.         $debug=($debug || $this->fldDebug);
  275.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBLOOKUPPOPUPSELECT::getNewBtn","",0);
  276.  
  277.         return "";
  278.     }
  279.  
  280.     function getPopupBtn($debug=FALSE{
  281.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBLOOKUPPOPUPSELECT::getPopupBtn","",0);
  282.  
  283.         $s_ret ="<!--\n\t\t _______ SEARCH VALUES BUTTON _______ \n";
  284.         $s_ret.="\t\t--> <a name=\"".$this->getMyFormName()."_".$this->myName."\" onClick=\"";
  285.         $s_ret.=$this->getPopupLinkJs(FRM_MODE_LIST,"","",$debug);
  286.         $s_ret.="\n";
  287.         $s_ret.="\t\t \"><img src=\"".$GLOBALS['PROJECT']['SYSIMGURL']."icons-16x16/view_multicolumn.gif\" border=\"0\" alt=\"Suchen/Hinzuf&uuml;gen\" title=\"Suchen/Hinzuf&uuml;gen\" valign=\"middle\" align=\"middle\" class=\"button\">";
  288.         $s_ret.="</a><!--\n";
  289.         $s_ret.="\t\t _______ SEARCH VALUES BUTTON _______ \n-->";
  290.  
  291.         return $s_ret;
  292.     }
  293.  
  294.     /**
  295.       * returns the html code for the select
  296.       *
  297.       * @param string $aValue 
  298.       * @param array $arrName 
  299.       * @param boolean $debug 
  300.       *
  301.       * @returns string
  302.       *
  303.       * @version pk-05-12-01
  304.       * @version pk-06-02-06 popUp_frmId
  305.       *
  306.       ***/
  307.     function getInputTag($aValue,$arrName="DBVAL",$debug=FALSE{
  308.         $debug=($debug || $this->fldDebug);
  309.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBLOOKUPPOPUPSELECT::getInputTag","aValue=$aValue",0);
  310.         global ${$arrName};
  311.  
  312.         $s_ret=parent::getInputTag($aValue,$arrName,$debug);
  313.         $s_ret.=$this->getPopupBtn($debug);
  314.  
  315.         return $s_ret;
  316.     }
  317.  
  318.  
  319.     // ###########################################################
  320.     // SEARCH FORM METHODS
  321.     // ###########################################################
  322.  
  323.  
  324.     // ###########################################################
  325.     // OBJECT HTML FORM METHODS
  326.     // ###########################################################
  327.  
  328.  
  329.     // ###########################################################
  330.     // OBJECT VALUE CHECK METHODS
  331.     // ###########################################################
  332.  
  333.  
  334. // end class DBMS_FIELD_DBLOOKUPPOPUPSELECT
  335. ?>

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