Exemple #1
0
function wp_ntreis_list()
{
    // include_once("header.php");
    global $wpdb, $plugin_dir;
    $sql = "SELECT * FROM " . $wpdb->prefix . "agentaccount ";
    $results = $wpdb->get_results($sql);
    $db_ip = $results[0]->host;
    $db_user = $results[0]->db_user;
    $db_pass = $results[0]->password;
    $db_name = $results[0]->db;
    $agent_offcode = $results[0]->agent_offcode;
    $office = $results[0]->agent_username;
    $rets_area = $results[0]->rets_area;
    $con = mysql_connect($db_ip, $db_user, $db_pass);
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db($db_name, $con);
    $proptype = 'all';
    if (!empty($rets_area)) {
        //if mls
        $WHERE_0fficelist = " officelist = '" . $agent_offcode . "' AND (rets_area = '" . $rets_area . "' OR rets_area = 'manual_" . $agent_offcode . "') ";
    } else {
        //manual only
        $WHERE_0fficelist = " officelist = '" . $agent_offcode . "' AND  rets_area = 'manual_" . $agent_offcode . "' ";
    }
    if (!empty($_GET['city'])) {
        $WHERE_0fficelist = " city = '" . $_GET['city'] . "' ";
    }
    $sql = "select * from ntreislist where " . $WHERE_0fficelist . " and (liststatus LIKE 'Active%' or liststatus LIKE 'Pending%') and delete_status = '0' order by replace(listprice, ',', '')+0 desc";
    $tkeqry = $wpdb->get_results($sql);
    $Num_Rows = count($tkeqry);
    // Number of Records
    $Per_Page = 50;
    // Records Per Page
    $Page = empty($_REQUEST['pageid']) ? 1 : $_REQUEST['pageid'];
    $Prev_Page = $Page - 1;
    $Next_Page = $Page + 1;
    $Page_Start = $Per_Page * $Page - $Per_Page;
    $Num_Pages = ceil($Num_Rows / $Per_Page);
    $sql .= " limit {$Page_Start} , {$Per_Page}";
    $myrows = array();
    $sql = mysql_query($sql);
    while ($row = mysql_fetch_assoc($sql)) {
        $myrows[] = $row;
    }
    $cntsqls = "select count(proptype) as cntprop,proptype from ntreislist where " . $WHERE_0fficelist . " and delete_status = '0' group by proptype ";
    $cntsqls1 = mysql_query($cntsqls);
    $ths = listing_table_headers($proptype);
    if (empty($proptype) || in_array($proptype, array('Residential', 'Residential Lots', 'Commercial', 'all'))) {
        $rowspan = 7;
    } else {
        $rowspan = 6;
    }
    ?>

	<div id="imge_load"></div>

	<div id="ajax_rep_div" class="amerisale">
	
		<!-- Listing Search  Start -->
		<?php 
    echo property_search_form($cntsqls1);
    ?>

		<div class="property-count"><strong><?php 
    echo $Num_Rows;
    ?>
</strong> Listings</div>

		<table class="res-table propert-list-table">
			<thead>
			<tr>
				<?php 
    echo $ths;
    ?>
			</tr>
			</thead>
			<tbody>
				<?php 
    if ($Num_Rows > 0) {
        foreach ($myrows as $key => $values) {
            //$sql = "select imagename from ntreisimages where mlsnum = ".$values['MLS']." order by recordListingID ASC limit 1";
            $sql = "select imagename from ntreisimages where n_id = " . $values['id'] . " order by recordListingID, id ASC limit 1";
            $sqls = mysql_query($sql);
            @($ress = mysql_fetch_assoc($sqls));
            $ntr_images = empty($ress['imagename']) ? get_bloginfo('url') . '/wp-content/plugins/amerisale-re/images/imgres1.png' : $ress['imagename'];
            $side_search = !empty($_GET['city']) ? '&side=y' : '';
            echo display_property_list_table($values, $proptype = 'all', $ntr_images, $side_search);
        }
    } else {
        echo '<td rowspan="' . $rowspan . '"><span class="no_results">Sorry, No Record Found</span></td>';
    }
    ?>
			</tbody>
		</table>

	
		<?php 
    if ($Num_Rows > $Per_Page) {
        ?>

		<div class="paginations">
			<ul>
				<br clear='all' />

				<?php 
        $firstlabel = "&laquo;&nbsp;";
        $prevlabel = "&lsaquo;&nbsp;";
        $nextlabel = "&nbsp;&rsaquo;";
        $lastlabel = "&nbsp;&raquo;";
        $page = $Page <= 0 ? 1 : $Page;
        $tpages = $Num_Pages;
        // 50 by default
        $adjacents = $_GET['adjacents'] <= 0 ? 5 : $_GET['adjacents'];
        $out = "<div class=\"pagin\">\n";
        // first
        if ($page > $adjacents + 1) {
            $out .= "<a href=\"JavaScript:get_ntreis_pages('{$proptype}','1','','')\" class='page_img'>" . $firstlabel . "</a>\n";
        } else {
            $out .= "<span>" . $firstlabel . "</span>\n";
        }
        // previous
        if ($page == 1) {
            $out .= "<span>" . $prevlabel . "</span>\n";
        } elseif ($page == 2) {
            $out .= "<a href=\"JavaScript:get_ntreis_pages('{$proptype}','{$tpages}','','')\" class='page_img'>" . $prevlabel . "</a>\n";
        } else {
            $decrpage = $page - 1;
            $out .= "<a href=\"JavaScript:get_ntreis_pages('{$proptype}','{$decrpage}','','')\" class='page_img'>" . $prevlabel . "</a>\n";
        }
        // 1 2 3 4 etc
        $pmin = $page > $adjacents ? $page - $adjacents : 1;
        $pmax = $page < $tpages - $adjacents ? $page + $adjacents : $tpages;
        for ($i = $pmin; $i <= $pmax; $i++) {
            if ($i == $page) {
                $out .= "<span class=\"current\">" . $i . "</span>\n";
            } elseif ($i == 1) {
                $out .= "<a href=\"JavaScript:get_ntreis_pages('{$proptype}','{$i}','','')\" class='page_img'>" . $i . "</a>\n";
            } else {
                $out .= "<a href=\"JavaScript:get_ntreis_pages('{$proptype}','{$i}','','')\" class='page_img'>" . $i . "</a>\n";
            }
        }
        // next
        if ($page < $tpages) {
            $incrpage = $page + 1;
            $out .= "<a href=\"JavaScript:get_ntreis_pages('{$proptype}','{$incrpage}','','')\" class='page_img'>" . $nextlabel . "</a>\n";
        } else {
            $out .= "<span>" . $nextlabel . "</span>\n";
        }
        // last
        if ($page < $tpages - $adjacents) {
            $out .= "<a href=\"JavaScript:get_ntreis_pages('{$proptype}','{$tpages}','','')\" class='page_img'>" . $lastlabel . "</a>\n";
        } else {
            $out .= "<span>" . $lastlabel . "</span>\n";
        }
        $out .= "</div>";
        echo $out;
        ?>
			</ul>
		</div>	
	</div>

<?php 
    }
    //mysql_close($commcon);
    // Reset DB Conn
    mysql_select_db(DB_NAME);
}
						</a><br>
						<a href="' . get_bloginfo('url') . '/viewproperty?mls=' . $values['MLS'] . $side_search . '" class="property_title1" >View Details</a>
					</td>' . $td_opt . '
					<td>' . $values['proptype'] . '</td>
					<td>' . $address . '</td></tr>';
    }
}
?>



<div id="amerisale" class="content amerisale">

	<!-- Listing Search  Start -->
	<?php 
echo property_search_form($cntsqls1, $_REQUEST);
?>


	<div class="property-count"><strong><?php 
echo $Num_Rows;
?>
</strong> Listings</div>

	<table class="res-table propert-list-table">
		<thead>
		<tr>
			<?php 
echo $ths;
?>
		</tr>