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


Current Path : /var/www/oasis/Report_details/
Upload File :
Current File : /var/www/oasis/Report_details/attDegwiseReport.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 attDegwiseReport($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"];
		$degexam = $aobj_context->mobj_data["degexam"];
    $fromdate = $aobj_context->mobj_data["fromdate"];
    $todate = $aobj_context->mobj_data["todate"];
    $section = $aobj_context->mobj_data["section"];
    
    $date = new DateTime($fromdate);
    $datefrom=$date->format('d-m-Y');
    $date1=new DateTime($todate);
    $dateto=$date1->format('d-m-Y');


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

    $degree1="  SELECT fdescpn,fadyear FROM degree WHERE fdegree='{$degree}'";
    $res2 = $aobj_context->mobj_db->GetRow($degree1);
 
    $query =" SELECT DISTINCT su.fsubshort,a.fsubcode FROM attend_det a INNER JOIN subject su ON su.fdegree = a.fdegree AND su.fexamno = a.fexamno 
              AND su.fcsubcode = a.fsubcode 
              INNER JOIN student s ON s.fregno=a.fregno AND s.fdegree=a.fdegree
              WHERE a.fdegree = '$degree' AND a.fexamno = '$sem' AND DATE_FORMAT(a.fdate,'%Y-%m-%d')
              BETWEEN ' $fromdate' AND '$todate' AND s.fsection='$section'
              GROUP BY su.fsubshort ORDER BY su.fsubshort";

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

    $string = "";
    foreach($result9 as $val)
    {
      $fsubshort = $val['fsubshort'];
      $string .= "`F$fsubshort` varchar(50) DEFAULT NULL,";
    }

    $query = "drop table IF EXISTS attenddetsum_18042024";
    $updateresult = $aobj_context->mobj_db->Execute($query);
   
    $query = "create table `attenddetsum_18042024` (
            `FREGNO` varchar(20) NOT NULL,
            `FDEGREE` varchar(5) DEFAULT NULL,
            `FCOLLCODE` varchar(5) DEFAULT NULL,
            `FNAME` varchar(200) DEFAULT NULL,
            $string
            PRIMARY KEY (`FREGNO`)
          ) ENGINE=InnoDB DEFAULT CHARSET=latin1";
 
    $updateresult = $aobj_context->mobj_db->Execute($query);
 

    $query = "insert into attenddetsum_18042024(FREGNO,FNAME,FDEGREE,FCOLLCODE)
            select distinct a.fregno,st.fname,st.fdegree,st.fcollcode
            from attend_det a inner join student st on a.fregno = st.fregno
            where a.fdegree = '$degree'
            and date_format(a.fdate,'%Y-%m-%d') between '$fromdate' and '$todate'
            group by a.fregno
            order by a.fregno";
    $updateresult = $aobj_context->mobj_db->Execute($query);
   

    if($section !=="All"){
     $connn="AND st.FSECTION='$section'";
    }else{
      $connn="";
    }

    if($sem !=="All"){
      $con1="and a.fexamno = '$sem'";
     }else{
       $con1="";
     }

    $query = "SELECT a.fregno, a.fname, 
            GROUP_CONCAT(a.fsubshort,'*',a.cond,'*',a.fpresent ORDER BY a.fsubshort SEPARATOR '|') AS subdet 
            FROM (SELECT DISTINCT a.fregno,st.fname,su.fsubshort,a.fsubcode,SUM(a.fnoclass) AS cond, 
            SUM(IF(a.fpresent = 'P',a.fnoclass,0)) AS fpresent 
            FROM attend_det a INNER JOIN student st ON a.fregno = st.fregno 
            INNER JOIN degree d ON d.fdegree=st.fdegree AND d.fexamno=st.FEXAMNO
            INNER JOIN subject su ON su.fdegree = a.fdegree AND su.fexamno = a.fexamno AND su.fcsubcode = a.fsubcode 
            WHERE a.fdegree = '$degree' AND DATE_FORMAT(a.fdate,'%Y-%m-%d') BETWEEN '$fromdate' AND '$todate'  $connn  $con1
            GROUP BY a.fregno,a.fsubcode ORDER BY a.fregno) a GROUP BY a.fregno";
          
    $result = $aobj_context->mobj_db->GetAll($query);

