new account selection:

- search after different criteria: all fields, firstname, lastname, lid, starting with or exact match
- additional display of the current selection in the popup
This commit is contained in:
Ralf Becker 2004-06-13 20:17:54 +00:00
parent d484a2227f
commit a99697ae09
5 changed files with 211 additions and 58 deletions

View File

@ -39,6 +39,12 @@
$this->accounts($account_id,$account_type); // call constructor of extended class
$this->account_selection = $GLOBALS['phpgw_info']['user']['preferences']['common']['account_selection'];
if (!is_object($GLOBALS['phpgw']->html))
{
$GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
}
$this->html = $GLOBALS['phpgw']->html;
}
/**
@ -59,10 +65,6 @@
function selection($name,$element_id,$selected,$use='accounts',$lines=1,$not=False,$options='',$onchange='')
{
//echo "<p>uiaccountsel::selection('$name',".print_r($selected,True).",'$use',$lines,$not,'$options')</p>\n";
if (!is_object($GLOBALS['phpgw']->html))
{
$GLOBALS['phpgw']->html = CreateObject('phpgwapi.html');
}
if (!is_array($selected))
{
$selected = $selected ? array($selected) : array();
@ -153,35 +155,38 @@
'element_id' => $element_id,
'single' => !$lines, // single selection, closes after the first selection
));
$popup_options = 'width=600,height=400,toolbar=no,scrollbars=auto,resizable=yes';
$app = $GLOBALS['phpgw_info']['flags']['currentapp'];
$single = (int) !$lines;
if (!$lines)
{
$options .= ' onchange="if (this.value==\'popup\') '."window.open('$link','uiaccountsel','width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes')".';'.
$options .= ' onchange="if (this.value==\'popup\') '."window.open('$link','uiaccountsel','$popup_options');".
($onchange ? " else { $onchange }" : '' ).'"';
$select['popup'] = lang('Search').' ...';
$need_js_popup = True;
}
elseif ($onchange)
{
$options .= ' onchange="'.$onchange.'"';
}
//echo "<p>html::select('$name',".print_r($selected,True).",".print_r($select,True).",True,'$options')</p>\n";
$html = $GLOBALS['phpgw']->html->select($name,$selected,$select,True,$options.' id="'.$element_id.'"',$lines);
$html = $this->html->select($name,$selected,$select,True,$options.' id="'.$element_id.'"',$lines);
if ($lines > 1 && ($this->account_selection == 'popup' || $this->account_selection == 'primary_group'))
{
$html .= '<a href="'.$link.'" target="uiaccountsel" onclick="'."window.open(this,this.target,'width=800,height=600,toolbar=no,scrollbars=yes,resizable=yes'); return false;".'">'.
$GLOBALS['phpgw']->html->image('calendar','multi_3',lang('click to select or search accounts')).'</a>';
$html .= '<a href="'.$link.'" target="uiaccountsel" onclick="'."window.open(this,this.target,'$popup_options'); return false;".'">'.
$this->html->image('phpgwapi','users',lang('search or select accounts')).'</a>';
$need_js_popup = True;
}
if(!$GLOBALS['phpgw_info']['flags']['uiaccountsel']['addOption_installed'])
if($need_js_popup && !$GLOBALS['phpgw_info']['flags']['uiaccountsel']['addOption_installed'])
{
$html .= '<script language="JavaScript">
function addOption(id,label,value)
{
'.// alert(\'opener.addOption(\'+id+\',\'+label+\',\'+value+\')\');
' selectBox = document.getElementById(id);
'.// if (selectBox == null) alert(\'selectBox \'+id+\' not found !!!\');
' for (i=0; i < selectBox.length; i++) {
'. // check existing entries if its already there and only select it in that case
selectBox = document.getElementById(id);
for (i=0; i < selectBox.length; i++) {
'.// check existing entries if they're already there and only select them in that case
' if (selectBox.options[i].value == value) {
selectBox.options[i].selected = true;
break;
@ -200,16 +205,16 @@
function popup($app='')
{
global $query; // nextmatch requires that !!!
if (!$app) $app = get_var('app',array('POST','GET'));
$group_id = get_var('group_id',array('POST','GET'));
$group_id = get_var('group_id',array('POST','GET'),$GLOBALS['phpgw']->accounts->data['account_primary_group']);
$element_id = get_var('element_id',array('POST','GET'));
$single = get_var('single',array('POST','GET'));
if(isset($_POST['query']))
{
$GLOBALS['query'] = $_POST['query'];
}
$query = get_var('query',array('POST','GET'));
$query_type = get_var('query_type',array('POST','GET'));
$start = (int) get_var('start',array('POST'),0);
$order = get_var('order',array('POST','GET'),'account_lid');
@ -222,6 +227,7 @@
$GLOBALS['phpgw']->template->set_root($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi'));
$GLOBALS['phpgw']->template->set_file(array('accounts_list_t' => 'uiaccountsel.tpl'));
$GLOBALS['phpgw']->template->set_block('accounts_list_t','letter_search','letter_search_cells');
$GLOBALS['phpgw']->template->set_block('accounts_list_t','group_cal','cal');
$GLOBALS['phpgw']->template->set_block('accounts_list_t','group_other','other');
$GLOBALS['phpgw']->template->set_block('accounts_list_t','group_all','all');
@ -230,7 +236,6 @@
$GLOBALS['phpgw']->template->set_block('accounts_list_t','other_intro','iother');
$GLOBALS['phpgw']->template->set_block('accounts_list_t','all_intro','iall');
$GLOBALS['phpgw']->template->set_block('accounts_list_t','accounts_list','list');
$GLOBALS['phpgw']->template->set_var('font',$GLOBALS['phpgw_info']['theme']['font']);
@ -260,7 +265,15 @@
break;
}
$GLOBALS['phpgw_info']['flags']['currentapp'] = $app;
if (!$single)
{
if (!is_object($GLOBALS['phpgw']->js))
{
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
}
$GLOBALS['phpgw']->js->set_onload("copyOptions('$element_id');");
}
$GLOBALS['phpgw_info']['flags']['app_header'] = lang('search or select accounts');
$GLOBALS['phpgw']->common->phpgw_header();
$GLOBALS['phpgw']->template->set_var('lang_perm',lang('Groups with permission for %1',lang($app)));
@ -273,6 +286,7 @@
'group_id' => $group_id,
'element_id' => $element_id,
'single' => $single,
'query_type' => $query_type,
);
$app_groups = array();
@ -338,7 +352,7 @@
{
$link_data['group_id'] = $group['account_id'];
$GLOBALS['phpgw']->template->set_var('onclick',"opener.addOption('$element_id','".
$GLOBALS['phpgw']->template->set_var('onclick',"addOption('$element_id','".
$GLOBALS['phpgw']->common->grab_owner_name($group['account_id'])."','$group[account_id]')".
($single ? '; window.close()' : ''));
@ -346,9 +360,7 @@
{
$GLOBALS['phpgw']->template->set_var('tr_color',$this->nextmatchs->alternate_row_color($tr_color));
$GLOBALS['phpgw']->template->set_var('link_user_group',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('name_user_group',$group['account_name']);
$GLOBALS['phpgw']->template->set_var('account_display',$GLOBALS['phpgw']->common->grab_owner_name($group['account_id']));
$GLOBALS['phpgw']->template->set_var('accountid',$group['account_id']);
$GLOBALS['phpgw']->template->set_var('name_user_group',$GLOBALS['phpgw']->common->grab_owner_name($group['account_id']));
switch($app)
{
@ -361,7 +373,7 @@
if ($app != 'admin')
{
$GLOBALS['phpgw']->template->set_var('link_all_group',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('name_all_group',$group['account_name']);
$GLOBALS['phpgw']->template->set_var('name_all_group',$GLOBALS['phpgw']->common->grab_owner_name($group['account_id']));
$GLOBALS['phpgw']->template->set_var('accountid',$group['account_id']);
$GLOBALS['phpgw']->template->fp('all','group_all',True);
}
@ -370,7 +382,7 @@
$link_data['group_id'] = $group_id; // reset it
}
if (!$GLOBALS['query'])
if (!$query)
{
if (isset($group_id) && !empty($group_id))
{
@ -433,7 +445,7 @@
case 'calendar': $users = 'both'; break;
default: $users = 'accounts'; break;
}
$entries = $this->get_list($users,$start,$sort,$order,$GLOBALS['query']);
$entries = $this->get_list($users,$start,$sort,$order,$query,'',$query_type);
$total = $this->total;
for ($i=0;$i<count($entries);$i++)
{
@ -447,15 +459,16 @@
// --------------------------------- nextmatch ---------------------------
$GLOBALS['phpgw']->template->set_var(array(
'left' => $this->nextmatchs->left('/index.php',$start,$total,$link_data),
'right' => $this->nextmatchs->right('/index.php',$start,$total,$link_data),
'lang_showing' => $this->nextmatchs->show_hits($total,$start),
'left' => $this->nextmatchs->left('/index.php',$start,$total,$link_data+array('query'=>$query)),
'right' => $this->nextmatchs->right('/index.php',$start,$total,$link_data+array('query'=>$query)),
'lang_showing' => ($query ? lang("Search %1 '%2'",lang($this->query_types[$query_type]),$query) :
lang('Group').' '.$this->id2name($group_id)).': '.$this->nextmatchs->show_hits($total,$start),
));
// -------------------------- end nextmatch ------------------------------------
$GLOBALS['phpgw']->template->set_var('search_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('search_list',$this->nextmatchs->search(array('query' => $GLOBALS['query'], 'search_obj' => 1)));
$GLOBALS['phpgw']->template->set_var('search_list',$this->nextmatchs->search(array('query' => $query, 'search_obj' => 1)));
// ---------------- list header variable template-declarations --------------------------
@ -465,6 +478,7 @@
$GLOBALS['phpgw']->template->set_var('sort_lastname',$this->nextmatchs->show_sort_order($sort,'account_lastname',$order,'/index.php',lang('Lastname'),$link_data));
// ------------------------- end header declaration --------------------------------
if ($query) $start = 0; // already handled by accounts::get_list
$stop = min($start + $this->nextmatchs->maxmatches,count($val_users));
for($i = $start; $i < $stop; ++$i)
{
@ -477,21 +491,57 @@
'lid' => $user['account_lid'],
'firstname' => $user['account_firstname'] ? $user['account_firstname'] : '&nbsp;',
'lastname' => $user['account_lastname'] ? $user['account_lastname'] : '&nbsp;',
'onclick' => "opener.addOption('$element_id','".
'onclick' => "addOption('$element_id','".
$GLOBALS['phpgw']->common->grab_owner_name($user['account_id'])."','$user[account_id]')".
($single ? '; window.close()' : ''),
));
$GLOBALS['phpgw']->template->fp('list','accounts_list',True);
}
$GLOBALS['phpgw']->template->set_var('start',$start);
$GLOBALS['phpgw']->template->set_var('sort',$sort);
$GLOBALS['phpgw']->template->set_var('order',$order);
$GLOBALS['phpgw']->template->set_var('query',$GLOBALS['query']);
$GLOBALS['phpgw']->template->set_var('query',$query);
$GLOBALS['phpgw']->template->set_var('group_id',$group_id);
$GLOBALS['phpgw']->template->set_var('lang_done',lang('done'));
$GLOBALS['phpgw']->template->set_var('accountsel_icon',$this->html->image('phpgwapi','users-big'));
$GLOBALS['phpgw']->template->set_var('query_type',is_array($this->query_types) ? $this->html->select('query_type',$query_type,$this->query_types) : '');
$link_data['query_type'] = 'start';
$letters = lang('alphabet');
$letters = explode(',',substr($letters,-1) != '*' ? $letters : 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z');
foreach($letters as $letter)
{
$link_data['query'] = $letter;
$GLOBALS['phpgw']->template->set_var(array(
'letter' => $letter,
'link' => $GLOBALS['phpgw']->link('/index.php',$link_data),
'class' => $query == $letter && $query_type == 'start' ? 'letter_box_active' : 'letter_box',
));
$GLOBALS['phpgw']->template->fp('letter_search_cells','letter_search',True);
}
unset($link_data['query']);
unset($link_data['query_type']);
$GLOBALS['phpgw']->template->set_var(array(
'letter' => lang('all'),
'link' => $GLOBALS['phpgw']->link('/index.php',$link_data),
'class' => $query_type != 'start' || !in_array($query,$letters) ? 'letter_box_active' : 'letter_box',
));
$GLOBALS['phpgw']->template->fp('letter_search_cells','letter_search',True);
$GLOBALS['phpgw']->template->set_var(array(
'lang_selection' => lang('selection'),
'lang_close' => lang('close'),
));
if (!$single)
{
$GLOBALS['phpgw']->template->set_var(array(
'selection' => $this->html->select('selected',False,array(),True,' id="uiaccountsel_popup_selection" style="width: 100%;"',13),
'remove' => $this->html->submit_button('remove','remove',
"removeSelectedOptions('$element_id'); return false;",True,' title="'.lang('Remove selected accounts').'"','delete'),
));
}
$GLOBALS['phpgw']->template->pfp('out','accounts_list_t',True);
$GLOBALS['phpgw']->common->phpgw_footer();

View File

@ -37,6 +37,7 @@ afghanistan common de AFGHANISTAN
albania common de ALBANIEN
algeria common de ALGERIEN
all common de alle
all fields common de alle Felder
alphabet common de a,ä,b,c,d,e,f,g,h,i,j,k,l,m,n,o,ö,p,q,r,s,t,u,ü,v,w,x,y,z
american samoa common de AMERICANISCH SAMOA
andorra common de ANDORRA
@ -198,6 +199,7 @@ error deleting %1 %2 directory common de Fehler beim L
error renaming %1 %2 directory common de Fehler beim Umbennenen des Verzeichnisses %1 %2
estonia common de ESTONIEN
ethiopia common de ETHIOPIEN
exact common de exakt
falkland islands (malvinas) common de FALKLAND INSELN (MALVINAS)
faroe islands common de FAROE INSELN
fax number common de Fax Nummer
@ -317,6 +319,7 @@ libyan arab jamahiriya common de LIBYAN ARAB JAMAHIRIYA
license common de Lizenz
liechtenstein common de LIECHTENSTEIN
list common de Liste
list members common de Mitglieder anzeigen
lithuania common de LITAUEN
local common de lokal
login common de Anmelden
@ -411,6 +414,7 @@ original common de Original
other common de Andere
overview common de Überblick
owner common de Besitzer
page common de Seite
page was generated in %1 seconds common de Seite wurde erstellt in %1 sekunden
pakistan common de PAKISTAN
palau common de PALAU
@ -462,6 +466,7 @@ read common de Lesen
read this list of methods. common de Diese Liste der Methoden lesen.
redoes your last action htmlarea de Letzte Aktion wiederholen
reject common de Zurückweisen
remove selected accounts common de Ausgewähle Benutzer entfernen
rename common de Umbenennen
returns a full list of accounts on the system. warning: this is return can be quite large common de Liefert eine vollständige Lister der Benutzerkonten auf diesem System. Warnung: Die Rückgabe kann sehr gross sein
returns an array of todo items common de Liefert ein array mit ToDo Einträgen
@ -482,6 +487,8 @@ saturday common de Samstag
saudi arabia common de SAUDI ARABIEN
save common de Speichern
search common de Suchen
search %1 '%2' common de Suche %1 '%2'
search or select accounts common de Auswählen oder Suchen von Benutzern
section common de Sektion
select common de Auswählen
select all %1 %2 for %3 common de Alles auswählen %1 %2 von %3
@ -492,6 +499,7 @@ select home email address common de private Email-Adresse ausw
select one common de Einen auswählen
select user common de Benutzer auswählen
select work email address common de geschäftl. Email-Addresse auswählen
selection common de Auswahl
send common de Abschicken
senegal common de SENEGAL
september common de September
@ -522,6 +530,7 @@ spain common de SPANIEN
sri lanka common de SRI LANKA
start date common de Startdatum
start time common de Startzeit
start with common de begint mit
status common de Status
strikethrough htmlarea de Durchstreichen
subject common de Betreff
@ -637,4 +646,3 @@ your settings have been updated common de Ihre Einstellungen wurden aktualisiert
yugoslavia common de JUGOSLAVIEN
zambia common de ZAMBIA
zimbabwe common de ZIMBABWE
Page common de Seite

View File

@ -37,6 +37,7 @@ afghanistan common en AFGHANISTAN
albania common en ALBANIA
algeria common en ALGERIA
all common en All
all fields common en all fields
alphabet common en a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
american samoa common en AMERICAN SAMOA
andorra common en ANDORRA
@ -193,6 +194,7 @@ error deleting %1 %2 directory common en Error deleting %1 %2 directory
error renaming %1 %2 directory common en Error renaming %1 %2 directory
estonia common en ESTONIA
ethiopia common en ETHIOPIA
exact common en exact
falkland islands (malvinas) common en FALKLAND ISLANDS (MALVINAS)
faroe islands common en FAROE ISLANDS
fax number common en fax number
@ -312,6 +314,7 @@ libyan arab jamahiriya common en LIBYAN ARAB JAMAHIRIYA
license common en License
liechtenstein common en LIECHTENSTEIN
list common en List
list members common en List members
lithuania common en LITHUANIA
local common en Local
login common en Login
@ -404,6 +407,7 @@ original common en Original
other common en Other
overview common en Overview
owner common en Owner
page common en Page
page was generated in %1 seconds common en Page was generated in %1 seconds
pakistan common en PAKISTAN
palau common en PALAU
@ -455,6 +459,7 @@ read common en Read
read this list of methods. common en Read this list of methods.
redoes your last action htmlarea en Redoes your last action
reject common en Reject
remove selected accounts common en remove selected accounts
rename common en Rename
returns a full list of accounts on the system. warning: this is return can be quite large common en Returns a full list of accounts on the system. Warning: This is return can be quite large
returns an array of todo items common en Returns an array of todo items
@ -475,6 +480,8 @@ saturday common en Saturday
saudi arabia common en SAUDI ARABIA
save common en Save
search common en Search
search %1 '%2' common en Search %1 '%2'
search or select accounts common en Search or select accounts
section common en Section
select common en Select
select all %1 %2 for %3 common en Select all %1 %2 for %3
@ -485,6 +492,7 @@ select home email address common en Select home email address
select one common en Select one
select user common en Select user
select work email address common en Select work email address
selection common en Selection
send common en Send
senegal common en SENEGAL
september common en September
@ -515,6 +523,7 @@ spain common en SPAIN
sri lanka common en SRI LANKA
start date common en Start date
start time common en Start time
start with common en start with
status common en Status
strikethrough htmlarea en Strikethrough
subject common en Subject

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -2,28 +2,99 @@
<script LANGUAGE="JavaScript">
window.focus();
function addOption(id,label,value)
{
opener.addOption(id,label,value);
selectBox = document.getElementById('uiaccountsel_popup_selection');
for (i=0; i < selectBox.length; i++) {
if (selectBox.options[i].value == value) {
selectBox.options[i].selected = true;
break;
}
}
if (i >= selectBox.length) {
selectBox.options[selectBox.length] = new Option(label,value,false,true);
}
}
function removeSelectedOptions(id)
{
openerSelectBox = opener.document.getElementById(id);
selectBox = document.getElementById('uiaccountsel_popup_selection');
for (i=0; i < selectBox.length; i++) {
if (selectBox.options[i].selected) {
for (j=0; j < openerSelectBox.length; j++) {
if (openerSelectBox[j].value == selectBox.options[i].value) {
openerSelectBox[j].selected = false;
}
}
selectBox.options[i--] = null;
}
}
}
function copyOptions(id)
{
openerSelectBox = opener.document.getElementById(id);
if (openerSelectBox == null) window.close();
selectBox = document.getElementById('uiaccountsel_popup_selection');
for (i=0; i < openerSelectBox.length; i++) {
with (openerSelectBox.options[i]) {
if (selected) {
selectBox.options[selectBox.length] = new Option(text,value);
}
}
}
}
</script>
<div id="divMain" style="height: 520px">
<style type="text/css">
.letter_box,.letter_box_active {
background-color: #E8F0F0;
width: 15px;
border: 1px solid white;
text-align: center;
cursor: pointer;
cusror: hand;
}
.letter_box_active {
font-weight: bold;
background-color: #D3DCE3;
}
.letter_box_active,.letter_box:hover {
border: 1px solid black;
background-color: #D3DCE3;
}
</style>
<div id="divMain" style="height: 315px">
<table border="0" width="100%">
<tr>
<td colspan="4">
<table border="0" width="100%">
<tr>
{left}
<td align="center">{lang_showing}</td>
{right}
</tr>
</table>
<td width="20%" rowspan="3">{accountsel_icon}</td>
<td align="right" colspan="5">
<form method="POST" action="{search_action}">
{query_type}
<input type="text" name="query">
<input type="submit" name="search" value="{lang_search}">
</form>
</td>
</tr>
<tr>
<td width="100%" colspan="4" align="right">
<form method="POST" action="{search_action}">
<input type="text" name="query">&nbsp;<input type="submit" name="search" value="{lang_search}">
</form>
<td colspan="5">
<table width="100%"><tr>
<!-- BEGIN letter_search -->
<td class="{class}" onclick="location.href='{link}';">{letter}</td>
<!-- END letter_search -->
</tr></table>
</td>
</tr>
<tr>
{left}
<td align="center">{lang_showing}</td>
{right}
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
@ -86,16 +157,16 @@
</table>
</td>
<td width="80%" valign="top">
<td valign="top">
<table border="0" width="100%" cellpadding="2" cellspacing="2">
<tr class="th">
<td width="100%" class="th" align="center" colspan="4"><b>{lang_accounts}</b></td>
</tr>
<tr class="th">
<td width="30%" class="th" align="center">{sort_lid}</td>
<td width="30%" class="th" align="center">{sort_firstname}</td>
<td width="30%" class="th" align="center">{sort_lastname}</td>
<td width="10%" class="th">&nbsp;</td>
<td align="center">{sort_lid}</td>
<td align="center">{sort_firstname}</td>
<td align="center">{sort_lastname}</td>
<td width="10%">&nbsp;</td>
</tr>
<!-- BEGIN accounts_list -->
@ -115,9 +186,24 @@
</table>
</td>
<td valign="top">
<table border="0" width="100%" cellpadding="2" cellspacing="2">
<tr class="th">
<td align="center" colspan="2"><b>{lang_selection}</b> {remove}</td>
</tr>
<tr class="row_off">
<td align="center">
{selection}
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="button" name="close" value="{lang_close}" onClick="window.close()">
</td>
</tr>
</table>
</td>
</tr>
</table>
<p style="text-align: center">
<input type="button" name="Done" value="{lang_done}" onClick="window.close()">
</p>
</div>