Sample Sidebar Module

This is a sample module published to the sidebar_top position, using the -sidebar module class suffix. There is also a sidebar_bottom position below the menu.
RD Store

Sample Sidebar Module

This is a sample module published to the sidebar_bottom position, using the -sidebar module class suffix. There is also a sidebar_top position below the search.
Find an RD

Northern Virginia Academy of Nutrition and Dietetics

  • RD Store

{source}

<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<header>
<script type="text/javascript">
function change() // no ';' here
{
var elem = document.getElementById("showmenu_expertise");
if (elem.value=="Find by Expertise") elem.value = "Hide Expertise Areas";
else elem.value = "Find by Expertise";
}
</script>

 <?php 

// no direct access

defined('_JEXEC') or die;

 

$doc = JFactory::getDocument();

JHtml::_('jquery.framework'); 

$doc->addScriptDeclaration(' jQuery(document).ready(function () { jQuery("#showmenu_expertise").click(function() {

jQuery(".menu_skill").toggle("fast");

});

}); 

')

?>


<title></title>
<style>
.cb-div {
width: 50%;
display:block;
float: left;
}
.cb2-div {
width: 50%;
display:block;
float: right;
}
.button {
background-color: #B21B3A;
}
div.two{
border: 2px solid #a1a1a1;
padding: 10px 40px;
background: #F5F5F5;
width: 80%;
border-radius: 25px;
}

