kivitendo/bin/mozilla/datev.pl @ 474247d8
d319704a | Moritz Bunkus | #=====================================================================
|
||
# Lx-Office ERP
|
||||
# Copyright (c) 2004
|
||||
#
|
||||
# Author: Philip Reetz
|
||||
# Email: p.reetz@linet-services.de
|
||||
# Web: http://www.lx-office.org
|
||||
#
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#======================================================================
|
||||
#
|
||||
# Datev export module
|
||||
#
|
||||
#======================================================================
|
||||
39f3d12c | Moritz Bunkus | use POSIX qw(strftime getcwd);
|
||
use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
|
||||
use SL::Common;
|
||||
d319704a | Moritz Bunkus | use SL::DATEV;
|
||
27309ff1 | Sven Schöling | use strict;
|
||
d319704a | Moritz Bunkus | 1;
|
||
# end of main
|
||||
40782548 | Moritz Bunkus | require "bin/mozilla/common.pl";
|
||
27309ff1 | Sven Schöling | sub continue { call_sub($main::form->{"nextsub"}); }
|
||
d319704a | Moritz Bunkus | |||
sub export {
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->enter_sub();
|
||
my $form = $main::form;
|
||||
my %myconfig = %main::myconfig;
|
||||
my $locale = $main::locale;
|
||||
d319704a | Moritz Bunkus | |||
27309ff1 | Sven Schöling | $main::auth->assert('datev_export');
|
||
8c7e4493 | Moritz Bunkus | |||
d319704a | Moritz Bunkus | $form->{title} = $locale->text("DATEX - Export Assistent");
|
||
DATEV->get_datev_stamm(\%myconfig, \%$form);
|
||||
$form->header;
|
||||
print qq|
|
||||
<body>
|
||||
<form method=post action=$form->{script}>
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<th class=listtop>$form->{title}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>| . $locale->text("DATEV Angaben") . qq|</th>
|
||||
</tr>
|
||||
<tr height="5"></tr>
|
||||
<tr valign=top>
|
||||
<td>
|
||||
<table>
|
||||
b65a230d | Sven Schöling | <tr>
|
||
<td align=left nowrap>| . $locale->text("Beraternummer") . qq|</td>
|
||||
<td><input name=beraternr size=10 maxlength=7 value="$form->{beraternr}"></td>
|
||||
<td align=left nowrap>| . $locale->text("DFV-Kennzeichen") . qq|</td>
|
||||
<td><input name=dfvkz size=5 maxlength=2 value="$form->{dfvkz}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=left nowrap>| . $locale->text("Beratername") . qq|</td>
|
||||
<td><input name=beratername size=10 maxlength=9 value="$form->{beratername}"></td>
|
||||
<td align=left nowrap>| . $locale->text("Password") . qq|</td>
|
||||
<td><input name=passwort size=5 maxlength=4 value="$form->{passwort}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=left nowrap>| . $locale->text("Mandantennummer") . qq|</td>
|
||||
<td><input name=mandantennr size=10 maxlength=5 value="$form->{mandantennr}"></td>
|
||||
<td align=left nowrap>| . $locale->text("Medium Number") . qq|</td>
|
||||
<td><input name=datentraegernr size=5 maxlength=3 value="$form->{datentraegernr}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
| . # OBE-Export noch nicht implementiert! <td><input checked name=kne type=checkbox class=checkbox value=1> | . $locale->text("Kontonummernerweiterung (KNE)") . qq|</td>
|
||||
39f3d12c | Moritz Bunkus | qq|<td><input type="hidden" name="kne" value="1"></td>
|
||
d319704a | Moritz Bunkus | <td></td>
|
||
0576299f | Moritz Bunkus | |||
b65a230d | Sven Schöling | <td align=left nowrap>| . $locale->text("Abrechnungsnummer") . qq|</td>
|
||
<td><input name=abrechnungsnr size=5 maxlength=3 value="$form->{abrechnungsnr}"></td>
|
||||
</tr>
|
||||
39f3d12c | Moritz Bunkus | |||
d319704a | Moritz Bunkus | <tr>
|
||
<td><input name=exporttype type=radio class=radio value=0 checked> |
|
||||
081a4f97 | Moritz Bunkus | . $locale->text("Export Buchungsdaten") . qq|</td>
|
||
d319704a | Moritz Bunkus | <td></td>
|
||
0576299f | Moritz Bunkus | |||
b65a230d | Sven Schöling | <td><input name=exporttype type=radio class=radio value=1> |
|
||
081a4f97 | Moritz Bunkus | . $locale->text("Export Stammdaten") . qq|</td>
|
||
d319704a | Moritz Bunkus | <td></td>
|
||
b65a230d | Sven Schöling | </td>
|
||
d319704a | Moritz Bunkus | </table>
|
||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><hr size=3 noshade></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type=hidden name=nextsub value=export2>
|
||||
<br>
|
||||
<input type=submit class=submit name=action value="|
|
||||
. $locale->text('Continue') . qq|">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|;
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->leave_sub();
|
||
d319704a | Moritz Bunkus | }
|
||
sub export2 {
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->enter_sub();
|
||
d319704a | Moritz Bunkus | |||
27309ff1 | Sven Schöling | my $form = $main::form;
|
||
$main::auth->assert('datev_export');
|
||||
8c7e4493 | Moritz Bunkus | |||
d319704a | Moritz Bunkus | if ($form->{exporttype} == 0) {
|
||
&export_bewegungsdaten();
|
||||
} else {
|
||||
&export_stammdaten();
|
||||
}
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->leave_sub();
|
||
d319704a | Moritz Bunkus | }
|
||
sub export_bewegungsdaten {
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->enter_sub();
|
||
my $form = $main::form;
|
||||
my %myconfig = %main::myconfig;
|
||||
my $locale = $main::locale;
|
||||
d319704a | Moritz Bunkus | |||
27309ff1 | Sven Schöling | $main::auth->assert('datev_export');
|
||
8c7e4493 | Moritz Bunkus | |||
d319704a | Moritz Bunkus | $form->{title} = $locale->text("DATEX - Export Assistent");
|
||
$form->{allemonate} =
|
||||
qq|<option value=1>|
|
||||
. $locale->text('January')
|
||||
. qq|</option>
|
||||
<option value=2>|
|
||||
081a4f97 | Moritz Bunkus | . $locale->text('February') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=3>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('March') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=4>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('April') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=5>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('May') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=6>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('June') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=7>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('July') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=8>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('August') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=9>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('September') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=10>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('October') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=11>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('November') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=12>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('December') . qq|</option>|;
|
||
d319704a | Moritz Bunkus | |||
$form->{allequartale} =
|
||||
qq|<option selected value=1>|
|
||||
. $locale->text('I')
|
||||
. qq|</option>
|
||||
<option value=2>| . $locale->text('II') . qq|</option>
|
||||
<option value=3>|
|
||||
081a4f97 | Moritz Bunkus | . $locale->text('III') . qq|</option>
|
||
d319704a | Moritz Bunkus | <option value=4>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('IV') . qq|</option>|;
|
||
a14a3ff5 | Moritz Bunkus | $form->{"jsscript"} = 1;
|
||
d319704a | Moritz Bunkus | $form->header;
|
||
print qq|
|
||||
<body>
|
||||
<form method=post action=$form->{script}>
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<th class=listtop>$form->{title}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>| . $locale->text("Zeitraum") . qq|</th>
|
||||
</tr>
|
||||
<tr height="5"></tr>
|
||||
<tr valign=top>
|
||||
<td>
|
||||
<table>
|
||||
b65a230d | Sven Schöling | <tr>
|
||
d319704a | Moritz Bunkus | <td align=left><input checked name=zeitraum class=radio type=radio value=monat> </td><td align=left>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('Monat') . qq|</td>
|
||
d319704a | Moritz Bunkus | <td align=left></td>
|
||
b65a230d | Sven Schöling | <td align=left></td>
|
||
d319704a | Moritz Bunkus | <td align=left><select name=monat>$form->{allemonate}</select></td>
|
||
</tr>
|
||||
0576299f | Moritz Bunkus | <tr>
|
||
d319704a | Moritz Bunkus | <td align=left><input name=zeitraum class=radio type=radio value=quartal> </td><td align=left>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('Quartal') . qq|</td>
|
||
b65a230d | Sven Schöling | <td align=left></td>
|
||
d319704a | Moritz Bunkus | <td align=left></td>
|
||
<td align=left><select name=quartal>$form->{allequartale}</select></td>
|
||||
</tr>
|
||||
0576299f | Moritz Bunkus | <tr>
|
||
d319704a | Moritz Bunkus | <td align=left><input name=zeitraum class=radio type=radio value=zeit> </td><td align=left>|
|
||
081a4f97 | Moritz Bunkus | . $locale->text('Datum von') . qq|</td>
|
||
a14a3ff5 | Moritz Bunkus | <td align=left><input id=transdatefrom name=transdatefrom size=10>
|
||
<input type="button" name="transdatefrom" id="trigger_transdatefrom" value="?"></td>
|
||||
b65a230d | Sven Schöling | <td align=left>| . $locale->text('bis') . qq|</td>
|
||
a14a3ff5 | Moritz Bunkus | <td align=left><input id=transdateto name=transdateto size=10>
|
||
<input type="button" name="transdateto" id="trigger_transdateto" value="?"></td>
|
||||
b65a230d | Sven Schöling | </tr>
|
||
d319704a | Moritz Bunkus | </table>
|
||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><hr size=3 noshade></td>
|
||||
</tr>
|
||||
</table>
|
||||
a14a3ff5 | Moritz Bunkus | | . $form->write_trigger(\%myconfig, 2,
|
||
"transdatefrom", "BL", "trigger_transdatefrom",
|
||||
"transdateto", "BL", "trigger_transdateto") . qq|
|
||||
d319704a | Moritz Bunkus | <input type=hidden name=beraternr value="$form->{beraternr}">
|
||
<input type=hidden name=dfvkz value="$form->{dfvkz}">
|
||||
<input type=hidden name=beratername value="$form->{beratername}">
|
||||
<input type=hidden name=passwort value="$form->{passwort}">
|
||||
<input type=hidden name=mandantennr value="$form->{mandantennr}">
|
||||
<input type=hidden name=datentraegernr value="$form->{datentraegernr}">
|
||||
<input type=hidden name=kne value="$form->{kne}">
|
||||
<input type=hidden name=abrechnungsnr value="$form->{abrechnungsnr}">
|
||||
<input type=hidden name=exporttype value="$form->{exporttype}">
|
||||
<input type=hidden name=nextsub value=export3>
|
||||
<br>
|
||||
<input type=submit class=submit name=action value="|
|
||||
. $locale->text('Continue') . qq|">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|;
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->leave_sub();
|
||
d319704a | Moritz Bunkus | }
|
||
sub export_stammdaten {
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->enter_sub();
|
||
d319704a | Moritz Bunkus | |||
27309ff1 | Sven Schöling | my $form = $main::form;
|
||
my $locale = $main::locale;
|
||||
$main::auth->assert('datev_export');
|
||||
8c7e4493 | Moritz Bunkus | |||
d319704a | Moritz Bunkus | $form->{title} = $locale->text("DATEX - Export Assistent");
|
||
$form->header;
|
||||
print qq|
|
||||
<body>
|
||||
<form method=post action=$form->{script}>
|
||||
<table width=100%>
|
||||
<tr>
|
||||
<th class=listtop>$form->{title}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>| . $locale->text("Konten") . qq|</th>
|
||||
</tr>
|
||||
<tr height="5"></tr>
|
||||
<tr valign=top>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
b65a230d | Sven Schöling | <td align=left>| . $locale->text('Von Konto: ') . qq|</td>
|
||
d319704a | Moritz Bunkus | <td align=left><input name=accnofrom size=8 maxlength=8></td>
|
||
</tr>
|
||||
<tr>
|
||||
b65a230d | Sven Schöling | <td align=left>| . $locale->text('Bis Konto: ') . qq|</td>
|
||
d319704a | Moritz Bunkus | <td align=left><input name=accnoto size=8 maxlength=8></td>
|
||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><hr size=3 noshade></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type=hidden name=beraternr value="$form->{beraternr}">
|
||||
<input type=hidden name=dfvkz value="$form->{dfvkz}">
|
||||
<input type=hidden name=beratername value="$form->{beratername}">
|
||||
<input type=hidden name=passwort value="$form->{passwort}">
|
||||
<input type=hidden name=mandantennr value="$form->{mandantennr}">
|
||||
<input type=hidden name=datentraegernr value="$form->{datentraegernr}">
|
||||
<input type=hidden name=kne value="$form->{kne}">
|
||||
<input type=hidden name=abrechnungsnr value="$form->{abrechnungsnr}">
|
||||
<input type=hidden name=exporttype value="$form->{exporttype}">
|
||||
<input type=hidden name=nextsub value=export3>
|
||||
<br>
|
||||
<input type=submit class=submit name=action value="|
|
||||
. $locale->text('Continue') . qq|">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|;
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->leave_sub();
|
||
d319704a | Moritz Bunkus | }
|
||
sub export3 {
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->enter_sub();
|
||
my $form = $main::form;
|
||||
my %myconfig = %main::myconfig;
|
||||
my $locale = $main::locale;
|
||||
d319704a | Moritz Bunkus | |||
27309ff1 | Sven Schöling | $main::auth->assert('datev_export');
|
||
8c7e4493 | Moritz Bunkus | |||
f8138d17 | Moritz Bunkus | DATEV::clean_temporary_directories();
|
||
d319704a | Moritz Bunkus | DATEV->save_datev_stamm(\%myconfig, \%$form);
|
||
f8138d17 | Moritz Bunkus | my $link = "datev.pl?action=download&download_token=";
|
||
39f3d12c | Moritz Bunkus | |||
d319704a | Moritz Bunkus | if ($form->{kne}) {
|
||
f8138d17 | Moritz Bunkus | my $result = DATEV->kne_export(\%myconfig, \%$form);
|
||
if ($result && @{ $result->{filenames} }) {
|
||||
$link .= Q($result->{download_token});
|
||||
print(qq|<br><b>| . $locale->text('KNE-Export erfolgreich!') . qq|</b><br><br><a href="$link">Download</a>|);
|
||||
39f3d12c | Moritz Bunkus | } else {
|
||
$form->error("KNE-Export schlug fehl.");
|
||||
d319704a | Moritz Bunkus | }
|
||
} else {
|
||||
f8138d17 | Moritz Bunkus | # OBE-Export nicht implementiert.
|
||
# my @filenames = DATEV->obe_export(\%myconfig, \%$form);
|
||||
# if (@filenames) {
|
||||
# print(qq|<br><b>| . $locale->text('OBE-Export erfolgreich!') . qq|</b><br>|);
|
||||
# $link .= "&filenames=" . $form->escape(join(":", @filenames));
|
||||
# print(qq|<br><a href="$link">Download</a>|);
|
||||
# } else {
|
||||
# $form->error("OBE-Export schlug fehl.");
|
||||
# }
|
||||
d319704a | Moritz Bunkus | }
|
||
39f3d12c | Moritz Bunkus | |||
print("</body></html>");
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->leave_sub();
|
||
39f3d12c | Moritz Bunkus | }
|
||
sub download {
|
||||
27309ff1 | Sven Schöling | $main::lxdebug->enter_sub();
|
||
my $form = $main::form;
|
||||
my $locale = $main::locale;
|
||||
39f3d12c | Moritz Bunkus | |||
27309ff1 | Sven Schöling | $main::auth->assert('datev_export');
|
||
8c7e4493 | Moritz Bunkus | |||
39f3d12c | Moritz Bunkus | my $tmp_name = Common->tmpname();
|
||
f8138d17 | Moritz Bunkus | my $zip_name = strftime("lx-office-datev-export-%Y%m%d.zip", localtime(time()));
|
||
39f3d12c | Moritz Bunkus | |||
my $cwd = getcwd();
|
||||
f8138d17 | Moritz Bunkus | my $path = DATEV::get_path_for_download_token($form->{download_token});
|
||
if (!$path) {
|
||||
$form->error($locale->text("Your download does not exist anymore. Please re-run the DATEV export assistant."));
|
||||
}
|
||||
chdir($path) || die("chdir $path");
|
||||
my @filenames = glob "*";
|
||||
if (!@filenames) {
|
||||
chdir($cwd);
|
||||
DATEV::clean_temporary_directories();
|
||||
$form->error($locale->text("Your download does not exist anymore. Please re-run the DATEV export assistant."));
|
||||
}
|
||||
39f3d12c | Moritz Bunkus | |||
my $zip = Archive::Zip->new();
|
||||
f8138d17 | Moritz Bunkus | map { $zip->addFile($_); } @filenames;
|
||
39f3d12c | Moritz Bunkus | $zip->writeToFileNamed($tmp_name);
|
||
f8138d17 | Moritz Bunkus | |||
39f3d12c | Moritz Bunkus | chdir($cwd);
|
||
open(IN, $tmp_name) || die("open $tmp_name");
|
||||
print("Content-Type: application/zip\n");
|
||||
print("Content-Disposition: attachment; filename=\"${zip_name}\"\n\n");
|
||||
while (<IN>) {
|
||||
print($_);
|
||||
}
|
||||
close(IN);
|
||||
unlink($tmp_name);
|
||||
f8138d17 | Moritz Bunkus | DATEV::clean_temporary_directories();
|
||
27309ff1 | Sven Schöling | $main::lxdebug->leave_sub();
|
||
d319704a | Moritz Bunkus | }
|