282 lines
11 KiB
PHP
282 lines
11 KiB
PHP
<?php
|
|
|
|
// Copyright (C) 2002-2006 Balint Kis (balint@k-i-s.net)
|
|
// Copyright (C) 2005-2013 Solomon Peachy (pizza@shaftnet.org)
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation; either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
include_once "include/config.php";
|
|
include_once "include/site.php";
|
|
include_once "include/datebook.php";
|
|
include_once "include/common.php";
|
|
include_once "include/contacts.php";
|
|
|
|
$showcounts = TRUE;
|
|
|
|
$database = site_prolog(PO_USER_TYPE_CLIENT);
|
|
$auth_handle = new $po_auth();
|
|
|
|
$calendar_view = isset($_REQUEST['view']) ? $_REQUEST['view'] : 1;
|
|
$calendar_year = (int) isset($_REQUEST['year']) ? $_REQUEST['year'] : FALSE;
|
|
$calendar_month = (int) isset($_REQUEST['month']) ? $_REQUEST['month'] : FALSE;
|
|
$calendar_day = (int) isset($_REQUEST['day']) ? $_REQUEST['day'] : FALSE;
|
|
|
|
site_header($strings['generic_my_datebook']);
|
|
site_navigator(8);
|
|
site_navigator_status(emit_a(generate_link('user', ''), $strings['generic_users'])." : ".$strings['generic_my_datebook'], "");
|
|
|
|
print "<br/>";
|
|
|
|
print "<div class=\"navigatorf\">";
|
|
print "<ul>";
|
|
|
|
$day_in_month = getDaysInMonth($calendar_year, $calendar_month);
|
|
if ($calendar_day === FALSE || $calendar_day < 1 || $calendar_day > $day_in_month) {
|
|
$today = getdate(time());
|
|
$calendar_day = $today["mday"];
|
|
}
|
|
if ($calendar_month === FALSE || $calendar_month < 1 || $calendar_month > 12) {
|
|
$today = getdate(time());
|
|
$calendar_month = $today["mon"];
|
|
}
|
|
if ($calendar_year === FALSE) {
|
|
$today = getdate(time());
|
|
$calendar_year = $today["year"];
|
|
}
|
|
|
|
$calendar_week = getWeekNumber($calendar_year, $calendar_month, $calendar_day, $po_options['start_day']);
|
|
if ($calendar_week=="") {
|
|
$today = getdate(time());
|
|
$calendar_week = getWeekNumber($calendar_year, $today["mon"], $today["mday"], $po_options['start_day']);
|
|
}
|
|
|
|
if ($calendar_view == "" || $calendar_view == 1) {
|
|
$here = "class=\"menu_here\" ";
|
|
} else {
|
|
$here = "";
|
|
}
|
|
print "<li $here><a $here href=\"my.datebook.php?view=1&year=$calendar_year&month=$calendar_month&day=$calendar_day\">".$strings['datebook_day']."</a></li>";
|
|
|
|
$week = getWeekNumber($calendar_year, $calendar_month, $calendar_day, $po_options['start_day']);
|
|
if ($calendar_view == 2) {
|
|
$here = "class=\"menu_here\" ";
|
|
} else {
|
|
$here = "";
|
|
}
|
|
print "<li $here><a $here href=\"my.datebook.php?view=2&year=$calendar_year&month=$calendar_month&day=$calendar_day\">".$strings['datebook_week']."</a></li>";
|
|
if ($calendar_view == 3) {
|
|
$here = "class=\"menu_here\" ";
|
|
} else {
|
|
$here = "";
|
|
}
|
|
print "<li $here><a $here href=\"my.datebook.php?view=3&year=$calendar_year&month=$calendar_month&day=$calendar_day\">".$strings['datebook_month']."</a></li>";
|
|
if ($calendar_view == 4) {
|
|
$here = "class=\"menu_here\" ";
|
|
} else {
|
|
$here = "";
|
|
}
|
|
print "<li $here><a $here href=\"my.datebook.php?view=4&year=$calendar_year&month=$calendar_month&day=$calendar_day\">".$strings['datebook_goto']."</a></li>";
|
|
|
|
// get correct YMD.
|
|
{
|
|
$today = getdate(time());
|
|
$day = $today["mday"];
|
|
$month = $today["mon"];
|
|
$year = $today["year"];
|
|
|
|
print "<li><a href=\"my.datebook.php?view=1&year=$year&month=$month&day=$day\">".$strings['datebook_today']."</a></li>";
|
|
print "<li><a href=\"my.datebook.php?view=2&year=$year&month=$month&day=$day\">".$strings['datebook_this_week']."</a></li>";
|
|
print "<li><a href=\"my.datebook.php?view=3&year=$year&month=$month&day=$day\">".$strings['datebook_this_month']."</a></li>";
|
|
}
|
|
|
|
print "</ul>";
|
|
print "</div>";
|
|
|
|
switch ($calendar_view) {
|
|
default:
|
|
case 1:
|
|
displayDayHTML($database, $po_user['id'], $calendar_year, $calendar_month, $calendar_day, $po_options['start_hour'], $po_options['end_hour'], $showcounts);
|
|
|
|
$timestamp = mktime(12, 0, 0, $calendar_month, $calendar_day, $calendar_year);
|
|
$date = getdate($timestamp);
|
|
$dayNameIndex = $date["wday"];
|
|
|
|
print "<div class=\"photo_nav\">";
|
|
$yesterday = adjustDay($calendar_year, $calendar_month, $calendar_day - 1);
|
|
|
|
print sprintf($thm_elem['button.previous'], "my.datebook.php?view=1&year=$yesterday[0]&month=$yesterday[1]&day=$yesterday[2]", $strings['generic_day'], "");
|
|
|
|
print "<b> $dayNames[$dayNameIndex] ".date($strings['formats_date'], $timestamp)." </b>";
|
|
$tomorrow = adjustDay($calendar_year, $calendar_month, $calendar_day + 1);
|
|
print sprintf($thm_elem['button.next'], "my.datebook.php?view=1&year=$tomorrow[0]&month=$tomorrow[1]&day=$tomorrow[2]", $strings['generic_day'], "");
|
|
|
|
print "</div>";
|
|
|
|
break;
|
|
case 2:
|
|
|
|
displayWeekHTML($database, $po_user['id'], $calendar_year, $calendar_week, $dayNames, $po_options['start_day'], $showcounts);
|
|
|
|
$firstDayOfWeek = getFirstDayOfWeek($calendar_year, $calendar_week, $po_options['start_day']);
|
|
$lastDayOfWeek = adjustDay($firstDayOfWeek[0], $firstDayOfWeek[1], $firstDayOfWeek[2]+7);
|
|
|
|
$month1 = $firstDayOfWeek[1];
|
|
$month2 = $lastDayOfWeek[1];
|
|
|
|
print "<div class=\"photo_nav\">";
|
|
$prev_week = adjustDay($calendar_year, $calendar_month, $calendar_day - 7);
|
|
print sprintf($thm_elem['button.previous'], "my.datebook.php?view=2&year=$prev_week[0]&month=$prev_week[1]&day=$prev_week[2]", $strings['generic_week'], "");
|
|
if ($firstDayOfWeek[0] != $lastDayOfWeek[0])
|
|
print "<b> ".$strings['datebook_week2']." $calendar_week, $monthNames[$month1] $firstDayOfWeek[0] - $monthNames[$month2] $lastDayOfWeek[0] </b>";
|
|
else {
|
|
if ($firstDayOfWeek[1] != $lastDayOfWeek[1])
|
|
print "<b> ".$strings['datebook_week2']." $calendar_week, $monthNames[$month1] - $monthNames[$month2] $lastDayOfWeek[0] </b>";
|
|
else
|
|
print "<b> ".$strings['datebook_week2']." $calendar_week, $monthNames[$month2] $lastDayOfWeek[0] </b>";
|
|
}
|
|
$next_week = adjustDay($calendar_year, $calendar_month, $calendar_day + 7);
|
|
print sprintf($thm_elem['button.next'], "my.datebook.php?view=2&year=$next_week[0]&month=$next_week[1]&day=$next_week[2]", $strings['generic_week'], "");
|
|
print "</div>";
|
|
|
|
break;
|
|
case 3:
|
|
if ($calendar_month=="" || $calendar_year=="") {
|
|
$today = getdate(time());
|
|
$calendar_year = $today["year"];
|
|
$calendar_month = $today["mon"];
|
|
}
|
|
|
|
displayMonthHTML($database, $po_user['id'], $calendar_year, $calendar_month, $dayNames, $po_options['start_day'], $showcounts);
|
|
|
|
print "<div class=\"photo_nav\">";
|
|
$next_month = adjustMonth($calendar_year, $calendar_month - 1);
|
|
print sprintf($thm_elem['button.previous'], "my.datebook.php?view=3&year=$next_month[0]&month=$next_month[1]", $strings['generic_month'], "");
|
|
|
|
print "<b> $monthNames[$calendar_month] $calendar_year </b>";
|
|
$previous_month = adjustMonth($calendar_year, $calendar_month + 1);
|
|
print sprintf($thm_elem['button.next'], "my.datebook.php?view=3&year=$previous_month[0]&month=$previous_month[1]", $strings['generic_month'], "");
|
|
print "</div>";
|
|
|
|
break;
|
|
case 4:
|
|
print "<div>";
|
|
print "<table class=\"datebook\">\n";
|
|
print "<tr>\n";
|
|
for ($month_index=1; $month_index < 13; $month_index++) {
|
|
if ($month_index == $calendar_month)
|
|
$bgcolor = "class=\"selected\"";
|
|
else
|
|
$bgcolor = "";
|
|
print "<td $bgcolor >\n";
|
|
print " <a href=\"my.datebook.php?view=4&year=$calendar_year&month=$month_index\">$monthNames[$month_index]</a> ";
|
|
print "</td>\n";
|
|
}
|
|
print "</tr>\n";
|
|
print "</table>\n";
|
|
|
|
print "<center>";
|
|
|
|
print "<div class=\"photo_nav\">";
|
|
$next_year = $calendar_year - 1;
|
|
|
|
print sprintf($thm_elem['button.previous'], "my.datebook.php?view=4&year=$next_year&month=$calendar_month", $strings['generic_year'], "");
|
|
|
|
print "<b> $calendar_year </b>";
|
|
$previous_year = $calendar_year + 1;
|
|
|
|
print sprintf($thm_elem['button.next'], "my.datebook.php?view=4&year=$previous_year&month=$calendar_month", $strings['generic_year'], "");
|
|
|
|
print "</div>";
|
|
|
|
print "<table class=\"gotodate\">\n";
|
|
print "<tr>\n";
|
|
print emit_th($strings['datebook_week2']);
|
|
for ($dayIncrement = 0; $dayIncrement < 7; $dayIncrement++)
|
|
print "<th width=\"80\"><b>" . $dayNames[($po_options['start_day'] + $dayIncrement) % 7] . "</b></th>\n";
|
|
print "</tr>\n";
|
|
// get timestamp of first day of month at noon
|
|
$timestamp = mktime(12, 0, 0, $calendar_month, 1, $calendar_year);
|
|
// get first day index 0 Sunday
|
|
$date = getdate($timestamp);
|
|
$day = $po_options['start_day'] + 1 - $date["wday"];
|
|
|
|
if ($day > 1)
|
|
$day -= 7;
|
|
|
|
$today = getdate(time());
|
|
$daysInMonth = getDaysInMonth($calendar_year, $calendar_month);
|
|
|
|
while ($day <= $daysInMonth) {
|
|
print "<tr>\n";
|
|
$curDate = adjustDay($calendar_year, $calendar_month, $day);
|
|
$weekNumber=getWeekNumber($curDate[0], $curDate[1], $curDate[2], $po_options['start_day']);
|
|
print "<th>";
|
|
print "<a href=\"my.datebook.php?view=2&year=$calendar_year&month=$curDate[1]&day=$curDate[2]\"><strong>$weekNumber</strong></a></th>\n";
|
|
for ($i = 0; $i < 7; $i++) {
|
|
$curDate = adjustDay($calendar_year, $calendar_month, $day);
|
|
$num_photos = 0;
|
|
if ($showcounts) {
|
|
$num_photos = photos_between_dates($database, $po_user['id'],
|
|
mktime(0,0,0,$curDate[1],$curDate[2],$curDate[0]),
|
|
mktime(0,0,0,$curDate[1],$curDate[2]+1,$curDate[0]));
|
|
}
|
|
|
|
$bgcolor = "";
|
|
if ($curDate[2]!=$day)
|
|
$bgcolor = "class=\"inactive\"";
|
|
if (($calendar_year == $today["year"]) &&
|
|
($calendar_month == $today["mon"]) &&
|
|
($day == $today["mday"])) {
|
|
$bgcolor = "class=\"selected\"";
|
|
}
|
|
|
|
print "<td $bgcolor ><a href=\"my.datebook.php?view=1&year=$curDate[0]&month=$curDate[1]&day=$curDate[2]\">$curDate[2]</a>";
|
|
if ($showcounts && $num_photos > 0) {
|
|
$start = urlencode(sprintf("%04d-%02d-%02d 00:00:00", $curDate[0],$curDate[1],$curDate[2]));
|
|
$end = urlencode(sprintf("%04d-%02d-%02d 23:59:59", $curDate[0],$curDate[1],$curDate[2]));
|
|
if ($po_options['search_masters_only'] != 'f') {
|
|
$master = "&only_masters=true";
|
|
} else {
|
|
$master = "";
|
|
}
|
|
$num_photos = emit_a("search.text.advanced.php?start_date=$start&end_date=$end&date_type=photo.date_of_exposure&date_operator=or&user=$po_user[id]$master", $num_photos);
|
|
print " [$num_photos]";
|
|
}
|
|
print "</td>\n";
|
|
$day++;
|
|
}
|
|
print "</tr>\n";
|
|
}
|
|
print "</table>\n";
|
|
print "</center>\n";
|
|
|
|
print "</div>";
|
|
print "<br/>";
|
|
|
|
break;
|
|
}
|
|
|
|
print " <br/>";
|
|
|
|
if ($po_user['type'] > PO_USER_TYPE_CLIENT) {
|
|
display_clients($database, $po_user['id'], $auth_handle);
|
|
}
|
|
|
|
display_protected_photographers($database, $po_user['id']);
|
|
site_footer($database);
|
|
site_epilog($database);
|
|
|
|
?>
|