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

	/**
	 * return array with table data
	 *
	 * @return array
	 */
	function get_smarty_data_array(){
		$array = (array) $this->data;
		
		$array['transport_type'] = yes_get_transport_type_name($array['transport_types_id']);
		$array['add_costs_link'] = yes_draw_href_text( TEXT_ADD_ENTRY,xtc_href_link(FILENAME_IMPORTS_EDIT_COSTS,'iID='.$array['imports_id']),'imports_edit',$style='');
		$array['add_ship_link'] = yes_draw_href_text( TEXT_ADD_ENTRY,xtc_href_link(FILENAME_IMPORT_SHIPS_EDIT,'iID='.$array['imports_id']),'imports_edit',$style='');
		
		$array['status_name'] = yes_get_imports_status_name($array['status']);
		
		$total = 0;
		for($i=0;$i<sizeOf($array['costs']);$i++){
			$total += $array['costs'][$i]['costs'];
		}
		$array['total_costs'] = $total;
		
		$array['edit_link'] = array('text'=>IMAGE_EDIT,'link'=>xtc_href_link(FILENAME_IMPORTS_EDIT,'id='.$array['imports_id']),'access'=>'imports_edit');
		$array['generate_invoice_link'] = array('text'=>BUTTON_GENERATE_INVOICE, 'link'=>xtc_href_link(FILENAME_INVOICES_EDIT,'action=add&iID='.$array['imports_id'] ),'access'=>'invoices_edit','css_class'=>'lbOn'); 
		
		$array['action_array'] = array(
			'edit'=>$array['edit_link'],
			'generate_invoice'=>$array['generate_invoice_link']
		);

		$array['routing_source'] = yes_get_location_name($array['routing_source']);
		$array['routing_target'] = yes_get_location_name($array['routing_target']);

		$array['haulage_service_address'] = yes_get_address_data_array($array,'haulage_service_','company');
		$array['shipper_address'] = yes_get_address_data_array($array,'shipper_','company');
		$array['transport_agent_address'] = yes_get_address_data_array($array,'transport_agent_','company');
		
		return $array;
	}

}
