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 : 13.59.236.101
<?php
require_once(_DIR_."/../../aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
function getQpDeggrp($aobj_context){
$db = $aobj_context->mobj_data['db'];
if($db === "dypatil"){
$cnd = "qpset_deggrp";
}else{
$cnd = "deggrp";
}
$query = "select fdeggrp, concat(fdescpn, '[ ', fdeggrp, ' ]')as fdescpn from {$cnd}
where ifnull(fdeleted, '')<>'T'";
$res = $aobj_context->mobj_db->GetAll($query);
if ($res) {
echo $aobj_context->mobj_output->TOJSONEnvelope($res, 0, "success");
}else{
$arr['msg'] = "failed to load deggrp";
echo $aobj_context->mobj_output->TOJSONEnvelope($arr, -1, "failed");
return;
}
}
function getQpDegree($aobj_context){
$deggrp = $aobj_context->mobj_data['deggrp'];
if($deggrp === "All"){
$deggrpcnd = "ifnull(fdeggrp, '') <> ''";
}else{
$deggrpcnd = "fdeggrp = '{$deggrp}'";
}
$query="select ifnull(fdegree,'') as fdegree, concat(fdescpn, ' [', fdegree, ']') as fdescpn
from degree
where {$deggrpcnd}
group by fdegree";
// var_dump($query);die();
$result = $aobj_context->mobj_db->GetAll($query);
if($result){
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
} else {
$arr['msg']="Failed to load degree";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function getQpBoard($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$deggrp = $aobj_context->mobj_data["deggrp"];
$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);
if(count($result) > 0){
echo $aobj_context->mobj_output->ToJSONEnvelope($result,0,"success");
} else {
$arr['msg'] = 'No board data found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function getQpcode($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$board = $aobj_context->mobj_data["board"];
$deggrp = $aobj_context->mobj_data["deggrp"];
if($board === "All"){
$cnd = "";
}else{
$cnd = "and s.fboard = '{$board}'";
}
$query = "select distinct s.fqpcode,
concat(s.fsubname,' ( ',group_concat(distinct 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,'') <> '' and d.fdeggrp = '{$deggrp}'
group by s.fqpcode";
$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 code found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function getUploadQpPatternDetails($aobj_context){
$db = $aobj_context->mobj_data["db"];
$board = $aobj_context->mobj_data["board"];
$deggrp = $aobj_context->mobj_data["deggrp"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$sem = $aobj_context->mobj_data["sem"];
$status = $aobj_context->mobj_data["status"];
if($qpcode == "All"){
$qpcnd = "";
}else{
$qpcnd = "and s.fqpcode = '{$qpcode}'";
}
if($sem == "All"){
$semcnd = "";
}else{
$semcnd = "and d.fexamno='{$sem}'";
}
if($status === "pending"){
$statuscnd = "and ifnull(s.FQPPATREN, '') = ''";
}else if($status === "uploaded"){
$statuscnd = "and (ifnull(s.FQPPATREN, '') <> ''
or ifnull(s.FSCHPATTERN, '') <> ''
or ifnull(s.FQPSYLLABUS, '') <> '')";
}else{
$statuscnd = "";
}
$query = "select distinct ifnull(fqpcode, '')as fqpcode,
concat(s.fsubname, ' - ', s.fsubshort) as fsubname,
ifnull(FSUBSHORT, '')as FSUBSHORT,
ifnull(FQPPATREN, '')as FQPPATREN,
ifnull(FQPSYLLABUS, '')as FQPSYLLABUS,
ifnull(FSCHPATTERN, '')as FSCHPATTERN,
fboard,ifnull(s.ftempcode,'')as ftempcode
from subject s inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
inner join deggrp dg on d.fdeggrp = dg.fdeggrp
where d.fdeggrp = '{$deggrp}'
and ifnull(s.fqpcode,'') <> ''
{$qpcnd} {$semcnd} {$statuscnd}
group by s.fqpcode";
// if($db ==='reva'){
// var_dump($query);die();
// }
$result = $aobj_context->mobj_db->GetAll($query);
$que = "select DISTINCT ftempcode from tdvs_qptemphead";
$res = $aobj_context->mobj_db->GetAll($que);
if($result){
$arr['data']= $result;
$arr['temp'] = $res;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}else{
$arr['msg'] = 'Failed to get the data';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function uploadQpPattern($aobj_context){
include("error_log.php");
$data = json_decode($aobj_context->mobj_data["data"], true);
$univcode = $aobj_context->mobj_data["univcode"];
$userid = $aobj_context->mobj_data["userid"];
$syllabusFile = $_FILES['syllabusFile'];
$qpFile = $_FILES['qpFile'];
$schemeFile = $_FILES['schemeFile'];
$date = date("Ymdhis");
try {
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
));
if($qpFile['tmp_name'] !== null){
$qpfileExt = pathinfo($qpFile['name'], PATHINFO_EXTENSION);
$key = $univcode.'/'.'pattern/'.$date.'_'.$data['fqpcode'].'_pattern'.'.'.$qpfileExt;
$s3->putObject(['Bucket' => "qp-scheme", 'Key' => $key, 'SourceFile' => $qpFile['tmp_name']]);
$query = "update subject set fqppatren='{$key}',
ftempcode='{$data['ftempcode']}',
fqpdate=now(), fuserid='{$userid}'
where fqpcode = '{$data['fqpcode']}'";
// var_dump($query);die();
$result = $aobj_context->mobj_db->Execute($query);
}
if($schemeFile['tmp_name'] !== null){
$schemeFileExt = pathinfo($schemeFile['name'], PATHINFO_EXTENSION);
$key = $univcode.'/'.'scheme/'.$date.'_'.$data['fqpcode'].'_scheme'.'.'.$schemeFileExt;;
$s3->putObject(['Bucket' => "qp-scheme", 'Key' => $key, 'SourceFile' => $schemeFile['tmp_name']]);
$query = "update subject set fschpattern='{$key}',
ftempcode='{$data['ftempcode']}',
fqpdate=now(), fuserid='{$userid}'
where fqpcode = '{$data['fqpcode']}'";
$result = $aobj_context->mobj_db->Execute($query);
}
if($syllabusFile['tmp_name'] !== null){
$syllabusFileExt = pathinfo($syllabusFile['name'], PATHINFO_EXTENSION);
$key = $univcode.'/'.'syllabus/'.$date.'_'.$data['fqpcode'].'_syllabus'.'.'.$syllabusFileExt;;
$s3->putObject(['Bucket' => "qp-scheme", 'Key' => $key, 'SourceFile' => $syllabusFile['tmp_name']]);
$syllabusFileExt = pathinfo($syllabusFile['name'], PATHINFO_EXTENSION);
$query = "update subject set fqpsyllabus='{$key}',
ftempcode='{$data['ftempcode']}',
fqpdate=now(), fuserid='{$userid}'
where fqpcode = '{$data['fqpcode']}'";
$result = $aobj_context->mobj_db->Execute($query);
}
// var_dump($query);die();
if($result){
$remarks = "uploaded qppattern and syllabus pattern file against qpcode ".$data['qpcode'];
$res = error_logs($aobj_context, $univcode, $remarks, '', "Upload QP Pattern and Syllabus Pattern", $userid, $userid);
$arr['msg'] = 'File uploaded';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "Success");
}else{
$arr['msg'] = 'Failed to upload';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
} catch (S3Exception $e) {
$arr['msg'] = 'Failed to upload';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
?>
|