#!/usr/bin/perl

require "config.idx";

$long = $ENV{'QUERY_STRING'};

if ($long) {
	@pairs=split(/&/,$long);
	foreach $item(@pairs) {
		($name,$content)=split (/=/,$item,2);
		$content=~tr/+/ /;
		$content=~ s/%(..)/pack("c",hex($1))/ge;
		if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$content; }
		else { $INPUT{$name} = $content; }
	}
}
else {
	read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
	@pairs = split(/&/, $buffer);
	foreach $pair (@pairs) {
		($name, $value) = split(/=/, $pair);
		$value =~ tr/+/ /;
		$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
		if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}.",".$value; }
		else { $INPUT{$name} = $value; }
	}
}

&checklogin;

if ($INPUT{action} eq "create_prospect") { &create_prospect; }
elsif ($INPUT{action} eq "create_prospect_verify") { &create_prospect_verify; }
elsif ($INPUT{action} eq "create_prospect_do") { &create_prospect_do; }
elsif ($INPUT{action} eq "overview_prospect_notes_show") { &overview_prospect_notes_show; }
elsif ($INPUT{action} eq "overview_documents_prospect") { &overview_documents_prospect; }
elsif ($INPUT{action} eq "overview_prospects_smallaz") { &overview_prospects_smallaz; }
elsif ($INPUT{action} eq "overview_prospect") { &overview_prospect; }
elsif ($INPUT{action} eq "overview_prospect_print") { &overview_prospect_print; }
elsif ($INPUT{action} eq "overview_prospect_delete") { &overview_prospect_delete; }
elsif ($INPUT{action} eq "overview_prospect_edit") { &overview_prospect_edit; }
elsif ($INPUT{action} eq "overview_prospect_doedit") { &overview_prospect_doedit; }
elsif ($INPUT{action} eq "overview_prospect_convert") { &overview_prospect_convert; }
elsif ($INPUT{action} eq "upload_document") { &upload_document; }
elsif ($INPUT{action} eq "document_progress") { &document_progress; }
elsif ($INPUT{action} eq "overview_prospects_linked") { &overview_prospects_linked; }
else { &main; }

sub overview_prospect_print {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;


my $basth = $dbh->prepare("select id,agent,type,firstname,lastname,address,spouse,city,state,zip,phone1type,phone1number,phone2type,phone2number,phone3type,phone3number,faxnumber,email,emailtwo,contacttype,DATE_FORMAT(initial_contactdate, '%M %D, %Y at %h\:%i%p'),DATE_FORMAT(last_contactdate, '%b %D, %Y'),DATE_FORMAT(next_contactdate, '%b %D, %Y'),source,notes from trans_boardprospect WHERE id = '$INPUT{prospectid}'");
$basth->execute;

while (($id,$agent,$type,$firstname,$lastname,$address,$spouse,$city,$state,$zip,$phone1type,$phone1number,$phone2type,$phone2number,$phone3type,$phone3number,$faxnumber,$email,$emailtwo,$contacttype,$initial_contactdate,$last_contactdate,$next_contactdate,$source,$notes) = $basth->fetchrow_array()) {


unless ($last_contactdate) {
$last_contactdate = "<font color=\"Red\">Not Entered</font>";
}

unless ($next_contactdate) {
$next_contactdate = "<font color=\"Red\">Not Entered</font>";
}

unless ($city eq "") {
$check_city = "$city";
}

unless ($state eq "") {
$check_state = "$state";
}

unless ($address eq "") {
$check_address = "<br><b>Address</b><br>$address";
}

unless ($zip eq "0") {
$check_zip = "$zip";
}

unless ($email eq "") {
$check_email = "<b>E-Mail</b> $email";
}

if ($spouse ne "") {
$spouse = " & $spouse ";
}
else {
$spouse = "";
}

print qq~
<html>
<head>
<title>My Prospect Overview -- Eagle Real Estate, Inc. - Connect.EagleSold.com</title>
</head>
<body bgcolor="white">
<center>
<table border="2" cellpadding="0" cellspacing="0" width="723">
<tr>
<td valign="top" width="100%">
<center>
<img src="images/prospect_header.jpg" alt=""><br>
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td valign="top">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font face="Tahoma" size="2"><b>Inquire Time: $initial_contactdate</b></font><br></td>
</tr>
</table>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<td valign="top">

<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td valign="top">
<img src="images/contacts_icon.gif" alt="$firstname$spouse $lastname">
</td>
<td valign="top" width="100%">
<font size="4" face="Tahoma"><b>$firstname$spouse $lastname</b><br></font>
<font size="3" face="Tahoma">

<b>$phone1type</b> $phone1number<br>
<b>$phone2type</b> $phone2number<br>
<b>$phone3type</b> $phone3number<br>
$check_email<br>
$check_address<br>
$check_city $check_state $check_zip
</font>
</td>
</tr>
</table>
</td>
<td valign="top">
<font size="4" face="Tahoma">
<b>Agent Assigned</b><br>
<i>
~;
my $iasth = $dbh->prepare("select agentid,mlsid,firstname,lastname,image,title,phone2name,phone2number from agents where mlsid = '$agent' order by lastname desc LIMIT 0,1");
$iasth->execute;
while (($agentid,$mlsid,$firstname,$lastname,$image,$title,$phone2name,$phone2number) = $iasth->fetchrow_array()) {
print qq~
	$firstname $lastname<br>
~;
}
print qq~
</i><br>
<br>
<b>Referal Source</b><br>
<i>$source</i><br>
</font>
</td>
</tr>
</table>
<br><br>

<table border="0" cellpadding="2" cellspacing="3" width="100%">
<tr>
<td valign="top" width="50%" bgcolor="navy"><font color="white" face="Tahoma"><b>Listing(s) Prospect Inquired About<br></b></font></td>
<td valign="top" width="50%" bgcolor="navy"><font color="white" face="Tahoma"><b>Prospect Note(s)<br></b></font></td>
<tr>
<td valign="top" width="50%">
~;

my $asth = $dbh->prepare("select transid,prospectid from trans_boardtranstoprospect where prospectid = '$INPUT{prospectid}'");
$asth->execute;
	while (($transid,$prospectid) = $asth->fetchrow_array()) {
		
		my $aasth = $dbh->prepare("select id,mlsnumber,addressnumber,addressdirection,addressstreet,city from trans_board where id = '$transid' GROUP BY mlsnumber ORDER BY addressstreet asc");
		$aasth->execute;
		while (($id,$mlsnumber,$addressnumber,$addressdirection,$addressstreet,$city) = $aasth->fetchrow_array()) {	
			print qq~<font face="tahoma" size="3">
				<b>MLS\# $mlsnumber - $addressnumber $addressdirection $addressstreet, $city</b><br>
				</font>			
			~;
		$found = "yes";
		}
	}

unless ($found eq "yes") {
print qq~
<font color="red" face="Tahoma"><b>Not linked to any listings!</b></font><br>
~;
}
print qq~
</td>
<td valign="top" width="50%">$notes ~; 


my $cbasth = $dbh->prepare("select noteid,prospectid,DATE_FORMAT(datetime, '%b %D, %Y at %h\:%i%p'),addedby,note from trans_boardprospectnotes WHERE prospectid = '$INPUT{prospectid}' ORDER by datetime DESC");
$cbasth->execute;

while (($noteid,$nprospectid,$datetime,$addedby,$tnote) = $cbasth->fetchrow_array()) {
	print qq~
	$tnote $datetime added by $addedby | 
	~;
	$notes_found = "yes";
}
unless ($notes_found eq "yes") {
print qq~
<font color="red" face="Tahoma"><b>No Notes Added!</b></font><br>
~;
}

print qq~</td>
</tr>
</table>
<br><br>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="98%" id="AutoNumber1">
  <tr>
    <td width="100%"><font face="Tahoma">&nbsp;Agent Comments:<br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
&nbsp;</font></td>
  </tr>
</table>
<br><br>
</center>
</td>
</tr>
</table>
</center>
<script language="JavaScript" type="text/javascript">
<!--

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1);

function printWin()
{
    if (pr) {
        // NS4+, IE5+
        window.print();
    } else if (!mac) {
        // IE3 and IE4 on PC
        VBprintWin();
    } else {
        // everything else
        handle_error();
    }
}

function handle_error()
{
    window.alert('Your browser does not support this print option. Press Control/Option + P to print.');
    return true;
}

// -->
</script>

<script language="VBSCript" type="text/vbscript">
<!--

sub window_onunload
    on error resume next
    ' Just tidy up when we leave to be sure we aren't
    ' keeping instances of the browser control in memory
    set WB = nothing
end sub

sub VBprintWin
    OLECMDID_PRINT = 6
    on error resume next

    ' IE4 object has a different command structure
    if da then
        call WB.ExecWB(OLECMDID_PRINT, 1)
    else
        call WB.IOleCommandTarget.Exec(OLECMDID_PRINT, 1, "", "")
    end if
end sub

' -->
</script>

<script language="JavaScript" type="text/javascript">
<!--
printWin();
// -->
</script>
</body>
</html>
~;
}

}


