diff --git a/src/pvv/side/project.php b/src/pvv/side/project.php index 990499b..93d3a9a 100644 --- a/src/pvv/side/project.php +++ b/src/pvv/side/project.php @@ -32,4 +32,8 @@ class Project{ public function getOwnerUName(){ return $this->owneruname; } + + public function getActive(){ + return $this->active; + } } \ No newline at end of file diff --git a/src/pvv/side/projectmanager.php b/src/pvv/side/projectmanager.php index 338c88d..9df3360 100644 --- a/src/pvv/side/projectmanager.php +++ b/src/pvv/side/projectmanager.php @@ -43,6 +43,7 @@ class ProjectManager{ $dbProj['name'], $dbProj['description'], $dbProj['owner'], + $dbProj['owneruname'], $dbProj['active'] ); diff --git a/www/admin/prosjekter/delete.php b/www/admin/prosjekter/delete.php new file mode 100644 index 0000000..4be135a --- /dev/null +++ b/www/admin/prosjekter/delete.php @@ -0,0 +1,15 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$projectID = $_GET['id']; + +$query = 'DELETE FROM projects WHERE id=\'' . $projectID . '\''; +$statement = $pdo->prepare($query); +$statement->execute(); + +header('Location: ' . $_SERVER['HTTP_REFERER']); +?> + +Om du ikke ble omdirigert tilbake klikk her \ No newline at end of file diff --git a/www/admin/prosjekter/edit.php b/www/admin/prosjekter/edit.php new file mode 100644 index 0000000..639d8e2 --- /dev/null +++ b/www/admin/prosjekter/edit.php @@ -0,0 +1,89 @@ +getAll(); + +$new = 0; +if(isset($_GET['new'])){ + $new = $_GET['new']; +} + +$projectID = 0; +if(isset($_GET['id'])){ + $projectID = $_GET['id']; +}else if($new == 0){ + echo "\nID not set"; + exit(); +} + +$project = new \pvv\side\Project( + 0, + 'Kult Prosjekt', + '', + 'kåre knoll', + 'pvvadmin', + 0 +); +if($new == 0){ + $project = $projectManager->getByID($projectID); +} +?> + + + + + + + + + +
Prosjekt­administrasjon
+ +
+ +
+

+ +
+
+

Tittel

+ getName() . '" class="boxinput">' ?>
+ +

Beskrivelse

+ +
+ +
+

Prosjekteier (Brukernavn)

+ getOwnerUName(). '" class="boxinput">' ?>
+ +

Prosjekteier (Navn)

+ getOwner(). '" class="boxinput">' ?> + +

Aktiv

+ getActive() ? 'checked' : '') . ' name="active"/>' ?> +
+ + getID() . '" />' ?> + +
+
+ + +
+
+

+

+ +
\ No newline at end of file diff --git a/www/admin/prosjekter/index.php b/www/admin/prosjekter/index.php new file mode 100644 index 0000000..5a52140 --- /dev/null +++ b/www/admin/prosjekter/index.php @@ -0,0 +1,124 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$projectManager = new \pvv\side\ProjectManager($pdo); +$projects = $projectManager->getAll(); + +$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 +$projects = array_values(array_filter( + $projects, + function($project) use ($filterTitle, $filterOrganiser){ + return (preg_match('/.*'.$filterTitle.'.*/i', $project->getName()) and preg_match('/.*'.$filterOrganiser.'.*/i', $project->getOwner())); + } +)); +?> + + + + + + + + + +
Prosjekt­administrasjon
+ +
+ +
+
+

Prosjekter

+ +
    + getID(); + ?> + +
  • +
    +
    +

    getName() . " (ID: " . $projectID . ")"; ?>

    +

    getOwner(); ?>

    +

    getDescription(); ?>

    +
    + +
    + 🖊'; ?> + 🗑'; ?> +
    +
    +
  • + + +
+ + Forrige side'; + } + + if(($counter == $pageLimit) and (($pageLimit * $page) < count($projects))){ + echo 'Neste side'; + } + ?> +
+ +
+

Verktøy

+ Legg inn nytt prosjekt +

Filter

+
+

Navn

+ ' ?>
+

Organisator

+ ' ?>
+ +
+ +
+
+
+
+ +
\ No newline at end of file diff --git a/www/admin/prosjekter/update.php b/www/admin/prosjekter/update.php new file mode 100644 index 0000000..1ce2be3 --- /dev/null +++ b/www/admin/prosjekter/update.php @@ -0,0 +1,54 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +if(!isset($_POST['title']) or !isset($_POST['desc']) or !isset($_POST['organisername']) or !isset($_POST['organiser'])){ + header('Location: ' . $_SERVER['HTTP_REFERER']); + exit(); +} + +$id = 0; +if(isset($_POST['id'])){ + $id = $_POST['id']; +} + +$title = $_POST['title']; +$desc = $_POST['desc']; +$owner = $_POST['organisername']; +$uname = $_POST['organiser']; +$active = (isset($_POST['active']) ? $_POST['active'] : 0); + +$statement; +if($id == 0){ + $query = 'INSERT INTO projects (name, owner, owneruname, description, active) VALUES (:title, :owner, :uname, :desc, :active)'; + $statement = $pdo->prepare($query); + + $statement->bindParam(':title', $title, PDO::PARAM_STR); + $statement->bindParam(':desc', $desc, PDO::PARAM_STR); + $statement->bindParam(':owner', $owner, PDO::PARAM_STR); + $statement->bindParam(':uname', $uname, PDO::PARAM_STR); + $statement->bindParam(':active', $active, PDO::PARAM_INT); +}else{ + $query = 'UPDATE projects SET name=:title, owner=:owner, owneruname=:uname, description=:desc, active=:active WHERE id=:id'; + $statement = $pdo->prepare($query); + + $statement->bindParam(':title', $title, PDO::PARAM_STR); + $statement->bindParam(':desc', $desc, PDO::PARAM_STR); + $statement->bindParam(':owner', $owner, PDO::PARAM_STR); + $statement->bindParam(':uname', $uname, PDO::PARAM_STR); + $statement->bindParam(':active', $active, PDO::PARAM_INT); + $statement->bindParam(':id', $id, PDO::PARAM_INT); +} + +$statement->execute(); + +header('Location: .'); +?> + +Om du ikke ble automatisk omdirigert tilbake klikk her \ No newline at end of file