禁用全日历中的某些自定义日期范围?

时间:2018-09-28 15:50:39

标签: javascript fullcalendar

我想阻止日历中的技术人员假期,日期是在SQL Server中安排的。

到目前为止,我已经成功地屏蔽了当天的前几天。 我想做同样的事情,但是要放假。

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>

1 个答案:

答案 0 :(得分:0)

我只是添加了代码并设置了背景颜色,但是我想在那些日子禁用点击功能...我该怎么做?

已添加代码:

[1] "987" "ABC"