# REVISIONDATA

ACTIONTIME: 2022-06-05 09:53:51
PARAMS: {"action":"t"}
SOURCE:
$_SESSION["back_url"]=GetTableLink("vacproperties", "list", "");
$stylename = "vacproperties";
$curUser = Security::currentUserData();
if( $curUser["group"] === "admin" ){
	$stylename.=" admin";
}
$xt->assign("stylename",$stylename);
if(postvalue("dateFrom") != false)
	$pageObject->setProxyValue("dateFrom",postvalue("dateFrom"));
if(postvalue("dateTo") != false)
	$pageObject->setProxyValue("dateTo",postvalue("dateTo"));
$pageObject->AddJSFile("vacation.js");

$find = array();
preg_match_all("/\(Area~equals~(.+)\)/U",postvalue("q"),$find,PREG_PATTERN_ORDER);

if(!isset($find[0][0]))
	$pageObject->setProxyValue("emptyArea",true);


ACTIONTIME: 2022-06-05 09:53:51
PARAMS: {"action":"t"}
SOURCE:
$xt->assign("pagetitle",$values["Name"]);

global $conn;
$strAvailability="<a target=_blank href='vacreservations_calendar_list.php?mastertable=vacproperties&masterkey1=" . @$_REQUEST["editid1"] . "'>Check Availability</a>";
$xt->assign("row00Availabilityvalue",$strAvailability);

global $dal;
$dal_table=$dal->Table("vacproperties");
$data = $dal_table->Query(AddFieldWrappers("PropertyID")."=".$_REQUEST["editid1"],"");
$rstt = db_fetch_array($data);

if(is_null($rstt["Kitchen"]))
	$xt->assign("ch_Kitchen",False);
else if($rstt["Kitchen"]==0)
	$xt->assign("ch_Kitchen",False);
else
	$xt->assign("ch_Kitchen",True);

if(is_null($rstt["AirConditioning"]))
	$xt->assign("ch_AirConditioning",False);
else if($rstt["AirConditioning"]==0)
	$xt->assign("ch_AirConditioning",False);
else
	$xt->assign("ch_AirConditioning",True);

if(is_null($rstt["Dishwasher"]))
	$xt->assign("ch_Dishwasher",False);
else if($rstt["Dishwasher"]==0)
	$xt->assign("ch_Dishwasher",False);
else
	$xt->assign("ch_Dishwasher",True);

if(is_null($rstt["Microwave"]))
	$xt->assign("ch_Microwave",False);
else if($rstt["Microwave"]==0)
	$xt->assign("ch_Microwave",False);
else
	$xt->assign("ch_Microwave",True);

if(is_null($rstt["WasherDryer"]))
	$xt->assign("ch_WasherDryer",False);
else if($rstt["WasherDryer"]==0)
	$xt->assign("ch_WasherDryer",False);
else
	$xt->assign("ch_WasherDryer",True);

if(is_null($rstt["ScreenedPorch"]))
	$xt->assign("ch_ScreenedPorch",False);
else if($rstt["ScreenedPorch"]==0)
	$xt->assign("ch_ScreenedPorch",False);
else
	$xt->assign("ch_ScreenedPorch",True);

if(is_null($rstt["BedLinensProvided"]))
	$xt->assign("ch_BedLinensProvided",False);
else if($rstt["BedLinensProvided"]==0)
	$xt->assign("ch_BedLinensProvided",False);
else
	$xt->assign("ch_BedLinensProvided",True);

if(is_null($rstt["Fireplace"]))
	$xt->assign("ch_Fireplace",False);
else if($rstt["Fireplace"]==0)
	$xt->assign("ch_Fireplace",False);
else
	$xt->assign("ch_Fireplace",True);

if(is_null($rstt["PoolTable"]))
	$xt->assign("ch_PoolTable",False);
else if($rstt["PoolTable"]==0)
	$xt->assign("ch_PoolTable",False);
else
	$xt->assign("ch_PoolTable",True);

if(is_null($rstt["HighSpeedInternet"]))
	$xt->assign("ch_HighSpeedInternet",False);
else if($rstt["HighSpeedInternet"]==0)
	$xt->assign("ch_HighSpeedInternet",False);
else
	$xt->assign("ch_HighSpeedInternet",True);

