<?php
	//Standard Plan Template
	
	global $post;
	global $pdf_output;
	global $pdf_header;
	global $pdf_footer;

	global $pdf_template_pdfpage;
	global $pdf_template_pdfpage_page;
	global $pdf_template_pdfdoc;

	global $pdf_html_header;
	global $pdf_html_footer;
	
	/*
	global $pdf_margin_left;
	global $pdf_margin_right;
	$pdf_margin_left =20;
	$pdf_margin_right=20;
	*/
 
	global $pdf_margin_top;
	global $pdf_margin_bottom;
	global $pdf_margin_header;
	global $pdf_margin_footer;

 $pdf_margin_top=30;
 $pdf_margin_bottom=30;
 $pdf_margin_header=10;
 $pdf_margin_footer=10;

	//Set a pdf template. if both are set the pdfdoc is used. (You didn't need a pdf template)
	$pdf_template_pdfpage 		= ''; //The filename off the pdf file (you need this for a page template)
	$pdf_template_pdfpage_page 	= 1;  //The page off this page (you need this for a page template)

	$pdf_template_pdfdoc  		= ''; //The filename off the complete pdf document (you need only this for a document template)
	
	$pdf_html_header 			= false; //If this is ture you can write instead of the array a html string on the var $pdf_header
	$pdf_html_footer 			= false; //If this is ture you can write instead of the array a html string on the var $pdf_footer

	//Set the Footer and the Header
	$pdf_header = array (
  		'odd' => 
  			array (
    			'R' => 
   					array (
						'content' => '{PAGENO}',
						'font-size' => 8,
						'font-style' => 'B',
						'font-family' => 'DejaVuSansCondensed',
    				),
    				'line' => 1,
  				),
  		'even' => 
  			array (
    			'R' => 
    				array (
						'content' => '{PAGENO}',
						'font-size' => 8,
						'font-style' => 'B',
						'font-family' => 'DejaVuSansCondensed',
    				),
    				'line' => 1,
  			),
	);
	$pdf_footer = array (
	  	'odd' => 
	 	 	array (
	    		'R' => 
	    			array (
						'content' => '{DATE d.m.Y}',
					    'font-size' => 8,
					    'font-style' => 'BI',
					    'font-family' => 'DejaVuSansCondensed',
					   
	    			),
	    		'C' => 
	    			array (
	      				'content' => '- {PAGENO} / {nb} -',
	      				'font-size' => 8,
	      				'font-style' => '',
	      				'font-family' => '',
	    			),
	    		'L' => 
	    			array (
	      				'content' => get_bloginfo('name'),
	      				'font-size' => 8,
	      				'font-style' => 'BI',
	      				'font-family' => 'DejaVuSansCondensed',
	    			),
	    		'line' => 1,
	  		),
	  	'even' => 
			array (
	    		'R' => 
	    			array (
						'content' => '{DATE d.m.Y}',
					    'font-size' => 8,
					    'font-style' => 'BI',
					    'font-family' => 'DejaVuSansCondensed',
	    			),
	    		'C' => 
	    			array (
	      				'content' => '- {PAGENO} / {nb} -',
	      				'font-size' => 8,
	      				'font-style' => '',
	      				'font-family' => '',
	    			),
	    		'L' => 
	    			array (
	      				'content' => get_bloginfo('name'),
	      				'font-size' => 8,
	      				'font-style' => 'BI',
	      				'font-family' => 'DejaVuSansCondensed',
	    			),
	    		'line' => 1,
	  		),
	);
		

	$pdf_output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
		<html xml:lang="en">
		
		<head>
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
			<title>' . get_bloginfo() . '</title>
		</head>
		<body xml:lang="en">
			<bookmark content="'.htmlspecialchars(get_bloginfo('name'), ENT_QUOTES).'" level="0" /><tocentry content="'.htmlspecialchars(get_bloginfo('name'), ENT_QUOTES).'" level="0" />
			<div id="header"><div id="headerimg">
				<h1><a href="' . get_option('home') . '/">' .  get_bloginfo('name') . '</a></h1>
				<div class="description">' .  get_bloginfo('description') . '</div>
				<div class="description">www.kolejnykrok.absolwencinawalizkach.pl</div>
			</div>
			</div>
			<div id="content" class="widecolumn" style="padding:30pt !important;">';
			
			if(have_posts()) :
				if(is_search()) $pdf_output .=  '<div class="post"><h2 class="pagetitle">Search Results</h2></div>';
			if(is_archive()) {
				global $wp_query;

				if(is_category()) {
					$pdf_output .= '<div class="post"><h2 class="pagetitle">Archive for the "' . single_cat_title('', false) . '" category</h2></div>';
				} elseif(is_year()) {
					$pdf_output .= '<div class="post"><h2 class="pagetitle">Archive for ' . get_the_time('Y') . '</h2></div>';
				} elseif(is_month()) {
					$pdf_output .= '<div class="post"><h2 class="pagetitle">Archive for ' . get_the_time('F, Y') . '</h2></div>';
				} elseif(is_day()) {
					$pdf_output .= '<div class="post"><h2 class="pagetitle">Archive for ' . get_the_time('F jS, Y') . '</h2></div>';
				} elseif(is_search()) {
					$pdf_output .= '<div class="post"><h2 class="pagetitle">Search Results</h2></div>';
				} elseif (is_author()) {
					$pdf_output .= '<div class="post"><h2 class="pagetitle">Author Archive</h2></div>';
				}
			}
			
			while (have_posts()) : the_post();

