#!/usr/bin/perl
# tta_sesstotal.cgi
# Display Services with Tarantella Sessions Counters
# STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo  --- license GNU GPL 
# stta: (@#) 1.31051043346- [2004_01_29_102036]

 require './stta-lib.pl';
 if ($access{'sessions'} ne 1 ) { &redirect("index.cgi"); }
 if ( $config{has_cronsess} ne "true" || $config{'totalsessout_file'} eq "" ) {
         &headerstta($text{'index_ttasess_total'}, "", "ttasess_total",undef,1,0,"$text{'headpage_right'}"."$text{'head_logout'}",undef,undef,"$text{head_below}" );
         $err_msg=$text{'nohastotalsess_err'};
         &footHere;
         exit;
 } 
 $ahora=&set_now();
 $ahora_str=set_datetime_str($ahora);
 $totalcounter_time="";
 %h_totalsess=&list_totalsess();
 $counter_time_str=set_datetime_str($totalcounter_time);
 $counter_times=get_datetime_str($counter_time_str);

 &headerstta($text{'index_ttasess_total'}, "", "ttasess_count",undef,1,0,"$text{'headpage_right'}"."$text{'head_logout'}",undef,undef,"$text{head_below}" );
 &ReadParse();  

 print "<table width=100% border>\n";
 print "<tr $tb> <td><font color='$revtext'><b>$text{'titidx_ttasess_total'}  $ahora </b></td> </tr>\n";
 print "<TR><TD><B>$text{l_ses_count} $text{'user_update'} $counter_time </B></TD><TR>\n";
#    print "<TR><TD><B>$aho - $con</B></TD><TR>\n";
#    print "<TR><TD><B>$counter_times - $counter_time_str</B></TD><TR>\n";
#    print "<TR><TD><B>$counter_time_str $ahora_str </B></TD><TR>\n";
#    if ( $counter_time_str gt $ahora_str ) {
#         print "<TR><TD><B>No actualizado </B></TD><TR>\n";
#    }
 print "</td></tr>\n";
 if ( !%h_totalsess) {
      $err_msg=$text{nosess_err};
      &footHere();
      exit;
 }
 print "<tr><td><table width=50%>\n";
 print "</b><TR $tb>\n";
 print "<TD><center><B>".$text{l_ses_object} . "</B></center></TD>\n";
 print "<TD><center><B>".$text{l_ses_num} . "</B></center></TD>\n";
 if ( $debug eq 2 ) {
            print "<TD><center><B> obj </B></center></TD>\n";
            print "<TD><center><B> objalias </B></center></TD>\n";
            print "<TD><center><B> alias </B></center></TD>\n";
            print "<TD><center><B> maxsess </B></center></TD>\n";
            print "<TD><center><B> objgrpalias </B></center></TD>\n";
            print "<TD><center><B> grpalias </B></center></TD>\n";
            print "<TD><center><B> name </B></center></TD>\n";
 }
 foreach $item (keys (%h_totalsess)) {
       if ($item ne "TOTAL" && $item ne ""  ) {
           $objdescrip=$h_totalsess{$item}->{'descrip'}; 
           print "<TR $cb>\n";
           print "<TD><A class=\"menu1\" href=\"javascript: alert('".$h_totalsess{$item}->{'name'};
           if ( $objdescrip ne $h_totalsess{$item}->{'alias'} ) { print " (".$objdescrip.")"; }
           print "')\">";
           $objdescrip=~s/ou=//g;     
           $objdescrip=~s/cn=//g;     
           print $objdescrip;
           print "</A></TD>\n";
           print "<TD>" . $h_totalsess{$item}->{'numsess'}."</TD>\n";
           if ( $debug eq 2 ) {
                print "<TD>" . $h_totalsess{$item}->{'obj'}."</TD>\n";
                print "<TD>" . $h_totalsess{$item}->{'objalias'}."</TD>\n";
                print "<TD>" . $h_totalsess{$item}->{'alias'}."</TD>\n";
                print "<TD>" . $h_totalsess{$item}->{'maxsess'}."</TD>\n";
                print "<TD>" . $h_totalsess{$item}->{'objgrpalias'}."</TD>\n";
                print "<TD>" . $h_totalsess{$item}->{'grpalias'}."</TD>\n";
                print "<TD>" . $h_totalsess{$item}->{'name'}."</TD>\n";
           }
           print "<\TR>\n";
      }
 }
 print "<TR $cb>\n";
 print "<TD>".$h_totalsess{"TOTAL"}->{'descrip'}."</A></TD>\n";
 print "<TD>" . $h_totalsess{"TOTAL"}->{'numsess'}."</TD>\n";
 print "<\TR>\n";
 print "<p></table>\n"; 
 print "<p></table>\n"; 
 print "<tr>\n";
 print "<tr>\n";
 print "<tr>\n";
 print "</table></table><p>\n";
 &footer($config{'back_return'},$text{'index'});
 print "<p><p><p>\n";
 do "footer.pl";
 exit;
