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 $auth->assert('datev_export');
47 $form->{title} = $locale->text("DATEX - Export Assistent");
49 DATEV->get_datev_stamm(\%myconfig, \%$form);
55 <form method=post action=$form->{script}>
60 <th class=listtop>$form->{title}</th>
63 <th align=left>| . $locale->text("DATEV Angaben") . qq|</th>
70 <td align=left nowrap>| . $locale->text("Beraternummer") . qq|</td>
71 <td><input name=beraternr size=10 maxlength=7 value="$form->{beraternr}"></td>
73 <td align=left nowrap>| . $locale->text("DFV-Kennzeichen") . qq|</td>
74 <td><input name=dfvkz size=5 maxlength=2 value="$form->{dfvkz}"></td>
77 <td align=left nowrap>| . $locale->text("Beratername") . qq|</td>
78 <td><input name=beratername size=10 maxlength=9 value="$form->{beratername}"></td>
80 <td align=left nowrap>| . $locale->text("Password") . qq|</td>
81 <td><input name=passwort size=5 maxlength=4 value="$form->{passwort}"></td>
84 <td align=left nowrap>| . $locale->text("Mandantennummer") . qq|</td>
85 <td><input name=mandantennr size=10 maxlength=5 value="$form->{mandantennr}"></td>
87 <td align=left nowrap>| . $locale->text("Medium Number") . qq|</td>
88 <td><input name=datentraegernr size=5 maxlength=3 value="$form->{datentraegernr}"></td>
91 | . # OBE-Export noch nicht implementiert! <td><input checked name=kne type=checkbox class=checkbox value=1> | . $locale->text("Kontonummernerweiterung (KNE)") . qq|</td>
92 qq|<td><input type="hidden" name="kne" value="1"></td>
95 <td align=left nowrap>| . $locale->text("Abrechnungsnummer") . qq|</td>
96 <td><input name=abrechnungsnr size=5 maxlength=3 value="$form->{abrechnungsnr}"></td>
100 <td><input name=exporttype type=radio class=radio value=0 checked> |
101 . $locale->text("Export Buchungsdaten") . qq|</td>
104 <td><input name=exporttype type=radio class=radio value=1> |
105 . $locale->text("Export Stammdaten") . qq|</td>
112 <td><hr size=3 noshade></td>
116 <input type=hidden name=nextsub value=export2>
119 <input type=submit class=submit name=action value="|
120 . $locale->text('Continue') . qq|">
126 $lxdebug->leave_sub();
130 $lxdebug->enter_sub();
132 $auth->assert('datev_export');
134 if ($form->{exporttype} == 0) {
135 &export_bewegungsdaten();
137 &export_stammdaten();
139 $lxdebug->leave_sub();
142 sub export_bewegungsdaten {
143 $lxdebug->enter_sub();
145 $auth->assert('datev_export');
147 $form->{title} = $locale->text("DATEX - Export Assistent");
149 $form->{allemonate} =
151 . $locale->text('January')
154 . $locale->text('February') . qq|</option>
156 . $locale->text('March') . qq|</option>
158 . $locale->text('April') . qq|</option>
160 . $locale->text('May') . qq|</option>
162 . $locale->text('June') . qq|</option>
164 . $locale->text('July') . qq|</option>
166 . $locale->text('August') . qq|</option>
168 . $locale->text('September') . qq|</option>
170 . $locale->text('October') . qq|</option>
172 . $locale->text('November') . qq|</option>
174 . $locale->text('December') . qq|</option>|;
176 $form->{allequartale} =
177 qq|<option selected value=1>|
180 <option value=2>| . $locale->text('II') . qq|</option>
182 . $locale->text('III') . qq|</option>
184 . $locale->text('IV') . qq|</option>|;
185 $form->{"jsscript"} = 1;
191 <form method=post action=$form->{script}>
196 <th class=listtop>$form->{title}</th>
199 <th align=left>| . $locale->text("Zeitraum") . qq|</th>
206 <td align=left><input checked name=zeitraum class=radio type=radio value=monat> </td><td align=left>|
207 . $locale->text('Monat') . qq|</td>
210 <td align=left><select name=monat>$form->{allemonate}</select></td>
213 <td align=left><input name=zeitraum class=radio type=radio value=quartal> </td><td align=left>|
214 . $locale->text('Quartal') . qq|</td>
217 <td align=left><select name=quartal>$form->{allequartale}</select></td>
220 <td align=left><input name=zeitraum class=radio type=radio value=zeit> </td><td align=left>|
221 . $locale->text('Datum von') . qq|</td>
222 <td align=left><input id=transdatefrom name=transdatefrom size=10>
223 <input type="button" name="transdatefrom" id="trigger_transdatefrom" value="?"></td>
224 <td align=left>| . $locale->text('bis') . qq|</td>
225 <td align=left><input id=transdateto name=transdateto size=10>
226 <input type="button" name="transdateto" id="trigger_transdateto" value="?"></td>
232 <td><hr size=3 noshade></td>
236 | . $form->write_trigger(\%myconfig, 2,
237 "transdatefrom", "BL", "trigger_transdatefrom",
238 "transdateto", "BL", "trigger_transdateto") . qq|
240 <input type=hidden name=beraternr value="$form->{beraternr}">
241 <input type=hidden name=dfvkz value="$form->{dfvkz}">
242 <input type=hidden name=beratername value="$form->{beratername}">
243 <input type=hidden name=passwort value="$form->{passwort}">
244 <input type=hidden name=mandantennr value="$form->{mandantennr}">
245 <input type=hidden name=datentraegernr value="$form->{datentraegernr}">
246 <input type=hidden name=kne value="$form->{kne}">
247 <input type=hidden name=abrechnungsnr value="$form->{abrechnungsnr}">
249 <input type=hidden name=exporttype value="$form->{exporttype}">
251 <input type=hidden name=nextsub value=export3>
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 $auth->assert('datev_export');
270 $form->{title} = $locale->text("DATEX - Export Assistent");
277 <form method=post action=$form->{script}>
280 <th class=listtop>$form->{title}</th>
283 <th align=left>| . $locale->text("Konten") . qq|</th>
290 <td align=left>| . $locale->text('Von Konto: ') . qq|</td>
291 <td align=left><input name=accnofrom size=8 maxlength=8></td>
294 <td align=left>| . $locale->text('Bis Konto: ') . qq|</td>
295 <td align=left><input name=accnoto size=8 maxlength=8></td>
301 <td><hr size=3 noshade></td>
304 <input type=hidden name=beraternr value="$form->{beraternr}">
305 <input type=hidden name=dfvkz value="$form->{dfvkz}">
306 <input type=hidden name=beratername value="$form->{beratername}">
307 <input type=hidden name=passwort value="$form->{passwort}">
308 <input type=hidden name=mandantennr value="$form->{mandantennr}">
309 <input type=hidden name=datentraegernr value="$form->{datentraegernr}">
310 <input type=hidden name=kne value="$form->{kne}">
311 <input type=hidden name=abrechnungsnr value="$form->{abrechnungsnr}">
313 <input type=hidden name=exporttype value="$form->{exporttype}">
315 <input type=hidden name=nextsub value=export3>
318 <input type=submit class=submit name=action value="|
319 . $locale->text('Continue') . qq|">
326 $lxdebug->leave_sub();
330 $lxdebug->enter_sub();
332 $auth->assert('datev_export');
334 DATEV::clean_temporary_directories();
336 DATEV->save_datev_stamm(\%myconfig, \%$form);
338 my $link = "datev.pl?action=download&download_token=";
341 my $result = DATEV->kne_export(\%myconfig, \%$form);
342 if ($result && @{ $result->{filenames} }) {
343 $link .= Q($result->{download_token});
345 print(qq|<br><b>| . $locale->text('KNE-Export erfolgreich!') . qq|</b><br><br><a href="$link">Download</a>|);
348 $form->error("KNE-Export schlug fehl.");
351 # OBE-Export nicht implementiert.
353 # my @filenames = DATEV->obe_export(\%myconfig, \%$form);
355 # print(qq|<br><b>| . $locale->text('OBE-Export erfolgreich!') . qq|</b><br>|);
356 # $link .= "&filenames=" . $form->escape(join(":", @filenames));
357 # print(qq|<br><a href="$link">Download</a>|);
359 # $form->error("OBE-Export schlug fehl.");
363 print("</body></html>");
365 $lxdebug->leave_sub();
369 $lxdebug->enter_sub();
371 $auth->assert('datev_export');
373 my $tmp_name = Common->tmpname();
374 my $zip_name = strftime("lx-office-datev-export-%Y%m%d.zip", localtime(time()));
378 my $path = DATEV::get_path_for_download_token($form->{download_token});
380 $form->error($locale->text("Your download does not exist anymore. Please re-run the DATEV export assistant."));
383 chdir($path) || die("chdir $path");
385 my @filenames = glob "*";
389 DATEV::clean_temporary_directories();
390 $form->error($locale->text("Your download does not exist anymore. Please re-run the DATEV export assistant."));
393 my $zip = Archive::Zip->new();
394 map { $zip->addFile($_); } @filenames;
395 $zip->writeToFileNamed($tmp_name);
399 open(IN, $tmp_name) || die("open $tmp_name");
400 print("Content-Type: application/zip\n");
401 print("Content-Disposition: attachment; filename=\"${zip_name}\"\n\n");
409 DATEV::clean_temporary_directories();
411 $lxdebug->leave_sub();