<?php
$w = "35"; // first column width
$w3 = "35";
$w2 = "15"; // second column width

$content = '
<table style="width: 100%; font-size: 8pt;">
	<tr>		
		<td style="width: ' . $w . '%">
			<b>ODBIORCA</b>
		</td>
		<td style="width: ' . $w3 . '%">';
		if($focus->parent_shipping_address_name!=''){ 
			$content.= '<b>'.$labels['LBL_PDF_CONTENT_DELIVERY'].'</b>';
		}
		
		$content.= '</td>
		<td style="width: ' . $w2 . '%"></td>
		<td style="text-align: right"></td>
	</tr>
	<tr>		
		<td style="width: ' . $w . '%">
			' . $focus->parent_name . '
		</td>
		<td style="width: ' . $w3 . '%">
			'.$a->parent_shipping_address_name.'
		</td>
		<td style="width: ' . $w2 . '%"></td>
		<td style="text-align: right"></td>
	</tr>
	<tr>		
		<td style="width: ' . $w . '%">
			' . $a->register_address_street . '
		</td>
		<td style="width: ' . $w3 . '%">
			' . $a->parent_shipping_address_street . '
		</td>
		<td style="width: ' . $w2 . '%">';

		$content.= '</td>
		<td style="text-align: right">
		</td>
	</tr>
	<tr>		
		<td style="width: ' . $w . '%">
			'. $a->register_address_postalcode . ' ' . $a->register_address_city;
		if (!is_null($focus->parent_address_country) & $focus->parent_address_country!='')
			$content.=', '.$a->register_address_country;
	$content.='
		</td>
		<td style="width: ' . $w3 . '%">
			'. $focus->parent_shipping_address_postalcode . ' ' . $focus->parent_shipping_address_city;
	if (!is_null($focus->parent_shipping_address_country) & $focus->parent_shipping_address_country!='')
		$content.=', '.$focus->parent_shipping_address_country;
	$content.='
		</td>
		<td style="width: ' . $w2 . '%">
		
		</td>
		<td style="text-align: right">
		
		</td>
	</tr>';
		$content.='
		<tr>
			<td valign="top" style="width: ' . $w . '%">NIP: '.$a->to_vatid;
		
		$content.='		
			</td>';
		$content.='
			<td valign="top" style="width: ' . $w3 . '%">';
		if (!is_null($focus->parent_shipping_nip) && $focus->parent_shipping_nip) {
			$content.=$labels['LBL_PDF_CONTENT_NIP'].' '.$focus->parent_shipping_nip;
			$nip = true;
		}
		if (!is_null($focus->parent_shipping_iln) && $focus->parent_shipping_iln) {
			if ($nip) $content.'<br>'; $nip = false;
			$content.=$labels['LBL_PDF_CONTENT_ILN'].' '.$focus->parent_shipping_iln;
		}
		$content.='
			</td>
		<td valign="top" style="width: ' . $w2 . '%"></td>
		<td colspan="0" valign="top" style="text-align: right">
	
		</td>
		</tr>';
$content.='
</table>
';
if($EcmSysInfo->getDatabaseName()=='preDb_45ab7160e7af49269e17044eaed9e0ba'){
	$content='';
}

$content .= '<br><table width="100%" style="font-size: 7pt;text-align:right;vertical-align:top;">
		<tr><td width="11%" >Data dokumentu:<br>'.$labels['LBL_PDF_CONTENT_SELL_DATE'].'</td>
				<td style="text-align: left;" width="20%"><b>' . date('d.m.Y') . '</b><br><b>' . $focus->sell_date . '</b></td>
		<td rowspan="2" style="text-align: left;vertical-align:top;">';

if($focus->order_no!=''){
	$content.=$labels['LBL_PDF_CONTENT_PARENT_DOCUMENT_NO'].':<br>';
}
	
		$content.='</td>
		<td rowspan="2" style="vertical-align:top;">';

		if($focus->order_no!=''){
			$content.='<b>' . $focus->order_no.'</b><br>';
		}

		$content.='</td></tr></table><br>';
		if($EcmSysInfo->getDatabaseName()=='preDb_45ab7160e7af49269e17044eaed9e0ba'){
			$content='<div style="width:100%;text-align: center;"><b>Wezwanie do zapłaty</b></div><br><br><div style="width:100%;text-align: left;font-size: 9pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Wzywamy do uregulowania w terminie 7 dni od daty otrzymania niniejszego wezwania do zapłaty niżej wymienionych należności w łącznej kwocie
					<b>'.format_number($focus->interest).'</b> zł<br>Należność należy przekazać na konto <b>RAIFFEISEN BANK POLSKA S.A.</b><br>nr konta 42 1750 0009 0000 0000 2627 2699<br><br></div>';
			
		}
