Source for file DBMS_FIELD_FOREIGNKEY.phpclass

Documentation is available at DBMS_FIELD_FOREIGNKEY.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_FOREIGNKEY.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   int
  8.   *
  9.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @version $Id: DBMS_FIELD_FOREIGNKEY.phpclass,v 1.18 2008/12/03 21:32:40 pitlinz Exp $
  13.   */
  14.  
  15.     // ---------------------------------------------------------------------------
  16.     // requirements
  17.     // ---------------------------------------------------------------------------
  18.  
  19.     pcf_require_class('DBMS_FIELD_DBLOOKUPSELECTLIST',dirname(__FILE__)."/");
  20.  
  21.     
  22. /**
  23.   * handles foreign key fields
  24.   *
  25.   * @project    Open CSP-Management
  26.   * @package    dbms_field
  27.   * @category   int
  28.   *
  29.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  30.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  31.   *
  32.   * @version pk-06-08-09
  33.   * @version pk-06-10-05 nullToZero added
  34.   * @version pk-07-08-31
  35.   *
  36.   * @version $Id: DBMS_FIELD_FOREIGNKEY.phpclass,v 1.18 2008/12/03 21:32:40 pitlinz Exp $
  37.   */
  38. {
  39.     // ---------------------------------------------------------------------------
  40.     // constants
  41.     // ---------------------------------------------------------------------------
  42.     
  43.     /**
  44.      * @constant string CLASS_SRC_FILE
  45.      */
  46.     const CLASS_SRC_FILE = __FILE__;
  47.  
  48.     // ---------------------------------------------------------------------------
  49.     // class (static)
  50.     // ---------------------------------------------------------------------------
  51.     
  52.     /*** class vars ------------------------------------------------------ */
  53.  
  54.     /*** class methods --------------------------------------------------- */    
  55.     
  56.     // ---------------------------------------------------------------------------
  57.     // object vars
  58.     // ---------------------------------------------------------------------------
  59.     
  60.     /*** compostion --------------------------------------------------- */
  61.     
  62.     /*** attributes --------------------------------------------------- */
  63.         
  64.     /**
  65.       * source file of the class
  66.       *
  67.       * @var string $classSrcFile 
  68.       * @since pk-05-01-20
  69.       */
  70.     protected $classSrcFile=__FILE__;
  71.  
  72.     /**
  73.       * @var boolean $checkWhereAnd 
  74.       * @since pk-05-09-30
  75.       ***/
  76.     protected $checkWhereAnd      =FALSE;
  77.  
  78.     /**
  79.      * url to popup for a new entry
  80.      *
  81.      * @var string $newUrl 
  82.      */
  83.     protected $newUrl             = "";
  84.     
  85.     /**
  86.      * @var int $newFormId 
  87.      * @since pk-08-02-21
  88.      */
  89.     protected $newFormId=0;
  90.     
  91.     /**
  92.      * edit or insert data with ajax or open an popup
  93.      *
  94.      * @var boolean 
  95.      */
  96.     protected $newEditAsAjax    = TRUE;
  97.     
  98.     /**
  99.      * width of the popup window
  100.      *
  101.      * @var int $popupWndWidth 
  102.      */
  103.     protected $popupWndWidth        = "600";
  104.     
  105.     /**
  106.      * hight of the popup window
  107.      *
  108.      * @var int popupWndHeight
  109.      */
  110.     protected $popupWndHeight       = "400";
  111.  
  112.     /**
  113.       * @var string $editUrl url to the field editor
  114.       * @version pk-03-10-17
  115.       * @todo add tags to input field link new
  116.       * @access protected
  117.       ***/
  118.     protected $editUrl             = "";
  119.     
  120.     /**
  121.      * @var int $editFormId 
  122.      * @since pk-08-02-21
  123.      */
  124.     protected $editFormId=0;    
  125.  
  126.     /**
  127.       * @var int $editEnableInList link List field with edit url
  128.       * @version pk-03-10-17
  129.       * @access protected
  130.       ***/
  131.     protected $editEnableInList   = TRUE;
  132.  
  133.     /**
  134.       * @var string $myURIQueryArrgs   semicolon seperated list of url arguments
  135.       * @since pk-04-09-07
  136.       * @access protected
  137.       ***/
  138.     protected $myURIQueryArrgs    = "";
  139.     
  140.     /**
  141.      * css class of the detail layer div
  142.      * 
  143.      * @var string $myLayerDivClass 
  144.      * 
  145.      * @since pk-08-02-27
  146.      */
  147.     protected $myLayerDivClass      = "";
  148.     
  149.     /**
  150.      * css style of the detail layer div
  151.      * 
  152.      * @var string $myLayerDivStyle 
  153.      * 
  154.      * @since pk-08-02-27
  155.      */
  156.     protected $myLayerDivStyle      = "";
  157.     
  158.     // ---------------------------------------------------------------------------
  159.     // factory / construct
  160.     // ---------------------------------------------------------------------------
  161.  
  162.     // ---------------------------------------------------------------------------
  163.     // init
  164.     // ---------------------------------------------------------------------------
  165.         
  166.     /**
  167.       * convert old object vars to DBMS_FIELD_DBLOOKUPSELECTLIST
  168.       * and then calls the parent method
  169.       *
  170.       * @param array $varArr 
  171.       * @param boolean $debug 
  172.       *
  173.       */
  174.     function setObjectVars($varArr,$debug=FALSE{
  175.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_FOREIGNKEY::setObjectVars(...)",print_r($varArr,TRUE));
  176.  
  177.         foreach($varArr as $str_name => $m_val)
  178.         {
  179.             if (!empty($m_val))
  180.             {
  181.                 switch($str_name)
  182.                 {
  183.                     case "foreignTbl":
  184.                         if (!empty($varArr['lookupTable'])) $varArr['lookupTable']=$m_val;
  185.                         unset($varArr['foreignTbl']);
  186.                         break;
  187.                     case "showField":
  188.                         if (!empty($varArr['lookupShowField'])) $varArr['lookupShowField']=$m_val;
  189.                         unset($varArr['foreignTbl']);
  190.                         break;
  191.                     case "lst_showFld":
  192.                         if (!empty($varArr['lookupShowLstField'])) $varArr['lookupShowLstField']=$m_val;
  193.                         unset($varArr['lst_showFld']);
  194.                         break;
  195.                     case "keyField":
  196.                         if (!empty($varArr['lookupField'])) $varArr['lookupField']=$m_val;
  197.                         unset($varArr['keyField']);
  198.                         break;
  199.                     case "whereAnd":
  200.                         if (!empty($varArr['lookupWhere'])) $varArr['lookupWhere']=$m_val;
  201.                         unset($varArr['whereAnd']);
  202.                         break;
  203.                     case "sortField":
  204.                         if (!empty($varArr['lookupSort'])) $varArr['lookupSort']=$m_val;
  205.                         unset($varArr['whereAnd']);
  206.                         break;
  207.                     case "allowNullSelect":
  208.                         $varArr['showNullOption']=$m_val;
  209.                         unset($varArr['allowNullSelect']);
  210.                         break;
  211.                 }
  212.             }
  213.         }
  214.         parent::setObjectVars($varArr,$debug);
  215.     }
  216.  
  217.     // ---------------------------------------------------------------------------
  218.     // dbms admin backoffice 
  219.     // ---------------------------------------------------------------------------    
  220.     
  221.     /**
  222.       * returns an array of field to bie shown in the edit form
  223.       * by using editTbl_echoForm
  224.       *
  225.       * the array is in the form:
  226.       *
  227.       * <code>
  228.       * [_sectionName_]
  229.       *      [TITLE] -> string
  230.       *      [_rowName_]
  231.       *         [FLDLAB]  (complete html code with <td></td>)
  232.       *         [FLDVAL] (complete html code with <td></td>)
  233.       * </code>
  234.       *
  235.       * @param boolean $debug 
  236.       *
  237.       * @returns array
  238.       *
  239.       * @since pk-06-04-26
  240.       * @version pk-06-04-29
  241.       *
  242.       */
  243.     function editTbl_getFieldEditArr($debug=FALSE{
  244.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_FOREIGNKEY::editTbl_getFieldEditArr","",0);
  245.  
  246.         if (empty($this->keyField)) $this->keyField=$this->myName// <pk-06-11-29 />
  247.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  248.  
  249.         $a_ret['LAYOUT']['FLD_SIZE']=NULL;      // unset parent field
  250.         $a_ret['LAYOUT']['FLD_INPUTADD']=NULL;  // unset parent field
  251.  
  252.         $a_ret['SELECT']['FLD_MULTISEL']=NULL;  // unset parent field
  253.  
  254.         //$a_ret['DBLOOKUP']['FLD_LSTADDVALUES']['FLDVAL']="<input name=\"allowAddValues\" type=\"checkbox\"".($this->allowAddValues ? " checked=\"checked\"" : "")." value=\"1\" />ja";
  255.         unset($a_ret['DBLOOKUP']['FLD_LSTADDVALUES'])// unset parent field
  256.         
  257.         $a_ret['DBLOOKUP']['FLD_WHEREFLD']['FLDVAL'].="<input name=\"checkWhereAnd\" type=\"checkbox\"".($this->checkWhereAnd ? " checked=\"checked\"" "")." value=\"1\" /> beim speichern &uuml;berpr&uuml;fen.";
  258.  
  259.         // <pk-06-05-19> compat
  260.         if (!intval($this->popupWndWidth)) {
  261.             $this->popupWndWidth=max($this->newWndWidth,$this->editWndWidth);
  262.         }
  263.         if (!intval($this->popupWndHeight)) {
  264.             $this->popupWndHeight=max($this->newWndHeight,$this->editWndHeight);
  265.         }
  266.         // </pk-06-05-19>
  267.  
  268.         /*
  269.         $a_ret['FTBL_POPUPS']=array(
  270.             'TITLE'=>"Bearbeiten/Hinzuf&uuml;gen",
  271.             'FLD_NEWPUP'=>array(
  272.                 'FLDLAB'=>"Neuer Datensatz",            
  273.                 'FLDVAL'=>"
  274.                     <input name=\"allowAddValues\" type=\"checkbox\" value=\"1\" " . ($this->allowAddValues ? "checked=\"checked\"" : "") . " /> hinzuf&uuml;gen von Daten erlauben<br /> 
  275.                     URL: <input name=\"newUrl\" value=\"" . $this->newUrl . "\" size=\"50\" /><br />
  276.                     Form: <select name=\"newFormId\" id=\"" . str_replace(".","_",$this->getKey()) . "_newForm\" >
  277.                         <option value=\"\">[Formular w&auml;hlen]</option>
  278.                         " . OCSP_FORM::findForm_getHTMLOptionList($this->lookupTable,$this->newFormId,$debug) ."
  279.                     </select>"
  280.             ),
  281.  
  282.             'FLD_EDITPUP'=>array(
  283.                 'FLDLAB'=>"Datensatz bearbeiten URL",
  284.                 'FLDVAL'=>"
  285.                     <input name=\"allowEditValues\" type=\"checkbox\" value=\"1\" " . ($this->allowEditValues ? "checked=\"checked\"" : "") . " /> bearbeiten von Details erm&ouml;glichen<br />
  286.                     URL: <input name=\"editUrl\" value=\"".$this->editUrl."\" size=\"50\" /><br />
  287.                     Form: <select name=\"editFormId\" id=\"" . str_replace(".","_",$this->getKey()) . "_editForm\" >
  288.                         <option value=\"\">[Formular w&auml;hlen]</option>
  289.                         " . OCSP_FORM::findForm_getHTMLOptionList($this->lookupTable,$this->editFormId,$debug) ."
  290.                     </select>"                                    
  291.             ),
  292.             'FLD_POPUPSIZE'=>array(
  293.                 'FLDLAB'=>"Popup",
  294.                 'FLDVAL'=>"
  295.                             <input type=\"checkbox\" name=\"newEditAsAjax\" value=\"1\" " . ($this->newEditAsAjax ? "" : "checked=\"checked\" ") . " /> als Popup Ã¶ffnen <hr />
  296.                             Gr&ouml;&szlig;e: 
  297.                             width=<input  name=\"popupWndWidth\" value=\"".$this->popupWndWidth."\"  size=\"4\" />&nbsp;
  298.                             height=<input name=\"popupWndHeight\"  value=\"".$this->popupWndHeight."\"  size=\"4\" />&nbsp; <hr />
  299.                             Popup Arguments: <input name=\"myURIQueryArrgs\" value=\"" .$this->myURIQueryArrgs ."\" size=\"40\" /><br />(durch Semicolon \";\" getrennte Feldnamen)  
  300.                           "
  301.             ),            
  302.             'FLD_LAYERPROPS'=>array(
  303.                 'FLDLAB'=>"Layer div class",
  304.                 'FLDVAL'=>"&lt;div class=\"<input name=\"myLayerDivClass\" value=\"" . $this->myLayerDivClass . "\" size=\"15\" />\" 
  305.                             style=\"<input name=\"myLayerDivStyle\" value=\"" . $this->myLayerDivStyle . "\" />\" &gt;"
  306.             )
  307.  
  308.         );
  309.         */
  310.         return $a_ret;
  311.     }
  312.  
  313.     /**
  314.      * update editTbl_getFieldEditArr fields after change of the table
  315.      *
  316.      * @param array $options 
  317.      * 
  318.      * @return string (js)
  319.      * 
  320.      * @since pk-08-02-10
  321.      */
  322.     public function editTbl_tableChanged($options)
  323.     {
  324.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_FOREIGNKEY::editTbl_tableChanged()");
  325.            
  326.         if ($arr_forms OCSP_FORM::findForm_listForTable($options['table']))
  327.         {
  328.             $str_options "var i=1;\n"// one to not overwrite the empty option
  329.             foreach($arr_forms as $arr_row)
  330.             {
  331.                 $str_options .= "obj_opt = new Option('" $arr_row['FRM_NAME'" (ID: " $arr_row['FRM_ID'")','" $arr_row['FRM_ID'"');";
  332.                 $str_options .= "obj_opt.title = '" pcf_makeJS_QuotedString($arr_row['FRM_DESC'],"'""';";
  333.                 $str_options .= "obj_sel.options[i++] = obj_opt;\n";             
  334.             }
  335.         else {
  336.             $str_options "var i=1;";
  337.         }
  338.         
  339.         $str_ret "
  340.             if (obj_sel = document.getElementById('" str_replace(".","_",$this->getKey()) "_newForm'))
  341.             {
  342.                 obj_sel.selectedIndex = 0;
  343.                 obj_sel.options.length = 1;
  344.                 " $str_options "
  345.             } else {
  346.                 alert('" str_replace(".","_",$this->getKey()) "_newForm not found');
  347.             }
  348.             if (obj_sel = document.getElementById('" str_replace(".","_",$this->getKey()) "_editForm'))
  349.             {
  350.                 obj_sel.selectedIndex = 0;
  351.                 obj_sel.options.length = 1;
  352.                 " $str_options "
  353.             } else {
  354.                 alert('" str_replace(".","_",$this->getKey()) "_editForm not found');
  355.             }           
  356.         ";
  357.         
  358.         $str_ret "try {" $str_ret "} catch(e) { alert(e); }";
  359.         return $str_ret;
  360.     }
  361.     
  362.     /**
  363.       * save the filed definition form
  364.       *
  365.       * @returns bool <code>parent::save()</code>
  366.       * @version pk-03-10-17
  367.       * @version pk-06-01-24
  368.       * @version pk-08-02-27
  369.       *
  370.       ***/
  371.     function save($debug=FALSE{
  372.         $ret=parent::save($debug);
  373.  
  374.          if (isset($this->foreignTbl))          unset($this->foreignTbl);
  375.          if (isset($this->showField))           unset($this->showField);
  376.          if (isset($this->lst_showFld))         unset($this->lst_showFld);
  377.          if (isset($this->keyField))               unset($this->keyField);
  378.          if (isset($this->sortField))               unset($this->sortField);
  379.          if (isset($this->allowNullSelect))     unset($this->allowNullSelect);
  380.         
  381.         $this->multiselect          = FALSE;
  382.  
  383.         $this->popupWndWidth        = ((isset($_POST['popupWndWidth']&& (intval($_POST['popupWndWidth']10)) intval($_POST['popupWndWidth']600);
  384.         $this->popupWndHeight       = ((isset($_POST['popupWndHeight']&& (intval($_POST['popupWndHeight']10)) intval($_POST['popupWndHeight']380);
  385.         $this->newEditAsAjax        = ((isset($_POST['newEditAsAjax']&& intval($_POST['newEditAsAjax'])) FALSE TRUE);
  386.         
  387.         $this->newUrl               = (isset($_POST['newUrl']$_POST['newUrl'$this->newUrl);
  388.         $this->newFormId            = (isset($_POST['newFormId']intval($_POST['newFormId']0);
  389.         
  390.         $this->editUrl              = (isset($_POST['editUrl']$_POST['editUrl'$this->editUrl);
  391.         $this->editFormId            = (isset($_POST['editFormId']intval($_POST['editFormId']0);
  392.         
  393.         if ($this->editEnableInList)
  394.         {
  395.             $this->lstDisableLinks=TRUE;
  396.         else {
  397.             $this->lstDisableLinks=FALSE;
  398.         }
  399.         // </pk-03-10-17>
  400.  
  401.         // <pk-04-07-29 />
  402.         $this->myURIQueryArrgs      =(isset($_POST['myURIQueryArrgs']$_POST['myURIQueryArrgs'$this->myURIQueryArrgs);
  403.         // <pk-08-02-27 />
  404.         $this->myLayerDivClass        =(isset($_POST['myLayerDivClass'])  $_POST['myLayerDivClass']  "");
  405.         $this->myLayerDivStyle        =(isset($_POST['myLayerDivStyle'])  $_POST['myLayerDivStyle']  "");
  406.  
  407.         return $ret;
  408.     }
  409.  
  410.     // ---------------------------------------------------------------------------
  411.     // buttons 
  412.     // ---------------------------------------------------------------------------    
  413.         
  414.     /**
  415.       * returns the html code for the new button
  416.       *
  417.       * @param string $arrName 
  418.       * @param boolean $debug 
  419.       * 
  420.       * @global array $OCSP_CONF 
  421.       *
  422.       * @returns string
  423.       *
  424.       * @since pk-08-02-22
  425.       */
  426.     function getNewBtn($arrName="DBVAL",$debug=FALSE
  427.     {    
  428.         global $OCSP_CONF;
  429.         
  430.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBLOOKUPSELECTLIST::getNewBtn","arrName$arrName",0);
  431.               
  432.         if ($debug)
  433.         {            
  434.             $str_onClick "try {
  435.                 alert('add new Detail: " $this->myName . "');";
  436.         else {
  437.             $str_onClick "";
  438.         }
  439.         
  440.         $str_onClick .= "
  441.                 if (obj_form = jOCSP.getFormByHash('" $this->myControll->jOCSP_getfrmHash("'))
  442.                 {
  443.                     if (obj_fld = obj_form.getFieldByDomId('" $this->getDOMId("'))
  444.                     {
  445.                         obj_fld.addDetail();
  446.                     }
  447.                 }
  448.             ";
  449.         
  450.         
  451.         if ($debug)
  452.         {
  453.             $str_onClick .= "} catch(e) {alert('Field: " $this->myName . ": ' + e);}"
  454.         }
  455.                 
  456.         return "<a onclick=\"" pcf_js_escapeOnEventCmd($str_onClick"\"><img src=\"" $OCSP_CONF['SYSIMGURL'"icons-16x16/filenew.gif\" border=\"0\" alt=\"neuer Eintrag\" align=\"middle\" class=\"button\" /></a>";
  457.     }
  458.     
  459.  
  460.     /**
  461.       * returns the html code for a button to zoom to the foreign record
  462.       *
  463.       * @param string $arrName 
  464.       * @param boolean $debug (pk-05-10-23)
  465.       *
  466.       * @returns string
  467.       *
  468.       * @version pk-05-02-22 parse url as template using ${$arrName} as value array
  469.       * @version pk-05-03-17 getPopupLinkJs added -> rewrite
  470.       * @version pk-05-10-04
  471.       * @version pk-05-10-23 param $debug added
  472.       * @version pk-06-01-03
  473.       *
  474.       ***/
  475.     function getZoomBtn($debug=FALSE
  476.     {
  477.         global $OCSP_CONF;
  478.         
  479.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBLOOKUPSELECTLIST::getZoomButton","arrName$arrName",0);
  480.  
  481.         
  482.            if (!empty($this->editUrl|| intval($this->editFormId))
  483.            {        
  484.             if ($debug)
  485.             {            
  486.                 $str_onClick "try {
  487.                     alert('edit Detail: " $this->myName . "');";
  488.             else {
  489.                 $str_onClick "";
  490.             }
  491.             
  492.             $str_onClick .= "
  493.                     if (obj_form = jOCSP.getFormByHash('" $this->myControll->jOCSP_getfrmHash("'))
  494.                     {
  495.                         if (obj_fld = obj_form.getFieldByDomId('" $this->getDOMId("'))
  496.                         {
  497.                             obj_fld." ($this->allowEditValues ? "editDetail" "showDetail"."();
  498.                         }
  499.                     }
  500.                 ";
  501.             
  502.             
  503.             if ($debug)
  504.             {
  505.                 $str_onClick .= "} catch(e) {alert('Field: " $this->myName . ": ' + e);}"
  506.             }
  507.                     
  508.             return "<a onclick=\"" pcf_js_escapeOnEventCmd($str_onClick"\"><img src=\"" $OCSP_CONF['SYSIMGURL'"icons-16x16/" ($this->allowEditValues ? "edit.gif" "viewmag.gif""\" border=\"0\" alt=\"Details\" align=\"middle\" class=\"button\" /></a>";
  509.            else {
  510.                return "";
  511.            }
  512.     }
  513.  
  514.     // -------------------------------------------------
  515.     // OBJECT VALUE CHECK/RETURN METHODS
  516.     // -------------------------------------------------
  517.     
  518.     /**
  519.       * returns the field value if the referenzed row exists
  520.       *
  521.       * @param  string  $aValue     the value
  522.       * @param  array   $err        error array
  523.       * @param  string  $arrName    name of the array to access fieldsarray  gloabl ${$arrName}
  524.       * @param  bool    $debug 
  525.       *
  526.       * @returns string
  527.       *
  528.       * @since   pk-03-12-13
  529.       * @version pk-03-12-13
  530.       * @version pk-04-12-31 $this->label added to NULL ERROR MSG
  531.       * @version pk-05-06-16 debug due to fieldsettings
  532.       * @version pk-07-09-10 null handling
  533.       *
  534.       ***/
  535.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=False{       
  536.         global ${$arrName};
  537.         $debug ($debug || $this->fldDebug || $this->fldDbgGetValue)// <pk-05-06-16 />
  538.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_FOREIGNKEY::getValue(".$aValue.") | ".$this->getKey());
  539.  
  540.         $aValue=trim($aValue);
  541.         if (empty($aValue)) {
  542.             
  543.             if (!$this->isToShow($this->myForm->getFrmMode(),${$arrName},$debug))
  544.             {
  545.                 return Null;
  546.             }
  547.             
  548.             if ($debugechoDebugLine(__FILE__,__LINE__,"NullSelect: ".($this->showNullOption ? "true" "false")." nullToZero: ".($this->nullToZero ? "true" "false")." allowNull: ".($this->allowNull ? "true" "false"));
  549.             if ($this->showNullOption && $this->nullToZero)
  550.             {
  551.                 if ($debugechoDebugLine(__FILE__,__LINE__,"Returning 0");
  552.                 return 0;
  553.             else if ($this->showNullOption && $this->allowNull{
  554.                 if ($debugechoDebugLine(__FILE__,__LINE__,"Returning $aValue");
  555.                 return $aValue;
  556.             else {
  557.                 $err['ERROR']=TRUE;
  558.                 $err[$this->myName]['MSG']=(empty($this->nullErrMsg$this->myForm->getLangTxt("NULL_NOT_ALLOWED"$this->nullErrMsg);
  559.                 $err[$this->myName]['LABEL']=$this->label;
  560.  
  561.                 if ($debugechoDebugLine(__FILE__,__LINE__,"Returning ERROR <pre>".print_r($err,TRUE)." with value$aValue");
  562.                 return $aValue;
  563.             }
  564.         }
  565.  
  566.         
  567.         $arr_parentError=array();
  568.         $aValue=parent::getValue($aValue,$arr_parentError,$arrName,$debug);
  569.  
  570.         if (!isset($arr_parentError['ERROR']|| !$arr_parentError['ERROR'])
  571.         {
  572.             if ($this->checkWhereAnd)
  573.             {
  574.                 if (!($obj_myDB=$this->myForm->getDBObj()))
  575.                 if ($obj_myDB->getRow($this->lookupTable,array($this->lookupField => $aValue)))
  576.                 {
  577.                     return $aValue;
  578.                 else {
  579.                     $err['ERROR']=True;
  580.                     $err[$this->myName]['MSG']="ROW_NOT_FOUND";
  581.                     $err[$this->myName]['LABEL']=$this->label;
  582.                     return $aValue;
  583.                 }
  584.             }
  585.         }
  586.         return $aValue;
  587.     }
  588.     
  589.     // -------------------------------------------------
  590.     // jOCSP rpc commands
  591.     // -------------------------------------------------
  592.  
  593.     /**
  594.      * creates an layer for the detail record
  595.      *
  596.      * @param int $mode 
  597.      * @param array $options 
  598.      * @param boolean $debug 
  599.      * 
  600.      * @return string (js)
  601.      */
  602.     public function jOCSP_detailFormLayer($mode,&$options,$debug=FALSE)
  603.     {
  604.         if ($debug
  605.         {
  606.             $str_ret "alert('jOCSP_detailFormLayer: " pcf_js_escape(print_r($options,TRUE)) "');";
  607.         else {
  608.             $str_ret "";
  609.         }
  610.  
  611.         $obj_ajax $this->myForm->ajax_getObj(TRUE);
  612.         
  613.         if (intval($this->newFormId))
  614.         {
  615.             $obj_form OCSP_FORM::factory_from_id($this->newFormId);
  616.             $obj_form->ajax_setObj($options['AJAXOBJ']);
  617.             $obj_form->setFrmMode($mode);
  618.             
  619.             $obj_controll $obj_form->getControllObj('OCSP_FRMCONTR_JQUERY');
  620.             $obj_controll->setBackCmd("document.getElementById('" $options['domId'"').closeDetail();");
  621.             
  622.             if ($mode == FRM_MODE_NEW)
  623.             {
  624.                 if (isset($options['FRMARRAYNAME']))
  625.                 {
  626.                     $obj_controll->setValuesFromArray($options[$options['FRMARRAYNAME']]);
  627.                 }
  628.             else {
  629.                 if (isset($optons['foreignKey']&& (!empty($optons['foreignKey'])))
  630.                 {
  631.                     $arr_errors array();
  632.                     if ($mix_lookupValue $this->getValue($optons['foreignKey'],$arr_errors))
  633.                     {
  634.                         $obj_controll->addFilter($this->lookupField,$mix_lookupValue);
  635.                     }        
  636.                 else if (isset($options['FRMARRAYNAME']&& is_array($options[$options['FRMARRAYNAME']])) {
  637.                     if ($mix_lookupValue $this->getValue($options[$options['FRMARRAYNAME']][$this->getName()],$arr_errors))
  638.                     {
  639.                         $obj_controll->addFilter($this->lookupField,$mix_lookupValue);
  640.                     }                            
  641.                 }                 
  642.             }
  643.             
  644.             $obj_controll->setNextUrl("js:document.getElementById('" $options['domId'"').closeDetail('\$*" $this->lookupField . "\$');");
  645.             
  646.             $obj_view $obj_form->getViewObj('OCSP_FRMVIEW_FORM');
  647.                         
  648.             $str_frmContent $obj_view->getForm($mode);  
  649.             
  650.             
  651.         }
  652.          
  653.         $str_ret .=
  654.              if (obj_fld = document.getElementById('" $options['domId'"'))
  655.              {
  656.                  obj_fld.closeDetail = function(aValue)
  657.                  {                     
  658.                      this.det_shadow.parentNode.removeChild(this.det_shadow);
  659.                      this.detLayer.parentNode.removeChild(this.detLayer);
  660.                      
  661.                      if (aValue) 
  662.                      {
  663.                          try {
  664.                              this.jOCSPFldObj.addOption(aValue,aValue,false,true);
  665.                              this.jOCSPFldObj.reloadOptionLst(aValue);                             
  666.                          } catch(e) {
  667.                              alert(e);
  668.                          }
  669.                      }                     
  670.                  }
  671.                  
  672.                  alert('Field: ' + typeof(obj_fld) + 'Cur Value: ' + obj_fld.value);
  673.                  
  674.                  try {                  
  675.                      dom_form = obj_fld.form;                                 
  676.                     obj_form = jOCSP.getFormByHash(dom_form.jOCSP_frmHash);
  677.                     
  678.                     
  679.                     obj_fld.det_shadow = obj_form.disableWithShadow();
  680.                     
  681.                     obj_fld.detLayer = jOCSP.dom.formLayerCreate(obj_form.getDomObj().parentNode.id);
  682.             ";
  683.         if ($this->myLayerDivClass)
  684.         {
  685.             $str_ret .= "obj_fld.detLayer.className='" $this->myLayerDivClass . "'";
  686.         }
  687.         $str_ret .= "
  688.                     obj_fld.detLayer.innerHTML = '"pcf_js_escape($str_frmContent)"';
  689.                                                             
  690.                 } catch(e) {
  691.                     alert(e);
  692.                 }
  693.              } else {
  694.                  " jOCSP_registerError("DBMS_FIELD_FOREIGNKEY::jOCSP_detailFormLayer() field id: " $options['domId'." not found",FALSE,print_r($_REQUEST,TRUE)) ."
  695.              }
  696.          ";
  697.          return $str_ret;
  698.     }
  699.     
  700.     
  701.     /**
  702.      * shows the form or url to add a new record in the foreign table
  703.      *
  704.      * @param array $options 
  705.      * @param boolean $debug 
  706.      * 
  707.      * @return string (javascript)
  708.      */
  709.     public function jOCSP_addDetail($options,$debug=FALSE)
  710.     {
  711.         if ($this->allowAddValues)
  712.         {
  713.             if ($this->newEditAsAjax)
  714.             {
  715.                 return $this->jOCSP_detailFormLayer(FRM_MODE_NEW,$options,$debug);
  716.             }
  717.         }
  718.     }
  719.    
  720.  
  721.     /**
  722.      * shows the form or url to edit a record in the foreign table
  723.      *
  724.      * @param array $options 
  725.      * @param boolean $debug 
  726.      * 
  727.      * @return string (javascript)
  728.      */
  729.     public function jOCSP_editDetail($options,$debug=FALSE)
  730.     {
  731.         if ($this->allowEditValues)
  732.         {
  733.             if ($this->newEditAsAjax)
  734.             {
  735.                 return $this->jOCSP_detailFormLayer(FRM_MODE_EDIT,$options,$debug);
  736.             }
  737.         }
  738.     }    
  739.     
  740.     
  741.     /**
  742.      * shows the form or url to edit a record in the foreign table
  743.      *
  744.      * @param array $options 
  745.      * @param boolean $debug 
  746.      * 
  747.      * @return string (javascript)
  748.      */
  749.     public function jOCSP_showDetail($options,$debug=FALSE)
  750.     {
  751.         if ($this->allowEditValues)
  752.         {
  753.             if ($this->newEditAsAjax)
  754.             {
  755.                 return $this->jOCSP_detailFormLayer(FRM_MODE_READONLY,$options,$debug);
  756.             }
  757.         }
  758.     }     
  759. }
  760. ?>

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