p {color:#B21B3A}

.Table

{

display: table;

}

.Title

{

display: table-caption;

text-align: center;

font-weight: bold;

font-size: larger;

}

.Heading

{

display: table-row;

font-weight: bold;

text-align: center;

}

.Row

{

display: table-row;

}

.Cell

{

display: table-cell;

height: auto;



min-width :500px;

padding-left: 5px;

padding-right: 5px;



}.rightCell

{

display: table-cell;

height: auto;



padding-left: 5px;

padding-right: 1px;

}

</style>
</header>
<div class="two">
<form>
<label>Enter your ZIP Code &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input maxlength="6" name="zipcode" id="zipcode" size="25" type="text" <?php if(isset($_POST['zipcode'])){ echo "value=".$_POST['zipcode']; }else{echo "autofocus";}?> ></label>

<label>Select search radius (in miles) &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
<select name="distance" style="height: 40px;">
<option>5</option>
<option>10</option>
<option selected="selected">25</option>
<option>50</option>
<option>100</option>
<option value="0">Ignore Distance Limit</option>
</select></label><br />
<?php
$link = mysql_connect('localhost', 'northfb2_nutriti','nvand7224$$') or die('Cannot connect to database server');
mysql_select_db('northfb2_nutrition') or die('Cannot select database');
if(!$rs = mysql_query("SELECT * FROM expertise ORDER BY skill ASC")) {

echo "<strong>No RD's found matching your search criteria.</strong> \n";
}

$k=0;
if (mysql_num_rows($rs) > 0){
// output data of each row
while($row = mysql_fetch_assoc($rs)) {
?>
<div class="menu_skill" <?php if(isset($_POST['check_list'])){ echo "'"; }else{ echo "style='display: none'"; }?>>

<span class="cb-div">

<?php

if(isset($_POST['check_list'])){



$selected = $_POST['check_list'];
while( $k <=count($selected)) {
if($row["skill"]===$selected[$k]){

?>

<label><input type="checkbox" name="check_list[]" value="<?=$row["skill"] ?>" <?php echo "checked='checked'"; ?>><?=" ".$row["skill"] ?></label>

<?php

$k++;

break;

}else{

?>

<label><input type="checkbox" name="check_list[]" value="<?=$row["skill"] ?>"><?=" ".$row["skill"] ?></label>

<?php

break;

}

}

if($k>count($selected)){

?>

<label><input type="checkbox" name="check_list[]" value="<?=$row["skill"] ?>"><?=" ".$row["skill"] ?></label>

<?php



}

}else{

?>

<label><input type="checkbox" name="check_list[]" value="<?=$row["skill"] ?>"><?=" ".$row["skill"] ?></label>

<?php

}

?>



</span></div>
<?php
}
}
?>

<input name="submit" type="submit"value="Search Now" class="button" />

<input name ="Find by Expertise"id="showmenu_expertise" type="button" <?php if(isset($_POST['check_list'])){ echo "value='Hide Expertise Areas'"; }else{ echo "value='Find by Expertise'"; }?> class="button" onclick="change()"/>

</div>
</form>
<?php
// Get a handle to the Joomla! application object
$application = JFactory::getApplication();
$str="";
$str2="";
$text2="";
$flag=false;

$countSkill=0;

$oJSON="";
$Search_result = array();
if(isset($_POST['submit'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
// Loop to store and display values of individual checked checkbox.
foreach($_POST['check_list'] as $selected){
//echo $selected."</br>";
$str.="'".$selected."'".',';
$str2.=$selected.', ';

$countSkill++;
}
}
}
$text2 = rtrim($str,',');
$str2=rtrim($str2, ', ');
function curl_request($sURL,$sQueryString=null) {
$cURL=curl_init();
curl_setopt($cURL,CURLOPT_URL,$sURL.'?'.$sQueryString);
curl_setopt($cURL,CURLOPT_RETURNTRANSFER, TRUE);
$cResponse=trim(curl_exec($cURL));
curl_close($cURL);
return $cResponse;
}
if(isset($_POST['submit'])) {

//connect to db server; select database

$link = mysql_connect('localhost', 'northfb2_nutriti','nvand7224$$') or die('Cannot connect to database server');
mysql_select_db('northfb2_nutrition') or die('Cannot select database');

$skill_query=" SELECT mem.* FROM members mem JOIN rd_skills rs ON rs.member_id = mem.id JOIN expertise exp ON exp.id = rs.expertise_id WHERE exp.skill IN (".$text2.") GROUP BY mem.id HAVING COUNT(DISTINCT exp.skill) = ".$countSkill;



if(!empty($_POST['check_list']) && !empty($_POST['zipcode'])){

if(!$rs = mysql_query($skill_query)) {

echo "<strong>No RD's found matching your search criteria.</strong> \n";
}
echo "<h3><strong>Search results for: </strong><br><strong> Zipcode - </strong>".$_POST['zipcode']." <br> <strong>Expertise -</strong>".$str2."</h3>";


}else if(!empty($_POST['zipcode'])){

if(!$rs = mysql_query("SELECT rd.* FROM members as rd ")) {
echo "<strong>No RD's found matching your search criteria.</strong> \n";
}
echo "<h3><strong>Search results for:</strong><br><strong>Zipcode -</strong>".$_POST['zipcode']."</h3>";


}else if(!empty($_POST['check_list'])){

if(!$rs = mysql_query($skill_query)) {

echo "<strong>No RD's found matching your search criteria.</strong> \n";
}
echo "<h3><strong>Search results for:</strong><br><strong>Expertise -</strong>".$str2."</h3>";
}else{
echo "<strong><p>Please specify a search criteria.</p></strong> \n";
}
echo "<hr>" ;
$bool=false;
if (mysql_num_rows($rs) > 0){
// output data of each row
while($row = mysql_fetch_assoc($rs)) {
$to = $row["Business_Address"]." ".$row["City"]." ".$row["State"]." ".$row["Zip_Code"];

$to = urlencode($to);

if((!empty($_POST['zipcode'])&& !empty($_POST['check_list'])) || !empty($_POST['zipcode']) ){
$sResponse=curl_request('https://maps.googleapis.com/maps/api/distancematrix/json',
'origins='.$_POST['zipcode'].'&destinations='.$to.'&mode=driving&units=imperial&sensor=false&key=AIzaSyCKSn82U-WuabQf2U_-L3x-CN3eVScFTsQ');

$oJSON = json_decode($sResponse);

$str= $oJSON->origin_addresses;

$str1=substr($str[0],-3);

if(strcmp($str1,"USA") != 0){

echo "<strong><p>Please enter a valid USA zip code!</p></strong> \n";

break;

}



if ($oJSON->status == 'OK'){
$fDistanceInMiles =(float)preg_replace('/[^\d\.]/','',$oJSON->rows[0]->elements[0]->distance->text);
//$fDistanceInMiles =miles2kms($fDistanceInMiles);
$fDistanceInMiles =number_format($fDistanceInMiles,1, '.', ',');
}else{$fDistanceInMiles = 0;}


if($_POST['distance']==0){
if($fDistanceInMiles>$_POST['distance']){
$flag=true;
$Search_row = array();
if( $row['Zip_Code']!=null){

$Search_row = array();
$serach_row["id"] = $row['id'];
$serach_row["Name"] = $row['Name'];
$serach_row["Credentials"] = $row['Credentials'];

$serach_row["Business_Name"] = $row['Business_Name'];
$serach_row["Business_Address"] = $row['Business_Address'];
$serach_row["City"] = $row['City'];
$serach_row["State"] = $row['State'];
$serach_row["Zip_Code"] = $row['Zip_Code'];
$serach_row["Work_Phone"] = $row['Work_Phone'];
$serach_row["E_Mail_Address"] = $row['E_Mail_Address'];
$serach_row["Website"] = $row['Website'];
$serach_row["distance"] = $fDistanceInMiles;
$Search_result[] = $serach_row;
}
}else{
$bool=true;
}
}else{
if($fDistanceInMiles<=$_POST['distance']){
$flag=true;
$Search_row = array();
if( $row['Zip_Code']!=null){

$Search_row = array();
$serach_row["id"] = $row['id'];
$serach_row["Name"] = $row['Name'];
$serach_row["Credentials"] = $row['Credentials'];

$serach_row["Business_Name"] = $row['Business_Name'];

$serach_row["Business_Address"] = $row['Business_Address'];
$serach_row["City"] = $row['City'];
$serach_row["State"] = $row['State'];
$serach_row["Zip_Code"] = $row['Zip_Code'];
$serach_row["Work_Phone"] = $row['Work_Phone'];
$serach_row["E_Mail_Address"] = $row['E_Mail_Address'];
$serach_row["Website"] = $row['Website'];
$serach_row["distance"] = $fDistanceInMiles;
$Search_result[] = $serach_row;
}

}
else{
$bool=true;
}
}
}
else{

echo "<div class='Table'>";



echo "<div class='Row'>";



echo "<div class='Cell'>";

if($row['Name']!=null){

echo "<strong>".trim($row['Name'])."</strong>";

}

if($row['Credentials']!=null){

echo "<strong>, ".$row['Credentials']."</strong>"."<br>";

}else{

echo "<br>";

}

if($row['Business_Name']!=null){

echo $row['Business_Name']. "<br> ";



}

if($row['Business_Address']!=null){
echo $row['Business_Address']. "<br> ";}

echo $row['City']. " , " . $row['State']. " " . $row['Zip_Code']."<br>";


if($row['Work_Phone']!=null){
echo $row['Work_Phone']."<br>";
}

if($row['E_Mail_Address']!=null){
echo $row['E_Mail_Address']."<br>";
}

if($row['Website']!=null){
echo '<a href="http://'.$row['Website'].'" target="_blank">'.$row['Website'].'</a><br>';
}
echo "</div>";
echo "<div class='rightCell'>";

echo "<br>";




echo '<a href="https://www.google.com/maps?saddr&daddr='.$row['Business_Address']." ".$row['City']." ".$row['State']." ".$row['Zip_Code'].'" target="_blank">Get Directions</a><br> ';

echo '<a href="http://northernvirginiadietitians.org/index.php/expert-details?rd_id='.$row['id'].'"target="_blank" >View Details </a><br>';


echo"</div>";

echo "</div>";

echo "</div>";

echo"<hr>";

}
}

if ($oJSON->status == 'OVER_QUERY_LIMIT'){

$to = "This email address is being protected from spambots. You need JavaScript enabled to view it.";
$subject = "Regarding website";
$txt = "your google api query is out of limit!";
$headers = "From:http://northernvirginiadietitians.org/";

mail($to,$subject,$txt,$headers);

$application->enqueueMessage(JText::_('Due to server issue, distance cannot be calculated in search. Please visit again to check distance.'), 'error');

}


$sort_Dis= array();
foreach ($Search_result as $key => $row)
{
$sort_Dis[$key] = $row['distance'];
}
$i = 0;
array_multisort($sort_Dis, SORT_NUMERIC, $Search_result);
foreach ($Search_result as $rec){

if( $i < 40)
{

$id = $rec['id'];
$Name = $rec['Name'];
$Credentials = $rec['Credentials'];

$Business_Name= $rec['Business_Name'];
$Business_Address = $rec['Business_Address'];
$City = $rec['City'];
$State = $rec['State'];
$Zip_Code = $rec['Zip_Code'];
$Work_Phone = $rec['Work_Phone'];
$E_Mail_Address = $rec['E_Mail_Address'];
$Website = $rec['Website'];
$distance = $rec['distance'];

echo "<div class='Table'>";



echo "<div class='Row'>";



echo "<div class='Cell'>";

if($Name!=null){

echo "<strong>".trim($Name)."</strong>";

}

if($Credentials!=null){

echo "<strong>, ".$Credentials."</strong>"."<br>";

}else{

echo "<br>";

}

if($Business_Name!=null){

echo $Business_Name. "<br> ";

}

if($Business_Address!=null){
echo $Business_Address. "<br> ";}

echo $City. " , " . $State. " " . $Zip_Code."<br>";


if($Work_Phone!=null){
echo $Work_Phone."<br>";
}

if($E_Mail_Address!=null){
echo $E_Mail_Address."<br>";
}

if($Website!=null){
echo '<a href="http://'.$Website.'" target="_blank">'.$Website.'</a><br>';
}
echo "</div>";
echo "<div class='rightCell'>";

echo "".'Distance '.$distance ." miles".""."<br>";




echo '<a href="https://www.google.com/maps?saddr&daddr='.$Business_Address." ".$City." ".$State." ".$Zip_Code.'" target="_blank">Get Directions</a><br> ';

echo '<a href="http://northernvirginiadietitians.org/index.php/
expert-details?rd_id='.$id.'" target="_blank">View Details </a><br>';



echo "</div>";

echo "</div>";

echo "</div>";

echo "<hr>";
$i++;

}

}
}else{
echo "<strong><p>No RDs found.Please try again.</p></strong> \n";
}
if($bool==true && $flag==false){
echo "<strong><p>Please increase distance no near by RDs found!</p></strong> \n";
}
}


?>

{/source}