session_start();
include"../include/conn.php";
require_once('../include/mailfunction.php');
//include_once("../../employer/classes/rndPass.class.php"); Commented on 22-08-2014
include"../include/statictable.php";
$userId=$_SESSION["userId"];
$loginid=$_SESSION["loginid"];
if(!isset($userId)) header("Location: ../profile/newaccount.php?a=displayLogin");
$sql="select count(*) as COUNT from CSS_APP_GENERAL where CSS_APPLICANT_ID=$userId";
// echo $sql;
$rs=OCIParse($conn,$sql);
OCIExecute($rs);
OCIFetchInto($rs,$arr,OCI_ASSOC);
$count=$arr["COUNT"];
$sql4="select count(*) as COUNT from CSS_JOB_RECIEPT a,CSS_APP_GENERAL b where b.CSS_PARENT_ID=$userId and a.CSS_APPLICANT_ID=b.CSS_APPLICANT_ID and a.CSS_ADVERTISEMENT_ID=$_GET[jid]";
// echo $sql4;
$rs4=OCIParse($conn,$sql4);
OCIExecute($rs4);
OCIFetchInto($rs4,$arr4,OCI_ASSOC);
$count4=$arr4["COUNT"];
$jobId=$_GET["jid"];
$a=$_REQUEST["a"];
// echo " count ".$count." ";
// echo " count4 ".$count4." post array ";
// print_r($_POST);
//echo " get ";
//print_r($_GET);
//echo " request ";
//print_r($_REQUEST);
//// checking eligibility
$errMsg="";
$eligible=1;
if($count<=0)
{ $eligible=2;
$errMsg="You have not created your profile. please create you profile to proceed further.
Create Profile ";
} else {
if($count4>0)
{ $eligible=3;
$errMsg="You have already applied. You cannot apply more than once in CSS-2015.
View Application History ";
} else {
$age_sql="select T.CSS_APPLICANT_ID, t.css_dob, p.age_cal_date, t.css_agerex1,
case when months_between(p.age_cal_date,(to_date(t.css_dob,'dd-mm-yyyy')-1))/12 > decode(t.css_agerex1, '00', 28,30) then 'OVERAGE'
when months_between(p.age_cal_date,(to_date(t.css_dob,'dd-mm-yyyy')-1))/12 <21 then 'UNDERAGE' ELSE 'AGEOK' end as age_check
from css_app_general t,
(SELECT d.age_cal_date
FROM CSS_POST_ADVERTISEMENT d
where d.css_advertisement_id=$jobId
) p
where t.css_dob is not null
and T.CSS_APPLICANT_ID=$userId ";
//echo $age_sql; exit;
$age_rs=OCIParse($conn,$age_sql);
OCIExecute($age_rs);
OCIFetchInto($age_rs,$age_ar,OCI_ASSOC);
//print_r($age_ar);
if($age_ar['AGE_CHECK']=='UNDERAGE' or $age_ar['AGE_CHECK']=='OVERAGE') {
$eligible=4;
$errMsg="You are ".$age_ar['AGE_CHECK']." and NOT ELIGIBLE to apply for CSS-2015.
";
} // end of if for age check
//new change
else {
//For checking valid date
$valid_date1="select count(*) as CNTAPP
from css_post_advertisement cpa
where cpa.css_advertisement_id = $jobId
and (trunc(SYSDATE) - trunc(cpa.close_date) <= 0)";
//echo $valid_date1;exit;
$valid_date_rs1=OCIParse($conn,$valid_date1);
OCIExecute($valid_date_rs1);
OCIFetchInto($valid_date_rs1,$valid_date_check1,OCI_ASSOC);
if($valid_date_check1['CNTAPP']<1)
{
$eligible=5;
$errMsg="Sorry, You cannot apply as the CLOSING DATE ".$valid_date_check2["CLOSE_DATE"]." for CSS has expired
";
} //end of if for closing date check
} //new change ends
}// end of if for already applied
} //end if for count porifle creation
// end of eligibility check
/*
if($errMsg<>""){
?>
ERROR
: echo $errMsg; ?>
}*/
//exit;
if(count($_POST)){ ///&& $count>0
// echo " post if";
foreach ($_POST as $key => $value) //new change
{
$$key = $value;
}
//exit;
if ($a =='Apply' && $eligible==1){
?>
$myv = verifyForm_apply();
if ($myv == 1) {
if (insert_data($conn)) //CHANGES MADE DUE TO EDUCATION CHECK THROUGH PROCEDURE
{
SendJobEmail();
}
else //CHANGES MADE DUE TO EDUCATION CHECK THROUGH PROCEDURE CSS_ADD_APPLICANT
{
if ($eligible==15)
{
$errMsg=" Your application cannot be submitted, atleast one Educational Record is missing which makes you eligible to apply!.
Go Back";
//echo "Application not submitted, check your profile and ensure you have entered education record as well.";
}
else if ($eligible==16) //CHANGES MADE DUE TO PROFILE AND APPLICATION CHECK THROUGH PROCEDURE CSS_ADD_APPLICANT
{
$errMsg=" Your application not submitted due to some profile data is not correct.
Go Back";
}
}
?>
// echo "eligible=".$eligible;
if ($eligible==10)
{
?>
$errMsg="Note : Your application will be accepted subject to submission of computer generated prefilled form (duly signed), alongwith all related documents must reach the FPSC Headquarters, Islamabad, not later than Ten(10) days after the closing date.
View Application History";
} //end if eligible=10
} // else of $V=1
else
{ //echo "eligible=".$eligible;
if($eligible==11){
$errMsg=" Please upload Your Picture in your Profile before applying.
Go Back";
}
if($eligible==12){
$errMsg=" Please Enter Your Educational Record, atleast one Educational Record is missing which makes you eligible to apply!.
Go Back";
}
if($eligible==14){
$errMsg=" Please Select your Test Center
Go Back";
}
if($eligible==6){
$errMsg=" Please choose valid Optional Subjects first, in order to submit application.
Go Back";
}
if($eligible==17){ //////////////FOR OCCUPATIONAL GROUPS
$errMsg=" Please choose Occupational Group, in order to proceed further.
Go Back";
}
if($eligible==18){ //////////////FOR PARENTS INFORMATION
$errMsg=" Parents information is not available, please provide parents information in order to proceed further.
Go Back";
}
if($eligible==7){
$errMsg=" Please Enter Treasury Receipt Amount.
Go Back";
}
if($eligible==8){
$errMsg=" Please Enter Valid Treasury Receipt Date.
Go Back";
}
if($eligible==15){ //CHANGES MADE DUE TO EDUCATION CHECK THROUGH PROCEDURE
$errMsg=" Educational record Not found.
Go Back";
}
//echo $errMsg;
}
} //end of a=apply if
} ///// end of count($_POST) && $count>0 if
/*
$ssl="select * from CSS_APP_GENERAL where CSS_APPLICANT_ID=$userId";
$rs=OCIParse($conn,$ssl);
OCIExecute($rs);
OCIFetchInto($rs,$arr1,OCI_ASSOC);
*/
$ad="select CSS_NEW_NIC, CSS_FATHER_NAME from CSS_APP_GENERAL where CSS_APPLICANT_ID=$userId";
$rs=OCIParse($conn,$ad);
OCIExecute($rs);
OCIFetchInto($rs,$ar1,OCI_ASSOC);
$css_nic=$ar1["CSS_NEW_NIC"];
?>