X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=84349d25dcd3a0a918c0e7ba53e40df9cf97adb7;hb=bd4debfbf0cddd53ba37a5f7881a4525e3c69891;hp=f737a58dda89290d548d90f289daf9a281e91b97;hpb=a8459f498a58bdabcd87bcdf1cd08e9f5726abe4;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index f737a58dd..84349d25d 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -63,6 +63,7 @@ use SL::DB::Default; use SL::DB::PaymentTerm; use SL::DB::Vendor; use SL::DO; +use SL::Helper::Flash qw(); use SL::IC; use SL::IS; use SL::Layout::Dispatcher; @@ -83,6 +84,8 @@ use URI; use List::Util qw(first max min sum); use List::MoreUtils qw(all any apply); use SL::DB::Tax; +use SL::Helper::File qw(:all); +use SL::Helper::CreatePDF qw(merge_pdfs); use strict; @@ -343,13 +346,12 @@ sub numtextrows { } sub dberror { - $main::lxdebug->enter_sub(); - my ($self, $msg) = @_; - $self->error("$msg\n" . $DBI::errstr); - - $main::lxdebug->leave_sub(); + die SL::X::DBError->new( + msg => $msg, + error => $DBI::errstr, + ); } sub isblank { @@ -732,6 +734,7 @@ sub redirect { $self->info($msg); } else { + SL::Helper::Flash::flash_later('info', $msg) if $msg; $self->_store_redirect_info_in_session; print $::form->redirect_header($self->{callback}); } @@ -1075,9 +1078,18 @@ sub parse_template { # therefore copy to webdav, even if we do not have the webdav feature enabled (just archive) my $copy_to_webdav = $::instance_conf->get_webdav_documents && !$self->{preview} && $self->{tmpdir} && $self->{tmpfile} && $self->{type}; + if ( $ext_for_format eq 'pdf' && $::instance_conf->get_doc_storage ) { + $self->append_general_pdf_attachments(filepath => $self->{tmpdir}."/".$self->{tmpfile}, + type => $self->{type}); + } if ($self->{media} eq 'file') { copy(join('/', $self->{cwd}, $userspath, $self->{tmpfile}), $out =~ m|^/| ? $out : join('/', $self->{cwd}, $out)) if $template->uses_temp_file; Common::copy_file_to_webdav_folder($self) if $copy_to_webdav; + if (!$self->{preview} && $::instance_conf->get_doc_storage) + { + $self->{attachment_filename} ||= $self->generate_attachment_filename; + $self->store_pdf($self); + } $self->cleanup; chdir("$self->{cwd}"); @@ -1088,6 +1100,10 @@ sub parse_template { Common::copy_file_to_webdav_folder($self) if $copy_to_webdav; + if ( !$self->{preview} && $ext_for_format eq 'pdf' && $::instance_conf->get_doc_storage) { + $self->{attachment_filename} ||= $self->generate_attachment_filename; + $self->store_pdf($self); + } if ($self->{media} eq 'email') { my $mail = Mailer->new; @@ -2451,81 +2467,7 @@ sub get_name { return scalar(@{ $self->{name_list} }); } -# the selection sub is used in the AR, AP, IS, IR, DO and OE module -# -sub all_vc { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $table, $module) = @_; - - my $ref; - my $dbh = $self->get_standard_dbh; - - $table = $table eq "customer" ? "customer" : "vendor"; - - # build selection list - # Hotfix für Bug 1837 - Besser wäre es alte Buchungsbelege - # OHNE Auswahlliste (reines Textfeld) zu laden. Hilft aber auch - # nicht für veränderbare Belege (oe, do, ...) - my $obsolete = $self->{id} ? '' : "WHERE NOT obsolete"; - my $query = qq|SELECT count(*) FROM $table $obsolete|; - my ($count) = selectrow_query($self, $dbh, $query); - - if ($count <= $myconfig->{vclimit}) { - $query = qq|SELECT id, name, salesman_id - FROM $table $obsolete - ORDER BY name|; - $self->{"all_$table"} = selectall_hashref_query($self, $dbh, $query); - } - - # get self - $self->get_employee($dbh); - - # setup sales contacts - $query = qq|SELECT e.id, e.name - FROM employee e - WHERE (e.sales = '1') AND (NOT e.id = ?) - ORDER BY name|; - $self->{all_employees} = selectall_hashref_query($self, $dbh, $query, $self->{employee_id}); - - # this is for self - push(@{ $self->{all_employees} }, - { id => $self->{employee_id}, - name => $self->{employee} }); - - # prepare query for departments - $query = qq|SELECT id, description - FROM department - ORDER BY description|; - - $self->{all_departments} = selectall_hashref_query($self, $dbh, $query); - - # get languages - $query = qq|SELECT id, description - FROM language - ORDER BY id|; - - $self->{languages} = selectall_hashref_query($self, $dbh, $query); - - # get printer - $query = qq|SELECT printer_description, id - FROM printers - ORDER BY printer_description|; - - $self->{printers} = selectall_hashref_query($self, $dbh, $query); - - # get payment terms - $query = qq|SELECT id, description - FROM payment_terms - WHERE ( obsolete IS FALSE OR id = ? ) - ORDER BY sortkey |; - $self->{payment_terms} = selectall_hashref_query($self, $dbh, $query, $self->{payment_id} || undef); - - $main::lxdebug->leave_sub(); -} - sub new_lastmtime { - $main::lxdebug->enter_sub(); my ($self, $table, $provided_dbh) = @_; @@ -2537,9 +2479,7 @@ sub new_lastmtime { my $ref = selectfirst_hashref_query($self, $dbh, $query, $self->{id}); $ref->{mtime} ||= $ref->{itime}; $self->{lastmtime} = $ref->{mtime}; - $main::lxdebug->message(LXDebug->DEBUG2(),"new lastmtime=".$self->{lastmtime}); - $main::lxdebug->leave_sub(); } sub mtime_ischanged { @@ -2633,8 +2573,6 @@ sub create_links { $arap = "ap"; } - $self->all_vc($myconfig, $table, $module); - # get last customers or vendors my ($query, $sth, $ref); @@ -2908,6 +2846,22 @@ sub lastname_used { $main::lxdebug->leave_sub(); } +sub get_variable_content_types { + my %html_variables = ( + longdescription => 'html', + partnotes => 'html', + notes => 'html', + orignotes => 'html', + notes1 => 'html', + notes2 => 'html', + notes3 => 'html', + notes4 => 'html', + header_text => 'html', + footer_text => 'html', + ); + return \%html_variables; +} + sub current_date { $main::lxdebug->enter_sub(); @@ -3074,6 +3028,7 @@ sub save_status { #--- 4 locale ---# # $main::locale->text('SAVED') +# $main::locale->text('SCREENED') # $main::locale->text('DELETED') # $main::locale->text('ADDED') # $main::locale->text('PAYMENT POSTED') @@ -3086,6 +3041,8 @@ sub save_status { # $main::locale->text('MAILED') # $main::locale->text('SCREENED') # $main::locale->text('CANCELED') +# $main::locale->text('IMPORT') +# $main::locale->text('UNIMPORT') # $main::locale->text('invoice') # $main::locale->text('proforma') # $main::locale->text('sales_order')