Revision ea5b6825
Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt
bin/mozilla/ar.pl | ||
---|---|---|
35 | 35 |
use POSIX qw(strftime); |
36 | 36 |
use List::Util qw(sum first max); |
37 | 37 |
use List::UtilsBy qw(sort_by); |
38 |
use Archive::Zip; |
|
38 | 39 |
|
39 | 40 |
use SL::AR; |
40 | 41 |
use SL::Controller::Base; |
... | ... | |
48 | 49 |
use SL::DB::Default; |
49 | 50 |
use SL::DB::Employee; |
50 | 51 |
use SL::DB::Invoice; |
52 |
use SL::DB::Manager::Invoice; |
|
51 | 53 |
use SL::DB::InvoiceItem; |
52 | 54 |
use SL::DB::RecordTemplate; |
53 | 55 |
use SL::DB::Tax; |
... | ... | |
58 | 60 |
use SL::Presenter::Chart; |
59 | 61 |
use SL::Presenter::ItemsList; |
60 | 62 |
use SL::ReportGenerator; |
63 |
use SL::File::Object; |
|
64 |
use SL::DB::Manager::File; |
|
65 |
use SL::File::Backend::Filesystem; |
|
66 |
use SL::Webdav; |
|
67 |
use SL::File::Backend::Webdav; |
|
61 | 68 |
|
62 | 69 |
require "bin/mozilla/common.pl"; |
63 | 70 |
require "bin/mozilla/reportgenerator.pl"; |
... | ... | |
937 | 944 |
my %params = @_; |
938 | 945 |
my $may_edit_create = $::auth->assert('invoice_edit', 1); |
939 | 946 |
|
947 |
my $webdav_enabled = SL::DB::Default->get->webdav |
|
948 |
&& SL::DB::Default->get->webdav_documents; |
|
949 |
my $files_enabled = SL::DB::Default->get->doc_storage; |
|
950 |
|
|
940 | 951 |
for my $bar ($::request->layout->get('actionbar')) { |
941 | 952 |
$bar->add( |
942 | 953 |
action => [ |
... | ... | |
946 | 957 |
: !$params{num_rows} ? $::locale->text('The report doesn\'t contain entries.') |
947 | 958 |
: undef, |
948 | 959 |
], |
949 |
|
|
960 |
combobox => [ |
|
961 |
action => [ $::locale->text('Record-Export') ], |
|
962 |
action => [ |
|
963 |
t8('WebDAV'), |
|
964 |
submit => [ '#report_form', { action => 'webdav_pdf_export' } ], |
|
965 |
checks => [ ['kivi.check_if_entries_selected', '[name="id[]"]'] ], |
|
966 |
disabled => !$webdav_enabled ? t8('No webdav backend enabled.') |
|
967 |
: undef, |
|
968 |
], |
|
969 |
action => [ |
|
970 |
t8('Files'), |
|
971 |
submit => [ '#report_form', { action => 'files_pdf_export' } ], |
|
972 |
checks => [ ['kivi.check_if_entries_selected', '[name="id[]"]'] ], |
|
973 |
disabled => !$files_enabled ? t8('No files backend enabled.') |
|
974 |
: undef, |
|
975 |
], |
|
976 |
], |
|
950 | 977 |
combobox => [ |
951 | 978 |
action => [ $::locale->text('Create new') ], |
952 | 979 |
action => [ |
... | ... | |
1510 | 1537 |
$::request->layout->add_javascripts('kivi.Validator.js'); |
1511 | 1538 |
} |
1512 | 1539 |
|
1540 |
sub webdav_pdf_export { |
|
1541 |
$main::lxdebug->enter_sub(); |
|
1542 |
|
|
1543 |
# TODO(Tamino): rights? |
|
1544 |
$::auth->assert('ar_transactions'); |
|
1545 |
$::auth->assert('invoice_edit'); |
|
1546 |
|
|
1547 |
my $form = $main::form; |
|
1548 |
my $ids = $form->{id}; |
|
1549 |
|
|
1550 |
my $invoices = SL::DB::Manager::Invoice->get_all(where => [ id => $ids ]); |
|
1551 |
|
|
1552 |
my %file_name_to_path = (); |
|
1553 |
my $no_files = ""; |
|
1554 |
foreach my $invoice (@{$invoices}) { |
|
1555 |
if ($invoice->type eq '') { |
|
1556 |
$no_files .= $invoice->displayable_name() . "\n"; |
|
1557 |
$main::lxdebug->dump(0, "TST: no_files loop", $no_files); |
|
1558 |
next; |
|
1559 |
} |
|
1560 |
my $webdav = SL::Webdav->new( |
|
1561 |
type => $invoice->type, |
|
1562 |
number => $invoice->record_number, |
|
1563 |
); |
|
1564 |
my @latest_object = $webdav->get_all_latest(); |
|
1565 |
if (scalar @latest_object) { |
|
1566 |
my $file_name = $latest_object[0]->basename . "." . $latest_object[0]->extension; |
|
1567 |
$file_name_to_path{$file_name} = $latest_object[0]->full_filedescriptor(); |
|
1568 |
} else { |
|
1569 |
$no_files .= $invoice->displayable_name() . "\n"; |
|
1570 |
} |
|
1571 |
} |
|
1572 |
|
|
1573 |
_create_and_send_zip(\%file_name_to_path, $no_files); |
|
1574 |
|
|
1575 |
$main::lxdebug->leave_sub(); |
|
1576 |
} |
|
1577 |
|
|
1578 |
sub files_pdf_export { |
|
1579 |
$main::lxdebug->enter_sub(); |
|
1580 |
|
|
1581 |
# TODO(Tamino): rights? |
|
1582 |
$::auth->assert('ar_transactions'); |
|
1583 |
$::auth->assert('invoice_edit'); |
|
1584 |
|
|
1585 |
my $form = $main::form; |
|
1586 |
my $ids = $form->{id}; |
|
1587 |
|
|
1588 |
my $invoices = SL::DB::Manager::Invoice->get_all(where => [ id => $ids ]); |
|
1589 |
|
|
1590 |
my %file_name_to_path = (); |
|
1591 |
my $no_files = ""; |
|
1592 |
foreach my $invoice (@{$invoices}) { |
|
1593 |
my $file_entry = SL::DB::Manager::File->get_first( |
|
1594 |
query => [ |
|
1595 |
object_type => $invoice->type, |
|
1596 |
object_id => $invoice->id, |
|
1597 |
], |
|
1598 |
); |
|
1599 |
if ($file_entry) { |
|
1600 |
my $file = SL::File::Object->new( |
|
1601 |
db_file => $file_entry, |
|
1602 |
id => $file_entry->id, |
|
1603 |
loaded => 1, |
|
1604 |
); |
|
1605 |
$file_name_to_path{$file->file_name()} = $file->get_file(); |
|
1606 |
} else { |
|
1607 |
$no_files .= $invoice->displayable_name() . "\n"; |
|
1608 |
} |
|
1609 |
} |
|
1610 |
|
|
1611 |
|
|
1612 |
_create_and_send_zip(\%file_name_to_path, $no_files); |
|
1613 |
|
|
1614 |
$main::lxdebug->leave_sub(); |
|
1615 |
} |
|
1616 |
|
|
1617 |
sub _create_and_send_zip { |
|
1618 |
my ($file_name_to_path, $no_files) = @_; |
|
1619 |
$main::lxdebug->enter_sub(); |
|
1620 |
|
|
1621 |
my ($fh, $zipfile) = File::Temp::tempfile(); |
|
1622 |
my $zip = Archive::Zip->new(); |
|
1623 |
foreach my $name (keys %{$file_name_to_path}) { |
|
1624 |
$zip->addFile($file_name_to_path->{$name}, $name); |
|
1625 |
} |
|
1626 |
if ($no_files ne '') { |
|
1627 |
$zip->addString($no_files, t8('no_file_found.txt')); |
|
1628 |
} |
|
1629 |
$zip->writeToFileHandle($fh) == Archive::Zip::AZ_OK() or die 'error writing zip file'; |
|
1630 |
close($fh); |
|
1631 |
|
|
1632 |
my $controller = SL::Controller::Base->new; |
|
1633 |
|
|
1634 |
$controller->send_file( |
|
1635 |
$zipfile, |
|
1636 |
name => t8('pdf_records.zip'), unlink => 1, |
|
1637 |
type => 'application/zip', |
|
1638 |
); |
|
1639 |
|
|
1640 |
$main::lxdebug->leave_sub(); |
|
1641 |
} |
|
1642 |
|
|
1643 |
|
|
1513 | 1644 |
1; |
locale/de/all | ||
---|---|---|
2417 | 2417 |
'No file selected, please set one checkbox!' => 'Kein Element selektiert,bitte eine Box anklicken', |
2418 | 2418 |
'No file uploaded yet' => 'Keine Datei hochgeladen', |
2419 | 2419 |
'No filename exists!' => 'Kein Dateiname angegeben', |
2420 |
'No files backend enabled.' => 'Dateimanagement nicht aktiviert.', |
|
2420 | 2421 |
'No function blocks have been created yet.' => 'Es wurden noch keine Funktionsblöcke angelegt.', |
2421 | 2422 |
'No groups have been created yet.' => 'Es wurden noch keine Gruppen angelegt.', |
2422 | 2423 |
'No internal phone extensions have been configured yet.' => 'Es wurden noch keine internen Durchwahlen konfiguriert.', |
... | ... | |
2461 | 2462 |
'No vendor has been selected yet.' => 'Es wurde noch kein Lieferant ausgewählt.', |
2462 | 2463 |
'No vendor selected or found!' => 'Kein Lieferant ausgewählt oder gefunden!', |
2463 | 2464 |
'No warehouse has been created yet or the quantity of the bins is not configured yet.' => 'Es wurde noch kein Lager angelegt, bzw. die dazugehörigen Lagerplätze sind noch nicht konfiguriert.', |
2465 |
'No webdav backend enabled.' => 'WebDAV nicht aktiviert.', |
|
2464 | 2466 |
'No year given for method year' => 'Für diese Exportmethode wird ein Jahr benötigt', |
2465 | 2467 |
'No.' => 'Position', |
2466 | 2468 |
'No/individual shipping address' => 'Keine/individuelle Lieferadresse', |
... | ... | |
3053 | 3055 |
'Record templates' => 'Belegvorlagen', |
3054 | 3056 |
'Record type to create' => 'Anzulegender Belegtyp', |
3055 | 3057 |
'Record\'s files' => 'Belegdateien', |
3058 |
'Record-Export' => 'Beleg-Export', |
|
3056 | 3059 |
'Recorded Tax' => 'Gespeicherte Steuern', |
3057 | 3060 |
'Recorded taxkey' => 'Gespeicherter Steuerschlüssel', |
3058 | 3061 |
'Records' => 'Belege', |
... | ... | |
4865 | 4868 |
'no shipping address' => 'keine Lieferadresse', |
4866 | 4869 |
'no skonto_chart configured for taxkey #1 : #2 : #3' => 'Kein Skontokonto für Steuerschlüssel #1 : #2 : #3', |
4867 | 4870 |
'no tax_id in acc_trans' => 'Keine tax_id in acc_trans', |
4871 |
'no_file_found.txt' => 'keine_datei_gefunden.txt', |
|
4868 | 4872 |
'not a valid DTVF file, expected field header start with \'Umsatz; (..) ;Konto;Gegenkonto\'' => 'Keine gültige DTVF-Datei, die erwartete Kopfzeile startet mit \'Umsatz; (..) ;Konto;Gegenkonto\'', |
4869 | 4873 |
'not a valid DTVF file, expected first field in A1 \'DTVF\'' => 'Keine gültige DTVF-Datei, der erwarte Feldwert in A1 ist \'DTVF\'', |
4870 | 4874 |
'not configured' => 'nicht konfiguriert', |
... | ... | |
4893 | 4897 |
'part' => 'Ware', |
4894 | 4898 |
'part \'#\'1 in bin \'#2\' only with qty #3 (need additional #4) and chargenumber \'#5\'.' => 'Artikel \'#1\' im \'#2\' nur mit der Menge #3 (noch #4 benötig) und Chargennummer \'#5\'.', |
4895 | 4899 |
'part_list' => 'Warenliste', |
4900 |
'pdf_records.zip' => 'pdf_belege.zip', |
|
4896 | 4901 |
'percental' => 'prozentual', |
4897 | 4902 |
'periodic' => 'Aufwandsmethode', |
4898 | 4903 |
'perpetual' => 'Bestandsmethode', |
locale/en/all | ||
---|---|---|
2415 | 2415 |
'No file selected, please set one checkbox!' => '', |
2416 | 2416 |
'No file uploaded yet' => '', |
2417 | 2417 |
'No filename exists!' => '', |
2418 |
'No files backend enabled.' => '', |
|
2418 | 2419 |
'No function blocks have been created yet.' => '', |
2419 | 2420 |
'No groups have been created yet.' => '', |
2420 | 2421 |
'No internal phone extensions have been configured yet.' => '', |
... | ... | |
2459 | 2460 |
'No vendor has been selected yet.' => '', |
2460 | 2461 |
'No vendor selected or found!' => '', |
2461 | 2462 |
'No warehouse has been created yet or the quantity of the bins is not configured yet.' => '', |
2463 |
'No webdav backend enabled.' => '', |
|
2462 | 2464 |
'No year given for method year' => '', |
2463 | 2465 |
'No.' => '', |
2464 | 2466 |
'No/individual shipping address' => '', |
... | ... | |
3051 | 3053 |
'Record templates' => '', |
3052 | 3054 |
'Record type to create' => '', |
3053 | 3055 |
'Record\'s files' => '', |
3056 |
'Record-Export' => '', |
|
3054 | 3057 |
'Recorded Tax' => '', |
3055 | 3058 |
'Recorded taxkey' => '', |
3056 | 3059 |
'Records' => '', |
... | ... | |
4862 | 4865 |
'no shipping address' => '', |
4863 | 4866 |
'no skonto_chart configured for taxkey #1 : #2 : #3' => '', |
4864 | 4867 |
'no tax_id in acc_trans' => '', |
4868 |
'no_file_found.txt' => '', |
|
4865 | 4869 |
'not a valid DTVF file, expected field header start with \'Umsatz; (..) ;Konto;Gegenkonto\'' => '', |
4866 | 4870 |
'not a valid DTVF file, expected first field in A1 \'DTVF\'' => '', |
4867 | 4871 |
'not configured' => '', |
... | ... | |
4890 | 4894 |
'part' => '', |
4891 | 4895 |
'part \'#\'1 in bin \'#2\' only with qty #3 (need additional #4) and chargenumber \'#5\'.' => '', |
4892 | 4896 |
'part_list' => '', |
4897 |
'pdf_records.zip' => '', |
|
4893 | 4898 |
'percental' => '', |
4894 | 4899 |
'periodic' => '', |
4895 | 4900 |
'perpetual' => '', |
templates/design40_webpages/ar/ar_transactions_header.html | ||
---|---|---|
1 |
<form method="post" action="controller.pl" id="report_form"> |
|
1 |
<form method="post" action="ar.pl" id="report_form"> |
templates/webpages/ar/ar_transactions_header.html | ||
---|---|---|
1 |
<form method="post" action="controller.pl" id="report_form"> |
|
1 |
<form method="post" action="ar.pl" id="report_form"> |
Auch abrufbar als: Unified diff
Beleg-Pdf aus Rechnungs/Gutschriften-Bericht herunterladen