Notice: ABPro's Stripe payment processor uses the Legacy Checkout and is not SCA compatible. read more..

How-To

Complex Resource Availability

Normally in ABPro a resource is available every week, with days off, vacation, etc., handled with Book-Offs.

If you have a complex resource availability requirement you can disable based on week of the year.

This How-to is for use in cases where book-offs will not work, like:

  • Available even weeks
  • Available odd weeks
  • Available 1st week of the month
  • Available only specific dates
  • etc.

Note 1: This mod works on GAD and Wizard screen grids only.

Note 2: If you are looking for specific date availability, rather than pattern availability (eg every other Saturday), see 

https://appointmentbookingpro.com/how-to/277-abpro-4-0-2-feature-date-specific-availability.html

 

 

Edit file: \components\com_rsappt_pro3\functions2.php

Around line 362 look for:

if($res_detail->disable_dates_after == "XDays"){
    if(strtotime($grid_date) >= strtotime("+ ".strval($res_detail->disable_dates_after_days)." day")){
        return "disabled";
    }
}

return "yes";

 


Specific weeks (odd, even, 1st)

If you only have one resource and/or all resources require the same schedule, insert the red code:

if($res_detail->disable_dates_after == "XDays"){
    if(strtotime($grid_date) >= strtotime("+ ".strval($res_detail->disable_dates_after_days)." day")){
        return "disabled";
    } 
}

    // Remove weeks from the following array to make the resource unavailable

    $available_weeks = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
    31,32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,48,49,50,51,52);

    $temp_date = strtotime($grid_date);
    $week_of_the_year = date("W",$temp_date);
    if(!in_array($week_of_the_year, $available_weeks)){
        return "disabled";
    }

return "yes";

 

 


Specific Dates 

If you only have one resource and/or all resources require the same schedule, insert the red code:

if($res_detail->disable_dates_after == "XDays"){
    if(strtotime($grid_date) >= strtotime("+ ".strval($res_detail->disable_dates_after_days)." day")){
        return "disabled";
    } 
}

    // array of available dates yyyy-mm-dd
    $available_dates = array("2016-11-01","2016-12-05","2017-01-09");

    if(!in_array($grid_date, $available_dates)){
        return "disabled";
    }

return "yes"; 

 

 


If the availability applies to a specific resource use the IF below with the appropriate resource id.

 

if($res_detail->disable_dates_after == "XDays"){
    if(strtotime($grid_date) >= strtotime("+ ".strval($res_detail->disable_dates_after_days)." day")){
        return "disabled";
    } 
}

    if($res_detail->id_resources == 2){

        // Remove weeks from the following array to make the resource unavailable
        $available_weeks = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
        31,32,33,
34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52);

        $temp_date = strtotime($grid_date);
        $week_of_the_year = date("W",$temp_date);
        if(!in_array($week_of_the_year, $available_weeks)){
            return "disabled";
        }
    } // closing of If the availability applies to a specific resource

 

return "yes";

 

Or, for available only on specific dates wrap with IF..

if($res_detail->disable_dates_after == "XDays"){
    if(strtotime($grid_date) >= strtotime("+ ".strval($res_detail->disable_dates_after_days)." day")){
        return "disabled";
    } 
}

    if($res_detail->id_resources == 60){
        // only resource 60
        // array of available dates yyyy-mm-dd,yyyy-mm-dd,etc
        $available_dates = array("2016-11-01","2016-12-05","2017-01-09");
 
        if(!in_array($grid_date, $available_dates)){
            return "disabled";
        }
    } // closing of If the availability applies to a specific resource

return "yes";

 

 

For cases where each resource requires a different set of weeks, you can insert multiple IF blocks, one for each resource.