sub overview_prospects_linked {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

if ($INPUT{do} eq "delete") {
	@cvariables = ($INPUT{prospectid},$INPUT{transid});
	$csql_query = "DELETE FROM trans_boardtranstoprospect WHERE prospectid = ? AND transid = ?";
	my $caasth = $dbh->do($csql_query, undef, @cvariables);
}


if ($INPUT{do} eq "add") {
	@variables = ($INPUT{transid},$INPUT{prospectid});
	$sql_query = "INSERT INTO trans_boardtranstoprospect values (?,?)";
	my $zzaasth = $dbh->do($sql_query, undef, @variables);
}

print qq~
<html>
<head>
<title></title>
<link rel="stylesheet" TYPE="text/css" href="includes/style.css">
</head>
<body bgcolor="white">
<b>Currently linked to the following listing(s)</b><br><br>
~;

my $asth = $dbh->prepare("select transid,prospectid from trans_boardtranstoprospect where prospectid = '$INPUT{prospectid}'");
$asth->execute;
	while (($transid,$prospectid) = $asth->fetchrow_array()) {
		
		my $aasth = $dbh->prepare("select id,addressnumber,addressdirection,addressstreet,city from trans_board where id = '$transid' GROUP BY mlsnumber ORDER BY addressstreet asc");
		$aasth->execute;
		while (($id,$addressnumber,$addressdirection,$addressstreet,$city) = $aasth->fetchrow_array()) {	
			print qq~
				<a href="prospectadmin.idx?action=overview_prospects_linked&do=delete&prospectid=$prospectid&transid=$transid"><img src="images/trans_sys/button_delete.gif" alt="Delete prospect" border="0"></a>  $addressnumber $addressdirection $addressstreet,$city<br>
			~;
		$found = "yes";
		}
	}

unless ($found eq "yes") {
print qq~
<font color="red" face="Tahoma"><b>Prospect not linked to listings yet!</b></font><br>
~;
}
print qq~
</body>
</html>
~;

}

sub upload_document {

if ($INPUT{cat} eq "c") {
$upload_for = "contact";
}
elsif ($INPUT{cat} eq "p") {
$upload_for = "prospect";
}
else {
$upload_for = "Transaction";
}

print qq~<b>Upload New $upload_for Document</b>
<br><br>
<FORM action="upload_doc.idx" encType=multipart/form-data method=post>
<input type=hidden name=matchid value="$INPUT{id}">
<input type=hidden name=matchcat value="$INPUT{cat}">
Title: <input type=text name=name size=34><br>
File: <INPUT name=FILE1 type=file> <br>
<INPUT type=submit value=" Upload File ">
</form>
~;


}

sub overview_documents_prospect {

$show_icon{pdf} = qq~<img src="http://connect.eaglesold.com/documents/small-pdf-icon.gif" alt="PDF Document">~;
$show_icon{doc} = qq~<img src="http://connect.eaglesold.com/documents/small-word-icon.jpg" alt="Microsoft Word Document">~;
$show_icon{jpg} = qq~<img src="http://connect.eaglesold.com/documents/small-jpg-icon.jpg" alt="JPG Photo">~;

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

my $basth = $dbh->prepare("select * from documents where matchid = '$INPUT{prospectid}' and matchcat = 'p' ORDER BY dateadded DESC");
$basth->execute;

while ($data_ref = $basth->fetchrow_hashref()) {
%documents = %$data_ref;

$doc_ext = $documents{newfileext};

$show_docs .= qq~	$show_icon{$doc_ext} <a href="http://connect.eaglesold.com/documents/$documents{did}.$documents{newfileext}" target="_blank">$documents{name}</a><br>Added $documents{dateadded}<br>~;
$found = "yes";
}


print qq~
<html>
<head>
<title>Transaction Report -- Eagle Real Estate, Inc. - Connect.EagleSold.com</title>
<link rel="stylesheet" TYPE="text/css" href="includes/style.css">
<body bgcolor="white" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<table border="0" cellpadding="4" cellspacing="0" width="100%">
<tr>
<td valign="top">
~;
unless ($found eq "yes") {
print qq~
<font color="red"><b>No Documents have been uploaded yet!</b></font>
~;
}
else {
print qq~
$show_docs
~;
}
print qq~
</td>
</tr>
</table>
</body>
</html>
~;
}

