Begin work on project pages

Also store project owners' emails as contact info
This commit is contained in:
Markus Wang Halvorsen 2018-02-24 19:41:57 +01:00
parent 63200f863b
commit d984dfb89c
11 changed files with 124 additions and 7 deletions

1
dist/pvv_mysql.sql vendored
View File

@ -13,6 +13,7 @@ CREATE TABLE projects (
`name` TEXT, `name` TEXT,
`owner` TEXT, `owner` TEXT,
`owneruname` TEXT, `owneruname` TEXT,
`owneremail` TEXT,
`description` TEXT, `description` TEXT,
`active` BOOLEAN `active` BOOLEAN
); );

View File

@ -13,6 +13,7 @@ CREATE TABLE "projects" (
"name" TEXT, "name" TEXT,
"owner" TEXT, "owner" TEXT,
"owneruname" TEXT, "owneruname" TEXT,
"owneremail" TEXT,
"description" TEXT, "description" TEXT,
"active" BOOLEAN "active" BOOLEAN
); );

View File

@ -2,14 +2,15 @@
namespace pvv\side; namespace pvv\side;
class Project{ class Project{
private $id, $name, $owner, $owneruname, $descr, $active; private $id, $name, $owner, $owneruname, $owneremail, $descr, $active;
public function __construct($id, $name, $descr, $owner, $owneruname, $active){ public function __construct($id, $name, $descr, $owner, $owneruname, $owneremail, $active){
$this->id = $id; $this->id = $id;
$this->name = $name; $this->name = $name;
$this->descr = explode("\n", $descr); $this->descr = explode("\n", $descr);
$this->owner = $owner; $this->owner = $owner;
$this->owneruname = $owneruname; $this->owneruname = $owneruname;
$this->owneremail = $owneremail;
$this->active = $active; $this->active = $active;
} }
@ -33,6 +34,10 @@ class Project{
return $this->owneruname; return $this->owneruname;
} }
public function getOwnerEmail(){
return $this->owneremail;
}
public function getActive(){ public function getActive(){
return $this->active; return $this->active;
} }

View File

@ -23,6 +23,7 @@ class ProjectManager{
$dbProj['description'], $dbProj['description'],
$dbProj['owner'], $dbProj['owner'],
$dbProj['owneruname'], $dbProj['owneruname'],
$dbProj['owneremail'],
$dbProj['active'] $dbProj['active']
); );
$projects[] = $project; $projects[] = $project;
@ -44,6 +45,7 @@ class ProjectManager{
$dbProj['description'], $dbProj['description'],
$dbProj['owner'], $dbProj['owner'],
$dbProj['owneruname'], $dbProj['owneruname'],
$dbProj['owneremail'],
$dbProj['active'] $dbProj['active']
); );
@ -64,6 +66,7 @@ class ProjectManager{
$dbProj['description'], $dbProj['description'],
$dbProj['owner'], $dbProj['owner'],
$dbProj['owneruname'], $dbProj['owneruname'],
$dbproj['owneremail'],
$dbProj['active'] $dbProj['active']
); );
$projects[] = $project; $projects[] = $project;

View File

