X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=a0fa96a2ce6283852b21cd913aa8da349369a22c;hb=685a41058225b91a5e19f62b58aebfd52637fa07;hp=bfe8e464472c9a7b498143b47e651c88fbc175a1;hpb=7247d23a2badb87bf894346ec5d211ac568f23ad;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index bfe8e4644..a0fa96a2c 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1,4 +1,4 @@ -#===================================================================== +#==================================================================== # LX-Office ERP # Copyright (C) 2004 # Based on SQL-Ledger Version 2.1.9 @@ -382,8 +382,8 @@ function fokus(){document.$self->{fokus}.focus();} $jsscript = qq| + + $self->{javascript} |; } @@ -450,25 +450,25 @@ sub write_trigger { $trigger_1 = qq| Calendar.setup( -  { -    inputField  : "$inputField_1", -    ifFormat    :"$ifFormat", -    align    : "$align_1",      -    button      : "$button_1" -  } -  ); + { + inputField : "$inputField_1", + ifFormat :"$ifFormat", + align : "$align_1", + button : "$button_1" + } + ); |; if ($qty == 2) { $trigger_2 = qq| Calendar.setup( { -     inputField  : "$inputField_2", -     ifFormat    :"$ifFormat", -    align    : "$align_2",      -    button      : "$button_2" -  } -  ); + inputField : "$inputField_2", + ifFormat :"$ifFormat", + align : "$align_2", + button : "$button_2" + } + ); |; } $jsscript = qq| @@ -632,7 +632,7 @@ sub parse_template { # Some variables used for page breaks my ($chars_per_line, $lines_on_first_page, $lines_on_second_page) = (0, 0, 0); - my ($current_page, $current_line) = (1, 1); + my ($current_page, $current_line, $current_row) = (1, 1, 0); my $pagebreak = ""; my $sum = 0; @@ -736,8 +736,9 @@ sub parse_template { $lpp = $lines_on_second_page; } - # Yes we need a manual page break - if (($current_line + $lines) > $lpp) { + # Yes we need a manual page break -- or the user has forced one + if ((($current_line + $lines) > $lpp) || + ($self->{"_forced_pagebreaks"} && grep(/^${current_row}$/, @{$self->{"_forced_pagebreaks"}}))) { my $pb = $pagebreak; # replace the special variables <%sumcarriedforward%> @@ -758,6 +759,7 @@ sub parse_template { $current_line = 1; } $current_line += $lines; + $current_row++; } $sum += $self->parse_amount($myconfig, $self->{"linetotal"}[$i]); @@ -1023,6 +1025,18 @@ sub format_string { %unique_fields = map({ $_ => 1 } @fields); @fields = keys(%unique_fields); + + foreach my $field (@fields) { + next unless ($self->{$field} =~ /\/); + $self->{$field} =~ s/\//g; + if ($field =~ /.*_(\d+)$/) { + if (!$self->{"_forced_pagebreaks"}) { + $self->{"_forced_pagebreaks"} = []; + } + push(@{ $self->{"_forced_pagebreaks"} }, "$1"); + } + } + my $format = $self->{format}; if ($self->{format} =~ /(postscript|pdf)/) { $format = 'tex'; @@ -1086,9 +1100,6 @@ sub format_string { 'u' => 'underline'); foreach my $field (@fields) { - if ($field =~ /descrip/) { - print(STDERR "QFT: ${field}: " . $self->{$field} . "\n"); - } foreach my $key (keys(%markup_replace)) { my $new = $markup_replace{$key}; $self->{$field} =~ @@ -1266,6 +1277,11 @@ sub get_exchangerate { $main::lxdebug->enter_sub(); my ($self, $dbh, $curr, $transdate, $fld) = @_; + + unless ($transdate) { + $main::lxdebug->leave_sub(); + return ""; + } my $query = qq|SELECT e.$fld FROM exchangerate e WHERE e.curr = '$curr' @@ -1749,10 +1765,9 @@ sub lastname_used { $where = "quotation = '1'"; } - my $query = qq|SELECT id FROM $arap - WHERE id IN (SELECT MAX(id) FROM $arap + my $query = qq|SELECT MAX(id) FROM $arap WHERE $where - AND ${table}_id > 0)|; + AND ${table}_id > 0|; my $sth = $dbh->prepare($query); $sth->execute || $self->dberror($query); @@ -2106,6 +2121,38 @@ sub get_partsgroup { } +sub get_pricegroup { + $main::lxdebug->enter_sub(); + + my ($self, $myconfig, $p) = @_; + + my $dbh = $self->dbconnect($myconfig); + + my $query = qq|SELECT p.id, p.pricegroup + FROM pricegroup p|; + + $query .= qq| + ORDER BY pricegroup|; + + if ($p->{all}) { + $query = qq|SELECT id, pricegroup FROM pricegroup + ORDER BY pricegroup|; + } + + my $sth = $dbh->prepare($query); + $sth->execute || $self->dberror($query); + + $self->{all_pricegroup} = (); + while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { + push @{ $self->{all_pricegroup} }, $ref; + } + $sth->finish; + $dbh->disconnect; + + $main::lxdebug->leave_sub(); +} + + sub audittrail { my ($self, $dbh, $myconfig, $audittrail) = @_; @@ -2166,7 +2213,7 @@ sub audittrail { $query = qq|INSERT INTO audittrail (trans_id, tablename, reference, formname, action, employee_id, transdate) VALUES ( $audittrail->{id}, '$audittrail->{tablename}', | - .$dbh->quote($audittrail->{reference}).qq|', + .$dbh->quote($audittrail->{reference}).qq|, '$audittrail->{formname}', '$audittrail->{action}', $employee_id, '$audittrail->{transdate}')|; } else {