Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/php/
Upload File :
Current File : /var/www/cesa.co.za/php/practicenotes_search.php

<?php 
include_once("memberauth.php");
include_once('inc_db.php'); 
?>
				<div data-elementor-type="wp-page" data-elementor-id="3428" class="elementor elementor-3428" data-elementor-settings="[]">
						<div class="elementor-inner">
							<div class="elementor-section-wrap">
							<section class="elementor-section elementor-top-section elementor-element elementor-element-5a57a73 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="5a57a73" data-element_type="section" data-settings="{&quot;ekit_has_onepagescroll_dot&quot;:&quot;yes&quot;}">
						<div class="elementor-container elementor-column-gap-default">
							<div class="elementor-row">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-7697602" data-id="7697602" data-element_type="column">
			<div class="elementor-column-wrap elementor-element-populated">
							<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-element-4ebe28c elementor-widget elementor-widget-heading" data-id="4ebe28c" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
			<h1 class="elementor-heading-title elementor-size-default">Practice Notes for Members</h1>		</div>
				</div>
						</div>
					</div>
		</div>
								</div>
					</div>
		</section>
				<section class="elementor-section elementor-top-section elementor-element elementor-element-89752d6 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="89752d6" data-element_type="section" data-settings="{&quot;ekit_has_onepagescroll_dot&quot;:&quot;yes&quot;}">
						<div class="elementor-container elementor-column-gap-default">
							<div class="elementor-row">
					<div class="elementor-column elementor-col-66 elementor-top-column elementor-element elementor-element-002a1b8" data-id="002a1b8" data-element_type="column" style="border:1px solid #CCCCCC; border-radius:5px;">
			<div class="elementor-column-wrap elementor-element-populated">
							<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-element-1da3a11 elementor-widget elementor-widget-heading" data-id="1da3a11" data-element_type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
			<h3 class="elementor-heading-title elementor-size-default">Search the Practice Notes</h3>		</div>
				</div>
				<div class="elementor-element elementor-element-52c1d66 elementor-widget elementor-widget-wp-widget-phpeverywherewidget" data-id="52c1d66" data-element_type="widget" data-widget_type="wp-widget-phpeverywherewidget.default">
				<div class="elementor-widget-container">

<form method="post" action="/practice-notes-search">
<input type="hidden" name="go" value="1">
<table border=0>
    <tr><td><b>PN Number:</b></td><td><input type="text" name="searchref" placeholder="e.g. PN5 - optional" value="<?php echo $_REQUEST["searchref"]; ?>"></td></tr>
    <tr><td><b>Category:</b></td><td>
    <select name="searchcat" class="catSelect">
    <option value=""<?php if (!isset($_REQUEST["searchcat"]) || empty($_REQUEST["searchcat"])) echo " selected"; ?>>All / Any</option>
<?php
$sql = "SELECT DISTINCT Category FROM PracticeNotes_2021 ORDER BY Category";
			$result = mysqli_query($conni, $sql);
			while($row = mysqli_fetch_array($result)) {
?>
	
                <option value="<?php echo str_replace(array(" ",","),array("_","."),$row["Category"]); ?>"<?php if (isset($_REQUEST["searchcat"]) && ($_REQUEST["searchcat"]==$row["Category"])) echo " selected"; ?>><?php echo $row["Category"]; ?></option>
<?php
}
?>                
    </select></td></tr>
    <tr><td><b>Sub-Category:</b></td><td><select name="searchsubcat" class="subSelect">
    <option value="" class="static"<?php if (!isset($_REQUEST["searchsubcat"]) || empty($_REQUEST["searchsubcat"])) echo " selected"; ?>>All / Any</option>
<?php
$sql = "SELECT DISTINCT Category, SubCategory FROM PracticeNotes_2021 ORDER BY Category, SubCategory";
			$result = mysqli_query($conni, $sql);
			while($row = mysqli_fetch_array($result)) {
?>
	
                <option value="<?php echo $row["SubCategory"]; ?>" class="sub_<?php echo str_replace(array(" ",","),array("_","."),$row["Category"]); ?>"<?php if (isset($_REQUEST["searchsubcat"]) && ($_REQUEST["searchsubcat"]==$row["SubCategory"])) echo " selected"; ?>><?php echo $row["SubCategory"]; ?></option>
<?php
}
?>
    </select></td></tr>
    <tr><td><b>Keyword/s:</b></td><td><input type=text name="searchkeyword" placeholder="optional" value="<?php echo $_REQUEST["searchkeyword"]; ?>"></td></tr>
    <tr><td>&nbsp;</td><td><input type="checkbox" name="searcharchived" value="y"<?php if (!isset($_REQUEST["searcharchived"]) || ($_REQUEST["searcharchived"]=="y")) echo " checked"; ?>> Include archived practice notes</td></tr>
    <tr><td colspan=2 align="center" style="text-align:center"><input type="submit" value="Search Now"></tr>
    </table>    
