<?php

/*************************************************************************\
* phpGroupWare app (Bookkeeping)                                          *
* http://www.phpgroupware.org                                             *
* Written by Rick Bakker <r.bakker@linvision.com>                         *
* --------------------------------------------                            *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the   *
* Free Software Foundation; either version 2 of the License, or (at your  *
* option) any later version.                                              *
\*************************************************************************/

/* $Id: admin.php,v 1.6 2001/05/21 22:09:38 darw1n Exp $ */

$phpgw_info['flags']['currentapp'] = 'bookkeeping';
$phpgw_info['flags']['enable_nextmatchs_class'] = True;
include('../header.inc.php');

$template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);

$template->set_file(array('admin' => 'admin.tpl'));
$template->set_block('admin', 'bk_admin_list', 'bk_admins');

$template->set_var('lang_app_title', lang('bookkeeping'));
$template->set_var('lang_title', lang('bookkeeping admins'));
$head_color = $phpgw_info['theme']['th_bg'];
$template->set_var('head_color', $head_color);
$template->set_var('lang_loginid', lang('loginid'));
$template->set_var('lang_lastname', lang('lastname'));
$template->set_var('lang_firstname', lang('firstname'));
$template->set_var('lang_delete', lang('delete'));
$template->set_var('actionurl', $phpgw->link('/bookkeeping/admin_add.php'));
$template->set_var('lang_add', lang('add bookkeeping admin'));

$phpgw->db->query("SELECT value FROM phpgw_bk_configuration WHERE name='admins' AND bookkeeping_id=0");
$phpgw->db->next_record();
$bk_admin = split(':', $phpgw->db->f('value'));
$phpgw->db->query("SELECT account_id,account_lid,account_firstname,account_lastname FROM phpgw_accounts WHERE account_status='A' AND account_type='u' ORDER BY account_lastname");
while($phpgw->db->next_record()) {
	for($j = 0; $j < count($bk_admin); $j++) {
		if($phpgw->db->f('account_id') == $bk_admin[$j]) {
			$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
			$template->set_var('tr_color', $tr_color);
			$template->set_var('loginid', $phpgw->db->f('account_lid'));
			$template->set_var('firstname', $phpgw->db->f('account_firstname'));
			$template->set_var('lastname', $phpgw->db->f('account_lastname'));
			$template->set_var('delete', '<a href="'.$phpgw->link('/bookkeeping/admin_delete.php','account_id='.$phpgw->db->f('account_id')).'">'.lang('delete').'</a>');
			$template->parse('bk_admins', 'bk_admin_list', true);
		}
	}
}

$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$template->set_var('tr_color_1', $tr_color);
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$template->set_var('tr_color_2', $tr_color);

$template->parse('out', 'admin', true);
$template->p('out');

$phpgw->common->phpgw_footer();

?>
