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


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

EXCEL REPORT FORMAT

<?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"];

   
	$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
	$main_src=$main_src_obj[1];
	$pdf_writer_class=$aobj_context->main_src."/maya-pdf/fpdf.php";
	$root_pdf_file_download=$aobj_context->main_src."/Report_details/output/report_me_student_list.pdf";
	
	include($pdf_writer_class);	
    $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 = 'Qn_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(fsubcode, 4)AS fsubcode FROM marksint WHERE fdegree='{$degree}' AND fexamno='{$sem}' ORDER BY fsubcode";
            $res_sub = $aobj_context->mobj_db->GetAll($query);

            $merge1=['C','E','G','I','K','M','O','Q','S','U','W','Y'];
            $alpha=['D','F','H','J','L','N','P','R','T','V','X','Z'];

            $objPHPExcel->getActiveSheet()->getStyle('1:6')->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('A5', 'Reg. No');
            $objPHPExcel->getActiveSheet()->setCellValue('B5', 'Student Name');
            $i=0;
            foreach($res_sub as $val){
                $objPHPExcel->getActiveSheet()->setCellValue($merge1[$i].'5', $val['fsubcode']);
                $objPHPExcel->getActiveSheet()->setCellValue($merge1[$i].'6', 'Total Marks');
                $objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].'6', 'Actual Marks');
                $i++;
            }
     
            $objPHPExcel->getActiveSheet()->mergeCells('A5:A6');
            $objPHPExcel->getActiveSheet()->mergeCells('B5:B6');
   
            $objPHPExcel->getActiveSheet()->freezePane('A7');




        
            $query3="SELECT stu.FREGNO, stu.FNAME, sd.fexamno,  
                    group_concat(left(mak.fsubcode, 4), '-', 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) 
                    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";

                    // var_dump($query3);die();
            $result3 = $aobj_context->mobj_db->GetAll($query3);
            // $j=0;

           
            foreach($result3 as $key=> $val){
                foreach ($res_sub as $value) {
                    $slNo = $key + 7;
                    $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
                    $objPHPExcel->getActiveSheet()->setCellValue('A'.$slNo, $val['FREGNO'])->getColumnDimension('A')->setwidth(8);
                    $objPHPExcel->getActiveSheet()->setCellValue('B'.$slNo, $val['FNAME'])->getColumnDimension('B')->setwidth(15);
                    $split = explode("|", $val['marksdet']);
                    $j = 0;
                    foreach ($split as $v) {
                        $splitagain = explode("-", $v);
                        if($value['fsubcode'] == $splitagain[0]){
                        var_dump($value['fsubcode']);
                            $objPHPExcel->getActiveSheet()->setCellValue($merge1[$j].$slNo, $splitagain[1])->getColumnDimension($merge1[$j].$slNo)->setwidth(15);
                            $objPHPExcel->getActiveSheet()->setCellValue($alpha[$j].$slNo, $splitagain[2])->getColumnDimension($alpha[$j].$slNo)->setwidth(15);
                        }
                        $j++;         
                    } ;die();     
                }
            }

            // foreach$res_sub[$j]['fsubcode']()

            
            // foreach($result3 as $key=> $val){
            //     $slNo = $key + 7;
            //     $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
            //     $objPHPExcel->getActiveSheet()->setCellValue('A'.$slNo, $val['FREGNO'])->getColumnDimension('A')->setwidth(8);
            //     $objPHPExcel->getActiveSheet()->setCellValue('B'.$slNo, $val['FNAME'])->getColumnDimension('B')->setwidth(15);
            //     $marksdet=explode('|',$val['marksdet']);

            //     for ($l=0; $l < count($marksdet); $l++) { 
            //         $split = explode('-', $marksdet[$l]);
            //         for ($k=0; $k < count($res_sub); $k++) { 
            //             if($res_sub[$k]['fsubcode'] === $split[0]){
            //                 $objPHPExcel->getActiveSheet()->setCellValue($merge1.$slNo, $split[1])->getColumnDimension($merge1.$slNo)->setwidth(8);
            //             }
            //         }
            //     }
                
               
            //     // for ($k=0; $k <count($marksdet) ; $k++) { 
            //     //     $splitData= explode('-', $marksdet[$k]);
            //     //     if($res_sub[$j]['fsubcode'] == $splitData[0]){
                  
            //     //     $objPHPExcel->getActiveSheet()->setCellValue($merge1[$k].$slNo, $splitData[1])->getColumnDimension($merge1[$k])->setwidth(15);
            //     //     $objPHPExcel->getActiveSheet()->setCellValue($alpha[$k].$slNo, $splitData[2])->getColumnDimension($alpha[$k])->setwidth(15);
            //     //     }
            //     //  }
            //     $j++;
            // }

            $merge=['C5:D5','E5:F5','G5:H5','I5:J5','K5:L5','M5:N5','O5:P5','Q5:R5','S5:T5','U5:V5','W5:X5','Y5:Z5'];
            
            

        //     for($z = 0; $z < count($split); $z++) {
               
        //       foreach ($result3 as $key => $value){
        //           $slNo = $key + 7;
        //           $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
        //           $objPHPExcel->getActiveSheet()->setCellValue('A'.$slNo, $value['FREGNO'])->getColumnDimension('A')->setwidth(8);
        //           $objPHPExcel->getActiveSheet()->setCellValue('B'.$slNo, $value['FNAME'])->getColumnDimension('B')->setwidth(15);
                
        //           $marksdet=explode('|',$value['marksdet']);
        //           $splitData = [];
        //             foreach ($marksdet as $item) {
        //                 $splitData[] = explode('-', $item); 
        //             }


        //             for($i=0;$i<count($res);$i++){
        //                 $objPHPExcel->getActiveSheet()->mergeCells($merge[$i]);
        //                 $objPHPExcel->getActiveSheet()->setCellValue($merge1[$i].'5',$res[$i]['fsubcode'] )->getColumnDimension('C')->setwidth(25);
        //                   $objPHPExcel->getActiveSheet()->setCellValue($merge1[$i].'6','Total Marks')->getColumnDimension('C')->setwidth(25);
        //                     $objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].'6','Actual Marks')->getColumnDimension('C')->setwidth(25);
        //                 if($res[$i]['fsubcode']==$splitData[$i][0]){
        //                     // var_dump($alpha[$i].($slNo-1),$splitData[$i][1]);
                          
        //                     $objPHPExcel->getActiveSheet()->setCellValue($merge1[$i].($slNo),$splitData[$i][1])->getColumnDimension('C')->setwidth(25);
        //                     $objPHPExcel->getActiveSheet()->setCellValue($alpha[$i].($slNo),$splitData[$i][1])->getColumnDimension('C')->setwidth(25);
        //                 }
                    
        //             }
                  
        //       } 
        //   } 
         
            $objPHPExcel->getActiveSheet()->getStyle('A:B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER); 
          
           
  getheaders($objPHPExcel, $fileName);
  
}
?>