<?php
$smarty = new yesSmarty();
$smarty->assign('BUTTON_CLOSE',BUTTON_CLOSE);
$imports = new imports;
$import = $imports->get_import($_GET['iID']);
$smarty->assign('import_number',$import->data->import_number);
$smarty->assign('form',xtc_draw_form('invoice_address', FILENAME_INVOICES_EDIT,'action=add_save&iID='.$_GET['iID'],'post','onsubmit="return check_form();"'));
if(is_array($import->data->ships) and sizeOf($import->data->ships)>0){
	$ship_array = array();
	foreach($import->data->ships as $k=>$ship){
		$invoice_owner_id = yes_get_ship_invoice_company_id($ship['orderer_ships_id']);
		if($invoice_owner_id == 0){
			$invoice_owner_id = $ship['orderer_id'];
		}
		$ship_array[] = array(
			'import_ships_id'=>$ship['import_ships_id'],
			'invoice_company_id'=>$invoice_owner_id,
			'ship_link'=>$ship['ship_link'],
			'address_data'=>yes_get_company_address_data($invoice_owner_id)
		);
	}
	$smarty->assign('ships',$ship_array);
}
echo $smarty->fetch(DIR_FS_ADMIN.'templates/invoices_choose_address.html');

include('includes/footer.php');
