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.145.186.132


Current Path : /proc/thread-self/root/var/www/html/admission/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/admission/src/teachvaluationcount.php

<?php
    require_once("/var/www/html/aws/aws-autoloader.php");
    use Aws\S3\S3Client;
    use Aws\S3\Exception\S3Exception;

    function getValuationCount($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $teachcode = $aobj_context->mobj_data["fteachcode"];
        $fdeggrp = $aobj_context->mobj_data["fdeggrp"];
        if($fdeggrp === 'All'){
            $cond = "";
        }else{
            $cond = "and m.fdeggrp = '{$fdeggrp}'";
        }

        $query = "select ifnull(m.fqpcode, '')as fqpcode, ifnull(m.fsubname,'')as fsubname,
                count(fvalno)as fcount, fvalno, t.fteachcode, mt.fteachname
                from tdvs_masqp m
                inner join tdvs_tabsum t on t.fqpcode = m.fqpcode
                inner join tdvs_masteach mt on t.fteachcode = mt.fteachcode where 
                t.fteachcode = '{$teachcode}' $cond
                group by FQPCODE, FVALNO, fteachcode";
                
        $result = $aobj_context->pobj_db->GetAll($query);
        if($result){
            echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
            return;
        }else{
            $arr['msg'] = "No data found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }
    }

    function getValuationCountDetails($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $teachcode = $aobj_context->mobj_data["fteachcode"];
        $qpcode = $aobj_context->mobj_data["qpcode"];
        $valno = $aobj_context->mobj_data["valno"];

        $query = "select ifnull(t.fqpcode, '')as fqpcode, ifnull(m.fsubname,'')as fsubname, 
                ifnull(t.FREGCODE, '')as FREGCODE, ifnull(t.FSYSMARKS, '')as FSYSMARKS,
                ifnull(FFILEPATH, '')as FFILEPATH, ifnull(FVALNO, '')as FVALNO,
                ifnull(t.fstatus, '')as fstatus,
                date_format(t.FSTDATE, '%d/%m/%Y %H:%i:%s')as FSTDATE, 
				date_format(t.FENDATE, '%d/%m/%Y %H:%i:%s')as FENDATE  
                from tdvs_tabsum t inner join tdvs_masqp m on t.fqpcode = m.fqpcode 
                inner join tdvs_tabhead h on t.fqpcode = h.fqpcode and t.fregcode = h.fregcode
                where t.fteachcode = '{$teachcode}' and 
                t.fqpcode = '{$qpcode}' and t.fvalno = '{$valno}'";

        $result = $aobj_context->pobj_db->GetAll($query);
        if($result){
            echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
            return;
        }else{
            $arr['msg'] = "No data found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }
    }

    function getPhotoCopyDet ($aobj_context){
        require_once ('/var/www/html/univadmin/vendor/autoload.php');
        header("Content-Type: text/plain");

        $univcode = $aobj_context->mobj_data["univcode"];
        $qpcode = $aobj_context->mobj_data["qpcode"];
        $regcode = $aobj_context->mobj_data["regcode"];
        $valno = $aobj_context->mobj_data["valno"];

        $get_coll_name = "select FUNIVNAME as FUNIVNAME,FUNIVCODE,
                        FUNIVADD1 as state, pdf_logo_path,
                        ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ From control";
        $lobj_get_coll_name = $aobj_context->pobj_db->GetRow($get_coll_name);

        $get_coll_name = "select FDUMMYNO, if(ifnull(FTOTMARKSV,'-') = '-',FIMGPOSJSON,FIMGPOSJSONV) as FIMGPOSJSON 
                        From tdvs_tabsum where FREGCODE = '{$regcode}'
                        and fvalno = '{$valno}'";
        $res = $aobj_context->pobj_db->GetRow($get_coll_name);

        $FDUMMYNO = $res['FDUMMYNO'];
        $FIMGPOSJSON = $res['FIMGPOSJSON'];  

        $get_coll_name = "select FFILEPATH From tdvs_tabhead 
                        where FREGCODE = '{$regcode}' and fqpcode = '{$qpcode}'";
        $res = $aobj_context->pobj_db->GetRow($get_coll_name);
        $FFILEPATH = $res['FFILEPATH'];

        $keyname = $FFILEPATH;
    
        $s3 = S3Client::factory(
            array(
                'credentials' => array(
                    'key' => IAM_KEY,
                    'secret' => IAM_SECRET
                ),
                'version' => "latest",
                'region'  => 'ap-south-1'
            )
        );
        $filePath = tempnam(sys_get_temp_dir(), rand(10,15));

        try{
            $result = $s3->getObject([
                'Bucket' => PHOTO_COPY,
                'Key'    => $keyname,
                'SaveAs' => $filePath
            ]);
        }catch(S3Exception $e){
        }
                
        $full_photo_path = $filePath;

        require_once ('/var/www/html/univadmin/vendor/autoload.php');
        $main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
        $pdf =  new \Mpdf\Mpdf(['tempDir' => $main_src. '/custom/temp/dir/path']);
        $pagecount = $pdf->SetSourceFile($full_photo_path);
        $valimg = json_decode($FIMGPOSJSON);

        
        $imgvalfpath = $main_src."eval_images/";
        $valimg1 =array();
        for($i = 0;$i<36;$i++)
        {    
            $valimg1[$i] = array();
        }
        $arr[$value['fmenucode']]['children'] = array();


        
        foreach($valimg as $val)
        {
            $qmarks = $val->qmarks;
            $x = $val->x;
            $y = $val->y;
            $newdata = array();
            $newdata =  array (
                'qmarks' => $qmarks,
                'x' => $x,
                'y' => $y
            );
            array_push($valimg1[$val->index],$newdata);
        }
        //$pagecount =3;
        for ($i=0; $i<=$pagecount; $i++) {
            if($i >2)
            {
                $qmarks = $valimg[$i]->qmarks;
                $x = $valimg[$i]->x;
                $y = $valimg[$i]->y;
                
                $import_page = $pdf->ImportPage($i);
                $pdf->UseTemplate($import_page);
                $y = 50;
                // foreach($valimg1[$i-1] as $val1)
                // {
                //     if($val1['qmarks'] == "")
                //         $pdf->Image($imgvalfpath."x.png", 150, 50, 20,  200, 'png', '', true, false);
                //     else
                //         $pdf->Image($imgvalfpath.$val1['qmarks'].".png", 10, $y, 20,  20, 'png', '', true, false);
                //     $y += 50;    
                // }    

                $pdf->AddPage();
            }    
        }

        // if($valno  == '1')
        // {
        //     $filds = "if(ifnull(d.FMARKS11,'-2') = -2,'NA',d.FMARKS11) as FMARKS11,
        //     if(ifnull(d.FMARKS12,'-2') = -2,'NA',d.FMARKS12) as FMARKS12,
        //     if(ifnull(d.FMARKSV1,'-2') = -2,'NA',d.FMARKSV1) as FMARKSV1,
        //     if(ifnull(d.FMARKSV2,'-2') = -2,'NA',d.FMARKSV2) as FMARKSV2,";

        // }else if($valno  == '2')
        // {
        //     $filds = "if(ifnull(d.FMARKS21,'-2') = -2,'NA',d.FMARKS21) as FMARKS11,
        //     if(ifnull(d.FMARKS22,'-2') = -2,'NA',d.FMARKS22) as FMARKS12,
        //     if(ifnull(d.FMARKSV1,'-2') = -2,'NA',d.FMARKSV1) as FMARKSV1,
        //     if(ifnull(d.FMARKSV2,'-2') = -2,'NA',d.FMARKSV2) as FMARKSV2,";
        // }

        if($valno === "1"){
            $filds = "if(ifnull(d.FMARKS11,'-2') = -2,'NA',d.FMARKS11) as FMARKS11,
                     if(ifnull(d.FMARKS12,'-2') = -2,'NA',d.FMARKS12) as FMARKS12,";
        }if($valno === "2"){
            $filds = "if(ifnull(d.FMARKS21,'-2') = -2,'NA',d.FMARKS21) as FMARKS11,
                     if(ifnull(d.FMARKS22,'-2') = -2,'NA',d.FMARKS22) as FMARKS12,";
        }if($valno === "3"){
            $filds = "if(ifnull(d.FMARKS31,'-2') = -2,'NA',d.FMARKS31) as FMARKS11,
                     if(ifnull(d.FMARKS32,'-2') = -2,'NA',d.FMARKS32) as FMARKS12,";
        }if($valno === "4"){
             $filds = "if(ifnull(d.FMARKS41,'-2') = -2,'NA',d.FMARKS41) as FMARKS11,
                     if(ifnull(d.FMARKS42,'-2') = -2,'NA',d.FMARKS42) as FMARKS12,";
        }if($valno === "5"){
             $filds = "if(ifnull(d.FMARKS51,'-2') = -2,'NA',d.FMARKS51) as FMARKS11,
                     if(ifnull(d.FMARKS52,'-2') = -2,'NA',d.FMARKS52) as FMARKS12,";
        }if($valno === "D"){
             $filds = "if(ifnull(d.FMARKSD1,'-2') = -2,'NA',d.FMARKSD1) as FMARKS11,
                     if(ifnull(d.FMARKSD2,'-2') = -2,'NA',d.FMARKSD2) as FMARKS12,";
        }if($valno === "R"){
             $filds = "if(ifnull(d.FMARKSR1,'-2') = -2,'NA',d.FMARKSR1) as FMARKS11,
                     if(ifnull(d.FMARKSR2,'-2') = -2,'NA',d.FMARKSR2) as FMARKS12,";
        }
        
        $query = "select qh.ftempname,qh.fpartdesc,qd.fqnno,d.FQPCODE,s.fsubname,d.FREGCODE,qh.fmaxqn,
        qh.fpartcode,
        qh.fmandqn,
                $filds
                ifnull(d.FMARKSV1,'') as Rev_Marks,fsubqp,s.fexamdate,s.fexamno
                from tdvs_tabdetl d inner join tdvs_masqp s on d.fqpcode = s.fqpcode
                inner join tdvs_qptemphead qh on s.ftempcode = qh.ftempcode
                inner join tdvs_qptempdetl qd on qh.ftempcode = qd.ftempcode 
                and qd.fpartcode = qh.fpartcode
                and d.FQNNO = qd.fqncode
                and s.fqpcode = d.fqpcode
                where d.FREGCODE = '{$regcode}'
                and qd.fsubqp = 'F'
                order by qd.fqnord";
                // var_dump($query);
                // die();
        $res = $aobj_context->pobj_db->GetAll($query);
        
        $pdf->SetMargins(40, 30);

        $img_path = $aobj_context->main_src . "/img/logo_".$lobj_get_coll_name['FUNIVCODE'].".jpg";
        
        if (file_exists($img_path)) {
            $pdf->Image($img_path, 20, 6, 20, 20);
        }

        $pdf->SetFont('Times', 'B', 13);
        $pdf->SetY(10);
        $pdf->Cell(0, 4, $lobj_get_coll_name['FUNIVNAME'], 0, 1, 'C');
        //state
        $pdf->SetFont('Times', '', 11);
        $pdf->Cell(0, 4, $lobj_get_coll_name['state'], 0, 1, 'C');
        $fexamdate = $res[0]['fexamdate'];
        $fexamno = $res[0]['fexamno'];

        $sem = "";
        if($fexamno == 'A')
        {
            $sem = "I";
        }else if($fexamno == 'B')
        {
            $sem = "II";
        }else if($fexamno == 'C')
        {
            $sem = "III";
        }else if($fexamno == 'D')
        {
            $sem = "IV";
        }else if($fexamno == 'E')
        {
            $sem = "V";
        }else if($fexamno == 'F')
        {
            $sem = "VI";
        }

        $pdf->SetFont('Times', 'B', 12);
        $pdf->Ln(1);
        $pdf->Cell(0, 4, $sem." SEMESTER EXAMINATION - ".$fexamdate, 0, 1, 'C');
        $pdf->SetFont('Times', 'BU', 12);

        $pdf->Ln(1);

        $pdf->Cell(0, 5, ' Marks Sheet', '0', 1, 'C');
        $pdf->SetFont('Times', 'B', 12);

        $pdf->Cell(0, 6, $res[0]['FQPCODE'].' - '.$res[0]['fsubname'], 0, 1, "C");
        $pdf->Ln(1);
        $pdf->SetFont('Times', 'B', 12);
        $oldsection ="";
        $newsection ="";
        $pdf->Ln(5);
        $pdf->Cell(120, 6,'Answer Booklet Id: '.$FDUMMYNO.'  Reg. Code.: '.$regcode, 0, 1, "C");
        $pdf->Cell(30, 6,'Qn. No.', 1, 0, "C");
        $pdf->Cell(40, 6,'Examiner Marks' , 1, 0, "C");
        $pdf->Cell(50, 6,'System Allotted Marks' , 1, 1, "C");
        $i = 0;
        $exmarks = 0;
        $sysallot = 0;
        $totexmarks = 0;
        $newpart = '';
        $totsysallot = 0;
        $pdf->SetFont('Times', '', 12);
        $reduce = 0;

        $m_field = "";
        $s_field = "";
        if ($valno == "1") {
            $m_field = "fmarks11";
            $s_field = "fmarks12";
        } else if ($valno == "2") {
            $m_field = "fmarks21";
            $s_field = "fmarks22";
        } else if ($valno == "3") {
            $m_field = "fmarks31";
            $s_field = "fmarks32";
        } else if ($valno == "4") {
            $m_field = "fmarks41";
            $s_field = "fmarks42";
        } else if ($valno == "5") {
            $m_field = "fmarks51";
            $s_field = "fmarks52";
        } else if ($valno == "R") {
            $m_field = "fmarksr1";
            $s_field = "fmarksr2";
        } else if ($valno == "D") {
            $m_field = "fmarksd1";
            $s_field = "fmarksd2";
        } else if ($valno == "W") {
            $m_field = "fmarksv1";
            $s_field = "fmarksv2";
        }


        foreach($res as $value)
        {
            $newsection = $value['fpartdesc'];
            if($oldsection != $newsection)
            {
                if($i != 0)
                {  
                
                    $query = "select a.fqpcode, m.fsubname, c.ftempname, b.fpartcode, c.fpartdesc, 
                    sum(if(ifnull(a.$m_field,0) < 0, 0, a.$m_field)) as fmarks11, 
                    sum(if(ifnull(a.$s_field,0) < 0, 0, a.$s_field))  as fmarks12,
                    c.fmaxmarks, c.ftempmax, c.fmaxqn, c.fmandqn
                    from tdvs_tabdetl a inner join tdvs_masqp m 
                    on a.fqpcode = m.fqpcode inner join 
                    tdvs_qptempdetl b on m.ftempcode = b.ftempcode  and a.fqnno = b.fqncode
                    inner join tdvs_qptemphead c on b.ftempcode = c.ftempcode and b.fpartcode = c.fpartcode
                    where fregcode = '{$regcode}' and a.fqpcode = '{$qpcode}' 
                    and b.fqncode = b.fqnparent
                    and c.fpartcode = '{$newpart}'
                    group by c.ftempname, b.fpartcode";
                    $res9 = $aobj_context->pobj_db->GetRow($query);
                    // var_dump($query);
                    // die();
                    $exmarks = $res9['fmarks11'];
                    $sysallot = $res9['fmarks12'];

                    $pdf->SetFont('Times', 'B', 12);
                    $pdf->Cell(30, 6,'Total', 1, 0, "C");
                    $pdf->Cell(40, 6,$exmarks , 1, 0, "C");
                    $pdf->Cell(50, 6,$sysallot , 1, 1, "C");
                    
                    $totexmarks +=$exmarks;
                    $totsysallot +=$sysallot;

                    $exmarks = 0;
                    $sysallot = 0;
                    $pdf->SetFont('Times', '', 12);
                }

                $pdf->Cell(120, 6,$value['fpartdesc'].'('.$value['fmandqn'].'/'.$value['fmaxqn'].')' , 1, 1, "C");
                $oldsection = $newsection;
                $reduce = $value['fmandqn'];
            
            }

            if($value['fsubqp'] == 'F')
             $pdf->Cell(30, 6,$value['fqnno'] , 1, 0, "C");

            if($value['Rev_Marks'] == '')
            {
                if($value['fsubqp'] == 'F')
                {
                    $pdf->Cell(40, 6,$value['FMARKS11'] , 1, 0, "C");
                    $pdf->Cell(50, 6,$value['FMARKS12'] , 1, 1, "C");
                }
                
                if($value['fmandqn'] == $value['fmaxqn'])
                {
                    $qpexmarks =($value['FMARKS11']=='NA')?0:$value['FMARKS11'];
                    $qpsysallot =($value['FMARKS12']=='NA')?0:$value['FMARKS12'];
                    
                    $exmarks +=floatval($qpexmarks);
                    $sysallot +=floatval($qpsysallot);
                }else
                {
                    if($value['fsubqp'] == 'T')
                    {
                        $qpexmarks =($value['FMARKS11']=='NA')?0:$value['FMARKS11'];
                        $qpsysallot =($value['FMARKS12']=='NA')?0:$value['FMARKS12'];
                    
                        $exmarks +=floatval($qpexmarks);
                        $sysallot =floatval($qpsysallot);
                        
                       
                    }
                }  

                
                

            }else
            {   
                if($value['fsubqp'] == 'F')
                {
                    $pdf->Cell(40, 6,$value['FMARKSV1'] , 1, 0, "C");
                    $pdf->Cell(50, 6,$value['FMARKSV2'] , 1, 1, "C");
                }

                if($value['fmandqn'] == $value['fmaxqn'])
                {
                    $qpexmarks =($value['FMARKSV1']=='NA')?0:$value['FMARKSV1'];
                    $qpsysallot =($value['FMARKSV2']=='NA')?0:$value['FMARKSV2'];
                    
                    $exmarks +=floatval($qpexmarks);
                    $sysallot +=floatval($qpsysallot);
                }else
                {
                    if($value['fsubqp'] == 'T')
                    {
                        $qpexmarks =($value['FMARKSV1']=='NA')?0:$value['FMARKSV1'];
                        $qpsysallot =($value['FMARKSV2']=='NA')?0:$value['FMARKSV2'];
                    
                        $exmarks =floatval($qpexmarks);
                        $sysallot =floatval($qpsysallot);
                        
                    }
                }
            }
            $newpart = $value['fpartcode'];
            $i++;
            
        }

        $query = "select a.fqpcode, m.fsubname, c.ftempname, b.fpartcode, c.fpartdesc, 
        sum(if(ifnull(a.$m_field,0) < 0, 0, a.$m_field)) as fmarks11, 
        sum(if(ifnull(a.$s_field,0) < 0, 0, a.$s_field))  as fmarks12,
        c.fmaxmarks, c.ftempmax, c.fmaxqn, c.fmandqn
        from tdvs_tabdetl a inner join tdvs_masqp m 
        on a.fqpcode = m.fqpcode inner join 
        tdvs_qptempdetl b on m.ftempcode = b.ftempcode  and a.fqnno = b.fqncode
        inner join tdvs_qptemphead c on b.ftempcode = c.ftempcode and b.fpartcode = c.fpartcode
        where fregcode = '{$regcode}' and a.fqpcode = '{$qpcode}' 
        and b.fqncode = b.fqnparent
        and c.fpartcode = '{$newpart}'
        group by c.ftempname, b.fpartcode";
        $res9 = $aobj_context->pobj_db->GetRow($query);
        // var_dump($query);
        // die();
        $exmarks = $res9['fmarks11'];
        $sysallot = $res9['fmarks12'];

        $pdf->SetFont('Times', 'B', 12);
        $pdf->Cell(30, 6,'Total', 1, 0, "C");
        $pdf->Cell(40, 6,$exmarks , 1, 0, "C");
        $pdf->Cell(50, 6,$sysallot , 1, 1, "C");
        $pdf->Ln(2);
        
        $totexmarks +=$exmarks;
        $totsysallot +=$sysallot;

        $pdf->SetFont('Times', 'B', 12);
        $pdf->Cell(30, 6,'Grand Total', 1, 0, "C");
        $pdf->Cell(40, 6,$totexmarks , 1, 0, "C");
        $pdf->Cell(50, 6,$totsysallot , 1, 1, "C");

        $pdf->Ln(2);
        $pdf->Cell(30, 6,'Final Marks awarded: '.$totsysallot, 0, 1, "L");

        $pdf->Output('Photo_Copy.pdf', 'I');
        
    }

    function getRegcodeDetails($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $regcode = $aobj_context->mobj_data["regcode"];

        $query = "select ifnull(t.fqpcode, '')as fqpcode, ifnull(m.fsubname, '')as fsubname,
                ifnull(t.fregcode, '')as fregcode, ifnull(t.fvalno, '')as fvalno, 
                ifnull(t.fsysmarks, '')as fsysmarks, ifnull(t.fstatus, '')as fstatus,
                ifnull(mt.fteachname, '')as fteachname, 
                ifnull(mt.fteachcode, '')as fteachcode,
                date_format(t.FSTDATE, '%d/%m/%Y %H:%i:%s')as FSTDATE, 
                date_format(t.FENDATE, '%d/%m/%Y %H:%i:%s')as FENDATE
                from tdvs_tabsum t inner join tdvs_masqp m
                on t.fqpcode = m.fqpcode inner join tdvs_masteach mt on 
                mt.FTEACHCODE = t.fteachcode where t.fregcode='{$regcode}'
                union 
                select ifnull(t.fqpcode, '')as fqpcode, ifnull(m.fsubname, '')as fsubname,
                ifnull(t.fregcode, '') as fregcode, 'W' as fvalno, 
                ifnull(t.FSYSMARKSV, '') as fsysmarks, 
                ifnull(t.FREVSTATUS, '') as fstatus,
                ifnull(mt.fteachname, '')as fteachname, 
                ifnull(mt.fteachcode, '')as fteachcode,
                date_format(t.FSTDATEV, '%d/%m/%Y %H:%i:%s')as FSTDATE, 
                date_format(t.FENDATEV, '%d/%m/%Y %H:%i:%s')as FENDATE
                from tdvs_tabsum t inner join tdvs_masqp m
                on t.fqpcode = m.fqpcode inner join tdvs_masteach mt on 
                mt.FTEACHCODE = t.FREVCODE where t.fregcode='{$regcode}'
                and ifnull(t.FREVSTATUS, '') <> ''";
        $result = $aobj_context->pobj_db->GetAll($query);
        if($result){
            echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
            return;
        }else{
            $arr['msg'] = "No data found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }
    }

    function tdvs_getTeachDet($aobj_context){
        $univcode = $aobj_context->mobj_data["univcode"];
        $fdeggrp = $aobj_context->mobj_data["fdeggrp"];
        if($fdeggrp == 'All'){
            $cond= "";
        }else{
            $cond = "where qp.fdeggrp = '{$fdeggrp}'";
        }

        $query = "select distinct t.fteachcode , concat(t.fteachname, ' ','[',t.fteachcode,']')as fteachname from tdvs_masqp qp 
        inner join tdvs_tabsum sum on qp.fqpcode = sum.fqpcode
        inner join tdvs_masteach t on sum.fteachcode = t.fteachcode
        $cond order by t.fteachname";
        $result = $aobj_context->pobj_db->GetAll($query);
        if($result){
            echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
            return;
        }else{
            $arr['msg'] = "No data found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
            return;
        }
    }
?>