Revision 8743f3cf
Von Tamino Steinert vor 12 Monaten hinzugefügt
- ID 8743f3cfd51467267369c026b35173192a67d70d
- Vorgänger b635fe0c
bin/mozilla/ar.pl | ||
---|---|---|
use List::Util qw(sum first max);
|
||
use List::UtilsBy qw(sort_by);
|
||
use Archive::Zip;
|
||
use Params::Validate qw(:all);
|
||
|
||
use SL::AR;
|
||
use SL::Controller::Base;
|
||
... | ... | |
: undef,
|
||
],
|
||
combobox => [
|
||
action => [ $::locale->text('Record-Export') ],
|
||
action => [ $::locale->text('PDF-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.')
|
||
disabled => !$webdav_enabled ? t8('WebDAV is not enabled.')
|
||
: undef,
|
||
],
|
||
action => [
|
||
t8('Files'),
|
||
t8('Documents'),
|
||
submit => [ '#report_form', { action => 'files_pdf_export' } ],
|
||
checks => [ ['kivi.check_if_entries_selected', '[name="id[]"]'] ],
|
||
disabled => !$files_enabled ? t8('No files backend enabled.')
|
||
disabled => !$files_enabled ? t8('No File Management enabled.')
|
||
: undef,
|
||
],
|
||
],
|
||
... | ... | |
|
||
my $invoices = SL::DB::Manager::Invoice->get_all(where => [ id => $ids ]);
|
||
|
||
my %file_name_to_path = ();
|
||
my $no_files = "";
|
||
my @file_names_and_file_paths;
|
||
my @errors;
|
||
foreach my $invoice (@{$invoices}) {
|
||
if ($invoice->type eq '') {
|
||
$no_files .= $invoice->displayable_name() . "\n";
|
||
next;
|
||
}
|
||
my $record_type = $invoice->record_type;
|
||
$record_type = 'general_ledger' if $record_type eq 'ar_transaction';
|
||
$record_type = 'invoice' if $record_type eq 'invoice_storno';
|
||
my $webdav = SL::Webdav->new(
|
||
type => $invoice->type,
|
||
type => $record_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";
|
||
unless (scalar @latest_object) {
|
||
push @errors, t8(
|
||
"No Dokument found for record '#1'. Please deselect it or create a document it.",
|
||
$invoice->displayable_name()
|
||
);
|
||
next;
|
||
}
|
||
push @file_names_and_file_paths, {
|
||
file_name => $latest_object[0]->basename . "." . $latest_object[0]->extension,
|
||
file_path => $latest_object[0]->full_filedescriptor(),
|
||
}
|
||
}
|
||
|
||
_create_and_send_zip(\%file_name_to_path, $no_files);
|
||
if (scalar @errors) {
|
||
die join("\n", @errors);
|
||
}
|
||
_create_and_send_zip(\@file_names_and_file_paths);
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
... | ... | |
|
||
my $invoices = SL::DB::Manager::Invoice->get_all(where => [ id => $ids ]);
|
||
|
||
my %file_name_to_path = ();
|
||
my $no_files = "";
|
||
my @file_names_and_file_paths;
|
||
my @errors;
|
||
foreach my $invoice (@{$invoices}) {
|
||
my $file_entry = SL::DB::Manager::File->get_first(
|
||
query => [
|
||
object_type => $invoice->type,
|
||
my $record_type = $invoice->record_type;
|
||
$record_type = 'invoice' if $record_type eq 'ar_transaction';
|
||
$record_type = 'invoice' if $record_type eq 'invoice_storno';
|
||
my @file_entries = @{SL::DB::Manager::File->get_all(
|
||
where => [
|
||
object_type => $record_type,
|
||
object_id => $invoice->id,
|
||
file_type => 'document',
|
||
source => 'created',
|
||
],
|
||
);
|
||
if ($file_entry) {
|
||
)};
|
||
|
||
unless (scalar @file_entries) {
|
||
push @errors, t8(
|
||
"No Dokument found for record '#1'. Please deselect it or create a document it.",
|
||
$invoice->displayable_name()
|
||
);
|
||
next;
|
||
}
|
||
foreach my $file_entry (@file_entries) {
|
||
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";
|
||
eval {
|
||
push @file_names_and_file_paths, {
|
||
file_name => $file->file_name,
|
||
file_path => $file->get_file(),
|
||
};
|
||
} or do {
|
||
push @errors, $@,
|
||
};
|
||
}
|
||
}
|
||
|
||
|
||
_create_and_send_zip(\%file_name_to_path, $no_files);
|
||
if (scalar @errors) {
|
||
die join("\n", @errors);
|
||
}
|
||
_create_and_send_zip(\@file_names_and_file_paths);
|
||
|
||
$main::lxdebug->leave_sub();
|
||
}
|
||
|
||
sub _create_and_send_zip {
|
||
my ($file_name_to_path, $no_files) = @_;
|
||
$main::lxdebug->enter_sub();
|
||
my ($file_names_and_file_paths) = validate_pos(@_, {
|
||
type => ARRAYREF,
|
||
callbacks => {
|
||
"has 'file_name' and 'file_path'" => sub {
|
||
foreach my $file_entry (@{$_[0]}) {
|
||
return 0 unless defined $file_entry->{file_name}
|
||
&& defined $file_entry->{file_path};
|
||
}
|
||
return 1;
|
||
}
|
||
}
|
||
});
|
||
|
||
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'));
|
||
foreach my $file (@{$file_names_and_file_paths}) {
|
||
$zip->addFile($file->{file_path}, $file->{file_name});
|
||
}
|
||
$zip->writeToFileHandle($fh) == Archive::Zip::AZ_OK() or die 'error writing zip file';
|
||
close($fh);
|
locale/de/all | ||
---|---|---|
'No Company Address given' => 'Keine Firmenadresse hinterlegt!',
|
||
'No Company Name given' => 'Kein Firmenname hinterlegt!',
|
||
'No Customer was found matching the search parameters.' => 'Zu dem Suchbegriff wurde kein Endkunde gefunden',
|
||
'No Dokument found for record \'#1\'. Please deselect it or create a document it.' => 'Kein Dokument gefunden für Beleg \'#1\'. Bitte wählen Sie diesen ab oder erstellen Sie ein Dokument für diesen.',
|
||
'No File Management enabled.' => 'Kein Dateimanagement aktiviert.',
|
||
'No GL template was found.' => 'Keine Dialogbuchungsvorlage gefunden.',
|
||
'No Journal' => 'Kein Journal',
|
||
'No Order Number' => 'Keine Auftragsnummer',
|
||
... | ... | |
'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 selected or found!' => 'Kein Lieferant ausgewählt oder gefunden!',
|
||
'No vendors to add to purchasebasket' => 'Kein Lieferant',
|
||
'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',
|
||
... | ... | |
'PDF export' => 'PDF-Export',
|
||
'PDF export -- options' => 'PDF-Export -- Optionen',
|
||
'PDF export with attachments' => 'Als PDF mit Anhängen exportieren',
|
||
'PDF-Export' => 'PDF-Export',
|
||
'PLZ Grosskunden' => 'PLZ Grosskunden',
|
||
'POSTED' => 'Gebucht',
|
||
'POSTED AS NEW' => 'Als neu gebucht',
|
||
... | ... | |
'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',
|
||
... | ... | |
'We need a valid to date' => 'Es wird ein gültiges bis Datum erwartet',
|
||
'Web shops' => 'Webshops',
|
||
'WebDAV' => 'WebDAV',
|
||
'WebDAV is not enabled.' => 'WebDAV ist nicht aktiviert.',
|
||
'WebDAV link' => 'WebDAV-Link',
|
||
'WebDAV save documents' => 'Belege in WebDAV-Ablage speichern',
|
||
'WebDAV sync extern' => 'WebDAV Synchronisation extern',
|
||
... | ... | |
'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',
|
locale/en/all | ||
---|---|---|
'No Company Address given' => '',
|
||
'No Company Name given' => '',
|
||
'No Customer was found matching the search parameters.' => '',
|
||
'No Dokument found for record \'#1\'. Please deselect it or create a document it.' => '',
|
||
'No File Management enabled.' => '',
|
||
'No GL template was found.' => '',
|
||
'No Journal' => '',
|
||
'No Order Number' => '',
|
||
... | ... | |
'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 selected or found!' => '',
|
||
'No vendors to add to purchasebasket' => '',
|
||
'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' => '',
|
||
... | ... | |
'PDF export' => '',
|
||
'PDF export -- options' => '',
|
||
'PDF export with attachments' => '',
|
||
'PDF-Export' => '',
|
||
'PLZ Grosskunden' => '',
|
||
'POSTED' => '',
|
||
'POSTED AS NEW' => '',
|
||
... | ... | |
'Record templates' => '',
|
||
'Record type to create' => '',
|
||
'Record\'s files' => '',
|
||
'Record-Export' => '',
|
||
'Recorded Tax' => '',
|
||
'Recorded taxkey' => '',
|
||
'Records' => '',
|
||
... | ... | |
'We need a valid to date' => '',
|
||
'Web shops' => '',
|
||
'WebDAV' => '',
|
||
'WebDAV is not enabled.' => '',
|
||
'WebDAV link' => '',
|
||
'WebDAV save documents' => '',
|
||
'WebDAV sync extern' => '',
|
||
... | ... | |
'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' => '',
|
Auch abrufbar als: Unified diff
FIX: Beleg-Export -> PDF-Export in Bericht VK-Rechnung, ...