128 lines
4.3 KiB
PHP
128 lines
4.3 KiB
PHP
<?php include('config.php'); ?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="pl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Planer</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
<body>
|
|
<?php
|
|
$year = Date('Y');
|
|
if(isset($_GET['year'])) { $year = intval($_GET['year']); }
|
|
if ($year < 1) { $year = 1; }
|
|
|
|
$month = Date('m');
|
|
if(isset($_GET['month'])) { $month = intval($_GET['month']); }
|
|
if($month < 1) { $month = 1; }
|
|
if($month > 12) { $month = 12; }
|
|
?>
|
|
|
|
<div class="container">
|
|
<form method="get">
|
|
<select id="select_miesiac" name="month">
|
|
<?php
|
|
for($i = 0; $i < 12; $i++) {
|
|
if($i + 1 == $month) {
|
|
echo '<option value="' . $i+1 . '" selected>' . $month_names[$i] . '</option>';
|
|
} else {
|
|
echo '<option value="' . $i+1 . '">' . $month_names[$i] . '</option>';
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
<select id="select_rok" name="year">
|
|
<?php
|
|
for($i = 2020; $i < 2030; $i++) {
|
|
if($i == $year) {
|
|
echo '<option selected>' . $i . '</option>';
|
|
} else {
|
|
echo '<option>' . $i . '</option>';
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
<button>ok</button>
|
|
</form>
|
|
|
|
<?php
|
|
$day_table_offset = strftime('%w', mktime(0, 0, 0, $month, 1, $year)) + 6;
|
|
if($day_table_offset >= 7) { $day_table_offset -= 7; }
|
|
$day_table = [];
|
|
|
|
$ptr = 1 - $day_table_offset;
|
|
while($ptr <= cal_days_in_month($CALENDAR, $month, $year)) {
|
|
if($ptr < 1) {
|
|
$day_table[] = '';
|
|
} else {
|
|
$day_table[] = strftime('%Y-%m-%d', mktime(0, 0, 0, $month, $ptr, $year));
|
|
}
|
|
$ptr++;
|
|
}
|
|
?>
|
|
|
|
<table>
|
|
<tr>
|
|
<?php
|
|
for($i = 0; $i < 7; $i++) {
|
|
if($i > 4) {
|
|
echo "<th class='holiday'>" . $weekday_letters[$i] . "</th>";
|
|
} else {
|
|
echo "<th>" . $weekday_letters[$i] . "</th>";
|
|
}
|
|
}
|
|
?>
|
|
</tr>
|
|
</tr>
|
|
<?php
|
|
$idx = 0;
|
|
while($idx < count($day_table)) {
|
|
if($day_table[$idx] != '') {
|
|
if($idx % 7 == 5 || $idx % 7 == 6) {
|
|
if(mb_substr($day_table[$idx], 8, 1) == '0') {
|
|
echo '<td class="holiday" data-date="' . $day_table[$idx] . '">' . mb_substr($day_table[$idx], 9, 2) . '</td>';
|
|
} else {
|
|
echo '<td class="holiday" data-date="' . $day_table[$idx] . '">' . mb_substr($day_table[$idx], 8, 2) . '</td>';
|
|
}
|
|
} else {
|
|
if(mb_substr($day_table[$idx], 8, 1) == '0') {
|
|
echo '<td data-date="' . $day_table[$idx] . '">' . mb_substr($day_table[$idx], 9, 2) . '</td>';
|
|
} else {
|
|
echo '<td data-date="' . $day_table[$idx] . '">' . mb_substr($day_table[$idx], 8, 2) . '</td>';
|
|
}
|
|
}
|
|
} else {
|
|
echo '<th></th>';
|
|
}
|
|
|
|
if(++$idx % 7 == 0) {
|
|
echo '</tr><tr>';
|
|
}
|
|
}
|
|
while($idx % 7 != 0) {
|
|
echo '<th></th>';
|
|
$idx++;
|
|
}
|
|
?>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
|
|
<p>Nie masz planów na dziś</p>
|
|
</div>
|
|
|
|
<script>
|
|
function edit() {
|
|
window.location = `edit.php?date=${this.dataset.date}`;
|
|
}
|
|
|
|
const kafelki = document.querySelectorAll("td");
|
|
for(let i = 0; i < kafelki.length; i++) {
|
|
kafelki[i].onclick = edit;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|