RedJumpsuit

jobberBase custom development and support

Send Photo on Apply Now

i have seen this request come up in the jobberBase forum here and there, so today i had the time to put together a how-to which will allow the applicants to send a photo of themselves when they send their resume on the job they are applying to.

so here it goes…

1) On /_includes/translations.ini, add under [apply]

photo_label = "Photo"
photo_error = "Photo size exceeds limit."
photo_info = "Accepts only *.jpg, *.gif and *.png"

2) /_templates/default/job-details.tpl, under this block:

<tr>
	<td valign="top"><label for="apply_cv">{$translations.apply.cv_label}:</label></td>
	<td>
		<input type="file" name="apply_cv" id="apply_cv" />
		<span class="validation-error">{if $smarty.session.apply_errors.apply_cv}<img src="{$BASE_URL}_templates/{$THEME}/img/icon-delete.png" alt="" title="{$smarty.session.apply_errors.apply_cv}" />{/if}</span>	
		<div class="suggestion">{$translations.apply.cv_info}</div>
	</td>
</tr>

add this block:

<tr>
	<td valign="top"><label for="apply_photo">{$translations.apply.photo_label}:</label></td>
	<td>
		<input type="file" name="apply_photo" id="apply_photo" />
		<span class="validation-error">{if $smarty.session.apply_errors.apply_photo}<img src="{$BASE_URL}_templates/{$THEME}/img/icon-delete.png" alt="" title="{$smarty.session.apply_errors.apply_photo}" />{/if}</span>	
		<div class="suggestion">{$translations.apply.photo_info}</div>
	</td>
</tr>

3) on page_apply.php, under this block:

if ($_FILES['apply_cv'] && $_FILES['apply_cv']['size'] >= MAX_CV_SIZE)
	{
		$errors['apply_cv'] = $translations['apply']['cv_error'];
	}

add this block:

if ($_FILES['apply_photo']['name'] != "" && $_FILES['apply_photo']['size'] >= MAX_CV_SIZE)
	{
		$errors['apply_photo'] = $translations['apply']['photo_error'];
	}
if ($_FILES['apply_photo']['name'] != "" && (($_FILES['apply_photo']['type'] != "image/gif") AND ($_FILES['apply_photo']['type'] != "image/jpeg") AND ($_FILES['apply_photo']['type'] != "image/png")))
	{
		$errors['apply_photo'] = $translations['apply']['photo_error'];
	}

next, under this block:

$filename = time() . '_' . $_FILES['apply_cv']['name'];
if (move_uploaded_file($_FILES['apply_cv']['tmp_name'], FILE_UPLOAD_DIR . $filename))
{
	$attachment = $filename;
}
else
{
	$attachment = '';
}

add this block:

$phfilename = time() . '_' . $_FILES['apply_photo']['name'];
if (move_uploaded_file($_FILES['apply_photo']['tmp_name'], FILE_UPLOAD_DIR . $phfilename))
{
	$phattachment = $phfilename;
}
else
{
	$phattachment = '';
}

after that, find this block:

$data = array('apply_email' => $apply_email,
		'apply_name' => $apply_name,
		'apply_msg' => strip_tags($apply_msg),
		'company_email' => $j->mPosterEmail,
		'company_name' => $j->mCompany,
		'job_title' => $j->mTitle,
		'attachment_path' => APP_PATH . FILE_UPLOAD_DIR . $attachment,
		'attachment_filename' => $attachment,
		'job_id' => $job_id);

and update with this block:

$data = array('apply_email' => $apply_email,
		'apply_name' => $apply_name,
		'apply_msg' => strip_tags($apply_msg),
		'company_email' => $j->mPosterEmail,
		'company_name' => $j->mCompany,
		'job_title' => $j->mTitle,
		'attachment_path' => APP_PATH . FILE_UPLOAD_DIR . $attachment,
		'attachment_filename' => $attachment,
		'phattachment_path' => APP_PATH . FILE_UPLOAD_DIR . $phattachment,
		'phattachment_filename' => $phattachment,
		'job_id' => $job_id);

lastly on that same file, find this block:

// delete uploaded file (cleanup)
if ($attachment != '')
{
	unlink(APP_PATH . FILE_UPLOAD_DIR . $attachment);
}

add this block under:

// delete uploaded photo (cleanup)
if ($phattachment != '')
{
	unlink(APP_PATH . FILE_UPLOAD_DIR . $phattachment);
}

4) open up /_includes/class.Postman.php and look for this function:

public function MailApplyOnline()
{
...
}

inside this function, look for this block:

if ($data['attachment_filename'] != '')
{
    $mailer->AddAttachment($data['attachment_path'], $data['attachment_filename']);
}

and add this below it:

if ($data['phattachment_filename'] != '')
{
    $mailer->AddAttachment($data['phattachment_path'], $data['phattachment_filename']);
}

just a note that i wrote this on top of my head (from what i remember i did for several other projects i did before) without testing/running the code, so if you come across any bugs, please let me know and if you found a fix, kindly share them here :)

Leave a Response