/**
  * カレンダー情報取得.
  *
  * @param  integer $disp_month 表示する月数
  * @return array   カレンダー情報の配列を返す
  */
 public function lfGetCalendar($disp_month = 1)
 {
     $objDate = new SC_Date_Ex();
     $arrCalendar = array();
     $today = date('Y/m/d');
     for ($j = 0; $j <= $disp_month - 1; $j++) {
         $time = mktime(0, 0, 0, date('n') + $j, 1);
         $year = date('Y', $time);
         $month = date('n', $time);
         $objMonth = new Calendar_Month_Weekdays($year, $month, 0);
         $objMonth->build();
         $i = 0;
         while ($objDay = $objMonth->fetch()) {
             $arrCalendar[$j][$i]['in_month'] = $month == $objDay->month;
             $arrCalendar[$j][$i]['first'] = $objDay->first;
             $arrCalendar[$j][$i]['last'] = $objDay->last;
             $arrCalendar[$j][$i]['empty'] = $objDay->empty;
             $arrCalendar[$j][$i]['year'] = $year;
             $arrCalendar[$j][$i]['month'] = $month;
             $arrCalendar[$j][$i]['day'] = $objDay->day;
             $arrCalendar[$j][$i]['holiday'] = $objDate->isHoliday($year, $month, $objDay->day);
             $arrCalendar[$j][$i]['today'] = $today === sprintf('%04d/%02d/%02d', $year, $month, $objDay->day);
             $i++;
         }
     }
     return $arrCalendar;
 }
Exemple #2
0
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $year = intval($requests['year']);
     $month = intval($requests['month']);
     // ----------
     if (!$year) {
         $year = date('Y');
     }
     if (!$month) {
         $month = date('n');
     }
     if ($year == date('Y') && $month == date('n')) {
         $is_curr = true;
         $curr_day = date('d');
     }
     if ($year < date('Y') || $year > intval(date('Y')) + 1) {
         $this->set('add_schedule', false);
     } else {
         $this->set('add_schedule', true);
     }
     $this->set('inc_navi', fetch_inc_navi('h'));
     // イベント
     $event_list = db_schedule_event4c_member_id($year, $month, $u);
     // 誕生日
     $birth_list = db_schedule_birth4c_member_id($month, $u);
     include_once 'Calendar/Month/Weekdays.php';
     $Month = new Calendar_Month_Weekdays($year, $month, 0);
     $Month->build();
     $calendar = array();
     $i = 0;
     while ($Day = $Month->fetch()) {
         if ($Day->isFirst()) {
             $i++;
         }
         if ($Day->isEmpty()) {
             $calendar[$i][] = array();
         } else {
             $day = $Day->thisDay();
             $item = array('day' => $day, 'now' => false, 'birth' => $birth_list[$day], 'event' => $event_list[$day], 'schedule' => db_schedule_c_schedule_list4date($year, $month, $day, $u), 'holiday' => db_c_holiday_list4date($month, $day));
             $item['day'] = $day;
             if ($is_curr && $item['day'] == $curr_day) {
                 $item['now'] = true;
             }
             $calendar[$i][] = $item;
         }
     }
     $ym = array('year_disp' => $year, 'month_disp' => $month, 'year_prev' => date('Y', $Month->prevMonth(true)), 'month_prev' => date('n', $Month->prevMonth(true)), 'year_next' => date('Y', $Month->nextMonth(true)), 'month_next' => date('n', $Month->nextMonth(true)));
     $this->set("ym", $ym);
     $this->set("year", $year);
     $this->set("month", $month);
     $this->set("calendar", $calendar);
     $c_member = db_member_c_member4c_member_id($u);
     $this->set("pref_list", p_regist_prof_c_profile_pref_list4null());
     $this->set("c_member", $c_member);
     return 'success';
 }
Exemple #3
0
 protected function generateCalendar(sfWebRequest $request)
 {
     $this->setTemplate('index');
     $old_error_level = error_reporting();
     error_reporting($old_error_level & ~(E_STRICT | E_DEPRECATED));
     include_once 'Calendar/Month/Weekdays.php';
     $this->year = (int) $request->getParameter('year', date('Y'));
     $this->month = (int) $request->getParameter('month', date('n'));
     $this->add_schedule = $this->year < date('Y') || $this->year > date('Y') + 1 ? false : true;
     $first_day = sprintf('%04d-%02d-01', $this->year, $this->month);
     $end_day = sprintf('%04d-%02d-%02d', $this->year, $this->month, date('t', strtotime($first_day)));
     if ($this->is_community) {
         if ('all' === $this->calendar_show_flag || 'only_community_event' === $this->calendar_show_flag) {
             $event_list = opCalendarPluginExtension::getMyCommunityEventByStartDayToEndDayInCommunity($this->community, $first_day, $end_day);
         }
     } else {
         $birth_list = $this->isSelf ? opCalendarPluginExtension::getScheduleBirthMemberByMonths(array($this->month)) : array();
         $event_list = $this->isSelf ? opCalendarPluginExtension::getMyCommunityEventByStartDayToEndDay($first_day, $end_day) : array();
     }
     $Month = new Calendar_Month_Weekdays($this->year, $this->month, 1);
     $Month->build();
     $this->calendar = array();
     $row = 0;
     $col = 0;
     $this->dayofweek = array('class' => array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'), 'item' => array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'));
     while ($Day = $Month->fetch()) {
         if ($Day->isFirst()) {
             $row++;
             $col = 0;
         }
         $item = array('dayofweek_class_name' => $this->dayofweek['class'][$col], 'dayofweek_item_name' => $this->dayofweek['item'][$col]);
         $scheduleTable = Doctrine::getTable('Schedule');
         if ($Day->isEmpty()) {
             $this->calendar[$row][$col++] = $item;
         } else {
             $day = $Day->thisDay();
             $month_day = sprintf('%02d-%02d', $this->month, $day);
             $year_month_day = sprintf('%04d-%s', $this->year, $month_day);
             $is_today = (int) date('Y') === $this->year && (int) date('n') === $this->month && (int) date('d') === $day;
             $schedules = array();
             if ($this->is_community) {
                 if ('all' === $this->calendar_show_flag || 'only_member_schedule' === $this->calendar_show_flag) {
                     $schedules = $scheduleTable->getScheduleByThisDayAndMemberInCommunity($this->community, $this->year, $this->month, $day);
                 }
             } else {
                 $schedules = $scheduleTable->getScheduleByThisDayAndMember($this->year, $this->month, $day, $this->member);
             }
             $item += array('day' => $day, 'today' => $is_today, 'births' => isset($birth_list[$month_day]) ? $birth_list[$month_day] : array(), 'events' => isset($event_list[$year_month_day]) ? $event_list[$year_month_day] : array(), 'schedules' => $schedules, 'holidays' => Doctrine::getTable('Holiday')->getByYearAndMonthAndDay($this->year, $this->month, $day));
             $this->calendar[$row][$col++] = $item;
         }
     }
     $this->ym = array('year_disp' => $this->year, 'month_disp' => $this->month, 'year_prev' => date('Y', $Month->prevMonth(true)), 'month_prev' => date('n', $Month->prevMonth(true)), 'year_next' => date('Y', $Month->nextMonth(true)), 'month_next' => date('n', $Month->nextMonth(true)));
     error_reporting($old_error_level);
 }
