0xV3NOMx
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.137.198.181


Current Path : /var/www/html/collportal/custom_src/
Upload File :
Current File : //var/www/html/collportal/custom_src/qptran.php

<?php

    require_once(_DIR_."/../../aws/aws-autoloader.php");
    use Aws\S3\S3Client;
    use Aws\S3\Exception\S3Exception;

    function getQptranDeggrp($aobj_context){

        $usertype = trim($aobj_context->mobj_data['usertype']);

        $query = "select fdeggrp, fdescpn from deggrp where ifnull(fdeleted, 'F')<>'T'";
        $resdeggrp = $aobj_context->mobj_db->GetAll($query);

        if($resdeggrp){
            echo $aobj_context->mobj_output->ToJSONEnvelope($resdeggrp, 0, "success");
        }else{
            $arr['msg'] = 'No degree group found';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }
    }

    function getSessionAndDate($aobj_context){

        $usertype = trim($aobj_context->mobj_data['usertype']);
        $deggrp = trim($aobj_context->mobj_data['deggrp']);

        $query = "select distinct date_format(su.fdoe,'%d/%m/%Y') as id,
        date_format(su.fdoe,'%d/%m/%Y') as value
        from canddet cd inner join subject su on cd.fdegree = su.fdegree
        and cd.fexamno = su.fexamno
        and cd.fsubcode = su.fsubcode
        inner join degree d on d.fdegree = su.fdegree and d.fexamno = su.fexamno
        where ifnull(su.fqpcode,'') <> ''
        and ifnull(fdoe,'0000-00-00') <> '0000-00-00'
        and cd.fpresent = 'p'
        and d.fdeggrp='{$deggrp}'
        group by su.fqpcode
        order by fdoe desc";
        $resdoe = $aobj_context->mobj_db->GetAll($query);
        
        $query = "select distinct su.FSESSION as id,
        r.FDESCPN as value
        from canddet cd inner join subject su on cd.fdegree = su.fdegree
        and cd.fexamno = su.fexamno
        and cd.fsubcode = su.fsubcode
        inner join reason r on su.FSESSION = r.FREASONCD
        inner join degree d on d.fdegree = su.fdegree and d.fexamno = su.fexamno
        where ifnull(su.fqpcode,'') <> ''
        and ifnull(fdoe,'0000-00-00') <> '0000-00-00'
        and cd.fpresent = 'p'
        and d.fdeggrp='{$deggrp}'
        group by su.fqpcode
        order by su.FSESSION";
        $ressession = $aobj_context->mobj_db->GetAll($query);

        if($resdoe){
            $arr['qptrandoe'] = $resdoe;
            $arr['qptransession'] = $ressession;
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
        } else {
            $arr['msg'] = 'Error while fetching Dates';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }
    }

    function uploadQpTranFile($aobj_context){
        $usertype = trim($aobj_context->mobj_data['usertype']);
        $deggrp = trim($aobj_context->mobj_data['deggrp']);
        $date = trim($aobj_context->mobj_data['date']);
        $session = trim($aobj_context->mobj_data['session']);
        $enableQp = trim($aobj_context->mobj_data['enableQp']);
        $autoSchedule = trim($aobj_context->mobj_data['autoSchedule']);
        $file = $_FILES['file'];
        $filename = $file['name'];
        $tmpdata = $file['tmp_name'];

        if($deggrp == ""){
            $arr['msg'] = 'Select Degree Group';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }

        if($date == "" || $date == "Select"){
            $arr['msg'] = 'Select Date of Examination';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }

        if($session == "" || $session == "Select"){
            $arr['msg'] = 'Select Examination Session';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }

        if($file == NULL){
            $arr['msg'] = 'Select File';
            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'
        ));
        // $s3->putObject(['Bucket' => "qptran", 'Key' => $key, 'SourceFile' => $tmpdata]);
        $dateObject = DateTime::createFromFormat('d/m/Y', $date);
        $formattedDate = $dateObject->format('Y-m-d');
        $dayOfWeekNumeric = date('l', strtotime($formattedDate));
        if($enableQp){
            $cnd = 'T';
        }else{
            $cnd = 'F';
        }

        $query = "insert into qpupload (fdeggrp, fsession, fexamdate, fday, ffilename, fenable, 
                  fschdate, fschfrtime, fschtotime, fupddate, fupduser)
                  values('{$deggrp}', '{$session}', '{$formattedDate}', '{$dayOfWeekNumeric}', '{}', 
                  '{$cnd}', '', '', '', now(), 'admin')";

                
        $res = $aobj_context->mobj_db->Execute($query);

        if($res){
            $arr['msg'] = 'Updated 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;
        }
    }

    function getQptranAutoScheduleTime($aobj_context){
        $usertype = trim($aobj_context->mobj_data['usertype']);
        $session = trim($aobj_context->mobj_data['session']);

        if($session === "N"){
            $cnd = "ifnull(FAFRTIME, '')as FROMTIME, ifnull(FATOTIME, '')as TOTIME";
        }else if($session === "M"){
            $cnd = "ifnull(FMFRTIME, '')as FROMTIME, ifnull(FMTOTIME, '')as TOTIME";
        }
        $query = "select {$cnd} from control";
        $res = $aobj_context->mobj_db->GetRow($query);

        if($res){
            echo $aobj_context->mobj_output->ToJSONEnvelope($res, 0, "success");
            return;
        }else{
            $arr['msg'] = 'Something went wrong';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }
    }
?>