adding jobs now works

This commit is contained in:
Joshua Perry 2023-02-05 12:55:06 +00:00
parent c7bd30da52
commit 48508fc429
7 changed files with 47 additions and 12 deletions

View File

@ -77,9 +77,32 @@ class Portal {
} }
} }
//TODO: add functions for adding jobs and categories
public function addJob() { public function addJob() {
return ['template' => 'add.html.php', return ['template' => 'job_add.html.php',
'title' => 'Jo\'s Jobs- Add Job',
'vars' => $this->vars
];
}
public function addJobSubmit() {
if (count($this->jobsTable->find(['title', 'clientId'], ['value0' => $_POST['title'], 'value1' => $_POST['client_id']])) == 0 && $this->catsTable->find(['name'], ['value0' => $_POST['categoryName']]) != 0) {
$record = [
'title' => $_POST['title'],
'description' => $_POST['description'],
'salary' => $_POST['salary'],
'closingDate' => $_POST['closingDate'],
'categoryId' => $this->catsTable->find(['name'], ['value0' => $_POST['categoryName']])[0]->id,
'location' => $_POST['location'],
'clientId' => $_POST['client_id']
];
$this->jobsTable->save($record);
$this->vars['response'] = 'Job made successfully';
}
else {
$this->vars['response'] = 'Some data was incorrect';
}
return ['template' => 'response.html.php',
'title' => 'Jo\'s Jobs- Add Job', 'title' => 'Jo\'s Jobs- Add Job',
'vars' => $this->vars 'vars' => $this->vars
]; ];

View File

@ -1,6 +0,0 @@
<main class="home">
<form>
<!-- TODO: Create form for adding a job -->
<!-- Look in to generifying for all add types -->
</form>
</main>

View File

@ -13,7 +13,7 @@
<td><a style="float: right" href="/portal/edit?cat_id=<?=$cat->id?>">Edit</a></td> <td><a style="float: right" href="/portal/edit?cat_id=<?=$cat->id?>">Edit</a></td>
<td><form method="post" action="/portal/"> <td><form method="post" action="/portal/">
<input type="hidden" name="cat_id" value="<?=$cat->id?>" /> <input type="hidden" name="cat_id" value="<?=$cat->id?>" />
<input type="submit" name="submit" value="Delete" /> <input type="submit" name="submit" value="Archive" />
</form></td> </form></td>
</tr> </tr>
<?php } ?> <?php } ?>

View File

@ -0,0 +1,18 @@
<main class="home">
<form method="post" action="/portal/addJob">
<label>Enter Job Title</label>
<input type="text" name="title"/>
<label>Enter Job Description</label>
<input type="text" name="description"/>
<label>Enter Salary</label>
<input type="text" name="salary"/>
<label>Enter Closing Date</label>
<input type="date" name="closingDate"/>
<label>Enter Category Name</label>
<input type="text" name="categoryName"/>
<label>Enter Location</label>
<input type="text" name="location"/>
<input type="hidden" name="client_id" value="<?=$_SESSION['loggedin']?>" />
<input type="submit" name="submit" value="Create"/>
</form>
</main>

View File

@ -29,7 +29,7 @@
<td><a style="float: right" href="portal/applicants?job_id=<?=$job->id?>">View applicants (<?=count($job->getApps())?>)</a></td> <td><a style="float: right" href="portal/applicants?job_id=<?=$job->id?>">View applicants (<?=count($job->getApps())?>)</a></td>
<td><form method="post" action="portal/"> <td><form method="post" action="portal/">
<input type="hidden" name="job_id" value="<?=$job->id?>" /> <input type="hidden" name="job_id" value="<?=$job->id?>" />
<input type="submit" name="submit" value="Delete" /> <input type="submit" name="submit" value="Archive" />
</form></td> </form></td>
</tr> </tr>
<?php } ?> <?php } ?>

View File

@ -8,7 +8,7 @@
<label>Enter Password</label> <label>Enter Password</label>
<input type="password" name="password" /> <input type="password" name="password" />
<input type="submit" name="submit"/> <input type="submit" name="submit" value="Log In" />
</form> </form>
</main> </main>
<p><?=nl2br($response)?></p> <p><?=nl2br($response)?></p>

2
todo
View File

@ -11,7 +11,7 @@ Assignment 2:
- Add filter to be able to filter by cat @done - Add filter to be able to filter by cat @done
- Allow customers to filter by location @done - Allow customers to filter by location @done
- Move new framework into project @done - Move new framework into project @done
- Fix Adding categories - Fix Adding categories @done
- Archive jobs instead of delete - Archive jobs instead of delete
- Add admin user control to admin portal - Add admin user control to admin portal
- User accounts made in admin portal - User accounts made in admin portal