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

	/**
	 * return array with table data
	 *
	 * @return array
	 */
	function get_smarty_data_array(){
		$array = (array) $this->data;
		$array['status_name'] = yes_get_invoice_status_name($array['status_id']);
		$array['import_number'] = yes_get_import_number_from_imports_id($array['imports_id']);
		$array['recipient_address'] = yes_get_address_data_array($array,'recipient_','company');
		if($array['baptismal_name'] != ''){
			$array['recipient_address']['baptismal_name'] = $array['baptismal_name'];
		}
		$array['add_entries_link'] = yes_draw_href_text( TEXT_ADD_ENTRY,xtc_href_link(FILENAME_INVOICES_ENTRIES_EDIT,'iID='.$array['invoices_id']),'invoice_entries_edit',$style='');
		$array['add_import_costs_link'] = yes_draw_href_text( TEXT_ADD_ENTRY, xtc_href_link(FILENAME_INVOICES_EDIT,'action=add_import_costs&iID='.$array['invoices_id'].'&impID='.$array['imports_id'] ),$access='invoices_edit','font-size:11px;background-color:#003a9c;border: 1px solid #000000;color:#FFFFFF;font-weight:bold;padding:3px;border-bottom:2px solid #000000;border-right:2px solid #000000;text-decoration:none;','lbOn'); 
		$array['add_import_ship_costs_link'] = yes_draw_href_text( TEXT_ADD_ENTRY, xtc_href_link(FILENAME_INVOICES_EDIT,'action=add_import_ship_costs&iID='.$array['invoices_id'].'&impID='.$array['imports_id'] ),$access='invoices_edit','font-size:11px;background-color:#003a9c;border: 1px solid #000000;color:#FFFFFF;font-weight:bold;padding:3px;border-bottom:2px solid #000000;border-right:2px solid #000000;text-decoration:none;','lbOn'); 
		
		$array['edit_link'] = array('text'=>IMAGE_EDIT,'link'=>xtc_href_link(FILENAME_INVOICES_EDIT,'id='.$array['invoices_id']),'access'=>'invoices_edit');
		$array['recipient_edit_link'] = yes_draw_href_image(
			'images/icons/icon_edit.gif',
			IMAGE_EDIT,
			xtc_href_link(FILENAME_INVOICES_RECIPIENT_EDIT,'id='.$array['invoices_id']),
			'invoices_recipient_edit',
			$class=''
		);
		
		$array['action_array'] = array(
			'edit'=>$array['edit_link']
		);
		
		return $array;
	}
}
