Location: PHPKode > projects > MembersGear > membersgear/includes/fields_class.php
<?php
 
 require_once "peardb_class.php";
    
 class fields_class extends peardb_class
 {   
    function View($pQuery, $pValues=false, $types=true, $pStart=0, $pEnd=0)
    {
        /*
        global $mdb2;    
        $result;  
 
        $query      = 'SELECT * FROM tbluser1 t limit 10;';
        $resultset  = $mdb2->query($query);
        
        if(PEAR::isError($resultset)) 
        {
            die("Failed to issue query, error message : " . $resultset->getMessage());
        }
        
        while($row = $resultset->fetchRow(MDB2_FETCHMODE_ASSOC))
        {
            $result[] = $row;
        }
                                                                                                                 
        return  $result;   
        */
        //print_r($pParameters);
        
        return $this->BaseView($pQuery,$pValues,$types,$pStart,$pEnd);
        
    }
    
    function Update($pQuery, $pValues=false, $types=true)
    { 
       
        return $this->BaseUpdate($pQuery, $pValues, $types);
    
    }
    
    function Delete($pQuery, $pValues=false, $types=true)
    { 
       
        return $this->BaseUpdate($pQuery, $pValues, $types);
    
    }

    
    function Insert($pQuery, $pValues=false, $types=true)
    { 
    
        return $this->BaseInsert($pQuery, $pValues, $types);
    
    }
    
    function UpdateSortOrder($pQuery, $pValues=false, $types=true)
    {
        return $this->BaseUpdate($pQuery, $pValues, $types); 
    }
    
    function  setFieldOrder($pValues, $pValuesID)
    {
           $liValueSize = sizeof($pValues);
           for($i=0;$i < $liValueSize ;$i++)
           {
               $query = 'UPDATE '.TABLE_PREFIX.'singupformfields SET sortorder=? WHERE id=?'; 
               
               $lsValues[0] = $pValues[$i];
               $lsValues[1] = $pValuesID[$i];
               
               fields_class::UpdateSortOrder($query,$lsValues,null);
               unset($query);
               unset($lsValues);
           }
    }
    function renderDynamiControl($pControlId,$pVisiblityOn,$pEditModevalue='',$pProductId='')
    {
        
            $result='';
            $lsdisableclt='';
            $query="SELECT * FROM ".TABLE_PREFIX ."singupformfields where id=?";
            $lsValues[0] =$pControlId;
            $lafeildresult = $this->View($query,$lsValues,null);

            if(is_array($lafeildresult))
            {
                if(sizeof($lafeildresult)>0)
                {
                    if($pVisiblityOn == 'signup' && $lafeildresult[0]['signupformvisibility']==0)
                    {
                        return '';
                    }
                    if($pVisiblityOn =='profile' && $lafeildresult[0]['profileformvisibility']==0)
                    {
                        
                        return '';   
                    }
                    if($pEditModevalue!='')
                    {
                        $lsvalue=$this->getformdata('profile',$pControlId,$_SESSION[SESSION_PREFIX.'UserID'],$pProductId);
                        if($lsvalue=='')
                        {
                           
                            if($lafeildresult[0]['displaytype']=='checkbox(checked)' or $lafeildresult[0]['displaytype']=='checkbox(unchecked)')
                           {
                                 $lsvalueeditchkunchk='';  
                           }
                           $lsvalue= $lafeildresult[0]['defaultvalue']; 
                           
                        }
                        /* disable for   Edit Profile  control*/
                        if($pVisiblityOn=='profile' and $lafeildresult[0]['profileformvisibility']==2)
                        {
                            $lsdisableclt='disabled'; 
                        }   
                      
                    }
                    else
                    {
                         $lsvalue=$lafeildresult[0]['defaultvalue']!=''?$lafeildresult[0]['defaultvalue']:'';   
                        
                    }    
                    
                    $lsdescription=$lafeildresult[0]['description']!=''?$lafeildresult[0]['description']:'';   
                    switch($lafeildresult[0]['displaytype'])
                    {
                        case 'text':
                              
                               $result="<input $lsdisableclt style=\"width:200px;\" name=\"".$lafeildresult[0]['name']."\"  class=\"txtcss\"  id=\"".$lafeildresult[0]['name']."\" type=\"text\" value=\"$lsvalue\" ".$lafeildresult[0]['property'].">"; 
                               //$result.="<div class=\"FieldLabelNote\">$lsdescription</div>";
                               break;
                        case 'textarea':
                              $result="<textarea  $lsdisableclt class=\"txtareacss\" name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\"  ".$lafeildresult[0]['property']." style=\"\">$lsvalue</textarea>"; 
                              //$result.="<div class=\"FieldLabelNote\">$lsdescription</div>";
                               break; 
                               
                        case 'select':
                        case 'multi_select':
                              $lsSelectProperty = explode('size=',$lafeildresult[0]['property']);
                              $lsmutiple=$lafeildresult[0]['displaytype']=='multi_select'?'multiple':'';
                              $lamutiple=$lafeildresult[0]['displaytype']=='multi_select'?'[]':'';  
                              $laselect=explode("\r\n",$lsSelectProperty[0]);
                              if($lsvalue!='' and  $pEditModevalue!='')
                              {
                                       $laselectedit=explode(",",$lsvalue);
                              }
                              $result="<select $lsdisableclt style=\"width: 208px;\"  class=\"selectcss\" name=\"".$lafeildresult[0]['name']."$lamutiple\" id=\"".$lafeildresult[0]['name']."\" ".$lsmutiple.">";
                              if($lafeildresult[0]['displaytype']=='select')
                                $result.="<option value=' '>select..</option>"; 
                              
                              foreach($laselect as $key=>$value)
                              {
                                  $laselectelement=explode("|",$value);
                              
                                  foreach($laselectelement as $key1=>$value1) 
                                  {
                                     switch($key1)
                                     {
                                       case "0":
                                        $lsselectvalue=trim($value1);
                                       break;
                                       case "1":
                                        $lsselectname=trim($value1);
                                       case "2":
                                        $lsselected=trim($value1);
                                       
                                     
                                     }   
                                  }
                                   if($lsvalue!='' and  $pEditModevalue!='')
                                        {
                                                foreach($laselectedit as $key2=>$value2)
                                                {
                                                    if($value2==$lsselectvalue)
                                                    { //  echo $value2."==>".$lsselectvalue;
                                                        $lsoptionselect='selected';
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        $lsoptionselect=''; 
                                                    }
                                                }    
                                        }
                                        else
                                        {
                                            $lsoptionselect=$lsselected=='1'?'selected':'';   
                                        }      
                                
                                  $result.="<option value=\"$lsselectvalue\" ".$lsoptionselect.">".$lsselectname."</option>";    
                                      
                              }
                              $result.="</select>"; 
                              //$result.="<div  class=\"FieldLabelNote\">$lsdescription</div>";
                              break;   
                     case 'radio':     
                              $lsradioProperty = explode('size=',$lafeildresult[0]['property']);
                              
                              $laradio=explode("\r\n",$lsradioProperty[0]);
                              
                              
                              foreach($laradio as $key=>$value)
                              {
                                  $laradioelement=explode("|",$value);
                              
                                  foreach($laradioelement as $key1=>$value1) 
                                  {
                                     switch($key1)
                                     {
                                       case "0":
                                        $lsradiovalue=trim($value1);
                                       break;
                                       case "1":
                                        $lsradiotname=trim($value1);
                                       case "2":
                                        $lsradioselected=trim($value1); 
                                     
                                     }   
                                  }
                                   if($lsvalue!='' and  $pEditModevalue!='')
                                  {
                                                if($lsvalue==trim($lsradiovalue))
                                                {
                                                        $lsoptionselect='checked';
                                                        
                                                }
                                                 else
                                                 {
                                                        $lsoptionselect=''; 
                                                 }
                                              
                                  }
                                  else
                                  {
                                    $lsoptionselect=trim($lsradioselected)=='1'?'checked':''; 
                                  }
                                   
                                 // $result.="<option value=\"$lsradiovalue\" ".$lsoptionselect.">".$lsselectname."</option>";    
                                   $result.="<input  $lsdisableclt class=\"chkcss\" type=\"radio\" name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\"  value=\"".$lsradiovalue."\" ".$lsoptionselect.">".$lsradiotname."<br/>";        
                              }
                              
                              //$result.="<div  class=\"FieldLabelNote\">$lsdescription</div>";
                              break;     
                     case 'checkbox(checked)':
                     case 'checkbox(unchecked)':
                           $lscheckboxcheckuncheckproperty= $lafeildresult[0]['displaytype'];
                           $lscheckuncheckproperty ='';
                           if($lscheckboxcheckuncheckproperty=='checkbox(checked)')
                           {
                               $lscheckuncheckproperty='checked';    
                           }
                           else if($lscheckboxcheckuncheckproperty=='checkbox(unhecked)')
                           {
                           
                               $lscheckuncheckproperty='';
                           }   
                           if($pEditModevalue!='')
                           {
                               if(isset($lsvalueeditchkunchk))
                               {
                                    $lscheckuncheckproperty='';
                               }
                               else
                               {
                                    $lscheckuncheckproperty='checked'; 
                               }
                           }    
                           $result.="<input $lsdisableclt class=\"chkcss\" type=\"checkbox\" name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\"  value=\"".$lsvalue."\" ".$lscheckuncheckproperty."><br/>";        
                           //$result.="<div  class=\"FieldLabelNote\">$lsdescription</div>";
                                               
                    break;
                    case 'label':
                         //$result.="<label name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\" >".$lsvalue."<br/>";
                         $result.="<input type=\"text\" style=\"border:0px;\" readonly name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\" value=\"".$lsvalue."\">";
                       //  $result.="<div  class=\"FieldLabelNote\">$lsdescription</div>";
                          
                    break;
                    
                    case 'checkbox':
                         $lacheckboxProperty = explode('size=',$lafeildresult[0]['property']);
                              
                              $lacheckbox=explode("\r\n",$lacheckboxProperty[0]);
                               if($lsvalue!='' and  $pEditModevalue!='')
                                  {
                                       $lacheckboxedit=explode(",",$lsvalue);
                                  }
                                  
                              foreach($lacheckbox as $key=>$value)
                              {
                                  
                                  $lacheckboxelement=explode("|",$value);
                                 
                                  foreach($lacheckboxelement as $key1=>$value1) 
                                  {
                                     switch($key1)
                                     {
                                       case "0":
                                        $lscheckboxvalue=trim($value1);
                                       break;
                                       case "1":
                                        $lscheckboxname=trim($value1);
                                       case "2":
                                        $lscheckboxselected=trim($value1); 
                                     
                                     }   
                                  }
                                  if($lsvalue!='' and  $pEditModevalue!='')
                                  {
                                       foreach($lacheckboxedit as $key2=>$value2)
                                       {
                                                if($value2==$lscheckboxvalue)
                                                {
                                                        $lsoptionselect='checked';
                                                        break;
                                                }
                                                 else
                                                 {
                                                        $lsoptionselect=''; 
                                                 }
                                       }       
                                  }
                                  else
                                  {
                                      $lsoptionselect=trim($lscheckboxselected)=='1'?'checked':'';  
                                  }    
                                 
                                   
                                 // $result.="<option value=\"$lsradiovalue\" ".$lsoptionselect.">".$lsselectname."</option>";    
                                   $result.="<input $lsdisableclt  type=\"checkbox\" class=\"chkcss\" name=\"".$lafeildresult[0]['name']."[]\" id=\"".$lafeildresult[0]['name']."\" value=\"".$lscheckboxvalue."\" ".$lsoptionselect."=\"\">".$lscheckboxname."<br/>";        
                              }
                              
                             // $result.="<div  class=\"FieldLabelNote\">$lsdescription</div>"; 
                              break;
                    
                    }      
                     return $result;                       
                }
                
            }
            else
            {
              return '';
            
            }   
      
        
           
    } 
  
     function renderDynamiControl_admin_user_edit_profile($pControlId,$pVisiblityOn,$pEditModevalue='',$pProductId='',$userId)
    {
        
            $result='';
            $lsdisableclt='';
            $query="SELECT * FROM ".TABLE_PREFIX ."singupformfields where id=?";
            $lsValues[0] =$pControlId;
            $lafeildresult = $this->View($query,$lsValues,null);

            if(is_array($lafeildresult))
            {
                if(sizeof($lafeildresult)>0)
                {
                    if($pVisiblityOn == 'signup' && $lafeildresult[0]['signupformvisibility']==0)
                    {
                        return '';
                    }
                    if($pVisiblityOn =='profile' && $lafeildresult[0]['profileformvisibility']==0)
                    {
                        
                        return '';   
                    }
                    if($pEditModevalue!='')
                    {
                        $lsvalue=$this->getformdata('profile',$pControlId,$userId,$pProductId);
                        if($lsvalue=='')
                        {
                           
                            if($lafeildresult[0]['displaytype']=='checkbox(checked)' or $lafeildresult[0]['displaytype']=='checkbox(unchecked)')
                           {
                                 $lsvalueeditchkunchk='';  
                           }
                           $lsvalue= $lafeildresult[0]['defaultvalue']; 
                           
                        }
                        /* disable for   Edit Profile  control*/
                        if($pVisiblityOn=='profile' and $lafeildresult[0]['profileformvisibility']==2)
                        {
                            $lsdisableclt='disabled'; 
                        }   
                      
                    }
                    else
                    {
                         $lsvalue=$lafeildresult[0]['defaultvalue']!=''?$lafeildresult[0]['defaultvalue']:'';   
                        
                    }    
                    
                    $lsdescription=$lafeildresult[0]['description']!=''?$lafeildresult[0]['description']:'';   
                    switch($lafeildresult[0]['displaytype'])
                    {
                        case 'text':
                              
                               $result="<input $lsdisableclt style=\"width:200px;\" name=\"".$lafeildresult[0]['name']."\"  class=\"txtcss\"  id=\"".$lafeildresult[0]['name']."\" type=\"text\" value=\"$lsvalue\" ".$lafeildresult[0]['property'].">"; 
                               //$result.="<div class=\"FieldLabelNote\">$lsdescription</div>";
                               break;
                        case 'textarea':
                              $result="<textarea  $lsdisableclt class=\"txtareacss\" name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\"  ".$lafeildresult[0]['property']." style=\"\">$lsvalue</textarea>"; 
                              //$result.="<div class=\"FieldLabelNote\">$lsdescription</div>";
                               break; 
                               
                        case 'select':
                        case 'multi_select':
                              $lsSelectProperty = explode('size=',$lafeildresult[0]['property']);
                              $lsmutiple=$lafeildresult[0]['displaytype']=='multi_select'?'multiple':'';
                              $lamutiple=$lafeildresult[0]['displaytype']=='multi_select'?'[]':'';  
                              $laselect=explode("\r\n",$lsSelectProperty[0]);
                              if($lsvalue!='' and  $pEditModevalue!='')
                              {
                                       $laselectedit=explode(",",$lsvalue);
                              }
                              $result="<select $lsdisableclt style=\"width: 208px;\"  class=\"selectcss\" name=\"".$lafeildresult[0]['name']."$lamutiple\" id=\"".$lafeildresult[0]['name']."\" ".$lsmutiple.">";
                              if($lafeildresult[0]['displaytype']=='select')
                                $result.="<option value=' '>select..</option>"; 
                              
                              foreach($laselect as $key=>$value)
                              {
                                  $laselectelement=explode("|",$value);
                              
                                  foreach($laselectelement as $key1=>$value1) 
                                  {
                                     switch($key1)
                                     {
                                       case "0":
                                        $lsselectvalue=trim($value1);
                                       break;
                                       case "1":
                                        $lsselectname=trim($value1);
                                       case "2":
                                        $lsselected=trim($value1);
                                       
                                     
                                     }   
                                  }
                                   if($lsvalue!='' and  $pEditModevalue!='')
                                        {
                                                foreach($laselectedit as $key2=>$value2)
                                                {
                                                    if($value2==$lsselectvalue)
                                                    { //  echo $value2."==>".$lsselectvalue;
                                                        $lsoptionselect='selected';
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        $lsoptionselect=''; 
                                                    }
                                                }    
                                        }
                                        else
                                        {
                                            $lsoptionselect=$lsselected=='1'?'selected':'';   
                                        }      
                                
                                  $result.="<option value=\"$lsselectvalue\" ".$lsoptionselect.">".$lsselectname."</option>";    
                                      
                              }
                              $result.="</select>"; 
                              //$result.="<div  class=\"FieldLabelNote\">$lsdescription</div>";
                              break;   
                     case 'radio':     
                              $lsradioProperty = explode('size=',$lafeildresult[0]['property']);
                              
                              $laradio=explode("\r\n",$lsradioProperty[0]);
                              
                              
                              foreach($laradio as $key=>$value)
                              {
                                  $laradioelement=explode("|",$value);
                              
                                  foreach($laradioelement as $key1=>$value1) 
                                  {
                                     switch($key1)
                                     {
                                       case "0":
                                        $lsradiovalue=trim($value1);
                                       break;
                                       case "1":
                                        $lsradiotname=trim($value1);
                                       case "2":
                                        $lsradioselected=trim($value1); 
                                     
                                     }   
                                  }
                                   if($lsvalue!='' and  $pEditModevalue!='')
                                  {
                                                if($lsvalue==trim($lsradiovalue))
                                                {
                                                        $lsoptionselect='checked';
                                                        
                                                }
                                                 else
                                                 {
                                                        $lsoptionselect=''; 
                                                 }
                                              
                                  }
                                  else
                                  {
                                    $lsoptionselect=trim($lsradioselected)=='1'?'checked':''; 
                                  }
                                   
                                 // $result.="<option value=\"$lsradiovalue\" ".$lsoptionselect.">".$lsselectname."</option>";    
                                   $result.="<input  $lsdisableclt class=\"chkcss\" type=\"radio\" name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\"  value=\"".$lsradiovalue."\" ".$lsoptionselect.">".$lsradiotname."<br/>";        
                              }
                              
                              //$result.="<div  class=\"FieldLabelNote\">$lsdescription</div>";
                              break;     
                     case 'checkbox(checked)':
                     case 'checkbox(unchecked)':
                           $lscheckboxcheckuncheckproperty= $lafeildresult[0]['displaytype'];
                           $lscheckuncheckproperty ='';
                           if($lscheckboxcheckuncheckproperty=='checkbox(checked)')
                           {
                               $lscheckuncheckproperty='checked';    
                           }
                           else if($lscheckboxcheckuncheckproperty=='checkbox(unhecked)')
                           {
                           
                               $lscheckuncheckproperty='';
                           }   
                           if($pEditModevalue!='')
                           {
                               if(isset($lsvalueeditchkunchk))
                               {
                                    $lscheckuncheckproperty='';
                               }
                               else
                               {
                                    $lscheckuncheckproperty='checked'; 
                               }
                           }    
                           $result.="<input $lsdisableclt class=\"chkcss\" type=\"checkbox\" name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\"  value=\"".$lsvalue."\" ".$lscheckuncheckproperty."><br/>";        
                           //$result.="<div  class=\"FieldLabelNote\">$lsdescription</div>";
                                               
                    break;
                    case 'label':
                         //$result.="<label name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\" >".$lsvalue."<br/>";
                         $result.="<input type=\"text\" style=\"border:0px;\" readonly name=\"".$lafeildresult[0]['name']."\" id=\"".$lafeildresult[0]['name']."\" value=\"".$lsvalue."\">";
                       //  $result.="<div  class=\"FieldLabelNote\">$lsdescription</div>";
                          
                    break;
                    
                    case 'checkbox':
                         $lacheckboxProperty = explode('size=',$lafeildresult[0]['property']);
                              
                              $lacheckbox=explode("\r\n",$lacheckboxProperty[0]);
                               if($lsvalue!='' and  $pEditModevalue!='')
                                  {
                                       $lacheckboxedit=explode(",",$lsvalue);
                                  }
                                  
                              foreach($lacheckbox as $key=>$value)
                              {
                                  
                                  $lacheckboxelement=explode("|",$value);
                                 
                                  foreach($lacheckboxelement as $key1=>$value1) 
                                  {
                                     switch($key1)
                                     {
                                       case "0":
                                        $lscheckboxvalue=trim($value1);
                                       break;
                                       case "1":
                                        $lscheckboxname=trim($value1);
                                       case "2":
                                        $lscheckboxselected=trim($value1); 
                                     
                                     }   
                                  }
                                  if($lsvalue!='' and  $pEditModevalue!='')
                                  {
                                       foreach($lacheckboxedit as $key2=>$value2)
                                       {
                                                if($value2==$lscheckboxvalue)
                                                {
                                                        $lsoptionselect='checked';
                                                        break;
                                                }
                                                 else
                                                 {
                                                        $lsoptionselect=''; 
                                                 }
                                       }       
                                  }
                                  else
                                  {
                                      $lsoptionselect=trim($lscheckboxselected)=='1'?'checked':'';  
                                  }    
                                 
                                   
                                 // $result.="<option value=\"$lsradiovalue\" ".$lsoptionselect.">".$lsselectname."</option>";    
                                   $result.="<input $lsdisableclt  type=\"checkbox\" class=\"chkcss\" name=\"".$lafeildresult[0]['name']."[]\" id=\"".$lafeildresult[0]['name']."\" value=\"".$lscheckboxvalue."\" ".$lsoptionselect."=\"\">".$lscheckboxname."<br/>";        
                              }
                              
                             // $result.="<div  class=\"FieldLabelNote\">$lsdescription</div>"; 
                              break;
                    
                    }      
                     return $result;                       
                }
                
            }
            else
            {
              return '';
            
            }   
      
        
           
    }
     
    function renderDynamiControlOnPage($pVisiblityOn,$pProductId='')
    {
        $result='';
        if($pVisiblityOn=='signup')
       {
            $query="SELECT *  FROM ".TABLE_PREFIX."singupformfields where signupformvisibility=1 order by sortorder,`label`";
            $lsEditmodevalue='';
            $lsProductid='';     
       }
       elseif($pVisiblityOn=='profile')
       {
         $query="SELECT *  FROM ".TABLE_PREFIX."singupformfields where profileformvisibility!=0 order by sortorder,`label`";
         $lsEditmodevalue="true";
         $lsProductid=$pProductId; 
       }    
       $lacontroleresult = $this->View($query);     
       
       if(is_array($lacontroleresult))
       {
            if(sizeof($lacontroleresult)>0)
            {
                 //$result= "<table  align=\"center\" width=\"100%\">";
                 foreach($lacontroleresult as $key=>$value)
                 {
                     if($value['validationfurnction']=='require')
                     {
                           $lsvalidationrequir="<label class=\"star\">*</label>";
                     }
                     else if($value['validationfurnction']=='require_email')
                     {
                          $lsvalidationrequir="<label class=\"star\">*</label>";
                     }
                     else if($value['validationfurnction']=='require_integer')
                     {
                         $lsvalidationrequir="<label class=\"star\">*</label>";
                     }
                     else
                     {
                         $lsvalidationrequir='';
                     }    
                    // $lsvalidationrequir=$value['validationfurnction']=='require' or $value['validationfurnction']=='require_email'?"<label class=\"star\">*</label>":'';
                    $lsdescription=$lacontroleresult[$key]['description']!=''?"(".$lacontroleresult[$key]['description'].")":''; 
                    $result.= "\r\n<tr>\r\n<td class=\"right-side-text\" style=\"width:200px;\"><label>".$lacontroleresult[$key]['label']."$lsvalidationrequir</label><div class=\"FieldLabelNote\" style=\"float:none;\">$lsdescription</div></td>";
                   if($value['displaytype']=="text" or $value['displaytype']=="textarea" or $value['displaytype']=="select" or $value['displaytype']=="multi_select")
                    {
                        $result.= "\r\n<td class=\"left-side-text\" style=\"padding:6px;\">".$this->renderDynamiControl($lacontroleresult[$key]['id'],$pVisiblityOn,$lsEditmodevalue,$lsProductid)."</td>";
                    }
                    else
                    {
                       $result.= "\r\n<td class=\"left-side-text\">".$this->renderDynamiControl($lacontroleresult[$key]['id'],$pVisiblityOn,$lsEditmodevalue,$lsProductid)."</td>"; 
                        
                    }    
                    
                    $result.= "\r\n</tr>\r\n";
                 
                 
                 } 
                 //$result.= "</table>"; 
            }
                
       }    
      return $result; 
       
    } 
    
     function renderDynamiControlOnPage_admin_user_edit_profile($pVisiblityOn,$pProductId='',$userId)
    {
        $result='';
        if($pVisiblityOn=='signup')
       {
            $query="SELECT *  FROM ".TABLE_PREFIX."singupformfields where signupformvisibility=1 order by sortorder,`label`";
            $lsEditmodevalue='';
            $lsProductid='';     
       }
       elseif($pVisiblityOn=='profile')
       {
         $query="SELECT *  FROM ".TABLE_PREFIX."singupformfields where profileformvisibility!=0 order by sortorder,`label`";
         $lsEditmodevalue="true";
         $lsProductid=$pProductId; 
       }    
       $lacontroleresult = $this->View($query);     
       
       if(is_array($lacontroleresult))
       {
            if(sizeof($lacontroleresult)>0)
            {
                 //$result= "<table  align=\"center\" width=\"100%\">";
                 foreach($lacontroleresult as $key=>$value)
                 {
                     if($value['validationfurnction']=='require')
                     {
                           $lsvalidationrequir="<label class=\"star\">*</label>";
                     }
                     else if($value['validationfurnction']=='require_email')
                     {
                          $lsvalidationrequir="<label class=\"star\">*</label>";
                     }
                     else if($value['validationfurnction']=='require_integer')
                     {
                         $lsvalidationrequir="<label class=\"star\">*</label>";
                     }
                     else
                     {
                         $lsvalidationrequir='';
                     }    
                    // $lsvalidationrequir=$value['validationfurnction']=='require' or $value['validationfurnction']=='require_email'?"<label class=\"star\">*</label>":'';
                    $lsdescription=$lacontroleresult[$key]['description']!=''?"(".$lacontroleresult[$key]['description'].")":''; 
                    $result.= "\r\n<tr>\r\n<td class=\"right-side-text\" style=\"width:200px;\"><label>".$lacontroleresult[$key]['label']."$lsvalidationrequir</label><div class=\"FieldLabelNote\" style=\"float:none;\">$lsdescription</div></td>";
                   if($value['displaytype']=="text" or $value['displaytype']=="textarea" or $value['displaytype']=="select" or $value['displaytype']=="multi_select")
                    {
                        $result.= "\r\n<td class=\"left-side-text\" style=\"padding:6px;\">".$this->renderDynamiControl_admin_user_edit_profile($lacontroleresult[$key]['id'],$pVisiblityOn,$lsEditmodevalue,$lsProductid,$userId)."</td>";
                    }
                    else
                    {
                       $result.= "\r\n<td class=\"left-side-text\">".$this->renderDynamiControl_admin_user_edit_profile($lacontroleresult[$key]['id'],$pVisiblityOn,$lsEditmodevalue,$lsProductid,$userId)."</td>"; 
                        
                    }    
                    
                    $result.= "\r\n</tr>\r\n";
                 
                 
                 } 
                 //$result.= "</table>"; 
            }
                
       }    
      return $result; 
       
    } 
    
    function renderDynamiControlvalidation($pVisiblityOn,$pFormname,$pvalidationAvailabelName='')
    {
        if($pVisiblityOn=='signup')
       {
        $query="SELECT *  FROM ".TABLE_PREFIX."singupformfields where signupformvisibility=1 and validationfurnction <>'none' order by sortorder,`label`";
       }
       elseif($pVisiblityOn=='profile')
       {
         $query="SELECT *  FROM ".TABLE_PREFIX."singupformfields where profileformvisibility!=0 and  validationfurnction<>'none' order by sortorder,`label`";
       }    
       $lacontroleresult = $this->View($query,false,null);     
       if(is_array($lacontroleresult))
       {
            if(sizeof($lacontroleresult)>0)
            {
                if($pvalidationAvailabel=='')
                {
                    $lsvalidatorname='frmvalidator';
                    $result="var $lsvalidatorname  = new Validator(\"".$pFormname."\");\r\n";
                    $result.="$lsvalidatorname.EnableMsgsTogether();\r\n";
                }
                else
                {
                    $lsvalidatorname=$pvalidationAvailabelName;    
                    
                }    
                foreach($lacontroleresult as $key=>$value)
                {
                    $lsname=$value['name'];
                  
                    $lsvalidatorfunctionname=$value['validationfurnction'];
                    $lsfeildname=$value['label'];
                    $lsfeilddisplaytype=$value['displaytype'];
                    switch($lsvalidatorfunctionname)
                    {
                        case 'require':
                               if($lsfeilddisplaytype=='checkbox(checked)' or $lsfeilddisplaytype=='checkbox(unchecked)')
                                 $result.="$lsvalidatorname.addValidation(\"".$lsname."\",\"shouldselchk=on\",'Please select $lsfeildname.');\r\n";
                               else if($lsfeilddisplaytype=='radio')
                                $result.="$lsvalidatorname.addValidation(\"".$lsname."\",\"selone_radio\",'Please select $lsfeildname.');\r\n"; 
                               else if($lsfeilddisplaytype=='checkbox')
                               {
                                   /* $result.= "function checkrdlnoreach()\r\n{
                                              var frm = document.forms[\"".$pFormname."\"]; 
                                              var test=frm.$lsname;
                                              var result = false;\r\n
                                              for(i=0;i<test.length;i++)\r\n
                                              {  
                                                if(test[i].checked)\r\n
                                                {\r\n   
                                                    result = true;\r\n
                                                    break;
                                                }\r\n 
                                              }\r\n 
                                              if(result==false)
                                              {   
                                                alert(\"Please Select atleast one $lsfeildname\");
                                                return false;
                                              }
                                              else
                                              {
                                              
                                                return result\r\n 
                                              }
                                              }\r\n"; */
                                       
                                       //frmvalidator.addValidation("gen_username","shouldselchk=on ","Please select Username generate."); 
                                       $result.="$lsvalidatorname.addValidation(\"".$lsname."\",\"selone_radio\",'Please select $lsfeildname.');\r\n"; 
                                       //$result.="$lsvalidatorname.setAddnlValidationFunction(\"".checkrdlnoreach."\")\r\n";     
                                   // $result.="$lsvalidatorname.setAddnlValidationFunction(\"".checkrdlnoreach."\")\r\n";
                               }
                               else if($lsfeilddisplaytype=='multi_select')
                               {
                                   $result.="$lsvalidatorname.addValidation(\"".$lsname."\",\"selone_option\",'Please select $lsfeildname.');\r\n"; 
                               }
                               
                               else if( $lsfeilddisplaytype=='select')
                               { 
                                   $result.="$lsvalidatorname.addValidation(\"".$lsname."\",\"dontselect=0\",'Please select $lsfeildname.');\r\n";
                                  
                               }     
                               else
                               $result.="$lsvalidatorname.addValidation(\"".$lsname."\",'req','Please enter $lsfeildname.');\r\n";
                             break;
                        case 'integer':
                             $result.="$lsvalidatorname.addValidation(\"".$lsname."\",'numeric','Please enter only digit in $lsfeildname.');\r\n";
                             break;
                        case 'email':
                             $result.="$lsvalidatorname.addValidation(\"".$lsname."\",'email','Please enter Proper  $lsfeildname.');\r\n";
                             break;
                        case 'require_email':
                             $result.="$lsvalidatorname.addValidation(\"".$lsname."\",'req','Please enter $lsfeildname.');\r\n";
                             $result.="$lsvalidatorname.addValidation(\"".$lsname."\",'email','Please enter Proper  $lsfeildname.');\r\n";
                             break;
                        case 'require_integer':
                             $result.="$lsvalidatorname.addValidation(\"".$lsname."\",'req','Please enter $lsfeildname.');\r\n";
                             $result.="$lsvalidatorname.addValidation(\"".$lsname."\",'numeric','Please enter only digit in $lsfeildname.');\r\n";                     
                             break;
                            
                    }
                   
                    
                     
                }    
                     
            }
            else
            {
               $result='';             
            }   
            
       }
       else
       {
          $result=''; 
           
       }    
       return $result;
    } 
    
    
    function insertsignupformdata($pVisiblityOn,$pValues,$pUserid)
    {
        $lacontroleresult='';
       if($pVisiblityOn=='signup')
       {
         $query="SELECT *  FROM ".TABLE_PREFIX."singupformfields where signupformvisibility=1  order by sortorder,`label`"; 
       }
       else if($pVisiblityOn=='profile')
       {
         $query="SELECT *  FROM ".TABLE_PREFIX."singupformfields where profileformvisibility!=0  order by sortorder,`label`";
           
       }    
       $lacontroleresult = $this->View($query,$lsValues,null);     
       if(is_array($lacontroleresult))
       {
            if(sizeof($lacontroleresult)>0)
            {
                if($pVisiblityOn=='profile')
                {   
                    $query="delete from ".TABLE_PREFIX."signupformdata where userid=?";
                    $ladelformdata=array();
                    $ladelformdata[]=$pUserid;
                   // $ladelformdata[]=$pValues['products'];
                    $lidelrecode=$this->Delete($query,$ladelformdata,null);
                   if($pValues['products']=="")
                     $pValues['products']=0; 
                    
                }    
                foreach($lacontroleresult as $key=>$value)
                {
                    $lsformdata='';
                    $query="insert into ".TABLE_PREFIX."signupformdata 
                   (signupformfieldid,signupformdata,userid,productid,createdon,createdby,createdipaddress) values(?,?,?,?,?,?,?)"; 
                   $laformdata=array();
                   $laformdata[]=$value['id'];
                   if(is_array($pValues[$value['name']]))
                   {
                      $lsformdata=implode(",",$pValues[$value['name']]);
                       
                   } 
                   else
                   {
                            $lsformdata =$pValues[$value['name']];
                   
                   } 
                   if($lsformdata==null)
                   {
                      $lsformdata=' ';
                   }      
                   $laformdata[]=$lsformdata;    
                   $laformdata[]=$pUserid;
                   $laformdata[]=0;
                   $laformdata[]=mktime();
                   $laformdata[]=$pUserid; 
                   $laformdata[]=$_SERVER['REMOTE_ADDR'];
                  if($pVisiblityOn=='profile')
                  {
                    $this->Insert($query,$laformdata,null);
                  } 
                  else if($pVisiblityOn=='signup')
                  {
                       $this->Insert($query,$laformdata,null); 
                  }    
                      
            }
            
       } 
       
        
        
    }   
    } 
    function getformdata($pVisiblityOn,$pFieldid, $pUserId, $pProductId)
    {

           /* $lsQuery = "select id from prefix_signupformfields
            where signupformvisibility = 1
            and userid = $pUserId and productid = $pProductId and fieldname=$fieldname";
           
           
            select signupformdata from prefix_signupformdata
        where signupformfieldid = result of above query
        and productid=    $pProductId
        and userid=$pUserId


        $r = value of above query signupformdata
        
    
     
    return $r;*/
      $result='';
      if($pVisiblityOn=='signup')
       {
        $query=$query="select * from ".TABLE_PREFIX."signupformdata where userid=$pUserId and productid=$pProductId and signupformfieldid=$pFieldid";
       }
       elseif($pVisiblityOn=='profile')
       {
          $query="select * from ".TABLE_PREFIX."signupformdata where userid=$pUserId and productid=$pProductId and signupformfieldid=$pFieldid";
          $ladefaultvalueres = $this->View($query,$lsValues,null);     
          if(is_array($ladefaultvalueres))
          {
            if(sizeof($ladefaultvalueres)>0)
            {
                   $result=$ladefaultvalueres[0]['signupformdata'];
                   if($result=="")
                     $result=" ";
                   
                
            }
          } 
          else
          {
                $result='';
          } 
          
                
       }  
       return $result;  

}  
       
    
 }   
  
    

?>
Return current item: MembersGear