*
* Class for creating select boxes for addresse, projects, array items, ... *
* Copyright (C) 2000, 2001 Dan Kuykendall *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/* $Id$ */
include(PHPGW_API_INC . '/class.sbox.inc.php');
class sbox2 extends sbox
{
/*
* Function: search for an id of an db-entry, eg. an address
* Parameter: $name base name for all template-vars and of the submitted vars (not to conflict with other template-var-names !!!)
* $lang_name titel of the field
* $prompt for the JavaScript prompt()
* $id_name id of previosly selected entry
* $content from id (eg. 'company: lastname, givenname' for address $id) if $id != 0, or
* array with searchresult (id's as key), if array is empty if search was unsucsessful
* $multipe present a multiple selectable box instead of one selector-button
* Returns: array with vars to set in temaplate, the vars are:
* {doSearchFkt} Javascript Funktion, place somewhere in Template (before rest of the vars)
* {$name.'_title} button with titel $lang_name (if JS) or just $lang_name
* {$name} content of $id if != 0, or lang('use Button to search for').$lang_name
* {$name.'_nojs} searchfield + button if we have no JavaScript, else empty
*
* To use call $template->set_var(getIdSearch( ... ));
* the template should look like {doSearchFkt}
{XXX_title}
{XXX}
{XXX_nojs}
(XXX is content of $name)
* In the submitted page the vars $query_XXX and $id_XXX are set according to what is selected, see getAddress as Example
*/
function getId($name,$lang_name,$prompt,$id_name,$content='',$note='',$multiple=False)
{
// echo "
getId('$name','$lang_name','$prompt',$id_name,'$content') =";
$ret['doSearchFkt'] =
'';
$ret[$name.'_title'] = is_array($content) && count($content) ? $lang_name :
'\n".
"";
if (is_array($content))
{ // result from search
if (!count($content))
{ // search was unsuccsessful
$ret[$name] = lang('no entries found, try again ...');
}
else
{
$ret[$name.'_OK'] = ''; // flag we have something so select
if ($multiple)
{
$ret[$name] = '