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

	/**
	 * return array with table data
	 *
	 * @return array
	 */
	function get_smarty_data_array(){
		$array = (array) $this->data;
		$recipient_link = xtc_href_link(FILENAME_COMPANIES,'id='.$array['recipient_id'].'&action=overview');
		$agent_link = xtc_href_link(FILENAME_COMPANIES,'id='.$array['agent_id'].'&action=overview');
		$transport_company_link = xtc_href_link(FILENAME_COMPANIES,'id='.$array['transport_company_id'].'&action=overview');

		$array['recipient_link'] = yes_draw_href_text( $array['recipient_name'],$recipient_link,'companies',$style='',$css_class='');
		$array['agent_link'] = yes_draw_href_text( $array['agent_name'],$agent_link,'companies',$style='',$css_class='');
		$array['transport_company_link'] = yes_draw_href_text( $array['transport_company_name'],$transport_company_link,'companies',$style='',$css_class='');
		
		$array['recipient_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,$recipient_link,'companies',$css_class='' );
		$array['agent_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,$agent_link,'companies',$css_class='' );
		$array['transport_company_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,$transport_company_link,'companies',$css_class='' );
		
		$recipient_contact_name = yes_get_customers_name($array['recipient_contact_id']);
		$recipient_contact_link = xtc_href_link(FILENAME_CUSTOMERS,'id='.$array['recipient_contact_id'].'&action=overview');
		$array['recipient_contact_link'] = yes_draw_href_text( $recipient_contact_name,$recipient_contact_link,'customers',$style='',$css_class=''); 
		$array['recipient_contact_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,$recipient_contact_link,'customers',$css_class='' );
		
		$agent_contact_name = yes_get_customers_name($array['agent_contact_id']);
		$agent_contact_link = xtc_href_link(FILENAME_CUSTOMERS,'id='.$array['agent_contact_id'].'&action=overview');
		$array['agent_contact_link'] = yes_draw_href_text( $agent_contact_name,$agent_contact_link,'customers',$style='',$css_class=''); 
		$array['agent_contact_link_button'] = yes_draw_href_image('images/link_arrow.gif',YES_LINKTEXT,$agent_contact_link,'customers',$css_class='' );
		
		$array['transport_type'] = yes_get_transport_type_name($array['transport_types_id']);
		if($array['transport_types_airlines_id'] > 0){
			$array['transport_type_airline'] = yes_get_airline_name($array['transport_types_airlines_id']);
			$array['transport_type_airline_number_code'] = yes_get_airline_code($array['transport_types_airlines_id']);
		}
		$array['add_target_link'] = yes_draw_href_text( TEXT_ADD_ENTRY,xtc_href_link(FILENAME_EXPORTS_EDIT_TARGETS,'eID='.$array['exports_id']),'export_targets_edit',$style='');
		$array['add_costs_link'] = yes_draw_href_text( TEXT_ADD_ENTRY,xtc_href_link(FILENAME_EXPORTS_EDIT_COSTS,'eID='.$array['exports_id']),'exports_edit',$style='');
		
		$array['recipient_address'] = yes_get_address_data_array($array,'recipient_','company');
		$array['agent_address'] = yes_get_address_data_array($array,'agent_','company');
		$array['transport_company_address'] = yes_get_address_data_array($array,'transport_company_','company');
		
		$total = 0;
		for($i=0;$i<sizeOf($array['costs']);$i++){
			$total += $array['costs'][$i]['costs'];
		}
		$array['total_costs'] = $total;

		$array['routing_source'] = yes_get_location_name($array['routing_source']);
		$array['routing_target'] = yes_get_location_name($array['routing_target']);
		
		$array['edit_link'] = array('text'=>IMAGE_EDIT,'link'=>xtc_href_link(FILENAME_EXPORTS_EDIT,'id='.$array['exports_id']),'access'=>'exports_edit');
		$array['action_array'] = array(
			'edit'=>$array['edit_link']
		);
		
		return $array;
	}
}
