<?php
if (!defined("WHMCS")) {
	exit("This file cannot be accessed directly");
}

$result = full_query("SELECT tb1.id id, tb2.msetupfee msetupfee, tb2.qsetupfee qsetupfee, tb2.ssetupfee ssetupfee, tb2.asetupfee asetupfee, tb2.bsetupfee bsetupfee, tb2.tsetupfee tsetupfee,tb2.monthly monthly, tb2.quarterly quarterly, tb2.semiannually semiannually, tb2.annually annually, tb2.biennially biennially, tb2.triennially triennially FROM tbldomainpricing as tb1
JOIN tblpricing as tb2
ON tb1.id = tb2.relid AND tb1.extension = '".$_POST['extension']."' AND tb2.type = '".$_POST['type']."';");

$apiresults = array();
//$apiresults = array("result" => "success","extension" => $_POST['extension'],"domaintype" => $_POST['type'], "totalresults" => mysql_num_rows($result));

while ($data = mysql_fetch_array($result)) {
	$rows[1]['price'] = $data['msetupfee'];
	$rows[1]['title'] = '1 year';
	$rows[1]['billingcycle'] = 'msetupfee';
	$rows[1]['regperiod'] = '1';
	
	$rows[2]['price'] = $data['qsetupfee'];
	$rows[2]['title'] = '2 years';
	$rows[2]['billingcycle'] = 'qsetupfee';
	$rows[2]['regperiod'] = '2';
	
	$rows[3]['price'] = $data['ssetupfee'];
	$rows[3]['title'] = '3 years';
	$rows[3]['billingcycle'] = 'ssetupfee';
	$rows[3]['regperiod'] = '3';
	
	$rows[4]['price'] = $data['asetupfee'];
	$rows[4]['title'] = '4 years';
	$rows[4]['billingcycle'] = 'asetupfee';
	$rows[4]['regperiod'] = '4';
	
	$rows[5]['price'] = $data['bsetupfee'];
	$rows[5]['title'] = '5 years';
	$rows[5]['billingcycle'] = 'bsetupfee';
	$rows[5]['regperiod'] = '5';
	
	$rows[6]['price'] = $data['tsetupfee'];
	$rows[6]['title'] = 'xxx years';
	$rows[6]['billingcycle'] = 'tsetupfee';
	$rows[6]['regperiod'] = '';
	
	$rows[7]['price'] = $data['monthly'];
	$rows[7]['title'] = '6 years';
	$rows[7]['billingcycle'] = 'monthly';
	$rows[7]['regperiod'] = '6';
	
	$rows[8]['price'] = $data['quarterly'];
	$rows[8]['title'] = '7 years';
	$rows[8]['billingcycle'] = 'quarterly';
	$rows[8]['regperiod'] = '7';
	
	$rows[9]['price'] = $data['semiannually'];
	$rows[9]['title'] = '8 years';
	$rows[9]['billingcycle'] = 'semiannually';
	$rows[8]['regperiod'] = '8';
	
	$rows[10]['price'] = $data['annually'];
	$rows[10]['title'] = '9 years';
	$rows[10]['billingcycle'] = 'annually';
	$rows[10]['regperiod'] = '9';
	
	$rows[11]['price'] = $data['biennially'];
	$rows[11]['title'] = '10 years';
	$rows[11]['billingcycle'] = 'biennially';
	$rows[11]['regperiod'] = '10';
	
	$rows[12]['price'] = $data['triennially'];
	$rows[12]['title'] = 'xxx years';
	$rows[12]['billingcycle'] = 'triennially';
	
	$apiresults[] = $rows;
}
?>