if(is_null($rstt["CableTV"]))
	$xt->assign("ch_CableTV",False);
else if($rstt["CableTV"]==0)
	$xt->assign("ch_CableTV",False);
else
	$xt->assign("ch_CableTV",True);

if(is_null($rstt["DVDVCR"]))
	$xt->assign("ch_DVDVCR",False);
else if($rstt["DVDVCR"]==0)
	$xt->assign("ch_DVDVCR",False);
else
	$xt->assign("ch_DVDVCR",True);

if(is_null($rstt["PrivatePool"]))
	$xt->assign("ch_PrivatePool",False);
else if($rstt["PrivatePool"]==0)
	$xt->assign("ch_PrivatePool",False);
else
	$xt->assign("ch_PrivatePool",True);

if(is_null($rstt["HeatedPool"]))
	$xt->assign("ch_HeatedPool",False);
else if($rstt["HeatedPool"]==0)
	$xt->assign("ch_HeatedPool",False);
else
	$xt->assign("ch_HeatedPool",True);

if(is_null($rstt["HotTub"]))
	$xt->assign("ch_HotTub",False);
else if($rstt["HotTub"]==0)
	$xt->assign("ch_HotTub",False);
else
	$xt->assign("ch_HotTub",True);

if(is_null($rstt["Grill"]))
	$xt->assign("ch_Grill",False);
else if($rstt["Grill"]==0)
	$xt->assign("ch_Grill",False);
else
	$xt->assign("ch_Grill",True);

if(is_null($rstt["EnclosedOutsideShower"]))
	$xt->assign("ch_EnclosedOutsideShower",False);
else if($rstt["EnclosedOutsideShower"]==0)
	$xt->assign("ch_EnclosedOutsideShower",False);
else
	$xt->assign("ch_EnclosedOutsideShower",True);

if(is_null($rstt["GameRoom"]))
	$xt->assign("ch_GameRoom",False);
else if($rstt["GameRoom"]==0)
	$xt->assign("ch_GameRoom",False);
else
	$xt->assign("ch_GameRoom",True);

if(is_null($rstt["Elevator"]))
	$xt->assign("ch_Elevator",False);
else if($rstt["Elevator"]==0)
	$xt->assign("ch_Elevator",False);
else
	$xt->assign("ch_Elevator",True);

if(is_null($rstt["PetsAllowed"]))
	$xt->assign("ch_PetsAllowed",False);
else if($rstt["PetsAllowed"]==0)
	$xt->assign("ch_PetsAllowed",False);
else
	$xt->assign("ch_PetsAllowed",True);

if(is_null($rstt["NonSmoking"]))
	$xt->assign("ch_NonSmoking",False);
else if($rstt["NonSmoking"]==0)
	$xt->assign("ch_NonSmoking",False);
else
	$xt->assign("ch_NonSmoking",True);

if(is_null($rstt["CommunityFacilities"]))
	$xt->assign("ch_CommunityFacilities",False);
else if($rstt["CommunityFacilities"]==0)
	$xt->assign("ch_CommunityFacilities",False);
else
	$xt->assign("ch_CommunityFacilities",True);

if(is_null($rstt["CommunityPool"]))
	$xt->assign("ch_CommunityPool",False);
else if($rstt["CommunityPool"]==0)
	$xt->assign("ch_CommunityPool",False);
else
	$xt->assign("ch_CommunityPool",True);

if(is_null($rstt["CommunityTennisCourts"]))
	$xt->assign("ch_CommunityTennisCourts",False);
else if($rstt["CommunityTennisCourts"]==0)
	$xt->assign("ch_CommunityTennisCourts",False);
else
	$xt->assign("ch_CommunityTennisCourts",True);

if(is_null($rstt["CommunityClubHouse"]))
	$xt->assign("ch_CommunityClubHouse",False);
else if($rstt["CommunityClubHouse"]==0)
	$xt->assign("ch_CommunityClubHouse",False);
else
	$xt->assign("ch_CommunityClubHouse",True);

if(is_null($rstt["Golf"]))
	$xt->assign("ch_Golf",False);
else if($rstt["Golf"]==0)
	$xt->assign("ch_Golf",False);
else
	$xt->assign("ch_Golf",True);

if(is_null($rstt["HandicapFriendly"]))
	$xt->assign("ch_HandicapFriendly",False);
else if($rstt["HandicapFriendly"]==0)
	$xt->assign("ch_HandicapFriendly",False);
else
	$xt->assign("ch_HandicapFriendly",True);


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$("td[id^=Photo]").each(function()
{
	if($(this).find("img")[0])
	{
		if($("#imgMainPhoto").attr("src").indexOf("no_image.gif") != -1)
			$("#imgMainPhoto").attr("src",$(this).find("img")[0].src);
		$(this).bind("mouseover", function(e){
			$("#imgMainPhoto").attr("src",$(this).find("img")[0].src);
		});
	}
});


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$("[id='srchOpt_" + pageid + "_Area']").val("Equals");
$("[id='srchOpt_" + pageid + "_reservationDate']").val("Between");
$("[id='srchOpt_" + pageid + "_reservationDate']").change();;
$("[data-field='reservationDate'] input.form-control").eq(0).attr("placeholder","date from");
$("[data-field='reservationDate'] input.form-control").eq(1).attr("placeholder","date to");


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$listingPhoto = my_json_decode($data["ListingPhoto"]);
						$photos = my_json_decode($data["Photos"]);
						$listingPhoto = array_merge($listingPhoto,$photos);
						$data["ListingPhoto"] = my_json_encode($listingPhoto);
						
						$dateToforQuery = str_replace("/","-",postvalue("dateTo"));
						$dateFromforQuery = str_replace("/","-",postvalue("dateFrom"));
						if(GetDatabaseType() == 3) {//access
							$dateToforQuery = "#".$dateToforQuery;
							$dateFromforQuery = "#".$dateFromforQuery;
						}
						if( postvalue("dateTo") !=false ){
							$reserveDateTo = DBLookup("select count(*) FROM vacreservations where '".$dateToforQuery."' BETWEEN FromDate and ToDate and PropertyID=".$data["PropertyID"]);
							if( intval($reserveDateTo) ) return false;
						}
						if( postvalue("dateFrom") !=false ){
							$reservedateFrom = DBLookup("select count(*) FROM vacreservations where '".$dateFromforQuery."' BETWEEN FromDate and ToDate and PropertyID=".$data["PropertyID"]);
							if( intval($reservedateFrom) ) return false;
						}
						if( postvalue("dateFrom") !=false && postvalue("dateTo") !=false ){
							$reserveDateTo = DBLookup("select count(*) FROM vacreservations where FromDate BETWEEN '".$dateFromforQuery."' and '".$dateToforQuery."' and PropertyID=".$data["PropertyID"]);
							$reservedateFrom = DBLookup("select count(*) FROM vacreservations where ToDate BETWEEN '".$dateFromforQuery."' and '".$dateToforQuery."' and PropertyID=".$data["PropertyID"]);
							if( intval($reserveDateTo) || intval($reservedateFrom)) return false;
						}
						$_SESSION["searchCount"]++;
						return true;


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$record["recordattrs"].=" data-vewlink=".$data["PropertyID"];
$imgarr = explode("field=ListingPhoto",$record["ListingPhoto_value"]);
$firstimg = array_shift($imgarr)."field=ListingPhoto";
$photos = implode("field=Photos",$imgarr);
$record["ListingPhoto_value"] = $firstimg.$photos;
$record["ListingPhoto_value"] = str_replace("</div>","<span class='arrowleft'></span><span class='arrowright'></span><span class='points'></span></div>",$record["ListingPhoto_value"]);


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$_SESSION["searchCount"] = 0;
/*print "<pre>";
var_dump($pageObject->searchClauseObj->_where);
print "</pre>";*/
$find = array();
preg_match_all("/\(Area~equals~(.+)\)/U",postvalue("q"),$find,PREG_PATTERN_ORDER);

