diff options
| author | Carson Fleming <cflems@cflems.net> | 2017-04-09 18:55:38 -0400 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2017-04-09 18:55:38 -0400 |
| commit | 37ef17fd2904e49d966ed0922871f675ceb384c0 (patch) | |
| tree | ee585ad1ec45ed93c9a2122c18ebf82698ea8eae /dash | |
| parent | 59d9ab47a3c2a30f4130efdb38466edcfd1fb3a8 (diff) | |
| download | bulletin-37ef17fd2904e49d966ed0922871f675ceb384c0.tar.gz | |
Rearrange ratings tab
Diffstat (limited to 'dash')
| -rw-r--r-- | dash/css/dash.css | 13 | ||||
| -rw-r--r-- | dash/css/jobs.css | 40 | ||||
| -rw-r--r-- | dash/dash_functions.php | 26 | ||||
| -rw-r--r-- | dash/headless.php | 3 | ||||
| -rw-r--r-- | dash/jobs.php (renamed from dash/rate.php) | 12 | ||||
| -rw-r--r-- | dash/js/dash.js | 7 | ||||
| -rw-r--r-- | dash/nav.php | 8 |
7 files changed, 88 insertions, 21 deletions
diff --git a/dash/css/dash.css b/dash/css/dash.css index 6e625a4..5af19f1 100644 --- a/dash/css/dash.css +++ b/dash/css/dash.css @@ -384,15 +384,26 @@ h3 a:hover, h4 a:hover { .adtrash:hover { background-image: url('../img/trash_hover.png'); } -.rate-widget { +.rate-widget .stars { display: flex; flex-direction: row; justify-content: center; } +.rate-widget .typereview { + margin: 0.25em auto; + width: 400px; + height: 120px; + border: 1px solid #dddddd; + border-radius: 5px; + padding: 5px; + resize: none; +} .ratebtn { margin: auto 5px; cursor: pointer; + height: 48px; } .ratebtn:hover { background-image: url('../img/star_given.png'); + background-size: contain; } diff --git a/dash/css/jobs.css b/dash/css/jobs.css new file mode 100644 index 0000000..fa2a70e --- /dev/null +++ b/dash/css/jobs.css @@ -0,0 +1,40 @@ +.israted::before { + content: ''; + display: inline-block; + width: 12px; + height: 12px; + background-size: contain; + background-position: center center; + background-repeat: no-repeat; + margin-right: 3px; +} +.job.rated .israted::before { + background-image: url('../img/check_hover.png'); +} +.job.unrated .israted::before { + background-image: url('../img/check_blank.png'); +} +.israted { + font-weight: bold; +} +.jobtitle a { + font-weight: normal; + font-style: italic; +} +.jobblurb { + text-align: center; +} +.ratingdata { + height: 32px; +} +.star { + height: 32px !important; + width: 32px !important; +} +.ratecomment { + margin: 1em 0 0 0; + padding: 1em; + background-color: #ffffff; + border-radius: 5px; + box-shadow: 0px 0px 4px rgba(0,0,0,0.75); +} diff --git a/dash/dash_functions.php b/dash/dash_functions.php index 9c106eb..7fa9c3e 100644 --- a/dash/dash_functions.php +++ b/dash/dash_functions.php @@ -22,18 +22,18 @@ function rating_format ($rating = null, $typestr = 'Employer') { function draw_norate_p () { ?> <div class="job"> - <p class="jobtitle"><a href="post.php">Nothing to Rate Yet!</a></p> + <p class="jobtitle"><a href="post.php">You have no jobs yet!</a></p> <p class="jobpay">Post another ad. It's FREE!</p> - <p class="jobblurb">None of your ads have received a response since you last visited. In the meantime, be sure to post more to maximize your exposure.<br /><a href="post.php">Post an ad!</a></p> + <p class="jobblurb">You haven't approved any applications yet. Be sure to post often to maximize your exposure.<br /><a href="post.php">Post an ad!</a></p> </div> <?php } function draw_norate_s () { ?> <div class="job"> - <p class="jobtitle"><a href="post.php">Nothing to Rate Yet!</a></p> + <p class="jobtitle"><a href="post.php">You have no jobs yet!</a></p> <p class="jobpay">Apply to more ads. It's FREE!</p> - <p class="jobblurb">None of your applications have received a response since you last visited. In the meantime, be sure to reply to more job postings maximize your exposure.<br /><a href="dash/">Browse ads!</a></p> + <p class="jobblurb">None of your applications have been approved yet. In the meantime, be sure to reply to more job postings maximize your exposure.<br /><a href="dash/">Browse ads!</a></p> </div> <?php } @@ -55,13 +55,27 @@ function draw_noapps () { </div> <?php } -function draw_rate ($row) { +function draw_rate ($row, $review) { ?> - <div class="job"> + <div class="job<?=is_null($review)?' unrated':' rated';?>"> + <p class="israted"><?=is_null($review)?'Job Pending':'Job Complete';?></p> <p class="jobtitle"><a href="ads.php?id=<?=$row['adid'];?>"><?=htmlentities($row['title']);?></a></p> <p class="jobpay">Provided by <a href="profile.php?id=<?=$row['uid'];?>"><?=htmlentities($row['name']);?></a></p> <p class="jobdate"><?=date('M j, Y', intval($row['time']));?></p> +<?php + if (!is_null($review)) { +?> + <div class="jobblurb"> + <?=rating_format($review['stars'], typestr($row['type']));?> + <div class="ratecomment"><?=is_null($review['comment'])?'<em>No comment.</em>':htmlentities($review['comment']);?></div> + </div> +<?php + } else { +?> <div class="jobblurb"><div class="rate-widget" data-uid="<?=$row['uid'];?>" data-jid="<?=$row['adid'];?>" data-rating="<?=is_null($row['rating']) ? 'undef' : number_format($row['rating'], 1);?>"></div></div> +<?php + } +?> </div> <?php } diff --git a/dash/headless.php b/dash/headless.php index 0312f5d..ac20748 100644 --- a/dash/headless.php +++ b/dash/headless.php @@ -33,10 +33,11 @@ if (isset($_GET['clicks'])) { $uid = intval($_GET['rate']); $jid = intval($_GET['jid']); $val = intval($_GET['val']); + $txt = $db->escape_string($_GET['txt']); if ($uid < 1 || $jid < 1 || $val < 1) die('NOK'); $result = $db->query('SELECT ads.id FROM ads INNER JOIN responses ON responses.adid = ads.id AND responses.matched = 1 INNER JOIN users ON users.id = responses.uid LEFT JOIN ratings ON ratings.rated = users.id WHERE ads.id = '.$jid.' AND (ads.uid = '.$b_user['id'].' OR responses.uid = '.$b_user['id'].') AND NOT EXISTS (SELECT ratings.id FROM ratings WHERE ratings.rated = responses.uid AND ratings.job = ads.id AND ratings.rater = '.$b_user['id'].') GROUP BY responses.id LIMIT 1') or die('ERR'); if ($result->num_rows < 1) die('NOK'); - $db->query('INSERT INTO ratings (rated, rater, job, stars) VALUES ('.$uid.', '.$b_user['id'].', '.$jid.', '.$val.')') or die('ERR'); + $db->query('INSERT INTO ratings (rated, rater, job, stars, comment) VALUES ('.$uid.', '.$b_user['id'].', '.$jid.', '.$val.', \''.$txt.'\')') or die('ERR'); if ($db->affected_rows < 1) die('NOK'); die('OK'); } diff --git a/dash/rate.php b/dash/jobs.php index 767d4ba..db473cb 100644 --- a/dash/rate.php +++ b/dash/jobs.php @@ -3,22 +3,22 @@ define('HEIRARCHY', 1); require('dash_common.php'); $title = 'Rate / Bulletin'; +$extra_head = '<link rel="stylesheet" type="text/css" href="css/jobs.css" />'; require('header.php'); if ($b_user['type'] == 'EMPLOYER') { - $result = $db->query('SELECT users.id AS uid, users.name, ads.id AS adid, ads.title, ads.time, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM ads INNER JOIN responses ON responses.adid = ads.id AND responses.matched = 1 INNER JOIN users ON users.id = responses.uid LEFT JOIN ratings ON ratings.rated = users.id WHERE ads.uid = '.$b_user['id'].' AND NOT EXISTS (SELECT ratings.id FROM ratings WHERE ratings.rated = responses.uid AND ratings.job = ads.id AND ratings.rater = '.$b_user['id'].') GROUP BY responses.id') or dash_fatal($db->error); + $result = $db->query('SELECT users.id AS uid, users.name, ads.id AS adid, ads.title, ads.time, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM ads INNER JOIN responses ON responses.adid = ads.id AND responses.matched = 1 INNER JOIN users ON users.id = responses.uid LEFT JOIN ratings ON ratings.rated = users.id WHERE ads.uid = '.$b_user['id'].' GROUP BY responses.id ORDER BY rated ASC') or dash_fatal($db->error); if ($result->num_rows < 1) draw_norate_p(); } else if ($b_user['type'] == 'EMPLOYEE') { - $result = $db->query('SELECT users.id AS uid, users.name, ads.id AS adid, ads.title, ads.time, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM ads INNER JOIN responses ON responses.adid = ads.id AND responses.matched = 1 INNER JOIN users ON users.id = ads.uid LEFT JOIN ratings ON ratings.rated = users.id WHERE responses.uid = '.$b_user['id'].' AND NOT EXISTS (SELECT ratings.id FROM ratings WHERE ratings.rated = ads.uid AND ratings.job = ads.id AND ratings.rater = '.$b_user['id'].') GROUP BY responses.id') or dash_fatal($db->error); + $result = $db->query('SELECT users.id AS uid, users.name, ads.id AS adid, ads.title, ads.time, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM ads INNER JOIN responses ON responses.adid = ads.id AND responses.matched = 1 INNER JOIN users ON users.id = ads.uid LEFT JOIN ratings ON ratings.rated = users.id WHERE responses.uid = '.$b_user['id'].' GROUP BY responses.id ORDER BY rated ASC') or dash_fatal($db->error); if ($result->num_rows < 1) draw_norate_s(); } else dash_fatal('Only job seekers and job providers can rate one another.'); while ($row = $result->fetch_assoc()) { - draw_rate($row); + $review = $db->query('SELECT ratings.stars, ratings.comment FROM ratings WHERE ratings.rated = '.$row['uid'].' AND ratings.job = '.$row['adid'].' AND ratings.rater = '.$b_user['id'].' LIMIT 1'); + draw_rate($row, $review->fetch_assoc()); + $review->free(); } $result->free(); -?> - -<?php require('footer.php'); ?> diff --git a/dash/js/dash.js b/dash/js/dash.js index 7eb10c0..2cd6fe6 100644 --- a/dash/js/dash.js +++ b/dash/js/dash.js @@ -62,18 +62,19 @@ function ratewidget (idx, me) { var $me = $(me); var rating = parseFloat($me.attr('data-rating')); if (!rating) rating = 0; - var html = ''; + var html = '<div><textarea class="typereview" maxlength="250" placeholder="Reflect on your experience (250 characters)..."></textarea></div><div class="stars">'; for (var i = 1; i <= rating; i++) html += '<img class="ratebtn" src="img/star_given.png" alt="Full Star" />'; if (rating-Math.floor(rating) >= 0.5) html += '<img class="ratebtn" src="img/star_half.png" alt="Half Star" />' i += Math.round(rating-Math.floor(rating)); for (; i <= 5; i++) html += '<img class="ratebtn" src="img/star_empty.png" alt="No Star" />'; + html += '</html>'; $me.html(html); $.each($me.find('.ratebtn'), function (idx, obj) { $(obj).click(function (e) { e.preventDefault(); console.log('Clicked '+(idx+1)); - $.get('headless.php?rate='+$me.attr('data-uid')+'&jid='+$me.attr('data-jid')+'&val='+(idx+1), function (data) { - if (data == 'OK') $me.parents().filter('.job').hide(250); + $.get('headless.php?rate='+$me.attr('data-uid')+'&jid='+$me.attr('data-jid')+'&val='+(idx+1)+'&txt='+$me.find('.typereview').val(), function (data) { + if (data == 'OK') window.location.reload(); else window.alert('The server encountered an error submitting your rating. We\'re sorry for the inconvenience.'); }); }); diff --git a/dash/nav.php b/dash/nav.php index bb01532..6d82439 100644 --- a/dash/nav.php +++ b/dash/nav.php @@ -1,11 +1,11 @@ <?php if (!defined('ACC_TYPE')) die; if (ACC_TYPE == 'EMPLOYEE') { - $navtitles = array('Dashboard', 'Help', 'Rate'); - $navlinks = array('dash/', 'dash/help.php', 'dash/rate.php'); + $navtitles = array('Dashboard', 'Help', 'My Jobs'); + $navlinks = array('dash/', 'dash/help.php', 'dash/jobs.php'); } else if (ACC_TYPE == 'EMPLOYER') { - $navtitles = array('Dashboard', 'Help', 'Rate', 'Post'); - $navlinks = array('dash/', 'dash/help.php', 'dash/rate.php', 'dash/post.php'); + $navtitles = array('Dashboard', 'Help', 'My Jobs', 'Post'); + $navlinks = array('dash/', 'dash/help.php', 'dash/jobs.php', 'dash/post.php'); } else if (ACC_TYPE == 'ADMIN') { $navtitles = array(); $navlinks = array(); |
