#!/usr/bin/perl
##########################################################################################
# Dash.pl is used for displaying passed variables more asthetically on a dashboard (car)##
# 25/06/2001 Gareth Kirwan, Thermeon Europe Ltd ##########################################
##########################################################################################
# Incoming variables are: ###
# ###################################################################################### #
# user= : This is the User (company) currently logged in and must be used more for our ###
# purposes than the customers. It is used on the get/post requests to Robert's ###
# scripts that quiz the carsplus database for the list of locations and the car###
# clases. It is also displayed on the dash for the user's amusement (!) ###
# ###################################################################################### #
# fleet= : The size of the fleet in total or the fleet at the location... or the class ###
# code fleet at the location... depending on which options have been chosen. ###
# ###################################################################################### #
# rent= : The number of vehicles on rent in the fleet ... or at the location ... or in ###
# a certain class (you get the idea!) ###
# ###################################################################################### #
# unavail= : The number of vehicles which are unvailable in the fleet ... location ... ###
# or in a class (right.... from now this is refered to as FLC... ok) #### ###################################################################################### #
# clocation= : The current location for which the FLC is being displayed. ###
# ###################################################################################### #
# cclass= : The current class for which the FLC is being displayed.
# ###################################################################################### #
# cdate= : The current date for which the FLC information is being displayed. This can ###
# either be now or month to date. ###
##########################################################################################
# Sub calling
##########################################################################################
# Get the Input and read it
&GetInput;
# end
# Set variables
&SetVars;
# end
# set the number of zeros to be used in the odometers and also to be called for
# calibrating the three (technically) needles on the dials
&Zerox;
##########################################################################################
# HTML is what follows mainly... although a little messy in places.
print "Content-type: text/html \n\n";
print "<html>";
print "<head>";
print "<title>Performance of $user</title>";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">";
if ($incr >= 5){
$diver = "1$addtoinc";
$muller = 270 / $diver;
}
elsif ($incr < 5 || (!$incr)){
$diver = "1$addtoinc";
$muller = 540 / $diver;
}
print "<SCRIPT language=javascript>\n
function both() {
if ($util > 120){
total = 225;
Rev.rotate(0,0,total);
}
else {
multiple = $util * 2.25;
total = multiple - 45;
Rev.rotate(0,0,total);
}
multipleb = $rent * $muller;
totalb = multipleb - 45;
Speed.rotate(0,0,totalb);
multiplec = $infleet * $muller;
totalc = multiplec - 45;
fleetsize.rotate(0,0,totalc);
}
</SCRIPT>";
print "</head>";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" onload=both(); topmargin=\"0\" leftmargin=\"0\">";
print "<div id=\"Util\" style=\"position:absolute; left:13px; top:31px; width:266px; height:134px; z-index:1\">";
print "<object id=\"Rev\" classid=\"CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6\" style=\"position:absolute;top:33px;left:309px;width:200px;height:200px\">";
print "<param name=\"Line0001\" value=\"setlinecolor(255,0,0)\">";
print "<param name=\"Line0002\" value=\"setfillcolor(255,0,0)\">";
print "<param name=\"Line0003\" value=\"Polygon(5, 0, 2, -85, 1, -85, -1, 0, -2, 0, 0)\">";
print "</object></div>";
if ($zchars){
if ($zchars < 4){
print "<div id=\"zerox\" style=\"position:absolute; left:145px; top:185px; width:50=px; height:16px; z-index:1\">";
print "<font face=\"palatino linotype\" size=\"2\" color=\"blue\"><center><b>";
print "1$zeros";
print "</b></center></font></div>";
}
else {
print "<div id=\"zerox\" style=\"position:absolute; left:145px; top:185px; width:50=px; height:16px; z-index:1\">";
print "<font face=\"palatino linotype\" size=\"2\" color=\"blue\"><center><b>";
print "10<sup>$zchars</sup>";
print "</b></center></font></div>";
}
}
else {
print "<div id=\"zerox\" style=\"position:absolute; left:130px; top:190px; width:25=px; height:25px; z-index:1\">";
print "<img src=\"../spacer.gif\" width=\"15\" height=\"10\">";
print "</div>";
}
print "<div id=\"stamping\" style=\"position:absolute; left:401px; top:207px; width:52px; height:16px; z-index:2\">";
print "<font color=\"white\" face=\"arial\" size=2><b>";
if ($uchars == "0" || ((!$unavail) && (!$unavail[0]))){
print "0 0 0 0";
}
else {
if ($uchars == 1){
print "0 0 0 @unavail";
}
if ($uchars == 2){
print "0 0 $unavail[0] $unavail[1]";
}
if ($uchars > 4){
print "9 9 9 9";
}
if ($uchars == 3){
print "0 $unavail[0] $unavail[1] $unavail[2]";
}
if ($uchars == 4) {
print "$unavail[0] $unavail[1] $unavail[2] $unavail[3]";
}
}
print "<b></font><center>";
print "</div>";
print "<div id=\"stamping\" style=\"position:absolute; left:126px; top:207px; width:52px; height:16px; z-index:3\">";
print "<font color=\"white\" face=\"arial\" size=2><b>";
print "<font color=\"white\" face=\"arial\" size=2><b>";
if ($fchars == "0" || ((!$fleet) && (!$fleet[0]))){
print "0 0 0 0 0";
}
else {
if ($fchars == "1"

{
print "0 0 0 0 $fleet";
}
if ($fchars == "2"

{
print "0 0 0 $fleet[0] $fleet[1]";
}
if ($fchars == "3"

{
print "0 0 $fleet[0] $fleet[1] $fleet[2]";
}
if ($fchars == "4"

{
print "0 $fleet[0] $fleet[1] $fleet[2] $fleet[3]";
}
if ($fchars == "5"

{
print "$fleet[0] $fleet[1] $fleet[2] $fleet[3] $fleet[4]";
}
if ($fchars > 6){
print "9 9 9 9 9";
}
}
print "<b></font><center>";
print "<b></font><center>";
print "</div>";
print "<div id=\"Rent\" style=\"position:absolute; left:13px; top:31px; width:266px; height:134px; z-index:3\">";
print "<object id=\"fleetsize\" classid=\"CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6\" style=\"position:absolute;top:33px;left:39px;width:200px;height:200px\">";
print "<param name=\"Line0001\" value=\"setlinecolor(0,255,0)\">";
print "<param name=\"Line0002\" value=\"setfillcolor(0,255,0)\">";
print "<param name=\"Line0003\" value=\"Polygon(4, -70, 1, -88, 1, -88, -1, -70, -1)\">";
print "</object></div><center>";
print "<div id=\"Rent\" style=\"position:absolute; left:13px; top:31px; width:266px; height:134px; z-index:4\">";
print "<object id=\"Speed\" classid=\"CLSID:369303C2-D7AC-11D0-89D5-00A0C90833E6\" style=\"position:absolute;top:33px;left:39px;width:200px;height:200px\">";
print "<param name=\"Line0001\" value=\"setlinecolor(255,0,0)\">";
print "<param name=\"Line0002\" value=\"setfillcolor(255,0,0)\">";
print "<param name=\"Line0003\" value=\"Polygon(5, 0, 2, -85, 1, -85, -1, 0, -2, 0, 0)\">";
print "</object></div><center>";
print "<div id=\"Rent\" style=\"position:absolute; left:270px; top:225px; width:35px; height:35px; z-index:5\">";
# print "<img src=\"../refreshon.gif\" name=\"refresh\" border=\"0\" onmouseover=document.refresh.src=\"../refreshoff.gif\" onmouseout=document.refresh.src=\"../refreshon.gif\" onclick=top.self.location=\"dash.cgi?$in&clocation=$nlocation\">";
print "<form method=\"post\" action=\"dash.cgi\">";
print "<input type=\"hidden\" name=\"clocation\" value=\"here\">";
print "<input type=image src=../refreshoff.gif>";
print "</form>";
print "</div>";
$temprent = $rentchars;
$overrent = $temprent--;
if ($overrent > 9) { $overrent = 9;}
if ($rentchars > 5){
$rentlcd = "$rents[0]x10<sup><font size=4>$overrent</font></sup>";
}
else { $rentlcd = $rent;}
if ($rentchars == 5){
print "<div id=\"Rentlcd\" style=\"position:absolute; left:53px; top:267px; width:55px; height:20px; z-index:6\">";
print "<font face=\"arial\" color=\"black\" size=5><b>";
print "$rentlcd";
print "</font></b></div>";
}
elsif ($rentchars > 5){
print "<div id=\"Rentlcd\" style=\"position:absolute; left:53px; top:266px; width:55px; height:20px; z-index:6\">";
print "<font face=\"arial\" color=\"black\" size=5><b>";
print "$rentlcd";
print "</font></b></div>";
}
else {
print "<div id=\"Rentlcd\" style=\"position:absolute; left:59px; top:267px; width:55px; height:20px; z-index:6\">";
print "<font face=\"arial\" color=\"black\" size=5><b>";
print "$rentlcd";
print "</font></b></div>";
}
print "<div id=\"utillcd\" style=\"position:absolute; left:466px; top:267px; width:55px; height:20px; z-index:6\">";
if ($util > 999){
print "<font face=\"arial\" color=\"black\" size=5><b>";
print "999\%";
print "</font></b></div>";
}
else {
print "<font face=\"arial\" color=\"black\" size=5><b>";
print "$util\%";
print "</font></b></div>";
}
${sinc} = "0";
if ($incr < 5){
${ainc} = "5";
${binc} = "10";
${cinc} = "15";
${dinc} = "20";
${einc} = "25";
${finc} = "30";
${ginc} = "35";
${hinc} = "40";
${iinc} = "45";
${jinc} = "50";
}
if ($incr >= 5){
${ainc} = "10";
${binc} = "20";
${cinc} = "30";
${dinc} = "40";
${einc} = "50";
${finc} = "60";
${ginc} = "70 ";
${hinc} = "80";
${iinc} = "90";
${jinc} = "100";
}
print "<div id=\"1inc\" style=\"position:absolute; left:84px; top:173px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${ainc}";
print "</font></b></div>";
print "<div id=\"0inc\" style=\"position:absolute; left:95px; top:198px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${sinc}";
print "</font></b></div>";
print "<div id=\"2inc\" style=\"position:absolute; left:83px; top:143px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${binc}";
print "</font></b></div>";
print "<div id=\"3inc\" style=\"position:absolute; left:95px; top:115px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${cinc}";
print "</font></b></div>";
print "<div id=\"4inc\" style=\"position:absolute; left:116px; top:98px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${dinc}";
print "</font></b></div>";
print "<div id=\"5inc\" style=\"position:absolute; left:143px; top:87px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${einc}";
print "</font></b></div>";
print "<div id=\"6inc\" style=\"position:absolute; left:169px; top:98px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${finc}";
print "</font></b></div>";
print "<div id=\"7inc\" style=\"position:absolute; left:189px; top:115px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${ginc}";
print "</font></b></div>";
print "<div id=\"8inc\" style=\"position:absolute; left:201px; top:142px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${hinc}";
print "</font></b></div>";
print "<div id=\"9inc\" style=\"position:absolute; left:202px; top:172px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${iinc}";
print "</font></b></div>";
print "<div id=\"10inc\" style=\"position:absolute; left:189px; top:197px; width:20px; height:20px; z-index:7\">";
print "<font face=\"palatino linotype\" color=\"black\" size=3><b>";
print "${jinc}";
print "</font></b></div>";
print "<div id=\"10inc\" style=\"position:absolute; left:240px; top:25px; width:150px; height:45px; z-index:9\" align=left>";
print "<font face=\"arial\" color=\"black\" size=1><b>";
print "Location: $clocation<br>";
print "Class: $cclass<br>";
print "Date: $cdate<br>";
use POSIX qw(strftime);
$time = strftime "%H:%M:%S", localtime;
print "Time: $time";
print "</font></div>";
print "<img src=\"../background.gif\" align=\"center\" border=\"0\"><br></body></html>";
##########################################################################################
# GetInput reads the incoming information and places it in associative arrays.
sub GetInput {
local (*in) = @_ if @_;
local ($i, $loc, $key, $val);
if ( $in_copy ) {
$in = $in_copy;
} elsif ($ENV{'REQUEST_METHOD'} eq "GET"

{
$in = $ENV{'QUERY_STRING'};
} elsif ($ENV{'REQUEST_METHOD'} eq "POST"

{
read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
} elsif ($ENV{'REQUEST_METHOD'} eq "STDIN"

{
$in = '';
while ( read(STDIN,$buffer,1024) )
{
$in .= $buffer;
}
} else {
$in=$ARGV[0];
}
$in_copy = $in unless ($in_copy);
@in = split(/&/,$in);
foreach $i (0 .. $#in) {
# Convert plus's to spaces
$in[$i] =~ s/\+/ /g;
# Convert %XX from hex numbers to alphanumeric
$in[$i] =~ s/%(..)/pack("c",hex($1))/ge;
# Split into key and value.
($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
$in{$key} = $val;
}
}
# end of GetInput
##########################################################################################
# Set vars associates more meaningful names with the incoming variables for the script
sub SetVars {
$clocation = $in{clocation};
$cclass = "All";
$cdate = "Today";
$user = $in{user};
$util = $in{util};
@utils = split(//, $util);
$utilchars = @utils."";
$rent = $in{rent};
@rents = split(//, $rent);
$rentchars = @rents."";
$infleet = $in{fleet};
@fleet = split(//, $infleet);
$fchars = @fleet."";
$inunavail = $in{unavail};
@unavail = split(//, $inunavail);
$uchars = @unavail."";
$chars = $fchars;
$incr = $fleet[0];
$nuchars = --$chars;
$multiple = --$nuchars;
}
# end of SetVars
##########################################################################################
# set the zeros for the odometers on divs stamping
sub Zerox {
if ($multiple == 0){$end = 1;}
until ($multiple == 0)
{
$i++;
$multiple--;
$zeros .= "0";
}
$dialnu = ++$chars;
until ($dialnu == 0)
{
$i++;
$dialnu--;
$addtoinc .= "0";
}
if (!$end){
if ($i == 1){$zchars = 1;}
else {
@numzero = split(//, $zeros);
$zchars = @numzero.""}
}
}
# end
#############################################