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


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

<?php
    function getAssignModeratorDetails($aobj_context){
        $board = $aobj_context->mobj_data["board"];
        $qpcode = $aobj_context->mobj_data["qpcode"];
        $deggrp = $aobj_context->mobj_data["deggrp"];
        $qptype = $aobj_context->mobj_data["qptype"];
        $fuser = $aobj_context->mobj_data["fuser"];
        $flogtyp = $aobj_context->mobj_data["flogtyp"];

        
        $qry = "select fyear, fexamtype from deggrp where fdeggrp='{$deggrp}'";
        $row = $aobj_context->mobj_db->GetRow($qry);

        $year = $row["fyear"];
        $examtype = $row["fexamtype"]; 

        if($qpcode === "All"){
            $qpcond = "";
        }else{
            $qpcond = "and s.fqpcode = '{$qpcode}'";
        }

        if($board === "All"){
            $boardCond = "";
        }else{
            $boardCond = "and s.fboard = '{$board}'";
        }
        
        if($flogtyp == "All"){
            $logCond = "";
        }else if($flogtyp == "Allowed"){
            $logCond = "and ifnull(m.flogin, '') = 'T'";
        }else if($flogtyp == "NotAllowed"){
            $logCond = "and ifnull(m.flogin, '') <> 'T'";
        }

        $get_data= "select distinct s.fqpcode, concat(s.fsubname, ' - ', s.fsubshort) as fsubname, 
                    ifnull(m.fteachcode,'') as fteachcode, ifnull(m.flogin, '')as fstatus, m.fdeleted,
                    mas.fteachname, mas.fmobile,count(q.fset) as fset, 
                    SUM(if(IFNULL(q.fqpfilepath, '')<>'', 0, 1)) as not_uploaded,
                    SUM(if(IFNULL(q.fqpfilepath, '')='', 0, 1)) as uploaded,
                    date_format(ifnull(m.ffromdate,'00/00/0000'), '%d/%m/%Y') as ffromdate,
                    date_format(ifnull(m.ftodate,'00/00/0000'), '%d/%m/%Y') as ftodate,
                    ifnull(m.femailstatus,'') as emailstatus,ifnull(q.fmodstatus,'')as fmodstatus
                    from moderator m right join subject s on m.fqpcode = s.fqpcode
                    left join masteach mas on mas.fteachcode = m.fteachcode  
                    inner join degree d on d.fdegree = s.fdegree and d.fexamno = s.fexamno
					left join qpseterdet q on s.fqpcode = q.fqpcode
                    where d.fdeggrp = '{$deggrp}' and ifnull(s.fqpcode, '') <> ''
                    and q.ftype = '{$qptype}' {$logCond}
                    {$boardCond} {$qpcond} group by s.fqpcode";
        
        $lobj_get_data = $aobj_context->mobj_db->GetAll($get_data);

        $teach = "select fteachcode, fteachname, fmobile  from masteach where ifnull(fteachcode, '')<>''";
        $teach_res = $aobj_context->mobj_db->GetAll($teach);

        if($teach_res){
            $arr['teach'] = $teach_res;
            $arr['mod'] = $lobj_get_data;
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");  
        }else{
            $arr['msg'] = 'Failed to load';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        }
    }

    function saveAssignModerator($aobj_context){
        include("error_log.php");
        include("sendzohomail.php");
        $univcode = $aobj_context->mobj_data["univcode"];
        $user = $aobj_context->mobj_data["user"];
        $degree = $aobj_context->mobj_data["exam"];
        $board = $aobj_context->mobj_data["board"];
        $qpcode = $aobj_context->mobj_data["qpcode"];
        $qptype = $aobj_context->mobj_data["qptype"];
        $data = json_decode($aobj_context->mobj_data["data"], true);
        $onldate = date('d-m-Y');

        $qry = "select fyear, fexamtype from deggrp where fdeggrp='{$degree}'";
        $row = $aobj_context->mobj_db->GetRow($qry);

        $year = '2222';
        $mode = '2'; 

        foreach($data as $val){
            $query = "select fqpcode from moderator where fqpcode = '{$val['fqpcode']}'";
            $res = $aobj_context->mobj_db->GetRow($query);
            
            if($val['fteachcode']!==NULL && $val['fteachcode']!=="" && $val['fteachcode']!=="Select"){
                
                if($res['fqpcode'] == $val['fqpcode']){
                     
                $Qry = "update moderator set fyear='{$year}', fexamtype='{$mode}', fteachcode='{$val['fteachcode']}', 
                        flogin='{$val['fstatus']}', fdeleted='{$val['fdeleted']}', fcreateduser='{$user}',ffromdate = date_format(str_to_date('{$val['ffromdate']}', '%d/%m/%Y'), '%Y-%m-%d'),
                        ftodate = date_format(str_to_date('{$val['ftodate']}', '%d/%m/%Y'), '%Y-%m-%d'),fcreatedate=now(), femailstatus = '{$val['emailstatus']}',
                        ftype = '{$qptype}'
                        where fqpcode='{$val['fqpcode']}'";
                    
                }else{
                    $Qry = "insert ignore into moderator (fyear, fexamtype, fqpcode, fteachcode, flogin, 
                        fdeleted, fcreateduser, fcreatedate, femailstatus,ffromdate,ftodate,ftype) 
                        values('{$year}', '{$mode}', '{$val['fqpcode']}',
                        '{$val['fteachcode']}', '{$val['fstatus']}', '{$val['fdeleted']}',
                        '{$user}', now(), '{$val['emailstatus']}',date_format(str_to_date('{$val['ffromdate']}', '%d/%m/%Y'), '%Y-%m-%d'),
                        date_format(str_to_date('{$val['ftodate']}', '%d/%m/%Y'), '%Y-%m-%d'),'{$qptype}')";
                }

                
                $result = $aobj_context->mobj_db->Execute($Qry);
                
                $freezque = "update qpseterdet set fmodstatus = '{$val['fmodstatus']}'
                where fqpcode = '{$val['fqpcode']}' 
                and fmodteach = '{$val['fteachcode']}'
                and ftype = '{$qptype}'";
                // var_dump($freezque);die();
                $freezed = $aobj_context->mobj_db->Execute($freezque);
                
                
                $remarks = "Moderator is Assigned for teacher ".$val['fteachcode']." and qpcode ".$val['fqpcode']." and exam year and number ".$year."-".$mode;
                $res = error_logs($aobj_context, $univcode, $remarks, $collcode, "Assign Moderator", $user, $user);
            }

            if($result){
                
                $slt = "select FMOBILE, fteachcode, FEMAIL from masteach where fteachcode = '{$val['fteachcode']}'";
                $reslt = $aobj_context->mobj_db->GetRow($slt);

                $mobile = $reslt['FMOBILE'];
                $usertype = $reslt['FUSERTYPE'];
                $emailid = $reslt['FEMAIL'];

                $query = "select FMOBILENO, FEMAIL, FUSERTYPE from qp_masuser where fregno='{$val['fteachcode']}' 
                          and fmobileno='{$reslt['FMOBILE']}' and fusertype = 'M'";
                $reslt = $aobj_context->mobj_db->GetRow($query);

                $query1 = "select FMOBILENO, FEMAIL, FUSERTYPE, FPASSWORD from qp_masuser where fregno='{$val['fteachcode']}' 
                               and fusertype = 'T'";
               

                $reslt1 = $aobj_context->mobj_db->GetRow($query1);

                $pwd = $mobile;
                if($reslt1){
                    $pwd = $reslt1['FPASSWORD']; 
                }

                if(count($reslt) == 0){
                    $queryIns = "insert ignore into qp_masuser(FREGNO, FMOBILENO, FEMAIL,
                                FUSERTYPE, FPASSWORD, FACTIVE)
                                values('{$val['fteachcode']}', '{$mobile}', '{$emailid}',
                                'M', '{$pwd}', 'T')";
                } else {
                    $queryIns = "update qp_masuser set FACTIVE='T', FPASSWORD='{$pwd}' where FREGNO='{$val['fteachcode']}' and 
                                 FMOBILENO='{$mobile}' and fusertype = 'M'";
                }

                
                $resultIns = $aobj_context->mobj_db->Execute($queryIns);
                
                $remarks = "Added new Usertype for ".$val['fmobile']." and Univcode ".$univcode;
                $res = error_logs($aobj_context, $univcode, $remarks, $collcode, "Assign Moderator", $user, $user);
             
                if($resultIns){
                    $sentStat = "select ifnull(fsent, '')as fsent from moderator where  
                                fteachcode='{$val['fteachcode']}'";
                                
                    $sentRes = $aobj_context->mobj_db->GetRow($sentStat);
                    
                    // if($sentRes['fsent'] !== 'T'){
                        
                        if($val['emailstatus'] == 'T'){

                            $slt = "select FMOBILENO, FUSERTYPE, FPASSWORD, FEMAIL from qp_masuser
                                    where FMOBILENO = '{$mobile}'";
                                    
                            $reslt = $aobj_context->mobj_db->GetRow($slt);
                            $usertype = $reslt['FUSERTYPE'];
                            $emailid = $reslt['FEMAIL'];

                            // $getEmail = "select FEMAIL from masteach where FMOBILE = '{$val['fmobile']}'";
                            // $ret = $aobj_context->mobj_db->GetRow($getEmail);
                            $emailsent = $emailid;
                
                            $unishort = "select funivname, ffolder, pdf_logo_path, FTOWN  from control";
                            $resunishort = $aobj_context->mobj_db->GetRow($unishort);
                            $univname = $resunishort['funivname'];
                            $town = $resunishort['FTOWN'];
                            $univshort = strtoupper($resunishort['ffolder']);

                            $teachDet = "select ifnull(m.fteachname, '')as fteachname, 
                                        ifnull(m.fcollname, '')as fcollname, d.fdegncode, 
                                        ifnull(d.fdegndesc, '')as fdegndesc 
                                        from masteach m inner join masdegn d on d.fdegncode = m.fdegncode 
                                        where fteachcode = '{$val['fteachcode']}'";

                            $teachDet1 = $aobj_context->mobj_db->GetRow($teachDet);
                            $teachname = $teachDet1['fteachname'];
                            $colladd = $teachDet1['fcollname'];
                            $degn = $teachDet1['fdegndesc'];

                            $query1 = "select distinct s.fqpcode,s.fsubname,d.fexamdate,d.fexamname,d.fdescpn  
                                        from subject s 
                                        inner join degree d on s.fdegree = d.fdegree and s.fexamno = d.fexamno
                                        where fqpcode = '{$val['fqpcode']}'";
                            $res1 = $aobj_context->mobj_db->GetRow($query1);
                            $fqpcode = $res1['fqpcode'];
                            $fsubname = $res1['fsubname'];
                            $fexamdate = $res1['fexamdate'];
                            $fexamnmae = $res1['fexamname'];
                            $fdescpn = $res1['fdescpn'];

                            $qur = "select fmodemail,ftdvs_helplineno from control";
                            $resn = $aobj_context->mobj_db->GetRow($qur);

                            $mailmtr =$resn['fmodemail'];
                            $helplineno =$resn['ftdvs_helplineno'];

                            $qur1 = "select fexamdate from deggrp where fdeggrp = '{$degree}'";
                            $resn1 = $aobj_context->mobj_db->GetRow($qur1);

                            $exm =$resn1['fexamdate'];

                            $frmdate = $val['ffromdate'];
                            $todate = $val['ftodate'];

                            if($univcode == "051"){
                                $logo_path = "/img/dyp_elogo.jpeg";
                            }else{
                                $logo_path = $resunishort['pdf_logo_path'];
                            }

                            $logo = "https://college.universitysolutions.in/".$resunishort['ffolder'].'/'. $logo_path;

                            $message="<html>";
                            $message.="<body>";
                            $message.="<style>";        
                            $message.=".mail_tbl td{text-align:left; padding:2px; font-size:12px; 
                                font-family: Verdana, Arial, Helvetica, sans-serif;}";  
                            $message.="</style>";
                            $message.="<center><img src='{$logo}' height='100px' width='200px'/></center>";
                            $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; text-align:center; color:red'>
                            CONFIDENTIAL</p>";
                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // Ref.: DYPU/COE/AYU/2022-23/EP/C-041.</p>";
                            $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif; text-align:right'>Date.:"." $onldate "."</p>";
                            $message.="<p>Dear Sir/Madam,<br><br><br></p>";
                            // $message.="<p style='line-height: 0;'>"."$teachname".",<br></p>";
                            // if($degn != ""){
                            //     $message.="<p style='line-height: 2;'>"."$degn".",<br></p>";
                            // }
                            // if($colladd != ""){
                            //     $message.="<p style='line-height: 0;'>"."$colladd".",<br></p>";
                            // }
                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // Sub: Appointment as Question Paper moderator for the University Examination – Summer 2023.</p>";

                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // Dear Sir / Madam,</p>";

                            $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            The University is pleased to appoint you as the Question paper moderator for the course "."$fqpcode"."–"."$fsubname"." of $fdescpn, University exams.<br>
                            You are asked to report to the CoE office on {$todate} and complete the Question paper moderation on the same day.</p>";

                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // <table style='width: 100%;border: 1px solid'><tr><th style='border: 1px solid'>Course Code</th>
                            // <th style='border: 1px solid'>Course Name</th><th style='border: 1px solid'>Total No of QP for the code (both Internal & external)</th></tr>
                            // <tr style='text-align:center'><td style='border: 1px solid'>"."$fqpcode"."</td><td style='border: 1px solid'>"."$fsubname"."</td>
                            // <td style='border: 1px solid'>"."{$val['fset']}"."</td></tr></table></p>";

                            $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            {$mailmtr}</p>";

                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // You are asked to report at CoE office on DATE at TIME</p>";

                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // Kindly submit your bank details at the portal.</p>";

                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // Syllabus with Course Outcomes (CO) and Question Paper Pattern are provided. Kindly prepare question paper as per the requirements
                            // of COs and Blooms Taxonomy (Preferably higher cognitive levels) and indicate them at the appropriate places in the question paper along with the marks allotted.</p>";

                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // The Question paper and the answer key (All Sections) are to be uploaded only in the portal on or before "."$lastdate"."</p>";
                            
                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // Kindly submit your bank details at the portal.</p>";

                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // Kindly inform your acceptance within three days of the receipt of this communication</p><br>";

                            $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            Portal Login details are as follows.<br><br>";
                            $message.="Portal Link: https://qpms.universitysolutions.in/#/".strtolower($resunishort['ffolder'])."/register"."<br>";

                            $message.="Teacher Code:"."{$val['fteachcode']}"."<br>";
                            $message.="Mobile No.:"."{$val['fmobile']}"."<br></p>";

                            $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            Kindly call to "."$helplineno"." in case if you have any technical issues.<br></p>";

                            $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            Thanking You,</p>";

                            // $message.="<p style='font-size:12px; font-family: Verdana, Arial, Helvetica, sans-serif'>
                            // Yours Sincerely<br><br><br>";

                            $querySign =  "select distinct s.fqpcode, d.fsignpath from degree d inner join subject s on 
                                        s.fdegree = d.fdegree and s.fexamno = d.fexamno 
                                        where s.fqpcode='{$fqpcode}' and ifnull(fsignpath,'')<>''";

                            $ressign = $aobj_context->mobj_db->GetRow($querySign);
                            
                            $sign = $ressign['fsignpath'];

                            $signpath = "https://college.universitysolutions.in/".$resunishort['ffolder']."/img/".$sign;

                            if($sign!==NULL){
                                $message .= "<img src='{$signpath}' width='100' height='50'/>";
                                $message .= "<br/>";
                            }
                            $message.="Controller of Examinations<br>"."$univname"."<br>
                            $town
                            </p>";

                            $message.="</body>";
                            $message.="</html>";

                            $subject= strtoupper("$univshort".": Appointment as Moderator for the University ".$fexamdate." Examination"); 
                            $from = "";

                            $qry10 = "select ifnull(femailkey, '')as femailkey, ifnull(FSUPEMAIL, '')as FSUPEMAIL from logisys3_comexam.dbname where funivcode='{$univcode}'";
                            $res10 = $aobj_context->mobj_db->GetRow($qry10);
                        
                            $resp = sendZohoMail($emailsent, $subject, $message, $res10['femailkey'], $res10['FSUPEMAIL']);

                            $insQry = "update moderator set fsent='T' where fteachcode='{$val['fteachcode']}'";
                            $res = $aobj_context->mobj_db->Execute($insQry);

                        }
                    // }
                }
            }
        }
        
        if($resultIns){
            $arr['msg'] = 'Saved Successfully';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");    
        } else{
            $arr['msg'] = 'Failed to save';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
        }  
    }

?>