本文整理汇总了PHP中XMLWriter::writeElementNs方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::writeElementNs方法的具体用法?PHP XMLWriter::writeElementNs怎么用?PHP XMLWriter::writeElementNs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::writeElementNs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeExtensions
/**
* Write the extensions into the GPX.
*
* @param \XMLWriter $xmlWriter The XMLWriter.
* @param ExtensionInterface[] $extensions The extensions to write.
*/
protected function writeExtensions(\XMLWriter $xmlWriter, array $extensions)
{
$xmlWriter->startElement('extensions');
foreach ($extensions as $extension) {
switch ($extension::ID()) {
case HR::ID():
$xmlWriter->startElementNs('gpxtpx', 'TrackPointExtension', null);
$xmlWriter->writeElementNs('gpxtpx', 'hr', null, (string) $extension->value());
$xmlWriter->endElement();
break;
}
}
$xmlWriter->endElement();
}
示例2: fiskalsve
function fiskalsve()
{
$zahtjev = $this->input->post('request');
$msg = '';
$uspjelo = 0;
$nijeuspjelo = 0;
//$firma = $this->fiskal->getById('firma', 'fi_id', $this->session->userdata('firmaID'));
$firma = $this->fiskal->getFirma();
//dohvati podatke za sve nefiskalizirane
$nefiskalizirani = $this->fiskal->getNefiskalizirane();
//foreach ID
if ($nefiskalizirani) {
foreach ($nefiskalizirani as $dokument) {
//dohvati pojedinacno
$prikaziStavke = $this->fiskal->getstavke($dokument->do_id);
$zaglavlje = $this->fiskal->getDokumentZag($dokument->do_id);
$rekapitualcijaporeza = $this->fiskal->rekapitulacijaporeza($dokument->do_id);
//Init XML
$doc = new DOMDocument();
$doc->formatOutput = true;
//XML
$ns = 'tns';
$writer = new XMLWriter();
$writer->openMemory();
$writer->startDocument('1.0', 'UTF-8');
$writer->setIndent(True);
$writer->startElementNs($ns, 'RacunZahtjev', null);
$writer->writeAttributeNS("xmlns", "tns", null, "http://www.apis-it.hr/fin/2012/types/f73");
$writer->writeAttributeNS("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
$writer->startElementNs($ns, 'Racun', null);
$writer->writeElementNs($ns, 'Oib', null, $firma->fi_oib);
$writer->writeElementNs($ns, 'USustPdv', null, $firma->fi_usustavuPDV);
$writer->writeElementNs($ns, 'DatVrijeme', null, date("d.m.Y", strtotime($zaglavlje->do_datum)) . date("\\Th:i:s", strtotime($zaglavlje->do_vrijeme)));
// date('d.m.Y\Th:i:s'));
$writer->writeElementNs($ns, 'OznSlijed', null, 'N');
/* P ili N => P na nivou Poslovnog prostora, N na nivou naplatnog uredaja */
$writer->startElementNs($ns, 'BrRac', null);
$writer->writeElementNs($ns, 'BrOznRac', null, $zaglavlje->do_broj);
$writer->writeElementNs($ns, 'OznPosPr', null, $zaglavlje->PP);
$writer->writeElementNs($ns, 'OznNapUr', null, $zaglavlje->NU);
$writer->endElement();
/* #BrRac */
$writer->startElementNs($ns, 'Pdv', null);
if (!empty($rekapitualcijaporeza)) {
$rank = 0;
foreach ($rekapitualcijaporeza as $porez) {
$writer->startElementNs($ns, 'Porez', null);
$writer->writeElementNs($ns, 'Stopa', null, $porez->porez_pz_posto);
$writer->writeElementNs($ns, 'Osnovica', null, $porez->sumaIznosa);
$writer->writeElementNs($ns, 'Iznos', null, number_format($porez->sumaPorez, 2, '.', ''));
$writer->endElement();
/* #Porez */
}
}
$writer->endElement();
/* #Pdv */
if (!empty($rekapitualcijaporeza)) {
$rank = 0;
foreach ($rekapitualcijaporeza as $porez) {
if ($porez->porez_pz_posto == "0") {
$writer->writeElementNs($ns, 'IznosOslobPdv', null, number_format($porez->sumaIznosa + $porez->sumaPorez, 2, '.', ''));
}
}
}
//$writer->writeElementNs($ns, 'IznosNePodlOpor', null, number_format($zaglavlje->do_iznos + $zaglavlje->do_iznosPDV, 2,'.',''));
$writer->writeElementNs($ns, 'IznosUkupno', null, number_format($zaglavlje->do_iznos + $zaglavlje->do_iznosPDV, 2, '.', ''));
$writer->writeElementNs($ns, 'NacinPlac', null, $zaglavlje->sp_oznaka);
$writer->writeElementNs($ns, 'OibOper', null, $zaglavlje->op_oib);
$writer->writeElementNs($ns, 'NakDost', null, '1');
$writer->endElement();
/* #Racun */
$writer->endElement();
/* #RacunZahtjev */
$writer->endDocument();
$XMLRequest = $writer->outputMemory();
$doc->loadXML($XMLRequest);
//file_put_contents("racun".$dokument->do_id.".xml",$XMLRequest);
//fiskaliziraj
if ($firma != FALSE) {
try {
$fis = new Fiskalizator($firma->fi_certifikat, $this->decrypt($firma->fi_pass));
//Produkcijski mode
//$fis->setProductionMode();
$fis->doRequest($doc);
#custom timeout and number of retries on network error, default is 3 retries and 5 seconds timeout tolerance
#$fis->doRequest($doc, 10, 5.2);
if ($fis->getRequestType() == 'RacunZahtjev') {
//echo 'JIR: '.$fis->getJIR().'<br>';
//echo 'ZKI: '.$fis->getZKI().'<br>';
$msg = '<pre class="bg-success">Uspješno fiskalizirani svi dokument!</pre>';
$uspjelo = $uspjelo + 1;
//update raèun
$dok['do_zki'] = $fis->getZKI();
$dok['do_jir'] = $fis->getJIR();
$this->fiskal->update("dokument", "do_id", $zaglavlje->do_id, $dok);
}
} catch (Exception $e) {
if ($zahtjev == 'RacunZahtjev') {
//update raèun
$dok['do_zki'] = $fis->getZKI();
//.........这里部分代码省略.........