<?php

  if(isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
    require_once('modules/EcmReceipts/EcmInvoiceOut.php');
    $eio = new EcmReceipt();
    $eio->retrieve($_REQUEST['record']);
    if(isset($eio->id) && $eio->id != '') {
      $json = getJSONobj();
      $arr = array();
	  
	  $arr['ecmlanguage'] = $eio->ecmlanguage;
      
	  $eio->format_all_fields();
	  
      $arr['template_id'] = $eio->template_id; 
      $arr['template_name'] = $eio->template_name; 
      $arr['parent_type'] = $eio->parent_type;
      $arr['parent_id'] = $eio->parent_id; 
      $arr['parent_name'] = $eio->parent_name; 
      $arr['parent_address_street'] = $eio->parent_address_street; 
      $arr['parent_address_city'] = $eio->parent_address_city; 
      $arr['parent_address_postalcode'] = $eio->parent_address_postalcode; 
      $arr['parent_address_country'] = $eio->parent_address_country; 
      $arr['to_nip'] = $eio->to_nip; 
      $arr['to_is_vat_free'] = $eio->to_is_vat_free;
      $arr['to_vatid'] = $eio->to_vatid;
      $arr['header_text'] = $eio->header_text;
      $arr['footer_text'] = $eio->footer_text;
      $arr['ads_text'] = $eio->ads_text;
      $arr['discount'] = $eio->discount;
      $arr['position_list'] = str_replace('&quot;','\"',$eio->getPositionList()); 
      $arr['total'] = $eio->total; 
      echo '['.$json->encode($arr).']';
      return;
    }
    return;
  }

?>
