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


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

<?php

require_once("/var/www/html/aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;

ini_set("xdebug.var_display_max_children", '-1');
ini_set("xdebug.var_display_max_data", '-1');
ini_set("xdebug.var_display_max_depth", '-1');

class AdmissionTicket
{
	public $aobj_context;
	public $degree_code;
	public $registor_no_starts;
	public $registor_no_ends;
	public $print_per_page;
	public $sub_appearing_count;
	public $std_adm_count;
	public $sub_arr;
	public $std_arr;
// university
	public $std_FUNIVNAME ;
	public $std_FUNIVCODE ;
	public $std_FTOWN;	
// college info	
	public $college_code;
	public $college_name;
	public $college_address;
// student info
	public $STD_RegNo;
	public $STD_CollCode;
	public $STD_Course;
	public $STD_Name;
	public $STD_FAT;
	public $STD_MAT;
	public $STD_DOB;	
	public $CollDetails;	
	public $ADMNUM;	
	public $bth_flag;
	public $FUNIVCODE;	
	
	
	function __construct($aobj_context)
    {
		$this->aobj_context=$aobj_context;
		$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
		session_start();
		$this->college_code = $_SESSION['collcode']; 
		$bth_flag=0;
		$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
		$this->main_src=$main_src_obj[1];
	}
	
	function getUniversityDetails()
	{
		$page_header_university = "select FUNIVNAME,FTOWN,FHTTEXT,FUNIVADD1,FUNIVCODE from control";		
		$lobj_page_header_university = $this->aobj_context->mobj_db->GetRow($page_header_university);	
		
		// var_dump($lobj_page_header_university);
		$this->std_FUNIVNAME = $lobj_page_header_university['FUNIVNAME'];
		$this->std_FTOWN = $lobj_page_header_university['FTOWN'];
		$this->std_FHTTEXT = $lobj_page_header_university['FHTTEXT'];
		$this->std_FUNIVADD1 = $lobj_page_header_university['FUNIVADD1'];
		$this->FUNIVCODE = $lobj_page_header_university['FUNIVCODE'];
		
	}	
	
	function getCollegeDetails()
	{
		$page_header_college = "select c.FCOLLCODE, c.FCOLLNAME, c.FEXAMCNTR,
		ec.FCOLLNAME AS exam_center_name,
		CONCAT(c.FCOLLADD1,SPACE(2), c.FTOWN,'\n',c.FEXAMCNTR) AS COLLEGE_ADRS 
		FROM college c LEFT JOIN college ec ON ec.FCOLLCODE=c.FEXAMCNTR
		WHERE c.FCOLLCODE='{$this->college_code}'";
		
		$lobj_page_header_college = $this->aobj_context->mobj_db->GetRow($page_header_college);
		$this->college_code = $lobj_page_header_college['FCOLLCODE'];
		$this->FEXAMCNTR = $lobj_page_header_college['FEXAMCNTR'];
		$this->exam_center_name = $lobj_page_header_college['exam_center_name'];
		$this->college_name = $lobj_page_header_college['FCOLLNAME'];
		$this->college_address = $lobj_page_header_college['COLLEGE_ADRS'];

	}
	
	function getStudentDetails()
	{
		session_start();
		$FUNIVCODE = $_SESSION['FUNIVCODE'];

		$canddettmp = "canddet";
		$candsumttmp = "candsum";
		
			

		$degreetmp = "degree";
		$subjecttmp = "subject";

		if($FUNIVCODE == '008')
		{
			$fyear = "1=1";
		}
		else
		{
			$fyear = "D.fmeyear = cs.fyear";
		}
		

		if($FUNIVCODE == '008x')
		{
			$candsum = "examcandsum"; 
			$canddet = "examcanddet"; 
			$cnd1 = "and D.fexyear = cs.fyear and left(D.fexexamtype,1) = left(cs.fexamtype,1)";

		}else if($FUNIVCODE == '001')
		{
			$candsum = "candsum_re_bed"; 
			$canddet = "canddet_re_bed"; 
			$cnd1 = "and {$fyear} and left(D.fmeexamtyp,1) = left(cs.fexamtype,1)";
		}else
		{
			$candsum = "candsum"; 
			$canddet = "canddet"; 
			$cnd1 = "and {$fyear} and left(D.fmeexamtyp,1) = left(cs.fexamtype,1)";
		}

		if( strtolower($this->exam) != 'all')
			$examstr = "and D.fexamno = '{$this->exam}'";
		else
			$examstr = "";

		
		$query = "update {$candsum} set FHTSTATUS = 'C', fhttime = now()
				where fcollcode = '{$this->college_code}' 
				and fregno between '{$this->registor_no_starts}'  and '{$this->registor_no_ends}'
				and fdegree = '{$this->degree_code}' and ifnull(FHTSTATUS,'') = '' 
				and ifnull(frecptdate,'') <> ''";
		$result = $this->aobj_context->mobj_db->execute($query);
				

		$get_student_data = "SELECT distinct S.FDEGREE,S.FREGNO,S.FCOLLCODE,ifnull(S.FPHOTOPATH,'') as photo_path,
		concat(left(col.FCOLLNAME,100),',',space(1), left(col.FTOWN,100)) as CollDetails  ,
		concat(ec.FCOLLNAME,', ',ec.ftown) AS exam_center_name,col.FCOLLNAME as FCOLLNAME,
		cs.FCNTRCODE AS FEXAMCNTR,col.FCOLLCODE,CONCAT(D.fdegree, ' - ',D.FDESCPN) AS COURSE, D.FEXAMDATE,
		D.FDESCPN as degname,ifnull(S.fenroll,'') as fenroll,
		ifnull(D.fsignpath,'controler_sign.jpg') as fsignpath, S.fabcid,
		ifnull(col.fprinsign,'signature_principal.jpeg') as fprinsignpath,
		S.FNAME,S.FFATNAME,S.FMOTNAME,S.fstudid,DATE_FORMAT(S.FDOB,'%d/%m/%Y') AS FDOB
		FROM student S INNER JOIN {$degreetmp} D ON S.FDEGREE=D.FDEGREE
		INNER JOIN college col ON S.FCOLLCODE=col.FCOLLCODE
		INNER join {$candsum} cs on S.fdegree = cs.fdegree and S.fregno = cs.fregno
		inner join {$canddet} cd on cs.fdegree = cd.fdegree and cs.fcollcode = cd.fcollcode 
		and cs.fregno = cd.fregno and cs.fyear = cd.fyear
		and cs.fexamtype = cd.fexamtype
		LEFT JOIN college ec ON ec.FCOLLCODE=cs.FCNTRCODE
		INNER join colldeg on colldeg.fdegree = cs.fdegree and colldeg.fcollcode = cs.fcollcode
		WHERE S.FREGNO>='{$this->registor_no_starts}' AND S.FREGNO<='{$this->registor_no_ends}' 
		AND S.FDEGREE='{$this->degree_code}' and cs.FCOLLCODE='{$this->college_code}'
		and cs.frecptdate is not null and cd.fexamno = D.fexamno
		and ifnull(S.fexamappblk,'') <> 'T' and ifnull(S.fmp,'') <> 'T' 
		and cs.fyear = '{$this->fyear}'
		and cs.fexamtype = '{$this->fexamtype}'
		and INSTR(cs.fhtenable,cd.fexamno) >0
	
		{$examstr}
		order by S.FREGNO";	
		$lobj_get_student_data = $this->aobj_context->mobj_db->GetAll($get_student_data);
		$this->std_adm_count = count($lobj_get_student_data);
		// var_dump($get_student_data);
		// die();
		$query = "select distinct r.FDESCPN from {$degreetmp} d,reason r where r.FREASONCD = d.FFACULTY and d.FDEGREE='{$this->degree_code}'";
		// var_dump($query);
		$this->result = $this->aobj_context->mobj_db->GetRow($query);
		$this->FFACULTY = $this->result['FDESCPN'];

		$query = "select distinct funivcode,
		ifnull(fsunivcode,'') as fsunivcode,
		ifnull(fdegas,'') as fdegas,
		ifnull(fcollas,'College') as fcollas,
		ifnull(fsubas,'Subject') as fsubas 
		from control";
		$this->result = $this->aobj_context->mobj_db->GetRow($query);
		$this->fsunivcode = $this->result['fsunivcode'];
		$this->fcollas = $this->result['fcollas'];

		// var_dump($lobj_get_student_data);
		
		foreach($lobj_get_student_data as  $rek=>$rev)
		{		
			
			$full_photo_path="";
			$full_photo_path = trim($this->aobj_context->main_src."/".$rev['photo_path']);
			if($this->rptype == 'wp')
			{	
				if(file_exists($full_photo_path) && !empty($rev['photo_path']))
				{
					// var_dump($std_arr[$rev['FREGNO']]);
					// die();
					$this->std_arr[$rev['FREGNO']]['FREGNO'] = $rev['FREGNO'];
					$this->std_arr[$rev['FREGNO']]['fsignpath'] = $rev['fsignpath'];
					$this->std_arr[$rev['FREGNO']]['fprinsignpath'] = $rev['fprinsignpath'];
					$this->std_arr[$rev['FREGNO']]['FCOLLCODE'] = $rev['FCOLLCODE'];
					$this->std_arr[$rev['FREGNO']]['FCOLLCODE'] = $rev['FCOLLCODE'];
					$this->std_arr[$rev['FREGNO']]['COURSE'] = $rev['COURSE'];
					$this->std_arr[$rev['FREGNO']]['degname'] = $rev['degname'];
					$this->std_arr[$rev['FREGNO']]['FNAME'] = $rev['FNAME'];
					$this->std_arr[$rev['FREGNO']]['FFATNAME'] = $rev['FFATNAME'];
					$this->std_arr[$rev['FREGNO']]['FMOTNAME'] = $rev['FMOTNAME'];
					$this->std_arr[$rev['FREGNO']]['FDOB'] = $rev['FDOB'];
					$this->std_arr[$rev['FREGNO']]['fenroll'] = $rev['fenroll'];
					$this->std_arr[$rev['FREGNO']]['EXAMDATE'] = $rev['FEXAMDATE'];
					$this->std_arr[$rev['FREGNO']]['FCOLLNAME'] = $rev['FCOLLNAME'];
					$this->std_arr[$rev['FREGNO']]['CollDetails'] = $rev['CollDetails'];
					$this->std_arr[$rev['FREGNO']]['photo_path'] = $rev['photo_path'];
					$this->std_arr[$rev['FREGNO']]['fstudid'] = $rev['fstudid'];
					$this->std_arr[$rev['FREGNO']]['FEXAMCNTR'] = $rev['FEXAMCNTR'];
					$this->std_arr[$rev['FREGNO']]['FABCID'] = $rev['fabcid'];
					$this->std_arr[$rev['FREGNO']]['exam_center_name'] = $rev['exam_center_name'];
					$this->std_arr[$rev['FREGNO']]['fsunivcode'] = $this->fsunivcode;
					
				}
			}
			else if($this->rptype == 'wop')
			{
				
				if(!file_exists($full_photo_path))
				{										
					$this->std_arr[$rev['FREGNO']]['FREGNO'] = $rev['FREGNO'];
					$this->std_arr[$rev['FREGNO']]['fsignpath'] = $rev['fsignpath'];
					$this->std_arr[$rev['FREGNO']]['fprinsignpath'] = $rev['fprinsignpath'];
					$this->std_arr[$rev['FREGNO']]['FCOLLCODE'] = $rev['FCOLLCODE'];
					$this->std_arr[$rev['FREGNO']]['FCOLLCODE'] = $rev['FCOLLCODE'];
					$this->std_arr[$rev['FREGNO']]['COURSE'] = $rev['COURSE'];
					$this->std_arr[$rev['FREGNO']]['degname'] = $rev['degname'];
					$this->std_arr[$rev['FREGNO']]['FNAME'] = $rev['FNAME'];
					$this->std_arr[$rev['FREGNO']]['FFATNAME'] = $rev['FFATNAME'];
					$this->std_arr[$rev['FREGNO']]['FMOTNAME'] = $rev['FMOTNAME'];
					$this->std_arr[$rev['FREGNO']]['FDOB'] = $rev['FDOB'];
					$this->std_arr[$rev['FREGNO']]['fenroll'] = $rev['fenroll'];
					$this->std_arr[$rev['FREGNO']]['EXAMDATE'] = $rev['FEXAMDATE'];
					$this->std_arr[$rev['FREGNO']]['FCOLLNAME'] = $rev['FCOLLNAME'];
					$this->std_arr[$rev['FREGNO']]['CollDetails'] = $rev['CollDetails'];
					$this->std_arr[$rev['FREGNO']]['photo_path'] = $rev['photo_path'];
					$this->std_arr[$rev['FREGNO']]['fstudid'] = $rev['fstudid'];
					$this->std_arr[$rev['FREGNO']]['FEXAMCNTR'] = $rev['FEXAMCNTR'];
					$this->std_arr[$rev['FREGNO']]['FABCID'] = $rev['fabcid'];
					$this->std_arr[$rev['FREGNO']]['exam_center_name'] = $rev['exam_center_name'];
					$this->std_arr[$rev['FREGNO']]['fsunivcode'] = $this->fsunivcode;
					// var_dump($this->std_arr[$rev['FREGNO']]);
				}
			}
			else
			{
					$this->std_arr[$rev['FREGNO']]['FREGNO'] = $rev['FREGNO'];
					$this->std_arr[$rev['FREGNO']]['fsignpath'] = $rev['fsignpath'];
					$this->std_arr[$rev['FREGNO']]['fprinsignpath'] = $rev['fprinsignpath'];
					$this->std_arr[$rev['FREGNO']]['FCOLLCODE'] = $rev['FCOLLCODE'];
					$this->std_arr[$rev['FREGNO']]['FCOLLCODE'] = $rev['FCOLLCODE'];
					$this->std_arr[$rev['FREGNO']]['COURSE'] = $rev['COURSE'];
					$this->std_arr[$rev['FREGNO']]['degname'] = $rev['degname'];
					$this->std_arr[$rev['FREGNO']]['FNAME'] = $rev['FNAME'];
					$this->std_arr[$rev['FREGNO']]['FFATNAME'] = $rev['FFATNAME'];
					$this->std_arr[$rev['FREGNO']]['FMOTNAME'] = $rev['FMOTNAME'];
					$this->std_arr[$rev['FREGNO']]['FDOB'] = $rev['FDOB'];
					$this->std_arr[$rev['FREGNO']]['fenroll'] = $rev['fenroll'];
					$this->std_arr[$rev['FREGNO']]['EXAMDATE'] = $rev['FEXAMDATE'];
					$this->std_arr[$rev['FREGNO']]['FCOLLNAME'] = $rev['FCOLLNAME'];
					$this->std_arr[$rev['FREGNO']]['CollDetails'] = $rev['CollDetails'];
					$this->std_arr[$rev['FREGNO']]['photo_path'] = $rev['photo_path'];
					$this->std_arr[$rev['FREGNO']]['fstudid'] = $rev['fstudid'];
					$this->std_arr[$rev['FREGNO']]['FEXAMCNTR'] = $rev['FEXAMCNTR'];
					$this->std_arr[$rev['FREGNO']]['FABCID'] = $rev['fabcid'];
					$this->std_arr[$rev['FREGNO']]['exam_center_name'] = $rev['exam_center_name'];
					$this->std_arr[$rev['FREGNO']]['FFACULTY'] = $this->FFACULTY;
					$this->std_arr[$rev['FREGNO']]['fsunivcode'] = $this->fsunivcode;
			}
		} 	 
	}
	
	function getSubjectAppearing() //date_format(FDOE,'%d/%m/%Y')
	{
		session_start();
		$FUNIVCODE = $_SESSION['FUNIVCODE'];
		
		$examstr1 = "";
		$examstr2 = "";
		$examstr3 = "";

		if(strtolower($this->exam) != 'all')
		{	
			$examstr1 = "and fexamno = '{$this->exam}'";
			$examstr2 = "and am.fexamno = '{$this->exam}'";
			$examstr3 = "and a.fexamno = '{$this->exam}'";
		}

		if($FUNIVCODE == '051')	
		{
			$query = "select distinct fyear, fexamtype from canddet where fdegree = '{$this->degree_code}' {$examstr1}";
			$res1 = $this->aobj_context->mobj_db->GetRow($query);
			$fyear = $res1['fyear'];
			$fexamtype = $res1['fexamtype'];

			$query = "select distinct fdeggrp from degree 
			where fdegree = '{$this->degree_code}' {$examstr1}";
			$res4 = $this->aobj_context->mobj_db->GetRow($query);
			$fdeggrp = $res4['fdeggrp'];

			$delqur = "delete from attshort where 
			fdegree = '{$this->degree_code}' 
			and fyear = '{$fyear}' and fexamtype = '{$fexamtype}'
			{$examstr1}";
			$res2 = $this->aobj_context->mobj_db->Execute($delqur);

			$delqur1 = "update canddet set fpassmth = NULL
			where fdegree = '{$this->degree_code}' and fpassmth = 'Short'
			and fyear = '{$fyear}' and fexamtype = '{$fexamtype}'
			{$examstr1}";
			$res3 = $this->aobj_context->mobj_db->Execute($delqur1);

			if($fdeggrp == 'UGMD')
			{
				$qyery = "insert ignore into attshort(fcollcode,fdegree,fexamno,fsubcode,fregno,fremarks,ftotval,fsecval,fperval,FUPDDATE,fyear,fexamtype,fshortiaper)
				select m.fcollcode,m.fdegree,m.fexamno,m.fsubcode,m.fregno,'IA Shortage', sum(m.fmarks) as secmarks,sum(s.fvalmax) as maxmarks,
				((sum(m.fmarks)/sum(s.fvalmax))*100) as perval,now(),m.fyear,m.fexamtype,dg.fshortiaper 
				from marks m inner join candsum cs on m.fregno = cs.fregno and m.fexamno = cs.ffreshexam
				and m.fyear = cs.fyear and m.fexamtype = cs.fexamtype
				inner join subject s on m.fdegree = s.fdegree and m.fexamno = s.fexamno and m.fsubcode = s.fcsubcode
				inner join degree dg on m.fdegree = dg.fdegree and m.fexamno = dg.fexamno
				where m.fdegree ='{$this->degree_code}' 
				and m.fcollcode = '{$this->college_code}'
				and ifnull(dg.fshortiaper,'') <> ''	
				{$examstr2}
				group by m.fcollcode,m.fdegree,m.fexamno,s.fsubcode,m.fregno
				having (perval< CAST(dg.fshortiaper as unsigned))";
				
				$res4 = $this->aobj_context->mobj_db->Execute($qyery);

			}else
			{	

				$qyery = "insert ignore into attshort(fcollcode,fdegree,fexamno,fsubcode,fregno,fremarks,ftotval,fsecval,fperval,FUPDDATE,fyear,fexamtype,fshortiaper)
				select m.fcollcode,m.fdegree,m.fexamno,m.fsubcode,m.fregno,'IA Shortage',
				sum(fsmaxmarks) as totval,sum(if(ifnull(fmarks,'-1') = '-1',0,fmarks)) as secval,
				(sum(if(ifnull(fmarks,'-1') = '-1',0,fmarks))/sum(fvalmax)*100) as perval,now(),m.fyear,m.fexamtype,dg.fshortiaper
				from marks m 
				inner join candsum cs on m.fregno = cs.fregno and m.fexamno = cs.ffreshexam
				and m.fyear = cs.fyear and m.fexamtype = cs.fexamtype
				inner join subject s on m.fdegree = s.fdegree and m.fexamno = s.fexamno and m.fsubcode = s.fcsubcode
				inner join degree dg on m.fdegree = dg.fdegree and m.fexamno = dg.fexamno
				where s.fintass = 'T' and m.fdegree like '{$this->degree_code}' 
				and ifnull(dg.fshortiaper,'') <> ''
				{$examstr2} 
				and m.fcollcode = '{$this->college_code}'
				and s.fretain = 'T' 
				group by m.fcollcode,m.fdegree,m.fexamno,m.fsubcode,m.fregno
				having (perval< CAST(dg.fshortiaper as unsigned))";
				
				//<ifnull(dg.fshortiaper,'0')
				// echo $qyery;
				// die();
				$res4 = $this->aobj_context->mobj_db->Execute($qyery);
			}

			$qyery = "insert ignore into attshort(fcollcode,fdegree,fexamno,fsubcode,fregno,fremarks,fperval,FUPDDATE,fyear,fexamtype)
			select distinct a.fcollcode,a.fdegree,a.fexamno,s.fcsubcode,a.fregno,'Attendance Shortage',ifnull(a.fper,0) as perval,now(),a.fyear,a.fexamtype
			from attend a inner join candsum cs on a.fregno = cs.fregno and a.fexamno = cs.ffreshexam
			and a.fyear = cs.fyear and a.fexamtype = cs.fexamtype
			inner join degree dg on a.fdegree = dg.fdegree and a.fexamno = dg.fexamno
			inner join subject s on a.fdegree = s.fdegree and a.fexamno = s.fexamno
			and left(a.fsubcode,4) = s.fsubcode
			where ifnull(fper,0) < ifnull(dg.fshortattper,0) 
			and a.fdegree = '{$this->degree_code}'
			and ifnull(dg.fshortattper,'') <> ''
			and s.fretain <> 'T'
			{$examstr3} 
			and a.fcollcode like '{$this->college_code}' and ifnull(a.fentdate,'')<>''";
			$res5 = $this->aobj_context->mobj_db->Execute($qyery);

			$qyery = "update canddet cd, attshort a set cd.FPASSMTH = 'Short', 
			cd.fmoduser = 'D'
			where a.fregno = cd.fregno and cd.fdegree = a.fdegree 
			and cd.fexamno = a.fexamno 
			and cd.fsubcode = left(a.fsubcode,4)
			and a.fyear = cd.fyear
			and a.fexamtype = cd.fexamtype
			#and cd.fpresent = 'P'
			and cd.fdegree = '{$this->degree_code}'
			{$examstr3} 
			and cd.fcollcode = '{$this->college_code}'";
			$res6 = $this->aobj_context->mobj_db->Execute($qyery);

		}


		$canddettmp = "canddet";
		$candsumttmp = "candsum"; 
		
		$degreetmp = "degree";
		$subjecttmp = "subject";
		
		if($FUNIVCODE == '008x')
		{
			$candsum = "examcandsum"; 
			$canddet = "examcanddet";
			$cnd1 = "and d.fexyear=c.FYEAR and left(d.fexexamtype,1)=left(c.FEXAMTYPE,1)"; 

		}
		else if($FUNIVCODE == '001')
		{
			$candsum = "candsum_re_bed"; 
			$canddet = "canddet_re_bed"; 
			$cnd1 = "and d.FADYEAR=c.FYEAR and left(d.FADEXAMTYP,1)=left(c.FEXAMTYPE,1)";
		}
		else
		{
			$candsum = "candsum"; 
			$canddet = "canddet"; 
			$cnd1 = "and d.FADYEAR=c.FYEAR and left(d.FADEXAMTYP,1)=left(c.FEXAMTYPE,1)";
		}	

		/* if($FUNIVCODE == '008')
		{
			$present = "1=1";	
		}else
		{
			$present = "c.fpresent = 'P'";
		} */
		// var_dump($_SESSION['usr']);
		// die();

		$userID = $_SESSION['user_id'];

		$query = "select * from s_sysdb where internal_code = '{$userID}'";
		$res = $this->aobj_context->mobj_db->GetRow($query);
		$user_type = $res['user_type'];	

		if($user_type != '40')
		{
			$query = 'select group_concat(concat("\'",fexamno,"\'")) as exam
			from collexam where fdegree = "'.$this->degree_code.'" and fcollcode = "'.$this->college_code.'"
			and DATE_FORMAT(now(),"%Y-%m-%d") 
			BETWEEN DATE_FORMAT(fhtfrom,"%Y-%m-%d") 
			AND DATE_FORMAT(fhtto,"%Y-%m-%d")';
			$res = $this->aobj_context->mobj_db->GetRow($query);
			$exam = $res['exam'];
		}else
		{
			$exam = "'A','B','C','D','E','F','G','H','I','J'";
		}	
		//var_dump($exam);
		//die();
		if($FUNIVCODE == '026')
		{
			$order = "ORDER BY s.FTHEORY desc, s.FCSUBCODE";
		}
		else if($FUNIVCODE == '051')
		{
		
			$order = "ORDER BY s.FTHEORY desc,s.FDOE, s.FSESSION,d.FEXAMNO,s.fsubcode,s.fcsubcode";
		}
		else
		{
			$order = "ORDER BY s.FTHEORY desc,if(t.fdate = '0000-00-00','2050-09-22',ifnull(t.fdate,'99999999')), t.fsession desc,d.FEXAMNO,rs.fdescpn,s.fqpcode";
		}

		if($FUNIVCODE == '049')
		{
			$sub = "GROUP_CONCAT(c.FEXAMNO,'->',s.FCSUBCODE ,'->',s.FSUBNAME,' ',if('{$FUNIVCODE}' = '049','',concat('[',s.FSSUBNAME,']')),'->',if(s.fcsubcode = a.fsubcode,a.fremarks,''),'->', 
			s.FSHORTNAME,'->',concat(if(date_format(FDOE,'%d/%m/%Y')!='00/00/0000',
			date_format(FDOE,'%d/%m/%Y'),''),' - ',ifnull(rs.fdescpn,''),'->',if('{$FUNIVCODE}' = '018',FSUBSHORT,s.FQPCODE)),'->',ftheory,'->',if(c.fsdoe = '','-',ifnull(c.fsdoe,'-')),'->',ifnull(fssession,'-') 
			{$order}  SEPARATOR '~')";

			// $subject = "and s.fssubcode = '0'";
		}else if($FUNIVCODE == '051' || $FUNIVCODE == '055')
		{
			
			$sub = "GROUP_CONCAT(c.FEXAMNO,'->',s.FSUBSHORT ,'->',s.FSUBNAME,'->',if(left(s.fsubcode,4) = left(a.fsubcode,4),a.fremarks,''),'->', 
			s.FSHORTNAME,'->',concat(if(date_format(FDOE,'%d/%m/%Y')!='00/00/0000',
			date_format(FDOE,'%d/%m/%Y'),''),' - ',ifnull(rs.fdescpn,''),'->',if('{$FUNIVCODE}' = '018',FSUBSHORT,s.FQPCODE)),'->',ftheory,'->',FSUBSHORT,'->',s.FSSUBNAME 
			{$order}  SEPARATOR '~')";

		}else if($FUNIVCODE == '052')
		{
			$sub = "GROUP_CONCAT(c.FEXAMNO,'->',s.FSUBSHORT ,'->',s.FSUBNAME,'->',if(s.fcsubcode = a.fsubcode,a.fremarks,''),'->', 
			s.FSHORTNAME,'->',concat(if(date_format(t.fdate,'%d/%m/%Y')!='00/00/0000',
			date_format(t.fdate,'%d/%m/%Y'),''),' - ',ifnull(t.fsession,''),'->',if('{$FUNIVCODE}' = '018',FSUBSHORT,s.FQPCODE)),'->',ftheory,'->',FSUBSHORT,'->',s.FSSUBNAME,'->',if(c.fsdoe = '','-',ifnull(c.fsdoe,'-')),'->',ifnull(fssession,'-') 
			{$order}  SEPARATOR '~')";
		}
		else
		{
			$sub = "GROUP_CONCAT(c.FEXAMNO,'->',s.FCSUBCODE ,'->',s.FSUBNAME,' ',if('{$FUNIVCODE}' = '049','',concat('[',s.FSSUBNAME,']')),'->',if(s.fcsubcode = a.fsubcode,a.fremarks,''),'->', 
			s.FSHORTNAME,'->',concat(if(date_format(FDOE,'%d/%m/%Y')!='00/00/0000',
			date_format(FDOE,'%d/%m/%Y'),''),' - ',ifnull(rs.fdescpn,''),'->',if('{$FUNIVCODE}' = '018',FSUBSHORT,s.FQPCODE)),'->',ftheory,'->',FSUBSHORT 
			{$order}  SEPARATOR '~')";
		}

		$cnd9 ="and s.FSSUBNAME not like '%MCQ%'";
		if($FUNIVCODE == '051' || $FUNIVCODE == '055')
			$cnd9 = '';
		
		$subsidary = "";
		

		if(strtolower($this->exam) != 'all')
			$examstr = "and d.fexamno = '{$this->exam}'";
		else
			$examstr = "";

		if($FUNIVCODE == '052')
		{
			$get_subject_appearing = "SELECT c.FDEGREE, cs.FREGNO AS FREGNO , 
			GROUP_CONCAT(d.FEXAMNAME ORDER BY s.FTHEORY desc, s.FDOE, s.FSESSION,d.FEXAMNO) EXAMNAME,ifnull(a.FREMARKS,'') as FREMARKS,
			GROUP_CONCAT(c.FEXAMNO ORDER BY c.FEXAMNO,c.FSUBCODE) FEXAMNO, c.FREGNO,
			{$sub} AS SUBCODE , 
			GROUP_CONCAT(ifnull(s.FSUBNAME,''),' ',ifnull(s.FSSUBNAME,''),
			' [',ifnull(FSUBSHORT,''),']' ORDER BY s.FCSUBCODE) AS SUBDECPN,
			ifnull(FRECPTDATE,'') as receipt_date FROM {$canddet} c INNER JOIN {$subjecttmp} s ON
			c.FDEGREE=s.FDEGREE AND c.FEXAMNO=s.FEXAMNO AND c.FSUBCODE=s.FSUBCODE AND s.FINTASS!='T' 
			AND INSTR(ifnull(c.fthpr,''), s.ftheory) <= 0
			left outer join reason rs on s.fsession = rs.freasoncd
			inner join {$degreetmp} d on c.FDEGREE= d.FDEGREE AND c.FEXAMNO=d.FEXAMNO
			
			inner join {$candsum} cs on cs.FREGNO=c.FREGNO AND 
			cs.FCOLLCODE=c.FCOLLCODE
			and cs.fyear = c.fyear
			and cs.fexamtype = c.fexamtype
			left join timetable t on s.fqpcode = t.fqpcode and c.fyear = t.fyear
			and c.fexamtype = t.fexamtype
			left join attshort a on a.fregno = c.fregno 
			and left(s.fsubcode,4) = left(a.fsubcode,4)
			and ifnull(a.fdeleted,'') <> 'T'
			AND a.FYEAR=cs.FYEAR
			and left(a.FEXAMTYPE,1)=left(cs.FEXAMTYPE,1)
			AND c.FYEAR=cs.FYEAR
			and left(c.FEXAMTYPE,1)=left(cs.FEXAMTYPE,1)
			WHERE c.FCOLLCODE='{$this->college_code}' 
			AND if(c.FPASSMTH = '','Short',ifnull(c.FPASSMTH,'Short')) = 'Short' 
			AND c.fpresent = 'P'
			and INSTR(cs.fhtenable,c.fexamno) >0
			{$cnd9}
			and c.FREGNO >= '{$this->registor_no_starts}' 
			AND c.FREGNO <='{$this->registor_no_ends}'
			and c.fyear = '{$this->fyear}'
			and c.fexamtype = '{$this->fexamtype}'
			and cs.frecptdate is not null  is not null {$subsidary}
			{$examstr} $subject
			GROUP BY c.FREGNO";	
			// var_dump($get_subject_appearing);
			// die();
		}else
		{

		
			$get_subject_appearing = "SELECT c.FDEGREE, cs.FREGNO AS FREGNO , 
			GROUP_CONCAT(d.FEXAMNAME ORDER BY s.FTHEORY desc, s.FDOE, s.FSESSION,d.FEXAMNO) EXAMNAME,ifnull(a.FREMARKS,'') as FREMARKS,
			GROUP_CONCAT(c.FEXAMNO ORDER BY c.FEXAMNO,c.FSUBCODE) FEXAMNO, c.FREGNO,
			{$sub} AS SUBCODE , 
			GROUP_CONCAT(ifnull(s.FSUBNAME,''),' ',ifnull(s.FSSUBNAME,''),
			' [',ifnull(FSUBSHORT,''),']' ORDER BY s.FCSUBCODE) AS SUBDECPN,
			ifnull(FRECPTDATE,'') as receipt_date FROM {$canddet} c INNER JOIN {$subjecttmp} s ON
			c.FDEGREE=s.FDEGREE AND c.FEXAMNO=s.FEXAMNO AND c.FSUBCODE=s.FSUBCODE AND s.FINTASS!='T' 
			AND INSTR(ifnull(c.fthpr,''), s.ftheory) <= 0
			left outer join reason rs on s.fsession = rs.freasoncd
			inner join {$degreetmp} d on c.FDEGREE= d.FDEGREE AND c.FEXAMNO=d.FEXAMNO
			{$cnd1}
			inner join {$candsum} cs on cs.FREGNO=c.FREGNO AND 
			cs.FCOLLCODE=c.FCOLLCODE
			left join attshort a on a.fregno = c.fregno 
			and left(s.fsubcode,4) = left(a.fsubcode,4)
			and ifnull(a.fdeleted,'') <> 'T'
			AND c.FYEAR=cs.FYEAR
			and left(c.FEXAMTYPE,1)=left(cs.FEXAMTYPE,1)
			WHERE c.FCOLLCODE='{$this->college_code}' 
			AND if(c.FPASSMTH = '','Short',ifnull(c.FPASSMTH,'Short')) = 'Short' 
			AND c.fpresent = 'P'
			and INSTR(cs.fhtenable,c.fexamno) >0
			{$cnd9}
			and c.FREGNO >= '{$this->registor_no_starts}' 
			AND c.FREGNO <='{$this->registor_no_ends}'
			and cs.frecptdate is not null  is not null {$subsidary}
			{$examstr} $subject
			GROUP BY c.FREGNO";	
		}
	// var_dump($get_subject_appearing);
	// die();
