Disable date in Datepicker from SQL Server table

2

I have a system in Classic ASP, where I have a scheduling schedule. I need to disable the dates included in the holidays and compensations table (meeting_id and date). I do not know how to do this select to populate an array of unavailable dates.

To do something like the line of the unavailableDates variable.

var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
var unavailableDates = ["2012/03/26","2012/03/27","2012/04/05"]; // yyyy/MM/dd**
var unavailableDays = ["Saturday","Sunday"];

function unavailable(date) {
ymd = date.getFullYear() + "/" + ("0"+(date.getMonth()+1)).slice(-2) + "/" + ("0"+date.getDate()).slice(-2);
day = new Date(ymd).getDay();
if ($.inArray(ymd, unavailableDates) < 0 && $.inArray(days[day], unavailableDays) < 0) {
    return [true, "enabled", "Book Now"];
} else {
    return [false,"disabled","Booked Out"];
}
}

$('#iDate').datepicker({ beforeShowDay: unavailable });
    
asked by anonymous 06.08.2015 / 16:28

1 answer

1

mmooser, follow a slightly cleaner example:

var diasSemana = [ "Domingo", "Segunda", "Terca", "Quarta", "Quinta", "Sexta", "Sabado" ];
var diasFinalSemana = [ "Domingo", "Sabado" ];

var datasIndisponiveis = [
    new Date(2015, 07, 26),
    new Date(2015, 07, 27),
    new Date(2015, 08, 05)
].map(function (data) {
    return data.getTime();
});

$('[date-datepicker]').datepicker({
    beforeShowDay: function(data){        
        var diaSemana = diasSemana[data.getDay()];
        var isDataIndisponivel = datasIndisponiveis.indexOf(data.getTime()) != -1;
        var isDataFinalSemana = diasFinalSemana.indexOf(diaSemana) != -1;
        return [!isDataIndisponivel && !isDataFinalSemana];
    }
});
.ui-widget {
    font-size: 70% !important;
}
<link href="https://code.jquery.com/ui/1.11.4/themes/flick/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><scriptsrc="https://code.jquery.com/ui/1.11.3/jquery-ui.js"></script>
<input type="text" date-datepicker="" />
    
06.08.2015 / 18:02