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