首页 > 解决方案 > 禁用完整日历中的某些自定义日期范围?

问题描述

我想在日历中阻止技术人员的假期,日期在 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>

标签: javascriptfullcalendar

解决方案


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

添加的代码:

// 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 }?> 


推荐阅读