added enquiry admin portal

This commit is contained in:
Joshua Perry 2023-02-05 16:13:36 +00:00
parent e9f4b7de97
commit 1f487fe45e
6 changed files with 75 additions and 9 deletions

View File

@ -15,10 +15,10 @@ class Enquiry {
}
public function getAdmin() {
if ($completed == 'y') {
if ($this->completed == 'y') {
return $this->usersTable->find(['id'], ['value0' => $this->admin_id])[0];
}
else {
else {
return 'N/A';
}

View File

@ -8,7 +8,7 @@ class Routes extends \CSY2028\Routes {
$this->setDbTables();
$this->controllers = [
"jobs" => new \jobs\controllers\Jobs($this->databaseTables["jobs"], $this->databaseTables["categories"], $this->databaseTables["applicants"], $this->databaseTables['enquiries']),
"portal" => new \jobs\controllers\Portal($this->databaseTables["categories"], $this->databaseTables["jobs"], $this->databaseTables["applicants"], $this->databaseTables['users']),
"portal" => new \jobs\controllers\Portal($this->databaseTables["categories"], $this->databaseTables["jobs"], $this->databaseTables["applicants"], $this->databaseTables['users'], $this->databaseTables['enquiries']),
"user" => new \jobs\controllers\User($this->databaseTables["users"], $this->databaseTables["categories"])
];
$this->loginControllers = [

View File

@ -5,13 +5,15 @@ class Portal {
private $jobsTable;
private $appsTable;
private $usersTable;
private $enquiryTable;
private $vars;
public function __construct(\jobs\JobDatabaseTable $catsTable, \jobs\JobDatabaseTable $jobsTable, \jobs\JobDatabaseTable $appsTable, \jobs\JobDatabaseTable $usersTable) {
public function __construct(\jobs\JobDatabaseTable $catsTable, \jobs\JobDatabaseTable $jobsTable, \jobs\JobDatabaseTable $appsTable, \jobs\JobDatabaseTable $usersTable, \jobs\JobDatabaseTable $enquiryTable) {
$this->catsTable = $catsTable;
$this->jobsTable = $jobsTable;
$this->appsTable = $appsTable;
$this->usersTable = $usersTable;
$this->enquiryTable = $enquiryTable;
$this->vars['cats'] = $this->catsTable->findAll();
$this->vars['table'] = 'job_table.html.php';
}
@ -109,6 +111,27 @@ class Portal {
}
}
public function enquiries() {
if ($_SESSION['userType'] == 'admin') {
$this->vars['table'] = 'enquiry_table.html.php';
$this->vars['enqs'] = $this->enquiryTable->findAll();
return ['template' => 'portal.html.php',
'title' => 'Jo\'s Jobs- Enquiries',
'vars' => $this->vars
];
}
}
public function enquiriesSubmit() {
$record = [
'id' => $_POST['enq_id'],
'completed' => 'y',
'admin_id' => $_SESSION['loggedin']
];
$this->enquiryTable->save($record);
$this->enquiries();
}
public function addUser() {
if ($_SESSION['userType'] == 'admin') {
if (isset($_GET['user_id'])) {

View File

@ -0,0 +1,42 @@
<h2>Enquiries</h2>
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Telephone</th>
<th>Enquiry</th>
<th>Completed</th>
<th>Handled by</th>
<th style="width: 5%">&nbsp;</th>
<th style="width: 5%">&nbsp;</th>
</tr>
<?php foreach ($enqs as $enq) { ?>
<tr>
<td><?=$enq->name?></td>
<td><?=$enq->email?></td>
<td><?=$enq->telephone?></td>
<td><?=$enq->enquiry?></td>
<td><?=$enq->completed?></td>
<td>
<?php
if ($enq->getAdmin() == 'N/A') {
echo 'N/A';
}
else {
echo $enq->getAdmin()->username;
}
?>
</td>
<?php if($enq->completed == 'n') { ?>
<td>
<form method="post" action="/portal/enquiries">
<input type="hidden" name="enq_id" value="<?=$enq->id?>" />
<input type="submit" name="submit" value="Complete" />
</form>
</td>
<?php } ?>
</tr>
<?php } ?>
</thead>
</table>

View File

@ -4,6 +4,7 @@
<li><a href="/portal">Jobs</a></li>
<?php if ($_SESSION['userType'] == 'admin') { ?>
<li><a href="/portal/categories">Categories</a></li>
<li><a href="/portal/enquiries">Enquiries</a></li>
<li><a href="/portal/users">Users</a></li>
<?php } ?>
</ul>

10
todo
View File

@ -22,11 +22,11 @@ Assignment 2:
- see who has applied for jobs @done
- Client can only see their jobs @done
- Homepage has 10 jobs that are about to reach closing date @done
- Contact form on contact page
- forms store data in db
- stored enquiries can be accessed from admin panel
- can mark enquieries as Completed once admin has responded
- Keep list of all previous enquieries and which admin dealt with it
- Contact form on contact page @done
- forms store data in db @done
- stored enquiries can be accessed from admin panel @done
- can mark enquieries as Completed once admin has responded @done
- Keep list of all previous enquieries and which admin dealt with it @done
- Create entity classes for database entities (topic 18) @done
- page 37-38 for implementation @done
- Restrict categories by jobs available past current date @done