Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.14.245.172
<?php
require_once("/var/www/oasis/aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
function getcolldegree($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$collcode = $_SESSION['collcode'];
$query = "select distinct ifnull(d.FDEGREE, '')as FDEGREE,
ifnull(FDESCPN, '')as FDESCPN
from degree d inner join colldeg c on c.fdegree = d.fdegree
where fcollcode = '{$collcode}'";
$lobj1 = $aobj_context->mobj_db->GetAll($query);
if($lobj1){
echo $aobj_context->mobj_output->ToJSONEnvelope($lobj1,0,"success");
}else{
$arr['msg'] = 'Failed to load';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function getcategoryall($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$query = "select ifnull(FCATEGORY,'')as FCATEGORY from category";
$lobj1 = $aobj_context->mobj_db->GetAll($query);
if($lobj1){
echo $aobj_context->mobj_output->ToJSONEnvelope($lobj1,0,"success");
}else{
$arr['msg'] = 'Failed to load';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function getConvocationDetails($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$collcode = $_SESSION['collcode'];
$degree = $aobj_context->mobj_data["degree"];
if($degree == "All"){
$cond = '';
}else{
$cond = "and fdegree = '{$degree}'";
}
$query = "select ifnull(fregno, '')as fregno,
ifnull(fcollcode, '')as fcollcode,
ifnull(fname, '')as fname,
ifnull(ffatname, '')as ffatname,
ifnull(fmotname, '')as fmotname,
ifnull(fdegree, '')as fdegree,
ifnull(fcaste, '')as fcaste,
ifnull(fgender, '')as fgender,
ifnull(fpercent, '')as fpercent,
ifnull(fcgpa, '')as fcgpa,
ifnull(fgrade, '')as fgrade,
ifnull(fexamdate, '')as fexamdate,
ifnull(famount, '')as famount,
ifnull(fpayid, '')as fpayid,
ifnull(fphotopath, '')as fphotopath,
date_format(fpaydate, '%d/%m/%Y') as fpaydate from autodcstud
where fcollcode = '{$collcode}' {$cond}";
$lobj1 = $aobj_context->mobj_db->GetAll($query);
if($lobj1){
echo $aobj_context->mobj_output->ToJSONEnvelope($lobj1,0,"success");
}else{
$arr['msg'] = 'Failed to load';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function uploadconvophoto($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$regno = $aobj_context->mobj_data["regno"];
$degree = $aobj_context->mobj_data["degree"];
$photo = $_FILES['image'];
$filename = $_FILES["image"]["name"];
$tempname = $_FILES["image"]["tmp_name"];
$path_server = move_uploaded_file($tempname, 'backup/'. $filename);
$univcode = $_SESSION['FUNIVCODE'];
$collcode = $_SESSION['collcode'];
$qrydate = "select sum(case when DATE_FORMAT(NOW(),'%Y-%m-%d') between
FCNVENTFROM AND FCNVENTTO then 1 else 0 end) as fdate
from collexam where fcollcode = '{$collcode}' and fdegree = '{$degree}';";
$resdate = $aobj_context->mobj_db->GetRow($qrydate);
if($resdate['fdate'] === "0"){
$arr['msg'] = 'Last date is over for the given details';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
if($photo){
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$allowedExtensions = array('jpg', 'jpeg');
if (!in_array($extension, $allowedExtensions)) {
$arr['msg'] = 'Only JPG, JPEG files are allowed.';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
$s3 = S3Client::factory(array(
'credentials' => array( 'key' => IAM_KEY, 'secret' => IAM_SECRET),
'version' => "latest",
'region' => 'ap-south-1'
));
if($filename != '' && $filename != NULL){
$image_path = $aobj_context->main_src."backup/{$filename}";
$file_path = $univcode."/"."student_photos/".$collcode."/".$filename;
if(file_exists($image_path)){
try{
$s3->putObject(['Bucket' => "university-cnv-student-photos", 'Key' => $file_path, 'SourceFile' => $image_path]);
$qry = "select fregno from autodcstud where fregno = '{$regno}' and fcollcode='{$collcode}'";
$res = $aobj_context->mobj_db->GetRow($qry);
if(count($res) > 0){
$query = "update autodcstud set fphotopath = '{$file_path}', fupddate=now()
where fregno='{$regno}' and fcollcode='{$collcode}' and fdegree='{$degree}'";
}else{
$query = "insert into autodcstud(fregno, fdegree, fcollcode, fphotopath, fcreateddate)
values('{$regno}', '{$degree}', {$collcode}, '{$file_path}', now())";
}
$result = $aobj_context->mobj_db->Execute($query);
if($result){
unlink($image_path);
$arr['msg'] = "Uploaded Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}else{
$arr['msg'] = 'Failed to upload';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}catch(S3Exception $e) {
$arr['msg'] = 'Failed to upload';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
}
}
}
}
function saveconvocationdet($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$degree = $aobj_context->mobj_data["degree"];
$regno = $aobj_context->mobj_data["regno"];
$name = $aobj_context->mobj_data["name"];
$grade = $aobj_context->mobj_data["grade"];
$gender = $aobj_context->mobj_data["gender"];
$category = $aobj_context->mobj_data["category"];
$exam = $aobj_context->mobj_data["examdate"];
$fees = $aobj_context->mobj_data["fees"];
$feereceipt = $aobj_context->mobj_data["feereceipt"];
$paydate = $aobj_context->mobj_data["paydate"];
$fatname = $aobj_context->mobj_data["fatname"];
$motname = $aobj_context->mobj_data["motname"];
$percent = $aobj_context->mobj_data["percent"];
$cgpa = $aobj_context->mobj_data["cgpa"];
$collcode = $_SESSION['collcode'];
$qry = "select * from autodcstud where fregno = '{$regno}' and fcollcode='{$collcode}'";
$res = $aobj_context->mobj_db->GetRow($qry);
if(count($res) === 0){
$arr['msg'] = 'Please Upload Photo First';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
$qrydate = "select sum(case when DATE_FORMAT(NOW(),'%Y-%m-%d') between
FCNVENTFROM AND FCNVENTTO then 1 else 0 end) as fdate
from collexam where fcollcode = '{$collcode}' and fdegree = '{$degree}';";
$resdate = $aobj_context->mobj_db->GetRow($qrydate);
if($resdate['fdate'] === "0"){
$arr['msg'] = 'Last date is over for the given details';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
$query = "update autodcstud set fname='{$name}', fdegree='{$degree}', fcaste='{$category}',
fgender='{$gender}', fgrade='{$grade}', fexamdate='{$exam}', famount='{$fees}', fpayid='{$feereceipt}',
fpaydate= date_format(str_to_date('{$paydate}','%d/%m/%Y'),'%Y-%m-%d'),
fupddate=now(), ffatname='{$fatname}', fmotname='{$motname}', fpercent='{$percent}', fcgpa='{$cgpa}'
where fregno='{$regno}' and fcollcode='{$collcode}'";
// var_dump($query);
// die();
$result = $aobj_context->mobj_db->Execute($query);
if($result){
$arr['msg'] = 'Saved Successfully';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
return;
}else{
$arr['msg'] = 'Something Went Wrong';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
}
?>
|