sub overview_prospect_edit {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

my $aaasth = $dbh->prepare("select id,agent,firstname,lastname,address,spouse,city,state,zip,phone1type,phone1number,phone2type,phone2number,phone3type,phone3number,faxnumber,email,emailtwo,contacttype,initial_contactdate,last_contactdate,next_contactdate,source,notes from trans_boardprospect WHERE id = '$INPUT{prospectid}'");
$aaasth->execute;

while (($id,$agent,$firstname,$lastname,$address,$spouse,$city,$state,$zip,$phone1type,$phone1number,$phone2type,$phone2number,$phone3type,$phone3number,$faxnumber,$email,$emailtwo,$contacttype,$initial_contactdate,$last_contactdate,$next_contactdate,$source,$notes) = $aaasth->fetchrow_array()) {

if ($initial_contactdate eq "0000-00-00") {
$initial_contactdate = "";
}

if ($last_contactdate eq "0000-00-00") {
$last_contactdate = "";
}

if ($next_contactdate eq "0000-00-00") {
$next_contactdate = "";
}

if ($zip eq "0") {
$zip = "";
}

(@db_contacttypes) = split(/\,/, $contacttype);
foreach $ctype (@db_contacttypes) {
$checked_ctypes{$ctype} = "checked";
}

$getstate = "<option value=\"$state\">$state</option>";
$getstate .= "<option value=\"\">--------</option>";

$getphone1type = "<option value=\"$phone1type\">$phone1type</option>";
$getphone1type .= "<option value=\"\">--------</option>";

$getphone2type = "<option value=\"$phone2type\">$phone2type</option>";
$getphone2type .= "<option value=\"\">--------</option>";

$getphone3type = "<option value=\"$phone3type\">$phone3type</option>";
$getphone3type .= "<option value=\"\">--------</option>";

$getemailtwo = "<option value=\"$emailtwo\">$emailtwo</option>";
$getemailtwo .= "<option value=\"\">--------</option>";

$get_source = "<option value=\"$source\">$source</option>";
$get_source .= "<option value=\"\">--------</option>";

print qq~
<html>
<head>
<title>Edit Prospect -- Eagle Real Estate, Inc. - Connect.EagleSold.com</title>
~;

&header;


print qq~

<td valign="top" width="581">
<script language="JavaScript" src="calendar1.js"></script>
<img src="images/headers/transaction_manager.gif" height="33" width="581" alt="My Transaction Manager"><br><br>
<img src="images/trans_sys/my_prospects.gif" alt="Edit prospect"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Edit the information below to edit your prospect</b><br><br>
<form method="post" name="econtact" action="prospectadmin.idx">
<input type="hidden" name="action" value="overview_prospect_doedit">
<input type="hidden" name="prospectid" value="$INPUT{prospectid}">
<input type="hidden" name="agent" value="$INPUT{agent}">

	<table border="0" width="500" cellpadding="3" cellspacing="1">	
	<tr>
	<td valign="top"><b>Prospect Information</b></td>
	<td valign="top"><b>Firstname</b><br>
	<input type="text" name="firstname" value="$firstname" class="form"><br>
	<b>Spouse Name</b><br>
	<input type="text" name="spouse" value="$spouse" class="form"><br>
	<b>Lastname</b><br>
	<input type="text" name="lastname" value="$lastname" class="form"><br>
</td>
	</tr>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Current Address</b></td>
	<td valign="top">
		<b>Address</b><br>
		<input type="text" name="address" value="$address" size="40" class="form"><br>
		<b>City</b><br>
		<input type="text" name="city" value="$city" size="12" class="form"><br>
		<b>State</b><br>
		<select name="state" class="form">$getstate<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option> 
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="District of Columbia">District of Columbia</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana" selected>Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Mississippi">Mississippi</option>
<option value="Missouri">Missouri</option>
<option value="Montana">Montana</option>
<option value="Nebraska">Nebraska</option>
<option value="Nevada">Nevada</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="New York">New York</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Vermont">Vermont</option>
<option value="Virgin Islands">Virgin Islands</option>
<option value="Virginia">Virginia</option>
<option value="Washington">Washington</option>
<option value="West Virginia">West Virginia</option>
<option value="Wisconsin">Wisconsin</option>
<option value="Wyoming">Wyoming</option></select><br>
<b>Zip</b><br><input type="text" name="zip" size="5" value="$zip" class="form">
	</td>
	</tr>
	<tr>
	<td bgcolor="white"><b>Phone 1 Type</b><br>
	</td>
	<td bgcolor="white">
		<select name="phone1type" class="form">
		$getphone1type
		<option value="">-- No Number --</option>
		<option value="Home">Home</option>
		<option value="Work">Work</option>
		<option value="Home Office">Home Office</option>
		<option value="Mobile">Mobile</option>
		<option value="Voicemail">Voicemail</option>
		<option value="Pager">Pager</option>
		</select> 
		<input type="text" name="phone1number" value="$phone1number" class="form">
	</td>
	</tr>
	<tr>
	<td bgcolor="white"><b>Phone 2 Type</b><br>
	</td>
	<td bgcolor="white">
		<select name="phone2type" class="form">
		$getphone2type
		<option value="">-- No Number --</option>
		<option value="Home">Home</option>
		<option value="Work">Work</option>
		<option value="Home Office">Home Office</option>
		<option value="Mobile">Mobile</option>
		<option value="Voicemail">Voicemail</option>
		<option value="Pager">Pager</option>
		</select> 
		<input type="text" name="phone2number" value="$phone2number" class="form">
	</td>
	</tr>
	<tr>
	<td bgcolor="white"><b>Phone 3 Type</b><br>
	</td>
	<td bgcolor="white">
		<select name="phone3type" class="form">
		$getphone3type
		<option value="">-- No Number --</option>
		<option value="Home">Home</option>
		<option value="Work">Work</option>
		<option value="Home Office">Home Office</option>
		<option value="Mobile">Mobile</option>
		<option value="Voicemail">Voicemail</option>
		<option value="Pager">Pager</option>
		</select> 
		<input type="text" name="phone3number" value="$phone3number" class="form">
	</td>
	</tr>
	<tr>
	<td valign="top"><b>Fax Number</b></td>
	<td valign="top">
		<input type="text" name="faxnumber" value="$faxnumber" size="20" class="form"><br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>E-Mail Address</b></td>
	<td valign="top">
				<input type="Text" name="email" value="$email" size="40" class="form"><br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>E-Mail Address #2</b></td>
	<td valign="top">
				<input type="Text" name="emailtwo" value="$emailtwo" size="40" class="form"><br>
	</td>
	</tr>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Check all Contact Types that apply</b></td>
	<td valign="top">
		<table border="0" cellpadding="1" cellspacing="0" width="100%">
		<tr>
		<td valign="top">
			<label for="contacttype_buyerpast"><input id="contacttype_buyerpast" type="checkbox" name="contacttype" value="buyerpast" $checked_ctypes{buyerpast}> <b><u>Buyer - Past</u></b></label><br>
			<label for="contacttype_buyerprospective"><input id="contacttype_buyerprospective" type="checkbox" name="contacttype" value="buyerprospective" $checked_ctypes{buyerprospective}> <b><u>Buyer - Prospective</u></b></label><br>
			<label for="contacttype_sellerpast"><input id="contacttype_sellerpast" type="checkbox" name="contacttype" value="sellerprospective" $checked_ctypes{sellerprospective}> <b><u>Seller - Prospective</u></b></label><br>
			<label for="contacttype_sellerprospective"><input id="contacttype_sellerprospective" type="checkbox" name="contacttype" value="sellerpast" $checked_ctypes{sellerpast}> <b><u>Seller - Past</u></b></label><br>
			<label for="contacttype_sphereofinfluence"><input id="contacttype_sphereofinfluence" type="checkbox" name="contacttype" value="sphereofinfluence" $checked_ctypes{sphereofinfluence}> <b><u>Sphere of Influence</u></b></label><br>
			<label for="contacttype_familymember"><input id="contacttype_familymember" type="checkbox" name="contacttype" value="familymember" $checked_ctypes{familymember}> <b><u>Family Member</u></b></label><br>
			<label for="contacttype_friend"><input id="contacttype_friend" type="checkbox" name="contacttype" value="friend" $checked_ctypes{friend}> <b><u>Friend</u></b></label><br>
		</td>
		<td valign="top">
			<label for="contacttype_appraiser"><input id="contacttype_appraiser" type="checkbox" name="contacttype" value="appraiser" $checked_ctypes{appraiser}> <b><u>Appraiser</u></b></label><br>
			<label for="contacttype_inspector"><input id="contacttype_inspector" type="checkbox" name="contacttype" value="inspector" $checked_ctypes{inspector}> <b><u>Inspector</u></b></label><br>
			<label for="contacttype_insuranceagent"><input id="contacttype_insuranceagent" type="checkbox" name="contacttype" value="insuranceagent" $checked_ctypes{insuranceagent}> <b><u>Insurance Agent</u></b></label><br>
			<label for="contacttype_lender"><input id="contacttype_lender" type="checkbox" name="contacttype" value="lender" $checked_ctypes{lender}> <b><u>Lender</u></b></label><br>
			<label for="contacttype_attorney"><input id="contacttype_attorney" type="checkbox" name="contacttype" value="attorney" $checked_ctypes{attorney}> <b><u>Attorney</u></b></label><br>
			<label for="contacttype_titleagent"><input id="contacttype_titleagent" type="checkbox" name="contacttype" value="titleagent" $checked_ctypes{titleagent}> <b><u>Title Agent</u></b></label><br>
 		</td>
		</tr>
		</table>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>Initial Contact Date</b><br></td>
	<td valign="top">
		<input type="text" size="10" name="initial_contactdate" value="$initial_contactdate" class="form">&nbsp;<a href="javascript:cal1.popup();"><img src="images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a><br>
	</td>
	</tr>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Last Contact Date</b></td>
	<td valign="top">
		<input type="text" size="10" name="last_contactdate" value="$last_contactdate" class="form">&nbsp;<a href="javascript:cal2.popup();"><img src="images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a><br><br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>Next Contact Date</b><br><br>
	<td valign="top">
		<input type="text" size="10" name="next_contactdate" value="$next_contactdate" class="form">&nbsp;<a href="javascript:cal3.popup();"><img src="images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a><br>
	</td>
	</tr>
			<script language="JavaScript">
			<!-- //
				var cal1 = new calendar1(document.forms['econtact'].elements['initial_contactdate']);
				cal1.year_scroll = true;
				cal1.time_comp = false;

				var cal2 = new calendar1(document.forms['econtact'].elements['last_contactdate']);
				cal2.year_scroll = true;
				cal2.time_comp = false;

				var cal3 = new calendar1(document.forms['econtact'].elements['next_contactdate']);
				cal3.year_scroll = true;
				cal3.time_comp = false;

			//-->
			</script>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Referral Source</b></td>
	<td valign="top">
		<select name="source" class="form">
		$get_source
		<option value="Yard Sign Call">Yard Sign Call</option>
		<option value="The Star Press">The Star Press</option>
		<option value="Quincy Place Billboard">Quincy Place Billboard</option>
		<option value="Homes and Lifestyles">Homes and Lifestyles</option>
		<option value="Homes Guide - HC">Homes Guide - HC</option>
		<option value="MuncieMLS Website">MuncieMLS Website</option>
		<option value="Cold Calling">Cold Calling</option>
		<option value="Prospecting">Prospecting</option>
		<option value="Past Client">Past Client</option>
		<option value="Referal">Referal</option>
		<option value="Family">Family</option>
		<option value="Friend">Friend</option>
		</select>
		<br>
	</td>
	</tr>

	<tr>
	<td valign="top" bgcolor="#CCCCFF"><b>Contact Notes</b><br>You may keep track of notes about this contact in this area for later viewing</td>
	<td valign="top" bgcolor="#CCCCFF">
		<textarea rows="6" name="notes" cols="50" class="form">$notes</textarea>
	</td>
	</tr>
	<tr>
	<td colspan="2"><center><input type="submit" value="Save Changes" class="form">&nbsp&nbsp;&nbsp;<a href="prospectadmin.idx?action=overview_prospect&agent=$INPUT{agent}&prospectid=$INPUT{prospectid}">Cancel</a></center></td>
	</tr>
	</table>
</form>
</td>
~;
}

&footer;

}



