<?php
/**
 * ship class
 *
 */
class ship
{
	var $data;
	
	/**
	 * initiated the ship class
	 *
	 * @param object $ship_object
	 */
	function ship( $ship_object ){
		$this->data = $ship_object;
	}

	/**
	 * return array with table data
	 *
	 * @return array
	 */
	function get_smarty_data_array(){
		$array = (array) $this->data;
		$owner = yes_get_ship_company_id($this->data->ships_id);
		if($owner){
			$array['owner'] = yes_get_companies_name($owner);
			$array['owner_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,xtc_href_link(FILENAME_COMPANIES,'id='.$owner.'&action=overview'),'companies',$css_class='' );
			$array['owner_link'] = yes_draw_href_text( $array['owner'],xtc_href_link(FILENAME_COMPANIES,'id='.$owner.'&action=overview'),'companies',$style='',$css_class=''); 
		}
		$invoice_owner = yes_get_ship_invoice_company_id($this->data->ships_id);
		if($invoice_owner){
			$array['invoice_owner'] = yes_get_companies_name($invoice_owner);
			$array['invoice_owner_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,xtc_href_link(FILENAME_COMPANIES,'id='.$invoice_owner.'&action=overview'),'companies',$css_class='' );
			$array['invoice_owner_link'] = yes_draw_href_text( $array['invoice_owner'],xtc_href_link(FILENAME_COMPANIES,'id='.$invoice_owner.'&action=overview'),'companies',$style='',$css_class=''); 
		}
		
		$names = yes_get_ship_names($this->data->ships_id);
		if($names){
			$array['names'] = $names;
		}
		$array['name'] = yes_get_ships_name($this->data->ships_id);
		$array['link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,xtc_href_link(FILENAME_SHIPS,'id='.$array['ships_id'].'&action=overview'),'ships',$css_class='');
		$array['link'] = yes_draw_href_text( $array['name'],xtc_href_link(FILENAME_SHIPS,'id='.$array['ships_id'].'&action=overview'),'ships',$style='',$css_class=''); 
		return $array;
	}
}
