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 : 18.117.11.13


Current Path : /var/www/oasis/Report_details/
Upload File :
Current File : /var/www/oasis/Report_details/getTestTotalMarksReport.php

<?php
    $main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
    error_reporting(E_ALL);
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);
    date_default_timezone_set('GMT+5:30');
    ini_set('max_execution_time', 300);
    ini_set('memory_limit', '2G');

    if (PHP_SAPI == 'cli')
        die('This example should only be run from a Web Browser');

    $pdf_writer_class = $main_src . '/PHPExcel/Classes/PHPExcel.php';
    require_once($pdf_writer_class);

    function getheaders($objPHPExcel, $fileName){
        ini_set('max_execution_time', '300');
        $objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1);
        $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
        $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);
        $objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
        $objPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);

        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename=' . $fileName);
        header('Cache-Control: max-age=0');
        header('Cache-Control: max-age=1');

        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); 
        header('Cache-Control: cache, must-revalidate'); 
        header('Pragma: public');
        ob_clean();
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
        $objWriter->save('php://output');
    }

    function getTestWiseAllMarksData($aobj_context){
  
        session_start();
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
        $collcode=$_SESSION['collcode'];
        $degree = $aobj_context->mobj_data["degree"];
        $sem = $aobj_context->mobj_data["sem"];
        $subject = $aobj_context->mobj_data["sub"];
        $testName = $aobj_context->mobj_data["test"];
        $subele=$aobj_context->mobj_data["subelement"];
	
        $page_header_university = "select FUNIVNAME as 'FUNIVNAME',FUNIVCODE,
        FUNIVADD1 as 'state', pdf_logo_path,
        ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ From control";
        $lobj_page_header_university = $aobj_context->mobj_db->GetRow($page_header_university);	

        $get_coll_name = "select fcollname as FCOLLNAME, ftown as FTOWN from college 
                        where fcollcode = '{$collcode}'";
        $res_coll_name = $aobj_context->mobj_db->GetRow($get_coll_name);

        $FUNIVNAME = $lobj_page_header_university['FUNIVNAME'];
        $STATE = $lobj_page_header_university['state'];
    
        $objPHPExcel = new PHPExcel();
        
        $fileName = 'Test_Wise_Marks_Report.xls';
    
        $objPHPExcel->getProperties()->setCreator("Uniclare")
        ->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
        ->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
        ->setKeywords("Excel Sheet")->setCategory("Me");
    
        $objPHPExcel->setActiveSheetIndex(0);
  
        $styleArray = array(
            'borders' => array(
                'allborders' => array(
                    'style' => PHPExcel_Style_Border::BORDER_THIN,
                    'color' => array('argb' => '000000'),
                ),
            ),
        );

                
        $query="SELECT DISTINCT LEFT(m.fsubcode, 4)AS fsubcode, fsubshort FROM marksint m 
                inner join subject s on s.fcsubcode = left(m.fsubcode, 5) and s.fdegree = m.fdegree 
                and s.fexamno = m.fexamno WHERE m.fdegree='{$degree}' AND m.fexamno='{$sem}' ORDER BY fsubcode";
        $res_sub = $aobj_context->mobj_db->GetAll($query);
        $alpha=['E','F','G','H','I','J','K','L','M','N','O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
        // $alpha=['D','F','H','J','L','N','P','R','T','V','X','Z'];
        // $merge=['C4:D4','E4:F4','G4:H4','I4:J4','K4:L4','M4:N4','O4:P4','Q4:R4','S4:T4','U4:V4','W4:X4','Y4:Z4'];

        $objPHPExcel->getActiveSheet()->getStyle('1:5')->getFont()->setBold(true);
        $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(18);
        $objPHPExcel->getActiveSheet()->getStyle('2:2')->getFont()->setSize(18);
        $objPHPExcel->getActiveSheet()->getStyle('3:3')->getFont()->setSize(14);
        $objPHPExcel->getActiveSheet()->getStyle('4:4')->getFont()->setSize(13);
        
        $objPHPExcel->getActiveSheet()->setCellValue('A1',"         ". $lobj_page_header_university['FUNIVNAME']);
        $objPHPExcel->getActiveSheet()->setCellValue('A2',"         College -".$res_coll_name['FCOLLNAME']." - ". $lobj_page_header_university['state']);
        $objPHPExcel->getActiveSheet()->setCellValue('A3',"            Degree -".$degree. "      Semester -".$sem );
    
        $objPHPExcel->getActiveSheet()->setCellValue('A4', 'Sl. No');
        $objPHPExcel->getActiveSheet()->setCellValue('B4', 'Reg. No');
        $objPHPExcel->getActiveSheet()->setCellValue('C4', 'Student Name');
        $objPHPExcel->getActiveSheet()->setCellValue('D4', 'Section');
        $objPHPExcel->getActiveSheet()->getStyle('A4:D4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);  
        $i=0;

        if(count($res_sub) > 0){
            foreach($res_sub as $val){
                $objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].'4', $val['fsubshort']);
                $objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].'5', 'Marks');
                // $objPHPExcel->getActiveSheet()->mergeCells($merge[$i]);
                $objPHPExcel->getActiveSheet()->getStyle($alpha[$i].'4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);  
                $objPHPExcel->getActiveSheet()->getStyle($alpha[$i].'5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);  
                $i++;
            }
        }

        $objPHPExcel->getActiveSheet()->mergeCells('A4:A5');
        $objPHPExcel->getActiveSheet()->mergeCells('B4:B5');
        $objPHPExcel->getActiveSheet()->mergeCells('C4:C5');
        $objPHPExcel->getActiveSheet()->mergeCells('D4:D5');
        $objPHPExcel->getActiveSheet()->freezePane('A6');

        $query3="SELECT stu.FREGNO, stu.FNAME, sd.fexamno, stu.FSECTION, 
                group_concat(left(mak.fsubcode, 4), '-', su.fsubshort, '-', IFNULL(ftotal, ''), '-', IFNULL(facttotal, '') order by a.fsubcode separator '|' )as marksdet,
                sd.fdegree, stu.fcollcode, IFNULL(ftotal, '')AS ftotal, 
                IFNULL(facttotal, '')AS facttotal, 
                fmarks1A, fmarks1B,fmarks1C,
                fmarks2A,fmarks2B,fmarks2C,
                fmarks3A,fmarks3B,fmarks3C,
                fmarks4A,fmarks4B,fmarks4C, 
                fu1max,a.fteachcode FROM attendsum a 
                INNER JOIN student stu ON stu.FREGNO=a.FREGNO AND stu.fdegree = a.fdegree 
                INNER JOIN degree d ON d.FDEGREE =a.FDEGREE AND d.Fexamno=a.Fexamno 
                INNER JOIN subdet sd ON a.fdegree = sd.fdegree AND a.fexamno = sd.fexamno 
                AND LEFT(a.fsubcode,4) = LEFT(sd.fcsubcode,4) 
                inner join subject su on su.fcsubcode = a.fsubcode and su.fdegree = a.fdegree and su.fexamno = a.fexamno
                LEFT JOIN marksint mak ON a.fdegree = mak.fdegree AND a.FREGNO=mak.FREGNO 
                AND mak.ftest = '{$testName}' and sd.fsubname='{$subele}' AND left(mak.fsubcode, 4)=left(a.fsubcode, 4)
                WHERE a.FCOLLCODE='{$collcode}' AND left(mak.fsubcode, 4)=left(a.fsubcode, 4) 
                AND a.fdegree='{$degree}' AND a.fexamno='{$sem}' GROUP BY fregno ORDER BY fname";
                
               
        $result3 = $aobj_context->mobj_db->GetAll($query3);
        
        if(count($result3)>0){
            $z=1;
            foreach($result3 as $key=> $val){
                $slNo = $key + 6;
                $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
                $objPHPExcel->getActiveSheet()->setCellValue('A'.$slNo, $z)->getColumnDimension('A')->setwidth(8);
                $objPHPExcel->getActiveSheet()->setCellValue('B'.$slNo, $val['FREGNO'])->getColumnDimension('B')->setwidth(20);
                $objPHPExcel->getActiveSheet()->setCellValue('C'.$slNo, $val['FNAME'])->getColumnDimension('C')->setwidth(40);
                $objPHPExcel->getActiveSheet()->setCellValue('D'.$slNo, $val['FSECTION'])->getColumnDimension('D')->setwidth(8);
                $split = explode("|", $val['marksdet']);  
                foreach($split as $v){
                    $splitagain = explode("-", $v);
                    $j=0;
                    foreach ($res_sub as $value) {
                        if($value['fsubcode'] == $splitagain[0]){
                            $objPHPExcel->getActiveSheet()->setCellValue($alpha[$j].$slNo, $splitagain[3])->getColumnDimension($alpha[$j])->setwidth(15);
                            $objPHPExcel->getActiveSheet()->getStyle($alpha[$j].$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);  
                        }
                        $j++;
                    }        
                }
                $z++;
                $objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':B'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);  
                $objPHPExcel->getActiveSheet()->getStyle('D'.$slNo.':D'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);  
            }
        }
        getheaders($objPHPExcel, $fileName);
    }
?>