From e6d76cd69c3cd76c943abce4f2e4a448a3df3b67 Mon Sep 17 00:00:00 2001 From: Trygve Date: Mon, 27 Oct 2025 23:14:35 +0100 Subject: [PATCH] =?UTF-8?q?Lagde=20l=C3=B8pers=C3=B8k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin.php | 20 +++++++++++++++++++- import_runners.php | 22 ++++++++++++++++++++-- runner.php | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/admin.php b/admin.php index 0b0a4a0..332fb2a 100644 --- a/admin.php +++ b/admin.php @@ -6,6 +6,15 @@ + - +

Søk opp løper

+
+ + +
+

Løpende resultater

+ \ No newline at end of file diff --git a/import_runners.php b/import_runners.php index 92c1165..06824b5 100644 --- a/import_runners.php +++ b/import_runners.php @@ -7,9 +7,10 @@ class Runner public string $course; public string $email; public string $phone; + public string $is_student; public array $splits; - function __construct($id, $name, $club, $course, $email, $phone) + function __construct($id, $name, $club, $course, $email, $phone, $is_student) { if ($id == null) { $id = 0; @@ -21,6 +22,7 @@ class Runner $this->course = $course; $this->email = $email; $this->phone = $phone; + $this->is_student = $is_student; for ($i = 0; $i < $GLOBALS['number_of_controls']; $i++) { $this->splits[$i] = false; } @@ -53,6 +55,22 @@ function get_runner($runnner_list, int $id) return false; } +function search_for_runner($runner_list, $search_term) { + $filtered_runners = []; + for ($i = 0; $i < count($runner_list); $i++) { + $runner = $runner_list[$i]; + if (str_contains(strtolower($runner->name), strtolower($search_term))){ + array_push($filtered_runners, $runner); + } + elseif (str_contains($runner->id, $search_term)){ + array_push($filtered_runners, $runner); + } + + } + return $filtered_runners; +} + + function cmp(Runner $a, Runner $b) { $a_control = $a->get_control(); $b_control = $b->get_control(); @@ -99,7 +117,7 @@ function read_runners_from_csv(){ $csv_runners = str_getcsv($csv_runners, "\n"); for ($i = 1; $i < count($csv_runners); $i++) { $line = str_getcsv($csv_runners[$i], ";"); - array_push($runners, new Runner($line[0], $line[2], $line[5], $line[6], $line[3], $line[4])); + array_push($runners, new Runner($line[0], $line[2], $line[5], $line[6], $line[3], $line[4], $line[7])); } diff --git a/runner.php b/runner.php index 5a83373..ecc7cf1 100644 --- a/runner.php +++ b/runner.php @@ -1,7 +1,7 @@ $r->name +

Klubb: $r->club

+

Løype: $r->course

+

Epost: email\">$r->email

+

Mobilnummer: phone\">$r->phone

+

Mobilnummer: phone\">$r->phone

+

Student? $r->is_student

+ "; + header("HX-Replace-Url: false"); + echo($response); + } + elseif (count($filtered) > 1){ + $response = ""; + + for ($i = 0; $i < count($filtered); $i++) { + $runner = $filtered[$i]; + $response .= ""; + header("HX-Replace-Url: false"); + echo($response); + } + } - +} \ No newline at end of file