<?php
$w = "35"; // first column width
$w2 = "15"; // second column width
if($focus->dir==1){
	$title='wypłaty'; // dla
	$parent_title='DLA:';
} else {
	$title='wpłaty'; // komu
	$parent_title='KOMU:';
}

$content = '
<table style="width: 100%; font-size: 8pt;">
	<tr>		
		<td style="width: ' . $w . '%; vertical-align: top;">
			<b><h1>Dowód '.$title.'</h1></b>
		</td>
		<td style="width: ' . $w . '%; vertical-align: top;"><b><h1>' . $focus->document_no . '</h1></b>z dnia: <b>' . date("d.m.Y", strtotime($focus->date_entered)) . '</b><br><br><br><br><br>
		</td>
		<td style="width: ' . $w2 . '%">
		</td>
		<td style="text-align: right">
			
		</td>
	</tr>
	<tr>		

			<td style="width: ' . $w . '%">
			<b>WYSTAWACA:</b>
		</td>
				<td style="width: ' . $w . '%">
			<b>'.$parent_title.'</b>
		</td>
		<td style="width: ' . $w2 . '%">
		</td>
		<td style="text-align: right">
			
		</td>
	</tr>
	<tr>		

			<td style="width: ' . $w . '%; vertical-align: top;">
			'.$comp['name'].'<br>'.$addr[0].'<br>'.$addr[1].'<br>'.$comp['footer_nip'].'
		</td>
				<td style="width: ' . $w . '%; vertical-align: top;">
			'.$focus->parent_name.'<br>'.$focus->parent_address_street.'<br>'.$focus->parent_address_postalcode.' '.$focus->parent_address_city.'<br>'.$acc->to_vatid.'
		</td>
		<td style="width: ' . $w2 . '%; vertical-align: top;">
		</td>
		<td style="text-align: right; vertical-align: top;">
		</td>
	</tr>
</table><br>
';
if ($focus->name && $focus->name != '') {
	$content .= '
		<table style="width: 100%; text-align: center">
			<tr><td>
				<b>' . $focus->name . '</b>
			</td></tr>
		</table>
';
}

$content .= '<br>';

// start items table
$columns = array ();

$columns ['price'] = array (
		'field' => array (
				'price' 
		),
		'label' => 'Tytułem',
		'height'=> '30',
		'align' => 'center' 
);

$columns ['total'] = array (
		'field' => array (
				'total' 
		),
		'label' => 'Kwota',
		'align' => 'center' 
);

// set widths
$totals = array ();

$columns ['price'] ['width'] = '80';
$columns ['total'] ['width'] = '20';

// rysujemy :)
$content .= '
	<table style="width: 100%; font-size: 7pt; border: 0.1 solid black; border-collapse: collapse"><thead>
		<tr>
';

foreach ( $columns as $col ) {
	$content .= '
		<th style="border: 0.1 solid black; width: ' . $col ['width'] . '%;height: ' . $col ['height'] . 'px;text-align: ' . $col ['align'] . ';background-color: #E6E6FA;">' . $col ['label'] . '</th>		
	';
}
$content .= '
	</tr></thead><tbody>
';

	$content .= '<tr>';
		$content .= '<td style="border: 0.1 solid black; text-align: left;height:20px;">'.$focus->ecmkpkw_name.'';

		$content .= '</td>';
		$content .= '<td style="border: 0.1 solid black; text-align: right;">'.number_format($focus->amount,2,',', ' ').' '.$cur->name;

		$content .= '</td>';
	$content .= '</tr>';
// waluty
switch ($focus->currency_id) {
    case 'PLN':
		echo 'ok';
        break;
    case '6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf':
		  $kwota->setCurrency(array('euro', 'euro', 'euro'),array('eurocent', 'eurocenty', 'eurocentów'));
        break;
    case '3c8d317e-513b-9a9b-d0e6-511e2abee625':
          $kwota->setCurrency(array('funt', 'funty', 'funtów'),array('cent', 'centy', 'centów'));
        break;
	 case '98b2b752-b0be-37c2-d2eb-511e29f81cab':
        $kwota->setCurrency(array('dolar', 'dolary', 'dolarów'),array('cent', 'centy', 'centów'));
        break;
}
$content .= '
	</tbody></table><p style="text-align:right;font-size: 8pt;">Słownie: '.$kwota->convertPrice($focus->amount).'</p><br><br><br>
	<table style="width: 100%; font-size: 8pt;"><tr><td style="width: 50%;"><b>Wystawił:</b><br>' . $user->full_name . '</td><td style="width: 50%;text-align: right;">.................................................<br>Kwotę powyższą otrzymałem</td></tr></table>
';
