-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
220 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
|
||
$db_link = new mysqli($db['host'], $db['name'], $db['pass'], $db['base']); | ||
$tasks = $db_link->query("SHOW TABLES LIKE 'tasks'"); | ||
if ($tasks->num_rows > 0) { | ||
if (isset($_GET['day'])) { | ||
$query = "SELECT * FROM `tasks` WHERE `datum`='$new_year.$new_month.$select_day'"; | ||
} elseif (isset($_GET['month'])) { | ||
$query = "SELECT * FROM `tasks` WHERE MONTH(`datum`) = '$new_month' AND YEAR(`datum`) = '$new_year'"; | ||
} else { | ||
$query = "SELECT * FROM `tasks` WHERE YEAR(`datum`) = '$new_year'"; | ||
} | ||
} else { | ||
$query = "CREATE TABLE `tasks` ( | ||
id INT(10) NOT NULL AUTO_INCREMENT, | ||
txt VARCHAR(64) NOT NULL, | ||
datum DATE, | ||
PRIMARY KEY (id) | ||
)"; | ||
} | ||
|
||
?> | ||
<div class="kal_container"> | ||
<table id="kalendar" data="<?php echo $season ?>"> | ||
<caption class="kal_title"> | ||
<?php | ||
echo '<div class="kal_navi">'; | ||
echo '<a class="btn_cal" href="?month=' . $new_month - 1 . '&year=' . $new_year . '">' . $kal_btn['prev'] . '</a>'; | ||
echo '<a class="btn_cal" href="?month=' . $cur_month . '">' . $kal_btn['cur_month'] . '</a>'; | ||
echo '<a class="btn_cal" href="?month=' . $new_month + 1 . '&year=' . $new_year . '">' . $kal_btn['next'] . '</a>'; | ||
echo '</div>'; | ||
echo '<span>' . $cur_month_str . '</span><span>' . $new_year . '</span>'; | ||
?> | ||
</caption> | ||
<thead> | ||
<tr class="row_header"> | ||
<?php | ||
foreach ($weekday as $day) { | ||
echo ' | ||
<th>' . $day . '</th> | ||
'; | ||
} | ||
?> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<?php | ||
$d = 1; | ||
while ($d <= $col_days) { | ||
echo '<tr class="row_kal">'; | ||
for ($w = 1; $w <= 7; $w++) { | ||
if ($d == 1 && $w < $cur_firstday_month || $d > $col_days) { | ||
echo '<td></td>'; | ||
} else { | ||
if ($d == $cur_day && $new_month == $cur_month) { | ||
echo '<td class="cur_day">'; | ||
} else { | ||
echo '<td>'; | ||
} | ||
echo '<a href="?year=' . $new_year . '&month=' . $new_month . '&day=' . $d . '">' . $d . '</a> | ||
</td> | ||
'; | ||
$d++; | ||
} | ||
} | ||
echo '</tr>'; | ||
} | ||
?> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<div class="task_container"> | ||
<ul class="task_list"> | ||
<?php | ||
if (isset($_GET['day'])) { | ||
$url = ' | ||
&year=' . $new_year . ' | ||
&month=' . $new_month . ' | ||
&day=' . $select_day; | ||
} else { | ||
$url = ' | ||
&year=' . $new_year . ' | ||
&month=' . $new_month; | ||
} | ||
|
||
print_r($_GET); | ||
|
||
$tasks = $db_link->query($query); | ||
if ($tasks->num_rows > 0) { | ||
while ($task = $tasks->fetch_assoc()) { | ||
echo '<li class="task_item"> | ||
<div class="item_container"> | ||
<p>' . $task['txt'] . '</p> | ||
<span>' . $task['datum'] . '</span> | ||
</div> | ||
<a class="btn_del" href="src/components/engine.php?cur-task=del&task-id=' . $task['id'] . $url . '">' | ||
. $kal_btn['del'] . '</a> | ||
</li>'; | ||
} | ||
} else { | ||
echo '<p>Pro vybraný termín nejsou žádné úkoly, můžete jít na čaj 🍵</p>'; | ||
} | ||
$db_link->close(); | ||
|
||
?> | ||
</ul> | ||
|
||
<form method="post" action="src/components/engine.php"> | ||
<?php | ||
$month = date("m", mktime(0, 0, 0, $new_month, 1)); | ||
$day = date("d", mktime(0, 0, 0, $month, $select_day)); | ||
?> | ||
|
||
<input type="text" name="ukol" placeholder="zadat úkol" required> | ||
<input type="date" name="date" value="<?php echo date("$new_year-$month-$day") ?>" required> | ||
<button type="submit">zadat úkol</button> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
if (isset($_GET['year'])) { | ||
$new_year = $_GET['year']; | ||
} else { | ||
$new_year = $cur_year; | ||
} | ||
|
||
if (isset($_GET['month'])) { | ||
$new_month = $_GET['month']; | ||
|
||
if ($new_month > 12) { | ||
$new_month = 1; | ||
$new_year += 1; | ||
} elseif ($new_month <= 0) { | ||
$new_month = 12; | ||
$new_year -= 1; | ||
} | ||
} else { | ||
$new_month = $cur_month; | ||
} | ||
|
||
if (isset($_GET['day'])) { | ||
$select_day = $_GET['day']; | ||
} else { | ||
$select_day = $cur_day; | ||
} | ||
|
||
$cur_month_str = $months[$new_month - 1]; | ||
$col_days = cal_days_in_month(CAL_GREGORIAN, $new_month, $new_year); | ||
$cur_firstday_month = date('w', mktime(0, 0, 0, $new_month, 1, $new_year)); | ||
|
||
if ($cur_firstday_month == 0) { | ||
$cur_firstday_month = 7; | ||
} | ||
|
||
$season_index = (($new_month == 12) ? 3 : ($new_month <= 2)) ? 3 : floor(($new_month - 2) / 3); | ||
$season = $seasons[$season_index]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
require('const.php'); | ||
require('cal_var.php'); | ||
|
||
$db_link = new mysqli($db['host'], $db['name'], $db['pass'], $db['base']); | ||
|
||
if (isset($_POST['ukol'])) { | ||
$ukol = mysqli_real_escape_string($db_link, $_POST['ukol']); | ||
$query_add_task = 'INSERT INTO tasks (txt, datum) VALUES ("' . $ukol . '", "' . $_POST['date'] . '")'; | ||
$db_link->query($query_add_task); | ||
unset($_POST['ukol']); | ||
|
||
$month = date('n', strtotime($_POST['date'])); | ||
$day = date('j', strtotime($_POST['date'])); | ||
$year = date('Y', strtotime($_POST['date'])); | ||
header('Location: /Kalendar?year=' . $year . '&month=' . $month . '&day=' . $day . ''); | ||
exit; | ||
} | ||
|
||
if (isset($_GET['cur-task']) && $_GET['cur-task'] == 'del') { | ||
$query_del_task = 'DELETE FROM `tasks` WHERE `tasks`.`id` = ' . $_GET['task-id'] . ''; | ||
$db_link->query($query_del_task); | ||
unset($_GET['cur-task']); | ||
|
||
if (isset($_GET['day'])) { | ||
$url = 'year=' . $new_year . '&month=' . $new_month . '&day=' . $select_day; | ||
} else { | ||
$url = 'year=' . $new_year . '&month=' . $new_month; | ||
unset($_GET['day']); | ||
} | ||
|
||
header('Location: /Kalendar?' . $url . ''); | ||
exit; | ||
} | ||
|
||
$db_link->close(); | ||
|
||
// lost variables ??? | ||
// echo $select_day . $new_month . '<br>'; | ||
// echo $day . $month . '<br>'; | ||
// print_r($_GET) . '<br>'; | ||
// print_r($_POST) . '<br>'; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.