Changeset 9127

Show
Ignore:
Timestamp:
03/11/10 05:39:36 (2 years ago)
Author:
mbrevda
Message:

closes #4123; add drawselects to gui_elements

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/htdocs/admin/components.class.php

    r8599 r9127  
    517517  var $html_input; 
    518518   
    519   function guiinput($elemname, $currentvalue = '', $prompttext = '', $helptext = '', $jsvalidation = '', $failvalidationmsg = '', $canbeempty = true) { 
     519  function guiinput($elemname, $currentvalue = '', $prompttext = '', $helptext = '', $jsvalidation = '', $failvalidationmsg = '', $canbeempty = true, $jsvalidationtest='') { 
    520520    // call parent class contructor 
    521521    guielement::guielement($elemname, '', ''); 
     
    529529    // JavaScript validation field on the element 
    530530    $this->jsvalidation = $jsvalidation; 
     531    // JavaScript validation test 
     532    $this->jsvalidationtest = $jsvalidationtest; 
    531533    // Msg to use if above validation fails (forced to use gettext language stuff) 
    532534    $this->failvalidationmsg = $failvalidationmsg; 
     
    542544    $output = ''; 
    543545     
    544     if ($this->jsvalidation != '') { 
    545       $thefld = "theForm." . $this->_elemname; 
    546       $thefldvalue = $thefld . ".value"; 
     546    if ($this->jsvalidation != '' ) { 
     547      if(!$this->jsvalidationtest){ 
     548        $thefld = "theForm." . $this->_elemname; 
     549        $thefldvalue = $thefld . ".value"; 
     550      }else{ 
     551        $thefld="theForm." . $this->_elemname; 
     552        $thefldvalue =$this->jsvalidationtest; 
     553      } 
    547554     
    548555      if ($this->canbeempty) { 
     
    705712} 
    706713 
     714class gui_drawselects extends guiinput { 
     715  function gui_drawselects($elemname, $index, $prompttext = '', $helptext = '', $canbeempty = true, $failvalidationmsg='') { 
     716    $parent_class = get_parent_class($this); 
     717    if(!$canbeempty){ 
     718      $jsvalidation ='()'; 
     719      $jsvalidationtest ='!$("input[name=goto'.$index.']:submit").val()'; 
     720      $failvalidationmsg = _('Please select a valid destination.'); 
     721    } 
     722    parent::$parent_class($elemname, '', $prompttext, $helptext, $jsvalidation, $failvalidationmsg, '', $jsvalidationtest); 
     723     
     724    $this->html_input=drawselects($currentvalue, $index, false, false); 
     725  }    
     726} 
     727 
    707728/* 
    708729************************************************************ 
  • freepbx/trunk/amp_conf/htdocs/admin/functions.inc.php

    r9069 r9127  
    19551955} 
    19561956 
    1957 // $goto is the current goto destination setting 
    1958 // $i is the destination set number (used when drawing multiple destination sets in a single form ie: digital receptionist) 
    1959 // esnure that any form that includes this calls the setDestinations() javascript function on submit. 
    1960 // ie: if the form name is "edit", and drawselects has been called with $i=2 then use onsubmit="setDestinations(edit,2)" 
    1961 function drawselects($goto,$i,$show_custom=false) { 
     1957/* 
     1958 * $goto is the current goto destination setting 
     1959 * $i is the destination set number (used when drawing multiple destination sets in a single form ie: digital receptionist) 
     1960 * esnure that any form that includes this calls the setDestinations() javascript function on submit. 
     1961 * ie: if the form name is "edit", and drawselects has been called with $i=2 then use onsubmit="setDestinations(edit,2)" 
     1962 * $table specifies if the destinations will be drawn in a new <tr> and <td> 
     1963 *  
     1964 */    
     1965function drawselects($goto,$i,$show_custom=false, $table=true) { 
    19621966  global $tabindex; 
    19631967   
     
    19671971  $all_destinations = array(); 
    19681972  $module_hash = array(); 
    1969  
    1970   $selectHtml = '<tr><td colspan=2>';  
     1973  $selectHtml=''; 
     1974  if($table){ 
     1975    $selectHtml.='<tr><td colspan=2>'; 
     1976  } 
     1977 
    19711978   
    19721979  //check for module-specific destination functions 
     
    20672074  //close off our row 
    20682075  } 
    2069   $selectHtml .= '</td></tr>'; 
     2076  if($table){ 
     2077    $selectHtml.='</td></tr>'; 
     2078  } 
    20702079   
    20712080  return $selectHtml;