global $current_user;				
$user_id = get_current_user_id();
			
$pyt1= get_user_meta( $user_id, 'pyt1', true );
$pyt2= get_user_meta( $user_id, 'pyt2', true );
$pyt3= get_user_meta( $user_id, 'pyt3', true );
$pyt4= get_user_meta( $user_id, 'pyt4', true );
$pyt5= get_user_meta( $user_id, 'pyt5', true );
$pyt6= get_user_meta( $user_id, 'pyt6', true );
$pyt7= get_user_meta( $user_id, 'pyt7', true );
$pyt8= get_user_meta( $user_id, 'pyt8', true );
$pyt9= get_user_meta( $user_id, 'pyt9', true );
$pyt10= get_user_meta( $user_id, 'pyt10', true );
$pyt11= get_user_meta( $user_id, 'pyt11', true );
$pyt12= get_user_meta( $user_id, 'pyt12', true );
$pyt13= get_user_meta( $user_id, 'pyt13', true );
$pyt14= get_user_meta( $user_id, 'pyt14', true );
$pyt15= get_user_meta( $user_id, 'pyt15', true );
$pyt16= get_user_meta( $user_id, 'pyt16', true );
$pyt17= get_user_meta( $user_id, 'pyt17', true );
$pyt18= get_user_meta( $user_id, 'pyt18', true );
$pyt19= get_user_meta( $user_id, 'pyt19', true );
$pyt20= get_user_meta( $user_id, 'pyt20', true );
$pyt21= get_user_meta( $user_id, 'pyt21', true );
$pyt22= get_user_meta( $user_id, 'pyt22', true );
$pyt23= get_user_meta( $user_id, 'pyt23', true );
$pyt24= get_user_meta( $user_id, 'pyt24', true );
$pyt25= get_user_meta( $user_id, 'pyt25', true );
$pyt26= get_user_meta( $user_id, 'pyt26', true );
$pyt27= get_user_meta( $user_id, 'pyt27', true );
$pyt28= get_user_meta( $user_id, 'pyt28', true );
$pyt29= get_user_meta( $user_id, 'pyt29', true );
$pyt30= get_user_meta( $user_id, 'pyt30', true );
$pyt31= get_user_meta( $user_id, 'pyt31', true );
$pyt32= get_user_meta( $user_id, 'pyt32', true );
$pyt33= get_user_meta( $user_id, 'pyt33', true );
$pyt34= get_user_meta( $user_id, 'pyt34', true );
$pyt35= get_user_meta( $user_id, 'pyt35', true );
$pyt36= get_user_meta( $user_id, 'pyt36', true );
$pyt37= get_user_meta( $user_id, 'pyt37', true );
$pyt38= get_user_meta( $user_id, 'pyt38', true );
$pyt39= get_user_meta( $user_id, 'pyt39', true );
$pyt40= get_user_meta( $user_id, 'pyt40', true );
$pyt41= get_user_meta( $user_id, 'pyt41', true );
$pyt42= get_user_meta( $user_id, 'pyt42', true );
$pyt43= get_user_meta( $user_id, 'pyt43', true );
$pyt44= get_user_meta( $user_id, 'pyt44', true );
$pyt45= get_user_meta( $user_id, 'pyt45', true );
$pyt46= get_user_meta( $user_id, 'pyt46', true );
$pyt47= get_user_meta( $user_id, 'pyt47', true );
$pyt48= get_user_meta( $user_id, 'pyt48', true );
$pyt49= get_user_meta( $user_id, 'pyt49', true );
$pyt50= get_user_meta( $user_id, 'pyt50', true );
$pyt1ex= get_user_meta( $user_id, 'pyt1ex', true );
$pyt2ex= get_user_meta( $user_id, 'pyt2ex', true );
$pyt3ex= get_user_meta( $user_id, 'pyt3ex', true );
$pyt4ex= get_user_meta( $user_id, 'pyt4ex', true );
$pyt5ex= get_user_meta( $user_id, 'pyt5ex', true );
$pyt6ex= get_user_meta( $user_id, 'pyt6ex', true );
$pyt7ex= get_user_meta( $user_id, 'pyt7ex', true );
$pyt8ex= get_user_meta( $user_id, 'pyt8ex', true );
$pyt9ex= get_user_meta( $user_id, 'pyt9ex', true );
$pyt10ex= get_user_meta( $user_id, 'pyt10ex', true );

