<?php 
function showDiscount($record) {
	$db = $GLOBALS['db'];
	$res = $db->fetchByAssoc($db->query("SELECT count(distinct discount) AS c FROM ecmreturnitems WHERE
								  ecmreturn_id='$record'
								  AND discount!=0"));
	
	if (isset($res['c']) && $res['c']>0)
		return true;
	else
		return false;
}

function formatPDFPositions($positions, $focus) {
	$result = array();
	foreach ($positions as $pos) {
		
		$pos['position'] = intval($pos['position'])+1;
		$p = new EcmProduct();
		$p -> retrieve($pos['product_id']);
		
		$pos['ean'] = $p->ean;
		$pos['ean2'] = $p->ean2;
		
		$pos['image'] = $p->product_picture;
		
		unset($p);
		
		$c = new Currency();
		$c->retrieve($focus->currency_id);
			
		$pos['price_start']=format_number($pos['price_start'],2,2).' '.$c->symbol;
		$pos['price_netto']=format_number($pos['price_netto'],2,2).' '.$c->symbol;
		$pos['total_netto']=format_number($pos['total_netto'],2,2).' '.$c->symbol;
		
		unset($c);
		
		if ($focus->ecmlanguage=='en_ussss') {
			//get names
			$db = $GLOBALS['db'];
			$r = $db->fetchByAssoc($db->query("SELECT short_description FROM ecmproduct_language WHERE ecmproduct_id='".$pos['product_id']."' AND language='en'"));
			$pos['name'] = $r['short_description'];
			
			$lists = return_app_list_strings_language($focus->ecmlanguage);
			$pos['unit_name'] = $lists['ecmproducts_unit_dom'][$pos['unit_id']];
			unset($lists);
		}
		
		$pos['discount'].='%';

		$result[] = $pos;
	}
	
	return $result;
}