sub overview_prospect_doedit {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

@variables = ($INPUT{firstname},$INPUT{lastname},$INPUT{address},$INPUT{spouse},$INPUT{city},$INPUT{state},$INPUT{zip},$INPUT{phone1type},$INPUT{phone1number},$INPUT{phone2type},$INPUT{phone2number},$INPUT{phone3type},$INPUT{phone3number},$INPUT{faxnumber},$INPUT{email},$INPUT{emailtwo},$INPUT{contacttype},$INPUT{initial_contactdate},$INPUT{last_contactdate},$INPUT{next_contactdate},$INPUT{source},$INPUT{notes},$INPUT{prospectid});
$sql_query = "update trans_boardprospect set firstname = ?, lastname = ?, address = ?, spouse = ?, city = ?, state = ?, zip = ?, phone1type = ?, phone1number = ?, phone2type = ?, phone2number = ?, phone3type = ?, phone3number = ?, faxnumber = ?, email = ?, emailtwo = ?, contacttype = ?, initial_contactdate = ?, last_contactdate = ?, next_contactdate = ?, source = ?, notes = ? where id = ?";
my $aasth = $dbh->do($sql_query, undef, @variables);

print qq~
<html>
<head>
<title>Making Changes to Datebase</title>
<meta http-equiv="Refresh" content="2; URL=http://connect.eaglesold.com/prospectadmin.idx?action=overview_prospect&agent=$INPUT{agent}&prospectid=$INPUT{prospectid}">
</head>
<body bgcolor="white">
<br><br><br><br>
<center><font size="3" face="Arial" color="Red">Please wait, Processing</font><br>You will be redirected to when finished.  If not <a href="http://connect.eaglesold.com/prospectadmin.idx?action=overview_prospect&agent=$INPUT{agent}&prospectid=$INPUT{prospectid}">Click Here</a>.</center>
</body>
</html>
~;


}

sub overview_prospect_delete {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

if ($INPUT{do} eq "yes") {


@cvariables = ($INPUT{prospectid});
$csql_query = "DELETE FROM trans_boardprospect WHERE id = ?";
my $caasth = $dbh->do($csql_query, undef, @cvariables);

@ncvariables = ($INPUT{prospectid});
$ncsql_query = "DELETE FROM trans_boardprospectnotes WHERE prospectid = ?";
my $ncaasth = $dbh->do($ncsql_query, undef, @ncvariables);

@variables = ($INPUT{prospectid});
$sql_query = "DELETE FROM trans_boardtranstoprospect WHERE prospectid = ?";
my $aasth = $dbh->do($sql_query, undef, @variables);

my $zaasth = $dbh->prepare("select did,newfileext from documents WHERE matchcat = 'p' AND matchid = '$INPUT{prospectid}'");
$zaasth->execute;
while (($pdid,$pnewfileext) = $zaasth->fetchrow_array()) {
unlink("/home/muncieml/public_html/connect/documents/$pdid.$pnewfileext");
}

@docvariables = ($INPUT{prospectid});
$docsql_query = "DELETE FROM documents WHERE matchcat = 'p' AND matchid = ?";
my $docasth = $dbh->do($docsql_query, undef, @docvariables);


print qq~
<html>
<head>
<title>Making Changes to Datebase</title>
<meta http-equiv="Refresh" content="1; URL=http://connect.eaglesold.com/prospectadmin.idx?agent=$INPUT{agent}">
</head>
<body bgcolor="white">
<br><br><br><br>
<center><font size="3" face="Arial" color="Red">Please wait, Processing</font><br><br>
<font color="red">
Removing Prospect Information<br>
Removing Prospect Notes Information<br>
Removing Prospect Links To Listings<br>
Removing Prospect Documents<br>
Removing Prospect Documents Information<br>
</font>
<br><br>
You will be redirected to when finished.  If not <a href="http://connect.eaglesold.com/prospectadmin.idx?agent=$INPUT{agent}">Click Here</a>.</center>
</body>
</html>
~;
}
else {

print qq~
<html>
<head>
<title>Edit Prospect -- Eagle Real Estate, Inc. - Connect.EagleSold.com</title>
~;

&header;

print qq~
<td valign="top" width="581">
<img src="images/headers/transaction_manager.gif" height="33" width="581" alt="My Transaction Manager"><br><br>
<font size="4" color="red">Really Delete prospect $INPUT{name}?</font><br>
are you sure you want to remove?<br><br>
<a href="prospectadmin.idx?action=overview_prospect_delete&agent=$INPUT{agent}&prospectid=$INPUT{prospectid}&do=yes">Yes</a> or <a href="prospectadmin.idx?agent=$INPUT{agent}">No [ Cancel ]</a><br><br>
If you select yes the following information will be removed:<br><br>
<font color="red">
Remove Prospect Information<br>
Remove Prospect Notes Information<br>
Remove Prospect Links To Listings<br>
Remove Prospect Documents<br>
Remove Prospect Documents Information<br>
</font>
</td>
~;

&footer;

}





}