$osob = $pyt1 + $pyt2 + $pyt3 + $pyt4 + $pyt5 + $pyt6 + $pyt7 + $pyt8 + $pyt9 + $pyt10 + $pyt11 + $pyt12 + $pyt13 + $pyt14 + $pyt15 + $pyt3ex + $pyt7ex + $pyt13ex;

$spol = $pyt16 + $pyt17 + $pyt18 + $pyt19 + $pyt20 + $pyt21 + $pyt22 + $pyt23 + $pyt24 + $pyt25 + $pyt26 + $pyt27 + $pyt28 + $pyt29 + $pyt30 + $pyt18ex + $pyt27ex + $pyt30ex;

$mena = $pyt31 + $pyt32 + $pyt33 + $pyt34 + $pyt35 + $pyt36 + $pyt37 + $pyt38 + $pyt39 + $pyt40 + $pyt32ex + $pyt37ex;

$tech = $pyt41 + $pyt42 + $pyt43 + $pyt44 + $pyt45 + $pyt46 + $pyt47 + $pyt48 + $pyt49 + $pyt50 + $pyt42ex + $pyt47ex;

$opis2 = get_theme_mod('opis2'); 
$opis3 = get_theme_mod('opis3'); 
$opis4 = get_theme_mod('opis4'); 
$opis5 = get_theme_mod('opis5'); 
$opis7 = get_theme_mod('opis7'); 
$opis8 = get_theme_mod('opis8'); 
$opis9 = get_theme_mod('opis9'); 
$opis10 = get_theme_mod('opis10'); 
$opis12 = get_theme_mod('opis12'); 
$opis13 = get_theme_mod('opis13'); 
$opis14 = get_theme_mod('opis14'); 
$opis15 = get_theme_mod('opis15'); 
$opis17 = get_theme_mod('opis17'); 
$opis18 = get_theme_mod('opis18'); 
$opis19 = get_theme_mod('opis19'); 
$opis20 = get_theme_mod('opis20'); 
			
				$cat_links = "";
				foreach((get_the_category()) as $cat) {
					$cat_links .= '<a href="' . get_category_link($cat->term_id) . '" title="' . $cat->category_description . '">' . $cat->cat_name . '</a>, ';
				}
				$cat_links = substr($cat_links, 0, -2);

				// Create comments link
				if($post->comment_count == 0) {
					$comment_link = 'No Comments &#187;';
				} elseif($post->comment_count == 1) {
					$comment_link = 'One Comment &#187;';
				} else {
					$comment_link = $post->comment_count . ' Comments &#187;';
				}

				$pdf_output .= '<bookmark content="'.the_title('','', false).'" level="1" /><tocentry content="'.the_title('','', false).'" level="1" />';
   
				$pdf_output .= '<div class="post">
				<h2 style="text-align:center">' . $current_user->user_firstname . ', to jest raport z badania Twoich kompetencji</h2>';

