javascript - 禁用完整日历中的某些自定义日期范围?
问题描述
我想在日历中阻止技术人员的假期,日期在 SQL 服务器中安排。
到目前为止,我已经设法阻止了当天之前的日子。我也想做同样的事情,但要考虑假期的日期。
dayRender: function (date, cell) {
if (moment().diff(date, 'days') > 0) {
cell.css("background-color", "#F5F5F5");
$(cell).addClass('disabled');
}
},
我感谢所有的帮助,在此先感谢。
编辑:
这就是我想做的: https ://codepen.io/anon/pen/xyxeJm
编辑 2
我的活动代码:
<script>
var url = window.location.href;
var recortar = url.indexOf("agenda=");
var tec = url.substr(recortar + 7);
var table = $('#example').DataTable({
"iDisplayLength": 5,
"bLengthChange": false,
pagingType: "simple",
"order": [[ 1, 'asc' ]],
});
$('#example tbody').on('click', 'tr', function () {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
} else {
table.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
});
<?php
if(isset($_GET['agenda'])){
$tec = selecttec($_GET['agenda']);
// curativas
$sql = "SELECT * FROM npedido WHERE tec1= '$tec' OR tec2= '$tec' OR responsable = '$tec' ";
$stmt2 = sqlsrv_query( $conn, $sql);
// agendamentos
$sql_agenda = "SELECT * FROM nagenda WHERE tec1= '$tec' OR tec2= '$tec'";
$stmt_agenda = sqlsrv_query( $conn, $sql_agenda);
?>
var name = "<?php echo utf8_encode($tec); ?>";
table.search(name).draw();
$("#tec_name").val(name);
$( "#example tr").each(function() {
if(this.id == tec){
$(this).addClass('selected');
}
});
var tec = "<?php echo $tec; ?>";
var events = function () {
return [
// curativas agenda
<?php while($row = sqlsrv_fetch_array($stmt2, SQLSRV_FETCH_NUMERIC)) {
if(strlen(str_replace(' ', '', $row[7])) < 15){ $start=date('h:i Y-m-d',strtotime(str_replace("18", "2018", substr($row[7], -16, 8)))) ;}else{ $start= date('Y-m-d H:i',strtotime($row[7])) ; }
if(strlen(str_replace(' ', '', $row[7])) < 15){ $end = date('h:i Y-m-d',strtotime(str_replace("18", "2018", substr($row[7], -16, 8)))) ;}else{ $end = date('Y-m-d H:i ',strtotime($row[7])) ; }
$start = substr($start,0,10)."T". substr($start,10);
$start = str_replace(" ","",$start);
$end = substr($end,0,10)."T". substr($end,10);
$end = str_replace(" ","",$end);
?> {
id: '<?php echo $row[0] ?>',
title: '<?php echo "Curativa - ".utf8_encode($row[8]).""; ?>',
start: '<?php echo $start; ?>',
end: '<?php echo $end; ?>',
color: '#0FB1DA',
},
<?php }?>
// agendamento
<?php while($row = sqlsrv_fetch_array($stmt_agenda, SQLSRV_FETCH_NUMERIC)) {?>
{
id: '<?php echo $row[0]; ?>',
title: '<?php echo "Agendamento - ".utf8_encode($row[4]).""; ?>',
start: '<?php echo $row[6]; ?>',
end: '<?php echo $row[7]; ?>',
dow: [1,4],
color: '<?php echo $row[10];?>',
},
<?php }?>
];
}
table.search("").draw();
<?php }else{?>
$('#example tbody tr:eq(0)').click();
<?php }sqlsrv_close($conn);?>
</script>
解决方案
我刚刚添加了代码并设置了背景颜色,但我想在那些日子禁用点击功能......我是怎么做到的?
添加的代码:
// ferias
<?php while($row = sqlsrv_fetch_array($stmt_ferias, SQLSRV_FETCH_NUMERIC)) {?>
{
id: '<?php echo $row[0]; ?>',
title: '<?php echo "Férias - ".utf8_encode($row[2]).""; ?>',
start: '<?php echo $row[3]; ?>',
end: '<?php echo $row[4]; ?>',
dow: [1,4],
rendering: 'background',
color: '#ff9f89'
},
<?php }?>
推荐阅读
- php - 从php中的数组中删除每个第3个和第4个元素
- xml - How to check empty node using FreeMarker
- angular - 图像未在角度上加载到引导卡上
- python - 无法将 Python venv 克隆到另一台 PC
- java - 我正在尝试创建一个单独的 HTTPServer,旁边是一个用于管理和度量公开的运行。这是个好主意吗?
- php - 收到错误“参数 1 传递给 Modules\\Admin\\Events\\”
- mqtt - Azure IoT Hub MQTT 失败(无 SDK)
- c++ - 如何在 Visual C++ 项目中定义和加载资源?
- c++ - 不同类型之间的模板类分配
- php - 如何在 laravel 中显示具有 is_admin 属性的管理员列表?