1 #=====================================================================
6 # Email: p.reetz@linet-services.de
7 # Web: http://www.lx-office.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #======================================================================
26 #======================================================================
28 use POSIX qw(strftime getcwd);
29 use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
38 sub continue { &{ $form->{nextsub} } }
41 $lxdebug->enter_sub();
43 $form->{title} = $locale->text("DATEX - Export Assistent");
45 DATEV->get_datev_stamm(\%myconfig, \%$form);
51 <form method=post action=$form->{script}>
56 <th class=listtop>$form->{title}</th>
59 <th align=left>| . $locale->text("DATEV Angaben") . qq|</th>
66 <td align=left nowrap>| . $locale->text("Beraternummer") . qq|</td>
67 <td><input name=beraternr size=10 maxlength=7 value="$form->{beraternr}"></td>
69 <td align=left nowrap>| . $locale->text("DFV-Kennzeichen") . qq|</td>
70 <td><input name=dfvkz size=5 maxlength=2 value="$form->{dfvkz}"></td>
73 <td align=left nowrap>| . $locale->text("Beratername") . qq|</td>
74 <td><input name=beratername size=10 maxlength=9 value="$form->{beratername}"></td>
76 <td align=left nowrap>| . $locale->text("Password") . qq|</td>
77 <td><input name=passwort size=5 maxlength=4 value="$form->{passwort}"></td>
80 <td align=left nowrap>| . $locale->text("Mandantennummer") . qq|</td>
81 <td><input name=mandantennr size=10 maxlength=5 value="$form->{mandantennr}"></td>
83 <td align=left nowrap>| . $locale->text("Datenträgernummer") . qq|</td>
84 <td><input name=datentraegernr size=5 maxlength=3 value="$form->{datentraegernr}"></td>
87 | . # OBE-Export noch nicht implementiert! <td><input checked name=kne type=checkbox class=checkbox value=1> | . $locale->text("Kontonummernerweiterung (KNE)") . qq|</td>
88 qq|<td><input type="hidden" name="kne" value="1"></td>
91 <td align=left nowrap>| . $locale->text("Abrechnungsnummer") . qq|</td>
92 <td><input name=abrechnungsnr size=5 maxlength=3 value="$form->{abrechnungsnr}"></td>
96 <td><input name=exporttype type=radio class=radio value=0 checked> |
97 . $locale->text("Export Buchungsdaten") . qq|</td>
100 <td><input name=exporttype type=radio class=radio value=1> |
101 . $locale->text("Export Stammdaten") . qq|</td>
108 <td><hr size=3 noshade></td>
112 <input type=hidden name=nextsub value=export2>
114 <input type=hidden name=path value=$form->{path}>
115 <input type=hidden name=login value=$form->{login}>
116 <input type=hidden name=password value=$form->{password}>
119 <input type=submit class=submit name=action value="|
120 . $locale->text('Continue') . qq|">
126 $lxdebug->leave_sub();
130 $lxdebug->enter_sub();
132 if ($form->{exporttype} == 0) {
133 &export_bewegungsdaten();
135 &export_stammdaten();
137 $lxdebug->leave_sub();
140 sub export_bewegungsdaten {
141 $lxdebug->enter_sub();
143 $form->{title} = $locale->text("DATEX - Export Assistent");
145 $form->{allemonate} =
147 . $locale->text('January')
150 . $locale->text('February') . qq|</option>
152 . $locale->text('March') . qq|</option>
154 . $locale->text('April') . qq|</option>
156 . $locale->text('May') . qq|</option>
158 . $locale->text('June') . qq|</option>
160 . $locale->text('July') . qq|</option>
162 . $locale->text('August') . qq|</option>
164 . $locale->text('September') . qq|</option>
166 . $locale->text('October') . qq|</option>
168 . $locale->text('November') . qq|</option>
170 . $locale->text('December') . qq|</option>|;
172 $form->{allequartale} =
173 qq|<option selected value=1>|
176 <option value=2>| . $locale->text('II') . qq|</option>
178 . $locale->text('III') . qq|</option>
180 . $locale->text('IV') . qq|</option>|;
186 <form method=post action=$form->{script}>
191 <th class=listtop>$form->{title}</th>
194 <th align=left>| . $locale->text("Zeitraum") . qq|</th>
201 <td align=left><input checked name=zeitraum class=radio type=radio value=monat> </td><td align=left>|
202 . $locale->text('Monat') . qq|</td>
205 <td align=left><select name=monat>$form->{allemonate}</select></td>
208 <td align=left><input name=zeitraum class=radio type=radio value=quartal> </td><td align=left>|
209 . $locale->text('Quartal') . qq|</td>
212 <td align=left><select name=quartal>$form->{allequartale}</select></td>
215 <td align=left><input name=zeitraum class=radio type=radio value=zeit> </td><td align=left>|
216 . $locale->text('Datum von') . qq|</td>
217 <td align=left><input name=transdatefrom size=8></td>
218 <td align=left>| . $locale->text('bis') . qq|</td>
219 <td align=left><input name=transdateto size=8></td>
225 <td><hr size=3 noshade></td>
229 <input type=hidden name=beraternr value="$form->{beraternr}">
230 <input type=hidden name=dfvkz value="$form->{dfvkz}">
231 <input type=hidden name=beratername value="$form->{beratername}">
232 <input type=hidden name=passwort value="$form->{passwort}">
233 <input type=hidden name=mandantennr value="$form->{mandantennr}">
234 <input type=hidden name=datentraegernr value="$form->{datentraegernr}">
235 <input type=hidden name=kne value="$form->{kne}">
236 <input type=hidden name=abrechnungsnr value="$form->{abrechnungsnr}">
238 <input type=hidden name=exporttype value="$form->{exporttype}">
240 <input type=hidden name=nextsub value=export3>
242 <input type=hidden name=path value=$form->{path}>
243 <input type=hidden name=login value=$form->{login}>
244 <input type=hidden name=password value=$form->{password}>
247 <input type=submit class=submit name=action value="|
248 . $locale->text('Continue') . qq|">
255 $lxdebug->leave_sub();
258 sub export_stammdaten {
259 $lxdebug->enter_sub();
261 $form->{title} = $locale->text("DATEX - Export Assistent");
268 <form method=post action=$form->{script}>
271 <th class=listtop>$form->{title}</th>
274 <th align=left>| . $locale->text("Konten") . qq|</th>
281 <td align=left>| . $locale->text('Von Konto: ') . qq|</td>
282 <td align=left><input name=accnofrom size=8 maxlength=8></td>
285 <td align=left>| . $locale->text('Bis Konto: ') . qq|</td>
286 <td align=left><input name=accnoto size=8 maxlength=8></td>
292 <td><hr size=3 noshade></td>
295 <input type=hidden name=beraternr value="$form->{beraternr}">
296 <input type=hidden name=dfvkz value="$form->{dfvkz}">
297 <input type=hidden name=beratername value="$form->{beratername}">
298 <input type=hidden name=passwort value="$form->{passwort}">
299 <input type=hidden name=mandantennr value="$form->{mandantennr}">
300 <input type=hidden name=datentraegernr value="$form->{datentraegernr}">
301 <input type=hidden name=kne value="$form->{kne}">
302 <input type=hidden name=abrechnungsnr value="$form->{abrechnungsnr}">
304 <input type=hidden name=exporttype value="$form->{exporttype}">
306 <input type=hidden name=nextsub value=export3>
308 <input type=hidden name=path value=$form->{path}>
309 <input type=hidden name=login value=$form->{login}>
310 <input type=hidden name=password value=$form->{password}>
313 <input type=submit class=submit name=action value="|
314 . $locale->text('Continue') . qq|">
321 $lxdebug->leave_sub();
325 $lxdebug->enter_sub();
327 DATEV->save_datev_stamm(\%myconfig, \%$form);
329 my $link = $form->{"script"} . "?";
330 map({ $link .= "${_}=" . $form->escape($form->{$_}) . "&"; } qw(path login password));
331 $link .= "action=download";
334 my @filenames = DATEV->kne_export(\%myconfig, \%$form);
336 print(qq|<br><b>| . $locale->text('KNE-Export erfolgreich!') . qq|</b><br>|);
337 $link .= "&filenames=" . $form->escape(join(":", @filenames));
338 print(qq|<br><a href="$link">Download</a>|);
340 $form->error("KNE-Export schlug fehl.");
343 my @filenames = DATEV->obe_export(\%myconfig, \%$form);
345 print(qq|<br><b>| . $locale->text('OBE-Export erfolgreich!') . qq|</b><br>|);
346 $link .= "&filenames=" . $form->escape(join(":", @filenames));
347 print(qq|<br><a href="$link">Download</a>|);
349 $form->error("OBE-Export schlug fehl.");
353 print("</body></html>");
355 $lxdebug->leave_sub();
359 $lxdebug->enter_sub();
361 my $tmp_name = Common->tmpname();
362 my $zip_name = strftime("lx-office-datev-export-%Y%m%d.zip",
366 chdir("users") || die("chdir users");
368 my @filenames = split(/:/, $form->{"filenames"});
369 map({ s|.*/||; $form->error("Eine der KNE-Exportdateien wurde nicht " .
370 "gefunden. Wurde der Export bereits " .
371 "durchgeführt?") unless (-f $_); }
374 my $zip = Archive::Zip->new();
375 map({ $zip->addFile($_); } @filenames);
376 $zip->writeToFileNamed($tmp_name);
379 open(IN, $tmp_name) || die("open $tmp_name");
380 print("Content-Type: application/zip\n");
381 print("Content-Disposition: attachment; filename=\"${zip_name}\"\n\n");
389 $lxdebug->leave_sub();