Begin work on project pages
Also store project owners' emails as contact info
This commit is contained in:
parent
63200f863b
commit
d984dfb89c
|
@ -13,6 +13,7 @@ CREATE TABLE projects (
|
|||
`name` TEXT,
|
||||
`owner` TEXT,
|
||||
`owneruname` TEXT,
|
||||
`owneremail` TEXT,
|
||||
`description` TEXT,
|
||||
`active` BOOLEAN
|
||||
);
|
||||
|
|
1
pvv.sql
1
pvv.sql
|
@ -13,6 +13,7 @@ CREATE TABLE "projects" (
|
|||
"name" TEXT,
|
||||
"owner" TEXT,
|
||||
"owneruname" TEXT,
|
||||
"owneremail" TEXT,
|
||||
"description" TEXT,
|
||||
"active" BOOLEAN
|
||||
);
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
namespace pvv\side;
|
||||
|
||||
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->name = $name;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->owner = $owner;
|
||||
$this->owneruname = $owneruname;
|
||||
$this->owneremail = $owneremail;
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
|
@ -33,6 +34,10 @@ class Project{
|
|||
return $this->owneruname;
|
||||
}
|
||||
|
||||
public function getOwnerEmail(){
|
||||
return $this->owneremail;
|
||||
}
|
||||
|
||||
public function getActive(){
|
||||
return $this->active;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ class ProjectManager{
|
|||
$dbProj['description'],
|
||||
$dbProj['owner'],
|
||||
$dbProj['owneruname'],
|
||||
$dbProj['owneremail'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
|
@ -44,6 +45,7 @@ class ProjectManager{
|
|||
$dbProj['description'],
|
||||
$dbProj['owner'],
|
||||
$dbProj['owneruname'],
|
||||
$dbProj['owneremail'],
|
||||
$dbProj['active']
|
||||
);
|
||||
|
||||
|
@ -64,6 +66,7 @@ class ProjectManager{
|
|||
$dbProj['description'],
|
||||
$dbProj['owner'],
|
||||
$dbProj['owneruname'],
|
||||
$dbproj['owneremail'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
|
|
|
@ -42,6 +42,7 @@ $project = new \pvv\side\Project(
|
|||
'',
|
||||
'kåre knoll',
|
||||
'pvvadmin',
|
||||
'drift@pvv.ntnu.no',
|
||||
0
|
||||
);
|
||||
if($new == 0){
|
||||
|
@ -86,6 +87,9 @@ if($new == 0){
|
|||
<p class="subtitle">Prosjektleder (Navn)</p>
|
||||
<?= '<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>
|
||||
<?= '<input type="checkbox" '. ($project->getActive() ? 'checked' : '') . ' name="active"/>' ?>
|
||||
</div>
|
||||
|
|
|
@ -32,26 +32,29 @@ $title = $_POST['title'];
|
|||
$desc = $_POST['desc'];
|
||||
$owner = $_POST['organisername'];
|
||||
$uname = $_POST['organiser'];
|
||||
$email = $_POST['organiseremail'];
|
||||
$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)';
|
||||
$query = 'INSERT INTO projects (name, owner, owneruname, owneremail, description, active) VALUES (:title, :owner, :uname, :email, :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(':email', $email, 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';
|
||||
$query = 'UPDATE projects SET name=:title, owner=:owner, owneruname=:uname, owneremail=:email, 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(':email', $email, PDO::PARAM_STR);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,52 @@
|
|||
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) {
|
||||
.projects {
|
||||
display: inline-block;
|
||||
|
|
|
@ -33,6 +33,7 @@ $project = new \pvv\side\Project(
|
|||
'',
|
||||
$attrs["cn"][0],
|
||||
$attrs["uid"][0],
|
||||
$attrs["email"][0]
|
||||
1
|
||||
);
|
||||
if($new == 0){
|
||||
|
|
|
@ -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>
|
|
@ -71,7 +71,7 @@ $projects = array_values(array_filter(
|
|||
<div class="event">
|
||||
<div class="event-info">
|
||||
<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>
|
||||
</li>
|
||||
|
|
|
@ -26,24 +26,27 @@ $title = $_POST['title'];
|
|||
$desc = $_POST['desc'];
|
||||
$owner = $attrs['cn'][0];
|
||||
$owneruname = $attrs['uid'][0];
|
||||
$owneremail = $attrs['mail'][0];
|
||||
|
||||
$statement;
|
||||
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->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owner', $owner, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $owneruname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $owneremail, PDO::PARAM_STR);
|
||||
}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->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owner', $owner, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $owneruname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $owneremail, PDO::PARAM_STR);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue