checkLogin();
$project = new SI_Project();
if($loggedin_user->hasRight('accounting') && !empty($_REQUEST['id'])){
	$id = $_REQUEST['id'];
}else{
	$id = $loggedin_user->company_id;
}

$company = new SI_Company();
if($company->get($id) === FALSE){
	$error_msg .= "Could not retrieve data for company!\n";
	debug_message($company->getLastError());
}

$balance = $company->getBalance();
if($balance === FALSE){
	$error_msg .= "Error getting your outstanding balance!";
	debug_message($company->getLastError());
}

$invoice = new SI_Invoice();
$invoices = $invoice->getForCompany($company->id);
if($invoices === FALSE){
	$error_msg .= "Could not retrieve Invoice list!\n";
	debug_message($invoice->getLastError());
}

$title = $company->name." Invoices";
if($loggedin_user->hasRight('admin')){
	$update_url = "company.php?mode=edit&id=$id";