<?php
include "../config.php";
//============================================================+
// File name   : example_009.php
// Begin       : 2008-03-04
// Last Update : 2010-12-04
//
// Description : Example 009 for TCPDF class
//               Test Image
//
// Author: Nicola Asuni
//
// (c) Copyright:
//               Nicola Asuni
//               Tecnick.com s.r.l.
//               Via Della Pace, 11
//               09044 Quartucciu (CA)
//               ITALY
//               www.tecnick.com
//               info@tecnick.com
//============================================================+

/**
 * Creates an example PDF TEST document using TCPDF
 * @package com.tecnick.tcpdf
 * @abstract TCPDF - Example: Test Image
 * @author Nicola Asuni
 * @since 2008-03-04
 */


require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');
class MYPDF extends TCPDF {
    //Page header
    public function Header() {

        // Set font
        $this->SetFont('helvetica', 'B', 20);
        // Title
        $this->Cell(0, 15, '', 0, false, 'C', 0, '', 0, false, 'M', 'M');
        
         // set bacground image
        //$img_file = K_PATH_IMAGES.'duplicate.png';
        //$this->Image($img_file, 0, 0, 240, 150, '', '', '', false, 300, '', false, false, 0);
    }
}

// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);


// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('unitedsikhs');
$pdf->SetTitle('Online Donation Receipt');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.'', PDF_HEADER_STRING);

// set header and footer fonts
//$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
//$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks


        
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

// --------------------------------------------------------

// set font
$pdf->SetFont('dejavusans', '', 10);

// add a page
$pdf->AddPage();
// writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='')
// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true)

$getTicket = mysql_query("SELECT * from user_information WHERE event_selected='".base64_decode($_GET['eid'])."' and is_donated=1");
if(mysql_num_rows($getTicket)==0){
    $html .='No ticket generated yet';
}
$i=0;
while($tickets = mysql_fetch_array($getTicket)){
    if($tickets['event_selected']== 26){
        $address = "Date: Saturday July 26th 2014<br/>
                    Time: 7:00 pm onwards<br/>
                    Venue : Sheraton Four Points<br/>
                    1201 K St NW, Washington,<br/>
                    DC 20005";
                
    }else if($tickets['event_selected']==27){
        $address = "Date: Sunday July 27th 2014<br/>
		            Time: 6:30pm-9:30pm<br/>
		            Venue: Five Star Banquet<br/>
		            13-05,43rd Ave, <br/>
		            Long Island City, New York 11102";
		            
    } else if($tickets['event_selected'] == 2){
    
    	$address = "Date: Saturday August 2nd 2014<br/>
		            Time: 6:00 pm onwards<br/>
		            Venue:	Chabot College<br/>
							Performing Arts Center<br/>
							25555 Hesperian Blvd,Hayward, CA 94545";
    }
//echo "<pre>";
//print_r($tickets);exit;
    $unique_number  = $tickets['unique_number'];
     
    $get_ticket_number = mysql_query("select * from ticket_master
                                        where event_number = '".$tickets['event_selected']."'
                                        AND tkt_type = '".$tickets['category_selected']."' ");
                                        
    $alltickets     = mysql_fetch_array($get_ticket_number);
    
    $ticket_id      = $tickets['ticket_number'];
  
  
 
$html .='<table width="100%" style=" background-color:#fffcdd; border:1px black solid; padding:3px">
				<tr>
						<td width="40%" style="vertical-align:top">
							<table  style="border:none;width:100% padding:10px">
								<tr>
								<td rowspan=""><img style = "width:550px;height:46px;"src="test.png"></td>		
								</tr>
								<tr>
									<td>
										<img style = "width:120px;height:80px;"src="myimage.png">
										<p style="margin-top:20px;font-size:20px;">'.$address.'</p>
										<p style="margin-top:10px;float:left;font-size:20px;"> <b>Ticket # '.$ticket_id.'</b> / '.$unique_number.'
										</p> 
									</td>
								</tr>
								<tr>
									<td><img style = "width:550px;height:46px;"src="test.png"></td>		
								</tr>
							</table>
						</td>
						
				</tr>
			</table>
	<table>
	
	<tr><td><br><hr></td></tr>
	</table>';	

$i++;
} 

$pdf->writeHTML($html, true, false, true, false, '');

$pdf->lastPage();

//Close and output PDF document
ob_start(); 
$pdf->Output('example_009.pdf', 'I');

 ob_end_flush(); 
// -------------------------------------------------------------------

//Close and output PDF document


//============================================================+
// END OF FILE
//============================================================+
