X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=98bb4dbe24c0d426bb4b61f3004be31af5069504;hb=88dea78ecdb77761f71c5016ca97e53b2d55d9d3;hp=c29097289d0cae8d07eda6cfeff7daedb5fcbc8b;hpb=67588d37a1fcdaed2ffdac55feaea26e488537d4;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index c29097289..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; @@ -469,7 +470,7 @@ sub header { # standard css for all # this should gradually move to the layouts that need it $layout->use_stylesheet("$_.css") for qw( - main menu common list_accounts jquery.autocomplete + common main menu list_accounts jquery.autocomplete jquery.multiselect2side ui-lightness/jquery-ui jquery-ui.custom @@ -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"; @@ -621,36 +622,12 @@ sub _prepare_html_template { ::end_of_request(); } - if ($self->{"DEBUG"}) { - $additional_params->{"DEBUG"} = $self->{"DEBUG"}; - } - - if ($additional_params->{"DEBUG"}) { - $additional_params->{"DEBUG"} = - "
DEBUG INFORMATION:
" . $additional_params->{"DEBUG"} . "
"; - } - - if (%main::myconfig) { - $::myconfig{jsc_dateformat} = apply { - s/d+/\%d/gi; - s/m+/\%m/gi; - s/y+/\%Y/gi; - } $::myconfig{"dateformat"}; - $additional_params->{"myconfig"} ||= \%::myconfig; - map { $additional_params->{"myconfig_${_}"} = $main::myconfig{$_}; } keys %::myconfig; - } - + $additional_params->{AUTH} = $::auth; $additional_params->{INSTANCE_CONF} = $::instance_conf; - - if (my $debug_options = $::lx_office_conf{debug}{options}) { - map { $additional_params->{'DEBUG_' . uc($_)} = $debug_options->{$_} } keys %$debug_options; - } - - if ($main::auth && $main::auth->{RIGHTS} && $main::auth->{RIGHTS}->{$self->{login}}) { - while (my ($key, $value) = each %{ $main::auth->{RIGHTS}->{$self->{login}} }) { - $additional_params->{"AUTH_RIGHTS_" . uc($key)} = $value; - } - } + $additional_params->{LOCALE} = $::locale; + $additional_params->{LXCONFIG} = \%::lx_office_conf; + $additional_params->{LXDEBUG} = $::lxdebug; + $additional_params->{MYCONFIG} = \%::myconfig; $main::lxdebug->leave_sub(); @@ -971,10 +948,17 @@ sub parse_amount { } sub round_amount { - my ($self, $amount, $places) = @_; + my ($self, $amount, $places, $adjust) = @_; 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); + } + # We use Perl's knowledge of string representation for # rounding. First, convert the floating point number to a string # with a high number of places. Then split the string on the decimal @@ -1877,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"}); @@ -1895,6 +1879,7 @@ sub add_shipto { shiptozipcode = ?, shiptocity = ?, shiptocountry = ?, + shiptogln = ?, shiptocontact = ?, shiptocp_gender = ?, shiptophone = ?, @@ -1911,6 +1896,7 @@ sub add_shipto { shiptozipcode = ? AND shiptocity = ? AND shiptocountry = ? AND + shiptogln = ? AND shiptocontact = ? AND shiptocp_gender = ? AND shiptophone = ? AND @@ -1922,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); } } @@ -2607,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) = @_; @@ -2878,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; @@ -2891,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; @@ -2999,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 { @@ -3671,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);