sub overview_prospect {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

if ($INPUT{addnote} eq "1") {

	my $usrdasth = $dbh->prepare("select firstname,lastname from users where userid = '$Cook{userid}'");
	$usrdasth->execute;
	while (($afirstname,$alastname) = $usrdasth->fetchrow_array()) {
	$generateaddedby = "$afirstname $alastname";
	}

	@variables = ($INPUT{prospectid},$generateaddedby,$INPUT{prospect_notes});
	$sql_query = "INSERT INTO trans_boardprospectnotes values ('',?,now(),?,?)";
	my $zzaasth = $dbh->do($sql_query, undef, @variables);

	
	if ($INPUT{todo} eq "yes") {

	my $zzdasth = $dbh->prepare("select DATE_FORMAT(now(), '%Y-%m-%d')");
	$zzdasth->execute;
	while (($gnow) = $zzdasth->fetchrow_array()) {
	$good_date = $gnow;
	}
	
	$prospect_notes = "<i>Prospect note added to $INPUT{name} by $generateaddedby:</i><br>";
	$prospect_notes .= "$INPUT{prospect_notes}";
	
	@insert_vars = ($INPUT{agent},TransactionSystem,None,$good_date,$prospect_notes);
	
	$tsql_query = "insert into todo values ('',?,?,?,?,?,'$INPUT{todo_mark}')";
	$yasth = $dbh->do($tsql_query, undef, @insert_vars);
	}

}

my $basth = $dbh->prepare("select id,agent,type,firstname,lastname,address,spouse,city,state,zip,phone1type,phone1number,phone2type,phone2number,phone3type,phone3number,faxnumber,email,emailtwo,contacttype,DATE_FORMAT(initial_contactdate, '%b %D, %Y'),DATE_FORMAT(last_contactdate, '%b %D, %Y'),DATE_FORMAT(next_contactdate, '%b %D, %Y'),source,notes from trans_boardprospect WHERE id = '$INPUT{prospectid}'");
$basth->execute;


print qq~
<html>
<head>
<title>My Prospect Overview -- Eagle Real Estate, Inc. - Connect.EagleSold.com</title>
~;

&header;


print qq~
<td valign="top" width="581">
<img src="images/headers/transaction_manager.gif" height="33" width="581" alt="My Transaction Manager"><br><br>
<img src="images/trans_sys/my_prospects.gif" alt="My prospect Overview"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Navigation:</b> <a href="prospectadmin.idx?agent=$INPUT{agent}">go back to prospects</a><br><br>
~;

#id,agent,type,firstname,lastname,phone1type,phone1number,phone2type,phone2number,phone3type,phone3number,faxnumber,email,emailtwo

while (($id,$agent,$type,$firstname,$lastname,$address,$spouse,$city,$state,$zip,$phone1type,$phone1number,$phone2type,$phone2number,$phone3type,$phone3number,$faxnumber,$email,$emailtwo,$contacttype,$initial_contactdate,$last_contactdate,$next_contactdate,$source,$notes) = $basth->fetchrow_array()) {

$contacttype =~ s/\,/ - /gi;

unless ($initial_contactdate) {
$initial_contactdate = "<font color=\"Red\">Not Entered</font>";
}

unless ($last_contactdate) {
$last_contactdate = "<font color=\"Red\">Not Entered</font>";
}

unless ($next_contactdate) {
$next_contactdate = "<font color=\"Red\">Not Entered</font>";
}

if ($spouse ne "") {
$spouse = " & $spouse ";
}
else {
$spouse = "";
}

print qq~
<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td colspan="3" valign="middle">
<img src="images/contacts_icon.gif" alt="$firstname$spouse $lastname"><font size="4" face="Arial Black">$firstname$spouse $lastname<br></font>
</td>
</tr>
<tr>
<td valign="top" width="33%">
<font face="Arial" size="2">
<b>Address</b><br>
$address<br>
$city, $state, $zip<br>
</font><br>

<a href="prospectadmin.idx?action=overview_prospect_edit&agent=$INPUT{agent}&prospectid=$id"><img src="images/trans_sys/button_edit.gif" alt="Edit prospect" border="0"> Edit prospect</a><br>
<a href="prospectadmin.idx?action=overview_prospect_delete&agent=$INPUT{agent}&prospectid=$id&name=$firstname $lastname"><img src="images/trans_sys/button_delete.gif" alt="Delete prospect" border="0"> Delete prospect</a><br>
<form method="post" action="prospectadmin.idx" target="_blank">
<input type="hidden" name="action" value="overview_prospect_print">
<input type="hidden" name="prospectid" value="$id">
<input type="submit" value="Print Opportunity Sheet">
</form>
</td>
<td valign="top" width="33%">
<b><font size="2" face="Arial">Prospect Info</font></b><br>
<b>$phone1type</b> $phone1number<br>
<b>$phone2type</b> $phone2number<br>
<b>$phone3type</b> $phone3number<br>
<b>Fax</b> $faxnumber<br>
<b>E-Mail</b> <a href="prospectadmin.idx?action=myemailer&agent=$INPUT{agent}&prospectid=$id">$email</a><br>
<b>E-Mail Address #2</b> $emailtwo<br>
~;
unless ($email eq "") {
print qq~
<a href="prospectadmin.idx?action=myemailer&agent=$INPUT{agent}&prospectid=$id">Send E-Mail</a><br>
~;
}
print qq~
</td>
<td valign="top" width="34%">
<b>Initial Contact Date</b><br>
<i>$initial_contactdate</i><br>
<b>Last Contact Date</b><br>
<i>$last_contactdate</i><br>
<b>Next Contact Date</b><br>
<i>$next_contactdate</i><br><br>
<b>Referal Source</b><br>
<i>$source</i><br>
</td>
</tr>
<tr>
<td>
<b>Contact Type(s)</b><br>
$contacttype<br><br>
</td>
<td colspan="2">
<b>Notes</b><br>
$notes<br><br>
</td>
</tr>
</table><br>
<br><br>
<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td valign="top" width="100%" colspan="2">
	<table border="0" cellpadding="3" cellspacing="0" width="100%">
	<tr>
		<td valign="top" bgcolor="navy" nowrap><font color="white" size="2"><b>Listing Property Is Linked To</b></font><br></td>
		<td valign="top" bgcolor="navy" align="right"></td>
	</tr>
	</table>
</td>
</tr>
<tr>
<td valign="top" width="65%">
<center>
<b><font size="3" face="Tahoma">Find Property Below</font></b><br><br>
<b>Select Address</b><br>
<form method="get" action="prospectadmin.idx" target="link">
<input type="hidden" name="action" value="overview_prospects_linked">
<input type="hidden" name="do" value="add">
<input type="hidden" name="prospectid" value="$INPUT{prospectid}">
<select name="transid" class="form">
~;

my $aasth = $dbh->prepare("select id,type,mlsnumber,addressnumber,addressdirection,addressstreet,city,state,zip from trans_board where status = 'Active' or status = 'Pending' GROUP BY mlsnumber ORDER BY addressstreet asc");
$aasth->execute;
while (($tid,$type,$mlsnumber,$addressnumber,$addressdirection,$addressstreet,$city,$state,$zip) = $aasth->fetchrow_array()) {
print qq~
<option value="$tid">$addressstreet - $addressnumber $addressdirection - $city -- MLS #$mlsnumber</option>
~;\n
}

print qq~
</select>
<br><br>
<input type="submit" class="form" value="Link prospect to this listing">
</form>
</center>
<br>
</td>
<td valign="top" width="35%">
		<iframe src="prospectadmin.idx?action=overview_prospects_linked&prospectid=$id" width="100%" height="150" noresize="noresize" scrolling ="yes" name="link" frameborder="0" marginwidth="0" marginheight="0"></iframe>
</td>
</tr>
</table>
<br><br>




<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td valign="top" width="65%">
	<table border="0" cellpadding="3" cellspacing="0" width="100%">
	<tr>
		<td valign="top" bgcolor="navy" nowrap><font color="white" size="2"><b>My Prospect Notes</b></font><br></td>
		<td valign="top" bgcolor="navy" align="right">
			<table border="0" cellspacing="1" cellpadding="2" bgcolor="white">
			<tr>
				<td valign="top" bgcolor="silver">
					View Notes Below<br>
				</td>
			</tr>
			</table>
	</td>
	</tr>
	</table>
		<iframe src="prospectadmin.idx?action=overview_prospect_notes_show&prospectid=$INPUT{prospectid}" width="100%" height="115" noresize="noresize" scrolling ="yes" frameborder="0" marginwidth="3" marginheight="3"></iframe>
</td>
<td valign="top" width="35%">
		<form method="get" action="prospectadmin.idx">
		<input type="hidden" name="action" value="overview_prospect">
		<input type="hidden" name="prospectid" value="$INPUT{prospectid}">
		<input type="hidden" name="agent" value="$INPUT{agent}">
		<input type="hidden" name="name" value="$firstname$spouse $lastname">
		<input type="hidden" name="addnote" value="1">
		<input type="hidden" name="address" value="$addressnumber $addressdirection $addressstreet">
		<textarea cols="35" rows="8" name="prospect_notes" class="form"></textarea><br>
		<select name="todo" class="form">
		<option value="yes">ToDo</option>
		<option value="no">Hide</option></select><select name="todo_mark" class="form"><option value="y">Mark Done</option><option value="n">Not Done</option></select><input type="submit" value="Save" class="form">
		</form>
</td>
</tr>
</table>

		<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td colspan="2">
	<table border="0" cellpadding="3" cellspacing="0" width="581">
	<tr>
	<td valign="top" bgcolor="navy" nowrap><font color="white" size="2"><b>Document Center</b></font><br></td>
	<td valign="top" bgcolor="navy" align="right">
	<table border="0" cellspacing="1" cellpadding="2" bgcolor="white">
	<tr>
	<td valign="top" bgcolor="silver">
	View or Upload Documents<br>
	</td>
	</tr>
	</table>
	</td>
	</tr>
	</table>
	<table border="0" cellpadding="0" cellspacing="0" width="581">
	<tr>
	<td valign="top" width="361">
		<iframe src="prospectadmin.idx?action=overview_documents_prospect&prospectid=$INPUT{prospectid}" width="361" height="90" noresize="noresize" scrolling ="yes" frameborder="0" marginwidth="0" marginheight="0" name="documents"></iframe>
	</td>
		<FORM action="upload_doc.idx" encType="multipart/form-data" method="post" target="documents" name="upload">
		<input type="hidden" name="matchid" value="$INPUT{prospectid}" class="form">
		<input type="hidden" name="matchcat" value="p" class="form">
<script language="JavaScript">
function postIt()
{
	 document.upload.submit();
	//	var winl = (screen.width - w) / 2;
	//	var wint = (screen.height - h) / 2;
	win = window.open('http://connect.eaglesold.com/prospectadmin.idx?action=document_progress', 'FileUpload', 'height=300, width=450, scrollbars=false, resizable');
	win.window.focus();

}
</script>
	<td valign="top" width="220">
<center>
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td valign="top">
		<center>
		<b><img src="images/trans_sys/button_view.gif"> <font size="2">Upload New Document</font></b>
		</center>
		<b>Name the file:</b><br>
		<input type="text" name="name" size="35" class="form"><br>
		<b>Find file by clicking browse:</b><br>
		<INPUT name="FILE1" type="file" class="form"><br>
		<INPUT type="button" value="           Upload File            " onClick="postIt();" class="form">
</td>
</tr>
</table>
</center>
	</td>
		</form>
	</tr>
	</table>
</td>
</tr>
</table>
</td>
~;
}
&footer;

}


