Your IP : 216.73.217.117


Current Path : /var/www/cesa.co.za/members/saaceadmin/
Upload File :
Current File : /var/www/cesa.co.za/members/saaceadmin/membersearch.phtml

<link rel="stylesheet" href="/css/default2.css" type="text/css">
<img src="/pics/Headers/search_members.jpg" width="450" height="67">
<p>
<?php
include( 'inc/auth.inc' );
$db = mysql_connect($loghost,$logid,$logpwd);
mysql_select_db("saace",$db);
// If the form is submitted process here
$graylight ="#EAEAEA";

if ($officeid) {
        echo "Office id is:"; echo $officeid;
		$sql = "SELECT
		tblMemberFirmOffices.OfficeStatus,
		tblMemberFirmOffices.OfficeName,
		tblMemberFirmOffices.Address2,
		tblMemberFirmOffices.PostalAddress,
		tblMemberFirmOffices.GeoLocation,
		tblMemberFirmOffices.TownCity,
		tblMemberFirmOffices.PostalCode,
		tblMemberFirmOffices.Country,
		tblMemberFirmOffices.BldgName,
		tblMemberFirmOffices.StreetName,
		tblMemberFirmOffices.Suburb,
		tblMemberFirmOffices.Telephone,
		tblMemberFirmOffices.Fax,
		tblMemberFirmOffices.Email,
		tblMemberFirmOffices.FullOrPartTime,
		tblMemberFirmOffices.OtherStaff,
		tblMemberFirmOffices.ProfessionalStaff,
		tblMemberFirmOffices.NonProfTechStaff,
		tblMemberFirms.URL,
		tblMemberFirms.DeclarationReceived,
		tblMemberFirms.Acoustics,
		tblMemberFirms.Agricultural,
		tblMemberFirms.BuildingServices,
		tblMemberFirms.Chemical,
		tblMemberFirms.Civil,
		tblMemberFirms.Development,
		tblMemberFirms.Electrical,
		tblMemberFirms.Electronic,
		tblMemberFirms.Environmental,
		tblMemberFirms.Geotechnical,
		tblMemberFirms.Industrial,
		tblMemberFirms.Mechanical,
		tblMemberFirms.Marine,
		tblMemberFirms.Mining,
		tblMemberFirms.Process,
		tblMemberFirms.Structural,
		tblMemberFirms.Transportation,
		tblMemberFirms.Architecture,
		tblMemberFirms.RuralDevelopment,		
		tblMemberFirms.ProjectManagement,
		tblMemberFirms.QuantitySurveying,
		tblMemberFirms.TownPlanning,
		tblMemberFirms.Multidisciplinary,
		tblMemberFirms.DisputeResolution,
		tblMemberFirms.ExpertWitness,
		tblMemberFirms.InformationSystems,
		tblMemberFirms.FacilitiesManagement,
		tblMemberFirms.GIS
		FROM tblMemberFirmOffices, tblMemberFirms WHERE (tblMemberFirmOffices.OfficeID = '$officeid') AND (tblMemberFirmOffices.FullOrPartTime = 'Full Time') AND (tblMemberFirmOffices.FirmID = tblMemberFirms.FirmID)";
		//echo $sql;
		echo "<h2>Member Firm Details</h2>";
		
		$result = mysql_query($sql) or die('An error has occured. Please go back and select another option.');
		$result_rows = mysql_num_rows($result);
		if ($result_rows > 0) {
			while ($row=mysql_fetch_array($result)) {
				echo "<h4>".$row["OfficeName"]."</h4>";
				echo "<p>";
				echo "<table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\">";
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Company</td><td valign=\"top\">".$row["OfficeName"]."</td></tr>";
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Office</td><td valign=\"top\">".$row["OfficeStatus"]."</td></tr>";
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Physical Address</td><td valign=\"top\">";
				if ($row["BldgName"] != '') { echo $row["BldgName"]."<br>"; }
				echo $row["StreetName"]."<br>".$row["Suburb"]."</td></tr>";
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Postal Address</td><td valign=\"top\">";
				if ($row["Address2"] != '') { echo $row["Address2"]."<br>"; }
				echo $row["PostalAddress"]."<br>".$row["TownCity"]."<br>".$row["GeoLocation"]."<br>".$row["PostalCode"]."<br>".$row["Country"]."</td></tr>";
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Geographic Location</td><td valign=\"top\">".$row["GeoLocation"]."</td></tr>";
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Telephone</td><td valign=\"top\">".$row["Telephone"]."</td></tr>";
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Fax</td><td valign=\"top\">".$row["Fax"]."</td></tr>";
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Email</td><td valign=\"top\"><a href=\"mailto:".$row["Email"]."\">".$row["Email"]."</a></td></tr>";
				if ($row["URL"]) {
					if (eregi("http://",$row["URL"])) {
						echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Website</td><td valign=\"top\"><a href=\"".$row["URL"]."\" target=\"new\">".$row["URL"]."</a></td></tr>";
					} else {
						echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Website</td><td valign=\"top\"><a href=\"http://".$row["URL"]."\" target=\"new\">".$row["URL"]."</a></td></tr>";
					}
				} else {
					echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Website</td><td valign=\"top\">None</td></tr>";
				}
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Full or Part Time</td><td valign=\"top\">".$row["FullOrPartTime"]."</td></tr>";
				$total = $row["ProfessionalStaff"] + $row["NonProfTechStaff"] + $row["OtherStaff"];
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Total Staff</td><td valign=\"top\">".$total."</td></tr>";
				echo "<tr><td valign=\"top\" bgcolor=\"$graylight\">Skills & Specialisations</td><td valign=\"top\">";
				if ($row["Acoustics"] == 1) { echo "Accoustics<br>"; }
				if ($row["Agricultural"] == 1) { echo "Agricultural<br>"; }
				if ($row["BuildingServices"] == 1) { echo "Building Services<br>"; }
				if ($row["Chemical"] == 1) { echo "Chemical<br>"; }
				if ($row["Civil"] == 1) { echo "Civil<br>"; }
				if ($row["Development"] == 1) { echo "Development<br>"; }
				if ($row["Electrical"] == 1) { echo "Electrical<br>"; }
				if ($row["Electronic"] == 1) { echo "Electronic<br>"; }
				if ($row["Environmental"] == 1) { echo "Environmental<br>"; }
				if ($row["Geotechnical"] == 1) { echo "Geotechnical<br>"; }
				if ($row["Industrial"] == 1) { echo "Industrial<br>"; }
				if ($row["Mechanical"] == 1) { echo "Mechanical<br>"; }
				if ($row["Marine"] == 1) { echo "Marine<br>"; }
				if ($row["Mining"] == 1) { echo "Mining<br>"; }
				if ($row["Process"] == 1) { echo "Process<br>"; }
				if ($row["Structural"] == 1) { echo "Structural<br>"; }
				if ($row["Transportation"] == 1) { echo "Transportation<br>"; }
				if ($row["Architecture"] == 1) { echo "Architecture<br>"; }
				if ($row["RuralDevelopment"] == 1) { echo "Rural Development<br>"; }
				if ($row["ProjectManagement"] == 1) { echo "Project Management<br>"; }
				if ($row["QuantitySurveying"] == 1) { echo "Quantity Surveying<br>"; }
				if ($row["TownPlanning"] == 1) { echo "Town Planning<br>"; }
				if ($row["Multidisciplinary"] == 1) { echo "Multidisciplinary<br>"; }
				if ($row["DisputeResolution"] == 1) { echo "Dispute Resolution<br>"; }
				if ($row["ExpertWitness"] == 1) { echo "Expert Witness<br>"; }
				if ($row["InformationSystems"] == 1) { echo "Information Systems<br>"; }
				if ($row["FacilitiesManagement"] == 1) { echo "Facilities Management<br>"; }
				if ($row["GIS"] == 1) { echo "GIS<br>"; }
				echo "</td></tr>";
				echo "</table>";
				echo "</p>";
			} //end while
		} //end if
		else 
		{
			echo "No details found";
		}
	} else {
	switch ($action) {
		case 1 :
			$sql = "SELECT tblMemberFirms.FirmName,tblMemberFirmOffices.FullOrPartTime, tblMemberFirmOffices.OfficeID, tblMemberFirmOffices.GeoLocation FROM tblMemberFirms, tblMemberFirmOffices WHERE tblMemberFirms.FirmID = tblMemberFirmOffices.FirmID  AND tblMemberFirmOffices.FullOrPartTime = 'Full Time' AND tblMemberFirms.MemberStatus='Member'";
			switch ($country) {
				case 'any' : 
						break;
				case 'outside' :
						$sql.=" AND tblMemberFirmOffices.Country != 'South Africa'";
						break;
				default : 
						$sql.=" AND tblMemberFirmOffices.Country = '$country'";
						break;
			} //end switch
			if ($provtowncity == '') {
			} else {
				$sql.=" AND (tblMemberFirmOffices.Province LIKE '%$provtowncity%' OR tblMemberFirmOffices.TownCity LIKE '%$provtowncity%' OR tblMemberFirmOffices.GeoLocation LIKE '%$provtowncity%')";
			}
			if ($containing) {
				$sql.=" AND tblMemberFirms.FirmName LIKE '%$containing%'";
			}
			// sql_criteria
			$count_criteria = 
				$Acoustics +
				$Agricultural +
				$BuildingServices +
				$Chemical +
				$Civil +
				$Development +
				$Electrical +
				$Electronic +
				$Environmental +
				$Geotechnical +
				$Industrial +
				$Mechanical +
				$Marine +
				$Mining +
				$Process +
				$Structural +
				$Transportation +
				$Architecture +
				$RuralDevelopment +
				$ProjectManagement +
				$QuantitySurveying +
				$TownPlanning +
				$Multidisciplinary +
				$DisputeResolution +
				$ExpertWitness +
				$InformationSystems +
				$FacilitiesManagement +
				$GIS;
			
			if ($count_criteria == 0) {
			
				$sql_criteria = "";
				
			} else {
			
				$sql_criteria = " AND (";
				
				do {
		 			if ($Acoustics == "1") { $sql_criteria .= " OR tblMemberFirms.Acoustics = $Acoustics"; $countposition++; } else { $sql_criteria .= ""; }
					if ($Agricultural == "1") { $sql_criteria .= " OR tblMemberFirms.Agricultural = $Agricultural "; $countposition++; } else { $sql_criteria .= ""; }
					if ($BuildingServices == "1") { $sql_criteria .= " OR tblMemberFirms.BuildingServices = $BuildingServices "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Chemical == "1") { $sql_criteria .= " OR tblMemberFirms.Chemical = $Chemical "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Civil == "1") { $sql_criteria .= " OR tblMemberFirms.Civil = $Civil "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Development == "-") { $sql_criteria .= " OR tblMemberFirms.Development = $Development "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Electrical == "1") { $sql_criteria .= " OR tblMemberFirms.Electrical = $Electrical "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Electronic == "1") { $sql_criteria .= " OR tblMemberFirms.Electronic = $Electronic "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Environmental == "1") { $sql_criteria .= " OR tblMemberFirms.Environmental = $Environmental "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Geotechnical == "1") { $sql_criteria .= " OR tblMemberFirms.Geotechnical = $Geotechnical "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Industrial == "1") { $sql_criteria .= " OR tblMemberFirms.Industrial = $Industrial "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Mechanical == "1") { $sql_criteria .= " OR tblMemberFirms.Mechanical = $Mechanical "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Marine == "1") { $sql_criteria .= " OR tblMemberFirms.Marine = $Marine "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Mining == "1") { $sql_criteria .= " OR tblMemberFirms.Mining = $Mining "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Process == "1") { $sql_criteria .= " OR tblMemberFirms.Process = $Process "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Structural == "1") { $sql_criteria .= " OR tblMemberFirms.Structural = $Structural "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Transportation == "1") { $sql_criteria .= " OR tblMemberFirms.Transportation = $Transportation "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Architecture == "1") { $sql_criteria .= " OR tblMemberFirms.Architecture = $Architecture "; $countposition++; } else { $sql_criteria .= ""; }
					if ($RuralDevelopment == "1") { $sql_criteria .= " OR tblMemberFirms.RuralDevelopment = $RuralDevelopment "; $countposition++; } else { $sql_criteria .= ""; }
					if ($ProjectManagement == "1") { $sql_criteria .= " OR tblMemberFirms.ProjectManagement = $ProjectManagement "; $countposition++; } else { $sql_criteria .= ""; }
					if ($QuantitySurveying == "1") { $sql_criteria .= " OR tblMemberFirms.QuantitySurveying = $QuantitySurveying "; $countposition++; } else { $sql_criteria .= ""; }
					if ($TownPlanning == "1") { $sql_criteria .= " OR tblMemberFirms.TownPlanning = $TownPlanning "; $countposition++; } else { $sql_criteria .= ""; }
					if ($Multidisciplinary == "1") { $sql_criteria .= " OR tblMemberFirms.Multidisciplinary = $Multidisciplinary "; $countposition++; } else { $sql_criteria .= ""; }
					if ($DisputeResolution == "1") { $sql_criteria .= " OR tblMemberFirms.DisputeResolution = $DisputeResolution "; $countposition++; } else { $sql_criteria .= ""; }
					if ($ExpertWitness == "1") { $sql_criteria .= " OR tblMemberFirms.ExpertWitness = $ExpertWitness "; $countposition++; } else { $sql_criteria .= ""; }
					if ($InformationSystems == "1") { $sql_criteria .= " OR tblMemberFirms.InformationSystems = $InformationSystems "; $countposition++; } else { $sql_criteria .= ""; }
					if ($FacilitiesManagement == "1") { $sql_criteria .= " OR tblMemberFirms.FacilitiesManagement = $FacilitiesManagement "; $countposition++; } else { $sql_criteria .= ""; }
					if ($GIS == "1") { $sql_criteria .= " OR tblMemberFirms.GIS = $GIS "; $countposition++; } else { $sql_criteria .= ""; }
					$countposition++;
			
				} while ($countposition < $count_criteria);
		 	
				$sql_criteria .= ") ";
			  	$sql_criteria = str_replace(" OR )", ")", $sql_criteria);
				$sql_criteria = str_replace("( OR ", "( ", $sql_criteria);
				$sql.=$sql_criteria;
			}
			
			//echo $sql;
			$result = mysql_query($sql);
			$result_rows = mysql_num_rows($result);
			
			echo "<h3>Matching Member Firms:</h3>";
			
			
			if ($result_rows > 0 ) {
			
				echo "<p class=\"footer\">The following <b>" . $result_rows . " results</b> match your search criteria.<br><font color=\"#cc0000\">Please note: The order of the displayed results have been randomised to provide equal opportunity for our members.</font></p><p class=\"footer\">Click on a company name for further information</p>";
				echo "<table width=\"400\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr bgcolor=\"#cc0000\"><th>Member</th><th>Geographic Region</th></tr>";
			
				// Randomise using array functions instead of ansi sql order by
		 		$numbers = range(0,$result_rows-1);
				srand((double)microtime()*1000000);
				shuffle($numbers);
				while (list(,$number) = each($numbers)) {
			    		
			    		if ($number >=$result_rows) {
					
					} else {
						$moverow = mysql_data_seek($result,$number);
					}
				
				$row = mysql_fetch_array($result);
				echo "<tr><td><font size=\"-2\"><a href=\"$PHP_SELF?officeid=". $row["OfficeID"]. "\">" . $row["FirmName"] . "</a></font></td><td><font size=\"-2\">" . $row["GeoLocation"]."</font></td></tr>";
				}
				
				echo "</table>";
			
			} else {
			
				echo "<p><b>Sorry, there were no matches for your search criteria.</b><br> Please <a href=\"$PHP_SELF\">go back</a> and try more general search options.</p>";
			
			}
			// Free Database Memory
			mysql_free_result($result);
			break;
		default : 
			?>
			<h2>Search the CESA Member database:</h2>
			<p>
			<b>To make it easier to search:</b>
			<ul>
			<li>Leaving an item blank will allow the system to search all/any records. 
			<li>Choosing additional search criteria will reduce the possibility of a match. 
			<li>Not checking any skill is the same as selecting all skills 
			<li><b>Hint:</b> if you are looking for a particular skill, ONLY select the one you want. 
			</ul>
			<p></p>
			<p>
			<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
			<b>Search for a member</b>
			<select name="country">
			<option value="any" selected>Anywhere
			<option value="outside">Outside of South Africa
			<?php
			$sql = "select distinct(Country) from tblMemberFirmOffices order by Country";
			$result = mysql_query($sql);
			while ($row=mysql_fetch_array($result)) {
				echo "<option value=\"".$row["Country"]."\">".$row["Country"];
			}
			?>
			</select>
			<br>optional province/city/town <input type="text" name="provtowncity"><br><br>
			<p></p>
			<p>
			<b>with a name containing the words </b><input type="text" name="containing">
			</p>
			<p>
			<b>and having the following specialisations or skills</b>
			<br>
			<table width="450" border="0" cellpaddi</form>