#### Set constants so we don't have to goto database for this stuff everytime...
@revenue = ('$50k to $100k', '$100k to $500k', '$500k to $1MM', '$1MM to $5MM', 'Over $5MM');
@employees = ('1 to 5', '5 to 10', '10 to 50', '50 to 100', '100 to 500', 'Over 500');

#################################################
sub printRightColumn() {

	showFeaturedEntrepreneur();

	print qq~
        $DIVIDER


        <table width=100% class=data cellpadding=4>
        <tr><th class=left> Entrepreneurial Resources</th></tr>
        <tr><td bgcolor=ffffee>
		&nbsp;<b>-&gt;</b>
		<a href=bizMain.cgi>Business Home</a><br>
		&nbsp;<b>-&gt;</b>
		<a href=bizMain.cgi?process_search=1>Browse Businesses</a><br>
		&nbsp;<b>-&gt;</b>
		<a href=bizMain.cgi?add=1>List A Business</a><br>
		&nbsp;<b>-&gt;</b>
		<a href=bizMain.cgi?edit=list>Edit Your Listing(s)</a><br>
		&nbsp;<b>-&gt;</b>
		<a href=entrepreneurs.cgi?process_search=1>Browse Entrepreneurs</a><br>
		&nbsp;<b>-&gt;</b>
		<a href=entrepreneurs.cgi?add=1>Be Featured!</a><br>
        </td></tr></table>


        $DIVIDER
        ~;
        showFeaturedBusiness();        print qq~

        $DIVIDER


        <table width=100% class=data cellpadding=4>
        <tr><th class=left> New Business Listings</th></tr>

	~;
	$sql = "SELECT * from biz_listings ORDER BY biz_id desc LIMIT 0,15";
	$sth = $dbh->prepare($sql);
	$sth->execute();

	while ($hash = $sth->fetchrow_hashref()) {
		print qq~
        	<tr><td style=font-family:tahoma;font-size:10>
                <b>-&gt;</b>
                <a href=bizMain.cgi?biz_id=$hash->{biz_id}>$hash->{biz_name}</a>
		</td></tr>
		~;
	}

	print qq~
        </table>

	$DIVIDER


        <table width=100% class=data cellpadding=4>
        <tr><th class=left> New Entrepreneur Listings</th></tr>

	~;
	$sql = "SELECT * from registry_data as a, biz_profiles as b WHERE a.registry_id=b.member_id
		ORDER BY member_id desc LIMIT 0,15";
	$sth = $dbh->prepare($sql);
	$sth->execute();

	while ($hash = $sth->fetchrow_hashref()) {
		print qq~
        	<tr><td style=font-family:tahoma;font-size:10>
                <b>-&gt;</b>
                <a href=entrepreneurs.cgi?member_id=$hash->{member_id}>$hash->{name}</a>
		</td></tr>
		~;
	}

	print qq~
        </table>


        $DIVIDER



        ~;

}

sub showFeaturedBusiness() {

   
    #### Grab next featured biz from database
    $sql = "SELECT * from biz_listings WHERE feature_queue=1 AND feature_expiration>curdate()
                ORDER BY biz_id desc";
    $sth = $dbh->prepare($sql);
    $sth->execute();
    $hash = $sth->fetchrow_hashref();
    if (!$hash) {
        $sth = $dbh->prepare("UPDATE biz_listings set feature_queue=1 WHERE feature_expiration>curdate()");
        $sth->execute();

        $sql = "SELECT * from biz_listings WHERE feature_queue=1 AND feature_expiration>curdate()
                ORDER BY biz_id desc";
        $sth = $dbh->prepare($sql);
        $sth->execute();
        $hash = $sth->fetchrow_hashref();
    }

    $sth = $dbh->prepare("UPDATE biz_listings set feature_queue=0 WHERE biz_id=?");
    $sth->execute($hash->{biz_id});


    print qq~
        <table width=100% class=data><form name=roger action=none.cgi>
        <tr><th class=left> Featured Business</th></tr>
        <tr><td class=left>
                <a href="bizMain.cgi?biz_id=$hash->{biz_id}">
                <img src="bizMain.cgi?img=1&biz_id=$hash->{biz_id}"
                width=60 height=60 align=left border=0></a>
                <font class=small_text>
                <b>$hash->{biz_name}:</b>
                <a href=bizMain.cgi?biz_id=$hash->{biz_id} style=color:black;text-decoration:none;font-weight:normal>
		$hash->{brief_promo}</a>
        </td></tr></form></table>
    ~;
}

sub showFeaturedEntrepreneur() {

   
    #### Grab next featured profile from database
    $sql = "SELECT * from biz_profiles as a,registry_data as b
	 WHERE a.member_id=b.registry_id and feature_queue=1 and photo<>''
                ORDER BY member_id desc";
    $sth = $dbh->prepare($sql);
    $sth->execute();
    $hash = $sth->fetchrow_hashref();

    if (!$hash) {
        $sth = $dbh->prepare("UPDATE biz_profiles set feature_queue=1");
        $sth->execute();

        $sql = "SELECT * from biz_profiles as a, registry_data as b
		WHERE a.member_id=b.registry_id AND feature_queue=1 and photo<>''
                ORDER BY member_id desc";
        $sth = $dbh->prepare($sql);
        $sth->execute();
        $hash = $sth->fetchrow_hashref();
    }

    $tsth = $dbh->prepare("UPDATE biz_profiles set feature_queue=0 WHERE member_id=?");
    $tsth->execute($hash->{member_id});


    print qq~
        <table width=100% class=data><form name=roger action=none.cgi>
        <tr><th class=left> Featured Entrepreneur!</th></tr>
        <tr ><td class=left>
                <a href="$CGI_URL/biz/entrepreneurs.cgi?member_id=$hash->{member_id}">
		<img src="entrepreneurs.cgi?img=1&member_id=$hash->{member_id}" 
		width=60 height=60 align=left border=0></a>
		<a href=$CGI_URL/biz/entrepreneurs.cgi?member_id=$hash->{member_id}
		style=font-weight:normal;color:black;text-decoration:none;>
                <font class=small_text>
                <b>$hash->{first_name} $hash->{last_name}:</b>
                $hash->{brief_promo}</a> 
        </td></tr></form></table>
    ~;
}

