I make a select box in which i select different resumes to apply on the same job but when i applying jobs it gives me error like this "You Already Applied"
Here is my apply_now.tpl:
{literal}
<script>
function applySubmit() {
$("#ApplicationForm").hide();
$("#ProgressBar").show();
$("#applyForm").ajaxSubmit({
url: $("#applyForm").attr("action"),
type: "POST",
success: function (data) {
$("#messageBox").html(data);
}
});
return false;
}
$(document).ready(function() {
$("#applyForm").jqTransform();
});
</script>
{/literal}
div id="ProgressBar" style="display:none"><img src="{$GLOBALS.site_url}/system/ext/jquery/progbar.gif" alt="[[Please wait ...]]" />[[Please wait ...]]</div>
<div id="ApplicationForm">
{if $is_data_submitted && !$errors}
<p class="message">[[You applied successfully]]</p>
{else}
{foreach from=$errors key=error_code item=error_message}
<p class="error">
{if $error_code eq 'EMPTY_VALUE'} [[Enter Security code]]
{elseif $error_code eq 'NOT_VALID'} [[Security code is not valid]]
{elseif $error_code eq 'SEND_ERROR'} [[There was an error while sending your application.]]
{else}[[{$error_message}]]
{/if}
</p>
{/foreach}
{include file='field_errors.tpl'}
<form method="POST" enctype="multipart/form-data" action="{$GLOBALS.site_url}/apply-now/" id="applyForm">
<input type="hidden" name="is_data_submitted" value="1">
<input type="hidden" name="listing_id" value="{$listing_id}">
{if NOT $GLOBALS.current_user.logged_in}
<fieldset>
<div class="inputName">[[Your name]]:</div>
<div class="inputField"><input type="text" name="name" value="{$request.name}" /></div>
</fieldset>
<fieldset>
<div class="inputName">[[Your e-mail]]:</div>
<div class="inputField"><input type="text" name="email" value="{$request.email}" /></div>
</fieldset>
{/if}
<fieldset>
<div class="inputName">[[Cover letter (optional)]]:</div>
<div class="inputField"><textarea name="comments" rows="5">{$request.comments}</textarea></div>
</fieldset>
{if $GLOBALS.current_user.logged_in && $resume}
<fieldset>
<div class="inputName">[[Select your resume]]:</div>
<div class="inputField">
<select name="id_resume" multiple="multiple">
<option value="0" selected="selected">[[Select your resume]]</option>
{html_options options=$resume selected=$request.id_resume}
</select>
<br />or
</div>
</fieldset>
{/if}
<fieldset>
<div class="inputName">[[Attach your resume]]:</div>
<div class="inputField"><input type="file" name="file_tmp" /></div>
</fieldset>
{if $isCaptcha == 1}
<fieldset>
<div class="inputName">[[$captcha.caption]]:</div>
<div class="inputField">{input property=$captcha.id object=$captchaObject}</div>
</fieldset>
{/if}
<input type="hidden" name="anonymous" value="1" />
{if $form_fields}
<fieldset>
{include file="questionnaire.tpl" form_fields=$form_fields}
</fieldset>
{/if}
<fieldset>
<div class="inputName"> </div>
<div class="inputButton"><input id="SubmitButton" type="submit" value="[[Send]]" onclick="return applySubmit();"/></div>
</fieldset>
</form>
{/if}
</div>
and here is my apply_now.php code:
$listingId = 0;
$post['submitted_data']['questionnaire'] = '';
if (isset($post['submitted_data']['id_resume']))
$listingId = $post['submitted_data']['id_resume'];
$mimeType = isset($_FILES['file_tmp']['type']) ? $_FILES['file_tmp']['type'] : '';
if (isset($_FILES['file_tmp']['size']) && $file_name != '' && $_FILES['file_tmp']['size'] == 0) {
$errors['FILE_IS_EMPTY'] = 'The uploaded file should not be blank';
}
if (!empty($_FILES['file_tmp']['name'])){
$fileFormats = explode(',',SJB_System::getSettingByName('file_valid_types'));
$fileInfo = pathinfo($_FILES['file_tmp']['name']);
if (!in_array(strtolower($fileInfo['extension']), $fileFormats)) {
$errors['NOT_SUPPORTED_FILE_FORMAT'] = strtolower($fileInfo['extension']) . ' ' . SJB_I18N::getInstance()->gettext(null, 'is not in an acceptable file format');
}
}
if ($file_name == '' && $listingId == 0) {
$canAppplyWithoutResume = false;
SJB_Event::dispatch('CanApplyWithoutResume', $canAppplyWithoutResume);
if (!$canAppplyWithoutResume) {
$errors['APPLY_INPUT_ERROR'] = 'Please select file or resume';
}
}
else if (SJB_Applications::isApplied($post['submitted_data']['listing_id'], $current_user_sid) && !is_null($current_user_sid)) {
$errors['APPLY_APPLIED_ERROR'] = 'You already applied';
}
if (count($errors) == 0 && count($field_errors) == 0) {
$res = SJB_Applications::create(
$post['submitted_data']['listing_id'],
$current_user_sid,
(isset($post['submitted_data']['id_resume'])) ? $post['submitted_data']['id_resume'] : '',
$post['submitted_data']['comments'],
$file_name,
$mimeType,
$id_file,
(isset($post['submitted_data']['anonymous'])) ? $post['submitted_data']['anonymous'] : '0',
$notRegisterUserData,
$post['submitted_data']['questionnaire'],
$score
);
if ($res)
SJB_Statistics::addStatistics('apply', $post['submitted_data']['listing_id'], $res);
if (isset($post['submitted_data']['id_resume']) && $post['submitted_data']['id_resume'] != 0) {
$listing_info = SJB_ListingManager::getListingInfoBySID($post['submitted_data']['id_resume']);
$emp_sid = SJB_ListingManager::getUserSIDByListingSID($post['submitted_data']['listing_id']);
$accessible = SJB_ListingManager::isListingAccessableByUser($post['submitted_data']['id_resume'], $emp_sid);
if (!$accessible)
SJB_ListingManager::setListingAccessibleToUser($post['submitted_data']['id_resume'], $emp_sid);
}
How i select multiple resumes and then applied?