⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

how to display multiple events on particular date in the calendar



Manju
  • profile picture
  • Member

Posted 02 March 2018 - 06:24 AM

<?php
 
defined('BASEPATH') OR exit('No direct script access allowed');
 
 
class Mycal_model extends CI_Model{
    
    public $conf;
function __construct()
{
            parent::__construct();
            $this->Mycal_model();
             $this->load->database();
        }
            
          //$this->load->database();
        function Mycal_model(){
    
  $this->conf = array(
  'start_day' => 'monday',
  'show_next_prev' => true,
  'next_prev_url' => base_url() .'Auditorium/index/'
);
          $this->conf['template'] = '
 
{table_open}<table border="0" cellpadding="0" cellspacing="0" class="calendar">{/table_open}
 
{heading_row_start}<tr>{/heading_row_start}
 
{heading_previous_cell}<th><a href="{previous_url}">&lt;&lt;</a></th>{/heading_previous_cell}
{heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
{heading_next_cell}<th><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}
 
{heading_row_end}</tr>{/heading_row_end}
 
{week_row_start}<tr>{/week_row_start}
{week_day_cell}<td>{week_day}</td>{/week_day_cell}
{week_row_end}</tr>{/week_row_end}
 
{cal_row_start}<tr class="days">{/cal_row_start}
{cal_cell_start}<td>{/cal_cell_start}
{cal_cell_start_today}<td>{/cal_cell_start_today}
{cal_cell_start_other}<td class="other-month">{/cal_cell_start_other}
 
{cal_cell_content}
  <div class="day_num">{day}</div>
  <div class="content">{content}</div>
  {/cal_cell_content}
  
{cal_cell_content_today} 
<div class="day_num highlight">{day}</div>
  <div class="content">{content}</div>
                                          </div>{/cal_cell_content_today}
 
{cal_cell_no_content}<div class="day_num">{day}</div>{/cal_cell_no_content}
{cal_cell_no_content_today}<div class="day_num highlight">{day}</div>{/cal_cell_no_content_today}
 
{cal_cell_blank}&nbsp;{/cal_cell_blank}
 
{cal_cell_other}{day}{/cal_cel_other}
 
{cal_cell_end}</td>{/cal_cell_end}
{cal_cell_end_today}</td>{/cal_cell_end_today}
{cal_cell_end_other}</td>{/cal_cell_end_other}
{cal_row_end}</tr>{/cal_row_end}
 
{table_close}</table>{/table_close}
 
                ';
 
 
}
 
     function get_calendar_data($year, $month){
            
      $query = $this->db->select('booking_date, sessions')->from('wp_rmcl_ad_application_form')->like('booking_date', "$year-$month", 'after')->get();
                      
      $cal_data = array();
                      $content = "";
                      $lastDay = -1;
                      $index = 0;
 
     foreach ($query->result() as $row) {
                         if($lastDay != intval(substr($row->booking_date, 8, 2))){       
                             
if($index > 0 && $content != '' ){
                               
                                      $cal_data[$lastDay] = $content;
                                          $content = '';
                                         
                                     }
                           $index = 0;               
                          }
                                if ($row->sessions == 'Full_day') {
                                   $cal_data[substr($row->booking_date, 8, 2)] = '<div class = "fullday">'.$row->sessions.'</div>';
                               } else if ($row->sessions == 'Morning'){
                                   $cal_data[substr($row->booking_date, 8, 2)] ='<div class = "morning">'.$row->sessions.'</div>';
                               }
                               else if ($row->sessions == 'Evening'){
                                   $cal_data[substr($row->booking_date, 8, 2)] ='<div class = "evening">'.$row->sessions.'</div>';
                               }
                                    $lastDay = intval(substr($row->booking_date, 8, 2));
                                 $index++;            
                            }
                                 if($lastDay != -1 && $content != ''){
                                  $cal_data[$lastDay] = $content;
                                      }
 
                           return $cal_data;
 
               }
         
        function generate($year,$month){
 
                $this->load->library('calendar', $this->conf);
 
                $cal_data = $this->get_calendar_data($year, $month);
               
                return  $this->calendar->generate($year, $month, $cal_data);
  }
 
 }