<?php 
    include_once('../../config.php');       
    require(ABS_PATH.'/admin/Bidding/fpdf/fpdf.php'); 
		
	$Rec = mysql_query("select name from   Bazzar where id=$_REQUEST[id] ");   
    $Rec_detail  = mysql_fetch_object($Rec);	
    $datepicker = date("d-M-Y");
	$heading=$Rec_detail->name." (".$datepicker.")";	
	
    class PDF extends FPDF
    {
        // Page header
        function Header()
        {
            global $heading;
        	
            $this->SetFont('Arial','B',13);
            // Move to the right
            $this->Cell(50);
            // Title
            $this->Cell(80,10,$heading,0,0,'C');
            // Line break
            $this->Ln(15);
        }
    }
	$pdf = new PDF();
	

	$pdf->AddPage();
	/*$pdf->SetFont('Arial','',10);
	$pdf->Cell(35,6,'Date : '.$datepicker,0,0);
	$pdf->Ln();*/
	 
	// Open Single start
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(255,21,0);
	$pdf->Cell(95,1,'OPEN GAME : ',0); 
	$pdf->SetTextColor(18,18,18);
	$pdf->Cell(95,6,'Single Ank : ',0);
	$pdf->Ln();
    $pdf->SetFont('Arial','',10);
	$result1 = mysql_query("select * from  biddings where bazarId=$_REQUEST[id] and gametype=1 and optionType=1 and adminDate='$datepicker'");
	$sr=1;
	while($row1 = mysql_fetch_object($result1))
	{
	   $res1=$row1->BidNo." = Rs ".$row1->Points;
	   $openSingle_total+=$row1->Points;
	   $pdf->Cell(30,4,$res1,1,0,'C');
	   $cnt = $sr++;
       if($cnt%6 == 0) 
       {
           $pdf->Ln();
       }
	}
	$pdf->Ln();
	// Open Single end
	
	// Close Single start
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(95,6,'SP : ',0);
	$pdf->Ln();
    $pdf->SetFont('Arial','',10);
	$result2 = mysql_query("select * from  biddings where bazarId=$_REQUEST[id] and gametype=1 and optionType=3 and adminDate='$datepicker'");
	$sr2=1;
	while($row2 = mysql_fetch_object($result2))
	{
	   $res2=$row2->BidNo." = Rs".$row2->Points;
	   $openSp_total+=$row2->Points;
	   $pdf->Cell(30,4,$res2,1,0,'C');
	   $cnt = $sr2++;
       if($cnt%6 == 0) 
       {
           $pdf->Ln();
       }
	}
	$pdf->Ln();	
	$pdf->Ln();	
	// Close Single end
	
	
	// Open Patti start
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(95,6,'DP : ',0);
	$pdf->Ln();
    $pdf->SetFont('Arial','',10);
	$result3 = mysql_query("select * from  biddings where bazarId=$_REQUEST[id] and gametype=1 and optionType=4 and adminDate='$datepicker'");
	$sr3=1;
	while($row3 = mysql_fetch_object($result3))
	{
	   $res3=$row3->BidNo." = Rs ".$row3->Points;
	   $openDp_total+=$row3->Points;
	   $pdf->Cell(30,4,$res3,1,0,'C');
	   $cnt = $sr3++;
       if($cnt%6 == 0) 
       {
           $pdf->Ln();
       }
	}
	$pdf->Ln();	
	$pdf->Ln();	
	// Open Patti end
	
	// Close Patti start
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(95,6,'TP : ',0);
	$pdf->Ln();
    $pdf->SetFont('Arial','',10);
	$result4 = mysql_query("select * from  biddings where bazarId=$_REQUEST[id] and gametype=1 and optionType=5 and adminDate='$datepicker'");
	$sr4=1;
	while($row4 = mysql_fetch_object($result4))
	{
	   $res4=$row4->BidNo."=".$row4->Points;
	   $openTp_total+=$row4->Points;
	   $pdf->Cell(30,4,$res4,1,0,'C');
	   $cnt = $sr4++;
       if($cnt%6 == 0) 
       {
           $pdf->Ln();
       }
	}
	$pdf->Ln();	
	$pdf->Ln();	
	// Close Patti end
	
	
	
	//*****************************************
	
	
	$pdf->SetFont('Arial','B',9);
	$pdf->SetTextColor(255,21,0);
	$pdf->Cell(95,1,'CLOSE GAME : ',0);
	$pdf->SetTextColor(18,18,18);
	$pdf->Cell(95,6,'Single Ank : ',0);
	$pdf->Ln();
    $pdf->SetFont('Arial','',10);
	$result1 = mysql_query("select * from  biddings where bazarId=$_REQUEST[id] and gametype=2 and optionType=1 and adminDate='$datepicker'");
	$sr=1;
	while($row1 = mysql_fetch_object($result1))
	{
	   $res1=$row1->BidNo." = Rs ".$row1->Points;
	   $closeSingle_total+=$row1->Points;
	   $pdf->Cell(30,4,$res1,1,0,'C');
	   $cnt = $sr++;
       if($cnt%6 == 0) 
       {
           $pdf->Ln();
       }
	}
	$pdf->Ln();
	// Open Single end
	
	// Close Single start
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(95,6,'SP : ',0);
	$pdf->Ln();
    $pdf->SetFont('Arial','',10);
	$result2 = mysql_query("select * from  biddings where bazarId=$_REQUEST[id] and gametype=2 and optionType=3 and adminDate='$datepicker'");
	$sr2=1;
	while($row2 = mysql_fetch_object($result2))
	{
	   $res2=$row2->BidNo." = Rs".$row2->Points;
	   $closeSp_total+=$row2->Points;
	   $pdf->Cell(30,4,$res2,1,0,'C');
	   $cnt = $sr2++;
       if($cnt%6 == 0) 
       {
           $pdf->Ln();
       }
	}
	$pdf->Ln();	
	$pdf->Ln();	
	// Close Single end
	
	
	// Open Patti start
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(95,6,'DP : ',0);
	$pdf->Ln();
    $pdf->SetFont('Arial','',10);
	$result3 = mysql_query("select * from  biddings where bazarId=$_REQUEST[id] and gametype=2 and optionType=4 and adminDate='$datepicker'");
	$sr3=1;
	while($row3 = mysql_fetch_object($result3))
	{
	   $res3=$row3->BidNo." = Rs ".$row3->Points;
	   $closeDp_total+=$row3->Points;
	   $pdf->Cell(30,4,$res3,1,0,'C');
	   $cnt = $sr3++;
       if($cnt%6 == 0) 
       {
           $pdf->Ln();
       }
	}
	$pdf->Ln();	
	$pdf->Ln();	
	// Open Patti end
	
	// Close Patti start
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(95,6,'TP : ',0);
	$pdf->Ln();
    $pdf->SetFont('Arial','',10);
	$result4 = mysql_query("select * from  biddings where bazarId=$_REQUEST[id] and gametype=2 and optionType=5 and adminDate='$datepicker'");
	$sr4=1;
	while($row4 = mysql_fetch_object($result4))
	{
	   $res4=$row4->BidNo."=".$row4->Points;
	   $closeTp_total+=$row4->Points;
	   $pdf->Cell(30,4,$res4,1,0,'C');
	   $cnt = $sr4++;
       if($cnt%6 == 0) 
       {
           $pdf->Ln();
       }
	}
	$pdf->Ln();	
	
	
	
	// Close Patti start
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(95,6,'JODI : ',0);
	$pdf->Ln();
    $pdf->SetFont('Arial','',10);
	$result4 = mysql_query("select * from  biddings where bazarId=$_REQUEST[id] and gametype=1 and optionType=2 and adminDate='$datepicker'");
	$sr4=1;
	while($row4 = mysql_fetch_object($result4))
	{
	   $res4=$row4->BidNo." = Rs ".$row4->Points;
	   $jodi+=$row4->Points;
	   $pdf->Cell(30,4,$res4,1,0,'C');
	   $cnt = $sr4++;
       if($cnt%6 == 0) 
       {
           $pdf->Ln();
       }
	}
	$pdf->Ln();	
	 
	 
	// Close Patti end
	
 
	/*$opensingle_total=6;
	$closesingle_total=10;
	$openpatti_total=18;
	$closepatti_total=90;
	$jodi_total=90;*/
	$final_total = $jodi+$openSingle_total + $openSp_total + $openDp_total + $openTp_total + $closeSingle_total +$closeSp_total + $closeDp_total + $closeTp_total;
	
	$pdf->SetFont('Arial','B',9); 
	$pdf->Cell(30,6,'OPEN GAME TOTAL : ',0);
    $pdf->SetFont('Arial','',9); 
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9); 
	$pdf->Cell(30,6,'Single Ank : ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(20,6,$openSingle_total,0);
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(30,6,'SP : ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(30,6,$openSp_total,0);
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(28,6,'DP: ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(28,6,$openDp_total,0);
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(28,6,'TP : ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(28,6,$openTp_total,0);
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(28,6,'JODI : ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(28,6,$jodi,0);
    $pdf->Ln();
    
    
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(28,6,'******************************************',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(28,6,$closeTp_total,0);
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9); 
	$pdf->Cell(30,6,'CLOSE GAME TOTAL : ',0);
    $pdf->SetFont('Arial','',9); 
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9); 
	$pdf->Cell(30,6,'Single Ank : ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(20,6,$closeSingle_total,0);
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(30,6,'SP : ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(30,6,$closeSp_total,0);
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(28,6,'DP: ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(28,6,$closeDp_total,0);
    $pdf->Ln();
    
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(28,6,'TP : ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(28,6,$closeTp_total,0);
    $pdf->Ln();
    
     
     
     $pdf->SetFont('Arial','B',9);
	$pdf->Cell(28,6,'******************************************',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(28,6,$closeTp_total,0);
    $pdf->Ln();
    
    
    $pdf->Ln();
    $pdf->SetFont('Arial','B',9);
	$pdf->Cell(15,6,'Total : ',0);
    $pdf->SetFont('Arial','',9);
    $pdf->Cell(15,6,"Rs ".$final_total,0);
    $pdf->Ln();
    
    
	/*$pdf->Ln(); 
	$pdf->SetFont('Arial','B',10);
	$pdf->Cell(65,6,'Important :',0);
	$pdf->Ln();
	
	$pdf->SetFont('Arial','',8);
	$pdf->Write(1,'Please carry your Government ID proof for all passengers to show during security check and check-in. Name on Government ID proof should be');
	$pdf->Ln(3);
	$pdf->Write(1,'same as on your ticket. We recommended you to reach airport 2 hrs before departure time. Airline check-in counters typically close 1 hr prior to');
	$pdf->Ln(3);
	$pdf->Write(1,'departure time.');*/
	$pdf->Ln();
	
	$pdf->Output(); 
?>  
