function calendar__display_calendar($admin = false) { global $lang, $color, $settings; $displayfrom = time(); if (isset($_REQUEST['displayfrom'])) { $displayfrom = $_REQUEST['displayfrom']; } $wholeyear = false; if (isset($_REQUEST['wholeyear']) && $admin) { $wholeyear = true; } //$monthsum format: years x 12 + months $calendar_month_font = "white"; if (isset($color['calendar_month_font'])) { $calendar_month_font = $color['calendar_month_font']; } $calendar_day_background = "white"; if (isset($color['calendar_day_background'])) { $calendar_day_background = $color['calendar_day_background']; } $calendar_month_background = "black"; if (isset($color['calendar_month_background'])) { $calendar_month_background = $color['calendar_month_background']; } echo ' <style> #calendarContainer { width: 90%; margin-left: auto; margin-right: auto; } .calendarTable { border: 0px; border-collapse: separate; } /* head of calendar */ .calendarTable thead { background: ' . $calendar_month_background . '; color: ' . $calendar_month_font . '; } .calendarTable>thead>tr>th { border: 0; border-bottom: 3px solid #E2E2E2; height: 20px; text-align: right; font-weight: 600; padding: 0px 10px 0px 0px; } .calendarTable>thead>tr>th.monthTag{ font-size: 13pt; height: 30px; } /* round corners */ .calendarTable>thead>tr:first-child>th:only-child { -moz-border-radius: 10px 10px 0px 0px; -webkit-border-radius: 10px 10px 0px 0px; border-radius: 10px 10px 0px 0px; } /* calendar rows and cells*/ .calendarTable>tbody>tr { } .calendarTable>tbody>tr>td { border: 1px solid #C5C5C5; padding: 0; margin: 0; height: 100px; min-width: 3%; width: 3%; max-width: 30%; text-align: left; vertical-align: top; } .calendarTable>tbody>tr .calendarCellRealDate{ border: 2px solid #C5C5C5; } .calendarTable>tbody>tr>td .calendarCellHead { padding: 0; padding-left: 3px; padding-right: 10px; margin: 0; background: ' . $calendar_day_background . '; text-align: right; height: 17px; font-weight: bold; } .calendarTable>tbody>tr>td .calendarCellContent { padding: 0; padding-top: 3px; padding-bottom: 3px; padding-left: 6px; padding-right: 15px; position: relative; margin-left: 5px; margin-right: 5px; margin-top: 3px; margin-bottom: 3px; -moz-border-radius: 5px 20px 5px 5px; -webkit-border-radius: 5px 20px 5px 5px; border-radius: 5px 20px 5px 5px; } .calendarTable>tbody>tr>td .calendarCellContent .calendarCellContentTitle { display: block; } .calendarTable>tbody>tr>td .calendarCellContent span { display: block; } /* round corners */ .calendarTable>tbody>tr:last-child>td:first-child { -moz-border-radius: 0px 0px 0px 10px; -webkit-border-radius: 0px 0px 0px 10px; border-radius: 0px 0px 0px 10px; } .calendarTable>tbody>tr:last-child>td:last-child { -moz-border-radius: 0px 0px 10px 0px; -webkit-border-radius: 0px 0px 10px 0px; border-radius: 0px 0px 10px 0px; } /* highlight today cell */ .calendarTable>tbody>tr>td.today { border: 2px solid #F00; } </style> '; $statusdata = array("not_enough_participants" => array("color" => $admin ? $color['session_not_enough_participants'] : $color['session_public_free_places'], "message" => $admin ? $lang["not_enough_participants"] : lang('free_places')), "not_enough_reserve" => array("color" => $admin ? $color['session_not_enough_reserve'] : $color['session_public_free_places'], "message" => $admin ? $lang["not_enough_reserve"] : lang('free_places')), "complete" => array("color" => $admin ? $color['session_complete'] : $color['session_public_complete'], "message" => $lang["complete"])); echo '<div id="calendarContainer">'; //start building calendar $displayfrom_lower = $displayfrom; $displayfrom_upper = date__skip_months(1, $displayfrom_lower); if ($wholeyear && $admin) { $displayfrom_upper = mktime(0, 0, 0, 1, 1, date('Y', $displayfrom) + 1); } $results = calendar__get_events($admin, $displayfrom_lower, $displayfrom_upper, false, true); $buttons1 = ""; $buttons2 = ""; if ($admin) { $buttons1 .= "<TABLE border=0 width=100%>"; $buttons1 .= '<TR>'; if ($wholeyear) { $buttons1 .= '<TD align="left">' . button_link("?", lang('current_month'), '', 'font-size: 8pt;') . '</TD>'; } else { $buttons1 .= '<TD align="left">' . button_link("?wholeyear=true&displayfrom=" . mktime(0, 0, 0, 1, 1, date('Y', $displayfrom)), lang('whole_year'), '', 'font-size: 8pt;') . '</TD>'; } $buttons1 .= '<TD align="center">' . button_link('events_edit.php', lang('create_event'), 'plus-circle') . '<BR> <FONT class="small">' . lang('for_session_time_reservation_please_use_experiments') . '</FONT></TD>'; $buttons1 .= '<TD align="right">' . button_link('calendar_main_print_pdf.php?displayfrom=' . $displayfrom . '&wholeyear=' . $wholeyear, lang('print_version'), 'print', 'font-size: 8pt;', 'target="_blank"') . '</TD>'; $buttons1 .= '</TR></TABLE>'; } $buttons2 .= '<TABLE width="100%"><TR><TD colspan=3 align="left">'; $buttons2 .= button_link("?displayfrom=" . date__skip_months(-1, $displayfrom), strtoupper(lang('previous')), 'caret-square-o-up', 'font-size: 8pt;'); $buttons2 .= '</TD><TD colspan=4 align="right">'; $buttons2 .= button_link("?displayfrom=" . date__skip_months(1, $displayfrom), strtoupper(lang('next')), 'caret-square-o-down', 'font-size: 8pt;'); $buttons2 .= '</TD></TR></TABLE><BR>'; echo $buttons1; echo $buttons2; $month_names = explode(",", $lang['month_names']); //loop through each month for ($itime = $displayfrom_lower; $itime <= $displayfrom_upper; $itime = date__skip_months(1, $itime)) { $year = date("Y", $itime); $month = date("m", $itime); $weeks = days_in_month($month, $year); echo '<TABLE class="calendarTable" WIDTH="100%">'; echo '<thead><tr>'; echo '<th colspan="7" class="monthTag"><center>' . $month_names[$month - 1] . ' ' . $year . '</center></td></tr><tr>'; $calendar__weekdays = explode(",", $lang['format_datetime_weekday_abbr']); for ($i3 = 1; $i3 <= 7; ++$i3) { if (!isset($lang['format_datetime_firstdayofweek_0:Su_1:Mo']) || !$lang['format_datetime_firstdayofweek_0:Su_1:Mo']) { $wdindex = $i3 - 1; } else { $wdindex = $i3; if ($wdindex == 7) { $wdindex = 0; } } echo '<th>' . $calendar__weekdays[$wdindex] . '</th>'; } echo '</tr></thead>'; echo '<tbody>'; for ($i2 = 1; $i2 <= count($weeks); ++$i2) { echo '<tr>'; for ($i3 = 1; $i3 <= 7; ++$i3) { if (isset($weeks[$i2][$i3])) { //the date is the key of the $results array for easy searching $today = $year * 10000 + $month * 100 + $weeks[$i2][$i3]; $realtoday = date("Y") * 10000 + date("m") * 100 + date("d"); echo '<td class="calendarCellRealDate'; if ($today == $realtoday) { echo ' today'; } echo '">'; echo '<div class="calendarCellHead">'; echo $weeks[$i2][$i3]; echo '</div>'; if (isset($results[$today])) { foreach ($results[$today] as $item) { $title = $item['title']; if (isset($item['title_link'])) { $title = '<a href="' . $item['title_link'] . '">' . $title . '</a>'; } echo '<div style="background: ' . $item['color'] . ';" class="calendarCellContent">'; echo '<span style="font-weight: bold;">'; echo $item['display_time']; echo '</span>'; echo '<span style="font-size: 11;">'; echo $item['location']; echo '</span>'; if ($admin || $settings['public_calendar_hide_exp_name'] != 'y') { echo '<div class="calendarCellContentTitle">' . $title . '</div>'; } else { echo '<div class="calendarCellContentTitle">' . lang('calendar_experiment_session') . '</div>'; } if ($admin) { echo '<span style="font-size: 11;">'; echo experiment__list_experimenters($item['experimenters'], true, true); echo '</span>'; } if ($item['type'] == "location_reserved") { echo '<span>'; if (check_allow('events_edit')) { echo '<a style="font-size: 11;" href="' . $item['edit_link'] . '">[' . lang('edit') . ']</a>'; } echo '</span>'; } elseif ($item['type'] == "experiment_session") { echo '<span style="color: ' . $statusdata[$item['status']]['color'] . ';">'; if ($admin) { echo " " . $item['participants_registered'] . " (" . $item['participants_needed'] . "," . $item['participants_reserve'] . ")"; } else { echo $statusdata[$item['status']]['message']; } echo '</span>'; if ($admin && check_allow('experiment_show_participants')) { echo '<span>'; echo '<a style="font-size: 11;" href="' . $item['participants_link'] . '">[' . lang('participants') . ']</a>'; echo '</span>'; } } echo '</div>'; } } } else { echo '<td> '; } echo '</td>'; } echo '</tr>'; } echo '</tbody></TABLE><br /><br /><br />'; } echo $buttons2; //echo $buttons1; echo '</div>'; }
function pdfoutput__make_pdf_calendar($displayfrom = 0, $wholeyear = false, $admin = false, $forward = 0, $file = false) { global $settings, $lang; if ($displayfrom == 0) { $displayfrom = time(); } // prepare pdf include_once '../tagsets/class.ezpdf.php'; $pdf = new Cezpdf('a4'); $pdf->selectFont('../tagsets/fonts/Times-Roman.afm'); $fontsize = $settings['calendar_pdf_table_fontsize'] ? $settings['calendar_pdf_table_fontsize'] : 8; $titlefontsize = $settings['calendar_pdf_title_fontsize'] ? $settings['calendar_pdf_title_fontsize'] : 12; //start building calendar $displayfrom_lower = $displayfrom; $displayfrom_upper = date__skip_months($forward, $displayfrom_lower); if ($wholeyear) { $displayfrom_upper = mktime(0, 0, 0, 1, 1, date('Y', $displayfrom) + 1); } $results = calendar__get_events($admin, $displayfrom_lower, $displayfrom_upper, false, true); $month_names = explode(",", $lang['month_names']); //loop through each month for ($itime = $displayfrom_lower; $itime <= $displayfrom_upper; $itime = date__skip_months(1, $itime)) { $year = date("Y", $itime); $month = date("m", $itime); $weeks = days_in_month($month, $year); $table_title = $month_names[$month - 1] . ' ' . $year; $table_headings = array(); $calendar__weekdays = explode(",", $lang['format_datetime_weekday_abbr']); for ($i3 = 1; $i3 <= 7; ++$i3) { if (!isset($lang['format_datetime_firstdayofweek_0:Su_1:Mo']) || !$lang['format_datetime_firstdayofweek_0:Su_1:Mo']) { $wdindex = $i3 - 2; if ($wdindex < 0) { $wdindex = 6; } } else { $wdindex = $i3 - 1; } $table_headings[$i3] = $calendar__weekdays[$wdindex]; } $table_data = array(); for ($i2 = 1; $i2 <= count($weeks); ++$i2) { $las1 = array(); $las2 = array(); for ($i3 = 1; $i3 <= 7; ++$i3) { if (!isset($weeks[$i2][$i3])) { $las1[$i3] = ""; $las2[$i3] = ""; } else { $las1[$i3] = $weeks[$i2][$i3]; $las2[$i3] = ""; //the date is the key of the $results array for easy searching $today = $year * 10000 + $month * 100 + $weeks[$i2][$i3]; if (isset($results[$today])) { foreach ($results[$today] as $item) { $las2[$i3] .= $item['display_time']; $las2[$i3] .= "\n" . "<i>" . $item['location'] . "</i>\n"; if ($admin || $settings['public_calendar_hide_exp_name'] != 'y') { $las2[$i3] .= '<b>' . $item['title'] . '</b>'; } else { $las2[$i3] .= '<b>' . $lang['calendar_experiment_session'] . '</b>'; } $las2[$i3] .= "\n"; if ($admin) { $las2[$i3] .= experiment__list_experimenters($item['experimenters'], false, true) . "\n"; } if ($item['type'] == "experiment_session") { if ($admin) { $las2[$i3] .= $item['participants_registered'] . " (" . $item['participants_needed'] . "," . $item['participants_reserve'] . ")"; } else { $las2[$i3] .= $statusdata[$item['status']]['message']; } } $las2[$i3] .= "\n\n"; } } } } $table_data[] = $las1; $table_data[] = $las2; } $y = $pdf->ezTable($table_data, $table_headings, $table_title, array('gridlines' => 31, 'showHeadings' => 1, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.9, 0.9, 1), 'fontSize' => $fontsize, 'titleFontSize' => $titlefontsize, 'rowGap' => 1, 'colGap' => 3, 'innerLineThickness' => 0.5, 'outerLineThickness' => 1, 'maxWidth' => 500, 'width' => 500, 'protectRows' => 2)); $pdf->ezSetDy(-20); } if ($file) { $pdffilecode = $pdf->output(); return $pdffilecode; //$fname ="/apache/orsee/admin/pdfdir/test.pdf"; //$fp = fopen($fname,'w'); //fwrite($fp,$pdffilecode); //fclose($fp); //echo '<A HREF="pdfdir/test.pdf" target="_blank">pdf file</A><BR><BR>'; //$pdfcode = str_replace("\n","\n<br>",htmlspecialchars($pdfcode)); //echo trim($pdfcode); } else { $pdf->ezStream(array('Content-Disposition' => 'calendar.pdf', 'Accept-Ranges' => 0, 'compress' => 1)); } }