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


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

<?php
function roomallotmantsummarysubjwise($aobj_context)
{	
	session_start();
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);  
    $college_code = $_SESSION['collcode']; 
	$FUNIVCODE = $_SESSION['FUNIVCODE'];
	$deggrp = $aobj_context->mobj_data["deggrp"]; 
	$frm_date = $aobj_context->mobj_data["frm_date"]; 
	$session = $aobj_context->mobj_data["session"];
    // var_dump($deggrp);
    // die(); 
    // if($session=="n%"){
    //     $time="Afternoon";
    // }elseif($session=="m%"){
    //     $time="Morning";
    // }else{
    //     $time="Both";
    // }

	$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
   
	$main_src=$main_src_obj[1];
	$pdf_writer_class=$aobj_context->main_src."/maya-pdf/fpdf.php";
	$tarkaheader=$aobj_context->main_src."/Report_details/tarkaheader.php";
	$root_pdf_file_download=$aobj_context->main_src."/Report_details/output/report_admission_list.pdf";
// global varibales
	$p_count =1;
// end global varibales	
	include($pdf_writer_class);		
	$pdf= new FPDF();
	//$pdf->$title='20000 Leagues Under the Seas';
	$pdf->SetFont('Times','',9);
	$pdf->SetMargins(12,10);		
	$pdf->AliasNbPages();	
	$sub_degree_cond="";

	$page_header_university = "select c.FUNIVNAME,c.FTOWN,concat(d.fcollname,', ',d.ftown) as fcollname, date_format(now(),'%d/%m/%Y') as date from control c,college d where d.fcollcode='{$college_code}'";
	$lobj_page_header_university = $aobj_context->mobj_db->GetRow($page_header_university);
	
	
	$pdf->aobj_context =$aobj_context ;
	$pdf->WhichReport = 'roomallotmentsummarysubjectwise';
	$pdf->FUNIVNAME = $lobj_page_header_university['FUNIVNAME'];
	$pdf->FTOWN = $lobj_page_header_university['FTOWN'];
	$pdf->college_name = $lobj_page_header_university['fcollname'];
	$pdf->frm_date = $frm_date;
	$pdf->session = $session;
	$pdf->deggrp = $deggrp;


	$pdf->date_1 = $lobj_page_header_university['date'];

	if($session== 'both')
	{
		$sectionvalue = "";
	}
	else 
	{
		$sectionvalue = "and s.fsession like '{$session}'";
	}
	if($deggrp== 'All'){
		$deggrpcond = "dg.fdeggrp between '0' and 'Z'";
	}
	else {
		$deggrpcond = "dg.fdeggrp='{$deggrp}'";
	}


	// if($_SESSION['fexamseparate'] == 'T')
	// {
	// 	$candsum = "examcandsum"; 
	// 	$canddet = "examcanddet"; 

	// }else
	// {
	// 	$candsum = "candsum"; 
	// 	$canddet = "canddet"; 
	// }	

    $get_subject_data="SELECT s.FQPCODE AS qpcode,s.fsubname,
                        mr.froomno,mr.froomname AS roomname,
                        COUNT(cd.fhallno) AS fcount,s.fsession
                        FROM canddet cd, masroom mr, subject s ,candsum cs ,degree dg
                        WHERE cs.fcntrcode=mr.fcollcode AND mr.fcollcode='{$college_code}' 
                        AND
                        mr.froomno = cd.fhallno AND cd.fdegree = s.fdegree AND cd.fexamno = s.fexamno 
                        AND mr.fcollcode=cs.fcntrcode AND cd.fdegree=cs.fdegree AND 
                        cd.fcollcode=cs.fcollcode AND cd.fregno=cs.fregno
                        AND s.FSUBCODE = cd.FSUBCODE AND IFNULL(s.fqpcode,'') <> '' AND 
                        IFNULL(cd.fpresent,'') = 'P' AND IFNULL(s.fparentsub,'') <> 'T' and
						dg.fexamno=cd.fexamno and dg.fdegree=cd.fdegree AND {$deggrpcond}
                        AND s.fdoe = DATE_FORMAT(STR_TO_DATE('{$frm_date}', '%d/%m/%Y'),'%Y-%m-%d')
                        {$sectionvalue}
                        GROUP BY mr.fcollcode,s.fsubshort,cd.fhallno ORDER BY s.fsession,s.fsubshort,cd.fhallno;";
	
	$aobj_context->mobj_db->execute("SET @@session.group_concat_max_len=1000000");
	$lobj_subject_data = $aobj_context->mobj_db->GetAll($get_subject_data);	
 	// var_dump($aobj_context);
	// print_r($lobj_subject_data); 
    // die();
	$pdf->fddate=$lobj_subject_data[0]['fddate'];
	$pdf->AddPage("P");	
	//$pdf->Ln();
	$pdf->SetFont('Times','B',9);
    $roomCountLimit = 10; // Adjust this value based on your requirements
    $maxSubjectWidth = 80; // Maximum width for the subject name
	$i = 1;
	$oldqp = "";
	$newqp = "";
			$pdf->Cell(10,5,'Sl. No.','1',0,'C');
			$pdf->Cell(25,5,'QP Code','1',0,'C');
			$pdf->Cell(80,5,'Subject Name','1',0,'C');
			$pdf->Cell(15,5,'Room No','1',0,'C');
			$pdf->Cell(35,5,'Room Name','1',0,'C');
			$pdf->Cell(20,5,'Alloted Count','1',1,'C');
			$pdf->SetFont('Times','',9);
			$totcount = 0;
			$roomcnt = 0;
            
	foreach($lobj_subject_data as $key => $value)
	{
        $border='LR';
        $yAxisPosition = 270;
        if($pdf->GetY() > $yAxisPosition)
        {
            $border='LRB';
            $pdf->AddPage("P");
            $pdf->SetFont('Times','B',9);
            $pdf->Cell(10,5,'Sl. No.','1',0,'C');
            $pdf->Cell(25,5,'QP Code','1',0,'C');
            $pdf->Cell(80,5,'Subject Name','1',0,'C');
            $pdf->Cell(15,5,'Room No','1',0,'C');
            $pdf->Cell(35,5,'Room Name','1',0,'C');
            $pdf->Cell(20,5,'Alloted Count','1',1,'C');
            $pdf->SetFont('Times','',9);
        }
            
        
		$newqp = $value['fsubname'];

		if($oldqp != $newqp)
		{
			$oldqp = $value['fsubname'];
			if($i > 1)
			{
			
				$pdf->SetFont('Times','B',9);
				$pdf->Cell(165,5,'Allotted Count','1',0,'R');
				$pdf->Cell(20,5,$roomcnt,'1',1,'C');

				$roomcnt = 0;
				$pdf->SetFont('Times','',9);
			}

			$pdf->Cell(10,5,$i,'LRT',0,'C');
        
			$pdf->Cell(25,5,$value['qpcode'],'LRT',0,'C');
            $maxWidth = 80;
            $content = $value['fsubname'];
            

            if ($pdf->GetStringWidth($content) > $maxWidth) {
                $splitContent = str_split($content, 30); 
                $secondPart = false; 
                $subjects=$splitContent[1];
                $pdf->Cell(80, 5, $splitContent[0], 'LRT', 0, 'L');    
            } else {
                $pdf->Cell($maxWidth, 5, $content, 'LRT', 0, 'L');
            }


			$pdf->Cell(15,5,$value['froomno'],'LRBT',0,'C');
			$pdf->Cell(35,5,$value['roomname'],'LRBT',0,'C');
            $pdf->SetFont('Times','B',9);
			$pdf->Cell(20,5,$value['fcount'],'LRTB',1,'C');
            

            $pdf->SetFont('Times','',9);
			$totcount = $totcount + $value['fcount'];
			$roomcnt = $roomcnt + $value['fcount'];
			$i++;
            
		}
		else
		{
			$pdf->Cell(10,5,'','LR',0,'C');
			$pdf->Cell(25,5,'','LR',0,'C');
            $y=$pdf->GetY();
            if (isset($splitContent[1]) && !$secondPart) {
                $pdf->Cell(80, 5, $splitContent[1], 'LR', 0, 'L');
                $secondPart = true; 
            } else {
                $pdf->Cell(80, 5, '', 'LR', 0, 'C'); 
            }
			$pdf->Cell(15,5,$value['froomno'],'LRB',0,'C');
			$pdf->Cell(35,5,$value['roomname'],'LRB',0,'C');
            $pdf->SetFont('Times','B',9);
			$pdf->Cell(20,5,$value['fcount'],'LRB',1,'C');
            $pdf->SetFont('Times','',9);
            // $pdf->SetY(-5); // Set Y position to 15 mm from the bottom
            // $pdf->Cell(185,10,'',0,0,'C');
			$totcount = $totcount + $value['fcount'];
			$roomcnt = $roomcnt + $value['fcount'];
		}
		
	}
			$pdf->SetFont('Times','B',9);
			$pdf->Cell(165,5,'Allotted Count','1',0,'R');
			$pdf->Cell(20,5,$roomcnt,'1',1,'C');
			$pdf->Cell(165,5,'Overall Total','1',0,'R');
			$pdf->Cell(20,5,$totcount,'1',1,'C');
	
	$pdf->Output("Roomsubjectwisesummary.pdf","I");
} 
// if ($pdf->GetStringWidth($content) > $maxWidth) {
            //     $numLines = ceil($pdf->GetStringWidth($content) / $maxWidth);

            //     $fontSize = 8; 
            //     $pdf->SetFont('Times', '', $fontSize);
            
            //     $pdf->Cell($maxWidth, 5, $content, 'LRT', 0, 'L');
            // } else {
            // }

            // if ($pdf->GetStringWidth($content) > $maxSubjectWidth) {
            //     $subjectLines = $pdf->MultiCell($maxSubjectWidth, 5, $content, 'LRT', 'L', false);

            //     // Determine the number of lines for subject and adjust other columns accordingly
            //     $linesCount = count($subjectLines);
                
            //     foreach ($subjectLines as $index => $line) {
            //         $pdf->Cell($maxSubjectWidth, 5, $line, 'LRT', 0, 'L');
            
            //         if ($index === 0) {
            //             // For the first line of subject, also adjust other columns
            //             $pdf->Cell(15, 5, $value['froomno'], 'LRBT', 0, 'C');
            //             $pdf->Cell(25, 5, $value['roomname'], 'LRBT', 0, 'C');
            //             $pdf->SetFont('Times', 'B', 9);
            //             $pdf->Cell(20, 5, $value['fcount'], 'LRTB', 1, 'C');
            //             $pdf->SetFont('Times', '', 9);
            //         } else {
            //             // For subsequent lines of subject, adjust other columns without repeating values
            //             $pdf->Cell(15 + 25 + 20, 5, '', 'LRBT', 0); // Empty space for froomno, roomname, and fcount
            //             $pdf->Cell(20, 5, '', 'LRTB', 1); // Empty space for fcount
            //         }
            //     }
            // } else {
            //     // Subject name fits within the maximum width
            //     $pdf->Cell($maxSubjectWidth, 5, $content, 'LRT', 0, 'L');
            //     $pdf->Cell(15, 5, $value['froomno'], 'LRBT', 0, 'C');
            //     $pdf->Cell(25, 5, $value['roomname'], 'LRBT', 0, 'C');
            //     $pdf->SetFont('Times', 'B', 9);
            //     $pdf->Cell(20, 5, $value['fcount'], 'LRTB', 1, 'C');
            //     $pdf->SetFont('Times', '', 9);
            // }
?>