@ -42,6 +42,7 @@ $project = new \pvv\side\Project(
'', '',
'kåre knoll', 'kåre knoll',
'pvvadmin', 'pvvadmin',
'drift@pvv.ntnu.no',
0 0
); );
if($new == 0){ if($new == 0){
@ -86,6 +87,9 @@ if($new == 0){
<p class="subtitle">Prosjektleder (Navn)</p> <p class="subtitle">Prosjektleder (Navn)</p>
<?= '<input type="text" name="organisername" value="' . $project->getOwner(). '" class="boxinput">' ?> <?= '<input type="text" name="organisername" value="' . $project->getOwner(). '" class="boxinput">' ?>
<p class="subtitle">Prosjektleder E-post</p>
<?= '<input type="text" name="organiseremail" value="' . $project->getOwnerEmail(). '" class="boxinput">' ?><br>
<p class="subtitle">Aktiv</p> <p class="subtitle">Aktiv</p>
<?= '<input type="checkbox" '. ($project->getActive() ? 'checked' : '') . ' name="active"/>' ?> <?= '<input type="checkbox" '. ($project->getActive() ? 'checked' : '') . ' name="active"/>' ?>
</div> </div>

View File

@ -32,26 +32,29 @@ $title = $_POST['title'];
$desc = $_POST['desc']; $desc = $_POST['desc'];
$owner = $_POST['organisername']; $owner = $_POST['organisername'];
$uname = $_POST['organiser']; $uname = $_POST['organiser'];
$email = $_POST['organiseremail'];
$active = (isset($_POST['active']) ? $_POST['active'] : 0); $active = (isset($_POST['active']) ? $_POST['active'] : 0);
$statement; $statement;
if($id == 0){ if($id == 0){
$query = 'INSERT INTO projects (name, owner, owneruname, description, active) VALUES (:title, :owner, :uname, :desc, :active)'; $query = 'INSERT INTO projects (name, owner, owneruname, owneremail, description, active) VALUES (:title, :owner, :uname, :email, :desc, :active)';
$statement = $pdo->prepare($query); $statement = $pdo->prepare($query);
$statement->bindParam(':title', $title, PDO::PARAM_STR); $statement->bindParam(':title', $title, PDO::PARAM_STR);
$statement->bindParam(':desc', $desc, PDO::PARAM_STR); $statement->bindParam(':desc', $desc, PDO::PARAM_STR);
$statement->bindParam(':owner', $owner, PDO::PARAM_STR); $statement->bindParam(':owner', $owner, PDO::PARAM_STR);
$statement->bindParam(':uname', $uname, PDO::PARAM_STR); $statement->bindParam(':uname', $uname, PDO::PARAM_STR);
$statement->bindParam(':email', $email, PDO::PARAM_STR);
$statement->bindParam(':active', $active, PDO::PARAM_INT); $statement->bindParam(':active', $active, PDO::PARAM_INT);
}else{ }else{
$query = 'UPDATE projects SET name=:title, owner=:owner, owneruname=:uname, description=:desc, active=:active WHERE id=:id'; $query = 'UPDATE projects SET name=:title, owner=:owner, owneruname=:uname, owneremail=:email, description=:desc, active=:active WHERE id=:id';
$statement = $pdo->prepare($query); $statement = $pdo->prepare($query);
$statement->bindParam(':title', $title, PDO::PARAM_STR); $statement->bindParam(':title', $title, PDO::PARAM_STR);
$statement->bindParam(':desc', $desc, PDO::PARAM_STR); $statement->bindParam(':desc', $desc, PDO::PARAM_STR);
$statement->bindParam(':owner', $owner, PDO::PARAM_STR); $statement->bindParam(':owner', $owner, PDO::PARAM_STR);
$statement->bindParam(':uname', $uname, PDO::PARAM_STR); $statement->bindParam(':uname', $uname, PDO::PARAM_STR);
$statement->bindParam(':email', $email, PDO::PARAM_STR);
$statement->bindParam(':active', $active, PDO::PARAM_INT); $statement->bindParam(':active', $active, PDO::PARAM_INT);
$statement->bindParam(':id', $id, PDO::PARAM_INT); $statement->bindParam(':id', $id, PDO::PARAM_INT);
} }

View File

@ -51,6 +51,52 @@
margin-bottom: 2em; margin-bottom: 2em;
} }
.contentsplit {
display: grid;
grid-template-columns: 1.3fr 2.7fr;
}
.gridl {
padding: 0 1em 0 1em;
box-shadow: 0 2px 10px 0 rgba(0,0,0,0.2);
}
.gridr {
border-left: 0;
}
.projectowner {
padding: 0 .5em 0 .5em;
overflow: hidden;
border-left: 4px solid #35a;
}
.projectowner p {
margin: 0;
}
.projectowner p {
font-size: .8em;
}
.projectowner p:first-child {
font-size: 1em;
margin-bottom: .2em;
}
.owneruname, .owneremail {
display: inline-block;
color: #888;
}
.owneruname {
float: left;
}
.owneremail {
float: right;
}
@media screen and (max-width: 50rem) { @media screen and (max-width: 50rem) {
.projects { .projects {
display: inline-block; display: inline-block;

View File

@ -33,6 +33,7 @@ $project = new \pvv\side\Project(
'', '',
$attrs["cn"][0], $attrs["cn"][0],
$attrs["uid"][0], $attrs["uid"][0],
$attrs["email"][0]
1 1
); );
if($new == 0){ if($new == 0){

50
www/prosjekt/info.php Normal file
View File

@ -0,0 +1,50 @@
<?php
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
$projectID = 0;
if(isset($_GET['id'])){
$projectID = $_GET['id'];
}else{
echo 'No project ID provided';
exit();
}
$projectManager = new \pvv\side\ProjectManager($pdo);
$project = $projectManager->getByID($projectID);
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../../css/normalize.css">
<link rel="stylesheet" href="../../css/style.css">
<link rel="stylesheet" href="../../css/events.css">
<link rel="stylesheet" href="../../css/projects.css">
</head>
<body>
<nav>
<?php echo navbar(2, 'prosjekt'); ?>
<?php echo loginbar(null, $pdo); ?>
</nav>
<main class="contentsplit">
<div class="gridr">
<h2><?= $project->getName(); ?></h2>
<p><?= implode($project->getDescription(), "<br>"); ?></p>
</div>
<div class="gridl">
<div class="projectlead">
<h2>Prosjektledelse</h2>
<div class="projectowner">
<p>Prosjekteier</p>
<p class="ownername"><?= $project->getOwner() ?></p>
<p class="owneruname"><?= $project->getOwnerUName(); ?></p>
<p class="owneremail"><?= $project->getOwnerEmail(); ?></p>
</div>
</div>
<h2>Medlemmer</h2>
</div>
</main>
</body>

View File

@ -71,7 +71,7 @@ $projects = array_values(array_filter(
<div class="event"> <div class="event">
<div class="event-info"> <div class="event-info">
<h3 class="no-chin"><?= '<a href="edit.php?id=' . $project->getID() . '">' . $project->getName() . '</a>'; ?></h3> <h3 class="no-chin"><?= '<a href="edit.php?id=' . $project->getID() . '">' . $project->getName() . '</a>'; ?></h3>
<p><?= implode($project->getDescription()); ?></p> <p><?= implode($project->getDescription(), "<br>"); ?></p>
</div> </div>
</div> </div>
</li> </li>

View File

@ -26,24 +26,27 @@ $title = $_POST['title'];
$desc = $_POST['desc']; $desc = $_POST['desc'];
$owner = $attrs['cn'][0]; $owner = $attrs['cn'][0];
$owneruname = $attrs['uid'][0]; $owneruname = $attrs['uid'][0];
$owneremail = $attrs['mail'][0];
$statement; $statement;
if($id == 0){ if($id == 0){
$query = 'INSERT INTO projects (name, owner, owneruname, description, active) VALUES (:title, :owner, :owneruname, :desc, 1)'; $query = 'INSERT INTO projects (name, owner, owneruname, owneremail, description, active) VALUES (:title, :owner, :owneruname, :desc, 1)';
$statement = $pdo->prepare($query); $statement = $pdo->prepare($query);
$statement->bindParam(':title', $title, PDO::PARAM_STR); $statement->bindParam(':title', $title, PDO::PARAM_STR);
$statement->bindParam(':desc', $desc, PDO::PARAM_STR); $statement->bindParam(':desc', $desc, PDO::PARAM_STR);
$statement->bindParam(':owner', $owner, PDO::PARAM_STR); $statement->bindParam(':owner', $owner, PDO::PARAM_STR);
$statement->bindParam(':owneruname', $owneruname, PDO::PARAM_STR); $statement->bindParam(':owneruname', $owneruname, PDO::PARAM_STR);
$statement->bindParam(':owneremail', $owneremail, PDO::PARAM_STR);
}else{ }else{
$query = 'UPDATE projects SET name=:title, owner=:owner, owneruname=:owneruname, description=:desc WHERE id=:id'; $query = 'UPDATE projects SET name=:title, owner=:owner, owneruname=:owneruname, owneremail=:owneremail, description=:desc WHERE id=:id';
$statement = $pdo->prepare($query); $statement = $pdo->prepare($query);
$statement->bindParam(':title', $title, PDO::PARAM_STR); $statement->bindParam(':title', $title, PDO::PARAM_STR);
$statement->bindParam(':desc', $desc, PDO::PARAM_STR); $statement->bindParam(':desc', $desc, PDO::PARAM_STR);
$statement->bindParam(':owner', $owner, PDO::PARAM_STR); $statement->bindParam(':owner', $owner, PDO::PARAM_STR);
$statement->bindParam(':owneruname', $owneruname, PDO::PARAM_STR); $statement->bindParam(':owneruname', $owneruname, PDO::PARAM_STR);
$statement->bindParam(':owneremail', $owneremail, PDO::PARAM_STR);
$statement->bindParam(':id', $id, PDO::PARAM_INT); $statement->bindParam(':id', $id, PDO::PARAM_INT);
} }