better addjob
This commit is contained in:
parent
7e29e9c8b4
commit
27d8600ea8
|
|
@ -40,7 +40,9 @@ class Portal {
|
|||
public function homeSubmit() {
|
||||
if ($_POST['submit'] == "List") {
|
||||
$this->vars['job'] = $this->jobsTable->find(['id'], ['value0' => $_POST['job_id']])[0];
|
||||
return ['template' => 'job_edit.html.php',
|
||||
$this->vars['archive'] = true;
|
||||
$this->vars['update'] = true;
|
||||
return ['template' => 'job_add.html.php',
|
||||
'title' => 'Jo\'s Jobs- Update Job',
|
||||
'vars' => $this->vars];
|
||||
}
|
||||
|
|
@ -55,20 +57,17 @@ class Portal {
|
|||
}
|
||||
if (isset($_POST['cat_id'])) {
|
||||
$this->catsTable->delete("id", $_POST['cat_id']);
|
||||
$jobs = $this->jobsTable->find(['categoryId'], ['value0' => $_POST['cat_id']]);
|
||||
foreach ($jobs as $job) {
|
||||
$this->jobsTable->delete("id", $job->id);
|
||||
}
|
||||
return $this->categories();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function secondHomeSubmit() {
|
||||
if(isset($_POST['archived'])) {
|
||||
$record = [
|
||||
'id' => $_POST['jobId'],
|
||||
'closingDate' => $_POST['closingDate'],
|
||||
'archived' => $_POST['archived']
|
||||
];
|
||||
$this->jobsTable->save($record);
|
||||
}
|
||||
|
||||
$this->vars['response'] = 'Update successful';
|
||||
return ['template' => 'response.html.php',
|
||||
'title' => 'Jo\'s Jobs- Success',
|
||||
|
|
@ -97,15 +96,21 @@ class Portal {
|
|||
}
|
||||
|
||||
public function edit() { //TODO: finish this function
|
||||
if (isset($_GET['job_id'])) {
|
||||
$this->vars['job'] = $this->jobsTable->find(["id"], ['value0' => $_GET['job_id']]);
|
||||
}
|
||||
if (isset($_GET['cat_id'])) {
|
||||
$this->vars['cat'] = $this->catsTable->find(["id"], ['value0' => $_GET['cat_id']]);
|
||||
}
|
||||
}
|
||||
|
||||
public function addJob() {
|
||||
if (isset($_GET['job_id'])) {
|
||||
$this->vars['job'] = $this->jobsTable->find(["id"], ['value0' => $_GET['job_id']])[0];
|
||||
$this->vars['archive'] = false;
|
||||
$this->vars['update'] = true;
|
||||
}
|
||||
else {
|
||||
$this->vars['archive'] = false;
|
||||
$this->vars['update'] = false;
|
||||
}
|
||||
return ['template' => 'job_add.html.php',
|
||||
'title' => 'Jo\'s Jobs- Add Job',
|
||||
'vars' => $this->vars
|
||||
|
|
@ -113,7 +118,7 @@ class Portal {
|
|||
}
|
||||
|
||||
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) {
|
||||
if ($this->catsTable->find(['name'], ['value0' => $_POST['categoryName']]) != 0) {
|
||||
$record = [
|
||||
'title' => $_POST['title'],
|
||||
'description' => $_POST['description'],
|
||||
|
|
@ -121,17 +126,26 @@ class Portal {
|
|||
'closingDate' => $_POST['closingDate'],
|
||||
'categoryId' => $this->catsTable->find(['name'], ['value0' => $_POST['categoryName']])[0]->id,
|
||||
'location' => $_POST['location'],
|
||||
'clientId' => $_POST['client_id']
|
||||
'clientId' => $_POST['client_id'],
|
||||
'archived' => $_POST['archived']
|
||||
];
|
||||
|
||||
if ($_POST['submit'] == 'Create' && count($this->jobsTable->find(['title', 'clientId'], ['value0' => $_POST['title'], 'value1' => $_POST['client_id']])) == 0) {
|
||||
$this->jobsTable->save($record);
|
||||
$this->vars['response'] = 'Job made successfully';
|
||||
}
|
||||
else if ($_POST['submit'] == 'Update') {
|
||||
$record['id'] = $_POST['jobId'];
|
||||
$this->jobsTable->save($record);
|
||||
$this->vars['response'] = 'Job updated successfully';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->vars['response'] = 'Some data was incorrect';
|
||||
}
|
||||
|
||||
return ['template' => 'response.html.php',
|
||||
'title' => 'Jo\'s Jobs- Add Job',
|
||||
'title' => 'Jo\'s Jobs- Edit Job',
|
||||
'vars' => $this->vars
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<td><a style="float: right" href="/portal/edit?cat_id=<?=$cat->id?>">Edit</a></td>
|
||||
<td><form method="post" action="/portal/">
|
||||
<input type="hidden" name="cat_id" value="<?=$cat->id?>" />
|
||||
<input type="submit" name="submit" value="Archive" />
|
||||
<input type="submit" name="submit" value="Delete" />
|
||||
</form></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,29 @@
|
|||
<main class="home">
|
||||
<form method="post" action="/portal/addJob">
|
||||
<?php if ($archive) { ?>
|
||||
<input type="hidden" name="archived" value="n"/>
|
||||
<?php }
|
||||
else { ?>
|
||||
<input type="hidden" name="archived" value="<?=$job->archived?>"/>
|
||||
<?php }
|
||||
if ($update) {?>
|
||||
<label>Enter Job Title</label>
|
||||
<input type="text" name="title" value="<?=$job->title?>"/>
|
||||
<label>Enter Job Description</label>
|
||||
<input type="text" name="description" value="<?=$job->description?>"/>
|
||||
<label>Enter Salary</label>
|
||||
<input type="text" name="salary" value="<?=$job->salary?>"/>
|
||||
<label>Enter Closing Date</label>
|
||||
<input type="date" name="closingDate" value="<?=$job->closingDate?>"/>
|
||||
<label>Enter Category Name</label>
|
||||
<input type="text" name="categoryName" value="<?=$job->getCat()->name?>"/>
|
||||
<label>Enter Location</label>
|
||||
<input type="text" name="location" value="<?=$job->location?>"/>
|
||||
<input type="hidden" name="client_id" value="<?=$job->clientId?>" />
|
||||
<input type="hidden" name="jobId" value="<?=$job->id?>"/>
|
||||
<input type="submit" name="submit" value="Update"/>
|
||||
<?php }
|
||||
else { ?>
|
||||
<label>Enter Job Title</label>
|
||||
<input type="text" name="title"/>
|
||||
<label>Enter Job Description</label>
|
||||
|
|
@ -14,5 +38,6 @@
|
|||
<input type="text" name="location"/>
|
||||
<input type="hidden" name="client_id" value="<?=$_SESSION['loggedin']?>" />
|
||||
<input type="submit" name="submit" value="Create"/>
|
||||
<?php } ?>
|
||||
</form>
|
||||
</main>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<main class="home">
|
||||
<h2>Update <?=$job->title?></h2>
|
||||
<form method="post" action="/portal/secondHome">
|
||||
<?php if ($job->archived == 'y') { ?>
|
||||
<label>Enter new Closing Date</label>
|
||||
<input type="date" name="closingDate"/>
|
||||
<input type="hidden" name="archived" value="n"/>
|
||||
<input type="hidden" name="jobId" value="<?=$job->id?>"/>
|
||||
<?php } ?>
|
||||
<input type="submit" name="submit" value="Update"/>
|
||||
</form>
|
||||
</main>
|
||||
|
|
@ -34,10 +34,10 @@
|
|||
echo 'yes';
|
||||
} ?>
|
||||
</td>
|
||||
<td><a style="float: right" href="portal/edit?job_id=<?=$job->id?>">Edit</a></td>
|
||||
<td><a style="float: right" href="portal/addJob?job_id=<?=$job->id?>">Edit</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/">
|
||||
<form method="post" action="portal">
|
||||
<input type="hidden" name="job_id" value="<?=$job->id?>" />
|
||||
<?php if ($job->archived == 'n') { ?>
|
||||
<input type="submit" name="submit" value="Archive" />
|
||||
|
|
|
|||
2
todo
2
todo
|
|
@ -16,7 +16,7 @@ Assignment 2:
|
|||
- Relist archived jobs with new closing date @done
|
||||
- Add admin user control to admin portal
|
||||
- User accounts made in admin portal
|
||||
- Client user accounts
|
||||
- Client user accounts @done
|
||||
- restricted admin panel @done
|
||||
- add and archive jobs @done
|
||||
- see who has applied for jobs @done
|
||||
|
|
|
|||
Loading…
Reference in New Issue