Exemple #4
0
<p>Rendering calendar....</p>
<table>
<caption><?php 
echo $Textual->thisMonthName() . ' ' . $Textual->thisYear();
?>
</caption>
<tr>
<?php 
$dayheaders = $Textual->orderedWeekdays('short');
foreach ($dayheaders as $dayheader) {
    echo '<th>' . $dayheader . '</th>';
}
?>
</tr>
<?php 
$Calendar->build();
while ($Day = $Calendar->fetch()) {
    if ($Day->isFirst()) {
        echo "<tr>\n";
    }
    if ($Day->isEmpty()) {
        echo '<td>&nbsp;</td>';
    } else {
        echo '<td>' . $Day->thisDay() . '</td>';
    }
    if ($Day->isLast()) {
        echo "</tr>\n";
    }
}
?>
</table>
Exemple #5
0
<caption>
<?php 
echo date('F Y', $Month->getTimeStamp());
?>
</caption>
<tr>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
</tr>
<?php 
while ($Day = $Month->fetch()) {
    // Build a link string for each day
    $link = $_SERVER['PHP_SELF'] . '?y=' . $Day->thisYear() . '&m=' . $Day->thisMonth() . '&d=' . $Day->thisDay();
    // isFirst() to find start of week
    if ($Day->isFirst()) {
        echo "<tr>\n";
    }
    if ($Day->isSelected()) {
        echo "<td class=\"selected\">" . $Day->thisDay() . "</td>\n";
    } else {
        if ($Day->isEmpty()) {
            echo "<td>&#160;</td>\n";
        } else {
            echo "<td><a href=\"" . $link . "\">" . $Day->thisDay() . "</a></td>\n";
        }
    }
Exemple #6
0
<caption>
<?php 
echo $thisDate->format('%B %Y');
?>
</caption>
<tr>
<th>M</th>
<th>T</th>
<th>W</th>
<th>T</th>
<th>F</th>
<th>S</th>
<th>S</th>
</tr>
<?php 
while ($day = $month->fetch()) {
    // Build a link string for each day
    $link = $_SERVER['PHP_SELF'] . '?y=' . $day->thisYear() . '&m=' . $day->thisMonth() . '&d=' . $day->thisDay();
    // isFirst() to find start of week
    if ($day->isFirst()) {
        echo "<tr>\n";
    }
    if ($day->isSelected()) {
        echo '<td class="selected">' . $day->thisDay() . '</td>' . "\n";
    } else {
        if ($day->isEmpty()) {
            echo '<td>&#160;</td>' . "\n";
        } else {
            echo '<td><a href="' . $link . '">' . $day->thisDay() . '</a></td>' . "\n";
        }
    }
function smarty_function_mini_calendar($params, &$smarty){
  $start = getmicrotime();

  # includes
  require_once 'Calendar/Calendar.php';
  require_once 'Calendar/Month/Weekdays.php';
  require_once 'Calendar/Day.php';
  require_once $smarty->_get_plugin_filepath('modifier','date_format');
  require_once $smarty->_get_plugin_filepath('function','html_select_date');
  require_once $smarty->_get_plugin_filepath('modifier','strip');

  # Cuando se hacia un redirect usando el ErrorDocument del 403 al archivo, no se pasaban los
  # parametros
  if((!isset($_REQUEST['Year'])&&!isset($_REQUEST['Month']))||!isset($_REQUEST['Day'])) {
    $query = parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY);
    parse_str($query,$_REQUEST);
  }
  if (!isset($_REQUEST['Year'])) $_REQUEST['Year'] = date('Y');
  if (!isset($_REQUEST['Month'])) $_REQUEST['Month'] = date('m');
  if (!isset($_REQUEST['Day'])) $_REQUEST['Day'] = date('d');
  
  // Build the month
  $Month = new Calendar_Month_Weekdays($_REQUEST['Year'],$_REQUEST['Month']);
  
  // Construct strings for next/previous links
  $PMonth = $Month->prevMonth('object'); // Get previous month as object
  $prev = '?Year='.$PMonth->thisYear().'&amp;Month='.$PMonth->thisMonth().'&amp;Day='.$PMonth->thisDay();
  $NMonth = $Month->nextMonth('object');
  $next = '?Year='.$NMonth->thisYear().'&amp;Month='.$NMonth->thisMonth().'&amp;Day='.$NMonth->thisDay();
  
  // Build the days in the month
  if($params['selectedDays'])
    foreach($params['selectedDays'] as $selectedDay) {
      $selectedDays[] = new Calendar_Day(smarty_modifier_date_format($selectedDay,"%Y"),smarty_modifier_date_format($selectedDay,"%m"), smarty_modifier_date_format($selectedDay,"%d"));
    }
  
  $class = ($params['custom_class']?$params['custom_class']:'');
  $Month->build($selectedDays);
  
  $out = "<table class=\"calendar\">";
  $out .= "<caption>".smarty_modifier_date_format($Month->getTimeStamp(),"%B %Y")."</caption>";
  $out .= "<tr>";
  $out .= "<th>Lun</th>";
  $out .= "<th>Mar</th>";
  $out .= "<th>Mie</th>";
  $out .= "<th>Jue</th>";
  $out .= "<th>Vie</th>";
  $out .= "<th".($params['dif_weekend']?" class=\"weekend sat\"":"").">Sáb</th>";
  $out .= "<th".($params['dif_weekend']?" class=\"weekend sun\"":"").">Dom</th>";
  $out .= "</tr>";
  while ( $Day = $Month->fetch() ) {
    // Build a link string for each day
    //$link = $_SERVER['PHP_SELF'].
    $link =     ($params['action']?$params['action']:"").'?Year='.$Day->thisYear().
                '&amp;Month='.$Day->thisMonth().
                '&amp;Day='.$Day->thisDay();

    
    //	Contain the week's day's number, 0 = sunday, ..., 6 = saturday
    $num_day = date("w",strtotime($Day->thisYear()."-".$Day->thisMonth()."-".$Day->thisDay()));
    // isFirst() to find start of week
    if ( $Day->isFirst() )
        $out .= "<tr>\n";

    if ( $Day->isSelected() ) {
        $out .= "<td class=\"selected\">";
        if($params['dif_weekend'])
          if($num_day == 6)
            $out .= "<div class=\"weekend sat\">";
          elseif($num_day == 0)
            $out .= "<div class=\"weekend sun\">";
          elseif($Day->thisDay()==date("d") AND $Day->thisMonth()==date("m") AND $Day->thisYear()==date("Y"))
            $out .= "<div class=\"now\">";
        $out .= "<a href=\"".$link."\"".(($class)?" class=\"$class\"":"").">".$Day->thisDay()."</a>";
        if(($params['dif_weekend'] && ($num_day == 6 || $num_day == 0)) || ($Day->thisDay()==date("d") && $Day->thisMonth()==date("m") && $Day->thisYear()==date("Y")))
          $out .= "</div>";
        $out .= "</td>\n";
    } else if ( $Day->isEmpty() ) {
        $out .= "<td>&nbsp;</td>\n";
    } elseif($Day->thisDay()==date("d") AND $Day->thisMonth()==date("m") AND $Day->thisYear()==date("Y")) {
        $out .= "<td><div class=\"now\">".$Day->thisDay()."</div></td>\n";
    } else {
        $out .= "<td>";
        if($num_day == 6 && $params['dif_weekend'])
          $out .= "<div class=\"weekend sat\">".$Day->thisDay()."</div>";
        elseif($num_day == 0 && $params['dif_weekend'])
          $out .= "<div class=\"weekend sun\">".$Day->thisDay()."</div>";
        else $out .= $Day->thisDay();
	$out .= "</td>\n";
    }
    // isLast() to find end of week
    if ( $Day->isLast() )
        $out .= "</tr>\n";
  }
 
  $start_year = ($params['start_year'])?$params['start_year']:"-5";
  $end_year = ($params['end_year'])?$params['end_year']:"+5";
  if (!isset($params['display_date'])) $params['display_date'] = true;
  $display_date = $params['display_date'];
  $day = $_REQUEST['Year']."-".$_REQUEST['Month']."-01";
  if($display_date) {
    $out .= "<tr>";
    $out .= "<td colspan=\"7\" class=\"control\"><form method=\"get\" action=\"".$params['action']."\"";
    $out .= ($params['frm_extra']?" ".$params['frm_extra']:"").">".smarty_function_html_select_date(array('time'=>$day,'prefix'=>'','start_year'=>$start_year,'end_year'=>$end_year,'display_days'=>false, 'display_months'=>true, 'display_years'=>true, 'month_extra'=>'id="Month"', 'year_extra'=>'id="Year"'),$smarty)."&nbsp;".($params['btn_img']?"<input name=\"btnsubmit\" type=\"image\" src=\"".$params['btn_img']."\"/>":"<input name=\"btnsubmit\" type=\"submit\" value=\"Ir\" />").($params['today_btn']===true?"&nbsp;<input name=\"today\" type=\"button\" value=\"Hoy\" title=\"Presione para ir al mes en curso\" onclick=\"location.href = './'\" />":"")."</form></td>";
    $out .= "</tr>";
  }
  $out .= "</table>";
  $out = smarty_modifier_strip($out);
  return $out;
}
Exemple #8
0
/**
 * メッセージページのカレンダー生成
 */
function db_common_message_monthly_calendar($u, $year, $month, $c_member_id, $box)
{
    include_once 'Calendar/Month/Weekdays.php';
    $Month = new Calendar_Month_Weekdays($year, $month, 0);
    $Month->build();
    $is_message_list = db_message_is_message_list4date($u, $year, $month, $box);
    $calendar = array();
    $week = 0;
    while ($Day = $Month->fetch()) {
        if ($Day->isFirst()) {
            $week++;
        }
        if ($Day->isEmpty()) {
            $calendar['days'][$week][] = array();
        } else {
            $day = $Day->thisDay();
            $item = array('day' => $day, 'is_message' => @in_array($day, $is_message_list));
            $calendar['days'][$week][] = $item;
        }
    }
    if ($box == 'inbox' || !$box) {
        $where = "c_member_id_to = ?" . " AND is_deleted_to = 0" . " AND is_send = 1";
    } elseif ($box == 'outbox') {
        $where = "c_member_id_from = ?" . " AND is_deleted_from = 0" . " AND is_send = 1";
    } else {
        return null;
    }
    // 最初にメッセージを書いた日
    $sql = "SELECT r_datetime FROM c_message WHERE {$where} ORDER BY r_datetime";
    $first_datetime = db_get_one($sql, array(intval($u)));
    // 前の月、次の月
    $prev_month = $Month->prevMonth('timestamp');
    $this_month = $Month->thisMonth('timestamp');
    $next_month = $Month->nextMonth('timestamp');
    $ym = array('disp_year' => $year, 'disp_month' => $month, 'prev_year' => null, 'prev_month' => null, 'next_year' => null, 'next_month' => null);
    if ($first_datetime && strtotime($first_datetime) < $this_month) {
        $ym['prev_year'] = date('Y', $prev_month);
        $ym['prev_month'] = date('n', $prev_month);
    }
    if ($next_month < time()) {
        $ym['next_year'] = date('Y', $next_month);
        $ym['next_month'] = date('n', $next_month);
    }
    $calendar['ym'] = $ym;
    return $calendar;
}
 /**
  * カレンダー情報取得.
  *
  * @param integer $disp_month 表示する月数
  * @return array $arrCalendar カレンダー情報の配列を返す
  */
 function lfGetCalendar($disp_month = 1)
 {
     for ($j = 0; $j <= $disp_month - 1; ++$j) {
         $year = date('Y');
         $month = date('n') + $j;
         if ($month > 12) {
             $month = $month % 12;
             $year = $year + $month % 12;
         }
         $objMonth = new Calendar_Month_Weekdays($year, $month, 0);
         $objMonth->build();
         $i = 0;
         while ($objDay = $objMonth->fetch()) {
             if ($month == $objDay->month) {
                 $arrCalendar[$j][$i]['in_month'] = true;
             } else {
                 $arrCalendar[$j][$i]['in_month'] = false;
             }
             $arrCalendar[$j][$i]['first'] = $objDay->first;
             $arrCalendar[$j][$i]['last'] = $objDay->last;
             $arrCalendar[$j][$i]['empty'] = $objDay->empty;
             $arrCalendar[$j][$i]['year'] = $year;
             $arrCalendar[$j][$i]['month'] = $month;
             $arrCalendar[$j][$i]['day'] = $objDay->day;
             if ($this->lfCheckHoliday($year, $month, $objDay->day)) {
                 $arrCalendar[$j][$i]['holiday'] = true;
             } else {
                 $arrCalendar[$j][$i]['holiday'] = false;
             }
             ++$i;
         }
     }
     return $arrCalendar;
 }
 function execute($requests)
 {
     $u = $GLOBALS['AUTH']->uid();
     // --- リクエスト変数
     $year = $requests['year'];
     $month = $requests['month'];
     $pref_id = $requests['pref_id'];
     // ----------
     if (empty($requests['target_id']) || $requests['target_id'] == $u) {
         //自分自身
         $target_id = $u;
         $this->set('is_h', true);
         //判別フラグ
         $this->set('inc_navi', fetch_inc_navi('h'));
     } else {
         //他人
         $target_id = $requests['target_id'];
         $this->set('is_f', true);
         //判別フラグ
         $this->set('inc_navi', fetch_inc_navi('f', $target_id));
     }
     if (!$year) {
         $year = date('Y');
     }
     if (!$month) {
         $month = date('n');
     }
     if ($year == date('Y') && $month == date('n')) {
         $is_curr = true;
         $curr_day = date('d');
     }
     // イベント
     $event_list = db_schedule_event4c_member_id($year, $month, $target_id);
     // 誕生日
     $birth_list = db_schedule_birth4c_member_id($month, $target_id);
     // Todo
     $todo_list = biz_schedule_todo4c_member_id($u, $target_id, $year, $month);
     require_once 'Calendar/Month/Weekdays.php';
     $Month = new Calendar_Month_Weekdays($year, $month, 0);
     $Month->build();
     $calendar = array();
     $schedule = array();
     $i = 0;
     while ($Day = $Month->fetch()) {
         if ($Day->isFirst()) {
             $i++;
         }
         if ($Day->isEmpty()) {
             $calendar[$i][] = array();
         } else {
             $day = $Day->thisDay();
             $schedule = biz_getDateMemberSchedule($year, sprintf("%02d", $month), sprintf("%02d", $day), $target_id, $u);
             $banner = biz_isBannerSchedule($year, sprintf("%02d", $month), sprintf("%02d", $day), $target_id);
             if (!empty($banner)) {
                 foreach ($banner as $value) {
                     array_push($schedule, $value);
                 }
             }
             $item = array('day' => $day, 'now' => false, 'birth' => $birth_list[$day], 'event' => $event_list[$day], 'schedule' => $schedule, 'todo' => $todo_list[$day], 'holiday' => db_c_holiday_list4date($month, $day));
             $item['day'] = $day;
             if ($is_curr && $item['day'] == $curr_day) {
                 $item['now'] = true;
             }
             $calendar[$i][] = $item;
         }
     }
     $ym = array('year_disp' => $year, 'month_disp' => $month, 'year_prev' => date('Y', $Month->prevMonth(true)), 'month_prev' => date('n', $Month->prevMonth(true)), 'year_next' => date('Y', $Month->nextMonth(true)), 'month_next' => date('n', $Month->nextMonth(true)));
     $this->set("ym", $ym);
     $this->set("year", $year);
     $this->set("month", $month);
     $this->set("calendar", $calendar);
     $c_member = db_member_c_member4c_member_id($target_id);
     $this->set("pref_list", p_regist_prof_c_profile_pref_list4null());
     $this->set("c_member", $c_member);
     return 'success';
 }
function GestionAffichageCalendrier($type = 'calendrier')
{
    $retour = '<div class="' . $type . '">';
    $url = $GLOBALS['_BAZAR_']['url'];
    $db =& $GLOBALS['_BAZAR_']['db'];
    // Nettoyage de l'url de la query string
    $chaine_url = $url->getQueryString();
    $tab_params = explode('&amp;', $chaine_url);
    if (count($tab_params) == 0) {
        $tab_params = explode('&', $chaine_url);
    }
    foreach ($tab_params as $param) {
        $tab_parametre = explode('=', $param);
        if ($tab_parametre[0] != 'wiki') {
            $url->removeQueryString($tab_parametre[0]);
        }
    }
    if (!isset($_GET['y'])) {
        $_GET['y'] = date('Y');
    }
    if (!isset($_GET['m'])) {
        $_GET['m'] = date('m');
    }
    // 	Construction Mois en Cours
    $month = new Calendar_Month_Weekdays($_GET['y'], $_GET['m']);
    $curStamp = $month->getTimeStamp();
    $url->addQueryString('y', date('Y', $curStamp));
    $url->addQueryString('m', date('n', $curStamp));
    $url->addQueryString('d', date('j', $curStamp));
    $cur = str_replace('&', '&amp;', $url->getUrl());
    // Gestion de l'affichage des titres des evenements
    if (isset($_GET['ctt']) && $_GET['ctt'] == '1') {
        $url->addQueryString('tt', '0');
        if (isset($_GET['tt']) && $_GET['tt'] == '0') {
            $url->addQueryString('tt', '1');
        }
        $tc_lien = str_replace('&', '&amp;', $url->getUrl());
    } else {
        $url->addQueryString('tt', '0');
        if (isset($_GET['tt']) && $_GET['tt'] == '0') {
            $url->addQueryString('tt', '1');
        }
        $url->addQueryString('ctt', '1');
        $tc_lien = str_replace('&', '&amp;', $url->getUrl());
    }
    $url->removeQueryString('ctt');
    $url->removeQueryString('tt');
    $tc_txt = BAZ_AFFICHE_TITRES_COMPLETS;
    if (isset($_GET['tt']) && $_GET['tt'] == '0') {
        $tc_txt = BAZ_TRONQUER_TITRES;
        $url->addQueryString('tt', $_GET['tt']);
    }
    // Navigation
    $prevStamp = $month->prevMonth(true);
    $url->addQueryString('y', date('Y', $prevStamp));
    $url->addQueryString('m', date('n', $prevStamp));
    $url->addQueryString('d', date('j', $prevStamp));
    $prev = str_replace('&', '&amp;', $url->getUrl());
    $nextStamp = $month->nextMonth(true);
    $url->addQueryString('y', date('Y', $nextStamp));
    $url->addQueryString('m', date('n', $nextStamp));
    $url->addQueryString('d', date('j', $nextStamp));
    $next = str_replace('&', '&amp;', $url->getUrl());
    // Suppression du parametre de troncage des titres
    $url->removeQueryString('tt');
    $fr_month = array("1" => BAZ_JANVIER, "2" => BAZ_FEVRIER, "3" => BAZ_MARS, "4" => BAZ_AVRIL, "5" => BAZ_MAI, "6" => BAZ_JUIN, "7" => BAZ_JUILLET, "8" => BAZ_AOUT, "9" => BAZ_SEPTEMBRE, "10" => BAZ_OCTOBRE, "11" => BAZ_NOVEMBRE, "12" => BAZ_DECEMBRE);
    if ($type == 'calendrier' || $type == 'calendrierjquery' || $type == 'calendrierjquerymini') {
        $retour .= '<div class="cal_entete">' . "\n";
        $retour .= '<span class="cal_navigation">' . "\n";
        $retour .= '<a class="cal_precedent_lien" href="' . $prev . '" title="Allez au mois precedent"><img class="cal_precedent_img" src="' . BAZ_CHEMIN . 'presentation/images/cal_precedent.png" alt="&lt;&lt;"/></a>' . "\n";
        $retour .= '<a class="cal_mois_courrant" href="' . $cur . '">';
        $retour .= $fr_month[date('n', $curStamp)];
        $retour .= '&nbsp;';
        $retour .= date('Y', $curStamp);
        $retour .= '</a>' . "\n";
        $retour .= '<a class="cal_suivant_lien" href="' . $next . '" title="Allez au mois suivant"><img class="cal_suivant_img" src="' . BAZ_CHEMIN . 'presentation/images/cal_suivant.png" alt="&gt;&gt;"/></a>' . "\n";
        $retour .= '</span>' . "\n";
        if ($type == 'calendrier') {
            $retour .= '<span class="tc_lien">' . '<a href="' . $tc_lien . '">' . $tc_txt . '</a>' . '</span>' . "\n";
        }
        $retour .= '</div>' . "\n";
    }
    // Vue Mois calendrier ou vue applette
    if (!isset($_GET['id_fiche']) && ($type == 'calendrier' || $type == 'calendrierjquery' || $type == 'calendrierjquerymini')) {
        // Recherche evenement de la periode selectionnée
        $ts_jour_fin_mois = $month->nextMonth('timestamp');
        $ts_jour_debut_mois = $month->thisMonth('timestamp');
        //on recherche toutes les fiches puis on trie sur ceux qui possede une date
        $tableau_resultat = baz_requete_recherche_fiches('', 'chronologique', $GLOBALS['_BAZAR_']['id_typeannonce'], $GLOBALS['_BAZAR_']['categorie_nature']);
        $tab_fiches = array();
        foreach ($tableau_resultat as $fiche) {
            $valeurs_fiche = json_decode($fiche[0], true);
            $valeurs_fiche = array_map('utf8_decode', $valeurs_fiche);
            //echo $valeurs_fiche['bf_titre'].' du '.$valeurs_fiche['bf_date_debut_evenement'].' au '.$valeurs_fiche['bf_date_fin_evenement'].'<br />';
            //echo 'date fin mois : '.date('Y-n-j', $ts_jour_fin_mois).'<br />';
            //echo 'date debut mois : '.date('Y-n-j', $ts_jour_debut_mois).'<br />';
            if (isset($valeurs_fiche['bf_date_debut_evenement'])) {
                $dateArr = explode("-", $valeurs_fiche['bf_date_debut_evenement']);
                $date1Int = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]);
            } else {
                $date1Int = NULL;
            }
            if (isset($valeurs_fiche['bf_date_fin_evenement'])) {
                $dateArr = explode("-", $valeurs_fiche['bf_date_fin_evenement']);
                $date2Int = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]);
            } else {
                $date2Int = NULL;
            }
            //echo ($date1Int < $ts_jour_fin_mois).' = ($date1Int < $ts_jour_fin_mois)';
            //echo ($date2Int >= $ts_jour_debut_mois).' = ($date2Int >= $ts_jour_debut_mois)';
            if ($date1Int && $date2Int) {
                $tab_fiches[] = $valeurs_fiche;
            }
        }
        $selection = array();
        $evenements = array();
        $annee = date('Y', $curStamp);
        $mois = date('m', $curStamp);
        $tablo_jours = array();
        foreach ($tab_fiches as $val_fiche) {
            list($annee_debut, $mois_debut, $jour_debut) = explode('-', $val_fiche['bf_date_debut_evenement']);
            list($annee_fin, $mois_fin, $jour_fin) = explode('-', $val_fiche['bf_date_fin_evenement']);
            $Calendrier = new Calendar($annee_debut, $mois_debut, $jour_debut);
            $ts_jour_suivant = $Calendrier->thisDay('timestamp');
            $ts_jour_fin = mktime(0, 0, 0, $mois_fin, $jour_fin, $annee_fin);
            $naviguer = true;
            while ($naviguer && $ts_jour_suivant <= $ts_jour_fin) {
                // Si le jours suivant est inferieur a la date de fin du mois courrant, on continue...
                if ($ts_jour_suivant < $ts_jour_fin_mois) {
                    $cle_j = date('Y-m-d', $ts_jour_suivant);
                    if (!isset($tablo_jours[$cle_j])) {
                        $tablo_jours[$cle_j]['Calendar_Day'] = new Calendar_Day(date('Y', $ts_jour_suivant), date('m', $ts_jour_suivant), date('d', $ts_jour_suivant));
                        $tablo_jours[$cle_j]['Diary_Event'] = new DiaryEvent($tablo_jours[$cle_j]['Calendar_Day']);
                    }
                    $tablo_jours[$cle_j]['Diary_Event']->setEntry($val_fiche['bf_titre']);
                    $ts_jour_suivant = $Calendrier->nextDay('timestamp');
                    //echo "ici$ts_jour_suivant-";
                    $Calendrier->setTimestamp($ts_jour_suivant);
                    //echo "la".$Calendrier->thisDay('timestamp')."-";
                } else {
                    $naviguer = false;
                }
            }
        }
        // Add the decorator to the selection
        foreach ($tablo_jours as $jour) {
            $selection[] = $jour['Diary_Event'];
        }
        // Affichage Calendrier
        $month->build($selection);
        $retour .= '<table>' . "\n" . '<colgroup>' . "\n" . '<col class="cal_lundi"/>' . "\n" . '<col class="cal_mardi"/>' . "\n" . '<col class="cal_mercredi"/>' . "\n" . '<col class="cal_jeudi"/>' . "\n" . '<col class="cal_vendredi"/>' . "\n" . '<col class="cal_samedi"/>' . "\n" . '<col class="cal_dimanche"/>' . "\n" . '</colgroup>' . "\n" . '<thead>' . "\n" . "<tr>" . "\n";
        if ($type == 'calendrier' || $type == 'calendrierjquery') {
            $retour .= "<th> " . BAZ_LUNDI . "</th>\n\t\t\t  <th> " . BAZ_MARDI . "</th>\n\t\t\t  <th> " . BAZ_MERCREDI . "</th>\n\t\t\t  <th> " . BAZ_JEUDI . "</th>\n\t\t\t  <th> " . BAZ_VENDREDI . "</th>\n\t\t\t  <th> " . BAZ_SAMEDI . "</th>\n\t\t\t  <th> " . BAZ_DIMANCHE . "</th>\n\t\t\t </tr>\n\t\t\t " . '</thead>' . "\n" . '<tbody>' . "\n";
        } elseif ($type == 'calendrierjquerymini') {
            $retour .= "<th> " . BAZ_LUNDI_COURT . "</th>\n\t\t\t  <th> " . BAZ_MARDI_COURT . "</th>\n\t\t\t  <th> " . BAZ_MERCREDI_COURT . "</th>\n\t\t\t  <th> " . BAZ_JEUDI_COURT . "</th>\n\t\t\t  <th> " . BAZ_VENDREDI_COURT . "</th>\n\t\t\t  <th> " . BAZ_SAMEDI_COURT . "</th>\n\t\t\t  <th> " . BAZ_DIMANCHE_COURT . "</th>\n\t\t\t </tr>\n\t\t\t " . '</thead>' . "\n" . '<tbody>' . "\n";
        }
        $todayStamp = time();
        $today_ymd = date('Ymd', $todayStamp);
        // Other month : mois
        while ($day = $month->fetch()) {
            $dayStamp = $day->thisDay(true);
            $day_ymd = date('Ymd', $dayStamp);
            if ($day->isEmpty()) {
                $class = "cal_autre_mois";
            } else {
                if ($day_ymd < $today_ymd) {
                    $class = "cal_mois_precedent";
                } else {
                    if ($day_ymd == $today_ymd) {
                        $class = "cal_jour_courant";
                    } else {
                        $class = "cal_mois_courant";
                    }
                }
            }
            $url->addQueryString('y', date('Y', $dayStamp));
            $url->addQueryString('m', date('n', $dayStamp));
            $url->addQueryString('d', date('j', $dayStamp));
            $link = $url->getUrl();
            // isFirst() to find start of week
            if ($day->isFirst()) {
                $retour .= "<tr>\n";
            }
            if ($type == 'calendrier') {
                $retour .= "<td class=\"" . $class . "\">" . '<span class="cal_j">' . $day->thisDay() . '</span>' . "\n";
                if ($day->isSelected()) {
                    $evenements = $day->getEntry();
                    $evenements_nbre = count($evenements);
                    $evenemt_xhtml = '';
                    while ($ligne_evenement = array_pop($evenements)) {
                        $id_fiches = $ligne_evenement->bf_id_fiche;
                        $url->addQueryString('id_fiche', $id_fiches);
                        $link = str_replace('&', '&amp;', $url->getUrl());
                        if (!isset($_GET['tt']) || isset($_GET['tt']) && $_GET['tt'] == '1') {
                            $titre_taille = strlen($ligne_evenement->bf_titre);
                            $titre = htmlentities($titre_taille > 40 ? substr($ligne_evenement->bf_titre, 0, 40) . '...' : $ligne_evenement->bf_titre, ENT_QUOTES);
                        } else {
                            $titre = htmlentities($ligne_evenement->bf_titre, ENT_QUOTES);
                        }
                        $evenemt_xhtml .= '<li class="tooltip" title="' . htmlentities($ligne_evenement->bf_titre, ENT_QUOTES) . '"><a class="cal_evenemt" href="' . $link . '">' . $titre . '</a></li>' . "\n";
                        $url->removeQueryString('id_fiches');
                    }
                    if ($evenements_nbre > 0) {
                        $retour .= '<ul class="cal_evenemt_liste">';
                        $retour .= $evenemt_xhtml;
                        $retour .= '</ul>';
                    }
                }
            } elseif ($type == 'calendrierjquery' || $type == 'calendrierjquerymini') {
                if ($day->isSelected()) {
                    $evenements = $day->getEntry();
                    $evenements_nbre = count($evenements);
                    $evenemt_xhtml = '';
                    while ($ligne_evenement = array_pop($evenements)) {
                        $id_fiches = $ligne_evenement->bf_id_fiche;
                        $url->addQueryString('id_fiche', $id_fiches);
                        $link = str_replace('&', '&amp;', $url->getUrl());
                        $titre = htmlentities($ligne_evenement->bf_titre, ENT_QUOTES);
                        $evenemt_xhtml .= '<li>
						<span class="titre_evenement"><a class="cal_evenemt" href="' . $link . '">' . $titre . '</a></span>
						</li>';
                        $url->removeQueryString('id_fiches');
                    }
                    if ($evenements_nbre > 0) {
                        $retour .= '<td class="' . $class . ' date_avec_evenements">' . $day->thisDay() . '
						<div class="evenements">						
						<ul>';
                        $retour .= $evenemt_xhtml;
                        $retour .= '</ul>
						</div>';
                    } else {
                        $retour .= '<td class="' . $class . '">' . $day->thisDay() . "\n";
                    }
                } else {
                    $retour .= '<td class="' . $class . '">' . $day->thisDay() . "\n";
                }
            } elseif ($type == 'calendriermini') {
                $lien_date = "<td class=\"" . $class . "\">" . $day->thisDay();
                if ($day->isSelected()) {
                    $evenements = $day->getEntry();
                    $id_fiches = array();
                    while ($ligne_evenement = array_pop($evenements)) {
                        $id_fiches[] = $ligne_evenement->bf_id_fiche;
                    }
                    $url->addQueryString('id_fiches', $id_fiches);
                    $link = str_replace('&', '&amp;', $url->getUrl());
                    $lien_date = "<td class=\"" . $class . "\"><a href=\"" . $link . "\">" . $day->thisDay() . "</a>\n";
                    $url->removeQueryString('id_fiches');
                }
                $retour .= $lien_date;
            }
            $retour .= "</td>\n";
            // isLast() to find end of week
            if ($day->isLast()) {
                $retour .= "</tr>\n";
            }
        }
        $retour .= "</tbody></table>";
    }
    // Vue detail
    if (isset($_GET['id_fiche'])) {
        // Ajout d'un titre pour la page avec la date
        $jours = array('lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche');
        $mois = array('janvier', 'f&eacute;vrier', 'mars', 'avril', 'mai', 'juin', 'juillet', 'ao&ucirc;t', 'septembre', 'octobre', 'novembre', 'd&eacute;cembre');
        $timestamp = strtotime($_GET['y'] . '/' . $_GET['m'] . '/' . $_GET['d']);
        $retour .= '<h1>' . $jours[date('w', $timestamp) - 1] . ' ' . $_GET['d'] . ' ' . $mois[$_GET['m'] - 1] . ' ' . $_GET['y'] . '</h1>';
        $retour .= baz_voir_fiche(0, $_GET['id_fiche']);
        // Un lien pour retourner au calendrier
        $url->removeQueryString('id_fiche');
        $url->removeQueryString('y');
        $url->removeQueryString('m');
        $url->removeQueryString('d');
        $url->addQueryString('y', $_GET['y']);
        $url->addQueryString('m', $_GET['m']);
        $url->addQueryString('d', $_GET['d']);
        $retour .= '<div class="retour"><a href="' . str_replace('&', '&amp;', $url->getUrl()) . '">Retour au calendrier</a></div>';
    }
    // Nettoyage de l'url
    $url->removeQueryString('id_fiche');
    $url->removeQueryString('y');
    $url->removeQueryString('m');
    $url->removeQueryString('d');
    return $retour . "\n" . '</div>' . "\n";
}
/**
 * Print a tabular calendar for selecting dates for appointments
 * Based on code from the PEAR package
 *
 * @link http://pear.php.net/package/Calendar PEAR Calendar
 * @link http://pearcalendar.sourceforge.net/examples/3.php Example this code based on
 *
 * @see make_appointment()
 * @see display_time()
 *
 * @param int $respondent_id The respondent id
 * @param int $questionnaire_id The questionnaire id
 * @param bool|int $day the day of the month if selected else false
 * @param bool|int $month the month of the year if selected else false
 * @param bool|int $year the year (4 digit) if selected else false
 *
 */
