Add project creation

The projects page will also display a few random projects now
This commit is contained in:
2017-10-22 17:57:55 +02:00
parent 68bba332f1
commit 1da1785e46
23 changed files with 311 additions and 53 deletions

35
src/pvv/side/project.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
namespace pvv\side;
class Project{
private $id, $name, $owner, $owneruname, $descr, $active;
public function __construct($id, $name, $descr, $owner, $owneruname, $active){
$this->id = $id;
$this->name = $name;
$this->descr = $descr;
$this->owner = $owner;
$this->owneruname = $owneruname;
$this->active = $active;
}
public function getID(){
return $this->id;
}
public function getName(){
return $this->name;
}
public function getDescription(){
return $this->descr;
}
public function getOwner(){
return $this->owner;
}
public function getOwnerUName(){
return $this->owneruname;
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace pvv\side;
use \PDO;
class ProjectManager{
private $pdo;
public function __construct(PDO $pdo){
$this->pdo = $pdo;
}
public function getAll() {
$query = 'SELECT * FROM projects ORDER BY id ASC';
$statement = $this->pdo->prepare($query);
$statement->execute();
$projects = [];
foreach($statement->fetchAll() as $dbProj){
$project = new Project(
$dbProj['id'],
$dbProj['name'],
$dbProj['description'],
$dbProj['owner'],
$dbProj['owneruname'],
$dbProj['active']
);
$projects[] = $project;
}
return $projects;
}
public function getByID($id){
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
$statement = $this->pdo->prepare($query);
$statement->bindParam(':id', $id, PDO::PARAM_INT);
$statement->execute();
$dbProj = $statement->fetch();
$project = new Project(
$dbProj['id'],
$dbProj['name'],
$dbProj['description'],
$dbProj['owner'],
$dbProj['active']
);
return $project;
}
}

View File

@@ -3,7 +3,7 @@ namespace pvv\side;
class SimpleEvent extends Event {
private $name, $start, $end, $org, $loc;
private $id, $name, $descr, $start, $end, $org, $loc;
public function __construct($id, $name,\DateTimeImmutable $start,\DateTimeImmutable $end,$org, $loc, $descr, $isDBEvent = false){
$this->id = $id;