sub overview_prospects_smallaz {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

print qq~
<html>
<head>
<title>prospects Small A-Z</title>
<link rel="stylesheet" TYPE="text/css" href="includes/style.css">
</head>
<body bgcolor="white" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">

<b>SEARCH USERS LASTNAME BY</b><br>
<center>
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=A">A</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=B">B</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=C">C</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=D">D</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=E">E</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=F">F</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=G">G</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=H">H</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=I">I</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=J">J</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=K">K</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=L">L</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=M">M</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=N">N</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=O">O</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=P">P</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=Q">Q</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=R">R</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=S">S</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=T">T</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=U">U</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=V">V</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=W">W</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=X">X</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=Y">Y</a> | 
<a href="prospectadmin.idx?action=overview_prospects_smallaz&transid=$INPUT{transid}&agent=$INPUT{agent}&find=Z">Z</a>
</center>
<br><br>
~;
my $basth = $dbh->prepare("select id,agent,type,firstname,lastname from trans_boardprospect WHERE agent = '$INPUT{agent}' AND lastname LIKE '$INPUT{find}%' ORDER by lastname ASC");
$basth->execute;

while (($id,$agent,$type,$firstname,$lastname) = $basth->fetchrow_array()) {
print qq~
$id - $agent - $type - $firstname - $lastname<br>
~;
}

print qq~
</body>
</html>
~;

}

sub overview_prospect_notes_show {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

my $basth = $dbh->prepare("select noteid,prospectid,DATE_FORMAT(datetime, '%b %D, %Y at %h\:%i%p'),addedby,note from trans_boardprospectnotes WHERE prospectid = '$INPUT{prospectid}' ORDER by datetime DESC");
$basth->execute;

print qq~
<html>
<head>
<title>Notes</title>
<link rel="stylesheet" TYPE="text/css" href="includes/style.css">
</head>
<body bgcolor="white" leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<table border="0" cellpadding="4" cellspacing="0" width="100%">
~;
$trcolor = "1";
$trcolor2 = "2";

while (($noteid,$prospectid,$datetime,$addedby,$note) = $basth->fetchrow_array()) {

	if ($trcolor eq $trcolor2) {
	$trcolor = "1";
	$setcolor = "#FFFFFF";
	}
	else {
	$setcolor = "#CCCCFF";
	$trcolor++;
	}
print qq~
<tr bgcolor="$setcolor">
<td valign="top">
<b>$note</b><br>
<i>Added by $addedby on $datetime</i>
</td>
</tr>
~;
$found = "yes";
}

unless ($found eq "yes") {
print qq~
<tr>
<td>
<font color="red"><b>No Notes have been added yet!  You may use the textbox to the right to save Notes.</b></font>
</td>
</tr>
~;
}
print qq~
</table>
</body>
</html>
~;
}

sub main {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

print qq~
<html>
<head>
<title>My Prospect Manager - Eagle Real Estate, Inc. - Connect.EagleSold.com</title>
<script language="JavScript">
function submit()
{
	 document.changestatus.submit();
}
</script>
~;

&header;


print qq~
<td valign="top" width="581">
<img src="images/headers/transaction_manager.gif" height="33" width="581" alt="My Transaction Manager"><br><br>
~;

print qq~
<br>
<img src="images/trans_sys/my_prospects.gif" alt="My prospects"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>use the alphabet below to search your prospects</b><br><br>
<table border="0" cellpadding="6" cellspacing="1" bgcolor="navy" width="100%">
<tr>
<td bgcolor="#CCCCFF">
<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td><b><font size="3">Search your prospects by Lastname</font></b><br></td>
<td align="right">
<a href="prospectadmin.idx?action=create_prospect&agent=$INPUT{agent}">Create A New prospect</a><br>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="white">
<center>
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=%">All</a> 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=A">A</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=B">B</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=C">C</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=D">D</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=E">E</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=F">F</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=G">G</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=H">H</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=I">I</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=J">J</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=K">K</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=L">L</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=M">M</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=N">N</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=O">O</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=P">P</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=Q">Q</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=R">R</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=S">S</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=T">T</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=U">U</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=V">V</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=W">W</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=X">X</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=Y">Y</a> | 
<a href="prospectadmin.idx?agent=$INPUT{agent}&prospect=Z">Z</a>
</center><br>
~;

if ($INPUT{prospect}) {
my $basth = $dbh->prepare("select id,agent,type,firstname,lastname,spouse from trans_boardprospect WHERE type = 'office' AND lastname LIKE '$INPUT{prospect}%' ORDER by lastname ASC");
$basth->execute;

		$trcount = "1";
		$totalperrow = "3";
		$rowcolor1 = "1";
		$rowcolor2 = "2";
		print qq~
		<table border="0" cellpadding="2" cellspacing="1" width="100%" bgcolor="gray">
		<tr bgcolor="#FFFFFF">
		~;

while (($prospectid,$agent,$type,$firstname,$lastname,$spouse) = $basth->fetchrow_array()) {

			if ($rowcolor1 eq $rowcolor2) {
			$color = "#FFFFFF";
			$rowcolor1 = "1";
			}
			else {
			$color = "#FFFF99";
			$rowcolor1++;
			}

	if ($spouse ne "") {
	$spouse = " & $spouse ";
	}
	else {
	$spouse = "";
	}
print qq~
<td>
<a href="prospectadmin.idx?action=overview_prospect&prospectid=$prospectid">$lastname, $firstname$spouse</a>  <a href="prospectadmin.idx?action=overview_prospect&agent=$INPUT{agent}&prospectid=$prospectid"><img src="images/trans_sys/button_view.gif" alt="View details for $lastname, $firstname$spouse" border="0"></a> <a href="prospectadmin.idx?action=overview_prospect_edit&agent=$INPUT{agent}&prospectid=$prospectid"><img src="images/trans_sys/button_edit.gif" alt="Edit $lastname, $firstname$spouse" border="0"></a> <a href="prospectadmin.idx?action=overview_prospect_delete&agent=$INPUT{agent}&prospectid=$prospectid&name=$firstname $lastname"><img src="images/trans_sys/button_delete.gif" alt="Delete $lastname, $firstname$spouse" border="0"></a><br>
</td>
~;

		if ($trcount eq $totalperrow) {
		print "</tr><tr bgcolor=\"$color\">";
		$trcount = "1";
		}
		else {
		$trcount++;
		}

$ccfound = "yes";
}

		print qq~
		</tr>
		</table>
		~;

unless ($ccfound eq "yes") {
print qq~
<font color="red" size="3" face="Arial"><b>No prospects Found, Click on the first letter in the alphabet above that corresponds with your prospects lastname to try another search.  If your prospect is not listed you can create a new prospect by clicking on the link above.</b></font><br>
~;
}
}
else {
print qq~
<font color="red" size="3" face="Arial"><b>Click on the first letter in the alphabet above that corresponds with your prospects lastname to search your prospects.</b></font><br>
~;
}


print qq~
</td>
</tr>
</table>
<br>
<font size="3"><b>Recently Added Prospects within the last 2 weeks</b><hr color="red" width="100%">
~;

my $casth = $dbh->prepare("select id,firstname,spouse,lastname,DATE_FORMAT(initial_contactdate, '%M %D, %Y') from trans_boardprospect WHERE type = 'office' AND initial_contactdate BETWEEN DATE_ADD(now(), INTERVAL -14 DAY) AND now() ORDER BY initial_contactdate DESC");
$casth->execute;
while (($id,$firstname,$spouse,$lastname,$initial_contactdate) = $casth->fetchrow_array()) {
print qq~
<a href="http://connect.eaglesold.com/prospectadmin.idx?action=overview_prospect&prospectid=$id">$initial_contactdate - $firstname $spouse $lastname</a><br>
~;
$found = "yes";
}

unless ($found eq "yes") {
print qq~No Prospects Have Saved Next Contact Dates Yet!~;
}


print qq~
</td>
~;
&footer;

}




sub create_prospect_verify {

#####id,agent,firstname,lastname,phone1type,phone1number,phone2type,phone2number,phone3type,phone3number,faxnumber,email,emailtwo,

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

$fcontacttype = "$INPUT{contacttype}";
$fcontacttype =~ s/\,/<br>/gi;

print qq~
<html>
<head>
<title>Verify New Prospect -- Eagle Real Estate, Inc. - Connect.EagleSold.com</title>
~;

&header;


print qq~

<td valign="top" width="581">
<img src="images/headers/transaction_manager.gif" height="33" width="581" alt="My Transaction Manager"><br><br>
<img src="images/trans_sys/my_prospects.gif" alt="Create New prospect"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>verify new prospect information</b><br><br>
<form method="post" name="transactions" action="prospectadmin.idx">
<input type="hidden" name="action" value="create_prospect_do">
<input type="hidden" name="agent" value="$INPUT{agent}">
<input type="hidden" name="prospect_type" value="$INPUT{prospect_type}">
~;
if ($INPUT{transid} eq "no") {
print qq~
~;
}
else {
print qq~
<input type="hidden" name="transid" value="$INPUT{transid}">
~;
}
print qq~
<input type="hidden" name="firstname" value="$INPUT{firstname}">
<input type="hidden" name="lastname" value="$INPUT{lastname}">
<input type="hidden" name="type" value="$INPUT{type}">
<input type="hidden" name="address" value="$INPUT{address}">
<input type="hidden" name="spouse" value="$INPUT{spouse}">
<input type="hidden" name="city" value="$INPUT{city}">
<input type="hidden" name="state" value="$INPUT{state}">
<input type="hidden" name="zip" value="$INPUT{zip}">
<input type="hidden" name="phone1type" value="$INPUT{phone1type}">
<input type="hidden" name="phone1number" value="$INPUT{phone1number}">
<input type="hidden" name="phone2type" value="$INPUT{phone2type}">
<input type="hidden" name="phone2number" value="$INPUT{phone2number}">
<input type="hidden" name="phone3type" value="$INPUT{phone3type}">
<input type="hidden" name="phone3number" value="$INPUT{phone3number}">
<input type="hidden" name="faxnumber" value="$INPUT{faxnumber}">
<input type="hidden" name="email" value="$INPUT{email}">
<input type="hidden" name="emailtwo" value="$INPUT{emailtwo}">
<input type="hidden" name="contacttype" value="$INPUT{contacttype}">
<input type="hidden" name="initial_contactdate" value="$INPUT{initial_contactdate}">
<input type="hidden" name="last_contactdate" value="$INPUT{last_contactdate}">
<input type="hidden" name="next_contactdate" value="$INPUT{next_contactdate}">
<input type="hidden" name="source" value="$INPUT{source}">
<input type="hidden" name="notes" value="$INPUT{notes}">

	<table border="0" width="500" cellpadding="3" cellspacing="1">	
	<tr>
	<td valign="top" width="50%"><b>Prospect Information</b></td>
	<td valign="top" width="50%">
	<b>Firstname</b><br>
	<font size="3">$INPUT{firstname}</font><br>
	<b>Spouse</b><br>
	<font size="3">$INPUT{spouse}</font><br>
	<b>Lastname</b><br>
	<font size="3">$INPUT{lastname}</font><br></td>
	</tr>
	<tr>
	<td valign="top" bgcolor="#CCCCFF"><b>Current Address</b></td>
	<td valign="top" bgcolor="#CCCCFF">
		<b>Address</b><br>
		<font size="3">$INPUT{address}</font><br>
		<b>City</b><br>
		<font size="3">$INPUT{city}</font><br>
		<b>State</b><br>
		<font size="3">$INPUT{state}</font><br>
		<b>Zip</b><br>
		<font size="3">$INPUT{zip}</font><br>
	</td>
	</tr>
	<tr>
	<td bgcolor="white"><b>Phone 1 Type</b><br>
	</td>
	<td bgcolor="white">
		<font size="3">$INPUT{phone1type} $INPUT{phone1number}</font>
	</td>
	</tr>
	<tr>
	<td bgcolor="white"><b>Phone 2 Type</b><br>
	</td>
	<td bgcolor="white">
		<font size="3">$INPUT{phone2type} $INPUT{phone2number}</font>
	</td>
	</tr>
	<tr>
	<td bgcolor="white"><b>Phone 3 Type</b><br>
	</td>
	<td bgcolor="white">
		<font size="3">$INPUT{phone3type} $INPUT{phone3number}</font>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>Fax Number</b></td>
	<td valign="top">
		<font size="3">$INPUT{faxnumber}</font><br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>E-Mail Address</b></td>
	<td valign="top">
				<font size="3">$INPUT{email}</font><br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>E-Mail Block</b></td>
	<td valign="top">
		<b>Block E-Mail</b><br>
		<font size="3">$INPUT{emailtwo}</font><br>
	</td>
	</tr>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Contact Type(s)</b></td>
	<td valign="top">
		$fcontacttype<br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>Initial Contact Date</b><br></td>
	<td valign="top">
		Now<br>
	</td>
	</tr>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Last Contact Date</b></td>
	<td valign="top">
		$INPUT{last_contactdate}<br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>Next Contact Date</b><br><br>
	<td valign="top">
		$INPUT{next_contactdate}<br>
	</td>
	</tr>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Referral Source</b></td>
	<td valign="top">
		$INPUT{source}
		<br>
	</td>
	</tr>
	<tr>
	<td valign="top" bgcolor="#CCCCFF"><b>Prospect Notes</b><br>You may keep track of notes about this contact in this area for later viewing</td>
	<td valign="top" bgcolor="#CCCCFF">
		<font size="3">$INPUT{notes}</font><br>
	</td>
	</tr>
	<tr>
	<td colspan="2"><center><input type="submit" value="Save New prospect" class="form"> <input type="button" value="Make Changes" onClick="history.back()" class="form"></center></td>
	</tr>
	</table>
</form>
</td>
~;

&footer;

}

sub create_prospect_do {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;						
@variables = ($INPUT{agent},$INPUT{type},$INPUT{firstname},$INPUT{lastname},$INPUT{address},$INPUT{spouse},$INPUT{city},$INPUT{state},$INPUT{zip},$INPUT{phone1type},$INPUT{phone1number},$INPUT{phone2type},$INPUT{phone2number},$INPUT{phone3type},$INPUT{phone3number},$INPUT{faxnumber},$INPUT{email},$INPUT{emailtwo},$INPUT{contacttype},$INPUT{last_contactdate},$INPUT{next_contactdate},$INPUT{source},$INPUT{notes});
$sql_query = "INSERT INTO trans_boardprospect values ('',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,now(),?,?,?,?)";
my $aasth = $dbh->do($sql_query, undef, @variables);

my $zaasth = $dbh->prepare("select id from trans_boardprospect WHERE agent = '$INPUT{agent}' ORDER BY id DESC LIMIT 0,1");
$zaasth->execute;
while (($prospectid) = $zaasth->fetchrow_array()) {

print qq~
<html>
<head>
<title>Making Changes to Datebase</title>
<meta http-equiv="Refresh" content="1; URL=http://connect.eaglesold.com/prospectadmin.idx?action=overview_prospect&agent=$INPUT{agent}&prospectid=$prospectid">
</head>
<body bgcolor="white">
<br><br><br><br>
<center><font size="3" face="Arial" color="Red">Please wait, Processing</font><br>You will be redirected to when finished.  If not <a href="http://connect.eaglesold.com/prospectadmin.idx?action=overview&transid=$INPUT{transid}&agent=$INPUT{agent}">Click Here</a>.</center>
</body>
</html>
~;
}

}

