0

MySQL に保存するカレンダーを作成しました。

時間枠イベントの allDay 値を false に設定していますが、カレンダーには終日として表示されます。

これはイベントを取得します..

$sql = mysql_query('SELECT * FROM `companies`.`calendar`');
${'Events'} = array();
while(${'Event'} = mysql_fetch_assoc($sql)){
    ${'Events'}[] = ${'Event'};
}

私のテーブルのスナップショット:

ここに私のjQueryがあります

$(document).ready(function() {

     $('#eventToAdd').dialog({ 
        autoOpen: false,
        height: '300',
        width: '550',
        modal: true,
        resizable: false,
        position: 'center',
    });

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    var calendar = $('#calendar').fullCalendar({
        theme: true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        loading: function(bool) {
            if (bool) $('#loading').show();
            else $('#loading').hide();
        },
        eventClick: function(calEvent, jsEvent, view) {
            $('#eventTitle').val(calEvent.title);
            $('#textColor').val(calEvent.textColor);
            $('#backgroundColor').val(calEvent.color);
            $("#eventToAdd").dialog({
                autoOpen: true,
                title: "Update Event",
                modal: true,
                buttons: [
                {
                    text:"Update Event",
                    click: function () {
                        if($('#eventTitle').val()){
                              calEvent.title = $('#eventTitle').val();
                              calEvent.color = $('#backgroundColor').val();
                              calEvent.textColor = $('#textColor').val();
                              calendar.fullCalendar('updateEvent',calEvent); 
                              $.post('post.api.php', { 'api': 'updateEvent', 'id': calEvent.id, 'title': calEvent.title, 'start': $.fullCalendar.formatDate(calEvent.start, 'yyyy-MM-dd h:mm:ss tt'), 'end': $.fullCalendar.formatDate(calEvent.end, 'yyyy-MM-dd h:mm:ss tt'), 'allDay': calEvent.allDay, 'bgColor': calEvent.color, 'textColor': calEvent.textColor }, function(resp) {
                                  if(resp == 'SUCCESS') {
                                      jAlert('The event has been updated','Updated');
                                  } else {
                                      jAlert('There was an error updating the event<br />Please try again later.<br />ERROR CODE: 728375', 'Process Error');
                                  }
                                  $('#eventToAdd').dialog('close');
                              });
                        }
                    }
                },
                {
                    text: "Cancel",
                    click: function() { $(this).dialog('close'); }
                }]
            });
        },
        selectable: true,
        selectHelper: true,
        select: function (start, end, allDay, jsEvent, view) {
            $("#eventToAdd").dialog(
            {
                autoOpen: true,
                title: "Create Event",
                modal: true,
                buttons: [
                {
                    text:"Create Event",
                    click: function () {
                        if($('#eventTitle').val()){
                            calendar.fullCalendar('renderEvent',
                            {
                                title: $('#eventTitle').val(),
                                start: $.fullCalendar.formatDate(start, 'yyyy-MM-dd h:mm:ss tt'),
                                end: $.fullCalendar.formatDate(end, 'yyyy-MM-dd h:mm:ss tt'),
                                allDay: allDay,
                                textColor: $('#textColor').val(),
                                color: $('#backgroundColor').val()
                            },
                            true
                        ); 
                        var startDate = $.fullCalendar.formatDate(start, 'yyyy-MM-dd h:mm:ss tt');
                        var endDate = $.fullCalendar.formatDate(end, 'yyyy-MM-dd h:mm:ss tt');
                        $.post('post.api.php', { 'api': 'createEvent', 'title': $('#eventTitle').val(), 'start': startDate, 'end': endDate, 'allDay': allDay, 'textColor': $('#textColor').val(), 'bgColor': $('#backgroundColor').val() }, function(response) {
                            if(response == 'SUCCESS'){
                                jAlert('The event has been saved!','Event Created');
                            } else {
                                jAlert('There was an error saving your event<br />Please try again later or let JD know<br />ERROR CODE: 882293','Process Error');
                            }
                        });
                        }
                        $(this).dialog('close');
                    }
                },
                {
                    text: "Cancel",
                    click: function() { $(this).dialog('close'); }
                }
                ],
                close: function(){
                    $('#eventTitle').val('');
                    $('#textColor').val('');
                    $('#backgroundColor').val('');     
                }
            });
        },
        editable: true,
        events: <?= ${'Events'}; ?>

    });


});
4

1 に答える 1

0

レコード値は false (引用符なし) として返されます。「偽」ではありません。私は同じ問題を抱えていて、この簡単な解決策を適用しました:

// -----------------------
while ($row = mysql_fetch_assoc($sql)) {
// -----------------------
if ($row['event_allday'] = 'false') {
$allDayStatus = false;
}
// -----------------------
$eventsArray['id'] =  $row['event_id'];
$eventsArray['title'] = $row['event_title'];
$eventsArray['start'] = $row['event_start'];
$eventsArray['end'] = $row['event_end'];
$eventsArray['url'] = $row['event_url'];
$eventsArray['allDay'] = $allDayStatus;
$eventsArray['className'] = $row['event_class'];
$eventsArray['admNotes'] = $row['event_adm_notes'];
// -----------------------
于 2013-11-27T13:12:48.587 に答える