#!/bin/bash
#
#
# BUGGER_Plugin
#
#
# Script to display project listing outside BUGGER. 
#
# You should call this script from within a template 
# so that the page is formatted to your liking!
#
# 



# Set this to the path to your cgi-bin directory
CGIROOT="/mnt/.apacheroot/www/localhost/cgi-bin"





echo Content-Type: text/html
echo


# Grab BUGGER config

# Grab our config
"$CGIROOT"/Projects/BUGGER_config.sh imascript /tmp/Website.front_page_process.conf.$$

source /tmp/Website.front_page_process.conf.$$
rm -f /tmp/Website.front_page_process.conf.$$ 2> /dev/null




# Grab Data Project Details

wget -q -O /tmp/.Website.projlist.$$ "http://$DATABASE_SERVER/cgi-bin/Claims_DB_listener.sh?USER=$DBUSERNAME&PASS=$DBPASS&METHOD=4&DBNAME=Bugs&TABLE=Projects&QCOL=7&QSTRING=Y"


# Response speed is currently reasonable, adding the request involved in caching would slow things down. Can be added at a later date if necessary.





/bin/cat << EOM
<br>
<table width="100%">
<tbody>

<tr>
<td><b><center>Project Name</b></center></td>
<td><b><center>Development Started</b></center></td>
<td><b><center>Development Ended</b></center></td>
<td><b><center>Description</b></center></td>
</tr>
EOM


while read -r a
do

echo "$a" > /tmp/.BUGGER.projlist.lbl.$$

PROJECT_ID=$( cat /tmp/.BUGGER.projlist.lbl.$$ | awk -F\, '{print $1}' | sed s/\"//g )
PROJECT_NAME=$( cat /tmp/.BUGGER.projlist.lbl.$$ | awk -F\, '{print $2}' | sed s/\"//g )
DEV_START=$( cat /tmp/.BUGGER.projlist.lbl.$$ | awk -F\, '{print $3}' | sed s/\"//g )
DEV_END=$( cat /tmp/.BUGGER.projlist.lbl.$$ | awk -F\, '{print $4}' | sed s/\"//g )
DESCRIPTION=$( cat /tmp/.BUGGER.projlist.lbl.$$ | awk -F\, '{print $5}' | sed s/\"//g | sed s/%2C/\,/g )
MAINTAINER=$( cat /tmp/.BUGGER.projlist.lbl.$$ | awk -F\, '{print $6}' | sed s/\"//g )



/bin/cat << EOM
<tr>
<td><font size="-1"><center><b><a href="/BUGGER/Project_summary.shtml?USERNAME=$USERNAME&PROJ=$PROJECT_ID" target=_blank>$PROJECT_NAME</a></b></font></center></td>
<td><font size="-1"><center>$DEV_START</font></center></td>
<td><font size="-1"><center>$DEV_END</font></center></td>
<td><font size="-1">$DESCRIPTION</font></td>
</tr>
<tr>
<td><br>
</td></tr>
EOM




done < /tmp/.Website.projlist.$$


/bin/cat << EOM
</tbody>
</table>
<br>
EOM

