<?php
require('ufpdf/fpdf.php');

require_once('connection/db.php');
require_once('convert_marathi.php');

class PDF extends FPDF
{
function Header()
{
    // Logo
  
    // Arial bold 15
    $this->SetFont('Arial','I',6);
    // Move to the right
    $this->Cell(110);
    // Title
    $this->Cell(80,10,'SUNRISE ENGLISH MEDIUM SCHOOL, AHMEDNAGAR.',0,0,'R');
    // Line brea
    $this->Ln(12);
}

// Page footer
function Footer()
{
    // Position at 1.5 cm from bottom
    $this->SetY(-15);
    // Arial italic 8
    $this->SetFont('Arial','I',8);
    // Page number
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
function ChapterTitle($stdname, $divname)
{
	
		
    // Arial 12
    // $this->SetFont('Arial','',12);
    // Background color
    $this->SetFillColor(200,220,255);
	
    // Title
    $this->Cell(0,6,"<meta charset='UTF-8' />गोषवारा -  $stdname - $divname",0,1,'L',true);
    // Line break
    $this->Ln(4);
}

function Dispaly($stdid,$divid,$dt1,$year)
{
	$this->SetFont('Arial','B',11);
	$this->Cell(15);
	$this->Cell(30,7,"PRN NO.",1,0,'C');
	$this->Cell(100,7,"STUDENT NAME",1,0,'C');
	$this->Cell(30,7,"STATUS",1,0,'C');
	$this->Ln();

	$this->SetFont('Arial','',10);
	//$dt1=date("Y-m-d");
	//echo $dt1;
	//$year="2014-2015";
	$res1 = mysql_query("SELECT * FROM daily_attendance WHERE std_id='$stdid' AND div_id='$divid' AND adm_year='$year' AND att_dt='$dt1'");
	while($row1 = mysql_fetch_assoc($res1))
	{
		$prnno= $row1['prn_no'];
		$status = $row1['status'];
		$res2 = mysql_query("SELECT * FROM admission WHERE prn_no='$prnno'");
		while($row2 = mysql_fetch_assoc($res2))
		{
			
			$stud = $row2['student_name'];
			$this->Cell(15);
			$this->Cell(30,7,$prnno,1,0,'C');
			$this->Cell(100,7,$stud,1,0,'L');
			$this->Cell(30,7,$status,1,0,'C');
			$this->Ln();
			
		}
	}
}



}
// Check ACADEMIC YEAR and DATE 
	$dt = date("Y-m-d",strtotime($_REQUEST['dt']));
	$dt1 = date("Y-m-d",strtotime($_REQUEST['dt1']));
	
	echo $dt." ".$dt1;
	
	
	convert_marathi();
		
	$type = array('मागील शिल्लक संदर्भ', 'चालू आठवड्यातील आवक संदर्भ', 'एकूण संदर्भ ', 'अद्यावत केलेले ','एकूण निर्गत संदर्भ','एकूण शिल्लक संदर्भ','एका आठवड्यातील शिल्लक संदर्भ','दोन आठवड्यातील शिल्लक संदर्भ','तीन आठवड्यातील शिल्लक संदर्भ','तीन आठवड्यावरील शिल्लक संदर्भ');
	
	$pdf = new PDF();

	$pdf->SetFont('Arial','',35);

	$result1 = mysql_query("SELECT * FROM department_master where desk_flag='Y' ");	
	while($row = mysql_fetch_array($result1))
	{
			$dptnm = $row['dept_nm'];
			$dptid = $row['dept_id'];
			echo $dptid."--".$dptnm;
			 
			$pdf->AliasNbPages();
			$pdf->AddPage();
			// Add Title to page
			$pdf->ChapterTitle($dptnm, $dptid);
	}

	// CHECK WHETHER ATTENDANCE DONE OR NOT.
		
		
		$output1 = $pdf->Output('pdf_r/'.$dt.'To'.$dt1.'.pdf','F');
	
?>

