1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
<?php
function dash_fatal ($msg = null, $link = null, $label = null) {
if ($link === null) $link = 'javascript:history.go(-1);';
if ($label == null) $label = '← Got It';
echo tpl(array('message' => $msg, 'link' => $link, 'label' => $label), 'dash_fatal.tpl').PHP_EOL;
require('footer.php');
die;
}
function typestr ($type) {
switch ($type) {
case 'EMPLOYER':
return 'Employer';
case 'EMPLOYEE':
return 'Employee';
default:
return 'Team Member';
}
}
function rating_format ($rating = null, $typestr = 'Employer') {
if (is_null($rating)) return $typestr.' Not Rated';
return number_format($rating, 1).' Star '.$typestr;
}
function draw_noads () {
?>
<div class="job">
<p class="jobtitle"><a href="post.php">Post an Ad!</a></p>
<p class="jobpay">It's FREE!</p>
<p class="jobblurb">You haven't posted any ads yet! It's a quick and easy way to get connected to the workers you need.<br /><a href="post.php">Post an ad!</a></p>
</div>
<?php
}
function draw_noapps () {
?>
<div class="job">
<p class="jobtitle"><a href="post.php">No Applications Yet!</a></p>
<p class="jobpay">Post another ad. It's FREE!</p>
<p class="jobblurb">This ad hasn't received any responses yet. In the meantime, be sure to post more to maximize your exposure.<br /><a href="post.php">Post an ad!</a></p>
</div>
<?php
}
function draw_ad ($row) {
?>
<div class="job">
<a href="#" class="jobxbtn"></a>
<p class="jobtitle"><a href="ads.php?id=<?=$row['id'];?>"><?=htmlentities($row['title']);?></a></p>
<?php
if (is_null($row['cat_name']))
echo ' <p class="jobcat">Uncategorized</p>'.PHP_EOL;
else
echo ' <p class="jobcat">'.htmlentities($row['cat_name']).'</p>'.PHP_EOL;
?>
<p class="joblocation"><?=htmlentities($row['location']);?></p>
<p class="jobstars"><?=rating_format($row['rating']);?></p>
<p class="jobpay">Pays $<?=number_format($row['pay'], 2);?></p>
<p class="jobblurb"><?=htmlentities(substr($row['description'], 0, min(strlen($row['description']), 160)));?> <a href="ads.php?id=<?=$row['id'];?>">[...]</a></p>
</p>
</div>
<?php
}
function draw_app ($row) {
?>
<div class="job">
<a href="#" class="appxbtn"></a>
<p class="jobtitle"><a href="review.php?id=<?=$row['id'];?>"><?=htmlentities($row['name']);?></a></p>
<p class="jobstars"><?=rating_format($row['rating'], 'Employee');?></p>
<p class="joblocation"><?=htmlentities($row['address']);?></p>
<p class="jobblurb"><?=htmlentities(substr($row['comment'], 0, min(strlen($row['comment']), 160)));?> <a href="review.php?id=<?=$row['id'];?>">[...]</a></p>
</p>
</div>
<?php
}
// triggers
function app_trigger ($responseid) {
global $db;
$result = $db->query('SELECT responses.id, responses.uid AS seeker, responses.adid, responses.comment, ads.title, users.name, users.email, users.notify FROM responses INNER JOIN ads ON responses.adid = ads.id INNER JOIN users ON ads.uid = users.id WHERE responses.id = '.$responseid.' LIMIT 1') or dash_fatal($db->error);
if ($result->num_rows < 1) dash_fatal('The ad you\'ve tried to apply to no longer exists.');
$appinfo = $result->fetch_assoc();
$result->free();
if (!$appinfo['notify']) return;
$result = $db->query('SELECT users.name, users.email, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM users LEFT JOIN ratings ON ratings.rated = users.id WHERE users.id = '.$appinfo['seeker'].' LIMIT 1') or dash_fatal($db->error);
$uinfo = $result->fetch_assoc();
$result->free();
$options = array(
'rid' => $appinfo['id'],
'adname' => $appinfo['title'],
'seekername' => $uinfo['name'],
'seekerrating' => is_null($uinfo['rating']) ? 'has yet to be rated' : 'is rated '.number_format($uinfo['rating'], 1).' stars',
'seekereml' => $uinfo['email'],
'seekerid' => $appinfo['seeker'],
);
bulletin_mail($appinfo['email'], '"'.$appinfo['title'].'" Has Received a Response', tpl($options, 'app_eml.tpl'));
}
?>
|