} </style> </head> <body> <?php $selectedDays = array(new Calendar_Day($_GET['y'], $_GET['m'], $_GET['d']), new Calendar_Day($_GET['y'], 12, 25)); // Build the days in the month $Month->build($selectedDays); ?> <h2>Built with Calendar_Month_Weekday::build()</h2> <table class="calendar"> <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();
$Month = new Calendar_Month($_GET['y'], $_GET['m']); $selection = array($Month); $Year->build($selection); $month_array = array(); $m = 0; while ($Child = $Year->fetch()) { $month_array[$m]['option'] = $Child->thisMonth(); if ($Child->isSelected()) { $month_array[$m]['selected'] = "selected"; } $m++; } //megmutatjuk a kivalasztott napra szolo esemenyeket, ha nincs kivalasztott, akkor a mai napit $query .= "\n\t\tWHERE DATE_FORMAT(start_date, '%Y-%m-%d') = DATE_FORMAT('" . $_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'] . "', '%Y-%m-%d') OR \n\t\t\tDATE_FORMAT(end_date, '%Y-%m-%d') = DATE_FORMAT('" . $_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'] . "', '%Y-%m-%d') OR \n\t\t\t(DATE_FORMAT(start_date, '%Y-%m-%d') <= DATE_FORMAT('" . $_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'] . "', '%Y-%m-%d') AND \n\t\t\tDATE_FORMAT(end_date, '%Y-%m-%d') >= DATE_FORMAT('" . $_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'] . "', '%Y-%m-%d')) \n\t\tORDER BY is_major DESC, start_date, end_date\n\t"; $result = $mdb2->query($query); $today_event = $result->fetchAll(); $fyear = date('Y', $month->getTimeStamp()); $fmonth = date('m', $month->getTimeStamp()); $monthName = date('Y F', $month->getTimeStamp()); $today = date('Y-m-d', strtotime($_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'])); $tpl->assign_by_ref('month', $weeksInMonth); $tpl->assign('fyear', $fyear); $tpl->assign('fmonth', $fmonth); $tpl->assign('monthName', $monthName); $tpl->assign('prevMonth', $prev); $tpl->assign('nextMonth', $next); $tpl->assign('today_event', $today_event); $tpl->assign('cal_today', $today); $tpl->assign('month_array', $month_array); $acttpl = "calendar"; }
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().'&Month='.$PMonth->thisMonth().'&Day='.$PMonth->thisDay(); $NMonth = $Month->nextMonth('object'); $next = '?Year='.$NMonth->thisYear().'&Month='.$NMonth->thisMonth().'&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(). '&Month='.$Day->thisMonth(). '&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> </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)." ".($params['btn_img']?"<input name=\"btnsubmit\" type=\"image\" src=\"".$params['btn_img']."\"/>":"<input name=\"btnsubmit\" type=\"submit\" value=\"Ir\" />").($params['today_btn']===true?" <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; }
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('&', $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('&', '&', $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('&', '&', $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('&', '&', $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('&', '&', $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('&', '&', $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="<<"/></a>' . "\n"; $retour .= '<a class="cal_mois_courrant" href="' . $cur . '">'; $retour .= $fr_month[date('n', $curStamp)]; $retour .= ' '; $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=">>"/></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('&', '&', $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('&', '&', $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('&', '&', $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évrier', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'dé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('&', '&', $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"; }
$Year->build($selection); $month_array = array(); $m = 0; while ($Child = $Year->fetch()) { $month_array[$m]['option'] = $Child->thisMonth(); if ($Child->isSelected()) { $month_array[$m]['selected'] = "selected"; } $m++; } //megmutatjuk a kivalasztott napra szolo esemenyeket, ha nincs kivalasztott, akkor a mai napit $query .= "\n\t\tWHERE DATE_FORMAT(start_date, '%Y-%m-%d') = DATE_FORMAT('" . $_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'] . "', '%Y-%m-%d') OR\n\t\t\tDATE_FORMAT(end_date, '%Y-%m-%d') = DATE_FORMAT('" . $_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'] . "', '%Y-%m-%d') OR\n\t\t\t(DATE_FORMAT(start_date, '%Y-%m-%d') <= DATE_FORMAT('" . $_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'] . "', '%Y-%m-%d') AND\n\t\t\tDATE_FORMAT(end_date, '%Y-%m-%d') >= DATE_FORMAT('" . $_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'] . "', '%Y-%m-%d'))\n\t\tORDER BY is_major DESC, start_date, end_date\n\t"; $result = $mdb2->query($query); $today_event = $result->fetchAll(); $add_new = array(array('link' => 'admin.php?p=' . $module_name . '&act=' . $page . '&sub_act=add&y=' . $_GET['y'] . '&m=' . $_GET['m'] . '&d=' . $_GET['d'], 'title' => $locale->get('title_add'), 'pic' => 'add.jpg')); $fyear = date('Y', $month->getTimeStamp()); $fmonth = date('m', $month->getTimeStamp()); $monthName = get_date(date('Y-m-d', $month->getTimeStamp()), 'year_month'); //print $dtum; $today = date('Y-m-d', strtotime($_GET['y'] . "-" . $_GET['m'] . "-" . $_GET['d'])); $tpl->assign_by_ref('month', $weeksInMonth); $tpl->assign('fyear', $fyear); $tpl->assign('fmonth', $fmonth); $tpl->assign('monthName', $monthName); $tpl->assign('prevMonth', $prev); $tpl->assign('nextMonth', $next); $tpl->assign('today_event', $today_event); $tpl->assign('today', $today); $tpl->assign('month_array', $month_array); $tpl->assign('add_new', $add_new); $tpl->assign('back_arrow', 'admin.php');
/** * 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() . '&m=' . $PMonth->thisMonth() . '&d=' . $PMonth->thisDay() . '&respondent_id=' . $respondent_id; $NMonth = $Month->nextMonth('object'); $next = '?y=' . $NMonth->thisYear() . '&m=' . $NMonth->thisMonth() . '&d=' . $NMonth->thisDay() . '&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() . '&m=' . $Day->thisMonth() . '&d=' . $Day->thisDay() . '&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> </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"><< </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"> >></a> </td> </tr> </table> <?php }