Limit Prev and Next Button

Hello

I am using the scheduler in a small booking system with users and admins. The users only can use the week view. I have to limit their movements between the weeks. They are only allowed to see the actual week and 2 weeks bevore and in the future.

I tried to use the limit feature like this example with fixed dates for this week.

    scheduler.config.first_hour = 8;
    scheduler.config.last_hour = 23;
    scheduler.config.time_step = 30;
    scheduler.config.server_utc = true;
    scheduler.config.xml_date="%Y-%m-%d %H:%i";

    scheduler.config.limit_start = new Date(2011,9,25, 0, 0);
    scheduler.config.limit_end   = new Date(2011,10,1, 0, 0);
    scheduler.config.limit_view  = true;
    
    scheduler.init('scheduler_here',null,"week");
    scheduler.setLoadMode("week");
    scheduler.load('functions/tennis.helper.php?action=getEvents');
    
    var dp = new dataProcessor('functions/tennis.helper.php?action=editEvent');
    dp.enableDataNames(true);
    dp.setTransactionMode("POST");
    dp.attachEvent("onAfterUpdate", function(sid, action, tid, tag){
        if(action == 'inserted')
            scheduler.changeEventId(sid, tid);
    });
    
    dp.init(scheduler);

with the necassary dhtmlxscheduler_limit.js included but it doesn’t seem to work.

Maybe it is possible to cancel the click event of the buttons after used two times in one way, or something.

Thanks for the help

You can use code like next to override default logic and add some kind of custom check

[code]schedulre.original_next = scheduler._click.dhx_cal_next_button;
scheduler._click.dhx_cal_next_button = function(){
if (some_custom_check())
scheduler.original_next();
});

schedulre.original_prev = scheduler._click.dhx_cal_prev_button;
scheduler._click.dhx_cal_prev_button = function(){
if (some_custom_check())
scheduler.original_prev();
});[/code]

Thanks for this fast answer.
It seems scheduler.original_prev() calls scheduler._click.dhx_cal_prev_button. If it is overwritten the new function is called but I solved the problem and it works fine. :slight_smile:

Thank you!!