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 require "bin/mozilla/common.pl";
40 sub continue { call_sub($form->{"nextsub"}); }
43 $lxdebug->enter_sub();
45 $form->{title} = $locale->text("DATEX - Export Assistent");
47 DATEV->get_datev_stamm(\%myconfig, \%$form);
53 <form method=post action=$form->{script}>
58 <th class=listtop>$form->{title}</th>
61 <th align=left>| . $locale->text("DATEV Angaben") . qq|</th>
68 <td align=left nowrap>| . $locale->text("Beraternummer") . qq|</td>
69 <td><input name=beraternr size=10 maxlength=7 value="$form->{beraternr}"></td>
71 <td align=left nowrap>| . $locale->text("DFV-Kennzeichen") . qq|</td>
72 <td><input name=dfvkz size=5 maxlength=2 value="$form->{dfvkz}"></td>
75 <td align=left nowrap>| . $locale->text("Beratername") . qq|</td>
76 <td><input name=beratername size=10 maxlength=9 value="$form->{beratername}"></td>
78 <td align=left nowrap>| . $locale->text("Password") . qq|</td>
79 <td><input name=passwort size=5 maxlength=4 value="$form->{passwort}"></td>
82 <td align=left nowrap>| . $locale->text("Mandantennummer") . qq|</td>
83 <td><input name=mandantennr size=10 maxlength=5 value="$form->{mandantennr}"></td>
85 <td align=left nowrap>| . $locale->text("Datenträgernummer") . qq|</td>
86 <td><input name=datentraegernr size=5 maxlength=3 value="$form->{datentraegernr}"></td>
89 | . # OBE-Export noch nicht implementiert! <td><input checked name=kne type=checkbox class=checkbox value=1> | . $locale->text("Kontonummernerweiterung (KNE)") . qq|</td>
90 qq|<td><input type="hidden" name="kne" value="1"></td>
93 <td align=left nowrap>| . $locale->text("Abrechnungsnummer") . qq|</td>
94 <td><input name=abrechnungsnr size=5 maxlength=3 value="$form->{abrechnungsnr}"></td>
98 <td><input name=exporttype type=radio class=radio value=0 checked> |
99 . $locale->text("Export Buchungsdaten") . qq|</td>
102 <td><input name=exporttype type=radio class=radio value=1> |
103 . $locale->text("Export Stammdaten") . qq|</td>
110 <td><hr size=3 noshade></td>
114 <input type=hidden name=nextsub value=export2>
116 <input type=hidden name=login value=$form->{login}>
117 <input type=hidden name=password value=$form->{password}>
120 <input type=submit class=submit name=action value="|
121 . $locale->text('Continue') . qq|">
127 $lxdebug->leave_sub();
131 $lxdebug->enter_sub();
133 if ($form->{exporttype} == 0) {
134 &export_bewegungsdaten();
136 &export_stammdaten();
138 $lxdebug->leave_sub();
141 sub export_bewegungsdaten {
142 $lxdebug->enter_sub();
144 $form->{title} = $locale->text("DATEX - Export Assistent");
146 $form->{allemonate} =
148 . $locale->text('January')
151 . $locale->text('February') . qq|</option>
153 . $locale->text('March') . qq|</option>
155 . $locale->text('April') . qq|</option>
157 . $locale->text('May') . qq|</option>
159 . $locale->text('June') . qq|</option>
161 . $locale->text('July') . qq|</option>
163 . $locale->text('August') . qq|</option>
165 . $locale->text('September') . qq|</option>
167 . $locale->text('October') . qq|</option>
169 . $locale->text('November') . qq|</option>
171 . $locale->text('December') . qq|</option>|;
173 $form->{allequartale} =
174 qq|<option selected value=1>|
177 <option value=2>| . $locale->text('II') . qq|</option>
179 . $locale->text('III') . qq|</option>
181 . $locale->text('IV') . qq|</option>|;
182 $form->{"jsscript"} = 1;
188 <form method=post action=$form->{script}>
193 <th class=listtop>$form->{title}</th>
196 <th align=left>| . $locale->text("Zeitraum") . qq|</th>
203 <td align=left><input checked name=zeitraum class=radio type=radio value=monat> </td><td align=left>|
204 . $locale->text('Monat') . qq|</td>
207 <td align=left><select name=monat>$form->{allemonate}</select></td>
210 <td align=left><input name=zeitraum class=radio type=radio value=quartal> </td><td align=left>|
211 . $locale->text('Quartal') . qq|</td>
214 <td align=left><select name=quartal>$form->{allequartale}</select></td>
217 <td align=left><input name=zeitraum class=radio type=radio value=zeit> </td><td align=left>|
218 . $locale->text('Datum von') . qq|</td>
219 <td align=left><input id=transdatefrom name=transdatefrom size=10>
220 <input type="button" name="transdatefrom" id="trigger_transdatefrom" value="?"></td>
221 <td align=left>| . $locale->text('bis') . qq|</td>
222 <td align=left><input id=transdateto name=transdateto size=10>
223 <input type="button" name="transdateto" id="trigger_transdateto" value="?"></td>
229 <td><hr size=3 noshade></td>
233 | . $form->write_trigger(\%myconfig, 2,
234 "transdatefrom", "BL", "trigger_transdatefrom",
235 "transdateto", "BL", "trigger_transdateto") . qq|
237 <input type=hidden name=beraternr value="$form->{beraternr}">
238 <input type=hidden name=dfvkz value="$form->{dfvkz}">
239 <input type=hidden name=beratername value="$form->{beratername}">
240 <input type=hidden name=passwort value="$form->{passwort}">
241 <input type=hidden name=mandantennr value="$form->{mandantennr}">
242 <input type=hidden name=datentraegernr value="$form->{datentraegernr}">
243 <input type=hidden name=kne value="$form->{kne}">
244 <input type=hidden name=abrechnungsnr value="$form->{abrechnungsnr}">
246 <input type=hidden name=exporttype value="$form->{exporttype}">
248 <input type=hidden name=nextsub value=export3>
250 <input type=hidden name=login value=$form->{login}>
251 <input type=hidden name=password value=$form->{password}>
254 <input type=submit class=submit name=action value="|
255 . $locale->text('Continue') . qq|">
262 $lxdebug->leave_sub();
265 sub export_stammdaten {
266 $lxdebug->enter_sub();
268 $form->{title} = $locale->text("DATEX - Export Assistent");
275 <form method=post action=$form->{script}>
278 <th class=listtop>$form->{title}</th>
281 <th align=left>| . $locale->text("Konten") . qq|</th>
288 <td align=left>| . $locale->text('Von Konto: ') . qq|</td>
289 <td align=left><input name=accnofrom size=8 maxlength=8></td>
292 <td align=left>| . $locale->text('Bis Konto: ') . qq|</td>
293 <td align=left><input name=accnoto size=8 maxlength=8></td>
299 <td><hr size=3 noshade></td>
302 <input type=hidden name=beraternr value="$form->{beraternr}">
303 <input type=hidden name=dfvkz value="$form->{dfvkz}">
304 <input type=hidden name=beratername value="$form->{beratername}">
305 <input type=hidden name=passwort value="$form->{passwort}">
306 <input type=hidden name=mandantennr value="$form->{mandantennr}">
307 <input type=hidden name=datentraegernr value="$form->{datentraegernr}">
308 <input type=hidden name=kne value="$form->{kne}">
309 <input type=hidden name=abrechnungsnr value="$form->{abrechnungsnr}">
311 <input type=hidden name=exporttype value="$form->{exporttype}">
313 <input type=hidden name=nextsub value=export3>
315 <input type=hidden name=login value=$form->{login}>
316 <input type=hidden name=password value=$form->{password}>
319 <input type=submit class=submit name=action value="|
320 . $locale->text('Continue') . qq|">
327 $lxdebug->leave_sub();
331 $lxdebug->enter_sub();
333 DATEV->save_datev_stamm(\%myconfig, \%$form);
335 my $link = $form->{"script"} . "?";
336 map({ $link .= "${_}=" . $form->escape($form->{$_}) . "&"; } qw(login password));
337 $link .= "action=download";
340 my @filenames = DATEV->kne_export(\%myconfig, \%$form);
342 print(qq|<br><b>| . $locale->text('KNE-Export erfolgreich!') . qq|</b><br>|);
343 $link .= "&filenames=" . $form->escape(join(":", @filenames));
344 print(qq|<br><a href="$link">Download</a>|);
346 $form->error("KNE-Export schlug fehl.");
349 my @filenames = DATEV->obe_export(\%myconfig, \%$form);
351 print(qq|<br><b>| . $locale->text('OBE-Export erfolgreich!') . qq|</b><br>|);
352 $link .= "&filenames=" . $form->escape(join(":", @filenames));
353 print(qq|<br><a href="$link">Download</a>|);
355 $form->error("OBE-Export schlug fehl.");
359 print("</body></html>");
361 $lxdebug->leave_sub();
365 $lxdebug->enter_sub();
367 my $tmp_name = Common->tmpname();
368 my $zip_name = strftime("lx-office-datev-export-%Y%m%d.zip",
372 chdir("users") || die("chdir users");
374 my @filenames = split(/:/, $form->{"filenames"});
375 map({ s|.*/||; $form->error("Eine der KNE-Exportdateien wurde nicht " .
376 "gefunden. Wurde der Export bereits " .
377 "durchgeführt?") unless (-f $_); }
380 my $zip = Archive::Zip->new();
381 map({ $zip->addFile($_); } @filenames);
382 $zip->writeToFileNamed($tmp_name);
385 open(IN, $tmp_name) || die("open $tmp_name");
386 print("Content-Type: application/zip\n");
387 print("Content-Disposition: attachment; filename=\"${zip_name}\"\n\n");
395 $lxdebug->leave_sub();