Welcome Guest, Not a member yet? Register   Sign In
Adding multiple variables to calendar days
#1

Hello;

I am using Codeigniter calendar3 and so far I have got it this far -> https://prnt.sc/g2z1co

I have a very specific requirement I am not sure how to achieve.

I want to check tasks in my database (already do), and when I build the calandar, wanna change the CSS of that day and highlight the div or td or ....

Also, I want every single day to be a link (like July 25th on my current code) so I can click and add task etc.

I am not that far but I am not sure how to take it from here.

In the doc they say it's possible to do whatever.

Here is my code:

Controller:
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Welcome extends CI_Controller {

 
/**
 * Index Page for this controller.
 *
 * Maps to the following URL
 * http://example.com/index.php/welcome
 * - or -
 * http://example.com/index.php/welcome/index
 * - or -
 * Since this controller is set as the default controller in
 * config/routes.php, it's displayed at http://example.com/
 *
 * So any other public methods not prefixed with an underscore will
 * map to /index.php/welcome/<method_name>
 * @see https://codeigniter.com/user_guide/general/urls.html
 */
 
public function index()
 
         {
 
          $query $this->db->get_where('tasks', array('user_id' => 1));
 
              $this->data['tasks'] = $query->result_array();
 
              $this->calendar();
 
              $this->load->view('welcome_message'$this->data);
 
         }
 
    public function calendar()
 
         {
 
              $prefs['template'] = '
                  {table_open}<table border="0" cellpadding="0" cellspacing="0" class = "text-center table" id = "table-calendar" style = "font-size:13px; border:0; font-family:Arial,sans-serif; width:90%">{/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}"><strong style = "font-size:">{heading}</strong><hr /></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 style = " border:0;">{/week_row_start}
                  {week_day_cell}<td style = "padding:0px; border:none;">{week_day}</td>{/week_day_cell}
                  {week_row_end}</tr>{/week_row_end}

                  {cal_row_start}<tr style = " border:0; ">{/cal_row_start}
                  {cal_cell_start}<td style = "padding:0px; border:none; line-height:2.2">{/cal_cell_start}
                  {cal_cell_start_today}<div class = "div-day"><td style = "background-color:#419dcd">{/cal_cell_start_today}
                  {cal_cell_start_other}<td class="other-month">{/cal_cell_start_other}

                  {cal_cell_content}<a style = "text-decoration:none" href="{content}"><div class = "div-day">{day}</div></a>{/cal_cell_content}
                  {cal_cell_content_today}<div class="highlight"><a href="{content}">{day}</a></div>{/cal_cell_content_today}

                  {cal_cell_no_content}{day}{/cal_cell_no_content}
                  {cal_cell_no_content_today}<div class="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}'
;
 
              $this->load->library('calendar'$prefs);
 
             


View

PHP Code:
<div class="container">
 <
div class="row">
 
  <?php
   $year 
date('Y');
 
  $month=0;
 
     
   
while($month<12)
 
  {
 
  $data=array();
 
         $days=0;
 
         $month++;
 
         while($days<32)
 
  {
 
  $days++;
 
             foreach($tasks as $row => $val)
 
               {
 
                 if(strtotime($year."-".$month."-".$days)==strtotime($val['date_added']))
 
                   {
 
                       $data[$days] = $days;
 
                   }
 
               }
 
           
 
         ?>
   <div class="col-md-2"><?php echo $this->calendar->generate($year,$month$data);?></div>
   <?php
   
if($month==6)
 
  {
 
  ?></div><div class="row"><?php
   
}
 
  ?>

   </div> 
</div> 

Thanks
Reply


Messages In This Thread
Adding multiple variables to calendar days - by behnampmdg3 - 08-01-2017, 06:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB