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


Current Path : /var/www/oasis/Report_details/
Upload File :
Current File : /var/www/oasis/Report_details/iaDegwiseIAReport.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');

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

function getheaders($objPHPExcel, $fileName)
{
    // To Fit To Page while printing
    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);

    // Redirect output to a client’s web browser (Excel5)
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename=' . $fileName);
    header('Cache-Control: max-age=0');
    // If you're serving to IE 9, then the following may be needed
    header('Cache-Control: max-age=1');

    // If you're serving to IE over SSL, then the following may be needed
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
    header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
    header('Pragma: public'); // HTTP/1.0
    ob_clean();
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    $objWriter->save('php://output');
}

function iaMarksDegwiseReport($aobj_context)
{
    session_start();
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
   
    $collcode=$_SESSION['collcode'];
    $funivcode = $_SESSION['FUNIVCODE'];
    $degree = $aobj_context->mobj_data["degree"]; 
    $sem = $aobj_context->mobj_data["sem"];
    $sub = $aobj_context->mobj_data["sub"];
    $subelement=$aobj_context->mobj_data["subelement"];
    $test = $aobj_context->mobj_data["test"];

    
    $collname="SELECT fcollname FROM college WHERE fcollcode='{$collcode}'";
    $res1 = $aobj_context->mobj_db->GetRow($collname);

    $degree1="  SELECT fdescpn,fadyear FROM degree WHERE fdegree='{$degree}'";
   

     $querysub = "SELECT DISTINCT sub.fsubname FROM subject sub 
               INNER JOIN subdet sd ON sd.fdegree=sub.fdegree AND 
               LEFT(sd.fcsubcode,5)=CONCAT(sub.fsubcode,sub.fssubcode) 
               WHERE sub.fsubcode='{$sub}' AND sub.fdegree='{$degree}' AND sd.fsubname='{$subelement}'";
     $subjectName = $aobj_context->mobj_db->GetRow($querysub);

  
  $query = "select sub.fsubshort, left(s.fcsubcode, 4)as fsubcode, m.ftest,
            sub.fsubname from subdet s inner join subject sub on 
            s.fdegree = sub.fdegree and s.fexamno = sub.fexamno 
            and left(s.fcsubcode, 4) = sub.fsubcode
            INNER JOIN marksint m ON sub.fdegree=m.fdegree AND sub.fexamno=m.fexamno   AND  LEFT(s.fcsubcode, 4)=LEFT( m.`FSUBCODE`,4)
              INNER JOIN subdet sd ON sd.fdegree=sub.fdegree AND LEFT(sd.fcsubcode,4)=sub.fsubcode AND m.fdegree=sd.fdegree AND 
              LEFT(m.fsubcode,5)=sd.fcsubcode
             where 
            s.fdegree='{$degree}' and s.fexamno='{$sem}'  AND LEFT(sub.fsubcode, 4)='{$sub}' AND sd.fsubname='{$subelement}' group by left(s.fcsubcode, 4) 
            order by s.fcsubcode";
         
            // var_dump($query);die();  
  $res = $aobj_context->mobj_db->GetAll($query);


$query=" SELECT  m.fregno, fname, GROUP_CONCAT(DISTINCT left(m.fsubcode, 4), '->', 
         sub.fsubshort, '->', facttotal  ORDER BY m.fsubcode SEPARATOR '|')AS fmarks 
         FROM marksint m 	  INNER JOIN student s ON s.fregno = m.fregno
         INNER JOIN subject sub ON sub.fsubcode = LEFT(m.fsubcode, 4) 
         AND sub.fdegree = m.fdegree
         AND sub.fexamno = m.fexamno
         INNER JOIN subdet sd ON sd.fdegree=sub.fdegree AND LEFT(sd.fcsubcode,4)=sub.fsubcode AND m.fdegree=sd.fdegree AND 
         LEFT(m.fsubcode,5)=sd.fcsubcode
         WHERE m.fdegree='{$degree}' AND m.fexamno='{$sem}' AND m.ftest='{$test}' 
         AND LEFT(sub.fsubcode, 4)='{$sub}' AND sd.fsubname='{$subelement}'   
         GROUP BY s.fregno";

        
     
$result = $aobj_context->mobj_db->GetAll($query);



// $query="SELECT DISTINCT sub.fsubshort,  m.fregno, fname,  facttotal AS fmarks FROM marksint m INNER JOIN student s ON s.fregno = m.fregno
//       INNER JOIN subject sub ON sub.fsubcode = LEFT(m.fsubcode, 4) AND sub.fdegree = m.fdegree
//       AND sub.fexamno = m.fexamno
//       WHERE m.fdegree='BCS22' AND m.fexamno='B' AND m.ftest='test 1' # and sub.fsubcode='B002' 
//       GROUP BY s.fregno         ";
        
             
    $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);		

    $objPHPExcel = new PHPExcel();
    
    $fileName = 'Att_Report_Degree_Wise.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'),
            ),
        ),
    );

    $count = "";

  $alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
           'AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ',
           'BA','BB','BC','BD','BE','BF','BG','BH','BI','BJ','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW','BX','BY','BZ',
           'CA','CB','CC','CD','CE','CF','CG','CH','CI','CJ','CK','CL','CM','CN','CO','CP','CQ','CR','CS','CT','CU','CV','CW','CX','CY','CZ'];
  $j=4;
  $objPHPExcel->getActiveSheet()->getStyle('1:5')->getFont()->setBold(true);
  $objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(18);
  $objPHPExcel->getActiveSheet()->getStyle('2:2')->getFont()->setSize(15);
  $objPHPExcel->getActiveSheet()->getStyle('3:3')->getFont()->setBold(false);
  $objPHPExcel->getActiveSheet()->getStyle('3:3')->getFont()->setSize(16);

  $objPHPExcel->getActiveSheet()->getStyle('4:4')->getFont()->setSize(12);

  $objPHPExcel->getActiveSheet()->freezePane('A6');
  $objPHPExcel->getActiveSheet()->setCellValue('A1', $res1['fcollname']);
  $objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->setCellValue('A2',  $res2['fdescpn'].'  Sem:'.$sem.' - Academic Year '.$res2['fadyear']);
  $objPHPExcel->getActiveSheet()->setCellValue('A3', 'Subject - '.$subjectName['fsubname']. '    IA Report (Degree Wise)');
  $objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

  $objPHPExcel->getActiveSheet()->setCellValue('A4', 'Sl No.');
  $objPHPExcel->getActiveSheet()->setCellValue('B4', 'USN');
  $objPHPExcel->getActiveSheet()->setCellValue('C4', 'Student Name');
  $objPHPExcel->getActiveSheet()->mergeCells('A4:A5');
  $objPHPExcel->getActiveSheet()->mergeCells('B4:B5');
  $objPHPExcel->getActiveSheet()->mergeCells('C4:C5');
  $objPHPExcel->getActiveSheet()->getStyle('A4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('B4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('C4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

  $merge=count($res);
  $space=($merge+3);
 
  $objPHPExcel->getActiveSheet()->mergeCells('A1:'.$alpha[$space-1].'1');
  $objPHPExcel->getActiveSheet()->mergeCells('A2:'.$alpha[$space-1].'2');
  $objPHPExcel->getActiveSheet()->mergeCells('A3:'.$alpha[$space-1].'3');


  $a =3;
  foreach($res as $value){
    $objPHPExcel->getActiveSheet()->setCellValue($alpha[$a]."4",$value['fsubshort'])->getColumnDimension($alpha[$a])->setwidth(15);
    $objPHPExcel->getActiveSheet()->setCellValue($alpha[$a]."5",$test)->getColumnDimension($alpha[$a])->setwidth(15);
    $objPHPExcel->getActiveSheet()->getStyle($alpha[$a]."4")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle($alpha[$a]."5")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $a++;
  }
    foreach ($result as $key => $val) {
      $slNo = $key + 6;
      $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
      $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 5)->getColumnDimension('A')->setwidth(8);
      $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $val['fregno'])->getColumnDimension('B')->setwidth(15);
      $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $val['fname'])->getColumnDimension('C')->setwidth(40);
      $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      $objPHPExcel->getActiveSheet()->getStyle('B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
      
      $subjects = explode("|", $val['fmarks']);
      $z=3;
      
      foreach ($res as $v){
        foreach ($subjects as  $value) {
          $sub = explode("->", $value);
            if($sub[0] == $v['fsubcode']){
              if($sub[2] == -2){
                            $conn="Ab";
                           } else if($sub[2] == " "){
                            $conn="-";
                           }
                           else{
                            $conn=$sub[2];
                           }
              $objPHPExcel->getActiveSheet()->setCellValue($alpha[$z]. $slNo, $conn)->getColumnDimension($alpha[$z])->setwidth(15);
              $objPHPExcel->getActiveSheet()->getStyle($alpha[$z]. $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
            }
        }
        $z++;
    }
    $slNo++;
  }
// die();
//  var_dump($value['fsubshort']);
  // foreach($result as $key =>$val){
  //   foreach($res as $value){
  //     var_dump($value['fsubcode']);
  //     $slNo = $key + 6;
  //     $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
  //     $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 6)->getColumnDimension('A')->setwidth(8);
  //     $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $val['fregno'])->getColumnDimension('B')->setwidth(15);
  //     $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $val['fname'])->getColumnDimension('C')->setwidth(40);
  //     $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  //     $objPHPExcel->getActiveSheet()->getStyle('B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
     
  //       $marks=explode("|",$val['fmarks']);
  //       $z=3;
  //       foreach($marks as $sub){
  //         $subshort=explode("->",$sub);
         
  //           if($subshort[1] == $value['fsubcode']){
  //            if($subshort[2] == -2){
  //             $conn="Ab";
  //            } else if($subshort[2] == " "){
  //             $conn="-";
  //            }
  //            else{
  //             $conn=$subshort[2];
  //            }
  //             $objPHPExcel->getActiveSheet()->setCellValue($alpha[$z]. $slNo,$conn)->getColumnDimension($alpha[$z])->setwidth(15);
  //             $objPHPExcel->getActiveSheet()->getStyle($alpha[$z]. $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  //           }
          
          
  //       }  
  //       $z++; 
  //   } 
  //   die();
  //   $slNo++;
  // } 

   $objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  getheaders($objPHPExcel, $fileName);

}

?>