<?php
	include(__DIR__.'/../includes/sysinit.php');
	$html	= '';
	if ($_POST['area_id'])
	{
		$area = $sableDB->getRow('select * from area where area_id = '.$_POST['area_id']);
		$sql = 'select service.service_id, service_name, service_price 
				from service 
				inner join service__area on service__area.service_id = service.service_id 
				where area_id = '.$area['area_id'];
		$rows = $sableDB->getRows($sql);
		
		if (empty($rows))
		{
			$html	= '<option value="0">No services linked to area "'.$area['area_name'].'".</option>';
		}
		else
		{
			foreach($rows as $row) 
			{
				$html .= '<option value="'.$row['service_id'].'">'.$row['service_name'].' (R'.number_format($row['service_price'], 2).')</option>';
			}
		}
	}
	SableSystem::ajaxFillField($html, $_POST['field']);