/home/mip/mip/public/img/credit/datatables/sqladd.php.tar
home/mip/public_html_/old_mip/sqladd.php 0000644 00000133423 15152061736 0014342 0 ustar 00 <?php
session_start();
require_once("common_msg.inc");
require_once("func-select.php");
require_once("func-proc.php");
$db = db_connect();
switch($what){
case 'principal':
$sql = "insert into principals (name,
address,
fax,
telephone,
acc_date_from,
acc_date_to,
email,
contact_person) values ('".$_POST['name']."',
'".$_POST['address']."',
'".$_POST['fax']."',
'".$_POST['telephone,']."',
'".$_POST['acc_date_from']."',
'".$_POST['acc_date_to']."',
'".$_POST['email']."',
'".$_POST['contact_person']."')";
$result = mysql_query($sql);
$array = array(
'name' => $_POST['name'],
'address' => $_POST['address'],
'telephone' => $_POST['telephone'],
'acc_date_from' => $_POST['acc_date_from'],
'acc_date_to' => $_POST['acc_date_to'],
'email' => $_POST['email'],
'contact_person' => $_POST['contact_person']
);
echo json_encode($array);
break;
case 'jo_pos':
$sql = "INSERT INTO jo_position(
job_order_id,category_id,
position_id,
no_of_male,
no_of_female,
no_of_coed,
wage,
min_age,
max_age,
civil_status,
job_details)
VALUES (
'".$_POST['job_order_id']."','".$_POST['category_id']."',
'".$_POST['position_id']."',
'".$_POST['no_of_male']."',
'".$_POST['no_of_female']."',
'".$_POST['no_of_coed']."',
'".$_POST['wage']."',
'".$_POST['min_age']."',
'".$_POST['max_age']."',
'".$_POST['civil_status']."',
'".$_POST['job_details']."')";
$result = mysql_query($sql);
$jopos_id = mysql_insert_id();
$result_valid = getdata("select * from selection_basket where principal_id='".$_POST['principal_id']."' and job_order_id = '".$_POST['job_order_id']."' and jo_pos_id = '".$_POST['jopos_id']."'");
if ($result_valid[1]['principal_id']){
$array = array(
'job_order_id' => $_POST['job_order_id'],
'category_id' => $_POST['category_id'],
'position_id' => $_POST['position_id'],
'no_of_male' => $_POST['no_of_male'],
'no_of_female' => $_POST['no_of_female'],
'no_of_coed' => $_POST['no_of_coed'],
'wage' => $_POST['wage'],
'min_age' => $_POST['min_age'],
'max_age' => $_POST['max_age'],
'civil_status' => $_POST['civil_status'],
'job_details' => $_POST['job_details'],
'principal_id' => $_POST['principal_id'],
'sqltoday' => $sqltoday,
'msg' => 'There is already an existing principal, job order and position like the one you entered.'
);
echo json_encode($array);
} else {
$sql_selection = "INSERT INTO selection_basket(principal_id,job_order_id,jo_pos_id,lineupdate) VALUES ('".$_POST['principal_id']."','".$_POST['job_order_id']."','".$jopos_id."','".$sqltoday."')";
$result_selection = mysql_query($sql_selection);
$array = array(
'job_order_id' => $_POST['job_order_id'],
'category_id' => $_POST['category_id'],
'position_id' => $_POST['position_id'],
'no_of_male' => $_POST['no_of_male'],
'no_of_female' => $_POST['no_of_female'],
'no_of_coed' => $_POST['no_of_coed'],
'wage' => $_POST['wage'],
'min_age' => $_POST['min_age'],
'max_age' => $_POST['max_age'],
'civil_status' => $_POST['civil_status'],
'job_details' => $_POST['job_details'],
'principal_id' => $_POST['principal_id'],
'sqltoday' => $sqltoday,
'msg' => ''
);
echo json_encode($array);
}
break;
case 'job_order':
$sql = "INSERT INTO job_order(job_order_no,principal_id,date,status,jobsite,date_needed,date_expired)
VALUES ('".$_POST['job_order_no']."','".$_POST['principal_id']."','".$_POST['date']."','".$_POST['status']."','".$_POST['jobsite']."','".$_POST['date_needed']."','".$_POST['date_expired']."')";
$result = mysql_query($sql);
$array = array(
'job_order_no' => $_POST['job_order_no'],
'principal_id' => $_POST['principal_id'],
'date' => $_POST['date'],
'status' => $_POST['status'],
'jobsite' => $_POST['jobsite'],
'date_needed' => $_POST['date_needed'],
'date_expired' => $_POST['date_expired']
);
echo json_encode($array);
break;
case 'position':
$sql = "INSERT INTO positions(name,category_id) VALUES ('".$_POST['name']."', '".$_POST['category_id']."')";
$result = mysql_query($sql,$db);
$id = mysql_insert_id($sql);
$array = array('name' => $_POST['name'], 'category_id' => $_POST['category_id'],'position_id'=>$id);
echo json_encode($array);
break;
case 'announcements':
$sql = "INSERT INTO web_announcements(title, status, posting_date, announcement, expiry_date )
VALUES ('".$_POST['title']."', '".$_POST['status']."', '".$_POST['posting_date']."', '".addslashes($_POST['job_details'])."', '".$_POST['expiry_date']."')";
$result = mysql_query($sql);
$id = mysql_insert_id($db);
$array = array(
'title' => $_POST['title'],
'status' => $_POST['status'],
'posting_date' => $_POST['posting_date'],
'job_details' => $_POST['job_details'],
'expiry_date' => $_POST['expiry_date'],
'id' => $id
);
echo json_encode($array);
break;
case 'webjobonly2':
$sql = "INSERT INTO web_jobs(
position_id,yrs_exp,min_reqmt,jo_pos_id,
country_id,
posting_date,
expiry_date,
min_age,
max_age,
gender,
principal_id,
status,category_id,numpositions,location,manpower_pooling,
job_details,
showit,
alias)
VALUES (
'".$_POST['position_id']."','".$_POST['yrs_exp']."','".$_POST['min_reqmt']."','".$_POST['jo_pos_id']."',
'".$_POST['country_id']."',
'".$_POST['posting_date']."',
'".$_POST['expiry_date']."',
'".$_POST['min_age']."',
'".$_POST['max_age']."',
'".$_POST['gender']."',
'".$_POST['principal_id']."',
'".$_POST['status']."','".$_POST['category_id']."','".$_POST['numpositions']."','".$_POST['location']."','".$_POST['manpower_pooling']."',
'".addslashes($_POST['job_details'])."',
'".$_POST['showit']."',
'".$_POST['alias']."')";
$result = mysql_query($sql);
$id = mysql_insert_id($db);
echo mysql_error();
$array = array(
'position_id'=>$_POST['position_id'],
'yrs_exp'=>$_POST['yrs_exp'],
'min_reqmt'=>$_POST['min_reqmt'],
'jo_pos_id'=>$_POST['jo_pos_id'],
'country_id'=>$_POST['country_id'],
'posting_date'=>$_POST['posting_date'],
'expiry_date'=>$_POST['expiry_date'],
'min_age'=>$_POST['min_age'],
'max_age'=>$_POST['max_age'],
'gender'=>$_POST['gender'],
'principal_id'=>$_POST['principal_id'],
'status'=>$_POST['status'],
'category_id'=>$_POST['category_id'],
'numpositions'=>$_POST['numpositions'],
'location'=>$_POST['location'],
'manpower_pooling'=>$_POST['manpower_pooling'],
'job_details'=>$_POST['job_details'],
'showit'=>$_POST['showit'],
'alias'=>$_POST['alias'],
'msg_status'=>'1',
'job_live_id'=>$id
);
echo json_encode($array);
break;
case 'webjobonly':
$duplicate = getdata("select * from web_jobs where position_id='$position_id' and country_id='$country_id' and principal_id='$principal_id'");
if(!empty($duplicate)) error_message('Duplicate hot job.');
$posting_date = "$post_year-$post_month-$post_day";
$expiry_date = "$expiry_year-$expiry_month-$expiry_day";
$sql = "INSERT INTO web_jobs(
position_id,yrs_exp,min_reqmt,jo_pos_id,
country_id,
posting_date,
expiry_date,
min_age,
max_age,
gender,
principal_id,
status,category_id,numpositions,location,manpower_pooling,
job_details,
showit,
alias)
VALUES (
'$position_id','$yrs_exp','$min_reqmt','$jopos_id',
'$country_id',
'$posting_date',
'$expiry_date',
'$min_age',
'$max_age',
'$gender',
'$principal_id',
'$status','$category_id','$numpositions','$location','$manpower_pooling',
'$job_details',
'$showit',
'$alias')";
$result = mysql_query($sql);
echo mysql_error();
$webjob_id = mysql_insert_id();
//header("Location: edit_webjob.php?webjob_id=$webjob_id");
header("Location: http://mipiris-server/irisonline/manage_webjobsonly.php?status=Open&Action=add&msg=New%20Job%20Opening%20Added");
break;
case 'agency_job':
//prevent spamm
if( !isset($_POST['position_id']) && !isset($_POST['principal_id']) && !isset($_POST['jopos_id']) && !isset($_POST['country_id']) && !isset($_POST['opening_date']) ) {
header("Location: edit_job.php?validationmsg=1");
exit;
}
if( isset($_REQUEST['savejob']) || isset($_REQUEST['addjob']) || isset($_REQUEST['saveaddjob']) ){
if($_REQUEST['savejob']) $buttonval = '1';
if($_REQUEST['addjob']) $buttonval = '2';
if($_REQUEST['saveaddjob']) $buttonval = '3';
try {
$oauth_client = new Oauth($iriskey,$iriskeysecret);
$oauth_client->enableDebug();
$oauth_client->setToken($iriskeytoken,$iriskeytokensecret);
$oauth_client->fetch("".$tokenrequestsite."api/insertjobs", array("position_id" => $position_id, "principal_id" => $principal_id, "category_id" => $category_id,"jopos_id" => $jopos_id, "accept_freshgrad" => $accept_freshgrad, "showit" => $showit, "alias" => $alias, "position_title" => $position_title, "numpositions" => $numpositions, "jobspec_id" => $jobspec_id, "jobspec_name" => @getname($jobspec_id,"job_spec","jobspec_id"), "gender" => $gender, "min_age" => $min_age, "max_age" => $max_age, "muslim" => $muslim, "min_reqmt" => str_replace("'","",$min_reqmt), "allow_fgrad_yes" => $allow_fgrad_yes, "allow_fgrad_no" => $allow_fgrad_no, "yrs_exp" => $yrs_exp, "principal_name" => $principal_name, "location" => $location, "country_id" => $country_id, "country_name" => @getname($country_id,"country","country_id"), "manpower_pooling" => $manpower_pooling, "jonum" => $jonum, "jodate" => $jodate, "noplacement" => $noplacement, "salarydeduct" => $salarydeduct, "salary" => $salary, "start_date" => $start_date, "end_date" => $end_date, "interview_venue" => $interview_venue, "status" => $status, "opening_date" => $opening_date, "closing_date" => $closing_date, "emailto" => $emailto, "repost" => $repost, "accept_wo_pic" => $accept_wo_pic, "add_question" => $add_question, "job_desc" => $job_desc, "question1" => $question1, "question2" => $question2, "question3" => $question3, "question4" => $question4, "question5" => $question5, "question6" => $question6, "question7" => $question7, "question8" => $question8, "question9" => $question9, "question10" => $question10, "answer1" => $answer1, "answer2" => $answer2, "answer3" => $answer3, "answer4" => $answer4, "answer5" => $answer5, "answer6" => $answer6, "answer7" => $answer7, "answer8" => $answer8, "answer9" => $answer9, "answer10" => $answer10, "agreelaw" => $agreelaw, "buttonval" => $buttonval));
$jsonEN = $oauth_client->getLastResponse();
$obj=json_decode($jsonEN);
if (!$obj) {
throw new Exception('Error Adding Record in Workabroad. Please Try Again');
} else {
foreach ($obj as $key=>$value) {
//insert in jobs
if($gender=='Any') $gender ='';
if($gender=='Male') $gender ='M';
if($gender=='Female') $gender ='F';
$sql = "INSERT INTO web_jobs(position_id,country_id,posting_date,
expiry_date,
min_age,
max_age,
gender,
job_details,
principal_id,
numpositions,
location,
jobspec_id,
min_reqmt,
accept_freshgrad,
yrs_exp,
manpower_pooling,
jonum,
jo_date,
noplacement,
salarydeduct,
salary,
interview_start_date,
interview_end_date,
interview_venue,
status,
open_date,
emailto,
WA,
category_id,
noremove,
jo_pos_id,
jobalertstatus,
showit,
muslim,allow_fgrad_yes,accept_wo_pic,add_question,agreelaw,position_title,principal_name,
alias)
VALUES ('".$value->position_id."','".$value->country_id."','".$value->opening_date."',
'".$value->closing_date."',
'".$value->min_age."',
'".$value->max_age."',
'".$gender."',
'".addslashes($value->job_desc)."',
'".$value->principal_id."',
'".$value->numpositions."',
'".$value->location."',
'".$value->jobspec_id."',
'".addslashes($min_reqmt)."',
'".$value->accept_freshgrad."',
'".$value->yrs_exp."',
'".$value->manpower_pooling."',
'".$value->jonum."',
'".$value->jodate."',
'".$value->noplacement."',
'".$value->salarydeduct."',
'".$value->salary."',
'".$value->start_date."',
'".$value->end_date."',
'".addslashes($value->interview_venue)."',
'".$value->status."',
'".$value->opening_date."',
'".$value->emailto."',
'".$value->job_id."',
'".$value->category_id."',
'0',
'".$value->jopos_id."',
'0',
'".$value->showit."',
'".$value->muslim."','".$value->allow_fgrad_yes."','".$value->accept_wo_pic."','".$value->add_question."','".$value->agreelaw."','".$value->position_title."','".$value->principal_name."',
'".addslashes($value->alias)."'
)";
$result= mysql_query($sql,$db);
$webjob_id = mysql_insert_id();
//insert into questions
if($add_question=='Y'){
$sql_question = "INSERT INTO `agency_jobs_questions` (`job_id`,`webjob_id`,`question1`,`answer1`,`question2`,`answer2`,`question3`,`answer3`,`question4`,`answer4`,
`question5`,`answer5`,`question6`,`answer6`,`question7`,`answer7`,`question8`,`answer8`,`question9`,`answer9`,`question10`,`answer10`)
VALUES ('".$value->job_id."','".$webjob_id."','".$value->question1."','".$value->answer1."','".$value->question2."','".$value->answer2."','".$value->question3."','".$value->answer3."','".$value->question4."','".$value->answer4."','".$value->question5."','".$value->answer5."',
'".$value->question6."','".$value->answer6."','".$value->question7."','".$value->answer7."','".$value->question8."','".$value->answer8."','".$value->question9."','".$value->answer9."','".$value->question10."','".$value->answer10."')";
$resultque = mysql_query($sql_question,$db);
}
//value of button if 1 (Save), 2 (Save and Add Another), 3 (Save and Add Similar)
$buttonval = $value->buttonval;
$wajobid = $value->job_id;
}
if($buttonval=='1') header("Location: manage_jobs.php?msg=You have successfully added your job opening. It will be posted in our list of job openings after our server refreshes its data by the end of the day.");
if($buttonval=='2') header("Location: edit_job.php?msg=You have successfully added your job opening. It will be posted in our list of job openings after our server refreshes its data by the end of the day.");
if($buttonval=='3') header("Location: edit_job.php?msg=You have successfully added your job opening. It will be posted in our list of job openings after our server refreshes its data by the end of the day.&webjob_id=".$webjob_id."&dump=1");
}
} catch (OAuthException $E){
//echo '<div class="errormsg">'.print_r($E->debugInfo).'Error Connecting to WA Server. Invalid Keys, Tokens.</div>';
header("Location: edit_job.php?errormsg=1&errormsgval=Invalid Keys, Tokens");
} catch (Exception $e) {
//echo '<div class="errormsg">'.$e->getMessage().'</div>';
header("Location: edit_job.php?errormsg=1&errormsgval=".$e->getMessage()."");
}
}
break;
case 'curl_webjob':
$sql = "update web_jobs set transfer = '1' where webjob_id='$webjob_id'";
$result = mysql_query($sql);
break;
case 'curl_ann_update':
$sql = "UPDATE web_announcements
SET title = '$title',
status = '$status',
announcement = '$announcement',
posting_date = '$posting_date',
expiry_date = '$expiry_date'
WHERE id='$id'";
$result = mysql_query($sql);
break;
case 'curl_announcements':
$sql = "update web_announcements set transfer = '1' where id='$id'";
$result = mysql_query($sql);
break;
case 'curl_personal':
$sql = "update web_personal set transfer = '1' where applicant_id='$applicant_id'";
$result = mysql_query($sql);
break;
case 'curl_employment':
$sql = "update web_employment set transfer = '1' where applicant_id='$applicant_id'";
$result = mysql_query($sql);
break;
case 'curl_education':
$sql = "update web_education set transfer = '1' where applicant_id='$applicant_id'";
$result = mysql_query($sql);
break;
case 'curl_training':
$sql = "update web_training set transfer = '1' where applicant_id='$applicant_id'";
$result = mysql_query($sql);
break;
case 'curl_doc':
$sql = "update web_doc_library set transfer = '1' where applicant_id='$applicant_id'";
$result = mysql_query($sql);
break;
case "web_doc" :
$doc_name = trim($doc_name);
if($_FILES['docfile']['name']){
if ( strstr($_FILES['docfile']['name'], "php") ) {
error_message('Invalid Format.');
exit;
}
$filename=stripslashes($_FILES['docfile']['name']);
$temp_dir = "$doc_rootdir"."$applicant_id";
if(!is_dir($doc_rootdir)) mkdir ($doc_rootdir);
if(!is_dir($temp_dir)) mkdir ($temp_dir);
copy($_FILES['docfile']['tmp_name'],"$temp_dir/$filename");
}
$date_submitted = "$year-$day-$month";
$date_withdrawn = "$wyear-$wday-$wmonth";
$sql = "insert into $table
(applicant_id,doc_name, type_id, doc_file,date_submitted,date_withdrawn)
values('$applicant_id','$doc_name', '$doc_type', '".addslashes($filename)."','$sqltoday','$date_withdrawn')";
$result= mysql_query($sql);
mysql_close();
header("Location: apply_online_doc.php?table=$table&applicant_id=$applicant_id");
break;
case 'web_personal1':
$birthdate = "$bday_year-$bday_month-$bday_day";
$lname=ucwords(strtolower($lname));
$fname=ucwords(strtolower($fname));
$mname=ucwords(strtolower($mname));
$email = ltrim(rtrim($email));
$duplicate_email1 = getdata("select * from web_personal where email='$email'");
if(!empty($duplicate_email1)) error_message('Email Address already exist.');
$duplicate_email2 = getdata("select * from personal where email='$email'");
if(!empty($duplicate_email2)) error_message('Email Address already exist.');
$duplicate2 = getdata("select * from web_personal where lname='$lname' and fname='$fname' and mname='$mname'");
if(!empty($duplicate2)) error_message('You have already applied online.');
$duplicate3 = getdata("select * from personal where lname='$lname' and fname='$fname' and mname='$mname'");
if(!empty($duplicate3)) error_message('You have already applied online.');
$duplicate4 = getdata("select * from personal where lname='$lname' and fname='$fname' and mname='$mname' and blacklisted='1'");
if(!empty($duplicate4)) error_message('The applicant is blacklisted.');
$max = '205000';
$filesize = filesize($_FILES['picture']['tmp_name']);
if($filesize>=$max) { // imagesize validtion
error_message('Filesize is greater than 200 kb');
}
$sql = "INSERT INTO web_personal(webjob_id,category_id,password,
apply_date,
position_id1,address1,email,cellphone,
fname,
mname,
lname,
birthdate,
position1_yrsofexp,
position1_mosofexp,
position2_yrsofexp,
position2_mosofexp,
position1_yrsofexp_abroad,
position1_mosofexp_abroad,
position2_yrsofexp_abroad,
position2_mosofexp_abroad,
resumefile)
VALUES ('$webjob_id','$category_id','$password1',
NOW(),
'$position1','$address1','$email','$cellphone',
'$fname',
'$mname',
'$lname',
'$birthdate',
'$position1_yrsofexp',
'$position1_mosofexp',
'$position2_yrsofexp',
'$position2_mosofexp',
'$position1_yrsofexp_abroad',
'$position1_mosofexp_abroad',
'$position2_yrsofexp_abroad',
'$position2_mosofexp_abroad',
'".$_FILES['picture']['name']."')";
$result = mysql_query($sql);
//echo mysql_error();
$applicant_id = mysql_insert_id();
if ($_FILES['picture']['name'] && $_FILES['picture']['name'] != 'none'){
if ( strstr($_FILES['picture']['name'], "php") ) {
error_message('Invalid Format.');
exit;
}
if(!is_dir($doc_dir.$applicant_id)) mkdir ($doc_dir.$applicant_id);
$max = '205000';
$filesize = filesize($_FILES['picture']['tmp_name']);
if($filesize<=$max) { // imagesize validtion
$type = basename($_FILES['picture']['type']);
switch($type){
case "vnd.openxmlformats-officedocument.wordprocessingml.document":
case "msword": $pic_name = $_FILES['picture']['name'];
$filename = $doc_dir.$applicant_id."/".$pic_name;
@copy($_FILES['picture']['tmp_name'], $filename);
break;
case "pdf": $pic_name = $_FILES['picture']['name'];
$filename = $doc_dir.$applicant_id."/".$pic_name;
@copy($_FILES['picture']['tmp_name'], $filename);
break;
default: error_message("Invalid file format: $type");
}
} else {
error_message('Filesize is greater than 200 kb');
} // imagesize validtion
}
if($limit){ $cnt = $limit-1; }
else { $cnt = 1; }
for($i=1; $i<=$cnt; $i++){
$filename = "file".$i;
if ( strstr($_FILES[$filename]['name'], "php") ) {
error_message('Invalid Format.');
exit;
}
if($_FILES[$filename]["size"]<=$max){
$newname = $_FILES[$filename];
$temp_dirA = "$doc_dir"."$applicant_id";
if(!is_dir($doc_dir)) mkdir ($doc_dir);
if(!is_dir($temp_dirA)) mkdir ($temp_dirA);
$temp_dir_finalA = "$temp_dirA" . "/" . "$newname[name]";
$file_copy = @copy($newname[tmp_name],$temp_dir_finalA);
$doc_names = @getname($_POST['doc_type'.$i.''],"doc_type","type_id");
if($file_copy){
$sql2 = "INSERT INTO web_doc_library(applicant_id,doc_file,date_submitted,type_id,doc_name)
VALUES ('$applicant_id','$newname[name]','$sqltoday','".$_POST['doc_type'.$i.'']."','".$doc_names."')";
$result2 = mysql_query($sql2);
}
}
}
if($result){
header("Location: apply_online.php?applicant_id=$applicant_id&resume=1&whatapply=$whatapply");
} else {
header("Location: apply_online.php?whatapply=$whatapply&msg=Pls. try to apply later. We are encountering problem right now. Thank you.");
}
break;
case 'web_personal':
$birthdate = date('Y-m-d', strtotime($birthdate));
$lname=ucwords(strtolower($lname));
$fname=ucwords(strtolower($fname));
$mname=ucwords(strtolower($mname));
$email = ltrim(rtrim($email));
$duplicate_email1 = getdata("select * from web_personal where email='$email'");
if(!empty($duplicate_email1)) error_message('Email Address already exist.');
$duplicate_email2 = getdata("select * from personal where email='$email'");
if(!empty($duplicate_email2)) error_message('Email Address already exist.');
$duplicate2 = getdata("select * from web_personal where lname='$lname' and fname='$fname' and mname='$mname'");
if(!empty($duplicate2)) error_message('You have already applied online.');
$duplicate3 = getdata("select * from personal where lname='$lname' and fname='$fname' and mname='$mname'");
if(!empty($duplicate3)) error_message('You have already applied online.');
$duplicate4 = getdata("select * from personal where lname='$lname' and fname='$fname' and mname='$mname' and blacklisted='1'");
if(!empty($duplicate4)) error_message('The applicant is blacklisted.');
if ($_FILES['picture']['name'] && $_FILES['picture']['name'] != 'none'){
if ( strstr($_FILES['picture']['name'], "php") ) {
error_message('Invalid Format.');
exit;
}
if(!is_dir("pictures/".date("Y")."")) mkdir ("pictures/".date("Y")."");
list($width, $height, $type, $attr) = getimagesize($_FILES['picture']['tmp_name']);
if($width>650 || $height>650) {
error_message('Picture must have a maximum dimension \n\r of 2 x 2');
}
$max = '50000';
$filesize = filesize($_FILES['picture']['tmp_name']);
if($filesize<=$max) { // imagesize validtion
$type = basename($_FILES['picture']['type']);
$applicantid=substr(cmd_guid(),0,5);
switch($type){
case "png": $pic_name = "pictures/".date("Y")."/$applicantid.png";
$filename = $pic_dir."$pic_name";
copy ($_FILES['picture']['tmp_name'], $filename);
break;
case "jpeg":
case "pjpeg": $pic_name = "pictures/".date("Y")."/$applicantid.jpg";
$filename = $pic_dir."$pic_name";
copy ($_FILES['picture']['tmp_name'], $filename);
break;
case "gif": $pic_name = "pictures/".date("Y")."/$applicantid.gif";
$filename = $pic_dir."$pic_name";
copy ($_FILES['picture']['tmp_name'], $filename);
break;
default: error_message("Invalid picture format:$type");
}
} else {
error_message('Filesize is greater than '.$max.' bytes');
} // imagesize validtion
}
if($cellphone) {
$cellphone = "0".substr($cellphone,-10);
}
$sql = "INSERT INTO web_personal(webjob_id,category_id,password,
apply_date,
fname,
mname,
lname,
address1,
perm_no,
perm_st,
perm_city,
perm_prov,
perm_zip,
office_phone,
home_phone,
cellphone,
email,
birthdate,
birthplace,
sex,
height1,
height2,
weight1,
weight2,
civil_status,
religion,
nationality,
position_id1,
position_id2,
position1_yrsofexp,
position1_mosofexp,
position2_yrsofexp,
position2_mosofexp,
position1_yrsofexp_abroad,
position1_mosofexp_abroad,
position2_yrsofexp_abroad,
position2_mosofexp_abroad, country_id,
picture)
VALUES ('$webjob_id','$category_id','$password1',
NOW(),
'$fname',
'$mname',
'$lname',
'$address1',
'$perm_no',
'$perm_st',
'$perm_city',
'$perm_prov',
'$perm_zip',
'$office_phone',
'$home_phone',
'$cellphone',
'$email',
'$birthdate',
'$birthplace',
'$sex',
'$height1',
'$height2',
'$weight1',
'$weight2',
'$civil_status',
'$religion',
'$nationality',
'$position_id1',
'$position2',
'$position1_yrsofexp',
'$position1_mosofexp',
'$position2_yrsofexp',
'$position2_mosofexp',
'$position1_yrsofexp_abroad',
'$position1_mosofexp_abroad',
'$position2_yrsofexp_abroad',
'$position2_mosofexp_abroad',
'$country_id',
'$pic_name')";
$result = mysql_query($sql);
echo mysql_error();
$applicant_id = mysql_insert_id();
if($result) {
header("Location: apply_online_education.php?msg=Pls. do provide other information.&applicant_id=$applicant_id");
} else{
header("Location: apply_online.php?msg=Pls. try to apply later. We are encountering problem right now. Thank you.");
}
break;
case 'web_education':
$sql = "INSERT INTO web_education (applicant_id,education,school,from_date,to_date,course)
VALUES ('$applicant_id','$education','$school','$from_date','$to_date','$course')";
$result = mysql_query($sql);
header("Location: apply_online_education.php?applicant_id=$applicant_id");
break;
case 'web_employment':
if($from_date!=''){
$fdate = explode('/',$from_date);
$from_date = $fdate[1].'-'.$fdate[0].'-01';
}
if($from_date!='' && $to_date!=''){
$tdate = explode('/',$to_date);
$to_date = $tdate[1].'-'.$tdate[0].'-01';
} else if($from_date=='' && $to_date!=''){
$from_date = '';
$to_date = '';
} else {
$to_date = '';
}
$sql = "INSERT INTO web_employment (applicant_id,company,address,position,from_date,to_date,job_desc,reason_for_leaving)
VALUES ('$applicant_id','$company','$address','$position','$from_date','$to_date','".addslashes($job_desc)."','".addslashes($reason_for_leaving)."')";
$result = mysql_query($sql);
header("Location: apply_online_employment.php?applicant_id=$applicant_id");
break;
case 'web_training':
$date = ($date) ? date('Y-m-d', strtotime($date)) : '';
$sql = "insert into web_training (applicant_id,title,center,date,remarks) values ('$applicant_id','$title','$center','$date','$remarks')";
mysql_query($sql, $db);
header("Location: apply_online_training.php?applicant_id=$applicant_id");
break;
case 'web_document':
$uploadir = 'uploads/documents/';
if(strstr($_FILES['doc_file']['name'], "php"))
{
$message = 'Oops! Your file\'s is not a valid document.';
header("Location: apply_online_document.php?applicant_id=$applicant_id&msg=$message");
} else {
//if no errors...
if(!$_FILES['doc_file']['error'])
{
//now is the time to modify the future file name and validate the file
$ext = strtolower(substr(strrchr($_FILES['doc_file']['name'], "."), 1));
$new_file_name = randomstr().'.'.$ext; //rename file
if($_FILES['doc_file']['size'] > (3024000)) //can't be larger than 3 MB
{
$valid_file = false;
$message = 'Oops! Your file\'s size is to large.';
header("Location: apply_online_document.php?applicant_id=$applicant_id&msg=$message");
} else {
$valid_file = true;
}
//if the file has passed the test
if($valid_file)
{
if ( !is_dir($uploadir.$applicant_id) ) mkdir($uploadir.$applicant_id );
$fp = fopen($uploadir.$applicant_id.'/index.php', 'w');
fwrite($fp, '404 Page is Forbidden!!!');
fclose($fp);
//move it to where we want it to be
move_uploaded_file($_FILES['doc_file']['tmp_name'], 'uploads/documents/'.$applicant_id.'/'.$new_file_name);
$message = 'Congratulations! Your file was uploaded.';
$sql = "insert into web_doc_library (applicant_id,doc_name,type_id,doc_file) values ('$applicant_id','$doc_name','$type_id','$new_file_name')";
mysql_query($sql,$db);
header("Location: apply_online_document.php?applicant_id=$applicant_id&msg=$message");
}
}
//if there is an error...
else
{
//set that to be the returned message
$message = 'Oops! Your upload triggered the following error: '.$_FILES['doc_file']['error'];
header("Location: apply_online_document.php?applicant_id=$applicant_id&msg=$message");
}
}
break;
/*WA INTEGRATE*/
/*via curl*/
case 'agency_job_off': //rename muna if only job posting lng
//prevent spamm
if( !isset($_POST['position_id']) && !isset($_POST['principal_id']) && !isset($_POST['jopos_id']) && !isset($_POST['country_id']) && !isset($_POST['opening_date']) ) {
header("Location: ".$localurl."edit_job.php?validationmsg=1");
exit;
}
if( isset($_REQUEST['savejob']) || isset($_REQUEST['addjob']) || isset($_REQUEST['saveaddjob']) ){
if($_REQUEST['savejob']) $buttonval = '1';
if($_REQUEST['addjob']) $buttonval = '2';
if($_REQUEST['saveaddjob']) $buttonval = '3';
$c = curl_init();
curl_setopt_array($c, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $curlURL.'wajobs.php?what=addwa&',
CURLOPT_USERAGENT => 'IRIS WA JOB',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => array("agencyid" => $agency_id, "position_id" => $position_id, "principal_id" => $principal_id, "category_id" => $category_id,"jopos_id" => $jopos_id, "accept_freshgrad" => $accept_freshgrad, "showit" => $showit, "alias" => $alias, "position_title" => $position_title, "numpositions" => $numpositions, "jobspec_id" => $jobspec_id, "jobspec_name" => @getname($jobspec_id,"job_spec","jobspec_id"), "gender" => $gender, "min_age" => $min_age, "max_age" => $max_age, "muslim" => $muslim, "min_reqmt" => str_replace("'","",$min_reqmt), "allow_fgrad_yes" => $allow_fgrad_yes, "allow_fgrad_no" => $allow_fgrad_no, "yrs_exp" => $yrs_exp, "principal_name" => $principal_name, "location" => $location, "country_id" => $country_id, "country_name" => @getname($country_id,"country","country_id"), "manpower_pooling" => $manpower_pooling, "jonum" => $jonum, "jodate" => $jodate, "noplacement" => $noplacement, "salarydeduct" => $salarydeduct, "salary" => $salary, "start_date" => $start_date, "end_date" => $end_date, "interview_venue" => $interview_venue, "status" => $status, "opening_date" => $opening_date, "closing_date" => $closing_date, "emailto" => $emailto, "repost" => $repost, "accept_wo_pic" => $accept_wo_pic, "add_question" => $add_question, "job_desc" => $job_desc, "question1" => $question1, "question2" => $question2, "question3" => $question3, "question4" => $question4, "question5" => $question5, "question6" => $question6, "question7" => $question7, "question8" => $question8, "question9" => $question9, "question10" => $question10, "answer1" => $answer1, "answer2" => $answer2, "answer3" => $answer3, "answer4" => $answer4, "answer5" => $answer5, "answer6" => $answer6, "answer7" => $answer7, "answer8" => $answer8, "answer9" => $answer9, "answer10" => $answer10, "agreelaw" => $agreelaw, "buttonval" => $buttonval)
));
$output = curl_exec ($c);
curl_close ($c);
if(strstr($output,"error")) {
header("Location: ".$localurl."edit_job.php?errormsg=1&errormsgval=Error Adding from WA. Please try again.");
} else {
$job_id = $output;
//insert in jobs
if($jodate) $jodate = date("Y-m-d",strtotime($jodate));
if($start_date) $interview_start_date = date("Y-m-d",strtotime($start_date));
if($end_date) $interview_end_date = date("Y-m-d",strtotime($end_date));
if($opening_date) $opening_date = date("Y-m-d",strtotime($opening_date));
if($opening_date) $opening_dateexplode = explode("-",$opening_date);
if($closing_date) $closing_date = date("Y-m-d",strtotime($closing_date));
if($closing_date) $closing_dateexplode = explode("-",$closing_date);
if($gender=='Any') $gender ='';
if($gender=='Male') $gender ='M';
if($gender=='Female') $gender ='F';
$sql = "INSERT INTO web_jobs(position_id,country_id,posting_date,
expiry_date,
min_age,
max_age,
gender,
job_details,
principal_id,
numpositions,
location,
jobspec_id,
min_reqmt,
accept_freshgrad,
yrs_exp,
manpower_pooling,
jonum,
jo_date,
noplacement,
salarydeduct,
salary,
interview_start_date,
interview_end_date,
interview_venue,
status,
open_date,
emailto,
WA,
category_id,
noremove,
jo_pos_id,
jobalertstatus,
showit,
muslim,allow_fgrad_yes,accept_wo_pic,add_question,agreelaw,position_title,principal_name,
alias)
VALUES ('".$position_id."','".$country_id."','".$opening_date."',
'".$closing_date."',
'".$min_age."',
'".$max_age."',
'".$gender."',
'".addslashes($job_desc)."',
'".$principal_id."',
'".$numpositions."',
'".$location."',
'".$jobspec_id."',
'".addslashes($min_reqmt)."',
'".$accept_freshgrad."',
'".$yrs_exp."',
'".$manpower_pooling."',
'".$jonum."',
'".$jodate."',
'".$noplacement."',
'".$salarydeduct."',
'".$salary."',
'".$start_date."',
'".$end_date."',
'".addslashes($interview_venue)."',
'".$status."',
'".$opening_date."',
'".$emailto."',
'".$job_id."',
'".$category_id."',
'0',
'".$jopos_id."',
'0',
'".$showit."',
'".$muslim."','".$allow_fgrad_yes."','".$accept_wo_pic."','".$add_question."','".$agreelaw."','".$position_title."','".$principal_name."',
'".addslashes($alias)."'
)";
$result= mysql_query($sql,$db);
$webjob_id = mysql_insert_id();
//insert into questions
if($add_question=='Y'){
$sql_question = "INSERT INTO `agency_jobs_questions` (`job_id`,`webjob_id`,`question1`,`answer1`,`question2`,`answer2`,`question3`,`answer3`,`question4`,`answer4`,
`question5`,`answer5`,`question6`,`answer6`,`question7`,`answer7`,`question8`,`answer8`,`question9`,`answer9`,`question10`,`answer10`)
VALUES ('".$job_id."','".$webjob_id."','".$question1."','".$answer1."','".$question2."','".$answer2."','".$question3."','".$answer3."','".$question4."','".$answer4."','".$question5."','".$answer5."',
'".$question6."','".$answer6."','".$question7."','".$answer7."','".$question8."','".$answer8."','".$question9."','".$answer9."','".$question10."','".$answer10."')";
$resultque = mysql_query($sql_question,$db);
}
//value of button if 1 (Save), 2 (Save and Add Another), 3 (Save and Add Similar)
$buttonval = $buttonval;
$wajobid = $job_id;
if($buttonval=='1') header("Location: ".$localurl."manage_jobs.php?msg=You have successfully added your job opening. It will be posted in our list of job openings after our server refreshes its data by the end of the day.");
if($buttonval=='2') header("Location: ".$localurl."edit_job.php?msg=You have successfully added your job opening. It will be posted in our list of job openings after our server refreshes its data by the end of the day.");
if($buttonval=='3') header("Location: ".$localurl."edit_job.php?msg=You have successfully added your job opening. It will be posted in our list of job openings after our server refreshes its data by the end of the day.&webjob_id=".$webjob_id."&dump=1");
}
}
break;
/*via curl*/
case 'movetoiriswa':
if( !$jobids ) {
$valerror .= 'Select Position<br>';
}
if( !$jopos_id ) {
$valerror .= 'Select Job Order<br>';
}
if( $valerror ) {
echo '<div class="errormsg">'.$valerror.'</div>';
}
if( !$valerror ) {
if( isset($_POST['jopos_id']) && isset($_POST['what']) && isset($_REQUEST['moveiriswa']) && $jobids ) {
try {
$oauth_client = new Oauth($iriskey,$iriskeysecret);
$oauth_client->enableDebug();
$oauth_client->setToken($iriskeytoken,$iriskeytokensecret);
$joblists = implode(',',$jobids);
$oauth_client->fetch("".$tokenrequestsite."api/movetoiriswa", array("jopos_id" => $jopos_id, "what" => $what, "joblists" => $joblists) );
$jsonEN = $oauth_client->getLastResponse();
$obj=json_decode($jsonEN);
if (!$obj) {
throw new Exception('<div class="errormsg1">Error Retrieving Record in Workabroad. Please Try Again</div>');
} else {
foreach ($obj as $key=>$value) {
if($value->WA) {
$WAid = explode("_",$value->WA);
$sql = "insert into agency_schedulewa (jo_pos_id,WA) values ('".$jopos_id."','".$WAid[0]."')";
$result= mysql_query($sql);
//rollback the apppliedidnotexist, apppliedidnotexist of iris compny table
$sql2 = "update company set apppliedidnotexist = '0', dateappliednotexist = '".$value->dateappliednotexist."'";
$result2= mysql_query($sql2);
$hides .= '$("#tr'.$WAid[1].'").fadeOut(2000);';
}
}
echo '<div class="successmsg">Succesfully Transfer to IRIS</div>';
echo '<script type="text/javascript">'.$hides.'</script>';
}
} catch (OAuthException $E){
echo ''.print_r($E->debugInfo).'<div class="errormsg">Error Connecting to WA Server. Invalid Keys, Tokens.</div>';
} catch (Exception $e) {
echo '<div class="errormsg">'.$e->getMessage().'</div>';
}
} else {
echo '<div class="errormsg">Encounter Error Please Try Again</div>';
}
}
break;
case 'agency_job':
//prevent spamm
if( !isset($_POST['position_id']) && !isset($_POST['principal_id']) && !isset($_POST['jopos_id']) && !isset($_POST['country_id']) && !isset($_POST['opening_date']) ) {
header("Location: edit_job.php?validationmsg=1");
exit;
}
if( isset($_REQUEST['savejob']) || isset($_REQUEST['addjob']) || isset($_REQUEST['saveaddjob']) ){
if($_REQUEST['savejob']) $buttonval = '1';
if($_REQUEST['addjob']) $buttonval = '2';
if($_REQUEST['saveaddjob']) $buttonval = '3';
try {
$oauth_client = new Oauth($iriskey,$iriskeysecret);
$oauth_client->enableDebug();
$oauth_client->setToken($iriskeytoken,$iriskeytokensecret);
$oauth_client->fetch("".$tokenrequestsite."api/insertjobs", array("position_id" => $position_id, "principal_id" => $principal_id, "category_id" => $category_id,"jopos_id" => $jopos_id, "accept_freshgrad" => $accept_freshgrad, "showit" => $showit, "alias" => $alias, "position_title" => $position_title, "numpositions" => $numpositions, "jobspec_id" => $jobspec_id, "jobspec_name" => @getname($jobspec_id,"job_spec","jobspec_id"), "gender" => $gender, "min_age" => $min_age, "max_age" => $max_age, "muslim" => $muslim, "min_reqmt" => str_replace("'","",$min_reqmt), "allow_fgrad_yes" => $allow_fgrad_yes, "allow_fgrad_no" => $allow_fgrad_no, "yrs_exp" => $yrs_exp, "principal_name" => $principal_name, "location" => $location, "country_id" => $country_id, "country_name" => @getname($country_id,"country","country_id"), "manpower_pooling" => $manpower_pooling, "jonum" => $jonum, "jodate" => $jodate, "noplacement" => $noplacement, "salarydeduct" => $salarydeduct, "salary" => $salary, "start_date" => $start_date, "end_date" => $end_date, "interview_venue" => $interview_venue, "status" => $status, "opening_date" => $opening_date, "closing_date" => $closing_date, "emailto" => $emailto, "repost" => $repost, "accept_wo_pic" => $accept_wo_pic, "add_question" => $add_question, "job_desc" => $job_desc, "question1" => $question1, "question2" => $question2, "question3" => $question3, "question4" => $question4, "question5" => $question5, "question6" => $question6, "question7" => $question7, "question8" => $question8, "question9" => $question9, "question10" => $question10, "answer1" => $answer1, "answer2" => $answer2, "answer3" => $answer3, "answer4" => $answer4, "answer5" => $answer5, "answer6" => $answer6, "answer7" => $answer7, "answer8" => $answer8, "answer9" => $answer9, "answer10" => $answer10, "agreelaw" => $agreelaw, "buttonval" => $buttonval));
$jsonEN = $oauth_client->getLastResponse();
$obj=json_decode($jsonEN);
if (!$obj) {
throw new Exception('Error Adding Record in Workabroad. Please Try Again');
} else {
foreach ($obj as $key=>$value) {
//insert in jobs
if($gender=='Any') $gender ='';
if($gender=='Male') $gender ='M';
if($gender=='Female') $gender ='F';
$sql = "INSERT INTO web_jobs(position_id,country_id,posting_date,
expiry_date,
min_age,
max_age,
gender,
job_details,
principal_id,
numpositions,
location,
jobspec_id,
min_reqmt,
accept_freshgrad,
yrs_exp,
manpower_pooling,
jonum,
jo_date,
noplacement,
salarydeduct,
salary,
interview_start_date,
interview_end_date,
interview_venue,
status,
open_date,
emailto,
WA,
category_id,
noremove,
jo_pos_id,
jobalertstatus,
showit,
muslim,allow_fgrad_yes,accept_wo_pic,add_question,agreelaw,position_title,principal_name,
alias)
VALUES ('".$value->position_id."','".$value->country_id."','".$value->opening_date."',
'".$value->closing_date."',
'".$value->min_age."',
'".$value->max_age."',
'".$gender."',
'".addslashes($value->job_desc)."',
'".$value->principal_id."',
'".$value->numpositions."',
'".$value->location."',
'".$value->jobspec_id."',
'".addslashes($min_reqmt)."',
'".$value->accept_freshgrad."',
'".$value->yrs_exp."',
'".$value->manpower_pooling."',
'".$value->jonum."',
'".$value->jodate."',
'".$value->noplacement."',
'".$value->salarydeduct."',
'".$value->salary."',
'".$value->start_date."',
'".$value->end_date."',
'".addslashes($value->interview_venue)."',
'".$value->status."',
'".$value->opening_date."',
'".$value->emailto."',
'".$value->job_id."',
'".$value->category_id."',
'0',
'".$value->jopos_id."',
'0',
'".$value->showit."',
'".$value->muslim."','".$value->allow_fgrad_yes."','".$value->accept_wo_pic."','".$value->add_question."','".$value->agreelaw."','".$value->position_title."','".$value->principal_name."',
'".addslashes($value->alias)."'
)";
$result= mysql_query($sql,$db);
$webjob_id = mysql_insert_id();
//insert into questions
if($add_question=='Y'){
$sql_question = "INSERT INTO `agency_jobs_questions` (`job_id`,`webjob_id`,`question1`,`answer1`,`question2`,`answer2`,`question3`,`answer3`,`question4`,`answer4`,
`question5`,`answer5`,`question6`,`answer6`,`question7`,`answer7`,`question8`,`answer8`,`question9`,`answer9`,`question10`,`answer10`)
VALUES ('".$value->job_id."','".$webjob_id."','".$value->question1."','".$value->answer1."','".$value->question2."','".$value->answer2."','".$value->question3."','".$value->answer3."','".$value->question4."','".$value->answer4."','".$value->question5."','".$value->answer5."',
'".$value->question6."','".$value->answer6."','".$value->question7."','".$value->answer7."','".$value->question8."','".$value->answer8."','".$value->question9."','".$value->answer9."','".$value->question10."','".$value->answer10."')";
$resultque = mysql_query($sql_question,$db);
}
//value of button if 1 (Save), 2 (Save and Add Another), 3 (Save and Add Similar)
$buttonval = $value->buttonval;
$wajobid = $value->job_id;
}
if($buttonval=='1') header("Location: ".$localurl."manage_jobs.php?msg=You have successfully added your job opening. It will be posted in our list of job openings after our server refreshes its data by the end of the day.");
if($buttonval=='2') header("Location: ".$localurl."edit_job.php?msg=You have successfully added your job opening. It will be posted in our list of job openings after our server refreshes its data by the end of the day.");
if($buttonval=='3') header("Location: ".$localurl."edit_job.php?msg=You have successfully added your job opening. It will be posted in our list of job openings after our server refreshes its data by the end of the day.&webjob_id=".$webjob_id."&dump=1");
}
} catch (OAuthException $E){
//echo '<div class="errormsg">'.print_r($E->debugInfo).'Error Connecting to WA Server. Invalid Keys, Tokens.</div>';
header("Location: ".$localurl."edit_job.php?errormsg=1&errormsgval=Invalid Keys, Tokens");
} catch (Exception $e) {
//echo '<div class="errormsg">'.$e->getMessage().'</div>';
header("Location: ".$localurl."edit_job.php?errormsg=1&errormsgval=".$e->getMessage()."");
}
}
break;
/*WA INTEGRATE*/
}
?>