<?php
// Define constants
define('BROKER_NAME', 'MSLLC Base');
define('WASSERVERURL', 'https://s3.wasabisys.com/nstphotos/');
define('BONSTPHOTOURL', 'https://msllcphotos.xyz/nstphotos/') ;
define('NSTPROPERTIESURL', 'https://bonstdata1.xyz/bonstListingsNew2/');
define('DETAIL_PAGE_URL', 'https://msllcbase.com/propertyDetails.php?mlsnumbers=');
define('NEWPHOTOSERVERURL', 'https://msllcphotos.xyz/nstphotos/') ;

// Database to fetch photos
define("DB_HOST_Photos", "localhost");
define("DB_USER_Photos", "aabonstdataxyz");
define("DB_PASSWORD_Photos", "bSM202al;skdjdi0t9ew");
define("DB_NAME_Photos", "aabonstdataxyz");
define("DB_PORT_Photos", "3306");
$photoConn = new mysqli(DB_HOST_Photos, DB_USER_Photos, DB_PASSWORD_Photos, DB_NAME_Photos, DB_PORT_Photos);

define("ListAgentMlsId", "NST502003048");
define("CoListAgentMlsId", "NST502003048");
define("BuyerAgentMlsId", "NST502003048");
define("CoBuyerAgentMlsId", "NST502003048");
define("ListOfficeMlsId", "NST6781");
define("AgentOne", "NST502017027");
define("AgentTwo", "NST502017762");
define("AgentThree", "NST502003048");

//QUERIES FOR MULTIPLE OFFICES

	define("OfficeName", "Greater Midwest Realty");
	define("CountsTag", "NST502003048");

	
	define("ListOfficeMlsId1", "NST26608");
	define("ListOfficeMlsId2", "NST25881");
	define("ListOfficeMlsId3", "NST25880");
	define("ListOfficeMlsId4", "NST21729");
	define("ListOfficeMlsId5", "NST21728");
	define("ListOfficeMlsId6", "NST21727");
	define("ListOfficeMlsId7", "NST21726");
	define("ListOfficeMlsId8", "NST21725");
	define("ListOfficeMlsId9", "NST21724");
	define("ListOfficeMlsId10", "NST6781");
	define("ListOfficeMlsId11", "NST1860");
	
	define("STATIC_POST_LISTING_QUERY_LOAD", "Select * from bonstlistingsnew2 where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending') AND (
	ListOfficeMlsId = '".ListOfficeMlsId1."' OR
	ListOfficeMlsId = '".ListOfficeMlsId2."' OR
	ListOfficeMlsId = '".ListOfficeMlsId3."' OR
	ListOfficeMlsId = '".ListOfficeMlsId4."' OR
	ListOfficeMlsId = '".ListOfficeMlsId5."' OR
	ListOfficeMlsId = '".ListOfficeMlsId6."' OR
	ListOfficeMlsId = '".ListOfficeMlsId7."' OR
	ListOfficeMlsId = '".ListOfficeMlsId8."' OR
	ListOfficeMlsId = '".ListOfficeMlsId9."' OR
	ListOfficeMlsId = '".ListOfficeMlsId10."' OR
	ListOfficeMlsId = '".ListOfficeMlsId11."'
	) ORDER BY alphastatus asc, OriginalEntryTimestamp desc");
	
	define("STATIC_POST_LISTING_QUERY", "Select * from bonstlistingsnew2 where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending' OR StandardStatus = 'Closed') AND (
	ListOfficeMlsId = '".ListOfficeMlsId1."' OR
	ListOfficeMlsId = '".ListOfficeMlsId2."' OR
	ListOfficeMlsId = '".ListOfficeMlsId3."' OR
	ListOfficeMlsId = '".ListOfficeMlsId4."' OR
	ListOfficeMlsId = '".ListOfficeMlsId5."' OR
	ListOfficeMlsId = '".ListOfficeMlsId6."' OR
	ListOfficeMlsId = '".ListOfficeMlsId7."' OR
	ListOfficeMlsId = '".ListOfficeMlsId8."' OR
	ListOfficeMlsId = '".ListOfficeMlsId9."' OR
	ListOfficeMlsId = '".ListOfficeMlsId10."' OR
	ListOfficeMlsId = '".ListOfficeMlsId11."'
	) AND ORDER BY alphastatus asc, OriginalEntryTimestamp desc");
	
	//define("STATIC_LISTING_COUNT_QUERY", "Select count(*) as total from bonstlistingsnew2 where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending' OR StandardStatus = 'Closed') AND (
	// ListOfficeMlsId = '".ListOfficeMlsId1."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId2."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId3."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId4."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId5."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId6."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId7."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId8."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId9."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId10."' OR
	// ListOfficeMlsId = '".ListOfficeMlsId11."'
	// ) AND ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_LISTING_QUERY", "Select * from bonstlistingsnew2 where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending' OR StandardStatus = 'Closed') AND (ListOfficeMlsId = '".ListOfficeMlsId."') ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_LISTING_COUNT_QUERY", "Select count(*) as total from bonstlistingsnew2 where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending' OR StandardStatus = 'Closed') AND (ListOfficeMlsId = '".ListOfficeMlsId."') ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

