Revision ea5b6825
Von Tamino Steinert vor fast 2 Jahren hinzugefügt
bin/mozilla/ar.pl | ||
---|---|---|
use POSIX qw(strftime);
|
||
use List::Util qw(sum first max);
|
||
use List::UtilsBy qw(sort_by);
|
||
use Archive::Zip;
|
||
|
||
use SL::AR;
|
||
use SL::Controller::Base;
|
||
... | ... | |
use SL::DB::Default;
|
||
use SL::DB::Employee;
|
||
use SL::DB::Invoice;
|
||
use SL::DB::Manager::Invoice;
|
||
use SL::DB::InvoiceItem;
|
||
use SL::DB::RecordTemplate;
|
||
use SL::DB::Tax;
|
||
... | ... | |
use SL::Presenter::Chart;
|
||
use SL::Presenter::ItemsList;
|
||
use SL::ReportGenerator;
|
||
use SL::File::Object;
|
||
use SL::DB::Manager::File;
|
||
use SL::File::Backend::Filesystem;
|
||
use SL::Webdav;
|
||
use SL::File::Backend::Webdav;
|
||
|
||
require "bin/mozilla/common.pl";
|
||
require "bin/mozilla/reportgenerator.pl";
|
||
... | ... | |
my %params = @_;
|
||
my $may_edit_create = $::auth->assert('invoice_edit', 1);
|
||
|
||
my $webdav_enabled = SL::DB::Default->get->webdav
|
||
&& SL::DB::Default->get->webdav_documents;
|
||
my $files_enabled = SL::DB::Default->get->doc_storage;
|
||
|
||
for my $bar ($::request->layout->get('actionbar')) {
|
||
$bar->add(
|
||
action => [
|
||
... | ... | |
: !$params{num_rows} ? $::locale->text('The report doesn\'t contain entries.')
|
||
: undef,
|
||
],
|
||
|
||
combobox => [
|
||
action => [ $::locale->text('Record-Export') ],
|
||
action => [
|
||
t8('WebDAV'),
|
||
submit => [ '#report_form', { action => 'webdav_pdf_export' } ],
|
||
checks => [ ['kivi.check_if_entries_selected', '[name="id[]"]'] ],
|
||
disabled => !$webdav_enabled ? t8('No webdav backend enabled.')
|
||
: undef,
|
||
],
|
||
action => [
|
||
t8('Files'),
|
||
submit => [ '#report_form', { action => 'files_pdf_export' } ],
|
||
checks => [ ['kivi.check_if_entries_selected', '[name="id[]"]'] ],
|
||
disabled => !$files_enabled ? t8('No files backend enabled.')
|
||
: undef,
|
||
],
|
||
],
|
||
combobox => [
|
||
action => [ $::locale->text('Create new') ],
|
||
action => [
|
||
... | ... | |
$::request->layout->add_javascripts('kivi.Validator.js');
|
||
}
|
||
|
||
sub webdav_pdf_export {
|
||
$main::lxdebug->enter_sub();
|
||
|
||
# TODO(Tamino): rights?
|
||
$::auth->assert('ar_transactions');
|
||
$::auth->assert('invoice_edit');
|
||
|
||
my $form = $main::form;
|
||
my $ids = $form->{id};
|
||
|
||
my $invoices = SL::DB::Manager::Invoice->get_all(where => [ id => $ids ]);
|
||
|
||
my %file_name_to_path = ();
|
||
my $no_files = "";
|
||
foreach my $invoice (@{$invoices}) {
|
||
if ($invoice->type eq '') {
|
||
$no_files .= $invoice->displayable_name() . "\n";
|
||
$main::lxdebug->dump(0, "TST: no_files loop", $no_files);
|
||
next;
|
||
}
|
||
my $webdav = SL::Webdav->new(
|
||
type => $invoice->type,
|
||
number => $invoice->record_number,
|
||
);
|
||
my @latest_object = $webdav->get_all_latest();
|
||
if (scalar @latest_object) {
|
||
my $file_name = $latest_object[0]->basename . "." . $latest_object[0]->extension;
|
||
$file_name_to_path{$file_name} = $latest_object[0]->full_filedescriptor();
|
||
} else {
|
||
$no_files .= $invoice->displayable_name() . "\n";
|
||
}
|
||
}
|
||
|
||
_create_and_send_zip(\%file_name_to_path, $no_files);
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub files_pdf_export {
|
||
$main::lxdebug->enter_sub();
|
||
|
||
# TODO(Tamino): rights?
|
||
$::auth->assert('ar_transactions');
|
||
$::auth->assert('invoice_edit');
|
||
|
||
my $form = $main::form;
|
||
my $ids = $form->{id};
|
||
|
||
my $invoices = SL::DB::Manager::Invoice->get_all(where => [ id => $ids ]);
|
||
|
||
my %file_name_to_path = ();
|
||
my $no_files = "";
|
||
foreach my $invoice (@{$invoices}) {
|
||
my $file_entry = SL::DB::Manager::File->get_first(
|
||
query => [
|
||
object_type => $invoice->type,
|
||
object_id => $invoice->id,
|
||
],
|
||
);
|
||
if ($file_entry) {
|
||
my $file = SL::File::Object->new(
|
||
db_file => $file_entry,
|
||
id => $file_entry->id,
|
||
loaded => 1,
|
||
);
|
||
$file_name_to_path{$file->file_name()} = $file->get_file();
|
||
} else {
|
||
$no_files .= $invoice->displayable_name() . "\n";
|
||
}
|
||
}
|
||
|
||
|
||
_create_and_send_zip(\%file_name_to_path, $no_files);
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub _create_and_send_zip {
|
||
my ($file_name_to_path, $no_files) = @_;
|
||
$main::lxdebug->enter_sub();
|
||
|
||
my ($fh, $zipfile) = File::Temp::tempfile();
|
||
my $zip = Archive::Zip->new();
|
||
foreach my $name (keys %{$file_name_to_path}) {
|
||
$zip->addFile($file_name_to_path->{$name}, $name);
|
||
}
|
||
if ($no_files ne '') {
|
||
$zip->addString($no_files, t8('no_file_found.txt'));
|
||
}
|
||
$zip->writeToFileHandle($fh) == Archive::Zip::AZ_OK() or die 'error writing zip file';
|
||
close($fh);
|
||
|
||
my $controller = SL::Controller::Base->new;
|
||
|
||
$controller->send_file(
|
||
$zipfile,
|
||
name => t8('pdf_records.zip'), unlink => 1,
|
||
type => 'application/zip',
|
||
);
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
|
||
1;
|
locale/de/all | ||
---|---|---|
'No file selected, please set one checkbox!' => 'Kein Element selektiert,bitte eine Box anklicken',
|
||
'No file uploaded yet' => 'Keine Datei hochgeladen',
|
||
'No filename exists!' => 'Kein Dateiname angegeben',
|
||
'No files backend enabled.' => 'Dateimanagement nicht aktiviert.',
|
||
'No function blocks have been created yet.' => 'Es wurden noch keine Funktionsblöcke angelegt.',
|
||
'No groups have been created yet.' => 'Es wurden noch keine Gruppen angelegt.',
|
||
'No internal phone extensions have been configured yet.' => 'Es wurden noch keine internen Durchwahlen konfiguriert.',
|
||
... | ... | |
'No vendor has been selected yet.' => 'Es wurde noch kein Lieferant ausgewählt.',
|
||
'No vendor selected or found!' => 'Kein Lieferant ausgewählt oder gefunden!',
|
||
'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.',
|
||
'No webdav backend enabled.' => 'WebDAV nicht aktiviert.',
|
||
'No year given for method year' => 'Für diese Exportmethode wird ein Jahr benötigt',
|
||
'No.' => 'Position',
|
||
'No/individual shipping address' => 'Keine/individuelle Lieferadresse',
|
||
... | ... | |
'Record templates' => 'Belegvorlagen',
|
||
'Record type to create' => 'Anzulegender Belegtyp',
|
||
'Record\'s files' => 'Belegdateien',
|
||
'Record-Export' => 'Beleg-Export',
|
||
'Recorded Tax' => 'Gespeicherte Steuern',
|
||
'Recorded taxkey' => 'Gespeicherter Steuerschlüssel',
|
||
'Records' => 'Belege',
|
||
... | ... | |
'no shipping address' => 'keine Lieferadresse',
|
||
'no skonto_chart configured for taxkey #1 : #2 : #3' => 'Kein Skontokonto für Steuerschlüssel #1 : #2 : #3',
|
||
'no tax_id in acc_trans' => 'Keine tax_id in acc_trans',
|
||
'no_file_found.txt' => 'keine_datei_gefunden.txt',
|
||
'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\'',
|
||
'not a valid DTVF file, expected first field in A1 \'DTVF\'' => 'Keine gültige DTVF-Datei, der erwarte Feldwert in A1 ist \'DTVF\'',
|
||
'not configured' => 'nicht konfiguriert',
|
||
... | ... | |
'part' => 'Ware',
|
||
'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\'.',
|
||
'part_list' => 'Warenliste',
|
||
'pdf_records.zip' => 'pdf_belege.zip',
|
||
'percental' => 'prozentual',
|
||
'periodic' => 'Aufwandsmethode',
|
||
'perpetual' => 'Bestandsmethode',
|
locale/en/all | ||
---|---|---|
'No file selected, please set one checkbox!' => '',
|
||
'No file uploaded yet' => '',
|
||
'No filename exists!' => '',
|
||
'No files backend enabled.' => '',
|
||
'No function blocks have been created yet.' => '',
|
||
'No groups have been created yet.' => '',
|
||
'No internal phone extensions have been configured yet.' => '',
|
||
... | ... | |
'No vendor has been selected yet.' => '',
|
||
'No vendor selected or found!' => '',
|
||
'No warehouse has been created yet or the quantity of the bins is not configured yet.' => '',
|
||
'No webdav backend enabled.' => '',
|
||
'No year given for method year' => '',
|
||
'No.' => '',
|
||
'No/individual shipping address' => '',
|
||
... | ... | |
'Record templates' => '',
|
||
'Record type to create' => '',
|
||
'Record\'s files' => '',
|
||
'Record-Export' => '',
|
||
'Recorded Tax' => '',
|
||
'Recorded taxkey' => '',
|
||
'Records' => '',
|
||
... | ... | |
'no shipping address' => '',
|
||
'no skonto_chart configured for taxkey #1 : #2 : #3' => '',
|
||
'no tax_id in acc_trans' => '',
|
||
'no_file_found.txt' => '',
|
||
'not a valid DTVF file, expected field header start with \'Umsatz; (..) ;Konto;Gegenkonto\'' => '',
|
||
'not a valid DTVF file, expected first field in A1 \'DTVF\'' => '',
|
||
'not configured' => '',
|
||
... | ... | |
'part' => '',
|
||
'part \'#\'1 in bin \'#2\' only with qty #3 (need additional #4) and chargenumber \'#5\'.' => '',
|
||
'part_list' => '',
|
||
'pdf_records.zip' => '',
|
||
'percental' => '',
|
||
'periodic' => '',
|
||
'perpetual' => '',
|
templates/design40_webpages/ar/ar_transactions_header.html | ||
---|---|---|
<form method="post" action="controller.pl" id="report_form">
|
||
<form method="post" action="ar.pl" id="report_form">
|
templates/webpages/ar/ar_transactions_header.html | ||
---|---|---|
<form method="post" action="controller.pl" id="report_form">
|
||
<form method="post" action="ar.pl" id="report_form">
|
Auch abrufbar als: Unified diff
Beleg-Pdf aus Rechnungs/Gutschriften-Bericht herunterladen