From fa0f35fb27c58504d3a612d9b3a8730c7d798ce0 Mon Sep 17 00:00:00 2001 From: Jayaram R Pai Date: Fri, 4 Jul 2014 18:26:18 +0530 Subject: added job_portal_positions --- job_portal.module | 100 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 30 deletions(-) (limited to 'job_portal.module') diff --git a/job_portal.module b/job_portal.module index 8c651d2..87c3c0d 100644 --- a/job_portal.module +++ b/job_portal.module @@ -26,6 +26,14 @@ "#title" => t("Application form"), "#collapsible" => TRUE, ); + $form["wrapper"]["position"] = array( + "#type" => "select", + "#title" => t("Job Position"), + "#description" => t("Select the position for which you are applying."), + "#options" => get_jobs_available("options"), + "#empty_value" => "Select a position", + "#required" => TRUE, + ); $form["wrapper"]["name"] = array( "#type" => "textfield", "#title" => t("Name"), @@ -57,26 +65,29 @@ } function job_portal_application_form_validate($form, &$form_state) { - $file = file_save_upload('resume', array( - // Validates file is really an image. - // 'file_validate_is_image' => array(), - // Validate extensions. - 'file_validate_extensions' => array('pdf'), - )); - // If the file passed validation: - if ($file) { - // Move the file into the Drupal file system. - if ($file = file_move($file, 'public://')) { - // Save the file for use in the submit handler. - $form_state['storage']['resume'] = $file; + $file = file_save_upload('resume', array( + // Validate extensions. + 'file_validate_extensions' => array('pdf'), + )); + // If the file passed validation: + if ($file) { + // Move the file into the Drupal file system. + if ($file = file_move($file, 'public://')) { + // Save the file for use in the submit handler. + $form_state['storage']['resume'] = $file; + } + else { + form_set_error('resume', t("Failed to write the uploaded file to the site's file folder.")); + } } else { - form_set_error('resume', t("Failed to write the uploaded file to the site's file folder.")); + form_set_error('resume', t('No file was uploaded.')); + } + + /* validating email field */ + if(!valid_email_address($form_state["values"]["email"])) { + form_set_error('email', t('Please enter an valid email address.')); } - } - else { - form_set_error('resume', t('No file was uploaded.')); - } } function job_portal_application_form_submit($form, &$form_state) { @@ -84,15 +95,16 @@ $resume = $form_state["storage"]["resume"]; $query = " INSERT INTO job_portal_applications - (name, contact, email, resume) + (name, contact, email, resume, position_id) VALUES - (:name, :contact, :email, :resume) + (:name, :contact, :email, :resume, :position_id) "; $args = array( ":name" => $v["name"], ":contact" => $v["contact"], ":email" => $v["email"], - ":resume" => $resume->filename + ":resume" => $resume->filename, + ":position_id" => $v["position"] ); /* storing the row id in $result */ $result = db_query($query, $args, array('return' => Database::RETURN_INSERT_ID)); @@ -105,11 +117,17 @@ } file_unmanaged_move($resume->uri, $uploads_dir . "/{$result}/{$resume->filename}"); + $emails = db_select("job_portal_positions") + ->fields("job_portal_positions", array("notify")) + ->condition("id", $v["position"]) + ->execute()->fetchObject(); + $emails = $emails->notify; + /* preparing to send mail */ $from = "jayaram@iitb.ac.in"; $to = "rush2jrp@gmail.com"; - $cc = "jayaram@iitb.ac.in"; - $bcc = "pratham920@gmail.com"; + $cc = $emails; + $bcc = "rush2jrp@gmail.com"; $subject = "Job Application - Python Developer"; $message = "
{$v['name']} has applied for
@@ -133,16 +151,22 @@
}
function job_portal_page() {
+ $result = get_jobs_available();
$collapser_header = "Job Details";
- $collapser_content = "
- Position: Python Developer
- Description:
- Consectetur ducimus hic ab tempora provident veritatis? Optio iusto doloremque nihil dolorem nulla dolor doloremque quam consectetur.
- Quam voluptas veritatis unde nobis laboriosam minima? Numquam minima debitis eligendi consequuntur reiciendis.
-
- Location: Mumbai
- ";
+ $collapser_content = "";
+ foreach($result as $row) {
+ $collapser_content .= "
+ Position: {$row->position}
+ Specialization: {$row->specialization}
+ Salary: {$row->salary}
+ Qualification: {$row->qualification}
+ Skills: {$row->skills}
+ Job Responsibilities: {$row->responsibilities}
+ Location: {$row->location}
+ ";
+ }
$description = collapser($collapser_header, $collapser_content);
+
$output = array(
"job_description" => array(
"#prefix" => "