<?php
require(DIR_WS_CLASSES.'ships.php');
$id = xtc_db_input($_GET['id']);
$ships = new ships();
$ship = $ships->get_ship($id);

switch($_GET['action']){
	case 'delete_confirm':
		$smarty->assign('BOX_TITLE', $ship->data->name );
		$contents = array();
		$contents[] = array('align'=>'center','text' => DELETE_ENTRY );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_DELETE,xtc_href_link(FILENAME_SHIPS,xtc_get_all_get_params(array('action')).'action=delete'),$access='func_ships_delete','width:100px;').'&nbsp;'.yes_draw_href_button(IMAGE_CANCEL,"javascript:ajax_box_action('".$id."','');",$access='ships','width:100px;') );
		
		break;
	default:
		$smarty->assign('BOX_TITLE', yes_get_ships_name($ship->data->ships_id) );
		$contents = array();
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_OVERVIEW,xtc_href_link(FILENAME_SHIPS,'id='.$id.'&action=overview'),$access='ships','width:180px;') );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_EDIT,xtc_href_link(FILENAME_SHIPS_EDIT,'id='.$id),$access='ships_edit','width:180px;') );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_SHIP_NAMES,xtc_href_link(FILENAME_SHIP_NAMES,'sID='.$id),$access='ship_names','width:180px;') );
		$contents[] = array('align'=>'center','text' => yes_draw_href_button(IMAGE_DELETE,"javascript:ajax_box_action('".$id."','delete_confirm');",$access='func_ships_delete','width:180px;') );
		$names = yes_get_ship_names($ship->data->ships_id);
		$names_string =  '';

		$baptismal_name = yes_get_baptismal_ship_name($ship->data->ships_id);
		for($i=0;$i<sizeOf($names);$i++){
			if($baptismal_name == $names[$i]){
				$names_string .= '<b>'.$names[$i].'</b><br />';
			}else{
				$names_string .= $names[$i].'<br />';
			}
		}
		$contents[] = array('align'=>'left','text'=>'<b>'.IMAGE_SHIP_NAMES.'</b><br />'.$names_string);
		break;
}

$box = new box;
$smarty->assign('BOX_CONTENT', $box->infoBox($contents) );

