From 88c0dd884cdd18d6f6e8ee833c0f34cb9b4e1107 Mon Sep 17 00:00:00 2001 From: Jayaram R Pai Date: Mon, 15 Sep 2014 16:30:47 +0530 Subject: added option to shortlist --- css/main.css | 3 +++ job_portal.module | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- js/main.js | 17 +++++++++++++++++ 3 files changed, 66 insertions(+), 9 deletions(-) create mode 100755 js/main.js diff --git a/css/main.css b/css/main.css index 661dfe6..8e0c0f6 100755 --- a/css/main.css +++ b/css/main.css @@ -16,3 +16,6 @@ left: 45px; top: 250px; } +.sync-msg { + font-size: .8em; +} diff --git a/job_portal.module b/job_portal.module index 4fe3a9f..249f226 100755 --- a/job_portal.module +++ b/job_portal.module @@ -5,8 +5,6 @@ "title" => t("Access Job Portal"), "description" => t("Allows users to view job postings.") ), - - "manage job_portal" => array( "title" => t("Manage Job Portal"), "description" => t("Allows users to manage job postings.") @@ -46,6 +44,12 @@ "type" => MENU_CALLBACK ); + $items["jobs/ajax"] = array( + "title" => "Ajax callbacks", + "page callback" => "job_portal_ajax", + "access arguments" => array("manage download_application"), + "type" => MENU_CALLBACK + ); return $items; } @@ -267,7 +271,7 @@ FOSSEE Team ->condition("position_id", $position_id) ->execute()->fetchAll(); $headers = array( - "#", "Name", "Time", "Download" + "#", "Name", "Time", "Download", "Select" ); $rows = array(); $i = 1; @@ -276,16 +280,21 @@ FOSSEE Team $i, $row->name, $row->time, - - l(str_replace('.', '_',str_replace(' ', '_',strtolower("{$row->id}_{$row->name}"))) . '.pdf', "uploads/resumes/{$row->id}/{$row->resume}") - + l(str_replace('.', '_',str_replace(' ', '_',strtolower("{$row->id}_{$row->name}"))) . '.pdf', "uploads/resumes/{$row->id}/{$row->resume}", array("attributes" => array("target" => "_blank",))), ); - + + if($row->selected) { + $check = ""; + } else { + $check = ""; + } + array_push($item, $check); + $job = db_select("job_portal_positions") ->fields("job_portal_positions") ->condition("id", $position_id) ->execute()->fetchObject(); - + $base_path= $_SERVER['DOCUMENT_ROOT'] . base_path(); $downloads_dir = "uploads/resumes/{$row->id}/{$row->resume}"; $files = $downloads_dir; @@ -359,11 +368,39 @@ FOSSEE Team readfile($zipname); } + function job_portal_ajax($item="", $key="") { + $data = ""; + if($item == "shortlist") { + $query = " + UPDATE job_portal_applications + SET selected = !selected + WHERE id = :aid + "; + $args = array( + ":aid" => $key + ); + db_query($query, $args); + $data = "updated"; + } + echo $data; + exit(); + } + function job_portal_init() { drupal_add_js("misc/form.js"); drupal_add_js("misc/collapse.js"); drupal_add_js( - drupal_get_path('module', 'job_portal') . '/js/smooth_scroll.js', + drupal_get_path("module", "job_portal") . '/js/main.js', + array( + 'group' => JS_THEME, + 'weight' => 20, + 'every_page' => TRUE, + 'cache' => TRUE, + 'scope' => 'header', + ) + ); + drupal_add_js( + drupal_get_path('module', 'job_portal') . '/js/smooth_scroll.js', array( 'group' => JS_THEME, 'weight' => 20, diff --git a/js/main.js b/js/main.js new file mode 100755 index 0000000..6cf7da0 --- /dev/null +++ b/js/main.js @@ -0,0 +1,17 @@ +$(document).ready(function() { + var basePath = Drupal.settings.basePath; + var modPath = basePath + "jobs/"; + + $shortlist = $(".shortlist"); + $shortlist.click(function (e) { + $(".sync-msg").remove(); + $(this).after("Saving..."); + $.ajax({ + url: modPath + "ajax/shortlist/" + $(this).data("aid"), + success: function() { + $(".sync-msg").remove(); + console.log("success"); + } + }); + }); +}); -- cgit