if(!isset($find[0][0])){
	foreach($pageObject->searchClauseObj->_where["_srchFields"] as $k=>$v){
		if($v["fName"] === "Area") unset($pageObject->searchClauseObj->_where["_srchFields"][$k]);
	}
}


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
var AreaSField = pageObj.controlsMap.search.searchBlocks.find(ctrl => ctrl.fName === 'Area');
var reservationDateSField = pageObj.controlsMap.search.searchBlocks.find(ctrl => ctrl.fName === 'reservationDate');
setBSControls(Runner.controls.ControlStorage.byAll(reservationDateSField.recId, "reservationDate", 0),Runner.controls.ControlStorage.byAll(reservationDateSField.recId, "reservationDate", 1));
Runner.controls.ControlStorage.byAll(reservationDateSField.recId, "reservationDate", 0).clear();
if(typeof proxy["emptyArea"] !== "undefined") Runner.getControl(AreaSField.recId,"Area").setValue("");
pageObj.searchController.on('beforeSearch', function(searchController, searchForm) {
    delete searchController.ctrlsShowMap.reservationDate;
    var dateFrom = $("#value_reservationDate_" + reservationDateSField.recId).val();
    var dateTo = $("#value1_reservationDate_" + reservationDateSField.recId).val();
    dateFrom = dateFrom.replace(/(\d\d)\/(\d\d)\/(\d\d\d\d)/, "$3-$1-$2");
    dateTo = dateTo.replace(/(\d\d)\/(\d\d)\/(\d\d\d\d)/, "$3-$1-$2");
    if (dateFrom !== "") {
        searchForm.baseParams['dateFrom'] = dateFrom;
    }
    if (dateTo !== "") {
        searchForm.baseParams['dateTo'] = dateTo;
    }
});
mobileCheck = function() {
    let check = false;
    (function(a) {
        if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true;
    })(navigator.userAgent || navigator.vendor || window.opera);
    return check;
};
if (!mobileCheck()) {
    $('.r-data-block').mousewheel(function(e, delta) {
        $(this).scrollTop(this.scrollTop + (-delta * 40));
        e.preventDefault();
    });
}

$("[id='srchOpt_" + AreaSField.recId + "_Area']").val("Equals");
$("[id='srchOpt_" + reservationDateSField.recId + "_reservationDate']").val("Between");
$("[id='srchOpt_" + reservationDateSField.recId + "_reservationDate']").change();
$("#filter_" + reservationDateSField.recId + "_reservationDate .rnr-searchcontrol input.form-control").eq(0).attr("placeholder", "date from");
$("#filter_" + reservationDateSField.recId + "_reservationDate .rnr-searchcontrol input.form-control").eq(1).attr("placeholder", "date to");
$("[data-location='supertop']").removeClass("navbar");
$("[data-location='supertop']").removeClass("navbar-default");
$("[data-location='supertop']").addClass("visibleitem");

if (typeof proxy["dateFrom"] !== "undefined")
    $("#value_reservationDate_" + reservationDateSField.recId).val(proxy["dateFrom"]);
if (typeof proxy["dateTo"] !== "undefined")
    $("#value1_reservationDate_" + reservationDateSField.recId).val(proxy["dateTo"]);

$("[data-field='ListingPhoto']").mouseenter(function() {
    var points = $(this).find(".points");
    var rimages = $(this).find(".r-images");
    var slides = rimages.data("images");
    var j = 5;
    if (slides.length < 5) j = slides.length;
    if (points.find(".point").size() == 0) {
        for (var i = 0; i < j; i++) points.append($("<span class='point' count='" + i + "'></span>"));
        points.find(".point").first().addClass("active");
    }

    if (rimages.attr("scount") === undefined) rimages.attr("scount", 0);
});
$(".arrowleft").click(function(event) {
    event.stopPropagation();
    var rimages = $(this).parent();
    rimages.find(".arrowright").show();
    var slides = rimages.data("images");
    var curcount = parseInt(rimages.attr("scount"));
    curcount--;
    rimages.find("img").attr("src", slides.at(curcount).image);
    rimages.attr("scount", curcount);
    if (curcount == 0) $(this).hide();
    rimages.find(".point").removeClass("active");
    if (slides.length > 5 && curcount > 1 && (curcount + 1) < slides.length - 2) rimages.find(".point[count=2]").addClass("active");
    else if (slides.length > 5 && (curcount + 1) >= slides.length - 2) {
        var num = 5 - (slides.length - curcount + 1) + 1;
        rimages.find(".point[count=" + num + "]").addClass("active");
    }
    if (slides.length <= 5 || curcount == 0 || curcount == 1) rimages.find(".point[count=" + curcount + "]").addClass("active");
});
$(".arrowright").click(function(event) {
    event.stopPropagation();
    var rimages = $(this).parent();
    rimages.find(".arrowleft").show();
    var slides = rimages.data("images");
    var curcount = parseInt(rimages.attr("scount"));
    curcount++;
    rimages.find("img").attr("src", slides.at(curcount).image);
    rimages.attr("scount", curcount);
    if ((curcount + 1) === slides.length) $(this).hide();
    rimages.find(".point").removeClass("active");
    if (slides.length > 5 && curcount > 1 && (curcount + 1) < slides.length - 2) rimages.find(".point[count=2]").addClass("active");
    else if (slides.length > 5 && (curcount + 1) >= slides.length - 2) {
        var num = 5 - (slides.length - curcount + 1) + 1;
        rimages.find(".point[count=" + num + "]").addClass("active");
    }
    if (slides.length <= 5 || curcount == 0 || curcount == 1) rimages.find(".point[count=" + curcount + "]").addClass("active");
});

