Revision 2768714b
Von Tamino Steinert vor fast 2 Jahren 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::File::Backend::Webdav->enabled(); |
|
948 |
my $files_enabled = SL::File::Backend::Filesystem->enabled(); |
|
949 |
|
|
940 | 950 |
for my $bar ($::request->layout->get('actionbar')) { |
941 | 951 |
$bar->add( |
942 | 952 |
action => [ |
... | ... | |
946 | 956 |
: !$params{num_rows} ? $::locale->text('The report doesn\'t contain entries.') |
947 | 957 |
: undef, |
948 | 958 |
], |
949 |
|
|
959 |
combobox => [ |
|
960 |
action => [ $::locale->text('Record-Export') ], |
|
961 |
action => [ |
|
962 |
t8('WebDAV'), |
|
963 |
submit => [ '#report_form', { action => 'webdav_pdf_export' } ], |
|
964 |
checks => [ ['kivi.check_if_entries_selected', '[name="id[]"]'] ], |
|
965 |
disabled => !$webdav_enabled ? t8('No webdav backend enabled.') |
|
966 |
: undef, |
|
967 |
], |
|
968 |
action => [ |
|
969 |
t8('Files'), |
|
970 |
submit => [ '#report_form', { action => 'files_pdf_export' } ], |
|
971 |
checks => [ ['kivi.check_if_entries_selected', '[name="id[]"]'] ], |
|
972 |
disabled => !$files_enabled ? t8('No files backend enabled.') |
|
973 |
: undef, |
|
974 |
], |
|
975 |
], |
|
950 | 976 |
combobox => [ |
951 | 977 |
action => [ $::locale->text('Create new') ], |
952 | 978 |
action => [ |
... | ... | |
1504 | 1530 |
$::request->layout->add_javascripts('kivi.Validator.js'); |
1505 | 1531 |
} |
1506 | 1532 |
|
1533 |
sub webdav_pdf_export { |
|
1534 |
$main::lxdebug->enter_sub(); |
|
1535 |
|
|
1536 |
# TODO(Tamino): rights? |
|
1537 |
$::auth->assert('ar_transactions'); |
|
1538 |
$::auth->assert('invoice_edit'); |
|
1539 |
|
|
1540 |
my $form = $main::form; |
|
1541 |
my $ids = $form->{id}; |
|
1542 |
|
|
1543 |
my $invoices = SL::DB::Manager::Invoice->get_all(where => [ id => $ids ]); |
|
1544 |
|
|
1545 |
my %file_name_to_path = (); |
|
1546 |
my $no_files = ""; |
|
1547 |
foreach my $invoice (@{$invoices}) { |
|
1548 |
if ($invoice->type eq '') { |
|
1549 |
$no_files .= $invoice->displayable_name() . "\n"; |
|
1550 |
$main::lxdebug->dump(0, "TST: no_files loop", $no_files); |
|
1551 |
next; |
|
1552 |
} |
|
1553 |
my $webdav = SL::Webdav->new( |
|
1554 |
type => $invoice->type, |
|
1555 |
number => $invoice->record_number, |
|
1556 |
); |
|
1557 |
my @latest_object = $webdav->get_all_latest(); |
|
1558 |
if (scalar @latest_object) { |
|
1559 |
my $file_name = $latest_object[0]->basename . "." . $latest_object[0]->extension; |
|
1560 |
$file_name_to_path{$file_name} = $latest_object[0]->full_filedescriptor(); |
|
1561 |
} else { |
|
1562 |
$no_files .= $invoice->displayable_name() . "\n"; |
|
1563 |
} |
|
1564 |
} |
|
1565 |
|
|
1566 |
_create_and_send_zip(\%file_name_to_path, $no_files); |
|
1567 |
|
|
1568 |
$main::lxdebug->leave_sub(); |
|
1569 |
} |
|
1570 |
|
|
1571 |
sub files_pdf_export { |
|
1572 |
$main::lxdebug->enter_sub(); |
|
1573 |
|
|
1574 |
# TODO(Tamino): rights? |
|
1575 |
$::auth->assert('ar_transactions'); |
|
1576 |
$::auth->assert('invoice_edit'); |
|
1577 |
|
|
1578 |
my $form = $main::form; |
|
1579 |
my $ids = $form->{id}; |
|
1580 |
|
|
1581 |
my $invoices = SL::DB::Manager::Invoice->get_all(where => [ id => $ids ]); |
|
1582 |
|
|
1583 |
my %file_name_to_path = (); |
|
1584 |
my $no_files = ""; |
|
1585 |
foreach my $invoice (@{$invoices}) { |
|
1586 |
my $file_entry = SL::DB::Manager::File->get_first( |
|
1587 |
query => [ |
|
1588 |
object_type => $invoice->type, |
|
1589 |
object_id => $invoice->id, |
|
1590 |
], |
|
1591 |
); |
|
1592 |
if ($file_entry) { |
|
1593 |
my $file = SL::File::Object->new( |
|
1594 |
db_file => $file_entry, |
|
1595 |
id => $file_entry->id, |
|
1596 |
loaded => 1, |
|
1597 |
); |
|
1598 |
$file_name_to_path{$file->file_name()} = $file->get_file(); |
|
1599 |
} else { |
|
1600 |
$no_files .= $invoice->displayable_name() . "\n"; |
|
1601 |
} |
|
1602 |
} |
|
1603 |
|
|
1604 |
|
|
1605 |
_create_and_send_zip(\%file_name_to_path, $no_files); |
|
1606 |
|
|
1607 |
$main::lxdebug->leave_sub(); |
|
1608 |
} |
|
1609 |
|
|
1610 |
sub _create_and_send_zip { |
|
1611 |
my ($file_name_to_path, $no_files) = @_; |
|
1612 |
$main::lxdebug->enter_sub(); |
|
1613 |
|
|
1614 |
my ($fh, $zipfile) = File::Temp::tempfile(); |
|
1615 |
my $zip = Archive::Zip->new(); |
|
1616 |
foreach my $name (keys %{$file_name_to_path}) { |
|
1617 |
$zip->addFile($file_name_to_path->{$name}, $name); |
|
1618 |
} |
|
1619 |
if ($no_files ne '') { |
|
1620 |
$zip->addString($no_files, t8('no_file_found.txt')); |
|
1621 |
} |
|
1622 |
$zip->writeToFileHandle($fh) == Archive::Zip::AZ_OK() or die 'error writing zip file'; |
|
1623 |
close($fh); |
|
1624 |
|
|
1625 |
my $controller = SL::Controller::Base->new; |
|
1626 |
|
|
1627 |
$controller->send_file($zipfile, name => t8('pdf_records.zip'), unlink => 1); |
|
1628 |
|
|
1629 |
$main::lxdebug->leave_sub(); |
|
1630 |
} |
|
1631 |
|
|
1632 |
|
|
1507 | 1633 |
1; |
locale/de/all | ||
---|---|---|
2406 | 2406 |
'No file selected, please set one checkbox!' => 'Kein Element selektiert,bitte eine Box anklicken', |
2407 | 2407 |
'No file uploaded yet' => 'Keine Datei hochgeladen', |
2408 | 2408 |
'No filename exists!' => 'Kein Dateiname angegeben', |
2409 |
'No files backend enabled.' => 'Dateimanagement nicht aktiviert.', |
|
2409 | 2410 |
'No function blocks have been created yet.' => 'Es wurden noch keine Funktionsblöcke angelegt.', |
2410 | 2411 |
'No groups have been created yet.' => 'Es wurden noch keine Gruppen angelegt.', |
2411 | 2412 |
'No internal phone extensions have been configured yet.' => 'Es wurden noch keine internen Durchwahlen konfiguriert.', |
... | ... | |
2449 | 2450 |
'No vendor has been selected yet.' => 'Es wurde noch kein Lieferant ausgewählt.', |
2450 | 2451 |
'No vendor selected or found!' => 'Kein Lieferant ausgewählt oder gefunden!', |
2451 | 2452 |
'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.', |
2453 |
'No webdav backend enabled.' => 'WebDAV nicht aktiviert.', |
|
2452 | 2454 |
'No year given for method year' => 'Für diese Exportmethode wird ein Jahr benötigt', |
2453 | 2455 |
'No.' => 'Position', |
2454 | 2456 |
'No/individual shipping address' => 'Keine/individuelle Lieferadresse', |
... | ... | |
3034 | 3036 |
'Record templates' => 'Belegvorlagen', |
3035 | 3037 |
'Record type to create' => 'Anzulegender Belegtyp', |
3036 | 3038 |
'Record\'s files' => 'Belegdateien', |
3039 |
'Record-Export' => 'Beleg-Export', |
|
3037 | 3040 |
'Recorded Tax' => 'Gespeicherte Steuern', |
3038 | 3041 |
'Recorded taxkey' => 'Gespeicherter Steuerschlüssel', |
3039 | 3042 |
'Records' => 'Belege', |
... | ... | |
4842 | 4845 |
'no shipping address' => 'keine Lieferadresse', |
4843 | 4846 |
'no skonto_chart configured for taxkey #1 : #2 : #3' => 'Kein Skontokonto für Steuerschlüssel #1 : #2 : #3', |
4844 | 4847 |
'no tax_id in acc_trans' => 'Keine tax_id in acc_trans', |
4848 |
'no_file_found.txt' => 'keine_datei_gefunden.txt', |
|
4845 | 4849 |
'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\'', |
4846 | 4850 |
'not a valid DTVF file, expected first field in A1 \'DTVF\'' => 'Keine gültige DTVF-Datei, der erwarte Feldwert in A1 ist \'DTVF\'', |
4847 | 4851 |
'not configured' => 'nicht konfiguriert', |
... | ... | |
4870 | 4874 |
'part' => 'Ware', |
4871 | 4875 |
'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\'.', |
4872 | 4876 |
'part_list' => 'Warenliste', |
4877 |
'pdf_records.zip' => 'pdf_belege.zip', |
|
4873 | 4878 |
'percental' => 'prozentual', |
4874 | 4879 |
'periodic' => 'Aufwandsmethode', |
4875 | 4880 |
'perpetual' => 'Bestandsmethode', |
locale/en/all | ||
---|---|---|
2405 | 2405 |
'No file selected, please set one checkbox!' => '', |
2406 | 2406 |
'No file uploaded yet' => '', |
2407 | 2407 |
'No filename exists!' => '', |
2408 |
'No files backend enabled.' => '', |
|
2408 | 2409 |
'No function blocks have been created yet.' => '', |
2409 | 2410 |
'No groups have been created yet.' => '', |
2410 | 2411 |
'No internal phone extensions have been configured yet.' => '', |
... | ... | |
2448 | 2449 |
'No vendor has been selected yet.' => '', |
2449 | 2450 |
'No vendor selected or found!' => '', |
2450 | 2451 |
'No warehouse has been created yet or the quantity of the bins is not configured yet.' => '', |
2452 |
'No webdav backend enabled.' => '', |
|
2451 | 2453 |
'No year given for method year' => '', |
2452 | 2454 |
'No.' => '', |
2453 | 2455 |
'No/individual shipping address' => '', |
... | ... | |
3033 | 3035 |
'Record templates' => '', |
3034 | 3036 |
'Record type to create' => '', |
3035 | 3037 |
'Record\'s files' => '', |
3038 |
'Record-Export' => '', |
|
3036 | 3039 |
'Recorded Tax' => '', |
3037 | 3040 |
'Recorded taxkey' => '', |
3038 | 3041 |
'Records' => '', |
... | ... | |
4840 | 4843 |
'no shipping address' => '', |
4841 | 4844 |
'no skonto_chart configured for taxkey #1 : #2 : #3' => '', |
4842 | 4845 |
'no tax_id in acc_trans' => '', |
4846 |
'no_file_found.txt' => '', |
|
4843 | 4847 |
'not a valid DTVF file, expected field header start with \'Umsatz; (..) ;Konto;Gegenkonto\'' => '', |
4844 | 4848 |
'not a valid DTVF file, expected first field in A1 \'DTVF\'' => '', |
4845 | 4849 |
'not configured' => '', |
... | ... | |
4868 | 4872 |
'part' => '', |
4869 | 4873 |
'part \'#\'1 in bin \'#2\' only with qty #3 (need additional #4) and chargenumber \'#5\'.' => '', |
4870 | 4874 |
'part_list' => '', |
4875 |
'pdf_records.zip' => '', |
|
4871 | 4876 |
'percental' => '', |
4872 | 4877 |
'periodic' => '', |
4873 | 4878 |
'perpetual' => '', |
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