<?php 

function nice_phone($phone = NULL)
{
	if(empty($phone))
	{
		return 'N/A';
	}
	$nice = 'INVALID: ' . $phone;
	if( strlen($phone) == 10)
	{
		$area = substr($phone , 0 , 3);
		$prefix = substr($phone , 3 , 3);
		$serial = substr($phone , 6 , 4);
		$nice = $area  .'-' . $prefix  .'-'. $serial ;
	}
	if( strlen($phone) == 11)
	{
		$country = substr($phone , 0 ,1);

		$area = substr($phone , 1 , 3);
		$prefix = substr($phone , 4 , 3);
		$serial = substr($phone , 7 , 4);
		$nice = '+'. $country. ' (' . $area  .') ' . $prefix  .'-'. $serial ;
	}
	return $nice;
}

function getOwner($companyID)
{
	global $db;
	$owner = new stdClass();
	$owner->firstname = "";
	$owner->lastname = "";
	$owner->email = "";
	$owner->notes = "";
	
	$res = $db->select('*')->from('owner')->where('id',$companyID)->get();
	if($res->count == 1)
	{
		$data = $res->result();
		$data = $data[0];
		$owner->firstname = $data->firstname;
		$owner->lastname = $data->lastname;
		$owner->email = $data->email;
		$owner->notes = $data->notes;
	}
	return $owner;
}

$db_info = new stdClass();
$db_info->host = 'localhost';
$db_info->user = 'lhsip_ciddbapiu';
$db_info->pass = 'mHXC}GwHRrEs1ezwk7';
$db_info->name = 'ciddb';

?>