Ish*_*ake 6 css php codeigniter fullcalendar
我想创建一个活动日历.楼上和楼下有两个大厅.和功能应分为上午或下午.楼上的上午有4种不同颜色,楼上是下午,楼上是下午和下楼.
我想将日历单元格分成四个,并为它们提供不同的颜色.我只能检索一种颜色.我正在使用php codeigniter框架.我不擅长CSS风格如果有人可以给我一个想法,如果这将是一个很大的帮助.提前致谢.
它应该是这样的

我目前的输出是这样的

以下是我用来生成日历的脚本
<script>
$(document).ready(function() {
var selected_date;
var holiday_list =<?php echo json_encode($calendar_results); ?>;
var events = []; //The events array
$.each(holiday_list, function(key, value) {
events.push({
title:value.type, //get the type(am or pm)
start: value.date_cal, //date of the calendar
});
});
/* initialize the calendar
-----------------------------------------------------------------*/
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
isRTL: $('body').hasClass('rtl'), //rtl support for calendar
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
selected_date = new Date(start);
selected_date = $.fullCalendar.formatDate(selected_date, 'yyyy-MM-dd');
},
editable: true,
droppable: false, // this allows things to be dropped onto the calendar !!!
drop: function(date, allDay) { // this function is called when something is dropped
},
buttonText: {
prev: '<i class="fa fa-chevron-left"></i>',
next: '<i class="fa fa-chevron-right"></i>'
},
eventLimit: true,
events: events
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
模型
function get_all_reservations_for_calendar(){
$this->db->select('reservations.date_cal,reservations.type,reservations.title,reservations.description');
$this->db->from('reservations');
$this->db->where('is_deleted', '0');
$query = $this->db->get();
return $query->result();
}
Run Code Online (Sandbox Code Playgroud)
调节器
function index() {
$reservation_service = new Reservation_service();
$output['calendar_results'] = $reservation_service->get_all_reservations_for_calendar();
$partials = array('content' => 'dashboard/dashboard_view');
$this->template->load('template/main_template', $partials, $output);
}
Run Code Online (Sandbox Code Playgroud)
我自己找到了一种提供多种颜色的方法。但无法分裂细胞。我发布它是假设它会在其他人需要类似的东西时对其有所帮助。我只改变了脚本
<script>
$(document).ready(function() {
var selected_date;
var holiday_list =<?php echo json_encode($calendar_results); ?>;
var downHall=[];
var upHall=[];
var events = []; //The events array
$.each(holiday_list, function(key, value) {
events.push({
title: value.type + value.title, //get the type(am or pm)
start: value.date_cal, //date of the calendar
});
if(value.title ==='Royal Princess Ballroom (Downstairs)' && value.type ==='am'){
downHall.push({
title: value.title + ' (' + value.type + ')' , //get the type(am or pm)
start: value.date_cal, //date of the calendar
color:'#FFFF00',
textColor:'#000603',
});
}else if(value.title ==='Royal Princess Ballroom (Downstairs)' && value.type ==='pm'){
downHall.push({
title: value.title + ' (' + value.type + ')' , //get the type(am or pm)
start: value.date_cal, //date of the calendar
color:'#FE642E',
textColor:'#000603',
});
}
else if(value.title ==='Grand Kings Ballroom (Upstairs)' && value.type ==='pm'){
upHall.push({
title: value.title + ' (' + value.type + ')' , //get the type(am or pm)
start: value.date_cal, //date of the calendar
color:'#9FF781',
textColor:'#000603',
});
}else{
upHall.push({
title: value.title + ' (' + value.type + ')' , //get the type(am or pm)
start: value.date_cal, //date of the calendar
color:'#31B404',
textColor:'#000603',
});
}
});
/* initialize the calendar
-----------------------------------------------------------------*/
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
isRTL: $('body').hasClass('rtl'), //rtl support for calendar
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
selected_date = new Date(start);
selected_date = $.fullCalendar.formatDate(selected_date, 'yyyy-MM-dd');
},
editable: true,
droppable: false, // this allows things to be dropped onto the calendar !!!
drop: function(date, allDay) { // this function is called when something is dropped
},
buttonText: {
prev: '<i class="fa fa-chevron-left"></i>',
next: '<i class="fa fa-chevron-right"></i>'
},
eventLimit: true,
events: downHall.concat(upHall),
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
我的输出

希望这能帮助那些和我有同样挣扎的人。
| 归档时间: |
|
| 查看次数: |
537 次 |
| 最近记录: |