我有一个基于由网站管理员打开的门票的日历。我们有四种类型的票:
这是我保存日历的div
:
<div class="col-lg-6 col-md-10 col-sm-11">
<div class="card">
<div class="card-header" data-background-color="blue">
<h4 class="title">Calendario</h4>
</div>
<br>
<section class="content">
<?php
$events = TicketData::getEvents();
foreach($events as $event){
$thejson[] = array("title"=>$event->title,"url"=>"./?view=editticket&id=".$event->id,"start"=>$event->date_at."T".$event->time_at);
}
// print_r(json_encode($thejson));
?>
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next, today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: jQuery.now(),
editable: false,
eventLimit: true, // allow "more" link when too many events
events: <?php echo json_encode($thejson); ?>
});
});
</script>
<div class="row">
<div class="col-md-12">
<div id="calendar">
</div>
</div>
</div>
</section>
</div>
</div>
票证的数据库结构很简单:id
、title
、description
、date_at
、time_at
、created_at
、tecnico_id
和status_id
。
我想使用if脚本对事件进行“着色”:
这是我的代码,但是它不能工作。
<section class="content">
<?php
$events = TicketData::getEvents();
// $status->status_id;
foreach($events as $event){
$thejson[] = array("title"=>$event->title,"url"=>"./?view=editticket&id=".$event->id,"start"=>$event->date_at."T".$event->time_at,);
$thejsonColor[] = array($event->status_id);
}
// print_r(json_encode($thejson));
?>
<script>
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next, today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: jQuery.now(),
editable: false,
eventLimit: true, // allow "more" link when too many events
events: <?php echo json_encode($thejson); ?>,
if ($thejsonColor=1){
eventColor: 'fb8c00'
}else if ($thejsonColor=2){
eventColor: 'ff0'
} else if ($thejsonColor=3){
eventColor: '43a047'
} else {
eventColor: '00acc1'
}
});
});
</script>
This is the calendar generated. These are the colors.
我想让它们与颜色标准相匹配,这样用户就可以知道哪些票证是未决的、未完成的、完整的和已取消的。我是javascript的新手,我不知道怎么做。你们能帮我或者告诉我该怎么做吗?
https://stackoverflow.com/questions/50571375
复制相似问题