//echo $get_subject_appearing;
		$this->aobj_context->mobj_db->execute("SET @@session.group_concat_max_len=100000");	
		$this->lobj_get_subject_appearing = $this->aobj_context->mobj_db->GetAll($get_subject_appearing);
		$this->receipt_date_arr=array();
		//var_dump($this->lobj_get_subject_appearing);
		//die();
		foreach($this->lobj_get_subject_appearing as $suk=>$suv)
		{		
			// var_dump($suv['SUBCODE']);
			
			$this->std_arr[$suv['FREGNO']]['SUBCODE']=$suv['SUBCODE'];
			$this->std_arr[$suv['FREGNO']]['FEXAMNO']=$suv['FEXAMNO'];
			$this->std_arr[$suv['FREGNO']]['EXAMNAME']=$suv['EXAMNAME'];
			$this->std_arr[$suv['FREGNO']]['FREMARKS']=$suv['FREMARKS'];
			if(!empty($suv['receipt_date']))
			$this->receipt_date_arr[$suv['FREGNO']]=$suv['receipt_date'];	

		} 
		//var_dump($this->receipt_date_arr);
		// var_dump($this->std_arr);	
	}	

	
}

function generateAdmissionTicketJsstu($aobj_context)
{
		include_once("stringspliter.php");
		session_start();
		$FUNIVCODE = $_SESSION['FUNIVCODE'];
		
		// var_dump($_SESSION['UNIVCODE']);
		$class_obj=new AdmissionTicket($aobj_context);		
		ini_set("memory_limit",-1);
		ini_set('max_execution_time',3300);
		$class_obj->degree_code	= $aobj_context->mobj_data["degree_code"];
		
		
		if(preg_match('[^BTH]', $class_obj->degree_code))
		$class_obj->bth_flag=1;
		
		$class_obj->registor_no_starts= $aobj_context->mobj_data["reg_starts"];
		$class_obj->registor_no_ends= $aobj_context->mobj_data["reg_ends"]; 
		$class_obj->rptype = $aobj_context->mobj_data["rptype"];  
		$class_obj->exam = $aobj_context->mobj_data["exam"]; 

		$class_obj->exammonth = $aobj_context->mobj_data["exammonth"]; 
		$month = explode('*',$class_obj->exammonth);
		$class_obj->fyear = $month[0];
		$class_obj->fexamtype = $month[1];
		
		
		 
		$main_src=substr($_SERVER['SCRIPT_FILENAME'],0,strlen($_SERVER['SCRIPT_FILENAME'])-7);
		$pdf_writer_class =$main_src."/tcpdf/tcpdf.php";
		//$pdf_writer_class =$main_src."/tarka_pdf/fpdf.php";
		include_once("stringspliter.php");
		require_once($pdf_writer_class);
		
		//include($pdf_writer_class);		
		//$pdf= new FPDF();
		$pdf= new TCPDF();;
		$pdf->SetMargins(9,2,15,2);	
		//$pdf->aobj_context =$aobj_context ;
		//$pdf->WhichReport = 'AdmissionTicket';
		//$pdf->SetFillColor(248, 248 ,255);		
		$pdf->SetFont('Times','',10);
		
		$pdf->AddPage("P");
		
		if($FUNIVCODE != '055')
			$pdf->SetMargins(9,2,15,2);
		
		$adm_details=$class_obj->getUniversityDetails();
		$adm_details=$class_obj->getCollegeDetails();
		$adm_details=$class_obj->getStudentDetails();
		$adm_details=$class_obj->getSubjectAppearing();

		if($FUNIVCODE != '027' && $FUNIVCODE != '055')
			$pdf->Rect(5,05,195,280,'D');
	 	$page_cnt=1;
		$a = 0;

		// var_dump($class_obj->std_arr);
		foreach($class_obj->std_arr as $reg_k=>$reg_v)
		{		
			$curexamtitle = '';
			

			if($reg_v['FREGNO'] == '')
				continue;

			if($reg_v['fsunivcode'] == '003D')
			{
				$FUNIVCODE = '003D';
			}

			if($FUNIVCODE == '003D')
			{
				$curl3 = curl_init();
				$photo_url = 'https://university-student-photos.s3.ap-south-1.amazonaws.com/'.$FUNIVCODE.'/'.urlencode($reg_v['photo_path']);
				//var_dump($photo_url);
				//		"https://university-student-photos.s3.ap-south-1.amazonaws.com/003D/student_photos/5501/dnmb/181A0006.jpg";
				curl_setopt($curl3, CURLOPT_URL, $photo_url);
				curl_setopt($curl3, CURLOPT_NOBODY, true);
				$response_photo = curl_exec($curl3);
				$httpCode_photo = curl_getinfo($curl3 , CURLINFO_HTTP_CODE);
				//var_dump($httpCode_photo);

				if($httpCode_photo != 200) //!file_exists($actualpath)
				{
					continue;
				}
			}	

			$query = "select FHTENABLE from candsum where  fregno = '{$reg_v['FREGNO']}'";
			$res = $aobj_context->mobj_db->GetRow($query);
			$FHTENABLE = $res['FHTENABLE'];

			$query = "select distinct funivcode,
			ifnull(fsunivcode,'') as fsunivcode,
			ifnull(fdegas,'Course') as fdegas,
			ifnull(fcollas,'College') as fcollas,
			ifnull(fsubas,'Subject') as fsubas,
			ifnull(FREGROLL,'Reg. No.') as FREGROLL 
			from control";
			$res2 = $aobj_context->mobj_db->GetRow($query);
			$fcollas = $res2['fcollas'];
			$FREGROLL = $res2['FREGROLL'];
			$fdegas = $res2['fdegas'];
			$fsubas = $res2['fsubas'];

			if($FUNIVCODE != '008')
			{
				if(!array_key_exists($reg_v['FREGNO'],$class_obj->receipt_date_arr))
				continue;
			}
			//for gcm edited on 15/11/2016 for no photo /with photo
			$full_photo_path="";
			$full_photo_path=trim($aobj_context->main_src."/".$reg_v['photo_path']);	
			
	
				$funivname = $class_obj->std_FUNIVNAME;

				$pdf->Ln(2);
				//$pdf->SetLineWidth(0.01);
				$pdf->SetFont('Times','B',14);
				$img_path = $aobj_context->main_src."/".$aobj_context->mobj_data["db"]."/img/report_uni_logo.jpg";
				
				if($FUNIVCODE == '055')
				{
					if(file_exists($img_path)) 
					{	
						if($FUNIVCODE == '048')
						{	
							$img_path = $aobj_context->main_src."/".$aobj_context->mobj_data["db"]."/img/rur_logo.jpg";
							$pdf->Image($img_path,47,6,110,19);
							$pdf->Ln(22);
						}else if($FUNIVCODE == '055')
						{
							$img_path = $aobj_context->main_src."/".$aobj_context->mobj_data["db"]."/img/SJBIT_Log_Header.jpg";
							// $pdf->Image($img_path,30,6,140,20);
							// $pdf->Ln(22);
							
							if($a == '0')
							{
								$pdf->Image($img_path,35,4,130,18);
								$pdf->Ln(16);
							}else
							{
								$pdf->setY(142);
								$pdf->Image($img_path,30,148,130,18);
								$pdf->setY(142);
								$pdf->Ln(22);
							}

						}
						else if($FUNIVCODE == '049')
						{	
							$img_path = $aobj_context->main_src."/".$aobj_context->mobj_data["db"]."/img/report_uni_logo.jpg";
							$pdf->Image($img_path,47,6,90,17);
							
							$pdf->Ln(17);
						}
						else if($FUNIVCODE == '052')
							$pdf->Image($img_path,10,6,50,18);
						else
							$pdf->Image($img_path,10,6,24,24);
					}	

				}else
				{
					if(file_exists($img_path)) 
					{	
						if($FUNIVCODE == '048')
						{	
							$img_path = $aobj_context->main_src."/".$aobj_context->mobj_data["db"]."/img/rur_logo.jpg";
							$pdf->Image($img_path,47,6,110,19);
							$pdf->Ln(22);
						}else if($FUNIVCODE == '055')
						{
							$img_path = $aobj_context->main_src."/".$aobj_context->mobj_data["db"]."/img/SJBIT_Log_Header.jpg";
							if($a == '0')
							{
								$pdf->Image($img_path,30,6,140,20);
								$pdf->Ln(22);
							}else
							{
								
								$pdf->Image($img_path,30,300,140,20);
								//$pdf->Ln(22);
							}
						}
						else if($FUNIVCODE == '049')
						{	
							
							$img_path = $aobj_context->main_src."/".$aobj_context->mobj_data["db"]."/img/report_uni_logo.jpg";
							$pdf->Image($img_path,47,6,90,17);
							
							$pdf->Ln(17);
						}
						else if($FUNIVCODE == '052')
							$pdf->Image($img_path,10,6,50,18);
						else
							$pdf->Image($img_path,10,6,24,24);
					}
				}
						

				$style = array(
					'position' => 'right',
					'align' => 'C',
					'stretch' => false,
					'fitwidth' => true,
					'cellfitalign' => '',
					'border' => false,
					'hpadding' => 'auto',
					'vpadding' => 'auto',
					'fgcolor' => array(0,0,0),
					'bgcolor' => false, //array(255,255,255),
					'text' => true,
					'font' => 'helvetica',
					'fontsize' => 8,
					'stretchtext' => 4
				);

				$pdf->Ln(1);
				if($FUNIVCODE != '048' && $FUNIVCODE != '049' && $FUNIVCODE != '055')
				{

					if($FUNIVCODE == '052')
					{
						$pdf->SetFont('Times','B',9);
						$pdf->Cell(0,4,"JSS MAHAVIDYAPEETHA",0,1,'C'); 
					}
					$pdf->SetFont('Times','B',14);
					$pdf->Cell(0,4,$funivname,0,1,'C');
					$pdf->SetFont('Times','B',9);
					$pdf->Cell(0,4,$class_obj->std_FUNIVADD1,0,1,'C');
				}
				
				$pdf->SetFont('Times','B',12);
				if($FUNIVCODE == '003' || $FUNIVCODE == '051')
					$pdf->Cell(0,5,'HALL TICKET ' ,'0',1,'C'); 
				else
					$pdf->Cell(0,6,'ADMISSION TICKET ' ,'0',1,'C'); 
				
				$pdf->SetFont('Times','',10);	
				if($FUNIVCODE == '051')
				{
					$pdf->Cell(0,5,'UNIVERSITY EXAMINATION '.$reg_v['EXAMDATE'] ,'0',1,'C'); 
				}else
				{
					$pdf->Cell(0,5,$reg_v['EXAMDATE'].' EXAMINATION ' ,'0',1,'C'); 
				}
				
				
				$pdf->SetFont('Times','',10);
				//$pdf->Ln(2);
				$width = 124;	
				////////////////////////////////////
				$nb =0;
				$pdf->SetFont('Times','',8);
				$value = $reg_v['FCOLLCODE']." - ".$reg_v['CollDetails'];
				$nb=max($nb,$pdf->getNumLines($value, 50));
				$yH = 7*$nb;
				

				if($FUNIVCODE == '003' || $FUNIVCODE == '003D' || $FUNIVCODE == '049' || $FUNIVCODE == '050' || $FUNIVCODE == '051' || $FUNIVCODE == '052' || $FUNIVCODE == '055')
				{
					if($FUNIVCODE == '003')
					{
						$folder = "kus";
					}else if($FUNIVCODE == '003D')
					{
						$folder = "kusdde";
					}else if($FUNIVCODE == '049')
					{
						$folder = "nmamit";
					}else if($FUNIVCODE == '050')
					{
						$folder = "srun";
					}else if($FUNIVCODE == '098')
					{
						$folder = "demo";
					}else if($FUNIVCODE == '051')
					{
						$folder = "dypatil";
					}else if($FUNIVCODE == '052')
					{
						$folder = "jssstu";
					}
					else if($FUNIVCODE == '055')
					{
						$folder = "sjbit";
					}
					
					$url = "https://college.universitysolutions.in/app.php?db=".$folder."&a=qrcodeGeneratePostAdmissionTicket.demo&degree_code=".$class_obj->degree_code."&fcollcode=".$reg_v['FCOLLCODE']."&regstarts=".$reg_v['FREGNO']."&regends=".$reg_v['FREGNO']."&FUNIVCODE=".$FUNIVCODE;
					if($FUNIVCODE == '055')
					{	
						if($a == '0')
						{	
							$pdf->write2DBarcode("{$url}", 'QRCODE,L', 175, 8, 17, 17, $style, 'N');
							$pdf->Ln(9);
						}else
						{
							$pdf->write2DBarcode("{$url}", 'QRCODE,L', 175, 148, 18, 18, $style, 'N');
							$pdf->Ln(8);
						}
					}
					else
						$pdf->write2DBarcode("{$url}", 'QRCODE,L', 175, 8, 25, 25, $style, 'N');

				}	

				$keyname = $FUNIVCODE."/".$reg_v['photo_path'];
				//var_dump($FUNIVCODE);
						$s3 = S3Client::factory(
							array(
								'credentials' => array(
									'key' => IAM_KEY,
									'secret' => IAM_SECRET
								),
								'version' => "latest",
								'region'  => 'ap-south-1'
							)
						);
					$filePath = tempnam(sys_get_temp_dir(), rand(10,15));
					try{
					$result = $s3->getObject([
						'Bucket' => STUDENT_PHOTOS_BUCKET,
						'Key'    => $keyname,
						'SaveAs' => $filePath
					]);}
					catch(S3Exception $e){
					}
					
				
				$full_photo_path = $filePath;
				$url = "https://university-student-photos.s3.ap-south-1.amazonaws.com/".$_SESSION['FUNIVCODE']."/".$reg_v['photo_path'];

				// var_dump($url);die();
				// var_dump($reg_v['photo_path']);
				// var_dump($reg_v['photo_path']);
				if(file_exists($full_photo_path) && !empty($reg_v['photo_path']))
				{
					if($FUNIVCODE == '045')
						$pdf->Image($full_photo_path,165,6,30,32);				
					else if($FUNIVCODE == '051' || $FUNIVCODE == '052' || $FUNIVCODE == '033' || $FUNIVCODE == '055')
						$pdf->Image($full_photo_path,174,30,19,19);
					else
					{	
						//var_dump($full_photo_path);
						$pdf->Image($full_photo_path,165,30,30,32);	
					}
						
				}
				else
				{
					if($FUNIVCODE == '051' || $FUNIVCODE == '052' || $FUNIVCODE == '055')
						$pdf->Image($aobj_context->main_src.'/'.$aobj_context->mobj_data["db"]."/img/nophotoborder.jpg",174,30,19,19);
					else
						$pdf->Image($aobj_context->main_src.'/'.$aobj_context->mobj_data["db"]."/img/nophotoborder.jpg",165.5,31,27,28);				
				}
					if($FUNIVCODE == '049')		
						$pdf->Ln(5);
					else
						$pdf->Ln(2);
						
					$pdf->SetFont('Times','B',10); 
					if($FUNIVCODE == '048' || $FUNIVCODE == '049')	
					{	
						$pdf->Cell(25,6,' Programme',0,0,'L');	$pdf->Cell(3,6,' :  ',0,0,'L');	
					}
					else
					{
						$pdf->Cell(25,6,' '.$fdegas,0,0,'L');	$pdf->Cell(3,6,' :  ',0,0,'L');	
					}
					$pdf->SetFont('Times','',10);	
					
					if($FUNIVCODE == '045')			
						$pdf->Cell(120,6,''.$reg_v['degname'],0,1,'L'); 
					else
						$pdf->Cell(120,6,''.$reg_v['COURSE'],0,1,'L'); 	

					if($FUNIVCODE != '045' && $reg_v['fsunivcode'] != '003D' && $FUNIVCODE != '055')
					{
						$pdf->SetFont('Times','B',10); 
						$pdf->Cell(25,6,' '.$fcollas,0,0,'L'); $pdf->Cell(3,6,' :  ',0,0,'L');
						$pdf->SetFont('Times','',10); 
						if($FUNIVCODE == '029')
							$pdf->Cell(120,6,''.$reg_v['CollDetails'],0,1,"L");
						else
							$pdf->MultiCell(120,6,''. $reg_v['FCOLLCODE']." - ".$reg_v['CollDetails'],0,"L");
					}

					
					$pdf->SetFont('Times','B',10); 
					$pdf->Cell(25,6," Student's Name",0,0,'L'); $pdf->Cell(3,6,' :  ',0,0,'L');
					
					if($FUNIVCODE == '052')
						$pdf->SetFont('Times','B',11); 
					else
						$pdf->SetFont('Times','B',10); 
					$pdf->Cell(120,6,''.$reg_v['FNAME'],0,1,'L');
			
					/*$pdf->SetFont('Times','B',9); 
					$pdf->Cell(25,6,' Reg. No.',0,0,'L'); $pdf->Cell(3,6,' :  ',0,0,'L');
					$pdf->SetFont('Times','B',9); 
					$pdf->Cell(120,6,''.$reg_v['FREGNO'],0,1,'L');*/
					/*$x = $pdf->getX();
					$y = $pdf->getY();
						$pdf->Rect($x,05,$y,5,'D');*/
						
					if($reg_v['fenroll'] != '' && $FUNIVCODE == '034')
					{	
						$pdf->ln(2);
						$pdf->SetFont('Times','B',10);
						$pdf->Cell(27,6," UUCMS Reg. No.",0,0,'L'); $pdf->Cell(3,6,' :  ',0,0,'L');
						$pdf->SetFont('Times','B',10); 
						$pdf->Cell(120,6,''.$reg_v['fenroll'],0,1,'L');
					}	
					
					$pdf->SetLineStyle(array('width' => 0.01, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(91, 91, 91)));	
					$pdf->ln(2);
					$pdf->SetFont('Times','B',12); 
					if($FUNIVCODE == '049')
						$pdf->Cell(27,6,' USN',1,0,'L'); 
					else
						$pdf->Cell(27,6,$FREGROLL,1,0,'L'); 
					$pdf->SetFont('Times','B',12);
					
					if($FUNIVCODE == '049')
					{
						if($reg_v['fenroll'] != '')
							$reg_v['FREGNO'] = $reg_v['fenroll'];
					}
					
					$pdf->Cell(5,6,substr($reg_v['FREGNO'],0,1),1,0,'C');
					$pdf->Cell(5,6,substr($reg_v['FREGNO'],1,1),1,0,'C');
					$pdf->Cell(5,6,substr($reg_v['FREGNO'],2,1),1,0,'C');
					$pdf->Cell(5,6,substr($reg_v['FREGNO'],3,1),1,0,'C');
					$pdf->Cell(5,6,substr($reg_v['FREGNO'],4,1),1,0,'C');
					$pdf->Cell(5,6,substr($reg_v['FREGNO'],5,1),1,0,'C');
					$pdf->Cell(5,6,substr($reg_v['FREGNO'],6,1),1,0,'C');
					$pdf->Cell(5,6,substr($reg_v['FREGNO'],7,1),1,0,'C');
					
					if($FUNIVCODE == '049' || $FUNIVCODE == '050' || $FUNIVCODE == '051' || $FUNIVCODE == '052' || $FUNIVCODE == '033' || $FUNIVCODE == '055')
					{	
						if(substr($reg_v['FREGNO'],8,1) != '')
							$pdf->Cell(5,6,substr($reg_v['FREGNO'],8,1),1,0,'C');
						if(substr($reg_v['FREGNO'],9,1) != '')
							$pdf->Cell(5,6,substr($reg_v['FREGNO'],9,1),1,0,'C');
					}

					if($FUNIVCODE == '050' || $FUNIVCODE == '051' || $FUNIVCODE == '052' || $FUNIVCODE == '033')
					{	
						if(substr($reg_v['FREGNO'],10,1) != '')
						$pdf->Cell(5,6,substr($reg_v['FREGNO'],10,1),1,0,'C');
					}
					
					if($FUNIVCODE == '051' || $FUNIVCODE == '052' || $FUNIVCODE == '033')
					{
						if(substr($reg_v['FREGNO'],11,1) != '')
						$pdf->Cell(5,6,substr($reg_v['FREGNO'],11,1),1,0,'C');
						if(substr($reg_v['FREGNO'],12,1) != '')
						$pdf->Cell(5,6,substr($reg_v['FREGNO'],12,1),1,0,'C');
						if($FUNIVCODE == '051' || $FUNIVCODE == '033')
						{
							if(substr($reg_v['FREGNO'],13,1) != '')
							$pdf->Cell(5,6,substr($reg_v['FREGNO'],13,1),1,0,'C');
							if(substr($reg_v['FREGNO'],14,1) != '')
							$pdf->Cell(5,6,substr($reg_v['FREGNO'],14,1),1,0,'C');
							if(substr($reg_v['FREGNO'],15,1) != '')
							$pdf->Cell(5,6,substr($reg_v['FREGNO'],15,1),1,0,'C');
						}
					}

					$pdf->Cell(5,6,'',0,0,'C');
					
					if($FUNIVCODE != '045' && $FUNIVCODE != '021' && $FUNIVCODE != '051x' && $FUNIVCODE != '033')
					{
						$pdf->Cell(24,6,"Student ID ",1,0,'L');
						$pdf->Cell(5,6,substr($reg_v['fstudid'],0,1),1,0,'L'); 
						$pdf->Cell(5,6,substr($reg_v['fstudid'],1,1),1,0,'L'); 
						$pdf->Cell(5,6,substr($reg_v['fstudid'],2,1),1,0,'L'); 
						$pdf->Cell(5,6,substr($reg_v['fstudid'],3,1),1,0,'L'); 
						$pdf->Cell(5,6,substr($reg_v['fstudid'],4,1),1,0,'L'); 
						$pdf->Cell(5,6,substr($reg_v['fstudid'],5,1),1,0,'L'); 
						$pdf->Cell(5,6,substr($reg_v['fstudid'],6,1),1,0,'L'); 
						$pdf->Cell(5,6,substr($reg_v['fstudid'],7,1),1,1,'L'); 
					}else
					{
						$pdf->Cell(5,6,'',0,1,'L'); 
						// if($FUNIVCODE == '051')
						// {
						// 	$pdf->ln(2);
						// 	$pdf->Cell(27,6,"Student ID ",1,0,'L');
						// 	$pdf->Cell(5,6,substr($reg_v['fstudid'],0,1),1,0,'L'); 
						// 	$pdf->Cell(5,6,substr($reg_v['fstudid'],1,1),1,0,'L'); 
						// 	$pdf->Cell(5,6,substr($reg_v['fstudid'],2,1),1,0,'L'); 
						// 	$pdf->Cell(5,6,substr($reg_v['fstudid'],3,1),1,0,'L'); 
						// 	$pdf->Cell(5,6,substr($reg_v['fstudid'],4,1),1,0,'L'); 
						// 	$pdf->Cell(5,6,substr($reg_v['fstudid'],5,1),1,0,'L'); 
						// 	$pdf->Cell(5,6,substr($reg_v['fstudid'],6,1),1,0,'L'); 
						// 	$pdf->Cell(5,6,substr($reg_v['fstudid'],7,1),1,1,'L'); 
						// }

					}

					$pdf->ln(2);
					if($reg_v['fenroll'] != '' && $FUNIVCODE == '043')
					{
						$pdf->SetFont('Times','B',10);
						$pdf->Cell(25,6," UUCMS No.",0,0,'L'); $pdf->Cell(3,6,' :  ',0,0,'L');
						$pdf->SetFont('Times','',10); 
						$pdf->Cell(120,6,''.$reg_v['fenroll'],0,1,'L');

					}						
					//if($FUNIVCODE == '043')
					$pdf->SetFont('Times','B',11); 
					$pdf->Cell(25,6,' Exam Center',0,0,'L'); $pdf->Cell(3,6,' :  ',0,0,'L');
					$pdf->SetFont('Times','',11); 
					
					if($FUNIVCODE == '045')
						$pdf->MultiCell(120,7,''.$reg_v['exam_center_name'],0,'L');	
					else if($FUNIVCODE == '055')
						$pdf->Cell(120,7,''.$reg_v['exam_center_name'],'0',1,'L');	
					else
						$pdf->MultiCell(110,7,''. $reg_v['FEXAMCNTR']." - ".$reg_v['exam_center_name'],0,'L');	

					if($FUNIVCODE == '021'){
						$pdf->SetFont('Times','B',11); 
						$pdf->Cell(25,6,' ABC Id',0,0,'L'); $pdf->Cell(3,6,' :  ',0,0,'L');
						$pdf->SetFont('Times','',11); 
						$pdf->Cell(120,7,''.$reg_v['FABCID'],'0',1,'L');	
					}
					
					if($FUNIVCODE == '008' || $FUNIVCODE == '035')
					{
						$pdf->SetFont('Times','B',10);
						$pdf->Cell(25,6," Father's Name",0,0,'L'); $pdf->Cell(3,6,' :  ',0,0,'L');
						$pdf->SetFont('Times','',10); 
						$pdf->Cell(120,6,''.$reg_v['FFATNAME'],0,1,'L');
						
						$pdf->SetFont('Times','B',10);
						$pdf->Cell(25,6," Mother's Name",0,0,'L'); $pdf->Cell(3,6,' :  ',0,0,'L');
						$pdf->SetFont('Times','',9); 
						$pdf->Cell(120,6,''.$reg_v['FMOTNAME'],0,1,'L');
					}

				
				if($FUNIVCODE == '045')
				{	
					$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '145', '40','130', 16, 0.3, $style, 'R');
					$pdf->Ln(7);
				}else if($FUNIVCODE == '048')
				{	
					$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '148', '62','130', 14, 0.3, $style, 'R');
					$pdf->Ln(10);
				}	
				else if($FUNIVCODE == '049')
					$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '138', '65','130', 16, 0.3, $style, 'R');	
				else if($FUNIVCODE == '050')
					$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '130', '65','125', 16, 0.3, $style, 'R');	
				else if($FUNIVCODE == '051' )
				{
					$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '123', '40','100', 11, 0.17, $style, 'R');		
					$pdf->Ln(21);
				}else if($FUNIVCODE == '055')
				{
					if($a == '0')
					{
						$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '160', '50','130', 12, 0.2, $style, 'R');	
						$pdf->Ln(5);
					}else
					{
						$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '160', '195','130', 12, 0.2, $style, 'R');	
						$pdf->Ln(5);
					}
				}
				else if($FUNIVCODE == '052')
				{
					$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '145', '60','130', 12, 0.2, $style, 'R');	

				}else if($FUNIVCODE == '033')
					$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '150', '60','130', 10, 0.17, $style, 'R');	
				else
					$pdf->write1DBarcode($reg_v['FREGNO'], 'C39', '145', '65','130', 16, 0.3, $style, 'R');	
				
					
				if($FUNIVCODE == '026' || $FUNIVCODE == '027' || $FUNIVCODE == '008')
				{
					$title1 = array('Sl.','Exam','Sub','Subject / Paper Title','QP','Answer','Invigilator');
					$title2 = array('No.','','Code','','Code','Book No.','Signature');
					$w = array('7','9','10','110','15','13','20');

				}else if($FUNIVCODE == '051')
				{
					$title1 = array('Sl.','Sem /','Course','Course Name','Th. / ','QP','Date and Time','Invigilator');
					$title2 = array('No.','Year','Code','','Pr.','Code','','Signature');
					$w = array('6','8','19','58','19','13','48','19');
				}else if($FUNIVCODE == '055')
				{
					$title1 = array('Sl.','Sem /','Course','Course Title','QP','Date and Time','Invigilator');
					$title2 = array('No.','Year','Code','','Code','','Signature');
					$w = array('6','8','19','77','13','48','19');
				}
				else if($FUNIVCODE == '005')
				{
					$title1 = array('Sl.','Sem /','Sub','Subject Title','Date and Time');
					$title2 = array('No.','Year','Code','','');
					$w = array('10','7','15','70','45');

				}else if($FUNIVCODE == '029')
				{
					$title1 = array('Sl.No.','Date','Time','Sub Code','Subject Title','Invigilator`s Signature');
					$title2 = array('','','','','');
					$w = array('9','15','29','16','85','33'); //10 
				}else if($FUNIVCODE == '030')
				{
					$title1 = array('Sl.','Sem /','Sub','Subject Title','Date','Time','Invigilator');
					$title2 = array('No.','Year','Code','','','','Signature');
					$w = array('8','7','15','70','16','29','30');
				}
				else if($FUNIVCODE == '045')
				{
					$title1 = array('Sl.','Sem','Sub','Subject Title','QP','Date and Time','Answer','Invigilator`s');
					$title2 = array('No.','','Code','','Code','','Book No.','Signature');
					$w = array('7','7','10','70','10','43','20','20');
				
				}else if($FUNIVCODE == '049')
				{
					$title1 = array('Sl.','Sem /','Course','Course Title','Th. /','Date and Time','Invigilator`s');
					$title2 = array('No.','Year','Code','','Pr.','','Signature');
					$w = array('7','7','20','70','10','50','25');
				
				}	
				else if($FUNIVCODE == '040')
				{
					$title1 = array('Sl.','Sem /','Sub','Subject Title','QP','Date and Time','Answer','Invigilator`s');
					$title2 = array('No.','Year','Code','','Code','','Book No.','Signature');
					$w = array('7','7','10','70','10','43','20','20');
				
				} else if($FUNIVCODE == '050')	
				{
					$title1 = array('Sl.','Sem','Sub','Subject Title','QP','Date and Time','Answer','Invigilator');
					$title2 = array('No.','','Code','','Code','','Book No.','Signature');
					$w = array('6','6','23','70','12','43','14','14');
				}
				else if($FUNIVCODE == '052')	
				{
					$title1 = array('Sl.','Sem','Course','Subject Title','Date and Time','Answer','Invigilator');
					$title2 = array('No.','','Code','','','Book No.','Signature');
					$w = array('7','7','20','70','45','19','20');
				}
				else if($FUNIVCODE == '021')	
				{
					$title1 = array('Sl.','Sem /','Sub','Subject Title','QP','Date and Time','Answer','Invigilator');
					$title2 = array('No.','Year','Code','','Code','','Book No.','Signature');
					$w = array('7','7','10','80','10','43','15','15');
				}
				else
				{
					$title1 = array('Sl.','Sem','Sub','Subject Title','QP','Date and Time','Answer','Invigilator');
					$title2 = array('No.','','Code','','Code','','Book No.','Signature');
					$w = array('7','7','10','80','10','43','15','15');
				} 

				$length = $w[6]+$w[5]+$w[0]+$w[1]+$w[2]+$w[3]+$w[4];
				//$pdf->Ln(1);
				$pdf->SetFont('Times','B',9);
				if($FUNIVCODE == '029')
					$pdf->Cell($length,5,"SUBJECT'S APPEARING",0,1,'C');
				else if($FUNIVCODE == '049')
					$pdf->Cell($length,5,'',0,1,'C');
				else if($FUNIVCODE == '051' || $FUNIVCODE == '055')
					$pdf->Cell($length,5,'COURSES APPEARING',0,1,'C');
				else
					$pdf->Cell($length,5,'SUBJECTS / PAPERS APPEARING',0,1,'C');
				$pdf->SetFont('Times','B',8);
				
				$length = (count($w) -1);
				for($i = 0;$i<count($w);$i++)
				{
					 if($FUNIVCODE != '029')
					 {	 
						if($i == $length)
							$pdf->Cell($w[$i],6,$title1[$i],"LRT",1,"C");
						else
							$pdf->Cell($w[$i],6,$title1[$i],"LRT",0,"C");
					 }
					 else
					 {
						 if($i == $length)
							$pdf->Cell($w[$i],6,$title1[$i],"1",1,"C");
						else
							$pdf->Cell($w[$i],6,$title1[$i],"1",0,"C");
						 
					 }
					
				}
				
				 if($FUNIVCODE != '029')
				 {
					for($i = 0;$i<count($w);$i++)
					{
						if($i == $length)
							$pdf->Cell($w[$i],4,$title2[$i],"LRB",1,"C");
						else
							$pdf->Cell($w[$i],4,$title2[$i],"LRB",0,"C");
						
					} 
				 }
				$pdf->SetFont('Times','',8);
				// Mark start coords

				$x = $pdf->GetX();
				$y = $pdf->GetY();


				$sub_arr = $reg_v['SUBCODE'];
				// var_dump($sub_arr);
				$subj_arr = explode("~",$sub_arr);
				// var_dump($subj_arr);
				$sl_no=1;
				$j = 0;
				$curexam = '';
				$fremarks = $reg_v['FREMARKS'];
				foreach($subj_arr as $ek)
				{								
					$explode_arr = explode("->",$ek);

					$sem = '';
			
					if($explode_arr[0] == 'A')
					{
						$sem = 'I';
						
					}else if($explode_arr[0] == 'B')
					{
						$sem = 'II';
					}else if($explode_arr[0] == 'C')
					{
						$sem = 'III';
					}else if($explode_arr[0] == 'D')
					{
						$sem = 'IV';
					}else if($explode_arr[0] == 'E')
					{
						$sem = 'V';
					}else if($explode_arr[0] == 'F')
					{
						$sem = 'VI';
					}else if($explode_arr[0] == 'G')
					{
						$sem = 'VII';
					}else if($explode_arr[0] == 'H')
					{
						$sem = 'VIII';
					}else if($explode_arr[0] == 'I')
					{
						$sem = 'IX';
					}else if($explode_arr[0] == 'J')
					{
						$sem = 'X';
					}
					
					if($FUNIVCODE == '029')
					{	
						$nb =0;
						$pdf->SetFont('Times','',8);
						$nb=max($nb,$pdf->getNumLines($explode_arr[2],$w[4]));
						$yH = 5*$nb;
						$pdf->Cell($w[0],$yH, $sl_no,"1",0,"C");
						
						$date = substr($explode_arr[5],0,10);
						$time = substr($explode_arr[5],10,100);
						$pdf->Cell($w[1],$yH, $date,"1",0,"C");
						$pdf->Cell($w[2],$yH, $time,"1",0,"C");
						
						$pdf->Cell($w[3],$yH, $explode_arr[6],"1",0,"C");
						$sub_short=$explode_arr[6];
						$x=$pdf->GetX();
						$y=$pdf->GetY();
						// $subjectname = str_splitf($explode_arr[2],49);
						$pdf->Rect($x,$y,$w[4],$yH);
						
						$pdf->MultiCell($w[4],$yH,$explode_arr[2],0,'L', 0, 0, '', '', true);
					}
					else
					{						
						$nb =0;
						$pdf->SetFont('Times','',8);
						$nb=max($nb,$pdf->getNumLines($explode_arr[2],$w[3]));
						if($nb ==3)
						{
							$yH = 4*$nb;
						}else if($nb ==2)
						{
							$yH = 5*$nb;
						}else
						{
							$yH = 6*$nb;
						}
						//var_dump($explode_arr);

						$pdf->Cell($w[0],$yH, $sl_no,"1",0,"C");
						$pdf->Cell($w[1],$yH,$sem,"1",0,"C");
						if($FUNIVCODE == '049')
							$pdf->Cell($w[2],$yH, $explode_arr[6],"1",0,"C");
						else if($FUNIVCODE == '050')
							$pdf->Cell($w[2],$yH, $explode_arr[8],"1",0,"C");
						else
							$pdf->Cell($w[2],$yH, $explode_arr[1],"1",0,"C");
						$sub_short=$explode_arr[6];
						$x=$pdf->GetX();
						$y=$pdf->GetY();
						// $subjectname = str_splitf($explode_arr[2],49);
						$pdf->Rect($x,$y,$w[3],$yH);
						$pdf->MultiCell($w[3],$yH,$explode_arr[2],0,'L', 0, 0, '', '', true, 0, false, true, $yH, 'M');
					}
					
				
					$pdf->SetXY($x+$w[3],$y);	
					//var_dump($explode_arr[2]);
					if($FUNIVCODE == '005' || $FUNIVCODE == '018')
					{
						$pdf->Cell($w[4], $yH, $explode_arr[4], 'LBR', 1, 'C');
						
					}
					else if($FUNIVCODE == '026' || $FUNIVCODE == '027' || $FUNIVCODE == '008' || $FUNIVCODE == '051x')
					{
						$pdf->Cell($w[4], $yH, $sub_short, 'LRB', 1, 'C');
						$pdf->SetXY($x+$w[3]+$w[4],$y);
						$pdf->Cell($w[5], $yH,'', 'LRB', 1, 'C');
						$pdf->SetXY($x+$w[4]+$w[3]+$w[5],$y);
						$pdf->Cell($w[6], $yH,'', 'LRB', 1, 'C');
					}
					else if($FUNIVCODE == '029')
					{
						//var_dump($explode_arr);
						//$pdf->SetXY($x+$w[2],$y);
						$pdf->SetFont('Times','',9);
						//$pdfCell($w[3], $yH,$explode_arr[5], 'LRB', 1, 'L');
						$pdf->SetXY($x+$w[4],$y);	
						$pdf->Cell($w[5], $yH,'', 'LRB', 1, 'L');						
					}
					else
					{
						$pdf->SetFont('Times','',8);
						//if($fremarks == 'NULL')
						//{
							$fremarks = $explode_arr[3];
							// if($FUNIVCODE == '040')
							// {
							// 	if($reg_v['FREGNO'] == '20MLT008')
							// 	{
							// 		var_dump($fremarks);
							// 		var_dump($explode_arr);
							// 	}
							// }	
							if($FUNIVCODE == '049')	
							{
									//var_dump($explode_arr);
									$pdf->SetFont('Times','',9);
									//$pdf->SetXY($x+$w[3]+$w[4],$y);
									$theyory = "";
									if($explode_arr[7] == 'T')
										$theyory = 'Th.';
									else if($explode_arr[7] == 'F')
										$theyory = 'Pr.';

									$pdf->Cell($w[4], $yH,$theyory, 'LB', 1, 'C');
									$fremarks = $explode_arr[3];
									if($fremarks != '')
									{
										//var_dump($fremarks);
										$pdf->SetFont('Times','B',9);
										$pdf->SetXY($x+$w[3]+$w[4],$y);
										$pdf->Cell($w[5]+$w[6], $yH, $fremarks, '1', 1, 'C');
										$pdf->SetFont('Times','',9);
										// $pdf->SetXY($x+$w[5]+$w[4]+$w[3],$y);
										// $pdf->Cell($w[6], $yH,'', 'LRB', 1, 'C');

									}else
									{
										$pdf->SetXY($x+$w[3]+$w[4],$y);

										if($explode_arr[8] != '-')
											$pdf->Cell($w[5], $yH, $explode_arr[8].' - '.$explode_arr[9], 'LB', 1, 'C');
										else
											$pdf->Cell($w[5], $yH, $explode_arr[5], 'LB', 1, 'C');
										//$pdf->Cell($w[5], $yH, $explode_arr[5], 'LB', 1, 'C');
										$pdf->SetXY($x+$w[5]+$w[4]+$w[3],$y);
										$pdf->Cell($w[6], $yH,'', 'LRB', 1, 'C');
									}

									
								
							}else if($FUNIVCODE == '051' || $FUNIVCODE == '055')
							{
								if($FUNIVCODE == '055')
								{
									$pdf->Cell($w[4], $yH, substr($sub_short,0,5), 'LRB', 1, 'C');
									$pdf->SetFont('Times','',8);
	
									if($fremarks == '')
									{
										
										$pdf->SetXY($x+$w[3]+$w[4],$y);
										$pdf->Cell($w[5], $yH, $explode_arr[5], 'LB', 1, 'C');
										$pdf->SetXY($x+$w[3]+$w[4]+$w[5],$y);
										$pdf->Cell($w[6], $yH,'', 'LRB', 1, 'C');	
										// $pdf->SetXY($x+$w[4]+$w[3]+$w[5]+$w[6],$y);
										// $pdf->Cell($w[7], $yH,'', 'LRB', 1, 'C');
										// $pdf->SetXY($x+$w[5]+$w[4]+$w[3]+$w[6]+$w[7],$y);
										// $pdf->Cell($w[8], $yH,'', 'LRB', 1, 'C');
	
									}else
									{
										$pdf->SetFont('Times','',9);
										$pdf->SetXY($x+$w[3]+$w[4],$y);
										$pdf->Cell($w[5]+$w[6]+$w[7], $yH, $fremarks, 'LBR', 1, 'C');
									
									}
								}else
								{
									$pdf->Cell($w[4], $yH, $explode_arr[9], 'LRB', 1, 'C');
									$pdf->SetFont('Times','',8);
	
									if($fremarks == '')
									{
										
										$pdf->SetXY($x+$w[3]+$w[4],$y);
										$pdf->Cell($w[5], $yH, $sub_short, 'LB', 1, 'C');
										$pdf->SetXY($x+$w[3]+$w[4]+$w[5],$y);
										$pdf->Cell($w[6], $yH, $explode_arr[5], 'LB', 1, 'C');	
										$pdf->SetXY($x+$w[4]+$w[3]+$w[5]+$w[6],$y);
										$pdf->Cell($w[7], $yH,'', 'LRB', 1, 'C');
										// $pdf->SetXY($x+$w[5]+$w[4]+$w[3]+$w[6]+$w[7],$y);
										// $pdf->Cell($w[8], $yH,'', 'LRB', 1, 'C');
	
									}else
									{
										$pdf->SetFont('Times','',9);
										$pdf->SetXY($x+$w[3]+$w[4],$y);
										$pdf->Cell($w[5]+$w[6]+$w[7], $yH, $fremarks, 'LBR', 1, 'C');
									
									}
								}
								
							}else if($FUNIVCODE == '052')
							{
								$pdf->SetFont('Times','',8);
								if($fremarks == '')
								{
									// var_dump($explode_arr);
									// die();
									if($explode_arr[10] != '-')
											$pdf->Cell($w[4], $yH, $explode_arr[10].' - '.$explode_arr[11], 'LB', 1, 'C');
									else
										$pdf->Cell($w[4], $yH, $explode_arr[5], 'LB', 1, 'C');

									//$pdf->Cell($w[4], $yH, $explode_arr[5], 'LB', 1, 'C');
									$pdf->SetXY($x+$w[3]+$w[4],$y);
									$pdf->Cell($w[5], $yH,'', 'LRB', 1, 'C');
									$pdf->SetXY($x+$w[5]+$w[4]+$w[3],$y);
									$pdf->Cell($w[6], $yH,'', 'LRB', 1, 'C');
								}else
								{
									$pdf->SetFont('Times','B',9);
									$pdf->SetXY($x+$w[3],$y);
									$pdf->Cell(+$w[4]+$w[5]+$w[6]+$w[7], $yH, $fremarks, 'LBR', 1, 'C');
									$pdf->SetFont('Times','',9);
								
								}
							}
							else
							{
								// if($FUNIVCODE == '050')
								// {
								// 	var_dump($explode_arr);
								// 	die();
								// }

								$pdf->Cell($w[4], $yH, $sub_short, 'LRB', 1, 'C');
								$pdf->SetFont('Times','',8);
								if($fremarks == '')
								{
									$pdf->SetXY($x+$w[3]+$w[4],$y);
									if($FUNIVCODE == '001')
										$pdf->Cell($w[5], $yH, "", 'LB', 1, 'C');
									else
										$pdf->Cell($w[5], $yH, $explode_arr[5], 'LB', 1, 'C');
									$pdf->SetXY($x+$w[4]+$w[3]+$w[5],$y);
									$pdf->Cell($w[6], $yH,'', 'LRB', 1, 'C');
									$pdf->SetXY($x+$w[5]+$w[4]+$w[3]+$w[6],$y);
									$pdf->Cell($w[7], $yH,'', 'LRB', 1, 'C');
								}else
								{
									$pdf->SetFont('Times','',9);
									$pdf->SetXY($x+$w[3]+$w[4],$y);
									$pdf->Cell($w[5]+$w[6]+$w[7], $yH, $fremarks, 'LBR', 1, 'C');
								
								}

							}
							
					}
					$sl_no++;	
					$j++;
				//}
				}
				if($FUNIVCODE == '055')
				{	
					date_default_timezone_set("Asia/Calcutta");
					$date = date("F j, Y, g:i a");
					$pdf->Cell(0, '6','Date of issue: '.$date, '0', 1, 'L');
				}
			
			
				$pdf->SetFont('Times','',7);
				if($FUNIVCODE == '051')	
					$pdf->Ln(1);
				else
					$pdf->Ln(4);

				$pdf->SetFont('Times','',8);
				$date_str = $class_obj->std_FHTTEXT;
				$text1 = str_replace("<br>","\n",$class_obj->std_FHTTEXT);
				$text = str_replace("<r>","\t",$text1);
				$pdf->writeHTML($date_str, $ln=true, $fill=false, $reseth=true, $cell=true, $align='L');
				
				

					$pdf->SetFont('Times','B',9);
					$x = "143";
					$y = "15";

					$sizex = 45;
					$sizey = 10;

					if($FUNIVCODE == '003')
					{
						$x = "143";
						$y = "2";
					}

					if($FUNIVCODE == '045')
					{
						$sizex = 45;
						$sizey = 15;
						$y = "5";

					}

					if($FUNIVCODE == '020')
					{
						$sizex = 45;
						$sizey = 19;
						$y = "10";
						$x = "135";
					}

					if($FUNIVCODE == '044')
					{
						$sizex = 45;
						$sizey = 10;
						$y = "15";
						$x = "145";
					}

					if($FUNIVCODE == '049')
					{
						$sizex = 70;
						$sizey = 20;
						$y = "7";
						$x = "120";
					}

					if($FUNIVCODE == '050')
					{
						$x = "150";
						$y = "8";

						$sizex = 15;
						$sizey = 20;
					}

					if($FUNIVCODE == '052')
					{
						$x = "140";
						$y = "15";

						$sizex = 42;
						$sizey = 10;

					}

					

					$img_x=($pdf->getX()+$x);;
					$img_y=$pdf->getY()+$y;
					
					$img_path = $aobj_context->main_src."/".$aobj_context->mobj_data["db"]."/img/".$reg_v['fsignpath'];

					if($FUNIVCODE == '037'){
						if(file_exists($img_path)) 
							$pdf->Image($img_path,$img_x-5,$img_y+2,$sizex,$sizey);
					}else if($FUNIVCODE == '055')
					{
						if(file_exists($img_path)) 
							$pdf->Image($img_path,$img_x-75,$img_y-24,$sizex,$sizey);
					}
					else{
						if(file_exists($img_path)) 
							$pdf->Image($img_path,$img_x,$img_y+2,$sizex,$sizey);
					}
					
					if($FUNIVCODE == '003')
					{
						$pdf->Ln(11);
						$pdf->Cell(130,5,'','0',0,'L');
					}
					else if($FUNIVCODE == '044x')
					{	
						$pdf->Ln(15);
						$pdf->Cell(0,5,'I certify that candidate has paid examination fee and eligible for the current examination','0',1,'R');
						$pdf->Ln(10);
						$pdf->Cell(130,5,'Student Signature','0',0,'L');
					}	
					else if($FUNIVCODE == '045')
					{
						$pdf->Ln(20);
						$pdf->Cell(130,5,'Signature of the Student','0',0,'L');
					}
					else if($FUNIVCODE == '049')
					{
						$pdf->Ln(25);
						$pdf->Cell(135,5,'Signature of the Student','0',0,'L');
					}
					else if($FUNIVCODE == '051')
					{
						$pdf->Ln(20);
						$pdf->Cell(130,5,'Student Signature','0',0,'L');
					}
					else
					{
						if($FUNIVCODE == '055')
						{	
							//$pdf->Ln(1);
							$pdf->Cell(70,5,'Student Signature','0',0,'L');
							$pdf->Cell(80,5,'Controller of Examinations ','0',0,'L');

							
							$img_y=$pdf->getY();

							$img_path=$aobj_context->main_src.'/'.$aobj_context->mobj_data["db"]."/img/".$reg_v['fprinsignpath'];
							
							if(file_exists($img_path))
							{	
								//var_dump($img_path);
								$pdf->Image($img_path,155,$img_y-12,18);
							}

							$pdf->Cell(90,5,'Principal','0',1,'L');
							$pdf->SetFont('Times','',7);
							$sjbity = $pdf->getY();
							//var_dump($sjbity);
							$pdf->Cell(0,1,'Note: If the student gets NSA / NSC for any of the above subject/s at any point of time, then such subject shall be null and void even though the student appears for such subject.','0',1,'L');
							$sjbity = $pdf->getY();
							//var_dump($sjbity);
						}
						else
						{	
							$pdf->Ln(25);
							$pdf->Cell(130,5,'Student Signature','0',0,'L');
						}
						
							
						
					}	
					
						if($FUNIVCODE=='041' || $FUNIVCODE == '042' || $FUNIVCODE == '003' || $FUNIVCODE == '027' || $FUNIVCODE == '001' || $FUNIVCODE == '023' || $FUNIVCODE == '026' || $FUNIVCODE == '008' || $FUNIVCODE == '045' || $FUNIVCODE == '047' || $FUNIVCODE == '003D' || $FUNIVCODE == '040' || $FUNIVCODE == '048' || $FUNIVCODE == '044' || $FUNIVCODE == '050')
							$pdf->Cell(50,6,'REGISTRAR (Evaluation)','0',0,'R');
						else if($FUNIVCODE == '044x')
							$pdf->Cell(50,6,'Principal Signature with seal','0',0,'R');
						else if($FUNIVCODE == '055')
						{

						}	
						else
							$pdf->Cell(50,6,'Controller of Examinations','0',0,'R');

						$pdf->SetFont('Times','',9);
						$pdf->Ln(10);
						//$pdf->Cell(110,5,'','0',0,'L');
						if($FUNIVCODE == '029')
							$pdf->Cell(0,5,'I certify that this candidate is eligible to appear for the current examination','0',1,'C');
						else if($FUNIVCODE == '003')
						{
							//$pdf->Ln(3);
							$pdf->SetFont('Times','B',10);
							$pdf->Cell(36,6,'I certify that this candidate is eligible to appear for the current examination','0',1,'L');				
							$pdf->SetFont('Times','',8);						
							$pdf->Cell(30,4,'1. He / She has satisfactory attendance (>=75%).','0',1,'L');						
							$pdf->Cell(30,4,'2. He / She has passed in lower semester examination as per Regulation (Min. 40% subjects).','0',1,'L'); 					
							$pdf->Cell(30,4,'3. His / Her admission has been approved by the University.','0',1,'L');					

							$pdf->Ln(3);
							$pdf->Cell(36,5,'( Digitally Approved by Principal / Chairman / HOD )','0',0,'L');			

							$pdf->Cell(0,5,'Signature of the Student','0',1,'R');
							$date = date("F j, Y, g:i a"); 
							//$pdf->Cell(0,5,"Date: {$date}",'0',1,'R');

						} else if($FUNIVCODE == '055')
						{

						}
						else if($FUNIVCODE == '045' || $FUNIVCODE == '047' || $FUNIVCODE == '003D' )
						{
							date_default_timezone_set("Asia/Calcutta");
							$pdf->SetFont('Times','B',9);
							$date = date("F j, Y, g:i a");
							$pdf->Ln(-5);
							$pdf->Cell(140,5,"Date: {$date}",'0',1,'L');
						}

						if($FUNIVCODE != '051' && $FUNIVCODE != '052' && $FUNIVCODE != '055') 
							if($FUNIVCODE === "054"){
								$pdf->ln(5);
							}	
							if($FUNIVCODE != '051' && $FUNIVCODE != '055'){
								$pdf->Cell(0,5,'I certify that this candidate is eligible to appear for the current examination','0',1,'R');
							}
						if($FUNIVCODE != '003' && $FUNIVCODE != '045' && $FUNIVCODE != '047' && $FUNIVCODE != '003D' && $FUNIVCODE != '055')
						{
							
							if($FUNIVCODE == '034')
							{
								$pdf->Ln(3);
								$y = -3;
								$x = 155;
								$size = 30;

                            }else if($FUNIVCODE == '033')
                            {
                               // $pdf->Ln(3);
                                $y = 0;
								$x = 146;
								$size = 25;
							}
							else if($FUNIVCODE == '044')
                            {
                                $y = 4;
								$x = 155;
								$size = 25;
                            }else if($FUNIVCODE == '035')
                            {
                                $pdf->Ln(7);
								$y = 1;
								$x = 145;
								$size = 40;
                            } else if($FUNIVCODE == '016')
							{
								$y = 1;
								$pdf->Ln(3);
								$x = 145;
								$size = 35;

							}else if($FUNIVCODE == '052')
							{
								$y = 0;
								$pdf->Ln(3);
								$x = 160;
								$size = 25;

							}
							else
                            {
                                $y = 1;
								$x = 145;
								$size = 40;
							}
							
							$img_x=($pdf->getX()+$x);;
							$img_y=$pdf->getY()+$y;
							$img_path=$aobj_context->main_src.'/'.$aobj_context->mobj_data["db"]."/img/".$reg_v['fprinsignpath'];
							
							if(file_exists($img_path))
								$pdf->Image($img_path,$img_x,$img_y,$size);

							$seal=$aobj_context->main_src.'/'.$aobj_context->mobj_data["db"]."/img/DPY_Seal.png";
							
							if(file_exists($seal)) 
								$pdf->Image($seal,90,240,30);
							
							if($FUNIVCODE != '051')
								$pdf->Ln(12);
							date_default_timezone_set("Asia/Calcutta");
							$pdf->SetFont('Times','B',9);
							//$pdf->Cell(36,5,'                                                                                                                                                                  Principal Signature with seal','0',1,'R');
							$date = date("F j, Y, g:i a");
							if($FUNIVCODE == '048' || $FUNIVCODE == '032')
								$pdf->Cell(140,5,"Date: ",'0',0,'L');
							else
								$pdf->Cell(140,5,"Date: {$date}",'0',0,'L');

							if($FUNIVCODE == '029')
								$pdf->Cell(0,5,'Signature of the Head of the Institution with College Seal','0',1,'R');
							else if($FUNIVCODE == '044x')
								$pdf->Cell(0,5,'Registrar (Evaluation)','0',1,'R');
							else if($FUNIVCODE == '034')
								$pdf->Cell(0,5,'Principal Signature','0',1,'R');
							else if($FUNIVCODE == '050')
								$pdf->Cell(0,5,'Dean Signature with seal','0',1,'R');
							else if($FUNIVCODE == '052')
								$pdf->Cell(0,5,'','0',1,'R');	
							else if($FUNIVCODE == '041')
							{
								//$pdf->Cell(0,5,'Chief Superintendent','0',0,'R');
								$pdf->Cell(0,5,'Chief Superintendent                                  Principal Signature with seal','0',1,'R');
							}
							else if($FUNIVCODE == '049')
							{
								//$pdf->Cell(0,5,'Chief Superintendent','0',0,'R');
								if($_SESSION['collcode']== '1003')
									$pdf->Cell(0,5,'Signature of the Director with Seal','0',1,'R');
								else
									$pdf->Cell(0,5,'Signature of the Principal with Seal','0',1,'R');
							}
							else
							{	
								if($FUNIVCODE != '051')
								if($FUNIVCODE == '040'){
									$pdf->Cell(0,5,'Dean of the Faculty','0',1,'R');
								}else{
									$pdf->Cell(0,5,'Principal Signature with Seal','0',1,'R');
								}
								if($FUNIVCODE === '021'){
									$pdf->ln(5);
									$style = array(
										'border' => 0,
										'vpadding' => 'auto',
										'hpadding' => 'auto',
										'fgcolor' => array(0, 0, 0),
										'bgcolor' => false, //array(255,255,255)
										'module_width' => 1, // width of a single module in points
										'module_height' => 1 // height of a single module in points
									);
									// Dear Students, it is mandatory to install JSSHER Students Examniation Mobile App
									$pdf->SetFont('Times','',9);
									$pdf->Cell(0,3,'Dear Student, install JSSHER Student Examination Mobile App to get important notifications. Scan to Install','0',1,'L');  
									// $det = "https://studentportal.universitysolutions.in/";
									$det = "https://bit.ly/3BXe5Gu";
									$pdf->write2DBarcode($det, 'QRCODE,L', 10, $pdf->getY(0), 25, 25, $style); 
									$pdf->ln(27);
									$pdf->SetFont('Times','B',9);
									// $pdf->Cell(10,0,' Scan to Install','0',0,'C');  
									// $pdf->Cell(10,0,'Scan to Install','0',1,'C');  

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

						if($FUNIVCODE == '026')
						{	
							//var_dump($pdf->getY());
							$pdf->Image($aobj_context->main_src.'/'.$aobj_context->mobj_data["db"]."/img/nophoto.jpg",100,225,27,28);		
						}	
				if($FUNIVCODE == '048')						
				{	
					$pdf->setY(271);
					$pdf->Cell(140,5,"Downloaded Date: {$date}",'0',0,'L');
				}

				if($page_cnt!=count($class_obj->std_arr))
				{
					$a++;
					if($FUNIVCODE == '055')
					{
						//$pdf->setY($sjbity); 
						 //if($a == '2')
						 //{
							$pdf->AddPage("P");
							//$pdf->Rect(02,03,100,150);
							$a = 0;
						//}
					//	var_dump($a);
						
					}else
					{
						$pdf->AddPage();
						if($FUNIVCODE != '027')
						{	
							//$pdf->Line($x,$y,$x+184,$y);
							$pdf->Rect(02,03,200,280);
						}
					}	
				}
				
				$page_cnt++;
				//var_dump($page_cnt);
		} 
		

		$pdf->Output("report_adm_ticket.pdf","I");	 
	
}
function NbLines($w,$txt,$pdf)
{
    //Computes the number of lines a MultiCell of width w will take
    $cw=&$pdf->CurrentFont['cw'];
    if($w==0)
        $w=$pdf->w - $pdf->rMargin-$pdf->x;
    $wmax=($w-2*$pdf->cMargin)*1000/$pdf->FontSize;
    $s=str_replace("\r",'',$txt);
    $nb=strlen($s);
    if($nb>0 and $s[$nb-1]=="\n")
        $nb--;
    $sep=-1;
    $i=0;
    $j=0;
    $l=0;
    $nl=1;
    while($i<$nb){
        $c=$s[$i];
        if($c=="\n"){
            $i++;
            $sep=-1;
            $j=$i;
            $l=0;
            $nl++;
            continue;
        }
        if($c==' ')
            $sep=$i;
        $l+=$cw[$c];
        if($l>$wmax)
		{
            if($sep==-1){
                if($i==$j)
                    $i++;
            } else
                $i=$sep+1;
            $sep=-1;
            $j=$i;
            $l=0;
            $nl++;
        } 
		else
            $i++;
    }
    return $nl;
 }
?>