#!/usr/local/bin/perl

##########################################################
# report2.pl by Mike Moxcey #
# Second try at displaying data for Oracle/Perl tutorial #
# This one accepts passed in parameters #
##########################################################

$| = 1; # prevents forking so stuff is printed in correct order

############################################
# Define include files #
############################################

require "cgi-lib.pl"; #ReadParse
require "oracle.pl"; #&sql,fix_string
require "oratut.pl";
&ReadParse (*input);
$call_type = $input{'call_type'}; # open,closed

########
# main #
########

if ($call_type eq "closed") {
$get_call="where close_date is not null";
$prn_type="Closed Calls";
}
else {
$get_call="where close_date is null";
$prn_type="Open Calls";
}

print &PrintHeader;
print &HtmlTopTut("$prn_type in Database");
print <<EOM;
<table border>
<tr><th>ID Nr
</th><th>Pri
</th><th>Date
</th><th>Time
</th><th>Name
</th><th>Email
</th><th>Problem
</th></tr>
EOM

@sql_show = <<ENDOFSQL;
select
'<tr><td>', seq,
'</td><td>', priority,
'</td><td>', open_date,
'</td><td>', to_char(open_date,'HH:MI PM'),
'</td><td>', name,
'</td><td>', email,
'</td><td>',substr(problem,1,30),
'</td></tr>'
from oratut.calls $get_call;
ENDOFSQL

##DEBUG print "SQLShow:@sql_show!";
&sql($sql_login,@sql_show);

print "</table>";
print &HtmlBotTut;


home