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.15.17.137
<?php
require_once(_DIR_."/../../aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
function viewQPDegrpDet($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["funivcode"];
$usertype = $aobj_context->mobj_data["fusertype"];
$fcollcode = $aobj_context->mobj_data["fcollege"];
$query = "";
if($usertype == 'T' || $usertype == 'P') {
$query = "select ifnull(x.fdeggrp,'')as fdeggrp,ifnull(x.fdescpn,'')as fdescpn,
ifnull(x.fyear,'') as fyear,
ifnull(x.fexamtype, '') as fexamtype, ifnull(x.fexamdate, '') as fexamdate,
if(ifnull(x.fdeleted,'') = 'T', 'true', 'false') as fdeleted ,ifnull(ftype,'') as ftype
from notif_deggrp x inner join degree y on x.fdeggrp = y.fdeggrp
inner join student s on y.fdegree = s.fdegree
where ifnull(x.fdeleted,'') <> 'T' and s.fcollcode = '{$fcollcode}'
group by x.fdeggrp";
} else {
$query = "select ifnull(fdeggrp,'') as fdeggrp,ifnull(fdescpn,'') as fdescpn,
ifnull(fyear,'') as fyear,ifnull(fexamtype,'') as fexamtype, ifnull(fexamdate, '') as fexamdate
from notif_deggrp
where ifnull(fdeleted,'') <> 'T'";
}
$result = $aobj_context->mobj_db->GetAll($query);
if (!$result && gettype($result) == 'boolean') {
$arr['msg'] = "Error while fetching degree group";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
return;
}
if (count($result) > 0) {
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
return;
} else {
$arr['msg'] = 'Degree Group not defined';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getDeggrpDet($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$type = $aobj_context->mobj_data["type"];
if($type === "old"){
$query = "select distinct ifnull(dg.fdeggrp,'')as fdeggrp, ifnull(d.fyear,'')as fyear,
ifnull(d.fexamtype,'')as fexamtype,ifnull(p.fdescpn,'')as fdescpn,
ifnull(d.fexamdate,'')as fexamdate
from qpseterdet q
inner join degexam d on q.fyear = d.fyear and q.fexamtype = d.fexamtype
inner join degree dg on d.fdegree = dg.fdegree and dg.fexamno = d.fexamno
inner join deggrp p on p.fdeggrp = dg.fdeggrp
where ifnull(fqpfilepath,'') <> ''
group by dg.fdeggrp,q.fyear,q.fexamtype";
}else{
$query = "select ifnull(fdeggrp,'')as fdeggrp,ifnull(fyear,'')as fyear,
ifnull(fexamtype,'')as fexamtype,ifnull(fdescpn,'')as fdescpn,
ifnull(fexamdate,'')as fexamdate
from deggrp where ifnull(fdeleted, '') <> 'T'";
}
$result = $aobj_context->mobj_db->GetAll($query);
if(count($result) > 0)
{
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
}
else
{
$arr['msg'] = 'No data Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function viewQPBoard($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$exam = $aobj_context->mobj_data["fdeggrp"];
$examarray = explode("*",$exam);
$deggrp = $examarray[0];
$query = "select distinct fboardcode, fboardname from masboard m
inner join subject s on m.fboardcode = s.fboard
inner join degree d on s.fdegree = d.fdegree
where ifnull(m.fdeleted,'') <>'T'
and d.fdeggrp = '{$deggrp}'";
$result = $aobj_context->mobj_db->GetAll($query);
$quer ="select ifnull(fdegree,'') as fdegree,ifnull(fdescpn,'') as fdescpn
from degree where fdeggrp = '{$deggrp}'
group by fdegree";
$res = $aobj_context->mobj_db->GetAll($quer);
if(count($result) > 0)
{
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
}
else
{
$arr['msg'] = 'No Board Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function viewQPDegree($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$exam = $aobj_context->mobj_data["fdeggrp"];
$examarray = explode("*",$exam);
$deggrp = $examarray[0];
$query = "select ifnull(fdegree,'') as fdegree,ifnull(fdescpn,'') as fdescpn
from degree where fdeggrp = '{$deggrp}'
group by fdegree";
$result = $aobj_context->mobj_db->GetAll($query);
if(count($result) > 0)
{
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
}
else
{
$arr['msg'] = 'No Board Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function viewQPSubj($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$board = $aobj_context->mobj_data["fboard"];
$exam = $aobj_context->mobj_data["fdeggrp"];
$examarray = explode("*",$exam);
$deggrp = $examarray[0];
if($board === "All"){
$boardCond = "";
}else{
$boardCond = "and s.fboard = '{$board}'";
}
$query = "select s.fqpcode, concat(s.fsubname,' ( ',s.fsubshort,' )', ' - ', s.fssubname) as fsubname
from subject s inner join degree d on s.fdegree = d.fdegree and
s.fexamno = d.fexamno
where ifnull(s.fqpcode,'') <> '' $boardCond
and d.fdeggrp = '{$deggrp}'";
$result = $aobj_context->mobj_db->GetAll($query);
if(count($result) > 0)
{
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
}
else
{
$arr['msg'] = 'No QP Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function viewQPData($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["funivcode"];
$deggrp = $aobj_context->mobj_data["fdeggrp"];
$board = $aobj_context->mobj_data["board"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$degree = $aobj_context->mobj_data["degree"];
$sem = $aobj_context->mobj_data["fexamno"];
$status = $aobj_context->mobj_data["fstatus"];
if($board === "All"){
$boardCond = " ";
}else{
$boardCond = "and qd.fboard='{$board}'";
}
if($qpcode === "All"){
$qpCond = " ";
}else{
$qpCond = " and qd.fqpcode = '{$qpcode}'";
}
if($degree === "All"){
$degCond = " ";
}else{
$degCond = "and d.fdegree = '{$degree}'";
}
if($sem === "All"){
$semCond = " ";
}else{
$semCond = "and d.fexamno = '{$sem}'";
}
if($status === "All"){
$statCond = " ";
}else if($status === "uploaded"){
$statCond = "and ifnull(fqpfilepath, '')<>'' and ifnull(fanskeypath, '')<>'' and
ifnull(fmodqppath, '')<>''";
}else if($status === "not_uploaded"){
$statCond = "and ifnull(fqpfilepath, '')='' and ifnull(fanskeypath, '')='' and
ifnull(fmodqppath, '')=''";
}
$query = "select ifnull(q.fqpcode,'')as fqpcode,
concat(s.fsubname, ' - ', s.fsubshort, ' - ', q.fqpcode) as fsubname,
ifnull(q.fset,'')as fset, ifnull(m.fteachcode,'')as fteachcode,
ifnull(m1.fteachname,'') as fmodteachname, ifnull(q.fmodteach,'')as fmodteach,
ifnull(q.fqpfilepath, '')as fqpfilepath, ifnull(q.fmodqpupd, '')as fmodqppath,
ifnull(q.fmodanskey, '')as fmodansfilepath,
date_format(ifnull(fqpdtme,''), '%d/%m/%Y %H:%i:%s')as fqpupddate,
ifnull(m.fteachname,'')as fteachname, ifnull(q.ffinalpaper, '') as ffinalpaper,
ifnull(q.fyear,'')as fyear, ifnull(q.fexamtype,'')as fexamtype,
ifnull(q.fanskeypath, '')as fanskeypath, ifnull(q.fstatus, '') as status
from qpseterdet q inner join subject s on s.fqpcode = q.fqpcode
inner join masteach m on m.fteachcode = q.fteachcode
left join masteach m1 on m1.fteachcode = q.fmodteach
inner join qpseter qd on qd.fqpcode = q.fqpcode
and qd.fteachcode = q.fteachcode
inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
where d.fdeggrp = '{$deggrp}' and q.ftype = 'THEORY'
{$boardCond} {$qpCond} {$degCond} {$semCond} {$statCond}
group by q.fqpcode, m.fteachcode,q.fset,q.fyear,q.fexamtype
order by q.fqpcode, m.fteachcode, q.fset,qd.fyear,qd.fexamtype";
$result = $aobj_context->mobj_db->GetAll($query);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
}else{
$arr['msg'] = 'No Data Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function viewFinalQP($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$deggrp = $aobj_context->mobj_data["exam"];
$board = $aobj_context->mobj_data["board"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$degree = $aobj_context->mobj_data["degree"];
$sem = $aobj_context->mobj_data["sem"];
$date = $aobj_context->mobj_data["ffinaldate"];
$board === "All" ? $boardCond = " " : $boardCond = "and s.fboard='{$board}'";
$qpcode === "All" ? $qpCond = " " : $qpCond = "and s.fqpcode='{$qpcode}'";
$degree === "All" ? $degreeCond = " " : $degreeCond = "and s.fdegree='{$degree}'";
$sem === "All" ? $semCond = " " : $semCond = "and s.fexamno='{$sem}'";
$findateCond = "";
if($date !== ""){
$findateCond = "and STR_TO_DATE(ifnull(q.ffinalpaperdate,''), '%Y-%m-%d') = '{$date}'";
}
$query = "select q.fqpcode, concat(s.fsubname, ' - ', s.fsubshort) as fsubname,q.fexamtype,q.fyear,
DATE_FORMAT(ffinalpaperdate,'%d-%m-%Y %H:%i:%s') as ffinalpaperdate,
q.fset, ifnull(fmodqpupd, '')as fmodqpupd, ifnull(fmodanskey, '')as fmodanskey, ifnull(q.fremarks,'') as fremarks,
ifnull(fmodform, '')as fmodform, q.fteachcode, s.fboard, group_concat(distinct s.fdegree) as fdegree, m.fteachname,
date_format(q.fmodqpdate, '%d/%m/%Y')as fmodqpdate, date_format(q.fqpdtme, '%d/%m/%Y')as fqpdtime,
ifnull(q.ffinalqpdate,'') as ffinalqpdate,ifnull(q.ffinalqppath,'') as ffinalqppath,
ifnull(q.ffinalqpuser,'') as ffinalqpuser, ifnull(q.ffinalqpstatus,'') as ffinalqpstatus,
ifnull(q.ffinalansdate,'') as ffinalansdate,ifnull(q.ffinalanspath,'') as ffinalanspath,
ifnull(q.ffinalansuser,'') as ffinalansuser, ifnull(q.ffinalansstatus,'') as ffinalansstatus,
if(ifnull(q.ffinalqpstatus,'F') = 'T','T','F') as ffinl, ifnull(q.fpretype, 'upload')as fpretype, ifnull(q.ftype, '')as ftype
from qpseterdet q
inner join subject s on s.fqpcode = q.fqpcode
inner join degree d on d.fdegree = s.fdegree and d.fexamno = s.fexamno
inner join masteach m on q.fteachcode = m.fteachcode
where ifnull(fmodqpdate, '') <> '' and d.fdeggrp='{$deggrp}' and
q.ffinalpaper='T'
{$degreeCond} {$semCond}
{$boardCond} {$qpCond}
{$findateCond}
and ifnull(q.fdeleted, '') <> 'T'
group by q.fqpcode,q.fteachcode,q.fset,q.fyear,q.fexamtype
order by ffinalpaperdate desc, q.fqpcode";
$result = $aobj_context->mobj_db->GetAll($query);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
}else{
$arr['msg'] = 'No Data Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function saveFinalQPData($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
include("error_log.php");
$univcode = $aobj_context->mobj_data["univcode"];
$userid = $aobj_context->mobj_data["userid"];
$exam = $aobj_context->mobj_data["exam"];
$data = json_decode($aobj_context->mobj_data["data"], true);
$qpcode = $data['fqpcode'];
$fremarks = $data['fremarks'];
$fteachcode = $data['fteachcode'];
$ffinalqpstatus = $data['ffinalqpstatus'];
$set = $data['fset'];
$examexplode= explode('*',$exam);
$curyear = $examexplode[0];
$curexam = $examexplode[1];
$curyearexam = $examexplode[1]."-".$examexplode[2];
$fyearmode = $data['fyear'];
$fexammode = $data['fexamtype'];
$yearmode = $data['fyear']."-".$data['fexamtype'] ;
$finQPFile = $_FILES['finQPFile'];
$finalQPFile = $finQPFile['name'];
$finalQPData = $finQPFile['tmp_name'];
$qpExt = pathinfo($finalQPFile, PATHINFO_EXTENSION);
$finAnsFile = $_FILES['finAnsFile'];
$finalAnsFile = $finAnsFile['name'];
$finalAnsData = $finAnsFile['tmp_name'];
$ansExt = pathinfo($finalAnsFile, PATHINFO_EXTENSION);
$date = date('Y-m-d H:i:s');
if($finQPFile!=="" && $finQPFile!==NULL){
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$length = 30;
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
$file_name = $qpcode."_Final_QP_".$randomString.".".$qpExt;
$server_path = move_uploaded_file($finalQPData, "QP_Details/". $file_name);
$file_path = $aobj_context->main_src."QP_Details/{$file_name}";
if(file_exists($file_path)){
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
));
$key = $univcode."/".$curyearexam."/".$qpcode."/".$file_name;
$s3->putObject(['Bucket' => "moderator-upd", 'Key' => $key, 'SourceFile' => $file_path]);
}
$qur = "select * from tdvs_qpfile where fqpcode = '{$qpcode}'
and fyear = '{$curyear}' and fexamtype = '{$curexam}'";
$res = $aobj_context->mobj_db->GetRow($qur);
if(count($res) !== 0){
$insrt_tdvs = "update tdvs_qpfile set FQPFILEPATH='{$key}', FQPDATE=now()
where fqpcode = '{$qpcode}'
and fyear = '{$curyear}' and fexamtype = '{$curexam}'";
}else{
$insrt_tdvs = "INSERT INTO tdvs_qpfile (FQPCODE, FYEAR, FEXAMTYPE,FQPFILEPATH,FQPDATE)
VALUES('{$qpcode}','{$curyear}','{$curexam}','{$key}',now())";
}
$result1 = $aobj_context->mobj_db->Execute($insrt_tdvs);
$consd = ",ffinalqppath='{$key}', ffinalqpdate=now(),
ffinalqpuser = '{$userid}'";
}
if($finAnsFile!=="" && $finAnsFile!==NULL){
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$length = 30;
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
$file_name = $qpcode."_Final_ANS_".$randomString.".".$ansExt;
$server_path = move_uploaded_file($finalAnsData, "QP_Details/". $file_name);
$file_path = $aobj_context->main_src."QP_Details/{$file_name}";
if(file_exists($file_path)){
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
));
$Anskey = $univcode."/".$curyearexam."/".$qpcode."/".$file_name;
$s3->putObject(['Bucket' => "moderator-upd", 'Key' => $Anskey, 'SourceFile' => $file_path]);
}
$qur = "select * from tdvs_qpfile where fqpcode = '{$qpcode}'
and fyear = '{$curyear}' and fexamtype = '{$curexam}'";
$res = $aobj_context->mobj_db->GetRow($qur);
if(count($res) !== 0){
$insrt_tdvs = "update tdvs_qpfile set FSCHEMA='{$Anskey}', FQPDATE=now()
where fqpcode = '{$qpcode}'
and fyear = '{$curyear}' and fexamtype = '{$curexam}'";
}else{
$insrt_tdvs = "INSERT INTO tdvs_qpfile (FQPCODE, FYEAR, FEXAMTYPE,FSCHEMA,FQPDATE)
VALUES('{$qpcode}','{$curyear}','{$curexam}','{$Anskey}',now())";
}
$result1 = $aobj_context->mobj_db->Execute($insrt_tdvs);
$consd1 = ",ffinalanspath='{$Anskey}', ffinalansdate=now(),ffinalansuser = '{$userid}'";
}
$query = "update qpseterdet set fremarks = '{$fremarks}',
ffinalqpstatus = '{$ffinalqpstatus}', fcuryear = '{$curyear}',fcurexamtype = '{$curexam}'
$consd $consd1
where fqpcode = '{$qpcode}'
and fyear = '{$fyearmode}' and fexamtype = '{$fexammode}'
and ffinalpaper = 'T' and fteachcode = '{$fteachcode}'
and fset='{$set}'";
$result = $aobj_context->mobj_db->Execute($query);
if($result) {unlink($file_path);}
if($result || $result1){
$arr['msg'] = "Uploaded Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
return;
}else{
$arr['msg'] = 'Failed to upload';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
}
?>
|