$subarry = [];
foreach($result as $val)
{
 
  $subdet = $val['subdet'];
  $fregno = $val['fregno'];

  $subdetarry = explode("|",$subdet);

  foreach($subdetarry as $val1)
  {
    $subdetatt = explode("*",$val1);
  
    $subshort = $subdetatt[0];
    $subatt = "$subdetatt[1]*$subdetatt[2]";
    
    $upd = "update attenddetsum_18042024 set F$subshort = '{$subatt}'
         where fregno = '{$fregno}'";
    $res = $aobj_context->mobj_db->Execute($upd);
   
  }
}
$query = "select * from attenddetsum_18042024 where fdegree = '$degree' and fcollcode = '$collcode'";
$result1 = $aobj_context->mobj_db->GetAll($query);


    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	
    $yearmode = explode("*",$yearmode);
		$year = $yearmode[0];
		$examtye = $yearmode[1];
    $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:6')->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()->getStyle('5:5')->getFont()->setSize(12);
  $objPHPExcel->getActiveSheet()->freezePane('A7');
  $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', 'ATTENDANCE  from '.$datefrom. ' to '.$dateto);
  $objPHPExcel->getActiveSheet()->setCellValue('A4', 'SECTION: '.$section);
  $objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('A4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
  $objPHPExcel->getActiveSheet()->setCellValue('A5', 'Sl No.');
  $objPHPExcel->getActiveSheet()->setCellValue('B5', 'USN');
  $objPHPExcel->getActiveSheet()->setCellValue('C5', 'Student Name');
  $objPHPExcel->getActiveSheet()->mergeCells('A5:A6');
  $objPHPExcel->getActiveSheet()->mergeCells('B5:B6');
  $objPHPExcel->getActiveSheet()->mergeCells('C5:C6');
  $objPHPExcel->getActiveSheet()->getStyle('A5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  $objPHPExcel->getActiveSheet()->getStyle('C5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

  $first=['D5','G5','J5','M5','P5','S5','V5','Y5','AB5','AE5','AH5','AK5','AN5','AQ5','AT5'];
  $second=['F5','I5','L5','O5','R5','U5','X5','AA5','AD5','AG5','AJ5','AM5','AP5','AS5','AV5'];
  $start=['D6','G6','J6','M6','P6','S6','V6','Y6','AB6','AE6','AH6','AK6','AN6','AQ6','AT6'];
  $first1=['D','G','J','M','P','S','V','Y','AB','AE','AH','AK','AN','AQ','AT'];
  $mid=['E6','H6','K6','N6','Q6','T6','W6','Z6','AC6','AF6','AI6','AL6','AO6','AR6','AU6'];
  $mid1=['E','H','K','N','Q','T','W','Z','AC','AF','AI','AL','AO','AR','AU'];
  $end=['F6','I6','L6','O6','R6','U6','X6','AA6','AD6','AG6','AJ6','AM6','AP6','AS6','AV6'];
  $end1=['F','I','L','O','R','U','X','AA','AD','AG','AJ','AM','AP','AS','AV'];
  $a =3;
  $b =6;
  $j=3;
  $x=0;
  $merge=count($result9);
  $space=($merge+1)*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');
  $objPHPExcel->getActiveSheet()->mergeCells('A4:'.$alpha[$space-1].'4');
  foreach($result9 as $val)
  { 
    $objPHPExcel->getActiveSheet()->mergeCells($first[$x].':'.$second[$x]);
    $objPHPExcel->getActiveSheet()->setCellValue($start[$x], 'CH=');
    $objPHPExcel->getActiveSheet()->setCellValue($mid[$x], 'CA');
    $objPHPExcel->getActiveSheet()->setCellValue($end[$x], '%');
    $objPHPExcel->getActiveSheet()->setCellValue($alpha[$a]."5", $val['fsubshort'])->getColumnDimension($alpha[$a])->setwidth(5);
    $objPHPExcel->getActiveSheet()->getStyle($alpha[$a]."5")->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle($start[$x])->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle($mid[$x])->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle($end[$x])->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
   
    $a = $a+3;
    $j++;
    $x++;
  }

  foreach($result as $key =>$val){
    $z=0;
    foreach($result9 as $v){
      $slNo = $key + 7;
      $objPHPExcel->getActiveSheet()->mergeCells($first[$x].':'.$second[$x]);
      $subdetcount = count($submarks);
      $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);

      $submarks=explode("|",$val['subdet']);
      foreach($submarks as $value){
        $explode = explode("*",  $value);

        if($v['fsubshort'] == $explode[0]){

          $cond = isset($explode[1]) ? $explode[1] : "-"; 
          $fpresent = isset($explode[2]) ? $explode[2] : "-"; 
          $cal = ($fpresent != "-" && $cond != "-") ? number_format(($fpresent / $cond) * 100, 2) : "-";

          $objPHPExcel->getActiveSheet()->setCellValue($first1[$z]. $slNo, $cond)->getColumnDimension($first1[$z])->setwidth(8);
          $objPHPExcel->getActiveSheet()->setCellValue($mid1[$z]. $slNo, $fpresent)->getColumnDimension($mid1[$z])->setwidth(8);
          $objPHPExcel->getActiveSheet()->setCellValue($end1[$z]. $slNo, $cal)->getColumnDimension($end1[$z])->setwidth(8);
          
           $objPHPExcel->getActiveSheet()->getStyle($first1[$z].$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
            $objPHPExcel->getActiveSheet()->getStyle($mid1[$z].$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
            $objPHPExcel->getActiveSheet()->getStyle($end1[$z].$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
            $objPHPExcel->getActiveSheet()->getStyle('A'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
            $objPHPExcel->getActiveSheet()->getStyle('B'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
           
        }
      }
      $z++;
      $slNo++;
    }
  }
   $objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  getheaders($objPHPExcel, $fileName);

}

?>