• <small id='1phSp'></small><noframes id='1phSp'>

      <bdo id='1phSp'></bdo><ul id='1phSp'></ul>

    <tfoot id='1phSp'></tfoot>
  • <legend id='1phSp'><style id='1phSp'><dir id='1phSp'><q id='1phSp'></q></dir></style></legend>

        <i id='1phSp'><tr id='1phSp'><dt id='1phSp'><q id='1phSp'><span id='1phSp'><b id='1phSp'><form id='1phSp'><ins id='1phSp'></ins><ul id='1phSp'></ul><sub id='1phSp'></sub></form><legend id='1phSp'></legend><bdo id='1phSp'><pre id='1phSp'><center id='1phSp'></center></pre></bdo></b><th id='1phSp'></th></span></q></dt></tr></i><div id='1phSp'><tfoot id='1phSp'></tfoot><dl id='1phSp'><fieldset id='1phSp'></fieldset></dl></div>

        如何修改 CodeIgniter 日历以每天处理多个事件?

        时间:2023-12-01
          <i id='W2l9t'><tr id='W2l9t'><dt id='W2l9t'><q id='W2l9t'><span id='W2l9t'><b id='W2l9t'><form id='W2l9t'><ins id='W2l9t'></ins><ul id='W2l9t'></ul><sub id='W2l9t'></sub></form><legend id='W2l9t'></legend><bdo id='W2l9t'><pre id='W2l9t'><center id='W2l9t'></center></pre></bdo></b><th id='W2l9t'></th></span></q></dt></tr></i><div id='W2l9t'><tfoot id='W2l9t'></tfoot><dl id='W2l9t'><fieldset id='W2l9t'></fieldset></dl></div>
        • <tfoot id='W2l9t'></tfoot>

          1. <small id='W2l9t'></small><noframes id='W2l9t'>

              <legend id='W2l9t'><style id='W2l9t'><dir id='W2l9t'><q id='W2l9t'></q></dir></style></legend>

                <bdo id='W2l9t'></bdo><ul id='W2l9t'></ul>
                  <tbody id='W2l9t'></tbody>
                  本文介绍了如何修改 CodeIgniter 日历以每天处理多个事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在创建一个没有 jquery 日历插件的日历.我可以将数据库中的数据检索到日历中.但是当每天有多个数据时,日历视图中只有一个数据.当有多个数据时,我希望它是这样的.

                  I am creating a calendar without jquery calendar plugin. I could retrieve the data which is in the database to the calendar. But when there are multiple data per day only one data comes to the calendar view. I want it to be like this when there is multiple data.

                  但是当有多个数据时我得到的是这个

                  But what i am getting is this when there are multiple data

                  第 16 天有每四个数据.但它只显示一个.如果有人对此有任何想法,那将对我有所帮助.

                  the day 16 has every four data.but it shows only one. If anyone has an idea about this it would be help me.

                  以下是我的代码

                  控制器

                  <?php
                  
                  class My_calendar extends CI_Controller {
                  
                      public function index($year = null, $month = null) {
                          echo "My calendar project";
                          $this->showcal($year, $month);
                      }
                  
                      public function showcal($year = null, $month = null) {
                          $this->load->model('mycal_model');
                          $data['calendar'] = $this->mycal_model->generate($year, $month);
                  
                          $this->load->view('mycal', $data);
                      }
                  
                  }
                  

                  查看

                  <!DOCTYPE html>
                  <html lang="en">
                      <head>
                          <meta charset="utf-8">
                          <title>Welcome to CodeIgniter</title>
                  
                          <style type="text/css">
                  
                  
                  
                              #body{
                                  margin: 0 15px 0 15px;
                              }
                  
                  
                  
                              #container{
                                  margin: 10px;
                                  border: 1px solid #D0D0D0;
                                  -webkit-box-shadow: 0 0 8px #D0D0D0;
                              }
                  
                  
                              .calendar{
                                  /*           background-color: yellow;*/
                              }
                              table.calendar{
                                  margin: auto;
                                  border-collapse: collapse;
                              }
                              .calendar .days td {
                                  width:80px;
                                  height: 90px;
                                  padding: 4px;
                                  border:  1px solid #999;
                                  vertical-align:  top;
                                  background-color: #DEF;
                  
                              }
                              .calendar .days td:hover{
                                  background-color: #fff;
                              }
                              .calendar .highlight {
                                  font-weight: bold;
                                  color: #EF1BAC;
                              }
                              .calendar .content .gk_am{
                                  float: left;
                                  display: inline-block;
                                  width: 40px;
                                  background-color: #D0D0D0;
                              }
                              .calendar .content .gk_pm{
                                  float: right;
                                  display: inline-block;
                                  width: 40px;
                                  background-color: red;
                              }
                  
                              .calendar .content .rp_am{
                                  float: left;
                                  display: inline-block;
                                  width: 40px;
                                  background-color: gray;
                              }
                  
                              .calendar .content .rp_pm{
                                  float: right;
                                  display: inline-block;
                                  width: 40px;
                                  background-color: #D893A1;
                              }
                          </style>
                      </head>
                      <body>
                  
                          <div id="container">
                  
                              <div id="body">
                                  <?PHP echo $calendar; ?>
                  
                              </div>
                  
                  
                          </div>
                  
                      </body>
                  </html>
                  

                  型号

                  <?php
                  
                  class mycal_model extends CI_Model {
                  
                      function __construct() {
                          parent::__construct();
                          $this->mycal_model();
                      }
                  
                      function mycal_model() {
                  
                          $this->conf = array(
                              'show_next_prev' => True,
                              'next_prev_url' => base_url() . 'index.php/my_calendar/index/'
                          );
                  
                          $this->conf['template'] = '
                              {table_open}<table cellpadding="1" cellspacing="2" class="calendar">{/table_open}
                  
                              {heading_row_start}<tr>{/heading_row_start}
                  
                              {heading_previous_cell}<th class="prev_sign"><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 class="next_sign"><a href="{next_url}">&gt;&gt;</a></th>{/heading_next_cell}
                  
                              {heading_row_end}</tr>{/heading_row_end}
                  
                              //Deciding where to week row start
                              {week_row_start}<tr class="week_name" >{/week_row_start}
                              //Deciding  week day cell and  week days
                              {week_day_cell}<td >{week_day}</td>{/week_day_cell}
                              //week row end
                              {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_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>
                              {/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_end}</td>{/cal_cell_end}
                              {cal_row_end}</tr>{/cal_row_end}
                  
                              {table_close}</table>{/table_close}
                              ';
                      }
                  
                      function get_calendar_data($year, $month) {
                  
                          $query = $this->db->select('date_cal,title,type')->from('reservations')->like('date', "$year-$month", 'after')->get();
                          $cal_data = array();
                  
                          foreach ($query->result() as $row) {
                              if ($row->title == 'GK' && $row->type == 'AM') {
                                  $cal_data[substr($row->date_cal, 8, 2)] = '<div class="gk_am">' . $row->title . ' ' . $row->type . '</div>';
                              } else if ($row->title == 'GK' && $row->type == 'PM') {
                                  $cal_data[substr($row->date_cal, 8, 2)] = '<div class="gk_pm">' . $row->title . ' ' . $row->type . '</div>';
                              } else if ($row->title == 'RP' && $row->type == 'AM') {
                                  $cal_data[substr($row->date_cal, 8, 2)] = '<div class="rp_am">' . $row->title . ' ' . $row->type . '</div>';
                              } else if ($row->title == 'RP' && $row->type == 'PM') {
                                  $cal_data[substr($row->date_cal, 8, 2)] = '<div class="rp_pm">' . $row->title . ' ' . $row->type . '</div>';
                              }
                          }
                  
                  
                  
                          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);
                      }
                  
                  }
                  
                  ?>
                  

                  推荐答案

                  如果要显示所有有数据的日期的四个框,请尝试如下更改 get_calendar_data() foreach,

                  If you want to show all four boxes for the dates which has data, try to change the get_calendar_data() foreach as below,

                  $content = "";
                  $lastDay = -1;
                  $index = 0;
                  foreach ($query->result() as $row) {
                  
                          if($lastDay != intval(substr($row->date_cal, 8, 2))){       
                              if($index > 0 ){
                                 if($content != ''){
                                     $cal_data[$lastDay] = $content;
                                     $content = '';
                                 }
                              }
                              $index = 0;               
                          }
                  
                  
                          if ($row->title == 'GK' && $row->type == 'AM') {
                              $content .= '<div class="gk_am">' . $row->title . ' ' . $row->type . '</div>';
                          } else if ($row->title == 'GK' && $row->type == 'PM') {
                              $content .= '<div class="gk_pm">' . $row->title . ' ' . $row->type . '</div>';
                          }else if ($row->title == 'RP' && $row->type == 'AM') {
                              $content .= '<div class="rp_am">' . $row->title . ' ' . $row->type . '</div>';                
                          } else if ($row->title == 'RP' && $row->type == 'PM') {
                              $content .= '<div class="rp_pm">' . $row->title . ' ' . $row->type . '</div>';                
                          }
                  
                          $lastDay = intval(substr($row->date_cal, 8, 2));
                          $index++;     
                  
                      }
                  
                      if($lastDay != -1 && $content != ''){
                          $cal_data[$lastDay] = $content;
                      }
                  

                  让我知道它现在是否有效.

                  Let me know whether it works now or not.

                  这篇关于如何修改 CodeIgniter 日历以每天处理多个事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 PHP5 中将当前日历周的日期作为数组返回 下一篇:上传文件时禁止 Apache 403

                  相关文章

                      <legend id='llhkk'><style id='llhkk'><dir id='llhkk'><q id='llhkk'></q></dir></style></legend><tfoot id='llhkk'></tfoot>
                        <bdo id='llhkk'></bdo><ul id='llhkk'></ul>
                    1. <i id='llhkk'><tr id='llhkk'><dt id='llhkk'><q id='llhkk'><span id='llhkk'><b id='llhkk'><form id='llhkk'><ins id='llhkk'></ins><ul id='llhkk'></ul><sub id='llhkk'></sub></form><legend id='llhkk'></legend><bdo id='llhkk'><pre id='llhkk'><center id='llhkk'></center></pre></bdo></b><th id='llhkk'></th></span></q></dt></tr></i><div id='llhkk'><tfoot id='llhkk'></tfoot><dl id='llhkk'><fieldset id='llhkk'></fieldset></dl></div>

                      <small id='llhkk'></small><noframes id='llhkk'>