php - how to give multiple colors in the same cell in a full calendar? -
i want create event calendar. there 2 halls in upstairs , downstairs. , functions should categorized or pm. there 4 different colors upstairs am, upstairs pm, downstairs , downstairs pm.
i want divided calendar cell 4 , give different colors them. retrieve 1 color.i using php codeigniter framework. not in css styles if can give me idea how if great help. in advance.
it should this
my current output this
following script use generate calendar
<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 type(am or pm) start: value.date_cal, //date of calendar }); }); /* initialize 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 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, // allows things dropped onto calendar !!! drop: function(date, allday) { // function called when dropped }, buttontext: { prev: '<i class="fa fa-chevron-left"></i>', next: '<i class="fa fa-chevron-right"></i>' }, eventlimit: true, events: events }); }); </script>
model
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(); }
controller
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); }
found way own give multiple colors. couldn't divided cell. posting assuming else when need that. changed script
<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 type(am or pm) start: value.date_cal, //date of calendar }); if(value.title ==='royal princess ballroom (downstairs)' && value.type ==='am'){ downhall.push({ title: value.title + ' (' + value.type + ')' , //get type(am or pm) start: value.date_cal, //date of calendar color:'#ffff00', textcolor:'#000603', }); }else if(value.title ==='royal princess ballroom (downstairs)' && value.type ==='pm'){ downhall.push({ title: value.title + ' (' + value.type + ')' , //get type(am or pm) start: value.date_cal, //date of calendar color:'#fe642e', textcolor:'#000603', }); } else if(value.title ==='grand kings ballroom (upstairs)' && value.type ==='pm'){ uphall.push({ title: value.title + ' (' + value.type + ')' , //get type(am or pm) start: value.date_cal, //date of calendar color:'#9ff781', textcolor:'#000603', }); }else{ uphall.push({ title: value.title + ' (' + value.type + ')' , //get type(am or pm) start: value.date_cal, //date of calendar color:'#31b404', textcolor:'#000603', }); } }); /* initialize 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 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, // allows things dropped onto calendar !!! drop: function(date, allday) { // function called when 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>
my output
hope in same struggle was.
Comments
Post a Comment