[ad_1]
I am using the following jquery plugin. I want to block certain dates for task labeling.
Let say my task is from 1 june to 15 june so I want to show task label on just these (1 2 4 7 15) dates not on all dates till end. Please take a look on attached pic.
Plugin link: https://www.jqueryscript.net/time-clock/Full-Size-Drag-Drop-Calendar-Plugin-FullCalendar.html
Here is the calender js.
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
let new_date = new Date();
var calendar = new FullCalendar.Calendar(calendarEl, {
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
initialDate: new_date,
navLinks: true, // can click day/week names to navigate views
selectable: true,
selectMirror: true,
showNonCurrentDates: true,
select: function(arg) {
jQuery('.task-form').show();
// jQuery('.fc-daygrid-day-frame.fc-scrollgrid-sync-inner').on('click', function(){
// var startDate = jQuery(this).parent().attr('data-date');
var Pdate = Date.parse(arg.start);
const formatDate = (date) => {
let d = new Date(Pdate);
let month = (d.getMonth() + 1).toString();
let day = d.getDate().toString();
let year = d.getFullYear();
if (month.length < 2) {
month="0" + month;
}
if (day.length < 2) {
day = '0' + day;
}
return [year, month, day].join('-');
}
var date_ahead = new Date(Pdate);
date_ahead.setDate(date_ahead.getDate() + 15);
const formatDate_end = (date) => {
let d = new Date(date_ahead);
let month = (d.getMonth() + 1).toString();
let day = d.getDate().toString();
let year = d.getFullYear();
if (month.length < 2) {
month="0" + month;
}
if (day.length < 2) {
day = '0' + day;
}
return [year, month, day].join('-');
}
jQuery('input[name="start_date"]').val(formatDate);
jQuery('input[name="end_date"]').val(formatDate_end);
var title = jQuery('input[name="task_title"]').val();
if (title) {
calendar.addEvent({
title: title,
start: arg.start,
end: arg.end,
noEventsText:'ubaid',
allDay: arg.allDay
})
}
calendar.unselect()
},
// eventClick: function (arg) {
// if (confirm('Are you sure you want to delete this event?')) {
// arg.event.remove()
// }
// },
editable: false,
dayMaxEvents: true, // allow "more" link when too many events
events: [
<?php for ($i = 0; $i < $count_rows; $i++) { ?> {
title: '<?php
if ($select_task[$i]->status == 1) {
echo $select_task[$i]->task_subject . ' ' . 'completed';
} else {
echo $select_task[$i]->task_subject;
}
?>',
start: '<?php echo $select_task[$i]->task_start_date; ?>',
end: '<?php echo $select_task[$i]->task_end_date ?>',
unselectAuto: false,
},
<?php } ?>
]
});
calendar.render();
});
[ad_2]