mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-15 04:27:14 +01:00
exportbuchhaltung PDFs
This commit is contained in:
parent
04de0df0b6
commit
1ff2878d06
@ -61,7 +61,11 @@
|
|||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
<tr>
|
||||||
|
<td>{|PDF-Dateien exportieren:|}</td>
|
||||||
|
<td><input type="checkbox" name="pdfexport" value="1" [PDFEXPORT] /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,6 +46,91 @@ class Exportbuchhaltung
|
|||||||
var $belegnummer;
|
var $belegnummer;
|
||||||
var $headerwritten = false;
|
var $headerwritten = false;
|
||||||
|
|
||||||
|
function typen($rechnung, $gutschrift, $verbindlichkeit, $lieferantengutschrift) : array {
|
||||||
|
return(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'typ' => 'rechnung',
|
||||||
|
'subtable' => 'rechnung_position',
|
||||||
|
'kennzeichen' => 'S',
|
||||||
|
'kennzeichen_negativ' => 'H',
|
||||||
|
'field_belegnr' => 'b.belegnr',
|
||||||
|
'field_name' => 'b.name',
|
||||||
|
'field_date' => 'datum',
|
||||||
|
'field_auftrag' => 'MAKE_SET(3,b.auftrag,(SELECT auftrag.internet FROM auftrag WHERE auftrag.id = auftragid))',
|
||||||
|
'field_zahlweise' => 'CONCAT(UCASE(LEFT(b.zahlungsweise, 1)),SUBSTRING(b.zahlungsweise, 2))',
|
||||||
|
'field_kontonummer' => 'a.kundennummer_buchhaltung',
|
||||||
|
'field_kundennummer' => 'b.kundennummer',
|
||||||
|
'field_betrag_gesamt' => 'b.soll',
|
||||||
|
'field_betrag' => 'p.umsatz_brutto_gesamt',
|
||||||
|
'condition_where' => ' AND b.status IN (\'freigegeben\',\'versendet\',\'storniert\')',
|
||||||
|
'Buchungstyp' => 'SR',
|
||||||
|
'do' => $rechnung,
|
||||||
|
'pdf' => 'print'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'typ' => 'gutschrift',
|
||||||
|
'subtable' => 'gutschrift_position',
|
||||||
|
'kennzeichen' => 'H',
|
||||||
|
'kennzeichen_negativ' => 'S',
|
||||||
|
'field_belegnr' => 'b.belegnr',
|
||||||
|
'field_name' => 'b.name',
|
||||||
|
'field_date' => 'datum',
|
||||||
|
'field_auftrag' => '\'\'',
|
||||||
|
'field_zahlweise' => '\'\'',
|
||||||
|
'field_kontonummer' => 'a.kundennummer_buchhaltung',
|
||||||
|
'field_kundennummer' => 'b.kundennummer',
|
||||||
|
'field_betrag_gesamt' => 'b.soll',
|
||||||
|
'field_betrag' => 'p.umsatz_brutto_gesamt',
|
||||||
|
'condition_where' => ' AND b.status IN (\'freigegeben\',\'versendet\')',
|
||||||
|
'Buchungstyp' => '',
|
||||||
|
'do' => $gutschrift,
|
||||||
|
'pdf' => 'print'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'typ' => 'verbindlichkeit',
|
||||||
|
'subtable' => 'verbindlichkeit_position',
|
||||||
|
'kennzeichen' => 'H',
|
||||||
|
'kennzeichen_negativ' => 'S',
|
||||||
|
'field_belegnr' => 'b.rechnung',
|
||||||
|
'field_name' => 'a.name',
|
||||||
|
'field_date' => 'rechnungsdatum',
|
||||||
|
'field_auftrag' => 'b.auftrag',
|
||||||
|
'field_zahlweise' => '\'\'',
|
||||||
|
'field_kontonummer' => 'a.lieferantennummer_buchhaltung',
|
||||||
|
'field_kundennummer' => 'a.lieferantennummer',
|
||||||
|
'field_betrag_gesamt' => 'b.betrag',
|
||||||
|
'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
|
||||||
|
'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
|
||||||
|
'condition_where' => ' AND b.status IN (\'freigegeben\')',
|
||||||
|
'Buchungstyp' => '',
|
||||||
|
'do' => $verbindlichkeit,
|
||||||
|
'pdf' => 'load'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'typ' => 'lieferantengutschrift',
|
||||||
|
'subtable' => 'lieferantengutschrift_position',
|
||||||
|
'kennzeichen' => 'S',
|
||||||
|
'kennzeichen_negativ' => 'H',
|
||||||
|
'field_belegnr' => 'b.rechnung',
|
||||||
|
'field_name' => 'a.name',
|
||||||
|
'field_date' => 'rechnungsdatum',
|
||||||
|
'field_auftrag' => '\'\'',
|
||||||
|
'field_zahlweise' => '\'\'',
|
||||||
|
'field_kontonummer' => 'a.lieferantennummer_buchhaltung',
|
||||||
|
'field_kundennummer' => 'a.lieferantennummer',
|
||||||
|
'field_betrag_gesamt' => 'b.betrag',
|
||||||
|
'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
|
||||||
|
'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
|
||||||
|
'condition_where' => ' AND b.status IN (\'freigegeben\')',
|
||||||
|
'Buchungstyp' => '',
|
||||||
|
'do' => $lieferantengutschrift,
|
||||||
|
'pdf' => 'load'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exportbelegepositionen constructor.
|
* Exportbelegepositionen constructor.
|
||||||
*
|
*
|
||||||
@ -81,6 +166,7 @@ class Exportbuchhaltung
|
|||||||
$diffignore = $this->app->Secure->GetPOST("diffignore");
|
$diffignore = $this->app->Secure->GetPOST("diffignore");
|
||||||
$sachkonto = $this->app->Secure->GetPOST('sachkonto');
|
$sachkonto = $this->app->Secure->GetPOST('sachkonto');
|
||||||
$format = $this->app->Secure->GetPOST('format');
|
$format = $this->app->Secure->GetPOST('format');
|
||||||
|
$pdfexport = $this->app->Secure->GetPOST("pdfexport");
|
||||||
|
|
||||||
$account_id = null;
|
$account_id = null;
|
||||||
if (!empty($sachkonto)) {
|
if (!empty($sachkonto)) {
|
||||||
@ -161,13 +247,88 @@ class Exportbuchhaltung
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($dataok) {
|
if ($dataok) {
|
||||||
$filename = "EXTF_".date('Ymd') . "_Buchungsstapel_DATEV_export.csv";
|
$filename_csv = "EXTF_".date('Ymd') . "_Buchungsstapel_DATEV_export.csv";
|
||||||
try {
|
try {
|
||||||
$csv = $this->DATEV_Buchuchungsstapel($rgchecked, $gschecked, $vbchecked, $lgchecked, $buchhaltung_berater, $buchhaltung_mandant, $buchhaltung_wj_beginn, $buchhaltung_sachkontenlaenge, $von, $bis, $projekt, $filename, $diffignore, $sachkonto_kennung, $format);
|
$csv = $this->DATEV_Buchuchungsstapel($rgchecked, $gschecked, $vbchecked, $lgchecked, $buchhaltung_berater, $buchhaltung_mandant, $buchhaltung_wj_beginn, $buchhaltung_sachkontenlaenge, $von, $bis, $projekt, $filename_csv, $diffignore, $sachkonto_kennung, $format);
|
||||||
header("Content-Disposition: attachment; filename=" . $filename);
|
if ($pdfexport) {
|
||||||
header("Pragma: no-cache");
|
|
||||||
header("Expires: 0");
|
$dateinamezip = 'Export_Buchhaltung_'.date('Y-m-d').'.zip';
|
||||||
echo($csv);
|
|
||||||
|
$zip = new ZipArchive;
|
||||||
|
$zip->open($dateinamezip, ZipArchive::CREATE);
|
||||||
|
|
||||||
|
$zip->addFromString($typ['typ']."/".$filename_csv, $csv);
|
||||||
|
|
||||||
|
$typen = $this->typen($rgchecked, $gschecked, $vbchecked, $lgchecked);
|
||||||
|
|
||||||
|
foreach ($typen as $typ) {
|
||||||
|
$sql = "
|
||||||
|
SELECT id, ".$typ['field_belegnr']." belegnr FROM ".$typ['typ']." b
|
||||||
|
WHERE
|
||||||
|
b.".$typ['field_date']." BETWEEN '".date_format($von,"Y-m-d")."' AND '".date_format($bis,"Y-m-d")."' AND (b.projekt=$projekt OR $projekt=0)".$typ['condition_where'];
|
||||||
|
$belege = $this->app->DB->SelectArr($sql);
|
||||||
|
foreach ($belege as $beleg) {
|
||||||
|
switch ($typ['pdf']) {
|
||||||
|
case 'print':
|
||||||
|
switch ($typ['typ']) {
|
||||||
|
case 'rechnung':
|
||||||
|
if(class_exists('GutschriftPDFCustom')) {
|
||||||
|
$Brief = new RechnungPDFCustom($this->app,$projekt);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$Brief = new RechnungPDF($this->app,$projekt);
|
||||||
|
}
|
||||||
|
$Brief->GetRechnung($beleg['id']);
|
||||||
|
break;
|
||||||
|
case 'gutschrift':
|
||||||
|
if(class_exists('RechnungPDFCustom')) {
|
||||||
|
$Brief = new GutschriftPDFCustom($this->app,$projekt);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$Brief = new GutschriftPDF($this->app,$projekt);
|
||||||
|
}
|
||||||
|
$Brief->GetGutschrift($beleg['id']);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
exit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$tmpfile = $Brief->displayTMP();
|
||||||
|
$file_name = $beleg['belegnr'].".pdf";
|
||||||
|
$zip->addFromString($typ['typ']."/".$file_name, file_get_contents($tmpfile));
|
||||||
|
break;
|
||||||
|
case 'load':
|
||||||
|
$file_attachments = $this->app->erp->GetDateiSubjektObjekt('%',$typ['typ'],$beleg['id']);
|
||||||
|
$suffix = "";
|
||||||
|
$count = 0;
|
||||||
|
foreach ($file_attachments as $file_attachment) {
|
||||||
|
if ($this->app->erp->GetDateiEndung($file_attachment) == 'pdf') {
|
||||||
|
$file_contents = $this->app->erp->GetDatei($file_attachment);
|
||||||
|
$file_name = filter_var($beleg['belegnr'],FILTER_SANITIZE_EMAIL).$suffix.".pdf";
|
||||||
|
$zip->addFromString($typ['typ']."/".$file_name, $file_contents);
|
||||||
|
$count++;
|
||||||
|
$suffix = "_".$count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
|
// download
|
||||||
|
header('Content-Type: application/zip');
|
||||||
|
header("Content-Disposition: attachment; filename=$dateinamezip");
|
||||||
|
header('Content-Length: ' . filesize($dateinamezip));
|
||||||
|
|
||||||
|
readfile($dateinamezip);
|
||||||
|
unlink($dateinamezip);
|
||||||
|
} else {
|
||||||
|
header("Content-Disposition: attachment; filename=" . $filename_csv);
|
||||||
|
header("Pragma: no-cache");
|
||||||
|
header("Expires: 0");
|
||||||
|
echo($csv);
|
||||||
|
}
|
||||||
$this->app->ExitXentral();
|
$this->app->ExitXentral();
|
||||||
}
|
}
|
||||||
catch (ConsistencyException $e) {
|
catch (ConsistencyException $e) {
|
||||||
@ -204,6 +365,7 @@ class Exportbuchhaltung
|
|||||||
$this->app->Tpl->SET('VBCHECKED',$vbchecked?'checked':'');
|
$this->app->Tpl->SET('VBCHECKED',$vbchecked?'checked':'');
|
||||||
$this->app->Tpl->SET('LGCHECKED',$lgchecked?'checked':'');
|
$this->app->Tpl->SET('LGCHECKED',$lgchecked?'checked':'');
|
||||||
$this->app->Tpl->SET('DIFFIGNORE',$diffignore?'checked':'');
|
$this->app->Tpl->SET('DIFFIGNORE',$diffignore?'checked':'');
|
||||||
|
$this->app->Tpl->SET('PDFEXPORT',$pdfexport?'checked':'');
|
||||||
|
|
||||||
$this->app->Tpl->SET('VON', $von_form);
|
$this->app->Tpl->SET('VON', $von_form);
|
||||||
$this->app->Tpl->SET('BIS', $bis_form);
|
$this->app->Tpl->SET('BIS', $bis_form);
|
||||||
@ -444,90 +606,13 @@ class Exportbuchhaltung
|
|||||||
$csv .= "\r\n";
|
$csv .= "\r\n";
|
||||||
|
|
||||||
// Collate data and transform in RAM
|
// Collate data and transform in RAM
|
||||||
$typen = array(
|
$typen = $this->typen($rechnung, $gutschrift, $verbindlichkeit, $lieferantengutschrift);
|
||||||
array(
|
|
||||||
'typ' => 'rechnung',
|
|
||||||
'subtable' => 'rechnung_position',
|
|
||||||
'kennzeichen' => 'S',
|
|
||||||
'kennzeichen_negativ' => 'H',
|
|
||||||
'field_belegnr' => 'b.belegnr',
|
|
||||||
'field_name' => 'b.name',
|
|
||||||
'field_date' => 'datum',
|
|
||||||
'field_auftrag' => 'MAKE_SET(3,b.auftrag,(SELECT auftrag.internet FROM auftrag WHERE auftrag.id = auftragid))',
|
|
||||||
'field_zahlweise' => 'CONCAT(UCASE(LEFT(b.zahlungsweise, 1)),SUBSTRING(b.zahlungsweise, 2))',
|
|
||||||
'field_kontonummer' => 'a.kundennummer_buchhaltung',
|
|
||||||
'field_kundennummer' => 'b.kundennummer',
|
|
||||||
'field_betrag_gesamt' => 'b.soll',
|
|
||||||
'field_betrag' => 'p.umsatz_brutto_gesamt',
|
|
||||||
'condition_where' => ' AND b.status IN (\'freigegeben\',\'versendet\',\'storniert\')',
|
|
||||||
'Buchungstyp' => 'SR',
|
|
||||||
'do' => $rechnung
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'typ' => 'gutschrift',
|
|
||||||
'subtable' => 'gutschrift_position',
|
|
||||||
'kennzeichen' => 'H',
|
|
||||||
'kennzeichen_negativ' => 'S',
|
|
||||||
'field_belegnr' => 'b.belegnr',
|
|
||||||
'field_name' => 'b.name',
|
|
||||||
'field_date' => 'datum',
|
|
||||||
'field_auftrag' => '\'\'',
|
|
||||||
'field_zahlweise' => '\'\'',
|
|
||||||
'field_kontonummer' => 'a.kundennummer_buchhaltung',
|
|
||||||
'field_kundennummer' => 'b.kundennummer',
|
|
||||||
'field_betrag_gesamt' => 'b.soll',
|
|
||||||
'field_betrag' => 'p.umsatz_brutto_gesamt',
|
|
||||||
'condition_where' => ' AND b.status IN (\'freigegeben\',\'versendet\')',
|
|
||||||
'Buchungstyp' => '',
|
|
||||||
'do' => $gutschrift
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'typ' => 'verbindlichkeit',
|
|
||||||
'subtable' => 'verbindlichkeit_position',
|
|
||||||
'kennzeichen' => 'H',
|
|
||||||
'kennzeichen_negativ' => 'S',
|
|
||||||
'field_belegnr' => 'b.rechnung',
|
|
||||||
'field_name' => 'a.name',
|
|
||||||
'field_date' => 'rechnungsdatum',
|
|
||||||
'field_auftrag' => 'b.auftrag',
|
|
||||||
'field_zahlweise' => '\'\'',
|
|
||||||
'field_kontonummer' => 'a.lieferantennummer_buchhaltung',
|
|
||||||
'field_kundennummer' => 'a.lieferantennummer',
|
|
||||||
'field_betrag_gesamt' => 'b.betrag',
|
|
||||||
'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
|
|
||||||
'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
|
|
||||||
'condition_where' => ' AND b.status IN (\'freigegeben\')',
|
|
||||||
'Buchungstyp' => '',
|
|
||||||
'do' => $verbindlichkeit
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'typ' => 'lieferantengutschrift',
|
|
||||||
'subtable' => 'lieferantengutschrift_position',
|
|
||||||
'kennzeichen' => 'S',
|
|
||||||
'kennzeichen_negativ' => 'H',
|
|
||||||
'field_belegnr' => 'b.rechnung',
|
|
||||||
'field_name' => 'a.name',
|
|
||||||
'field_date' => 'rechnungsdatum',
|
|
||||||
'field_auftrag' => '\'\'',
|
|
||||||
'field_zahlweise' => '\'\'',
|
|
||||||
'field_kontonummer' => 'a.lieferantennummer_buchhaltung',
|
|
||||||
'field_kundennummer' => 'a.lieferantennummer',
|
|
||||||
'field_betrag_gesamt' => 'b.betrag',
|
|
||||||
'field_betrag' => 'p.preis*p.menge*((100+p.steuersatz)/100)',
|
|
||||||
'field_gegenkonto' => '(SELECT sachkonto FROM kontorahmen k WHERE k.id = p.kontorahmen)',
|
|
||||||
'condition_where' => ' AND b.status IN (\'freigegeben\')',
|
|
||||||
'Buchungstyp' => '',
|
|
||||||
'do' => $lieferantengutschrift
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($typen as $typ) {
|
foreach ($typen as $typ) {
|
||||||
|
|
||||||
if (!$typ['do']) {
|
if (!$typ['do']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!empty($typ['field_gegenkonto'])) {
|
if (!empty($typ['field_gegenkonto'])) {
|
||||||
$sql_gegenkonto = $typ['field_gegenkonto'];
|
$sql_gegenkonto = $typ['field_gegenkonto'];
|
||||||
} else
|
} else
|
||||||
|
Loading…
Reference in New Issue
Block a user