| 1964 | | // $goto is the current goto destination setting |
|---|
| 1965 | | // $i is the destination set number (used when drawing multiple destination sets in a single form ie: digital receptionist) |
|---|
| 1966 | | // esnure that any form that includes this calls the setDestinations() javascript function on submit. |
|---|
| 1967 | | // ie: if the form name is "edit", and drawselects has been called with $i=2 then use onsubmit="setDestinations(edit,2)" |
|---|
| 1968 | | function drawselects($goto,$i,$show_custom=false) { |
|---|
| | 1964 | |
|---|
| | 1965 | /* |
|---|
| | 1966 | * $goto is the current goto destination setting |
|---|
| | 1967 | * $i is the destination set number (used when drawing multiple destination sets in a single form ie: digital receptionist) |
|---|
| | 1968 | * esnure that any form that includes this calls the setDestinations() javascript function on submit. |
|---|
| | 1969 | * ie: if the form name is "edit", and drawselects has been called with $i=2 then use onsubmit="setDestinations(edit,2)" |
|---|
| | 1970 | * $table specifies if the destinations will be drawn in a new <tr> and <td> |
|---|
| | 1971 | * |
|---|
| | 1972 | */ |
|---|
| | 1973 | function drawselects($goto,$i,$show_custom=false, $table=true) { |
|---|
| 1998 | | foreach ($all_destinations as $cat=>$destination) { |
|---|
| 1999 | | // create a select option for each destination |
|---|
| 2000 | | $options = ""; |
|---|
| 2001 | | $checked = false; |
|---|
| 2002 | | foreach ($destination as $dest) { |
|---|
| 2003 | | $options .= '<option value="'.$dest['destination'].'" '.(strpos($goto,$dest['destination']) === false ? '' : 'SELECTED').'>'.($dest['description'] ? $dest['description'] : $dest['destination']); |
|---|
| 2004 | | |
|---|
| 2005 | | // check to see if the currently selected goto matches one these destinations |
|---|
| 2006 | | if($dest['destination'] == $goto) $checked = true; |
|---|
| | 2010 | //get the destination module name if we have a $goto |
|---|
| | 2011 | if($goto){ |
|---|
| | 2012 | foreach($module_hash as $mod => $description){ |
|---|
| | 2013 | foreach($all_destinations[$mod] as $destination){ |
|---|
| | 2014 | if($goto==$destination['destination']){ |
|---|
| | 2015 | $destmod=$mod; |
|---|
| | 2016 | } |
|---|
| | 2017 | } |
|---|
| 2008 | | |
|---|
| 2009 | | // make a unique id to be used for the HTML id |
|---|
| 2010 | | // This allows us to have multiple drawselect() sets on the page without |
|---|
| 2011 | | // conflicting with each other |
|---|
| 2012 | | $radioid = uniqid("drawselect"); |
|---|
| 2013 | | |
|---|
| 2014 | | $cat_identifier = preg_replace('/[^a-zA-Z0-9]/','_', $cat); |
|---|
| 2015 | | |
|---|
| | 2019 | } |
|---|
| | 2020 | if ($tabindex_needed && ($checked || !$goto)) { |
|---|
| | 2021 | $tabindex_txt = (isset($tabindex) && $tabindex != '') ? ' tabindex="'.++$tabindex.'" ':''; |
|---|
| | 2022 | $tabindex_needed = false; |
|---|
| | 2023 | } else { |
|---|
| | 2024 | $tabindex_txt = ''; |
|---|
| | 2025 | } |
|---|
| | 2026 | //draw first select box |
|---|
| | 2027 | $selectHtml.='<select name="goto'.$i.'" class="destdropdown" '.($tabindex_needed?' tabindex="'.$tabindex_txt.'"':'').'>'; |
|---|
| | 2028 | $selectHtml.='<option value="">== '._('chose one').' ==</option>'; |
|---|
| | 2029 | foreach($module_hash as $mod => $disc){ |
|---|
| | 2030 | $cat_identifier = preg_replace('/[^a-zA-Z0-9]/','_', $mod); |
|---|
| 2029 | | |
|---|
| 2030 | | if ($tabindex_needed && ($checked || ! $goto)) { |
|---|
| 2031 | | $tabindex_txt = (isset($tabindex) && $tabindex != '') ? ' tabindex="'.++$tabindex.'" ':''; |
|---|
| 2032 | | $tabindex_needed = false; |
|---|
| 2033 | | } else { |
|---|
| 2034 | | $tabindex_txt = ''; |
|---|
| | 2044 | $selectHtml .='<option value="'.str_replace(' ','_',$mod).'" '.(($mod==$destmod)?'SELECTED':'').'>'.$mod.'</option>'; |
|---|
| | 2045 | } |
|---|
| | 2046 | $selectHtml .='</select> '; |
|---|
| | 2047 | |
|---|
| | 2048 | foreach ($all_destinations as $cat=>$destination) { |
|---|
| | 2049 | $selectHtml .='<select name="'.str_replace(' ','_',$cat).$i.'"'.(($cat==$destmod)?'':' style="display:none"').'>'; |
|---|
| | 2050 | foreach($destination as $dest){ |
|---|
| | 2051 | $selectHtml .='<option value="'.$dest['destination'].'" '.(($goto==$dest['destination'])?'SELECTED':'').'>'.$dest['description'].'</option>'; |
|---|
| 2036 | | $selectHtml .= '<input type="radio"'.$tabindex_txt.' id="'.$radioid.'" name="goto'.$i.'" value="'.$cat_identifier.'" '. |
|---|
| 2037 | | //'onclick="javascript:this.form.goto'.$i.'.value=\''.$cat.'\';" '. |
|---|
| 2038 | | //'onkeypress="javascript:if (event.keyCode == 0 || (document.all && event.keyCode == 13)) this.form.goto'.$i.'.value=\''.$cat.'\';" '. |
|---|
| 2039 | | ($checked? 'CHECKED=CHECKED' : '').' /> '; |
|---|
| 2040 | | $selectHtml .= '<label for="'.$radioid.'">'.$label_text.':</label> '; |
|---|
| 2041 | | |
|---|
| 2042 | | // set the |
|---|
| 2043 | | // if ($checked) { $gotomod = $cat; } |
|---|
| 2044 | | |
|---|
| 2045 | | $selectHtml .= '<select name="'.$cat_identifier.$i.'" onfocus="document.getElementById(\''.$radioid.'\').checked = true; this.form.goto'.$i.'.value=\''.$cat.'\';">'; |
|---|
| 2046 | | $selectHtml .= $options; |
|---|
| 2047 | | $selectHtml .= "</select><br />\n"; |
|---|
| 2048 | | |
|---|
| 2049 | | if ($checked) $foundone = true; |
|---|
| | 2053 | $selectHtml .='</select>'; |
|---|