Ver código fonte

+ export plik JPK dla danych z L1

Piotr Labudda 5 anos atrás
pai
commit
9aefc19959
1 arquivos alterados com 34 adições e 1 exclusões
  1. 34 1
      SE/se-lib/Route/UrlAction/JPK.php

+ 34 - 1
SE/se-lib/Route/UrlAction/JPK.php

@@ -278,7 +278,22 @@ format: 'YYYY-MM'
       <div class="col-sm-12">
       <div class="col-sm-12">
          <table class="table table-bordered table-hover table-striped">
          <table class="table table-bordered table-hover table-striped">
            <thead>
            <thead>
-              <tr style="text-align:center; background-color:lightgray"><td width="19%"></td><td witdh="27%">Insert</td><td width="27%">L1</td><td width="27%">Dane wynikowe</td></tr>
+				<tr style="text-align:center; background-color:lightgray">
+					<td width="19%"></td>
+					<td witdh="27%">Insert</td>
+					<td width="27%">L1
+						<?php
+							if ($this->JPK['IN_L1']) {
+								echo UI::h('a', [
+									'class' => "btn btn-xs btn-default",
+									'target' => "_blank",
+									'href' => $this->getLink('exportL1JPK', [ 'ID_JPK' => V::get('ID_JPK',0,$_GET,'int') ]),
+								], 'Pobierz JPK');
+							}
+						?>
+					</td>
+					<td width="27%">Dane wynikowe</td>
+				</tr>
            </thead>
            </thead>
            <tbody>
            <tbody>
 <?php
 <?php
@@ -312,6 +327,22 @@ format: 'YYYY-MM'
 <?php
 <?php
 	}
 	}
 
 
+	function exportL1JPKAction() {
+		if (!$this->JPK['IN_L1']) throw new Exception("Błąd danych - nie pobrano danych JPK z L1");
+		$xml = simplexml_load_string($this->JPK['IN_L1']);
+		$ns = $xml->getNamespaces(true);
+		$this->validateJPK_VAT($xml);
+		if ($this->JPK_VAT_Wariant == 2) $pelnaNazwa = $xml->Podmiot1->IdentyfikatorPodmiotu->children($ns['etd'])->PelnaNazwa;
+		elseif ($this->JPK_VAT_Wariant == 3) $pelnaNazwa = $xml->Podmiot1->PelnaNazwa;
+		$fileName = preg_replace("/[: \.]/", "_", "JPK_VAT_{$this->JPK['MONTH']}_L1_" . str_replace('"', '', $pelnaNazwa)) . ".xml";
+		$output = $xml->asXml();
+		header("Content-Type: application/xml");
+		header("Content-Disposition: attachment; filename={$fileName};");
+		header("Content-Transfer-Encoding: binary");
+		header("Content-Length: " . strlen($output));
+		echo $output;
+	}
+
 	private function show() {
 	private function show() {
 		if (V::get('action','',$_POST) == "getJPK") {
 		if (V::get('action','',$_POST) == "getJPK") {
 			try {
 			try {
@@ -726,6 +757,7 @@ EOT;
 
 
 		$xmlSchema = $xmlSchemaWarianty[$this->JPK_VAT_Wariant];
 		$xmlSchema = $xmlSchemaWarianty[$this->JPK_VAT_Wariant];
 
 
+		// bfp.ID_SERVICES -> SERVICES.ID (NAME_LIST_SERVICES: NET, TV, VOIP)
 		$queryFVAT = <<<EOT
 		$queryFVAT = <<<EOT
 select
 select
 bn.ID as BN_ID,
 bn.ID as BN_ID,
@@ -748,6 +780,7 @@ and bu.BILLING_OWNER='{$this->BO['ID']}'
 order by bf.BILL_DATE,bn.ID
 order by bf.BILL_DATE,bn.ID
 EOT;
 EOT;
 
 
+		//	bkp.ID_SERVICES ->  -> SERVICES.ID (NAME_LIST_SERVICES: NET, TV, VOIP)
 		$queryKORV = <<<EOT
 		$queryKORV = <<<EOT
 select
 select
 bn.ID AS BN_ID,
 bn.ID AS BN_ID,