X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=98bb4dbe24c0d426bb4b61f3004be31af5069504;hb=88dea78ecdb77761f71c5016ca97e53b2d55d9d3;hp=b9263004be7bdbfd395a0758391ad106a3fbee96;hpb=73a78da630ce363f70062447dd82a8a0ece8cd89;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index b9263004b..98bb4dbe2 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -75,6 +75,7 @@ use SL::PrefixedNumber; use SL::Request; use SL::Template; use SL::User; +use SL::Util; use SL::X; use Template; use URI; @@ -480,7 +481,7 @@ sub header { jquery jquery-ui jquery.cookie jquery.checkall jquery.download jquery/jquery.form jquery/fixes client_js jquery/jquery.tooltipster.min - common part_selection switchmenuframe + common part_selection ), "jquery/ui/i18n/jquery.ui.datepicker-$::myconfig{countrycode}"); $self->{favicon} ||= "favicon.ico"; @@ -951,6 +952,8 @@ sub round_amount { return 0 if !defined $amount; + $places //= 0; + if ($adjust) { my $precision = $::instance_conf->get_precision || 0.01; return $self->round_amount( $self->round_amount($amount / $precision, 0) * $precision, $places); @@ -1858,7 +1861,7 @@ sub add_shipto { my $shipto; my @values; - foreach my $item (qw(name department_1 department_2 street zipcode city country + foreach my $item (qw(name department_1 department_2 street zipcode city country gln contact cp_gender phone fax email)) { if ($self->{"shipto$item"}) { $shipto = 1 if ($self->{$item} ne $self->{"shipto$item"}); @@ -1876,6 +1879,7 @@ sub add_shipto { shiptozipcode = ?, shiptocity = ?, shiptocountry = ?, + shiptogln = ?, shiptocontact = ?, shiptocp_gender = ?, shiptophone = ?, @@ -1892,6 +1896,7 @@ sub add_shipto { shiptozipcode = ? AND shiptocity = ? AND shiptocountry = ? AND + shiptogln = ? AND shiptocontact = ? AND shiptocp_gender = ? AND shiptophone = ? AND @@ -1903,9 +1908,9 @@ sub add_shipto { if(!$insert_check){ $query = qq|INSERT INTO shipto (trans_id, shiptoname, shiptodepartment_1, shiptodepartment_2, - shiptostreet, shiptozipcode, shiptocity, shiptocountry, + shiptostreet, shiptozipcode, shiptocity, shiptocountry, shiptogln, shiptocontact, shiptocp_gender, shiptophone, shiptofax, shiptoemail, module) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; do_query($self, $dbh, $query, $id, @values, $module); } } @@ -2588,6 +2593,19 @@ sub all_vc { $main::lxdebug->leave_sub(); } +sub new_lastmtime { + my ($self, $table, $option) = @_; + + return unless $self->{id}; + croak ("wrong call, no valid table defined") unless $table =~ /^(oe|ar|ap|delivery_orders|parts)$/; + + my $query = "SELECT mtime, itime FROM " . $table . " WHERE id = ?"; + my $ref = selectfirst_hashref_query($self, $self->get_standard_dbh, $query, $self->{id}); + $ref->{mtime} ||= $ref->{itime}; + $self->{lastmtime} = $ref->{mtime}; + $main::lxdebug->message(LXDebug->DEBUG2(),"new lastmtime=".$self->{lastmtime}); +} + sub mtime_ischanged { my ($self, $table, $option) = @_; @@ -2859,7 +2877,9 @@ sub create_links { d.closedto, d.revtrans, (SELECT cu.name FROM currencies cu WHERE cu.id=d.currency_id) AS defaultcurrency, (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, - (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno + (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, + (SELECT c.accno FROM chart c WHERE d.rndgain_accno_id = c.id) AS rndgain_accno, + (SELECT c.accno FROM chart c WHERE d.rndloss_accno_id = c.id) AS rndloss_accno FROM defaults d|; $ref = selectfirst_hashref_query($self, $dbh, $query); map { $self->{$_} = $ref->{$_} } keys %$ref; @@ -2872,7 +2892,9 @@ sub create_links { current_date AS transdate, d.closedto, d.revtrans, (SELECT cu.name FROM currencies cu WHERE cu.id=d.currency_id) AS defaultcurrency, (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, - (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno + (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, + (SELECT c.accno FROM chart c WHERE d.rndgain_accno_id = c.id) AS rndgain_accno, + (SELECT c.accno FROM chart c WHERE d.rndloss_accno_id = c.id) AS rndloss_accno FROM defaults d|; $ref = selectfirst_hashref_query($self, $dbh, $query); map { $self->{$_} = $ref->{$_} } keys %$ref; @@ -2980,19 +3002,9 @@ sub current_date { } sub like { - $main::lxdebug->enter_sub(); - my ($self, $string) = @_; - if ($string !~ /%/) { - $string = "%$string%"; - } - - $string =~ s/\'/\'\'/g; - - $main::lxdebug->leave_sub(); - - return $string; + return "%" . SL::Util::trim($string // '') . "%"; } sub redo_rows { @@ -3652,11 +3664,12 @@ sub calculate_tax { my ($self,$amount,$taxrate,$taxincluded,$roundplaces) = @_; - $roundplaces = 2 unless defined $roundplaces; + $roundplaces //= 2; + $taxincluded //= 0; my $tax; - if ($taxincluded *= 1) { + if ($taxincluded) { # calculate tax (unrounded), subtract from amount, round amount and round tax $tax = $amount - ($amount / ($taxrate + 1)); # equivalent to: taxrate * amount / (taxrate + 1) $amount = $self->round_amount($amount - $tax, $roundplaces);