$("[data-location='grid']").on("click", ".panel", function(e) {
    var link = document.createElement("a");
    link.href = Runner.pages.getUrl("vacproperties", "view") + "?editid1=" + $(this).data("vewlink");
    if (typeof proxy["dateFrom"] !== "undefined") link.href += "&dateFrom=" + proxy["dateFrom"];
    if (typeof proxy["dateTo"] !== "undefined") link.href += "&dateTo=" + proxy["dateTo"];
    link.click();
});


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
// Parameters:
// $values - Array object. 
// Each field on the Add form represented as 'Field name'-'Field value' pair

global $conn;
global $dal;

if($values["FromDate"]>$values["ToDate"])
{
	$message="<div class=message style='color:red' align=center><<< Invalid reservation dates >>></div>";
	return false;
}

//**********  Custom code  ************
// put your custom code here
$dal_table=$dal->Table("vacreservations");
//$rstt = CustomQuery("select * from vacreservations where PropertyID=" . $values["PropertyID"]);
$rstt = $dal_table->Query(AddFieldWrappers("PropertyID")."=" . $values["PropertyID"],"");
while($rsh=db_fetch_array($rstt))
{
	if($values["FromDate"]>=$rsh["FromDate"] && $values["FromDate"]<$rsh["ToDate"] || $values["ToDate"]>=$rsh["FromDate"] && $values["ToDate"]<=$rsh["ToDate"] || $values["FromDate"]<=$rsh["FromDate"] && $values["ToDate"]>=$rsh["ToDate"])
	{
		$message="<div class=message style='color:red' align=center><<< Selected property is already booked for these dates >>></div>";
		return false;
	}
}

return true;

// return true if you like to proceed with adding new record
// return false in other case 


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
// Parameters:
// $values - Array object. 
// Each field on the Edit form represented as 'Field name'-'Field value' pair
// $where - string with WHERE clause pointing to record to be edited

//**********  Custom code  ************
// put your custom code here

//$rstt = db_query("select * from vacreservations where " . $strWhereClause, $conn);
//$rsh=db_fetch_array($rstt);

if($values["FromDate"]>$values["ToDate"])
{
	$message="<div class=message style='color:red' align=center><<< Invalid reservation dates >>></div>";
	return false;
}


global $dal;
$dal_table=$dal->Table("vacreservations");
$rstt = $dal_table->Query($where,"");
$rsh=db_fetch_array($rstt);
$rid=$rsh["ReservationID"];

$rstt = $dal_table->Query(AddFieldWrappers("ReservationID")."<>" . $rid . " and ".AddFieldWrappers("PropertyID")."=" . $values["PropertyID"],"");
//$rstt = CustomQuery("select * from vacreservations where ReservationID<>" . $rid . " and PropertyID=" . $values["PropertyID"]);
while($rsh=db_fetch_array($rstt))
{
	if($values["FromDate"]>=$rsh["FromDate"] && $values["FromDate"]<=$rsh["ToDate"] || $values["ToDate"]>=$rsh["FromDate"] && $values["ToDate"]<=$rsh["ToDate"] || $values["FromDate"]<=$rsh["FromDate"] && $values["ToDate"]>=$rsh["ToDate"] || $values["FromDate"]>$values["ToDate"])
	{
		$message="<div align=center style='color:red' class=message><<< Selected property is already booked for these dates >>></div>";
		return false;
	}
}

