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

	/**
	 * return array with table data
	 *
	 * @return array
	 */
	function get_smarty_data_array(){
		$array = (array) $this->data;

		$ship_link = xtc_href_link(FILENAME_SHIPS,'id='.$array['ships_id'].'&action=overview');
		$array['ship_link'] = yes_draw_href_text( yes_get_ships_name($array['ships_id']),$ship_link,'ships',$style='',$css_class='');
		$array['ship_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,$ship_link,'ships',$css_class='' );

		$invoice_recipient_link = xtc_href_link(FILENAME_COMPANIES,'id='.$array['invoice_recipient_id'].'&action=overview');
		$array['invoice_recipient_link'] = yes_draw_href_text( yes_get_companies_name($array['invoice_recipient_id']),$invoice_recipient_link,'companies',$style='',$css_class='');
		$array['invoice_recipient_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,$invoice_recipient_link,'companies',$css_class='' );

		$invoice_recipient_contact_link = xtc_href_link(FILENAME_CUSTOMERS,'id='.$array['contact_id'].'&action=overview');
		$array['invoice_recipient_contact_link'] = yes_draw_href_text( yes_get_customers_name($array['contact_id']),$invoice_recipient_contact_link,'customers',$style='',$css_class='');
		$array['invoice_recipient_contact_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,$invoice_recipient_contact_link,'customers',$css_class='' );
		
		$array['edit_link'] = yes_draw_href_image('images/icons/icon_edit.gif',IMAGE_EDIT,xtc_href_link(FILENAME_EXPORTS_EDIT_TARGETS,'id='.$array['export_targets_id']),'export_targets_edit','' ); 
		$array['delete_link'] = yes_draw_href_image_confirm(TEXT_REMOVE_ENTRY,'images/icons/delete.gif',IMAGE_EDIT,xtc_href_link(FILENAME_EXPORTS,'id='.$array['exports_id'].'&etID='.$array['export_targets_id'].'&subaction=delete_target'),'func_export_targets_delete','' );
		$array['add_collie_link'] = yes_draw_href_text( TEXT_ADD_ENTRY,xtc_href_link(FILENAME_EXPORTS_TARGET_COLLIES_EDIT,'etID='.$array['export_targets_id']),'export_target_collies_edit',$style='',$css_class=''); 
		$array['add_collie_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,xtc_href_link(FILENAME_EXPORTS_TARGET_COLLIES_EDIT,'etID='.$array['export_targets_id']),'export_target_collies_edit',$css_class=''); 
		$array['add_import_ship_link'] = yes_draw_href_text( TEXT_ADD_ENTRY,xtc_href_link(FILENAME_EXPORTS_TARGET_IMPORT_SHIPS_EDIT,'etID='.$array['export_targets_id']),'export_target_import_ships_edit',$style='',$css_class='');
		$array['add_import_ship_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,xtc_href_link(FILENAME_EXPORTS_TARGET_IMPORT_SHIPS_EDIT,'etID='.$array['export_targets_id']),'export_target_import_ships_edit',$css_class='');
		
		$import_ships_id_array = array();
		for($i=0;$i<sizeOf($array['imports']);$i++){
			$import_ships_id_array[] = array(
				'import_ships_id'=>$array['imports'][$i]['import_ships_id']);
		}
		$array['total_collies_string'] = sprintf(TEXT_COLLIES_IN_IMPORTS,yes_get_sum_of_collies_from_import_ships($import_ships_id_array),sizeOf($import_ships_id_array)); 
		return $array;
	}
}
