get_results($sql, ARRAY_A);
if(isset($_POST['id']) && $_POST['action']=='delete'){
$total_deleted = 0;
foreach($_POST['id'] as $key => $value) {
$delete_mlsid = $wpdb->get_results("SELECT * FROM ".AEM_PLUGIN_DB_Table." WHERE id = ".$value." LIMIT 1", ARRAY_A);
if(count($delete_mlsid ) > 0) {
$selected_mlsid_before = $wpdb->get_results("SELECT * FROM ".AEM_PLUGIN_DB_Table." WHERE id = ".$value." LIMIT 1", ARRAY_A);
$sql = "DELETE FROM ".AEM_PLUGIN_DB_Table." WHERE id = ".$value." LIMIT 1";
$wpdb->query($sql);
$selected_mlsid_after = $wpdb->get_results("SELECT * FROM ".AEM_PLUGIN_DB_Table." WHERE id = ".$value." LIMIT 1", ARRAY_A);
$total_deleted = ( $total_deleted + ( count($selected_mlsid_before) - count($selected_mlsid_after) ) );
}
}
if($total_deleted > 0) {
echo '
';
echo $total_deleted.' Agents Deleted Successfully.';
echo '
';
} else {
/*
echo '';
echo 'Failed Deleting Agent.';
echo '
';
*/
}
}
if(isset($_GET['id']) && $_GET['action']=='delete'){
$delete_mlsid = $wpdb->get_results("SELECT * FROM ".AEM_PLUGIN_DB_Table." WHERE id = ".$_GET['id']." LIMIT 1", ARRAY_A);
if(count($delete_mlsid ) > 0) {
$sql = "DELETE FROM ".AEM_PLUGIN_DB_Table." WHERE id = ".$_GET['id']." LIMIT 1";
$wpdb->query($sql);
$delete_mlsid = $wpdb->get_results("SELECT * FROM ".AEM_PLUGIN_DB_Table." WHERE id = ".$_GET['id']." LIMIT 1", ARRAY_A);
if(count($delete_mlsid ) <= 0) {
echo '';
echo 'Properties Deleted Successfully.';
echo '
';
} else {
echo '';
echo 'Failed Deleting Property.';
echo '
';
}
}
}
if($_POST['action'] == 'sort') {
$_SESSION['search_mlsid']['where'] = $_POST['where'];
$_SESSION['search_mlsid']['operator'] = $_POST['operator'];
$_SESSION['search_mlsid']['value'] = $_POST['value'];
$_SESSION['search_mlsid']['sortBy'] = $_POST['sortBy'];
$_SESSION['search_mlsid']['ascdesc'] = $_POST['ascdesc'];
}
if(!isset($_SESSION['search_mlsid']['where']) || empty($_SESSION['search_mlsid']['where'])) {
$_SESSION['search_mlsid']['where'] = "none";
}
if(!isset($_SESSION['search_mlsid']['operator']) || empty($_SESSION['search_mlsid']['operator'])) {
$_SESSION['search_mlsid']['operator'] = "";
}
if(!isset($_SESSION['search_mlsid']['value']) || empty($_SESSION['search_mlsid']['value'])) {
$_SESSION['search_mlsid']['value'] = "";
}
if(!isset($_SESSION['search_mlsid']['sortBy']) || empty($_SESSION['search_mlsid']['sortBy'])) {
$_SESSION['search_mlsid']['sortBy'] = "MLS";
}
if(!isset($_SESSION['search_mlsid']['ascdesc']) || empty($_SESSION['search_mlsid']['ascdesc'])) {
$_SESSION['search_mlsid']['ascdesc'] = "ASC";
}
$sql = "SELECT * FROM ".AEM_PLUGIN_DB_Table;
if($_SESSION['search_mlsid']['where'] != 'none'){
if($_SESSION['search_mlsid']['operator'] == "LIKE" || $_SESSION['search_mlsid']['operator'] == "NOT LIKE") {
$sql .= " WHERE ".$_SESSION['search_mlsid']['where'].' '.$_SESSION['search_mlsid']['operator']." '%".$_SESSION['search_mlsid']['value']."%' ";
} else {
$sql .= " WHERE ".$_SESSION['search_mlsid']['where'].' '.$_SESSION['search_mlsid']['operator']." '".$_SESSION['search_mlsid']['value']."' ";
}
}
$sql .= " ORDER BY ".$_SESSION['search_mlsid']['sortBy']." ".$_SESSION['search_mlsid']['ascdesc'];
#echo $sql;
// set pagination setting
$frontText = "";
$limit = 10;
$adjacents = 1;
$targetpage = "admin.php?page=agenteasy-properties/properties.php";
$pagestring = "&pg=";
$mlsid_list = $wpdb->get_results($sql, ARRAY_A);
$total_mlsid = count($mlsid_list);
// get current page
if($_GET['pg'] > 0) {
$pg = $_GET['pg']; // get page from the url parameter ( eg. ?pg=2 )
} else {
$pg = 1; // default = page 1
}
// check if current page value is greater than 1 (page 2 and above)
if($pg > 1) {
$offset = (($pg - 1) * $limit);// set the start number of displaying records
} else {
$offset = 0; // default: page 1 will start displaying records from record 1
}
// pagination >> get & set the listings that will be lists
$rec_min = ($offset);
if($total_mlsid > $limit) {
$rec_max = ($offset) + $limit;
} else {
$rec_max = $total_mlsid;
}
$n = $rec_min; // counter
?>
| Shortcodes |
Description |
|
|
When the Agent MLSID is supplied in the Plugin Settings and the Shortcode is on a page, it will display the auto feed of the Agents Active Listings.
|
|
|
When the Agent MLSID is supplied in the Plugin Settings and the Shortcode is on a page, it will display the auto feed of the Agents Sold Listings.
|
1){
$pagination .= "";
#$pagination .= "";
//previous button
if($page > 1) {
$pagination .= " « PREV ";
} else {
//$pagination .= "« prev";
}
//pages
if($lastpage < 7 +($adjacents * 2)) { //not enough pages to bother breaking it up
for($counter = 1; $counter <= $lastpage; $counter++)
{
if($counter == $page) {
$pagination .= "$counter";
} else {
$pagination .= "$counter";
}
}
} elseif($lastpage >= 7 +($adjacents * 2)) { //enough pages to hide some
//close to beginning; only hide later pages
if($page < 1 +($adjacents * 3))
{
for($counter = 1; $counter < 4 +($adjacents * 2); $counter++)
{
if($counter == $page) {
$pagination .= "$counter";
} else {
$pagination .= "$counter";
}
}
$pagination .= "....";
$pagination .= "$lpm1";
$pagination .= "$lastpage";
//in middle; hide some front and some back
} elseif($lastpage -($adjacents * 2) > $page && $page >($adjacents * 2)) {
$pagination .= "1";
$pagination .= "2";
$pagination .= "...";
for($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if($counter == $page) {
$pagination .= "$counter";
} else {
$pagination .= "$counter";
}
}
$pagination .= "...";
$pagination .= "$lpm1";
$pagination .= "$lastpage";
//close to end; only hide early pages
} else {
$pagination .= "1";
$pagination .= "2";
$pagination .= "....";
for($counter = $lastpage -(1 +($adjacents * 3)); $counter <= $lastpage; $counter++)
{
if($counter == $page) {
$pagination .= "$counter";
} else {
$pagination .= "$counter";
}
}
}
}
//next button
if($page < $counter - 1) {
$pagination .= " NEXT »";
} else {
//$pagination .= "next »";
}
$pagination .= "";
}
return $pagination;
}
?>