return true;

// return true if you like to proceed with editing this record
// return false in other case 


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$xt->assign("vc_backbutton_attrs","href=".$_SESSION["back_url"]);
if ($_SESSION["back_url"]!=GetTableLink("vacproperties", "list", ""))
$xt->assign("back_vacproperties_button",true);
else 
$xt->assign("back_vacproperties_button",false);

$disabledays = array();
if(postvalue("pid")!= false){
	$rs = DB::Query("select * from vacreservations where PropertyID=".postvalue("pid"));
	while($data = $rs->fetchAssoc()){
		$sdate = date("Y-m-d",strtotime($data["FromDate"]));
		$edate = date("Y-m-d",strtotime($data["ToDate"]));
		for($i=strtotime($sdate);$i<=strtotime($edate);$i+=60*60*24){
			$disabledays[] = runner_date_format("Y-m-d",$i);
		}
	}
}
$pageObject->setProxyValue("disdays",$disabledays);
if( !Security::isLoggedIn() ){
	$pageObject->hideItem("status_field");
}
$pageObject->AddJSFile("vacation.js");


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$_SESSION["back_url"]=GetTableLink("vacreservations", "list", "a=return");

// Place event code here.
// Use "Add Action" button to add code snippets.


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
if( postvalue("dateTo") != false)
	$values["ToDate"] = postvalue("dateTo");
if( postvalue("dateFrom") != false)
	$values["FromDate"] = postvalue("dateFrom");
if( postvalue("PropertyID") != false)
	$values["PropertyID"] = postvalue("PropertyID");
if( postvalue("dateFrom") != false && postvalue("dateTo") == false ){
	$values["ToDate"] = date('Y-m-d', strtotime($values["FromDate"] . ' +3 day'));
}
if( postvalue("pid") != false) {
	$values["PropertyID"] = postvalue("pid");
	$propertyName = DBLookup("select name from vacproperties where PropertyID=".postvalue("pid"));
	$pageObject->setProxyValue("propertyName",$propertyName);
	$pageObject->setProxyValue("propertyId",$values["PropertyID"]);
}


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$pageObject->setProxyValue('saved', true);  
$pageObject->stopPRG = true;
if( !Security::isLoggedIn() ){
	HeaderRedirect("vacproperties","list");
	exit();
}


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
Runner.controls.DateField.prototype.setDisabledDates = function( dates ) {
   var picker = this.bsDateTimePicker.data('DateTimePicker');
	adates = [];
	$.each(dates, function(i,v){
		adates[adates.length] = moment(v);
	});
   picker.disabledDates( adates );
}

Runner.controls.DateField.prototype.getPicker = function( dates ) {
   return this.bsDateTimePicker.data('DateTimePicker');
}
var FromDate = Runner.getControl(pageid,'FromDate');
FromDate.setDisabledDates( proxy["disdays"] );
var ToDate = Runner.getControl(pageid,'ToDate');
ToDate.setDisabledDates( proxy["disdays"] );
setBSControls(FromDate,ToDate);

if ((proxy['saved']) && window.parent && window.parent.popup) {
   window.parent.location.reload();
   window.parent.popup.close();
}
if( typeof proxy["propertyName"] !== "undefined" ){
	$("[data-fieldname='PropertyID'] .r-readonly-control").html("<a href='"+Runner.pages.getUrl("vacproperties","view")+"?editid1="+proxy["propertyId"]+"'>"+proxy["propertyName"]+"</a>");
}