sub create_prospect {

use DBI;
my $dsn = "DBI:mysql:database=$d_name;host=localhost";
my $dbh = DBI->connect($dsn, $d_username, $d_pass, {RaiseError => 1}) || die $DBI::errstr;

my $casth = $dbh->prepare("select mlsid,firstname,lastname from agents ORDER BY lastname ASC");
$casth->execute;
while (($mlsid,$firstname,$lastname) = $casth->fetchrow_array()) {
$printagents .= "<option value=\"$mlsid\">$lastname, $firstname</option>";
}

print qq~
<html>
<head>
<title>Create New Prospect -- Eagle Real Estate, Inc. - Connect.EagleSold.com</title>
~;

&header;


print qq~
<td valign="top" width="581">
<script language="JavaScript" src="calendar1.js"></script>
<img src="images/headers/transaction_manager.gif" height="33" width="581" alt="My Transaction Manager"><br><br>
<img src="images/trans_sys/my_prospects.gif" alt="Create New prospect"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>fill out the form below to create a new prospect</b><br><br>
<form method="post" name="ccontact" action="prospectadmin.idx">
<input type="hidden" name="action" value="create_prospect_verify">
<input type="hidden" name="type" value="office">

	<table border="0" width="500" cellpadding="3" cellspacing="1">	
	<tr>
	<td valign="top" width="40%"><b>Agent Assigned Prospect</b></td>
	<td valign="top" width="60%">		<b>Agent</b><br>
		<select name="agent" class="form">
		<option value="">You Must Choose Agent</option>
		$printagents
		</select>
		<br>
	</td>
	</tr>
	<tr>
	<td valign="top" width="40%"><b>Prospect Information</b></td>
	<td valign="top" width="60%"><b>Firstname</b><br>
	<input type="text" name="firstname" class="form"><br>
	<b>Spouse Name</b><br>
	<input type="text" name="spouse" class="form"><br>
	<b>Lastname</b><br>
	<input type="text" name="lastname" class="form"><br>
	</td>
	</tr>
	<tr>
	<td bgcolor="white"><b>Phone 1 Type</b><br>
	</td>
	<td bgcolor="white">
		<select name="phone1type" class="form">
		<option value="">-- No Number --</option>
		<option value="Home">Home</option>
		<option value="Work">Work</option>
		<option value="Home Office">Home Office</option>
		<option value="Mobile">Mobile</option>
		<option value="Voicemail">Voicemail</option>
		<option value="Pager">Pager</option>
		</select> 
		<input type="text" name="phone1number" class="form">
	</td>
	</tr>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Current Address</b></td>
	<td valign="top">
		<b>Address</b><br>
		<input type="text" name="address" size="40" class="form"><br>
		<b>City</b><br>
		<input type="text" name="city" size="12" class="form"><br>
		<b>State</b><br>
		<select name="state" class="form"><option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option> 
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="District of Columbia">District of Columbia</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana" selected>Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland">Maryland</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Mississippi">Mississippi</option>
<option value="Missouri">Missouri</option>
<option value="Montana">Montana</option>
<option value="Nebraska">Nebraska</option>
<option value="Nevada">Nevada</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="New York">New York</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Vermont">Vermont</option>
<option value="Virgin Islands">Virgin Islands</option>
<option value="Virginia">Virginia</option>
<option value="Washington">Washington</option>
<option value="West Virginia">West Virginia</option>
<option value="Wisconsin">Wisconsin</option>
<option value="Wyoming">Wyoming</option></select><br>
<b>Zip</b><br><input type="text" name="zip" size="5" class="form">
	</td>
	</tr>
	<tr>
	<td bgcolor="white"><b>Phone 2 Type</b><br>
	</td>
	<td bgcolor="white">
		<select name="phone2type" class="form">
		<option value="">-- No Number --</option>
		<option value="Home">Home</option>
		<option value="Work">Work</option>
		<option value="Home Office">Home Office</option>
		<option value="Mobile">Mobile</option>
		<option value="Voicemail">Voicemail</option>
		<option value="Pager">Pager</option>
		</select> 
		<input type="text" name="phone2number" class="form">
	</td>
	</tr>
	<tr>
	<td bgcolor="white"><b>Phone 3 Type</b><br>
	</td>
	<td bgcolor="white">
		<select name="phone3type" class="form">
		<option value="">-- No Number --</option>
		<option value="Home">Home</option>
		<option value="Work">Work</option>
		<option value="Home Office">Home Office</option>
		<option value="Mobile">Mobile</option>
		<option value="Voicemail">Voicemail</option>
		<option value="Pager">Pager</option>
		</select> 
		<input type="text" name="phone3number" class="form">
	</td>
	</tr>
	<tr>
	<td valign="top"><b>Fax Number</b></td>
	<td valign="top">
		<input type="text" name="faxnumber" size="15" class="form"><br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>E-Mail Address</b></td>
	<td valign="top">
				<input type="Text" name="email" size="30" class="form"><br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>E-Mail Address #2</b></td>
	<td valign="top">
				<input type="Text" name="emailtwo" size="30" class="form"><br>
	</td>
	</tr>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Check all Contact Types that apply</b></td>
	<td valign="top">
		<table border="0" cellpadding="1" cellspacing="0" width="100%">
		<tr>
		<td valign="top" width="50%">
			<label for="contacttype_buyerpast"><input id="contacttype_buyerpast" type="checkbox" name="contacttype" value="buyerpast"> <b><u>Buyer - Past</u></b></label><br>
			<label for="contacttype_buyerprospective"><input id="contacttype_buyerprospective" type="checkbox" name="contacttype" value="buyerprospective"> <b><u>Buyer - Prospective</u></b></label><br>
			<label for="contacttype_sellerpast"><input id="contacttype_sellerpast" type="checkbox" name="contacttype" value="sellerprospective"> <b><u>Seller - Prospective</u></b></label><br>
			<label for="contacttype_sellerprospective"><input id="contacttype_sellerprospective" type="checkbox" name="contacttype" value="sellerpast"> <b><u>Seller - Past</u></b></label><br>
			<label for="contacttype_sphereofinfluence"><input id="contacttype_sphereofinfluence" type="checkbox" name="contacttype" value="sphereofinfluence"> <b><u>Sphere of Influence</u></b></label><br>
			<label for="contacttype_familymember"><input id="contacttype_familymember" type="checkbox" name="contacttype" value="familymember"> <b><u>Family Member</u></b></label><br>
			<label for="contacttype_friend"><input id="contacttype_friend" type="checkbox" name="contacttype" value="friend"> <b><u>Friend</u></b></label><br>
		</td>
		<td valign="top" width="50%">
			<label for="contacttype_appraiser"><input id="contacttype_appraiser" type="checkbox" name="contacttype" value="appraiser"> <b><u>Appraiser</u></b></label><br>
			<label for="contacttype_inspector"><input id="contacttype_inspector" type="checkbox" name="contacttype" value="inspector"> <b><u>Inspector</u></b></label><br>
			<label for="contacttype_insuranceagent"><input id="contacttype_insuranceagent" type="checkbox" name="contacttype" value="insuranceagent"> <b><u>Insurance Agent</u></b></label><br>
			<label for="contacttype_lender"><input id="contacttype_lender" type="checkbox" name="contacttype" value="lender"> <b><u>Lender</u></b></label><br>
			<label for="contacttype_attorney"><input id="contacttype_attorney" type="checkbox" name="contacttype" value="attorney"> <b><u>Attorney</u></b></label><br>
			<label for="contacttype_titleagent"><input id="contacttype_titleagent" type="checkbox" name="contacttype" value="titleagent"> <b><u>Title Agent</u></b></label><br>
 		</td>
		</tr>
		</table>
	</td>
	</tr>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Last Contact Date</b></td>
	<td valign="top">
		<input type="text" size="10" name="last_contactdate" class="form">&nbsp;<a href="javascript:cal2.popup();"><img src="images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a><br><br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>Next Contact Date</b><br><br>
	<td valign="top">
		<input type="text" size="10" name="next_contactdate" class="form">&nbsp;<a href="javascript:cal3.popup();"><img src="images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the date"></a><br>
	</td>
	</tr>
			<script language="JavaScript">
			<!-- //

				var cal2 = new calendar1(document.forms['ccontact'].elements['last_contactdate']);
				cal2.year_scroll = true;
				cal2.time_comp = false;

				var cal3 = new calendar1(document.forms['ccontact'].elements['next_contactdate']);
				cal3.year_scroll = true;
				cal3.time_comp = false;

			//-->
			</script>
	<tr bgcolor="#CCCCFF">
	<td valign="top"><b>Referral Source</b></td>
	<td valign="top">
		<select name="source" class="form">
		<option value="Not Selected">-- Select Lead Source --</option>
		<option value="Yard Sign Call">Yard Sign Call</option>
		<option value="The Star Press">The Star Press</option>
		<option value="Quincy Place Billboard">Quincy Place Billboard</option>
		<option value="Homes and Lifestyles">Homes and Lifestyles</option>
		<option value="Homes Guide - HC">Homes Guide - HC</option>
		<option value="MuncieMLS Website">MuncieMLS Website</option>
		<option value="Cold Calling">Cold Calling</option>
		<option value="Prospecting">Prospecting</option>
		<option value="Past Client">Past Client</option>
		<option value="Referal">Referal</option>
		<option value="Family">Family</option>
		<option value="Friend">Friend</option>
		</select>
		<br>
	</td>
	</tr>
	<tr>
	<td valign="top"><b>Contact Notes</b><br>You may keep track of notes about this contact in this area for later viewing</td>
	<td valign="top">
		<textarea rows="6" name="notes" cols="50" class="form"></textarea>
	</td>
	</tr>
	<tr>
	<td colspan="2"><center><input type="submit" value="Submit / Next Page" class="form" name="btnOK" value="Save"></center></td>
	</tr>
	</table>
</form>
</td>
~;

&footer;


}