</form>

				</div>
				</div>
						</div>
					</div>
		</div>
				<div class="elementor-column elementor-col-33 elementor-top-column elementor-element elementor-element-7c2465e" data-id="7c2465e" data-element_type="column">
			<div class="elementor-column-wrap elementor-element-populated">
							<div class="elementor-widget-wrap">
						<div class="elementor-element elementor-element-9cbab9c elementor-align-center elementor-widget elementor-widget-button" data-id="9cbab9c" data-element_type="widget" data-widget_type="button.default">
				<div class="elementor-widget-container">
					<div class="elementor-button-wrapper">
			<a href="/practice-notes-help" class="elementor-button-link elementor-button elementor-size-sm" role="button" style="background-color:#3D58AE">
						<span class="elementor-button-content-wrapper">
						<span class="elementor-button-icon elementor-align-icon-left">
				<i aria-hidden="true" class="fas fa-question-circle"></i>			</span>
						<span class="elementor-button-text">Ask a Question</span>
		</span>
					</a>
		</div>
				</div>
				</div>
				<div class="elementor-element elementor-element-67dd9ee elementor-button-info elementor-align-center elementor-widget elementor-widget-button" data-id="67dd9ee" data-element_type="widget" data-widget_type="button.default">
				<div class="elementor-widget-container">
					<div class="elementor-button-wrapper">
			<a href="/practice-notes-list-2021/" class="elementor-button-link elementor-button elementor-size-sm" role="button" style="background-color:#3D58AE">
						<span class="elementor-button-content-wrapper">
						<span class="elementor-button-icon elementor-align-icon-left">
				<i aria-hidden="true" class="fas fa-list"></i>			</span>
						<span class="elementor-button-text">Full List of Practice Notes</span>
		</span>
					</a>
		</div>
				</div>
				</div>
				<p>There are currently <?php echo mysqli_num_rows(mysqli_query($conni,"SELECT * FROM PracticeNotes_2021")); ?> practice notes available. Please use the search form on the left to search the database, or access the full list by category using the button above.</p>
				<p>Archived practice notes are provided for background reading, but have been superseded by new versions.</p>
				<p><b><i>&copy; Consulting Engineers South Africa. The practice notes remain the property of CESA and may not be distributed without authorisation.</i></b></p>
				
						</div>
					</div>
		</div>
								</div>
					</div>
		</section>
						</div>
						</div>
					</div>
			

<?php
	
if (isset($_POST) && ($_POST["go"]==1)) {
	LogUserActivity("Search Practice Notes");
	
	$searchkeyword = mysqli_real_escape_string($conni, $_REQUEST["searchkeyword"]);
	$searchkeyword=strtolower(str_replace(array(" ",","),"%",$searchkeyword));
	
	$searchcat = mysqli_real_escape_string($conni, $_REQUEST["searchcat"]);
	$searchcat=str_replace(array("_","."),array(" ",","),$searchcat);
	
	$searchsubcat = mysqli_real_escape_string($conni, $_REQUEST["searchsubcat"]);
	$searchref = strtolower(mysqli_real_escape_string($conni, $_REQUEST["searchref"]));
	
	$sql="SELECT * FROM PracticeNotes_2021 WHERE (Status='Current'";
	if ($_REQUEST["searcharchived"]=="y") $sql.=" OR Status='Archived'";
	$sql.=")";
	if (!empty($searchkeyword)) {
		$sql .= " AND (LOWER(Title) like '%".$searchkeyword."%' OR LOWER(Keywords) like '%".$searchkeyword."%')";
	}
	if (!empty($searchcat)) {
		$sql.=" AND Category='".$searchcat."'";
	}
	if (!empty($searchsubcat)) {
		$sql.=" AND SubCategory='".$searchsubcat."'";
	}
	if (!empty($searchref)) {
		$sql.=" AND LOWER(PNNo) LIKE '%".$searchref."%'";
	}
	$sql.=" ORDER BY Category, SubCategory, PNNo, Title";

	$result = mysqli_query($conni, $sql);
	$result_rows = mysqli_num_rows($result);
	if ($result_rows > 0 ) {
?>
<h1>Search Results:</h1>
<p>The following <b><?php echo $result_rows; ?> results</b> match your search criteria.</p>
<?php
		include("inc_practicenoteslist.php");
	} else {
	
		echo "<p><br><B>No results found. Please try a wider search criteria or a simpler keyword.</b></p>";
	}
	mysqli_free_result($result);
}
?>
<script>
function docascadeSelect(parent, child) {
 var childOptions = child.find('option:not(.static)');
 child.data('options',childOptions);
 
 parent.change(function(){
  childOptions.remove();
  child
   .append(child.data('options').filter('.sub_' + this.value))
   .change();
 })
 
 childOptions.not('.static, .sub_' + parent.val()).remove();
}

jQuery(document).ready(function( $ ) {
	catSelect = $('.catSelect');
	subSelect = $('.subSelect');
	 
	docascadeSelect(catSelect, subSelect);
});

</script>