<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Allopass - Liste des paliers</title>
</head>
<body>

<?php
require_once 'allopass-apikit-php5/api/AllopassAPI.php';
$api = new AllopassAPI();

$site_id = '222616';
$country = $_REQUEST['country'];
$type = $_REQUEST['type'];

$response = $api->getOnetimePricing(array('site_id' => $site_id, 'country' => $country, 'type' => $type));	
$markets = $response->getMarkets();
echo "<table border='1'>";

foreach ($markets as $market) {
	$pricepoints = $market->getPricepoints();
	foreach ($pricepoints as $market_pricepoint) {
		$market_pricepoint_id = $market_pricepoint->getId(); 
		if ($type == 'premium-sms') {
			$keywords = $market_pricepoint->getKeywords();
			foreach ($keywords as $keyword) {
				$blanche['keyword'] = $keyword->getName();
				$blanche['shortcode'] = $keyword->getShortcode();
				$blanche['ppdescription'] = $keyword->getDescription();
			}
		}
		elseif ($type == 'premium-calling') {
			$numbers = $market_pricepoint->getPhoneNumbers();
			foreach ($numbers as $number) {
				$blanche['keyword'] = '';
				$blanche['shortcode'] = $number->getValue();
				$blanche['ppdescription'] = $number->getDescription();
			}
		}
		else {
			$blanche['keyword'] = "";
			$blanche['shortcode'] = "";
			$blanche['ppdescription'] = "";
		}
		//$blanche[$market_pricepoint_id]['keywords'] = $keywords->getName();
		//$blanche[$market_pricepoint_id]['shortcodes'] = $market_pricepoint->getPhoneNumbers()->getShortcode();
		$blanche['cgv'] = $market_pricepoint->getDescription();
		
		echo "<tr><td>" . $blanche['keyword'] . "</td><td>" . $blanche['shortcode'] . "</td><td>" . $blanche['ppdescription'] . "</td><td>" . $blanche['cgv'] . "</td></tr>";
	}
}

echo "</table>";
/*
$description_payment = "<br>" . $blanche[$pricepoint]['description'] . 
"<br><br>" . $blanche[$pricepoint]['cgv'] . 
"<br><br>" .
"<form action='allopass/validate_codes.php' method='POST'>
<input type='hidden' value='".$product_name."' name='product_name'>
<input type='hidden' value='".$pricepoint."' name='pricepoint'>
<input type='text' name='code'>
<input type='submit'>
</form>
";

echo $description_payment;
*/
?>

</body>
</html>