package TTXOpers;
#
# This module is a part of Trouble Ticket Express package
# http://www.troubleticketexpress.com
#
# COPYRIGHT: 2002-2006, United Web Coders
# http://www.unitedwebcoders.com
#
# $Revision: 224 $
# $Date: 2006-07-24 11:32:24 -0400 (Mon, 24 Jul 2006) $
#

$TTXOpers::VERSION='2.22';
BEGIN {
  $TTXOpers::REVISION = '$Revision: 224 $';
  if ($TTXOpers::REVISION =~ /(\d+)/) {
    $TTXOpers::REVISION = $1;
  }
};

use strict;
use TTXUser;

# ===================================================================== selector

sub selector {
  my ($cfg, $query, $data) = @_;
  $data->{OPERSELSTD} = '<tr><td align=right class=lbl>[%Assign to%]</td>'."\n<td align=left>";
  $data->{OPERSEL} = "<select name=oper>\n".'<option value="">-- [%please select%] --</option>'."\n".
                     "<option value=\"-\"";
  $data->{OPERSEL} .= ' selected' if $query->param('oper') eq '-';
  $data->{OPERSEL} .= '>-- [%any operator%] --</option>'."\n";
  my @operlist = TTXUser::list();
  my %operinfo;
  foreach my $id (@operlist) {
    my $u = TTXUser->new($id);
    next if $u eq undef;
    $operinfo{$id} = $u;
  }
  foreach my $id (sort {uc($operinfo{$a}->{lname}) cmp uc($operinfo{$b}->{lname})} keys %operinfo) {
    my $oper = $operinfo{$id}->{fname}.' '.$operinfo{$id}->{lname};
    next if $oper eq undef || $oper eq '';
    $oper =~ s/</&quot;/g;
    $data->{OPERSEL} .= "<option value=\"$id\"";
    $data->{OPERSEL} .= ' selected' if $query->param('oper') eq $id;
    $data->{OPERSEL} .= ">$oper</option>\n";
  }
  $data->{OPERSEL} .= '</select>';
  $data->{OPERSELSTD} .= $data->{OPERSEL} . "</td></tr>\n";
}

1;
#