function display_calendar($respondent_id, $questionnaire_id, $year = false, $month = false, $day = false)
{
    global $db;
    /**
     * PEAR Caldendar Weekday functions
     */
    include_once 'Calendar/Month/Weekdays.php';
    /**
     * PEAR Caldendar Day functions
     */
    include_once 'Calendar/Day.php';
    /**
     * See if questionnaire has shift restrictions
     */
    $restricted = is_shift_restricted($questionnaire_id);
    $rtime = strtotime(get_respondent_time($respondent_id));
    $y = date('Y', $rtime);
    $m = date('m', $rtime);
    $d = date('d', $rtime);
    if (!$year) {
        $year = $y;
    }
    if (!$month) {
        $month = $m;
    }
    if (!$day) {
        $day = $d;
    }
    $ttoday = new Calendar_Day($y, $m, $d);
    $Month = new Calendar_Month_Weekdays($year, $month);
    // Construct strings for next/previous links
    $PMonth = $Month->prevMonth('object');
    // Get previous month as object
    $prev = '?y=' . $PMonth->thisYear() . '&amp;m=' . $PMonth->thisMonth() . '&amp;d=' . $PMonth->thisDay() . '&amp;respondent_id=' . $respondent_id;
    $NMonth = $Month->nextMonth('object');
    $next = '?y=' . $NMonth->thisYear() . '&amp;m=' . $NMonth->thisMonth() . '&amp;d=' . $NMonth->thisDay() . '&amp;respondent_id=' . $respondent_id;
    // Build the days in the month
    $Month->build();
    print "<table class=\"calendar table-hover table-condensed text-center\">";
    print "<caption class=\"text-center text-primary\"><b>" . T_(date('F Y', $Month->getTimeStamp())) . "</b></caption>\r\n\t\t\t\t<thead style=\"font-weight: bolder;\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Mon") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Tue") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Wed") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Thu") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Fri") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Sat") . "</td>\r\n\t\t\t\t\t<td style=\"width: 50px;\">" . T_("Sun") . "</td>\r\n\t\t\t\t</tr></thead>";
    while ($Day = $Month->fetch()) {
        // Build a link string for each day
        $link = '?y=' . $Day->thisYear() . '&amp;m=' . $Day->thisMonth() . '&amp;d=' . $Day->thisDay() . '&amp;respondent_id=' . $respondent_id;
        $today = "";
        if ($year == $Day->thisYear() && $month == $Day->thisMonth() && $day == $Day->thisDay()) {
            $today = "today";
        }
        // isFirst() to find start of week
        if ($Day->isFirst()) {
            echo "<tr>\n";
        }
        if ($Day->isSelected()) {
            echo "<td class=\"selected {$today}\">" . $Day->thisDay() . "</td>\n";
        } else {
            if ($Day->isEmpty()) {
                echo "<td>&nbsp;</td>\n";
            } else {
                //if it is in the past -> unavailable
                if ($Day->getTimeStamp() < $ttoday->getTimeStamp()) {
                    echo "<td style=\"color:grey;\" class=\"notavailable\">" . $Day->thisDay() . "</td>\n";
                } else {
                    if ($restricted) {
                        $rs = $db->Execute("    SELECT s.shift_id\r\n\t\t\t\t\t\tFROM shift as s\r\n\t\t\t\t\t\tLEFT JOIN respondent as r on (r.respondent_id = '{$respondent_id}')\r\n\t\t\t\t\t\tWHERE s.questionnaire_id = '{$questionnaire_id}'\r\n\t\t\t\t\t\tAND DAY(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisDay()}'\r\n\t\t\t\t\t\tAND MONTH(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisMonth()}'\r\n\t\t\t\t\t\tAND YEAR(CONVERT_TZ(s.start,'UTC',r.Time_zone_name)) = '{$Day->thisYear()}'");
                        if (!empty($rs) && $rs->RecordCount() == 0) {
                            echo "<td style=\"color:grey;\" class=\"notavailable {$today}\">" . $Day->thisDay() . "</td>\n";
                        } else {
                            echo "<td class=\"{$today}\"><a class=\"btn-primary btn-block \" href=\"" . $link . "\"><b>" . $Day->thisDay() . "</b></a></td>\n";
                        }
                    } else {
                        echo "<td class=\"{$today}\"><a class=\"btn-primary btn-block \" href=\"" . $link . "\"><b>" . $Day->thisDay() . "</b></a></td>\n";
                    }
                }
            }
        }
        // isLast() to find end of week
        if ($Day->isLast()) {
            echo "</tr>\n";
        }
    }
    ?>
	<tr>
	<td>
	<a href="<?php 
    echo $prev;
    ?>
" class="prevMonth btn btn-default">&lt;&lt; </a>
	</td>
	<td colspan="5"><?php 
    print "<b class=\"text-primary\">" . date('l j F Y', mktime(0, 0, 0, $month, $day, $year)) . "</b>";
    ?>
</td>
	<td>
	<a href="<?php 
    echo $next;
    ?>
" class="nextMonth btn btn-default"> &gt;&gt;</a>
	</td>
	</tr>
	</table>
	<?php 
}