*/ require_once AWP_LIB_DIR . '/Plugin.php'; require_once AWP_INC_DIR . '/apptivo_services/jobApplicantDetails.php'; require_once AWP_INC_DIR . '/apptivo_services/appParam.php'; require_once AWP_INC_DIR . '/apptivo_services/jobDetails.php'; /** * Class awp_jobsForms */ class AWP_Jobs extends AWP_Base { var $_plugin_activated = false; /** * PHP5 constructor */ function __construct() { $settings=array(); $this->_plugin_activated=false; $settings=get_option("awp_plugins"); if(get_option("awp_plugins")!=="false"){ if($settings["jobs"]) $this->_plugin_activated=true; } } /** * Returns plugin instance * * @return awp_jobsForms */ function &instance() { static $instances = array(); if (!isset($instances[0])) { $class = __CLASS__; $instances[0] = new $class(); } return $instances[0]; } /** * Runs plugin */ function run() { if($this->_plugin_activated){ add_action( 'widgets_init',array(&$this, 'register_widget' )); //initialize widget add_action('the_posts',array(&$this,'check_for_shortcode')); add_shortcode('apptivo_job_applicantform',array(&$this,'jobapplicantform')); //Job applicant Form. add_shortcode('apptivo_jobs',array(&$this,'listofjobs')); //List Of Jobs. add_shortcode('apptivo_job_searchform',array(&$this,'jobsearchform'));//Job Search Form. add_shortcode('apptivo_job_description',array(&$this,'jobdescription')); //Job description. } } /** * Registering widget * */ function register_widget() { register_widget( 'JobSearch_Widget' ); // Job Search Form Widget. register_widget( 'JobList_Widget' ); // Job Lists Widget. } /** * Jobs Form shortcode handler */ function jobapplicantform($atts){ ob_start(); $jobidwith_Number = FALSE; extract(shortcode_atts(array('name'=> ''), $atts)); $formname=trim($name); $content=""; $successmsg=""; $hrjobsform=$this->get_jobapplicantform_fields($formname); $status = array('0' => 'Approved', '1' => 'New'); $allJobs = getAlljobs(999,0,'false',$status); //echo '
';print_r($allJobs);
//$allJobs = getAllHrjobs(999,0,'false',$status)->jobDetails;
$allJobs = awp_convertObjToArray($allJobs);
$jobId = $_POST['jobId'];
$jobNo = $_POST['jobNo'];
if(!empty($hrjobsform[fields])) {
foreach($hrjobsform[fields] as $field){
if($field[fieldid]=="country"){
$countrylist = $this->getAllCountryList();
break;
}
}
}
$submitformname = $_POST['awp_jobsformname'];
if(isset($_POST['awp_jobsformname']) && $submitformname==$formname)
{
if(trim($jobId) == '' && isset($_POST['jobidwithnumber']))
{
$jobid_Number = $_POST['jobidwithnumber'];
$jobid_No = explode('::',$jobid_Number);
$jobId = $jobid_No[0];
$jobNo = $jobid_No[1];
$jobidwith_Number = TRUE;
}
$successmsg=$this->save_applicantjobs($submitformname,$jobId,$jobNo);
}
if(strlen(trim($successmsg)) != 0 && $hrjobsform['confmsg_pagemode'] == 'other' ) :
$location = get_permalink($hrjobsform['confmsg_pageid']);
wp_safe_redirect($location);
endif;
if($jobidwith_Number)
{
$jobId = '';
}
if(!empty($hrjobsform)){
include $hrjobsform['templatefile'];
} else { echo awp_messagelist('jobapplicant-form-display-page'); }
$content = ob_get_clean();
return $content;
}
function jobsearchform($atts){
ob_start();
$jobsearchForm_Submit = FALSE;
extract(shortcode_atts(array('name'=> '','resulttype' => ''), $atts));
$result_type = trim($resulttype);
$formname=trim($name);
$jobsSettings = get_option('awp_jobs_settings');
$target_pageid = $jobsSettings['description_page'];
$content="";
$successmsg="";
$jobsearchform=$this->get_jobsearch_field($formname);
$submitformname=$_POST['awp_job_seachformname'];
if(isset($_POST['awp_job_seachformname']) && $submitformname==$formname){ // Shortcode Form Submit.
$keywords = $_POST['keywords'];
if( $keywords == 'Keyword' ) { $keywords = ''; }
$industry = $_POST['industry_select'];
$jobtype = $_POST['customfield2'];
if(!is_array($jobtype))
{
$jobtype =array($jobtype);
}
/*$response = serchByJobs($keywords, $industry, $jobtype);
$jobDetails_Response = $response->return->jobDetails;
$JobSearchResults = awp_convertObjToArray($jobDetails_Response);
*/
/*if(is_empty($jobtype)){
$jobtype = "";
}*/
if($industry == 'All'){
$industry = "";
}
$response = searchJob($keywords, $industry, $jobtype);
//echo 'response';print_r($response);
$jobDetails_Response = $response->data;
$JobSearchResults = awp_convertObjToArray($jobDetails_Response);
$jobsearchForm_Submit = TRUE;
}
$widgetFormname=$_POST['job_seachformname_widget'];
if(isset($_POST['job_seachformname_widget'])){ // Widget Form Submit.
$keywords = $_POST['keywords'];
if( $keywords == 'Keyword' ) { $keywords = ''; }
$industry = $_POST['customfield1'];
$jobtype = $_POST['customfield2'];
$maxcount = $_POST['maxcnt'];
if(!is_array($jobtype))
{
$jobtype =array($jobtype);
}
$response = serchByJobs($keywords, $industry, $jobtype);
$jobDetails_Response = $response->return->jobDetails;
$JobSearchResults = awp_convertObjToArray($jobDetails_Response);
$jobsearchForm_Submit = TRUE;
}
//To check custiom field (except fieldid=keywords) option is empty or not.
//To avoid Empty page.
$jobsearch_field = $jobsearchform['fields'];
$job_searchform_display = true;
if(count(($jobsearch_field) == 1))
{
if( $jobsearch_field[0]['fieldid'] != 'keywords' )
{
if( empty($jobsearch_field[0]['options'] ))
{
$job_searchform_display = false;
}
}
}
if($jobsearchForm_Submit && $response->return->statusCode == '1000' && $response->return->numResults == 0 )
{
echo awp_messagelist('jobsearch-noresult').'
'; //Display error Message.
$jobsearchForm_Submit = FALSE;
}else if(isset($response->return->statusCode) && $jobsearchForm_Submit && $response->return->statusCode != '1000')
{
echo awp_messagelist('validate-searchJobsBySearchText'); //Display Apptivo Validation Error.(E.g Invalide SiteKey and others..)
$jobsearchForm_Submit = FALSE;
}
if(!empty($jobsearchform) && $job_searchform_display)
{
include $jobsearchform['templatefile'];
}else {
echo awp_messagelist('jobsearch-form-display-page'); //Display error Message (E.g forms are not available..).
}
$content = ob_get_clean();
return $content;
}
function jobdescription($atts)
{
ob_start();
extract(shortcode_atts(array('applicantpage'=> ''), $atts));
$jobNo= $_GET['vacancyno']; //Request Job vacancy number
//$jobDetail = jobdescriptionByNumber($jobNo); //Get job details of selected job number
$jobDetail = jobdescriptionByNumberV6($jobNo); //Get job details of selected job number
// echo '';print_r($jobDetail);
if($jobDetail->status == 'SUCCESS'){
$jobDescription = $jobDetail->data[0]->description;
}else{
$jobDescription = "";
}
$jobs_settings = get_option('awp_jobs_settings');
$applicantFormList = get_option('awp_jobsforms');
$applicantformName = $jobs_settings['applicant_form'];
$templateName = $jobs_settings['desc_template_name'];
$template_type = $jobs_settings['jobdescription_template_type'];
//added template files
if($template_type == 'theme_template') :
$template_File = TEMPLATEPATH."/jobs/jobdescription/".$templateName; //Job Description theme template
else:
$template_File = AWP_JOBDESCRIPTION_TEMPLATEPATH."/".$templateName; //Job Description plugin template.
endif;
if(!empty($applicantFormList))
{
foreach($applicantFormList as $applicantform)
{
if($applicantformName == $applicantform[name])
{
$applicantpageUrl = $applicantform[properties][jobapplicant_page];
}
}
}
if($jobs_settings['submit_type'] == 'image')
{
$value = '';
if(strlen(trim($jobs_settings['submit_val'])) != 0)
{
$imageSrc = 'src="'.$jobs_settings['submit_val'].'"';
} else {
$imageSrc = 'src="'.awp_image('submit_button').'"';
}
} else {
$imageSrc = '';
if(strlen(trim($jobs_settings['submit_val'])) != 0)
{
$value = 'value="'.$jobs_settings['submit_val'].'"';
} else {
$value = 'value="Submit"';
}
}
if(!empty($templateName) && strlen(trim($jobDescription)) != 0 ){
include $template_File;
}else if(empty($templateName)) {
echo awp_messagelist('jobdescription-display-page'); //Display error Message.
}else { echo awp_messagelist('validate-getJobsByNo'); }
$content = ob_get_clean();
return $content;
?>
'Approved', '1' => 'New');
//$getalljobs_response = getAllHrjobs(999,0,'false',$status);
$getalljobs_response = getAlljobs(999,0,'false',$status);
//error_log(json_encode($getalljobs_response));
//$allJobs = $getalljobs_response->jobDetails;
$allJobs = $getalljobs_response->data;
$allJobs = awp_convertObjToArray($allJobs);
//echo $getalljobs_response->countOfRecords;exit;
/*if( $getalljobs_response->statusCode != '1000')
{error_log('temp if');
echo awp_messagelist('validate-getAllJobsWithStatus');
}else */
if(!empty($templateName) && $getalljobs_response->countOfRecords != 0 )
{
include $template_File;
}else if(empty($templateName)){
echo awp_messagelist('joblists-display-page');
}else {
echo awp_messagelist('joblists-noresults-display-page');
}
$content = ob_get_clean();
return $content;
}
/**
* Save Jobs from submitted
*/
function save_applicantjobs($formname,$jobId,$jobNo){
$hrjobsform=$this->get_jobapplicantform_fields($formname);
if(!empty($hrjobsform)){
$hrjobsformfields=$hrjobsform['fields'];
//Process the $_POST here..
$submittedformvalues=array();
$submittedformvalues['name']=$hrjobsform[name];
$customfields="";
foreach($hrjobsformfields as $field)
{
$fieldid=$field['fieldid'];
if($fieldid=="company"):
$companyName=stripslashes(trim($_POST['company']));
if($companyName !=''){
$customfields.="
".$field['showtext'].":".$companyName;
}
endif;
$pos=strpos($fieldid, "customfield");
if($pos===false){
if($fieldid=='telephonenumber'){
$telephone1=$_POST['telephonenumber1'];
if(isset($telephone1)){
$submittedformvalues[$fieldid]= $telephone1.sanitize_text_field($_POST['telephonenumber2']).sanitize_text_field($_POST['telephonenumber3']);
}
else{
$submittedformvalues[$fieldid]= sanitize_text_field($_POST[$fieldid]);
}
}else if($fieldid=='upload')
{
//$submittedformvalues[$fieldid]= $_POST['uploadfile_docid'];
$submittedformvalues[$fieldid]= sanitize_text_field($_FILES['file_upload']['name']);
$documentId = sanitize_text_field(trim($_POST['awp_document_key']));
}
else{
$submittedformvalues[$fieldid]= stripslashes($_POST[$fieldid]);
}
}else if($fieldid != 'industry'){
if(trim($customfields)!="")
{
if(is_array($_POST[$fieldid]))
{
$CustomArr = sanitize_text_field($_POST[$fieldid]);
$customfieldVal= "";
for($i=0; $i ".$field['showtext'].": ".stripslashes($customfieldVal);
endif;
}
else
{
if(is_array($_POST[$fieldid]))
{
$CustomArr = sanitize_text_field($_POST[$fieldid]);
$customfieldVal= "";
for($i=0; $i:".stripslashes($customfieldVal);
endif;
}
}else {
$submittedformvalues[industry]= sanitize_text_field($_POST[industry]);
}
}
if(trim($customfields)!="")
$submittedformvalues["notes"]=$customfields;
$firstName = sanitize_text_field($submittedformvalues['firstname']);
$lastName = sanitize_text_field($submittedformvalues['lastname']);
$emailId = sanitize_email($submittedformvalues['email']);
$jobTitle = sanitize_text_field($submittedformvalues['jobtitle']);
$company = sanitize_text_field($submittedformvalues['company']);
$address1 = sanitize_text_field($submittedformvalues['address1']);
$address2 = sanitize_text_field($submittedformvalues['address2']);
$city = sanitize_text_field($submittedformvalues['city']);
$provinceAndState = sanitize_text_field($submittedformvalues['state']);
$postalCode = sanitize_text_field($submittedformvalues['zipcode']);
$bestWayTohrjobs = sanitize_text_field($submittedformvalues['bestway']);
$country = sanitize_text_field($submittedformvalues['country']);
$countryIdCode = sanitize_text_field($_POST['country_id']);
$countryName = sanitize_text_field($_POST['country_name']);
$leadSource = sanitize_text_field($submittedformvalues['name']);
$phoneNumber = sanitize_text_field($submittedformvalues['telephonenumber']);
$comments = sanitize_text_field($submittedformvalues['comments']);
$coverletter = sanitize_text_field($submittedformvalues['coverletter']);
$skills = sanitize_text_field($submittedformvalues['Skills']);
$upload_docid = sanitize_text_field($submittedformvalues['upload']);
$industry = sanitize_text_field($submittedformvalues['industry']);
$industryId = sanitize_text_field($submittedformvalues['industryId']);
$positionName = sanitize_text_field($_POST['positionName']);
$positionIdNumber = sanitize_text_field($_POST['jobidwithnumber']);
$positionIdNumber = explode("::",$positionIdNumber);
$positionId = $positionIdNumber[0];
$positionNumber = $positionIdNumber[1];
$noteDetails = $submittedformvalues['notes'];
if($_POST['awp_industry_id']!=''){ $industryId=sanitize_text_field($_POST['awp_industry_id']); }
if(!empty($noteDetails)){
$parent1details = nl2br($noteDetails);
$awp_services_obj=new AWPAPIServices();
$noteDetails = $awp_services_obj->notes('Custom Fields',$parent1details,$parent1NoteId);
}
if(!empty($emailId)){
//$response = createJobApplicant($addressId, $address1, $address2, $applicantId, $applicantNumber, $city, $comments, $country, $countyAndDistrict, $emailId, $jobTitle, $expectedSalary, $firstName, $industryId, $jobApplicantId, $jobId,$jobNo, $lastName, $middleName,null, $phoneNumber, $postalCode, $provinceAndState, $coverletter, $resumeDetails, $resumeFileName, $resumeId, $skills,$upload_docid);
if($upload_docid != ""){
$file_ext = strtolower( end(explode('.',$upload_docid)));
$file_name = $_FILES ['file_upload'] ['name'];
$file_size= $_FILES['file_upload']['size'];
$file_tmp= $_FILES['file_upload']['tmp_name'];
$data = file_get_contents($file_tmp);
$base64 = base64_encode($data);
$add_document=uploadDocument($file_name,$file_ext,$file_size,$base64);
$docId = $add_document->documentId;
$docName = $add_document->documentName;
}
$response = saveCandidate($docId,$docName,$firstName,$lastName,$emailId,$phoneNumber,$upload_docid,$coverletter,$jobTitle,$comments,$industry,$industryId,$address1,$address2,$city,$provinceAndState,$postalCode,$country,$countryIdCode,$countryName,$skills);
//$jobApplicantId = $response->applicantId;
$jobApplicantId = $response->data->candidateId;
$jobApplicantName = $response->data->fullName;
if($jobApplicantId != "" && $positionId !=""){
$assoResponse = associateCandidatesToPosition($jobApplicantId,$positionId);
}
if($noteDetails!= "" && $jobApplicantId !="")
{
$noteText=$noteDetails->noteText;
$createNotesResponse=$awp_services_obj->saveNotes(APPTIVO_JOBS_OBJECT_ID,$jobApplicantId,$jobApplicantName,$noteText);
}
}
if(isset($jobApplicantId) && $jobApplicantId != ''){
if(!empty($hrjobsform[confmsg])){
$confmsg = $hrjobsform[confmsg];
}
else{
$confmsg="Job applicant uploaded Successfully";
}
}else if($response == 'E_IP') { echo awp_messagelist('IP_banned');}
}
return $confmsg;
}
/**
* Get hrjobsform and its fields to render in page which is using shortcode
*/
function get_jobapplicantform_fields($formname){
$formExists="";
$hrjobs_forms=array();
$hrjobsform=array();
$hrjobsformdetails=array();
$formname=trim($formname);
$hrjobs_forms=get_option('awp_jobsforms');
if($formname=="")
$formExists="";
else if(!empty($hrjobs_forms))
$formExists = awp_recursive_array_search($hrjobs_forms,$formname,'name' );
if(trim($formExists)!=="" ){
$hrjobsform=$hrjobs_forms[$formExists];
//build hrjobsformdetails array
$hrjobsformdetails['name']=$hrjobsform['name'];
//add properties
$hrjobsformproperties=$hrjobsform['properties'];
$hrjobsformdetails['tmpltype']=$hrjobsformproperties['tmpltype'];
$hrjobsformdetails['layout']=$hrjobsformproperties['layout'];
$hrjobsformdetails['confmsg']= stripslashes($hrjobsformproperties['confmsg']);
$hrjobsformdetails['confmsg_pagemode']= $hrjobsformproperties['confirm_msg_page'];
$hrjobsformdetails['confmsg_pageid']= $hrjobsformproperties['confirm_msg_pageid'];
$hrjobsformdetails['targetlist']=$hrjobsformproperties['targetlist'];
$hrjobsformdetails['css']=stripslashes($hrjobsformproperties['css']);
$hrjobsformdetails['submit_button_type']=$hrjobsformproperties['submit_button_type'];
$hrjobsformdetails['submit_button_val']=$hrjobsformproperties['submit_button_val'];
//inclde templates.
if($hrjobsformproperties['tmpltype']=="awp_plugin_template") :
$templatefile=AWP_JOBSFORM_TEMPLATEPATH."/".$hrjobsformproperties['layout']; //Job Applicant form plugin template
else :
$templatefile=TEMPLATEPATH."/jobs/jobapplicant/".$hrjobsformproperties['layout']; //Job Applicant form theme template
endif;
$hrjobsformdetails['templatefile']=$templatefile;
//add fields
$hrjobsformfields=$hrjobsform['fields'];
if(!empty($hrjobsformfields)){
usort($hrjobsformfields, "awp_sort_by_order");
$newhrjobsformfields=$hrjobsformfields;
$hrjobsformdetails['fields']=$newhrjobsformfields;
}
}
return $hrjobsformdetails;
}
function get_jobsearch_field($formname)
{
$formExists="";
$jobsearch_forms=array();
$jobsearchform=array();
$jobsearchformdetails=array();
$formname=trim($formname);
$jobsearch_forms=get_option('awp_jobsearchforms');
if($formname=="")
$formExists="";
else if(!empty($jobsearch_forms))
$formExists = awp_recursive_array_search($jobsearch_forms,$formname,'name' );
if(trim($formExists)!=="" ){
$jobsearchform=$jobsearch_forms[$formExists];
//build hrjobsformdetails array
$jobsearchformdetails['name']=$jobsearchform['name'];
//add properties
$jobsearchformproperties=$jobsearchform['properties'];
$jobsearchformdetails['tmpltype']=$jobsearchformproperties['tmpltype'];
$jobsearchformdetails['layout']=$jobsearchformproperties['layout'];
$jobsearchformdetails['confmsg']= stripslashes($jobsearchformproperties['confmsg']);
$jobsearchformdetails['targetlist']=$jobsearchformproperties['targetlist'];
$jobsearchformdetails['css']=stripslashes($jobsearchformproperties['css']);
$jobsearchformdetails['submit_button_type']=$jobsearchformproperties['submit_button_type'];
$jobsearchformdetails['submit_button_val']=$jobsearchformproperties['submit_button_val'];
$jobsearchformdetails['target_pageurl']=$jobsearchformproperties['target_pageurl'];
$jobsearchformdetails['jobapplicant_pageurl']=$jobsearchformproperties['jobapplicant_pageurl'];
//Include job serach template
if($jobsearchformproperties['tmpltype']=="awp_plugin_template") :
$templatefile=AWP_JOBSEARCHFORM_TEMPLATEPATH."/".$jobsearchformproperties['layout']; //Job search form plugin templates
else :
$templatefile=TEMPLATEPATH."/jobs/jobsearch/".$jobsearchformproperties['layout']; //Job search form theme templates
endif;
$jobsearchformdetails['templatefile']=$templatefile;
//add fields
$jobsearchformfields=$jobsearchform['fields'];
if(!empty($jobsearchformfields)){
usort($jobsearchformfields, "awp_sort_by_order");
$newhrjobsformfields=$jobsearchformfields;
$jobsearchformdetails['fields']=$newhrjobsformfields;
}
}
return $jobsearchformdetails;
}
/**
* Get hrjobs form settings by form name to render in Admin
*/
function get_settings($formname,$type){
$formExists="";
$hrjobs_forms=array();
$hrjobsform=array();
$formname=trim($formname);
if( $type == 'jobsearch')
{
$hrjobs_forms=get_option('awp_jobsearchforms');
}
else {
$hrjobs_forms=get_option('awp_jobsforms');
}
if($formname=="")
$formExists="";
else if(!empty($hrjobs_forms))
$formExists = awp_recursive_array_search($hrjobs_forms,$formname,'name' );
if(trim($formExists)!=="" ){
$hrjobsform=$hrjobs_forms[$formExists];
}
return $hrjobsform;
}
/**
* Return master fields lists supported by Apptivo hrjobs Form
*/
function get_master_fields()
{
$fields = array(
array('fieldid' => 'firstname','fieldname' => 'First Name','defaulttext' => 'First Name','showorder' => '1','validation' => 'text','fieldtype' => 'text'),
array('fieldid' => 'lastname','fieldname' => 'Last Name','defaulttext' => 'Last Name','showorder' => '2','validation' => 'text','fieldtype' => 'text'),
array('fieldid' => 'email','fieldname' => 'Email','defaulttext' => 'Email','showorder' => '3','validation' => 'email','fieldtype' => 'text'),
array('fieldid' => 'jobtitle','fieldname' => 'Job Title','defaulttext' => 'Job Title','showorder' => '4','validation' => 'text','fieldtype' => 'text'),
array('fieldid' => 'company','fieldname' => 'Company','defaulttext' => 'Company','showorder' => '5','validation' => 'text','fieldtype' => 'text'),
array('fieldid' => 'address1','fieldname' => 'Address1','defaulttext' => 'Address1','showorder' => '6','validation' => 'text','fieldtype' => 'text'),
array('fieldid' => 'address2','fieldname' => 'Address2','defaulttext' => 'Address2','showorder' => '7','validation' => 'text','fieldtype' => 'text'),
array('fieldid' => 'city','fieldname' => 'City','defaulttext' => 'City','showorder' => '8','validation' => 'text','fieldtype' => 'text'),
array('fieldid' => 'zipcode','fieldname' => 'ZipCode','defaulttext' => 'ZipCode','showorder' => '10','validation' => 'text','fieldtype' => 'text'),
array('fieldid' => 'country','fieldname' => 'Country','defaulttext' => 'Country','showorder' => '11','validation' => 'text','fieldtype' => 'select'),
array('fieldid' => 'telephonenumber','fieldname' => 'Telephone Number','defaulttext' => 'Telephone Number','showorder' => '12','validation' => 'number','fieldtype' => 'text'),
array('fieldid' => 'comments','fieldname' => 'Comments','defaulttext' => 'Comments','showorder' => '13','validation' => 'textarea','fieldtype' => 'textarea'),
array('fieldid' => 'coverletter','fieldname' => 'Cover Letter','defaulttext' => 'Cover Letter','showorder' => '14','validation' => 'textarea','fieldtype' => 'textarea'),
array('fieldid' => 'Skills','fieldname' => 'Skills','defaulttext' => 'Skills','showorder' => '15','validation' => 'upload','fieldtype' => 'textarea'),
array('fieldid' => 'upload','fieldname' => 'Upload File','defaulttext' => 'Upload File','showorder' => '16','validation' => 'textarea','fieldtype' => 'upload'),
array('fieldid' => 'industry','fieldname' => 'Industry','defaulttext' => 'Industry','showorder' => '17','validation' => '','fieldtype' => 'select'),
array('fieldid' => 'customfield1','fieldname' => 'Custom Field 1','defaulttext' => 'Custom Field1','showorder' => '18','validation' => '','fieldtype' => 'select'),
array('fieldid' => 'customfield2','fieldname' => 'Custom Field 2','defaulttext' => 'Custom Field2','showorder' => '19','validation' => '','fieldtype' => 'select'),
array('fieldid' => 'customfield3','fieldname' => 'Custom Field 3','defaulttext' => 'Custom Field3','showorder' => '20','validation' => '','fieldtype' => 'select'),
array('fieldid' => 'customfield4','fieldname' => 'Custom Field 4','defaulttext' => 'Custom Field4','showorder' => '21','validation' => '','fieldtype' => 'radio'),
array('fieldid' => 'customfield5','fieldname' => 'Custom Field 5','defaulttext' => 'Custom Field5','showorder' => '22','validation' => '','fieldtype' => 'checkbox')
);
//For Additional custom fields.
$addtional_custom = get_option('awp_addtional_custom_jobapplicant');
if(!empty($addtional_custom)):
$fields = array_merge($fields,$addtional_custom);
endif;
return $fields;
}
function get_master_fieldsfor_searchjobs()
{
$fields = array(
array('fieldid' => 'keywords','fieldname' => 'Keywords','defaulttext' => 'Keywords','showorder' => '1','validation' => 'text','fieldtype' => 'text'),
array('fieldid' => 'customfield1','fieldname' => 'Industry','defaulttext' => 'Industry','showorder' => '2','validation' => '','fieldtype' => 'select'),
array('fieldid' => 'customfield2','fieldname' => 'JobType','defaulttext' => 'Job Type','showorder' => '3','validation' => '','fieldtype' => 'select'),
);
return $fields;
}
/**
* Retrieve list of validations supported by Apptivo hrjobs Form
*
*/
function get_master_validations(){
$validations = array(
array('validationLabel' => 'None','validation' => 'none'),
array('validationLabel' => 'Email ID','validation' => 'email'),
array('validationLabel' => 'Number','validation' => 'number')
);
return $validations;
}
/**
*
* * Retrieve list of Field Types supported by Apptivo hrjobs Form
*/
function get_master_fieldtypes(){
$fieldtypes = array(
array('fieldtypeLabel' => 'Checkbox','fieldtype' => 'checkbox'),
array('fieldtypeLabel' => 'Radio Option','fieldtype' => 'radio'),
array('fieldtypeLabel' => 'Select','fieldtype' => 'select'),
array('fieldtypeLabel' => 'Textbox','fieldtype' => 'text'),
array('fieldtypeLabel' => 'Textarea','fieldtype' => 'textarea')
);
return $fieldtypes;
}
function get_master_fieldtypes_jobsearch(){
$fieldtypes = array(
array('fieldtypeLabel' => 'Checkbox','fieldtype' => 'checkbox'),
array('fieldtypeLabel' => 'Select','fieldtype' => 'select')
);
return $fieldtypes;
}
/**
* return array of plugin templates available with Template name and template file name
*/
function get_plugin_templates($dir_hrjobs)
{
$default_headers = array(
'Template Name' => 'Template Name'
);
$templates = array();
// Open a known directory, and proceed to read its contents
if (is_dir($dir_hrjobs)) {
if ($dh = opendir($dir_hrjobs)) {
while (($file = readdir($dh)) !== false) {
if ( substr( $file, -4 ) == '.php' )
{
$plugin_data = get_file_data( $dir_hrjobs."/".$file, $default_headers, '' );
if(strlen(trim($plugin_data['Template Name'])) != 0 )
{
$templates[$plugin_data['Template Name']] = $file;
}
}
}
closedir($dh);
}
}
return $templates;
}
function get_apptivo_template_data( $apptivo_template_file,$template_filename)
{
$test = array();
$default_headers = array(
'Apptivo Template Name' => 'Apptivo Template Name',
'Version' => 'Version',
'Description' => 'Description',
'Author' => 'Author',
);
$plugin_data = get_file_data( $apptivo_template_file, $default_headers, '' );
if(strlen(trim($plugin_data['Apptivo Template Name'])) != 0 )
{
$test[$plugin_data['Apptivo Template Name']] = $template_filename;
}
}
/**
* Create field array
*/
function createformfield_array($fieldid,$showtext,$required,$type,$validation,$options,$displayorder){
$displayorder = (trim($displayorder)=="")?0:trim($displayorder);
$options = (is_array($options))?$options:stripslashes(str_replace( array('"'), '', strip_tags($options)));
if( trim($type) != 'text' && trim($type) != 'textarea')
{
$pos = strpos(trim($fieldid), 'customfield');
if( $pos !== false )
{
if( !is_array($options) && trim($options) == '')
{
return '';
}
}
}
$hrjobsformfield= array(
'fieldid'=>$fieldid,
'showtext' => stripslashes(str_replace( array('"'), '', strip_tags($showtext))),
'required' => $required,
'type' => $type,
'validation' => $validation,
'options' => $options,
'order' => $displayorder
);
return $hrjobsformfield;
}
function createJobsoptions()
{
if($_POST['awp_jobs_add'] && ($_POST['nogdog'] == $_SESSION['apptvo_single_jobs'])) //Create Jobs
{
$jobtitle = $_POST['jobs_title'];
$content = stripslashes($_POST['content']);
$content = apply_filters('the_content', $content);
$jobindustry = $_POST['jobs_industry'];
$jobtype = $_POST['jobs_type'];
$jobstatus = $_POST['jobs_status'];
$isFeatured = $_POST['jobs_featured'];
if( strlen(trim($jobtitle)) == 0 || strlen(trim($content)) == 0)
{
$errorMsg = "Job Title and Job Description can not be empty.";
} else {
$jobindustry = explode('_', $jobindustry);
$industryName =$jobindustry[1];
$industryCode =$jobindustry[0];
$jobtype = explode('_', $jobtype);
$categoryName =$jobtype[1];
$categoryCode =$jobtype[0];
$jobstatus = explode('_', $jobstatus);
$statusName =$jobstatus[1];
$statusId =$jobstatus[0];
$positionDetails = new stdClass();
$positionDetails->positionNumber = "Auto generated number";
$positionDetails->statusName = $statusName;
$positionDetails->statusId = $statusId;
$positionDetails->statusCode = strtoupper($statusName);
if($isFeatured == "on"){
$positionDetails->isFeatured = "Y";
}else{
$positionDetails->isFeatured = "N";
}
$positionDetails->title = $jobtitle;
$positionDetails->description = $content;
$positionDetails->industryName = $industryName;
$positionDetails->industryId = $industryCode;
$positionDetails->categoryName = $categoryName;
$positionDetails->categoryId = $categoryCode;
$response = createJob(json_encode($positionDetails));
if(isset($response->status) && $response->status == 'SUCCESS'){
$sucMsg = "Job Created successfully.";
}else{
$sucMsg = 'Please Try again later.';
}
/*$response = createJobs($jobtitle,$content,$jobindustry,$jobtype,$isFeatured);
if($response == 'E_100')
{
$sucMsg = 'Invalid Keys';
}else if(isset($response->status) && $response->status != '1000')
{
$sucMsg = ''.$response->statusMessage.'';
}else { $sucMsg = "Job Created successfully."; }*/
}
} //End of Create Jobs.
if($_POST['awp_updatejobs']) // Update Jobs
{
$jobtitle = $_POST['jobs_title'];
$content = stripslashes($_POST['editcontent']);
$content = apply_filters('the_content', $content);
$jobId = $_POST['jobs_id'];
$industryId = $_POST['jobs_industry'];
$jobindustry = $_POST['jobs_industry'];
$jobtype = $_POST['jobs_type'];
$jobstatus = $_POST['jobs_status'];
$isFeatured = $_POST['jobs_featured'];
if( strlen(trim($jobtitle)) == 0 || strlen(trim($content)) == 0)
{
$errorMsg = "Job Title and Job Description can not be empty.";
}else {
if(isset($jobId) && is_numeric($jobId))
{
$jobindustry = explode('_', $jobindustry);
$industryName =$jobindustry[1];
$industryCode =$jobindustry[0];
$jobtype = explode('_', $jobtype);
$categoryName =$jobtype[1];
$categoryCode =$jobtype[0];
$jobstatus = explode('_', $jobstatus);
$statusName =$jobstatus[1];
$statusId =$jobstatus[0];
$positionDetails = new stdClass();
$positionDetails->positionNumber = "Auto generated number";
$positionDetails->statusName = $statusName;
$positionDetails->statusId = $statusId;
$positionDetails->statusCode = strtoupper($statusName);
if($isFeatured == "on"){
$positionDetails->isFeatured = "Y";
}else{
$positionDetails->isFeatured = "N";
}
$positionDetails->title = $jobtitle;
$positionDetails->description = $content;
$positionDetails->industryName = $industryName;
$positionDetails->industryId = $industryCode;
$positionDetails->categoryName = $categoryName;
$positionDetails->categoryId = $categoryCode;
$response = updateJob(json_encode($positionDetails),$jobId);
if(isset($response->data) && $response->data != ''){
$sucMsg = "Job Updated successfully.";
}else{
$sucMsg = 'Please Try again later.';
}
/*$response = updatejobs($jobId,$jobtitle,$content,$industryId,$jobtype,$isFeatured,$jobstatus);
if(isset($response->statusCode) && $response->statusCode != '1000')
{
$sucMsg = ''.$response->statusMessage.'';
}else {
$sucMsg = "Job Updated successfully.";}*/
}
}
} //End of Update Jobs.
//$jobTypeLists = array('Full Time' => 'Full Time','Part Time' => 'Part Time','Contract' => 'Contract');
//$jobTypeStatus = array('New' => 'New','Approved' => 'Approved','Closed' => 'Closed','Canceled' => 'Canceled');
$jobTypeLists = getAllStatusesTypesV6()->categories;
$jobStatuses = getAllStatusesTypesV6()->statuses;
?>
Jobs Management
_plugin_activated){
echo "Jobs plugin currently disabled. Please enable this in Apptivo General Settings";
}
?>
For Complete instructions, see the - Developer's
Guide.
_plugin_activated) :
$this->AllJobs();
endif;
//Displaying Job Lists
if(strlen($sucMsg) != 0 ) { ?>
return;*/
$jobresultsbyid = getJobById($_GET['id']);
$selectedJobs = $jobresultsbyid->data;
?>
jobDetails);
$Job_results = getAlljobs();//To get Jobs From Apptivo.
$JobSearchResults = awp_convertObjToArray($Job_results->data);
//if( $Job_results->numResults != 0)
if( $Job_results->countOfRecords != 0)
{
$numberofjobs = count($JobSearchResults);
$jobsperpage =5;
$tpages = ceil($numberofjobs/$jobsperpage);
$currentpage = intval($_GET['pageno']);
if($currentpage<=0) $currentpage = 1;
if($currentpage>=$tpages) $currentpage = $tpages;
$reload = $_SERVER['PHP_SELF'].'?page=awp_jobs&keys=jobcreation';
$start = ( $currentpage - 1 ) * $jobsperpage;
$JobSearchResults = array_slice( $JobSearchResults, $start, $jobsperpage);
?>
_plugin_activated){
echo "Jobs plugin currently disabled. Please enable this in Apptivo General Settings.";
}else {
$jobapplicant_settings = get_option('awp_jobsforms');
$job_appl_page = $jobapplicant_settings[0][properties][jobapplicant_page];
$awp_jobs_settings = get_option('awp_jobs_settings');
$list_template = $awp_jobs_settings[list_template_name];
if(strlen(trim($job_appl_page)) == 0 && strlen(trim($list_template)) == 0)
{
echo 'To show job list in Website. Update Job settings and Job Applicant form Configuration before adding Jobs list shortcode in Page or Post.';
}else if(strlen(trim($job_appl_page)) != 0 && strlen(trim($list_template)) == 0)
{
echo 'To show job list in Website. Update Job settings Configuration before adding Jobs list shortcode in Page or Post.';
}else if(strlen(trim($job_appl_page)) == 0 && strlen(trim($list_template)) != 0)
{
echo 'To show job list in Website. Update Job Applicant form Configuration before adding Jobs list shortcode in Page or Post.';
}
}
?>
$jobsperpage)
{
echo awp_paginate($reload,$currentpage,$tpages,$numberofjobs);
}
?>
_plugin_activated) {
echo 'Copy and Paste this short code in your page to display this list of jobs
';
} ?>
industries;
$_SESSION['industries'] = $allIndustries;
$Results = getAllHrjobs(1,1);
$updatemessage="";
/*if( $Results->numResults != 0) { */
$hrjobs_forms=array();
$hrjobsformdetails=array();
$hrjobs_forms=get_option('awp_jobsforms');
if(empty($hrjobs_forms))
{
$jobapplicant_array =array("name"=>'jaform');
$jobapplicantform=array($jobapplicant_array);
update_option('awp_jobsforms',$jobapplicantform);
$hrjobs_forms=get_option('awp_jobsforms');
}
/*
* Saving selected form settings
*/
if(isset($_POST['awp_jobsform_settings'])){
$templatelayout="";
$newformname=$_POST['awp_jobsform_name'];
if($_POST['awp_jobsform_templatetype']=="awp_plugin_template")
$templatelayout=$_POST['awp_jobsform_plugintemplatelayout'];
else
$templatelayout=$_POST['awp_jobsform_themetemplatelayout'];
$hrjobsformproperties=array(
'tmpltype' =>$_POST['awp_jobsform_templatetype'],
'layout' =>$templatelayout,
'confmsg' => stripslashes($_POST['awp_jobsform_confirmationmsg']),
'css' => stripslashes($_POST['awp_jobsform_customcss']),
'confirm_msg_page' => stripslashes($_POST['awp_jobsform_confirm_msg_page']),
'confirm_msg_pageid' => $_POST['awp_jobsform_confirmmsg_pageid'],
'subscribe_option' => $_POST['subscribe_option'],
'submit_button_type' => $_POST['awp_jobsform_submit_type'],
'submit_button_val' => $_POST['awp_jobsform_submit_val'],
'jobapplicant_page' => $_POST['awp_jobapplicant_page'] );
//New custom fields
$stack = array();
$addtional_custom = array();
$addtional_order = 23;
for($i=6;$i<200;$i++)
{
if(isset($_POST['customfield'.$i.'_newest']) )
{
$addtional_custom = array('fieldid' => 'customfield'.$i.'','fieldname' => 'Custom Field '.$i.'',
'defaulttext' => 'Custom Field'.$i.'','showorder' => $addtional_order,'validation' => '',
'fieldtype' => 'select');
$addtional_order++;
array_push($stack, $addtional_custom);
}else {
break;
}
}
if(!empty($stack)) :
update_option('awp_addtional_custom_jobapplicant',$stack);
endif;
//General fields
$hrjobsformfields=array();
foreach( $this->get_master_fields() as $fieldsmasterproperties )
{
$enabled=0;
$hrjobsformfield=array();
$fieldid=$fieldsmasterproperties['fieldid'];
if(!empty ($_POST[$fieldid.'_order'])){
$displayorder = $_POST[$fieldid.'_order'];
}
else{
$displayorder = $fieldsmasterproperties['showorder'];
}
if(!empty ($_POST[$fieldid.'_text'])){
$displaytext = $_POST[$fieldid.'_text'];
}
else{
$displaytext = $fieldsmasterproperties['defaulttext'];
}
if($fieldid=='lastname' || $fieldid=='email' || $fieldid=='firstname' || $fieldid=='country' )
{
$enabled = 1;
$required = 1;
}
else
{
$enabled = $_POST[$fieldid.'_show'];
$required = $_POST[$fieldid.'_require'];
}
if($enabled){
$hrjobsformfield=$this->createformfield_array($fieldid,$displaytext,$required,$_POST[$fieldid.'_type'],$_POST[$fieldid.'_validation'],$_POST[$fieldid.'_options'],$displayorder);
array_push($hrjobsformfields, $hrjobsformfield);
}
}
//usort($hrjobsformfields, "awp_sort_by_order");
if(!empty($hrjobsformfields)){
$newhrjobsformdetails=array('name'=>$newformname,'properties'=>$hrjobsformproperties,'fields'=>$hrjobsformfields);
$formExists="";
if(!empty($hrjobs_forms))
$formExists = awp_recursive_array_search($hrjobs_forms,$newformname,'name' );
if(trim($formExists)!=="" ){
unset($hrjobs_forms[$formExists]);
array_push($hrjobs_forms, $newhrjobsformdetails);
sort($hrjobs_forms);
update_option('awp_jobsforms',$hrjobs_forms);
$hrjobs_forms=get_option('awp_jobsforms');
$updatemessage= "Jobs Form '".$newformname."' settings updated. Use Short code '[apptivo_job_applicantform name=\"".$newformname."\"]' in your page to use this form.";
}
}else{
$updatemessage="Select atleast one Form field for jobs Form.";
}
$selectedhrjobsform=$newformname;
}
// Now display the settings editing screen
echo '';
//if updatemessage is not empty display the div
if(trim($updatemessage)!=""){
?>
get_plugin_templates(AWP_JOBSFORM_TEMPLATEPATH); //Job applicant form plugin templates
?>
get_settings($selectedhrjobsform,'');
if(count($hrjobsformdetails)>0){
$selectedhrjobsform=$hrjobsformdetails[name];
$fields=$hrjobsformdetails[fields];
$formproperties=$hrjobsformdetails[properties];
}
?>
/>
*Developers Guide - Job Applicant Form Shortcodes.
Save the below settings to get the Shortcode for job applicant form. '; } ?>
_plugin_activated) :
echo "Jobs Plugin is currently disabled. Please enable this in Apptivo General Settings.";
endif;
?>
Jobs Settings';
echo 'Jobs Applicant form';
$this->descriptionSettings();
}
if($_GET['step'] == 2)
{
echo 'Jobs Settings';
echo 'Jobs Applicant form';
$this->jobApplicant();
}
?>
$_POST['awp_joblist_descriptionpage'],
'submit_type' => $_POST['awp_joblist_submit_type'],
'submit_val' => $_POST['awp_joblist_submit_value'],
'applicant_form' => $applicantformName,
'desc_template_name' => $jobdesc_template,
'jobdescription_template_type' => $_POST['awp_jobdesc_templatetype'],
'list_template_name' => $joblist_template,
'joblist_template_type' => $_POST['awp_joblists_templatetype']
);
update_option('awp_jobs_settings',$jobs_settings_post);
}
$jobs_settings = get_option('awp_jobs_settings');
?>
Copy and Paste this short code in Job Description Page :
Save the below settings to get the Shortcode for job description.'; } ?>
_plugin_activated) :
_e("Jobs Plugin is currently disabled. Please enable this in Apptivo General Settings.",'apptivo-businesssite');
endif;
?>
'jsform');
$newhrjobsform=array($newhrjobsformname_array);
update_option('awp_jobsearchforms',$newhrjobsform);
$hrjobs_forms=get_option('awp_jobsearchforms');
}
/*
* Saving selected form settings
*/
if(isset($_POST['awp_jobsearchform_settings'])){
$templatelayout="";
$newformname=$_POST['awp_jobsearchform_name'];
if($_POST['awp_jobsearchform_templatetype']=="awp_plugin_template")
$templatelayout=$_POST['awp_jobsearchform_plugintemplatelayout'];
else
$templatelayout=$_POST['awp_jobsearchform_themetemplatelayout'];
$hrjobsformproperties=array(
'tmpltype' =>$_POST['awp_jobsearchform_templatetype'],
'layout' =>$templatelayout,
'confmsg' => stripslashes($_POST['awp_jobsearchform_confirmationmsg']),
'css' => stripslashes($_POST['awp_jobsearchform_customcss']),
'subscribe_option' => $_POST['subscribe_option'],
'submit_button_type' => $_POST['awp_jobsearchform_submit_type'],
'submit_button_val' => $_POST['awp_jobsearchform_submit_value'],
'target_pageurl' => $_POST['awp_target_pageurl'],
'jobapplicant_pageurl' => $_POST['awp_jobapplicant_pageurl']
);
$hrjobsformfields=array();
foreach( $this->get_master_fieldsfor_searchjobs() as $fieldsmasterproperties )
{
$enabled=0;
$hrjobsformfield=array();
$fieldid=$fieldsmasterproperties['fieldid'];
if(!empty ($_POST[$fieldid.'_order'])){
$displayorder = $_POST[$fieldid.'_order'];
}
else{
$displayorder = $fieldsmasterproperties['showorder'];
}
if(!empty ($_POST[$fieldid.'_text'])){
$displaytext = $_POST[$fieldid.'_text'];
}
else{
$displaytext = $fieldsmasterproperties['defaulttext'];
}
$enabled = $_POST[$fieldid.'_show'];
if($enabled){
$hrjobsformfield=$this->createformfield_array($fieldid,$displaytext,'',$_POST[$fieldid.'_type'],'',$_POST[$fieldid.'_options'],$displayorder);
array_push($hrjobsformfields, $hrjobsformfield);
}
}
if(!empty($hrjobsformfields)){
$newhrjobsformdetails=array('name'=>$newformname,'properties'=>$hrjobsformproperties,'fields'=>$hrjobsformfields);
$formExists="";
if(!empty($hrjobs_forms))
$formExists = awp_recursive_array_search($hrjobs_forms,$newformname,'name' );
if(trim($formExists)!=="" ){
unset($hrjobs_forms[$formExists]);
array_push($hrjobs_forms, $newhrjobsformdetails);
sort($hrjobs_forms);
update_option('awp_jobsearchforms',$hrjobs_forms);
$hrjobs_forms=get_option('awp_jobsearchforms');
$updatemessage= "Job Search Form '".$newformname."' settings updated. Use Short code '[apptivo_job_searchform name=\"".$newformname."\"]' in your page to use this form.";
}
}else{
$updatemessage="Select atleast one Form field for job search Form.";
}
$selectedhrjobsform=$newformname;
}
// Now display the settings editing screen
echo '';
// header
//if updatemessage is not empty display the div
if(trim($updatemessage)!=""){
?>
get_settings($selectedhrjobsform,'jobsearch');
if(count($hrjobsformdetails)>0){
$selectedhrjobsform=$hrjobsformdetails[name];
$fields=$hrjobsformdetails[fields];
$formproperties=$hrjobsformdetails[properties];
}
?>
*Developers Guide - Job Search Form Shortcodes.
Save the below settings to get the Shortcode for job search form. ';
}?>
loadscripts();
}
if($searchform_found || $joblists_found || $jobdesc_found || $applicantformfound)
{
$this->loadstyles();
}
return $posts;
}
function loadstyles()
{
wp_enqueue_style('style_awp_job', AWP_PLUGIN_BASEURL.'/inc/jobs/css/style.css' , false, '1.0.0', 'screen');
}
/**
* Load the JS files
*/
function loadscripts() {
wp_enqueue_script('jquery_validation',AWP_PLUGIN_BASEURL. '/assets/js/validator-min.js',array('jquery'));
}
/**
* Country lists from Apptivo
*/
function getAllCountryList()
{
$awp_services_obj=new AWPAPIServices();
$countrylist = $awp_services_obj->getAllCountries();
return $countrylist;
}
} //End Class
/**
* Create Jobs in Apptivo.
*/
function createJobs($jobTitle,$jobDescription,$industryId,$jobtype,$isFeatured)
{
if($isFeatured == 'on') :
$isFeatured = 'Y';
else:
$isFeatured = 'N';
endif;
$jobStatusName = 'New';
$jobDetails = new jobDetails($fillByDate, $firmId, $industryId, $industryName, $isFeatured, $jobDescription, $jobId, $jobNumber, $jobStatusId, $jobStatusName, $jobTitle, $jobTypeId, $jobtype);
$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $jobDetails
);
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'createJob',$params);
if($response == 'E_100')
{
return $response;
}
return $response->return;
}
/**
* Document details for upload document.
*/
function getDetailsForDocumentUpload(){
$params = array ( "arg0" => APPTIVO_BUSINESS_API_KEY,"arg1"=> APPTIVO_BUSINESS_ACCESS_KEY,"arg2" => '0');
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'getUploadDocumentDetails',$params);
return $response;
}
/**
* Update Apptivo Jobs
*/
function updatejobs($jobId,$jobTitle,$jobDescription,$industryId,$jobtype,$isFeatured,$jobStatusName='New')
{
if($isFeatured == 'on')
{
$isFeatured = 'Y';
}else {
$isFeatured = 'N';
}
$jobDetails = new jobDetails($fillByDate, $firmId, $industryId, $industryName, $isFeatured, $jobDescription, $jobId, $jobNumber, $jobStatusId, $jobStatusName, $jobTitle, $jobTypeId, $jobtype);
$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" =>$jobDetails
);
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'updateJob',$params);
return $response->return;
}
/**
* Job Details based on Jobs ID.
*/
function getJobByJobId($jobId)
{
$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $jobId
);
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'getJobByJobId',$params);
return $response;
}
/*
* Job Applicant Details are stored in Apptivo Jobs apps
*/
function createJobApplicant($addressId, $addressLine1, $addressLine2, $applicantId, $applicantNumber, $city, $comments, $country, $countyAndDistrict, $emailId, $expectedDesignation, $expectedSalary, $firstName, $industryId, $jobApplicantId, $jobId, $jobNumber, $lastName, $middleName, $noteDetails, $phoneNumber, $postalCode, $provinceAndState, $resumeCoverLetter, $resumeDetails, $resumeFileName, $resumeId, $skills,$upload_docid)
{
$verification = check_blockip();
if($verification){
return $verification;
}
$jobapplicantdetals = new JobApplicantDetails($addressId, $addressLine1, $addressLine2, $applicantId, $applicantNumber, $city, $comments, $country,$countyAndDistrict,$emailId, $expectedDesignation, $expectedSalary, $firstName, $industryId, $jobApplicantId,$jobId, $jobNumber, $lastName, $middleName, $noteDetails, $phoneNumber, $postalCode, $provinceAndState, $resumeCoverLetter, $resumeDetails, $resumeFileName, $resumeId, $skills,$upload_docid);
$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $jobapplicantdetals
);
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'createNewJobApplicant',$params);
$noteDetails=$response->return->noteDetails->noteText;
$applicantId=$response->return->applicantId;
if($applicantId!='' && $upload_docid!=''){
$file_ext = strtolower( end(explode('.',$upload_docid)));
$file_size= $_FILES['file_upload']['size'];
$file_tmp= $_FILES['file_upload']['tmp_name'];
$data = file_get_contents($file_tmp);
$base64 = base64_encode($data);
$add_document=uploadDocument($applicantId,$upload_docid,$file_ext,$file_size,$base64);
}
if($noteDetails!="" && $applicantId != "")
{
$noteText=$response->return->noteDetails->noteText;
$caseNotes='{"noteText":"'.$noteText.'"}';
$param = array (
"a" => "save",
"objectId" => APPTIVO_JOBS_OBJECT_ID,
"objRefId" => "$applicantId",
"noteData" => "$caseNotes",
"apiKey"=> APPTIVO_BUSINESS_API_KEY,
"accessKey"=> APPTIVO_BUSINESS_ACCESS_KEY
);
$notesResponse= getRestAPICall("POST", APPTIVO_NOTES_API,$param);
$noteid=$notesResponse->noteId;
}
if((isset($response->return->statusCode) && $response->return->statusCode != '1000') || $response =='E_100')
{
echo awp_messagelist('jobapplicant-display-page');
}
return $response->return;
}
/**
* Create Jobs in Apptivo V6.
*/
function createJob($positionDetails){
$param = array(
"a" => "save",
"positionData" => $positionDetails,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_RECRUITMENT_V6_API,$param);
return $response;
}
/**
* Update Jobs in Apptivo V6.
*/
function updateJob($positionDetails,$jobId){
$param = array(
"a" => "update",
"positionData" => $positionDetails,
"positionId"=>$jobId,
"attributeName"=>'["statusName","title","industryName","categoryName","isFeatured","description"]',
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_RECRUITMENT_V6_API,$param);
return $response;
}
/**
*
* Save Candidate...
*/
function saveCandidate($docId,$docName,$firstName,$lastName,$emailId,$phone,$resumeName,$coverLetter,$jobTitle,$comments,$industry,$industryId,$address1,$address2,$city,$state,$zipcode,$country,$countryIdCode,$countryName,$skills) {
//echo $countryIdCode;
$countryIdCode = explode('_', $countryIdCode);
$countryId = $countryIdCode[0];
$countryCode = $countryIdCode[1];
/*if($countryIdCode == ""){
$countryId = 176;
$countryCode = "US";
$countryName = "United States";
}*/
if($state == ""){ $state = null;}
if($docId != ''){
$doc = ',"candidateResumeId":'.$docId.',"candidateResume":"'.$docName.'"';
}
//$candidateDetails = '{"applicantNumber":"Auto+generated+number","statusId":"-1","firstName":"'.htmlspecialchars($firstName).'","emailId":"'.htmlspecialchars($emailId).'","lastName":"'.htmlspecialchars($lastName).'","phoneNumber":"'.$phone.'","industryId":"'.$industryId.'","mobileNumber":"","resumeId":"'.$resumeName.'","skills":"'.htmlspecialchars($skills).'","resumeCoverLetter":"'.htmlspecialchars($coverLetter).'","address_country":"176","jobTitle":"'.$jobTitle.'","comments":"'.htmlspecialchars($comments).'"}';
$candidateDetails = '{"candidateNumber":"Auto generated number", "customAttributes":[],"educationalHistories":[{"customAttributes":[]}],"labels":[],"tags":[],"addresses":[{"addressAttributeId":"address_section_attr_id","addressTypeCode":"3","addressType":"Communication","addressLine1":"'.$address1.'","addressLine2":"'.$address2.'","city":"'.$city.'","county":"","stateCode":"","state":null,"zipCode":"'.$zipcode.'","countryId":'.$countryId.',"countryName":"'.$countryName.'","countryCode":"'.$countryCode.'","deliveryInstructions":null,"addressGroupName":"Address1"}],"firstName":"'.$firstName.'","lastName":"'.$lastName.'","industryName":"Electronic Equip./Components","industryId":12924110,"skills":"'.$skills.'","coverLetter":"'.$coverLetter.'","phoneNumbers":[{"id":"candidate_phone_input","phoneType":"Business","phoneTypeCode":"PHONE_BUSINESS","phoneNumber":"'.$phone.'"}],"phoneType":"Business","phoneTypeCode":"PHONE_BUSINESS","emailAddresses":[{"id":"cont_email_input","emailType":"Business","emailTypeCode":"BUSINESS","emailAddress":"'.$emailId.'"}],"emailType":"Business","emailTypeCode":"BUSINESS","removePhoneNumbers":[],"removeEmailAddresses":[],"statusCode":"APPLIED"'.$doc.'}';
//echo $candidateDetails;exit;
//$candidateDetails = '{"experience":0,"candidateNumber":"Auto generated number","statusName":"Applied","statusId":67169,"customAttributes":[],"labels":[],"tags":[],"addresses":[{"addressAttributeId":"address_section_attr_id","addressTypeCode":"1","addressType":"Billing Address","addressLine1":"","addressLine2":"","city":"","county":"","stateCode":"","state":null,"zipCode":"","countryId":70,"countryName":"India","countryCode":"IN","deliveryInstructions":null,"addressGroupName":"Address1"}],"currentSalaryCurrencyCode":"INR","currencyCode":"INR","expectedSalaryCurrencyCode":"INR","isDirtypage":null,"firstName":"Test","title":"Dr.","lastName":"test","phoneNumbers":[{"id":"candidate_phone_input","phoneType":"Business","phoneTypeCode":"PHONE_BUSINESS","phoneNumber":"4444444444"}],"phoneType":"Business","phoneTypeCode":"PHONE_BUSINESS","emailAddresses":[{"id":"cont_email_input","emailType":"Business","emailTypeCode":"BUSINESS","emailAddress":"dsd@berijam.com"}],"emailType":"Business","emailTypeCode":"BUSINESS","removePhoneNumbers":[],"removeEmailAddresses":[],"statusCode":"APPLIED"}';
// $addressData = '["-1","'.$country.'","'.$address1.'","'.$address2.'","","'.$city.'","'.$state.'","'.$zipcode.'","'.$country.'"]';
/* $param = array(
"a" => "saveCandidate",
"candidateDetails" => $candidateDetails,
"addressData" => $addressData,
"documentId" => $documentId,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);*/
//echo $candidateDetails;exit;
$param = array(
"a" => "save",
"candidateData" => $candidateDetails,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_CANDIDATE_V6_API,$param);
return $response;
}
function associateCandidatesToPosition($jobApplicantId,$positionId){
$param = array(
"a" => "associateCandidatesToPosition",
"candidateIds" => '['.$jobApplicantId.']',
"positionId"=>$positionId,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_RECRUITMENT_V6_API,$param);
return $response;
}
/* Save Notes to Objects */
function getUploadDetailsByBucketName() {
$param = array(
"a" => "getUploadDetailsByBucketName",
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_COMMON_API, $param);
return $response;
}
/*
* upload document
*/
function uploadDocument($file_name,$file_ext,$file_size,$base64) {
$params = array(
"a" => "uploadDoc",
"objectId" => 177,
"docName"=> $file_name,
"docTitle"=> $file_name,
"docType"=> $file_ext,
"docSize"=> $file_size,
"encodedDocStr"=> $base64,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_DOCUMENT_API, $params);
return $response;
}
/*
* get All industries
*/
function getAllIndustriesV6(){
$param = array(
"a" => "getConfigData",
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_CANDIDATE_V6_API, $param);
return $response;
}
/*
* get All industries
*/
function getAllStatusesTypesV6(){
$param = array(
"a" => "getConfigData",
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_RECRUITMENT_V6_API, $param);
return $response;
}
/*
* get All jobs from recruitment
*/
function getAlljobs(){
$param = array(
"a" => "getAll",
"iDisplayLength" => 50,
"iDisplayStart"=>0,
"numRecords"=>50,
"sSortDir_0"=>"desc",
"selectedTab"=>"show-all",
"sortColumn"=>"lastUpdateDate",
"sortDir"=>desc,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_RECRUITMENT_V6_API, $param);
return $response;
}
function getJobById($id){
$param = array(
"a" => "getById",
"positionId" => $id,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_RECRUITMENT_V6_API, $param);
return $response;
}
/* search job */
function searchJob($keyword,$industry,$job_types){
if(sizeof($job_types == 0 )){
$jobtype = array();
$jobType = json_encode($jobtype);
}else{
$jobType = json_encode($job_types);
}
$param = array(
"a" => "getAllByAdvancedSearch",
"startIndex"=>0,
"numRecords"=>50,
"iDisplayLength"=>50,
"iDisplayStart"=>0,
"filterAdvData"=>'{"statusIds":[],"industryIds":['.$industry.'],"categoryIds":'.$jobType.',"departmentIds":[]}',
"searchData"=>'{"customAttributes":[],"title":"'.$keyword.'","isFeatured":null,"labels":[]}',
"objectId"=>APPTIVO_RECRUITMENT_OBJECT_ID,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_RECRUITMENT_V6_API, $param);
return $response;
}
/**
* Get ALL Jobs from Index
*/
function getAllHrjobs($maxCount=999,$pageIndex=1,$getFeaturedJobsOnly='false',$status = null)
{
$sortBy = 0;
$params_plugincall = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $getFeaturedJobsOnly,
"arg3" => $pageIndex,
"arg4" => $maxCount,
"arg5" => $sortBy,
"arg6" => $status
);
$response = getsoapCall(APPTIVO_BUSINESS_INDEX,'getAllJobsWithStatus',$params_plugincall);
if($response == 'E_100') :
echo awp_messagelist('validate-getAllJobsWithStatus');
endif;
return $response->return;
}
/*
* Get ALL Jobs from Apptivo
*/
function get_apptivojobs()
{
$params_plugincall = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => 'false',
"arg3" => 999,
"arg4" => 0,
"arg5" => 0,
"arg6" => null
);
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'getAllJobsWithStatus',$params_plugincall);
if($response == 'E_100')
{
echo awp_messagelist('validate-getAllJobsWithStatus');
}
return $response->return;
}
/**
* Serach By Jobs
*/
function serchByJobs($keyword,$industry,$job_types,$maxcount=999,$pageIndex=1)
{
$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $keyword,
"arg3" => $industry,
"arg4" => $job_types,
"arg5" => 'false',
"arg6" => $pageIndex,
"arg7" => $maxcount,
"arg8" => 0
);
$response = getsoapCall(APPTIVO_BUSINESS_INDEX,'searchJobsBySearchText',$params); //searchJobs
return $response;
}
/**
* Job Details based on Job number.
*/
function jobdescriptionByNumber($jobNo)
{
$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $jobNo
);
$response = getsoapCall(APPTIVO_BUSINESS_INDEX,'getJobByJobNo',$params); //getJobByJobNumber
if( $response == 'E_100')
{
return $response;
}
return $response->return;
}
function jobdescriptionByNumberV6($jobNo){
$param = array(
"a" => "getAllByAdvancedSearch",
"startIndex"=>0,
"numRecords"=>50,
"iDisplayLength"=>50,
"iDisplayStart"=>0,
"filterAdvData"=>'{"statusIds":[],"industryIds":[],"categoryIds":[],"departmentIds":[]}',
"searchData"=>'{"customAttributes":[],"positionNumber":"'.$jobNo.'","isFeatured":null,"labels":[]}',
"objectId"=>APPTIVO_RECRUITMENT_OBJECT_ID,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_RECRUITMENT_V6_API, $param);
return $response;
}
/**
* Apptivo Job Industries.
*/
function getAllIndustries()
{
$params = array ( "arg0" => APPTIVO_BUSINESS_API_KEY, "arg1" => APPTIVO_BUSINESS_ACCESS_KEY );
$data_key = APPTIVO_BUSINESS_API_KEY.'-industries';
if(class_exists('Memcache'))
{
$mcache_obj = new AWP_Cache_Util(); //Create Object in AWP_DataCache clss
$mcacheconnect = $mcache_obj->connectmcache();
}
else {
$mcacheconnect = FALSE;
}
//To check if the MemCache is connected or not.
if( $mcacheconnect )
{
$response = $mcache_obj->getdata($data_key);
if( empty($response)) //Check the published date key value is set in memcahe or not.
{
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'getAllIndustries',$params);
$mcache_obj->storedata($data_key,$response);
}
}else {
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'getAllIndustries',$params);
}
return $response->return;
}
/* SelectAll functionality for Job Industry,Job Type in Job Search From Fields */
add_action("admin_footer", "apptivo_business_jobs_search_formfields");
function apptivo_business_jobs_search_formfields() {
?>