diff --git a/www/admin/aktiviteter/index.php b/www/admin/aktiviteter/index.php index ed4c74b..d146972 100644 --- a/www/admin/aktiviteter/index.php +++ b/www/admin/aktiviteter/index.php @@ -8,11 +8,30 @@ require __DIR__ . '/../../../sql_config.php'; $pdo = new \PDO($dbDsn, $dbUser, $dbPass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $customActivity = new \pvv\side\DBActivity($pdo); +$events = $customActivity->getAllEvents(); $page = 1; if(isset($_GET['page'])){ $page = $_GET['page']; } + +$filterTitle = ''; +if(isset($_POST['title'])){ + $filterTitle = $_POST['title']; +} + +$filterOrganiser = ''; +if(isset($_POST['organiser'])){ + $filterOrganiser = $_POST['organiser']; +} + +// filter +$events = array_values(array_filter( + $events, + function($event) use ($filterTitle, $filterOrganiser){ + return (preg_match('/.*'.$filterTitle.'.*/i', $event->getName()) and preg_match('/.*'.$filterOrganiser.'.*/i', $event->getOrganiser())); + } +)); ?> @@ -42,7 +61,6 @@ if(isset($_GET['page'])){ getAllEvents(); for($i = ($pageLimit * ($page - 1)); $i < count($events) ;$i++){ if($counter == $pageLimit){ @@ -91,6 +109,17 @@ if(isset($_GET['page'])){

Verktøy

Legg inn ny aktivitet +

Filter

+
+

Navn

+ ' ?>
+

Organisator

+ ' ?>
+ +
+ +
+