eventmanager/events.php

144 lines
4.8 KiB
PHP

<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"pl-PL\">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Event Manager</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Piotr Szefler">
<meta http-equiv="X-Ua-Compatible" content="IE=edge">
<link rel="stylesheet" href="style/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="main.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&amp;subset=latin-ext" rel="stylesheet">
<style>
th, td {
border-bottom: 1px solid #ddd;
padding: 15px;
}
tr:hover {
background-color: #f5f5f5;
}
</style>
</head>
<body>
<div class="container">
<div class="table-responsive" >
<table class="tabel" style="margin:auto; border:">
<thead>
<?php
ini_set("display_errors", 0);
session_start();
/*echo '<pre>';
print_r($_SESSION);
echo '</pre>';
*/
if (!isset($_SESSION['zalogowany']))
{
header('Location: index.php');
exit();
}
require_once "dbconnect.php";
$polaczenie = mysqli_connect($host, $db_user, $db_password);
mysqli_query($polaczenie, "SET CHARSET utf8");
mysqli_query($polaczenie, "SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
mysqli_select_db($polaczenie, $db_name);
$zapytanietxt = "SELECT * FROM events";
$rezultat = mysqli_query($polaczenie, $zapytanietxt);
$ile = mysqli_num_rows($rezultat);
echo "</br></br>Witaj ".$_SESSION['login']; echo " [<i>".$_SESSION['perm'].'</i>]! [ <a href="logout.php">Wyloguj się!</a> ';echo "] [";
echo '<a href="events_arch.php"> Archiwalne</a>]</p>';
if(isset($_SESSION['blad_perm'])){
echo "<span style='color:red'>".$_SESSION['blad_perm']."</span>";unset($_SESSION['blad_perm']);
}
elseif(isset($_SESSION['id_log'])){
echo "<span style='color:red'>".$_SESSION['id_log']."</span>";unset($_SESSION['id_log']);
}
elseif(isset($_SESSION['slots_log'])){
echo "<span style='color:red'>".$_SESSION['slots_log']."</span>";unset($_SESSION['slots_log']);
}
if ($ile>=1)
{
if($_SESSION['perm']=='modder' || $_SESSION['perm']=='admin'){
echo '<tr onclick=location.href="add_event.php"><td class="header_tabler" width="60" align="center" bgcolor="#f8f8f8" >&#10012; ADD</td>';
}
else{
echo '<tr><td class="header_tabler" width="60" align="center" bgcolor="#f8f8f8">ID Eventu</td>';
}
echo<<<END
<td class="header_tabler" width="350" align="center" bgcolor="#f8f8f8" padding=5px>Nazwa Eventu</td>
<td class="header_tabler" width="100" align="center" bgcolor="#f8f8f8" padding=5px>Data rozpoczecia</td>
<td class="header_tabler" width="50" align="center" bgcolor="#f8f8f8" padding=5px>Godzina rozpoczecia</td>
<td class="header_tabler" width="100" align="center" bgcolor="#f8f8f8" padding=5px>Ilość godzin</td>
<td class="header_tabler" width="100" align="center" bgcolor="#f8f8f8" padding=5px>Lokalizacja</td>
</tr></thead><tbody>
END;
}
$akt_date = date("Y-m-d");
for ($i = 1; $i <= $ile; $i++)
{
$row = mysqli_fetch_assoc($rezultat);
$a4 = $row['date_stop'];
if($a4 >= $akt_date){
$a1 = $row['title'];
$a2 = $row['description'];
$a3 = $row['date_start'];
$a5 = $row['time_start'];
$a6 = $row['time_stop'];
$a7 = $row['location'];
$a8 = $row['id_events'];
$a9 = $a6 - $a5;
$a5 = substr($a5,0,strlen($a5)-3);
$a6 = substr($a6,0,strlen($a6)-3);
echo<<<END
<tr onclick="location.href='controller.php?info=$a8'">
<td width="50" align="center">$a8</td>
<td width="100" align="center" padding=2px><h3>$a1</h3></td>
<td width="100" align="center" padding=5px>$a3</td>
<td width="100" align="center" padding=5px>$a5</td>
<td width="100" align="center" padding=5px>$a9</td>
<td width="100" align="center" padding=5px>$a7</td>
</tr>
END;
}
}
echo "</tr><br/>";
?>
</tr></tbody></table>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>