$pdf_output .= '<p>&nbsp;</p>';
$pdf_output .= '<p>&nbsp;</p>';

$pdf_output .= '<h2 id="druk"><strong>Kompetencje osobiste</strong></h2>';
$pdf_output .= $opis2;
$pdf_output .= '<p>';
if ($osob <= 22) { $pdf_output .= $opis3; } elseif ($osob <= 38) { $pdf_output .= $opis4; } else { $pdf_output .= $opis5; }
$pdf_output .= '</p>';

$pdf_output .= '<p>&nbsp;</p>';

$pdf_output .= '<h2 id="druk"><strong>Kompetencje społeczne</strong></h2>';;
$pdf_output .= $opis7;
$pdf_output .= '<p>';
if ($spol <= 22) { $pdf_output .= $opis8; } elseif ($spol <= 38) { $pdf_output .= $opis9; } else { $pdf_output .= $opis10; }
$pdf_output .= '</p>';

$pdf_output .= '<p>&nbsp;</p>';

$pdf_output .= '<h2 id="druk"><strong>Kompetencje menedżerskie</strong></h2>';
$pdf_output .= $opis12;
$pdf_output .= '<p>';
if ($mena <= 16) { $pdf_output .= $opis13; } elseif ($mena <= 28) { $pdf_output .= $opis14; } else { $pdf_output .= $opis15; }
$pdf_output .= '</p>';

$pdf_output .= '<p>&nbsp;</p>';

$pdf_output .= '<h2 id="druk"><strong>Kompetencje specjalistyczno-techniczne</strong></h2>';
$pdf_output .= $opis17;
$pdf_output .= '<p>';
if ($tech <= 16) { $pdf_output .= $opis18; } elseif ($tech <= 28) { $pdf_output .= $opis19; } else { $pdf_output .= $opis20; }
$pdf_output .= '</p>';


				// no authors and dates on static pages
				if(!is_page()) $pdf_output .=  '<p class="small subtitle">' . get_the_author_meta('display_name') . ' &middot; ' . date('l, F jS, Y', mpdf_mysql2unix($post->post_date)) . '</p>';

				$pdf_output .= '<div class="entry">' .	wpautop($post->post_content, true) . '</div>';
				
				if(!is_page() && !is_single()) $pdf_output .= '<p class="postmetadata">Posted in ' . $cat_links . ' | ' . '<a href="' . get_permalink() . '#comment">' . $comment_link . '</a></p>';

				// the following is the extended metadata for a single page
				if(is_single()) {
					$pdf_output .= '<p class="postmetadata alt">
						<span>
							This entry was posted on ' . date('l, F jS, Y', mpdf_mysql2unix($post->post_date)) . ' at ' . date('g:i a', mpdf_mysql2unix($post->post_date)) . ' and is filed under ' . $cat_links . '
							You can follow any responses to this entry through the <a href="' . get_bloginfo('comments_rss2_url') . '">Comments (RSS)</a> feed.';
	
							if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
								// Both Comments and Pings are open
								$pdf_output .= ' You can leave a response, or <a href="' . get_trackback_url() . '" rel="trackback">trackback</a> from your own site.';
							} elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
								// Only Pings are Open
								$pdf_output .= ' Responses are currently closed, but you can <a href="' . get_trackback_url() . '" rel="trackback">trackback</a> from your own site.';
							} elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
								// Comments are open, Pings are not
								$pdf_output .= ' You can skip to the end and leave a response. Pinging is currently not allowed.';
							} elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
								// Neither Comments, nor Pings are open
								$pdf_output .= ' Both comments and pings are currently closed.';
							}
	
						$pdf_output .= '</span>
					</p>';
				}
				$pdf_output .= '</div> <!-- post -->';
			endwhile;
			
		else :
			$pdf_output .= '<h2 class="center">Not Found</h2>
				<p class="center">Sorry, but you are looking for something that isn\'t here.</p>';
		endif;

		$pdf_output .= '</div> <!--content-->';

		
	$pdf_output .= '
		</body>
		</html>';
?>
