#!/usr/bin/perl
###################################################################################
#                                                                                 #
#                   PerlDesk - Customer Help Desk Software                        #
#                                                                                 #
###################################################################################
#                                                                                 #
#     Author: John Bennett	                                                  #
#      Email: j.bennett@perldesk.com                                              #
#        Web: http://www.perldesk.com                                             #
#   Filename: staff.cgi                                                           #
#    Details: The main staff file                                                 #
#    Release: 1.5.5                                                               #
#                                                                                 #
###################################################################################
# Please direct bug reports,suggestions or feedback to the perldesk forums.       #
# www.perldesk.com/board                                                          #
#                                                                                 #
# PerlDesk is free for both commercial and non-commercial use providing that the  #
# copyright headers remain intact and the links remain on the html pages.         #
# Re-distribution of this script without prior consent is strictly prohibited.    # 
#                                                                                 #
###################################################################################
# Please see the README/INSTALL files if you have any problems with this software #                                                            
################################################################################### 
 use CGI qw(:standard);                                 
 use DBI();                                             
 use Digest::MD5;   

 require "/var/www/agenda/cgi-bin/desk/include/pd.cgi";
 require "/var/www/agenda/cgi-bin/desk/include/conf.pl";

 
eval {
   $dbh      =  DBI->connect("DBI:mysql:$dbname:$dbhost","$dbuser","$dbpass") or script_error("Could not connect to the help desk database");
   %global   =  get_vars();                                    
   $q        =  CGI->new();                         

   &get_time();

   my $lang = $q->param('language');        # Get the language choice, or set it 
      $lang ?                               # as the default.
           $language = $lang :             
           $language = $global{'language'};  

    require "include/staff_subs.cgi";       # Get the Required Files  
    require "include/lang/$language.inc";   # Get the specified lang file
    require "include/parse/staff.cgi";      # The template parsing 
    navigate();                             # Run the program

    $dbh->disconnect;
};

if ($@) {                                               
    script_error("$@");
    exit;
}                                                       


sub navigate {               
        $action = $q->param('action');
	    if ($action)
            {
                check_user();
                print "Content-type: text/html\n\n";
                function("$action");
            }
        else {
            section($q->param('do')) if  defined $q->param('do');
           
            if (!$q->param('do'))
            {
                section("login");
            }
        }
      exit;	
 }