$("[id^=backButton]").off("click").click(function() {
	history.back()
});


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$propertyName = DBLookup("select name from vacproperties where PropertyID=".$values["PropertyID"]);
$pageObject->setProxyValue("propertyName",$propertyName);
$pageObject->setProxyValue("propertyId",$values["PropertyID"]);


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
if( typeof proxy["propertyName"] !== "undefined" ){
	$("[data-fieldname='PropertyID'] .r-readonly-control").html("<a href='"+Runner.pages.getUrl("vacproperties","view")+"?editid1="+proxy["propertyId"]+"'>"+proxy["propertyName"]+"</a>");
}


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$propertyName = DBLookup("select name from vacproperties where PropertyID=".$values["PropertyID"]);
$pageObject->setProxyValue("propertyName",$propertyName);
$pageObject->setProxyValue("propertyId",$values["PropertyID"]);


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
if( typeof proxy["propertyName"] !== "undefined" ){
	$("#view1_PropertyID").html("<a href='"+Runner.pages.getUrl("vacproperties","view")+"?editid1="+proxy["propertyId"]+"'>"+proxy["propertyName"]+"</a>");
}


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
var events;
var today = new Date();
var formatdate = "ddd M/D";
$.post("vacreservations_calendar_list.php", {
        a: 'fullcalendar'
    })
    .done(function(txt) {
        onDone(txt);
    });

function onDone(txt) {
    events = JSON.parse(txt);
    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'year,month'
        },
        height: document.documentElement.clientHeight - 150,
        defaultDate: today,
        editable: false,
        themeSystem: 'bootstrap3',
        nextDayThreshold: "00:00:00",
        yearColumns: 3,
        events: events,
        columnFormat: {
            month: formatdate
        },
        eventRender: function(event, el, view) {


        },
        eventClick: function(calEvent, jsEvent, view) {

            if (proxy["group"] === "admin")
                location.href = "vacreservations_view.php?editid1=" + calEvent.pid + "&editid2=" + calEvent.id;
            else
                return false;


        },
    });
}
$("body").on("click", ".reserve_event.fc-future:not(.hasEvent)", function() {
    var FromDate = $(this).data("date");
    var params = "?dateFrom=" + FromDate;
    if (typeof proxy["pid"] !== "undefined")
        params += "&PropertyID=" + proxy["pid"];
    var popup = Runner.displayPopup({
        url: Runner.pages.getUrl("vacreservations", "add") + params,
        width: 700,
        height: 500,
        header: 'New reservation',
		  afterCreate: function(popup) {
				window.popup = popup;
		  }
    });
});


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
if(postvalue("a")=="fullcalendar"){
	
	$rs = DB::Query("select r.*, p.name from vacreservations as r left join vacproperties as p on p.PropertyID=r.PropertyID where r.PropertyID=".$_SESSION["pid"]);
	$cnt = 0;
	while($data = $rs->fetchAssoc()){
		$elem["pid"] = $data["PropertyID"];
		$elem["id"] = $data["ReservationID"];


		$elem["title"] = $data["name"];

		$elem["start"] = date("Y-m-d",strtotime($data["FromDate"]));
		$elem["end"] = date("Y-m-d",strtotime($data["ToDate"]));

		/*$elem["desc_month"] = "<b>".$data["Team1"]."</b><br>vs.<br><b>".$data["Team2"]."</b><br>";
		$elem["desc_month"].= "<b>" . $data["Score"] . "</b><br>";
		$elem["desc_month"].= $data["sTime"];
		$elem["desc_year"] = $data["Team1"]."</b><br>vs.<br><b>".$data["Team2"];*/
		$elem1 = $elem;
		$res[$cnt] = $elem1;
		$cnt++;
	}
	echo my_json_encode($res);
	die();
}
else
	$_SESSION["pid"] = postvalue("pid");


$pageObject->AddCSSFile("fullcalendar/fullcalendar.css");
$pageObject->AddJSFile("fullcalendar/moment.min.js");
$pageObject->AddJSFile("fullcalendar/fullcalendar.js","fullcalendar/moment.min.js");
$pageObject->AddJSFile("fullcalendar/lang-all.js","fullcalendar/fullcalendar.js");



// Place event code here.
// Use "Add Action" button to add code snippets.


ACTIONTIME: 2022-06-05 09:53:52
PARAMS: {"action":"t"}
SOURCE:
$_SESSION["booknow"] = "<a type='button' class='btn btn-default' href='vacreservations_add.php?mastertable=vacproperties&amp;masterkey1=".$_SESSION["pid"]."'>Book Now</a>";
$curUser = Security::currentUserData();
$pageObject->setProxyValue("group",$curUser["group"]);
if( postvalue("pid") != false )
	$pageObject->setProxyValue("pid",postvalue("pid"));
$pageObject->setProxyValue("group",$curUser["group"]);


