# $Id: person_cat_adm.pm,v 1.2 2004/11/12 05:45:23 gwolf Exp $
######################################
# Comas - Conference Management System
######################################
# Copyright 2003 CONSOL
# Congreso Nacional de Software Libre (http://www.consol.org.mx/)
#   Gunnar Wolf <gwolf@gwolf.cx>
#   Manuel Rabade <mig@mig-29.net>
#
# 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.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
######################################

######################################
# Module: Comas::HTML::committee::person_adm
# Attendee lookup/administration
######################################
# Depends on:
#

# This module is not meant to be called on its own, it should be called from
# Comas::HTML.

package Comas::HTML::committee::person_cat_adm;

use strict;
use warnings;
use Carp;

use Comas::Admin;
use Comas::Proposal;
use Comas::Person;
use Comas::HTML::common qw(:all);

use Data::FormValidator;
use HTML::FromText;

use Exporter;

our @ISA = qw(Exporter);
our @EXPORT_OK = qw( person_cat_adm_menu person_cat_adm_edit );
our %EXPORT_TAGS = (all => [@EXPORT_OK]);

=head1 NAME
    
Comas::HTML::committee::admin_mgr

=head1 SYNOPSIS

This module is not meant to be used by itself, but as an auxiliary to
L<Comas::HTML>. Please check L<Comas::HTML>'s documentation, in the
B<Front End Tasks> section, for further details on the usage for this functions.

=head1 SEE ALSO

L<Comas::HTML|Comas::HTML> module documentation

=head1 AUTHOR

Gunnar Wolf, gwolf@gwolf.cx

Manuel Rabade, mig@mig-29.net

Comas has been developed for CONSOL, Congreso Nacional de Software Libre,
http://www.consol.org.mx/

=head1 COPYRIGHT

Copyright 2003 Gunnar Wolf and Manuel Rabade

This library is free software, you can redistribute it and/or modify it
under the terms of the GPL version 2 or later.

=cut

sub person_cat_adm_menu {
    my ($h, $template, @catalogs, $admin);
    $h = shift;

    unless ($h->_ck_committee_task) {
	return $h->committee_menu('NOT_AUTHORIZED');
    }

    $template = $h->new_template('committee/person_cat_adm/menu.tmpl');

    $admin = Comas::Admin->new(-db => $h->{-db_adm},
			       %{$h->{-session}->{-admin}});

    for my $catalog ($admin->get_person_catalogs) {
	push @catalogs, {table => $catalog};
    }
    $template->param(catalogs => \@catalogs, show_cat => 1);

    return $template->output;
}

sub person_cat_adm_edit {
    my ($h, $catname, $template, %catdata, @rows);
    $h = shift;
    $catname = shift;

    unless ($h->_ck_committee_task) {
	return $h->committee_menu('NOT_AUTHORIZED');
    }

    $template = $h->new_template('committee/person_cat_adm/menu.tmpl');

    %catdata = $h->{-db_adm}->getCatalog($catname);
    for my $key (sort {$a<=>$b} keys %catdata) {
	push @rows, {id => $key, descr => $catdata{$key}};
    }

    $template->param(table => $catname, rows => \@rows, show_rows => 1);

    return $template->output;
}

1;

# $Log: person_cat_adm.pm,v $
# Revision 1.2  2004/11/12 05:45:23  gwolf
# Added the functionality to be able to handle more than one file per proposal and store it in the DB, not in separate files.
#
# Revision 1.1  2004/10/05 21:52:04  gwolf
# Person catalog administration HTML front-end - First revision, still incomplete
#