// start items table
$columns = array ();

$columns ['position'] = array (
		'field' => array (
				'position' 
		),
		'label' => 'Lp.',
		'align' => 'center' 
);

$columns ['name'] = array (
		'field' => array (
				'name',
			
		),
		'label' => 'Nazwa',
		'align' => 'left' 
);
$columns ['date_doc'] = array (
		'field' => array (
				'date_doc',
					
		),
		'label' => 'Data dokumentu',
		'align' => 'right'
);
$columns ['total2'] = array (
        'field' => array (
                'paid'
        ),
        'label' => 'Kwota',
        'align' => 'right'
);
$columns ['qty'] = array (
		'field' => array (
				'payment_date',
			
		),
		'label' => 'Termin płatności',
		'align' => 'right' 
);


$columns ['total_vat'] = array (
        'field' => array (
                'days'
        ),
        'label' => 'Dni po<br>Terminie',
        'align' => 'right'
);
$columns ['total'] = array (
        'field' => array (
                'total'
        ),
        'label' => 'Odsetki<br>na dziś',
        'align' => 'right'
);



// set widths
$totals = array ();

$columns ['position'] ['width'] = '5';
$columns ['name'] ['width'] = '31';
$columns ['date_doc'] ['width'] = '10';

$columns ['total2'] ['width'] = '10';
$columns ['qty'] ['width'] = '10';

$columns ['total_vat'] ['width'] = '10';
$columns ['total'] ['width'] = '10';


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

foreach ( $columns as $col ) {
	$content .= '
		<th style="border: 0.5 solid black; width: ' . $col ['width'] . '%;background-color: #E9E9E9;">' . $col ['label'] . '</th>		
	';
}
$content .= '
	</tr></thead><tbody>
';
$counter=1;

    foreach ( $positions as $pos ) {
    	$content .= '<tr>';
    	foreach ( $columns as $col ) {
    
    		$content .= '<td style="border: 0.5 solid black; text-align: ' . $col ['align'] . ';">';
    		foreach ( $col ['field'] as $f ) {
    
    				if (! $pos [$f] || $pos [$f] == '')
    					$pos [$f] = '-';
    				$content .= $pos [$f] . '<br>';
    				
    		}
    		$content .= '</td>';
    	}
    	$content .= '</tr>';
    }

$content .= '
	</tbody>
        <tr style="border: 0 solid black;"><td style="border: 0 solid black;"></td>
		tr style="border: 0 solid black;"><td style="border: 0 solid black;"></td>
        <td style="border: 0 solid black;text-align:right"><b>Razem</b></td>
        <td style="border: 0 solid black;text-align:right;"><b>'.format_number($focus->interest).'</b></td>
        <td style="border: 0 solid black;"></td>
        <td style="border: 0 solid black;"></td>
        <td style="border: 0 solid black;text-align:right;"><b>'.format_number($focus->total).'</b></td>';

$content .= '</tr>
        
        </table>
';
if($EcmSysInfo->getDatabaseName()=='preDb_45ab7160e7af49269e17044eaed9e0ba'){
	$content.='<div style="width:100%;text-align: left;font-size: 9pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;W przypadku nie uregulowania należności w podanym wyżej terminie sprawa zostanie automatycznie skierowana na drogę sądową i wpisana do KRD<br><br></div>';
	$content.='<br><BR>
		<table style="width:100%">
		<tr>
			<td style="width:50%">
			
			</td>
			<td style="width:50%;text-align:center;">
				.............................................<br>Podpis
			</td>
		</tr>
		</table>';
	
}
// summary table
// get currency symbol
$c = new Currency ();
$c->retrieve ( $focus->currency_id );
$symbol = $c->symbol;
unset ( $c );
$content .= '
	<br>

';


	
//echo $content; die();