// define("STATIC_LISTING_QUERY_SORT1", "Select ActiveListings.* from (    
//  Select StandardStatus,AlphaStatus,ListPrice,ClosePrice from bonstlistingsnew2 s1 where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending') AND (ListOfficeMlsId = '".ListOfficeMlsId."') ORDER BY s1.AlphaStatus desc, s1.ListPrice DESC
// ) ActiveListings  UNION ALL Select ClosedListings.* from (Select StandardStatus,AlphaStatus,ListPrice,ClosePrice from bonstlistingsnew2 s2 where (StandardStatus = 'Closed') AND (ListOfficeMlsId = '".ListOfficeMlsId."') ORDER BY s2.ClosePrice desc) ClosedListings");
// define("STATIC_LISTING_QUERY_SORT1", "Select *,'alphastatus1' orderAlphaStatus from bonstlistingsnew2 where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending') AND (ListOfficeMlsId = '".ListOfficeMlsId."') UNION ALL Select *, 'alphastatus2' orderAlphaStatus from bonstlistingsnew2  where (StandardStatus = 'Closed') AND (ListOfficeMlsId = '".ListOfficeMlsId."') ORDER by orderAlphaStatus desc, ClosePrice desc");
define("STATIC_LISTING_QUERY_SORT1", "Select * from bonstlistingsnew2 where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending' OR StandardStatus = 'Closed') AND (ListOfficeMlsId = '".ListOfficeMlsId."') ORDER BY alphastatus asc, ListPrice desc");

define("STATIC_LISTING_COUNT_SORT1", "Select count(*) as total from bonstlistingsnew2 where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending' OR StandardStatus = 'Closed') AND (ListOfficeMlsId = '".ListOfficeMlsId."') ORDER BY alphastatus asc");

define("STATIC_RADIUS_QUERY1", "Select * from bonstlistingsnew2 WHERE (
   acos(sin(bonstlistingsnew2.Latitude *0.0175)* sin(44.93376656880308 *0.0175)
   + cos(bonstlistingsnew2.Latitude *0.0175)* cos(44.93376656880308 *0.0175)*
   cos((-93.32552237274355 *0.0175)-(bonstlistingsnew2.Longitude *0.0175)
   )
   )*3959<= 20
   ) AND (StandardStatus = 'Active' OR StandardStatus = 'Coming Soon') AND (PropertyType = 'Residential Income') ORDER BY alphastatus asc, OriginalEntryTimestamp desc");
   
define("STATIC_RADIUS_COUNT_QUERY1", "Select count(*) as total from bonstlistingsnew2 WHERE (
acos(sin(bonstlistingsnew2.Latitude *0.0175)* sin(44.93376656880308 *0.0175)
+ cos(bonstlistingsnew2.Latitude *0.0175)* cos(44.93376656880308 *0.0175)*
cos((-93.32552237274355 *0.0175)-(bonstlistingsnew2.Longitude *0.0175)
)
)*3959<= 20
) AND (StandardStatus = 'Active' OR StandardStatus = 'Coming Soon') AND (PropertyType = 'Residential Income') ORDER BY alphastatus asc, OriginalEntryTimestamp desc");
	  
define("STATIC_POLYGON_QUERY", "SELECT 
	ListingId, Latitude, Longitude, PropertyLocation,	
	ASTEXT(POINT(`Longitude`, `Latitude`))	
FROM bonstlistingsnew2
WHERE ST_CONTAINS(
		ST_GEOMFROMTEXT('POLYGON((
			44.84938732133096, -93.50450427162313
			44.83812882512378, -93.50072772135493
			44.83526820802489, -93.50012690653955
			44.83271179174094, -93.51089865787273
			44.83405088108051, -93.51158530337604
			44.83952864982508, -93.51377398591784
			44.84141531626617, -93.52094084835863
			44.84719665124472, -93.52111250973446
				))'), 
		(POINT(`Longitude`, `Latitude`))
		) AND (StandardStatus = 'Active' OR StandardStatus = 'Coming Soon') AND (PropertyType = 'Residential') ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

