archive instead of delete

This commit is contained in:
Joshua Perry 2023-02-05 13:50:57 +00:00
parent dfc971f9c0
commit d8173208da
4 changed files with 24 additions and 9 deletions

View File

@ -9,6 +9,7 @@ class Job {
public $location; public $location;
public $categoryId; public $categoryId;
public $clientId; public $clientId;
public $archived;
private $catsTable; private $catsTable;
private $appsTable; private $appsTable;

View File

@ -14,7 +14,7 @@ class Jobs {
} }
public function home() { public function home() {
$this->vars['jobs'] = $this->jobsTable->find(["closingDate"], ['value0' => date('y-m-d')], ['>'], "DESC", "closingDate"); $this->vars['jobs'] = $this->jobsTable->find(["closingDate", 'archived'], ['value0' => date('y-m-d'), 'value1' => 'n'], ['>', '='], "DESC", "closingDate");
return ['template' => 'home.html.php', return ['template' => 'home.html.php',
'title' => 'Jo\'s Jobs- Home', 'title' => 'Jo\'s Jobs- Home',
'vars' => $this->vars 'vars' => $this->vars
@ -28,16 +28,17 @@ class Jobs {
} }
else { else {
if (isset($_GET['filter'])) { if (isset($_GET['filter'])) {
$columns = ['categoryId', "location", 'closingDate']; $columns = ['categoryId', "location", 'closingDate', 'archived'];
$values = ['value0' => $cat[0]->id, $values = ['value0' => $cat[0]->id,
'value1' => $_GET['filter'], 'value1' => $_GET['filter'],
'value2' => date('y-m-d') 'value2' => date('y-m-d'),
'value3' => 'n'
]; ];
$comparators = ["=","=",">"]; $comparators = ["=","=",">",'='];
$this->vars['jobs'] = $this->jobsTable->find($columns, $values, $comparators); $this->vars['jobs'] = $this->jobsTable->find($columns, $values, $comparators);
} }
else { else {
$this->vars['jobs'] = $this->jobsTable->find(['categoryId', 'closingDate'], ["value0" => $cat[0]->id, "value1" => date("y-m-d")], ["=", ">"]); $this->vars['jobs'] = $this->jobsTable->find(['categoryId', 'closingDate', 'archived'], ["value0" => $cat[0]->id, "value1" => date("y-m-d"), 'value2' => 'n'], ["=", ">", '=']);
} }
$this->vars['heading'] = $cat[0]->name; $this->vars['heading'] = $cat[0]->name;

View File

@ -41,9 +41,13 @@ class Portal {
if ($_POST['submit'] == "List") { if ($_POST['submit'] == "List") {
//TODO: Direct to edit job date //TODO: Direct to edit job date
} }
else { //TODO: Change to archive instead of delete else {
if (isset($_POST['job_id'])) { if (isset($_POST['job_id'])) {
$this->jobsTable->delete("id", $_POST['job_id']); $record = [
'id' => $_POST['job_id'],
'archived' => 'y'
];
$this->jobsTable->save($record);
return $this->home(); return $this->home();
} }
if (isset($_POST['cat_id'])) { if (isset($_POST['cat_id'])) {

View File

@ -15,6 +15,7 @@
<th>Title</th> <th>Title</th>
<th style="width: 15%">Salary</th> <th style="width: 15%">Salary</th>
<th>Category</th> <th>Category</th>
<th>Archived</th>
<th style="width: 5%">&nbsp;</th> <th style="width: 5%">&nbsp;</th>
<th style="width: 15%">&nbsp;</th> <th style="width: 15%">&nbsp;</th>
<th style="width: 5%">&nbsp;</th> <th style="width: 5%">&nbsp;</th>
@ -25,15 +26,23 @@
<td><?=$job->title?></td> <td><?=$job->title?></td>
<td><?=$job->salary?></td> <td><?=$job->salary?></td>
<td><?=$job->getCat()->name?></td> <td><?=$job->getCat()->name?></td>
<td>
<?php if ($job->archived == 'n') {
echo 'no';
}
if ($job->archived == 'y') {
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/edit?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 (date('y-m-d', strtotime($job->closingDate)) > date('y-m-d')) { ?> <?php if ($job->archived == 'n') { ?>
<input type="submit" name="submit" value="Archive" /> <input type="submit" name="submit" value="Archive" />
<?php } <?php }
else { ?> else if ($job->archived == 'y') { ?>
<input type="submit" name="submit" value="List" /> <input type="submit" name="submit" value="List" />
<?php } ?> <?php } ?>
</form> </form>