Files
crm.e5.pl/modules/EcmInvoiceOutOlds/createEdiXML.php

56 lines
1.9 KiB
PHP
Raw Normal View History

2024-04-27 09:23:34 +02:00
<?php
class createEdiXML {
private $xml;
private $id;
//private $i; //EcmInvoiceOutOld object
function createEdiXML($id) {
$this->id = $id;
$this->i = new EcmInvoiceOutOld();
$this->i->retrieve($this->id);
}
public function getXML() {
$i = $this->i;
if ($i->type == 'normal')
$this->xml = $this->createInvoiceXML();
elseif ($i->type == 'correct')
$this->xml = $this->createInvoiceXML();
//$this->xml->flush ();
}
private function createInvoiceXML() {
$db = $GLOBALS['db'];
$i = $this->i;
//get data
//get WZ && Sale info
$wz = $db->fetchByAssoc($db->query("SELECT document_no, register_date, so_id FROM ecmstockdocouts WHERE id ='$i->wz_id'"));
$sale = $db->fetchByAssoc($db->query("SELECT docment_no, register_date, parent_document_no FROM ecmsales WHERE id = '".$wz['so_id']."'"));
//get ILNs
$shipping_iln = $db->fetchByAssoc($db->query("SELECT iln FROM "));
$xml = new XMLWriter ();
$xml->openURI ( 'php://output' );
// $this->p->openMemory();
$xml->startDocument ( '1.0', 'UTF-8' );
$xml->startElement ( 'Document-Invoice' );
$xml->startElement('Invoice-Header');
$xml->writeElement('InvoiceNumber' ,$i->document_no);
$xml->writeElement('InvoiceDate', $i->register_date);
$xml->writeElement('SalesDate', $i->sell_date);
$c = new Currency();
$c->retrieve($i->currency_id);
$xml->writeElement('InvoiceCurrency', $c->iso4217);
unset($c);
$xml->writeElement('InvoicePaymentDueDate', $i->payment_date);
$pc = new EcmPaymentCondition();
$pc->retrieve($i->ecmpaymentcondition_id);
$xml->writeElement('InvoicePaymentTerms', $pc->days);
unset($pc);
$xml->writeElement('DocumentFunctionCode', 'O');
$xml->endElement(); //</Invoice-Header>
$xml->endElement(); //</Document-Invoice>
return $xml;
}
}
?>