// OLD CODES
/*	
define("STATIC_LISTING_QUERY", "Select * from bonstlistingsnew2plus where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending') AND (ListAgentMlsId = '".AgentOne."' OR CoListAgentMlsId = '".AgentOne."' OR BuyerAgentMlsId ='".AgentOne."' OR CoBuyerAgentMlsId = '".AgentOne."' OR ListAgentMlsId = '".AgentTwo."' OR CoListAgentMlsId = '".AgentTwo."' OR BuyerAgentMlsId ='".AgentTwo."' OR CoBuyerAgentMlsId = '".AgentTwo."' OR ListAgentMlsId = '".AgentThree."' OR CoListAgentMlsId = '".AgentThree."' OR BuyerAgentMlsId ='".AgentThree."' OR CoBuyerAgentMlsId = '".AgentThree."') ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_LISTING_COUNT_QUERY", "Select count(*) as total from bonstlistingsnew2plus where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active' OR StandardStatus = 'Pending') AND (ListAgentMlsId = '".AgentOne."' OR CoListAgentMlsId = '".AgentOne."' OR BuyerAgentMlsId ='".AgentOne."' OR CoBuyerAgentMlsId = '".AgentOne."' OR ListAgentMlsId = '".AgentTwo."' OR CoListAgentMlsId = '".AgentTwo."' OR BuyerAgentMlsId ='".AgentTwo."' OR CoBuyerAgentMlsId = '".AgentTwo."' OR ListAgentMlsId = '".AgentThree."' OR CoListAgentMlsId = '".AgentThree."' OR BuyerAgentMlsId ='".AgentThree."' OR CoBuyerAgentMlsId = '".AgentThree."') ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_LISTING_QUERY2", "Select * from bonstlistingsnew2plus where (StandardStatus = 'Closed') AND (ListAgentMlsId = '".AgentOne."' OR CoListAgentMlsId = '".AgentOne."' OR BuyerAgentMlsId ='".AgentOne."' OR CoBuyerAgentMlsId = '".AgentOne."' OR ListAgentMlsId = '".AgentTwo."' OR CoListAgentMlsId = '".AgentTwo."' OR BuyerAgentMlsId ='".AgentTwo."' OR CoBuyerAgentMlsId = '".AgentTwo."' OR ListAgentMlsId = '".AgentThree."' OR CoListAgentMlsId = '".AgentThree."' OR BuyerAgentMlsId ='".AgentThree."' OR CoBuyerAgentMlsId = '".AgentThree."') ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_LISTING_COUNT_QUERY2", "Select count(*) as total from bonstlistingsnew2plus where (StandardStatus = 'Closed') AND (ListAgentMlsId = '".AgentOne."' OR CoListAgentMlsId = '".AgentOne."' OR BuyerAgentMlsId ='".AgentOne."' OR CoBuyerAgentMlsId = '".AgentOne."' OR ListAgentMlsId = '".AgentTwo."' OR CoListAgentMlsId = '".AgentTwo."' OR BuyerAgentMlsId ='".AgentTwo."' OR CoBuyerAgentMlsId = '".AgentTwo."' OR ListAgentMlsId = '".AgentThree."' OR CoListAgentMlsId = '".AgentThree."' OR BuyerAgentMlsId ='".AgentThree."' OR CoBuyerAgentMlsId = '".AgentThree."') ORDER BY alphastatus asc, OriginalEntryTimestamp desc");
*/

// For Communities
define("STATIC_COMMUNITY_LISTING_QUERY1", "Select * from bonstlistingsnew2plus where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active') AND City='White Bear Lake' ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_COMMUNITY_LISTING_COUNT_QUERY1", "Select count(*) as total from bonstlistingsnew2plus where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active') AND City='White Bear Lake' ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_COMMUNITY_LISTING_QUERY2", "Select * from bonstlistingsnew2plus where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active') AND City='North Oaks' ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_COMMUNITY_LISTING_COUNT_QUERY2", "Select count(*) as total from bonstlistingsnew2plus where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active') AND City='North Oaks' ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_COMMUNITY_LISTING_QUERY3", "Select * from bonstlistingsnew2plus where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active') AND City='Shoreview' ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

define("STATIC_COMMUNITY_LISTING_COUNT_QUERY3", "Select count(*) as total from bonstlistingsnew2plus where (StandardStatus = 'Coming Soon' OR StandardStatus = 'Active') AND City='Shoreview' ORDER BY alphastatus asc, OriginalEntryTimestamp desc");

// For S
$site = array(
    'name' => '',
    'title' => 'Mobile Search Tool',
    'office' => '<h2 class="title">MSLLC.XYZ</h2><h4 class="tagline">A Greater Way to Find Homes</h4>', 
    'agentid' => '502003013',
    'officeid' => '1860',
    'refresh' => 15000, // auto refreash duration milliseconds
    'lat' => "44.986656", // default
    'lon' => "-93.258133",
    'radius' => 5,
    'call' => '612-925-5900',
    'text' => '612-925-5900',
    'email' => 'mark@markbehlen',
);

$domainname = "msllcbase.com";

?>