I have this datepicker, in which I show the blocked dates according to the condition that they are accepted or not, I try to filter now by a new parameter, area_id. If the area_id of the data is equal to the user's, the dates must be shown in orange and if accepted, it is equal to 1, blocked and painted in red.
This is the code I have:
var daysData = <?= json_encode($data) ?>;
var isArea = {{ Auth::user()->area_id }}
var newA = [];
for( j of daysData){
let start = moment(j["start"]);
let end = moment(j["end"]);
for (let m = moment(start); m.diff(end, 'days') <= 0; m.add(1, 'days')) {
newA[m.format('DD/MM/YYYY')] = j;
}
}
$('input[name="datefilter"]').daterangepicker({
isInvalidDate: function(date) {
var valid = false ; // default css class
let d = date.format("DD/MM/YYYY");
if(typeof newA[d] !== 'undefined'){
if(newA[d].acept == 1 && newA[d].area_id == isArea){
valid = true;
}
}
return valid;
},
isCustomDate: function(date) {
var daySettings = 'day_green';
let d = date.format("DD/MM/YYYY");
if(typeof newA[d] !== 'undefined'){
daySettings = 'day_red';
if(newA[d].acept == 0 && newA[d].area_id ==isArea){
daySettings = 'day_orange';
}
}
}
return daySettings;
},
Pro keeps on painting the dates that do not correspond to the user's area_id, which makes me a bit frustrated. I would appreciate a little hand.
Greetings and thanks