X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=4ad3cbf2fe66810cf2410c77ac1e24768fc0bf1a;hb=cff1389b37e5adfde7734718a02290421aa1bf9a;hp=a050e746a014c503da1d294ab9d9337ab59868f9;hpb=c607fb403082a05a5c9f16b084de5b99203bfad7;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index a050e746a..4ad3cbf2f 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -41,8 +41,10 @@ use CGI; use List::MoreUtils qw(any uniq apply); use List::Util qw(min max first); +use SL::ClientJS; use SL::CVar; use SL::Common; +use SL::Controller::Base; use SL::CT; use SL::Locale::String qw(t8); use SL::IC; @@ -351,8 +353,8 @@ sub display_row { $column_data{price_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $price->invalid, title => $price->invalid }) if $price->invalid; $column_data{price_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $price->missing, title => $price->missing }) if $price->missing; if (!$price->missing && !$price->invalid) { - $column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png', alt => t8('This price has since gone up'), title => t8('This price has since gone up' ) }) if $price->price > $record_item->sellprice; - $column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This price has since gone down'), title => t8('This price has since gone down') }) if $price->price < $record_item->sellprice; + $column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png', alt => t8('This price has since gone up'), title => t8('This price has since gone up' ) }) if $price->price - $record_item->sellprice > 0.01; + $column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This price has since gone down'), title => t8('This price has since gone down') }) if $price->price - $record_item->sellprice < -0.01; $column_data{price_source} .= ' ' . $cgi->img({src => 'image/ok.png', alt => t8('There is a better price available'), title => t8('There is a better price available') }) if $best_price && $price->source ne $price_source->best_price->source; } } @@ -360,8 +362,8 @@ sub display_row { $column_data{discount_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $discount->invalid, title => $discount->invalid }) if $discount->invalid; $column_data{discount_source} .= ' ' . $cgi->img({src => 'image/flag-red.png', alt => $discount->missing, title => $discount->missing }) if $discount->missing; if (!$discount->missing && !$discount->invalid) { - $column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png', alt => t8('This discount has since gone up'), title => t8('This discount has since gone up') }) if $discount->discount * 100 > $record_item->discount; - $column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This discount has since gone down'), title => t8('This discount has since gone down') }) if $discount->discount * 100 < $record_item->discount; + $column_data{price_source} .= ' ' . $cgi->img({src => 'image/up.png', alt => t8('This discount has since gone up'), title => t8('This discount has since gone up') }) if $discount->discount * 100 - $record_item->discount > 0.01; + $column_data{price_source} .= ' ' . $cgi->img({src => 'image/down.png', alt => t8('This discount has since gone down'), title => t8('This discount has since gone down') }) if $discount->discount * 100 - $record_item->discount < -0.01; $column_data{price_source} .= ' ' . $cgi->img({src => 'image/ok.png', alt => t8('There is a better discount available'), title => t8('There is a better discount available') }) if $best_discount && $discount->source ne $price_source->best_discount->source; } } @@ -760,15 +762,6 @@ sub check_form { $form->{creditremaining} -= &invoicetotal; } - #sk - # if pricegroups - if ( $form->{type} =~ (/sales_quotation/) - or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/)) - or (($form->{level} eq undef) and ($form->{type} =~ /invoice/)) - or ($form->{type} =~ /sales_order/)) { - - } - &display_form; $main::lxdebug->leave_sub(); @@ -1205,6 +1198,7 @@ sub print_options { my %dont_display_groupitems = ( 'dunning' => 1, + 'letter' => 1, ); my %template_vars = ( @@ -1501,11 +1495,13 @@ sub print_form { format_dates($output_dateformat, $output_longdates, qw(invdate orddate quodate pldate duedate reqdate transdate shippingdate deliverydate validitydate paymentdate - datepaid transdate_oe deliverydate_oe dodate + datepaid transdate_oe transdate_do transdate_quo deliverydate_oe dodate employee_startdate employee_enddate ), grep({ /^datepaid_\d+$/ || /^transdate_oe_\d+$/ || + /^transdate_do_\d+$/ || + /^transdate_quo_\d+$/ || /^deliverydate_oe_\d+$/ || /^reqdate_\d+$/ || /^deliverydate_\d+$/ || @@ -1805,20 +1801,35 @@ sub relink_accounts { $main::lxdebug->leave_sub(); } -sub set_duedate { - $main::lxdebug->enter_sub(); +sub get_payment_terms_for_invoice { + my $terms = $::form->{payment_id} ? SL::DB::PaymentTerm->new(id => $::form->{payment_id}) ->load + : $::form->{customer_id} ? SL::DB::Customer ->new(id => $::form->{customer_id})->load->payment + : $::form->{vendor_id} ? SL::DB::Vendor ->new(id => $::form->{vendor_id}) ->load->payment + : undef; - my $form = $main::form; - my %myconfig = %main::myconfig; + return $terms; +} +sub set_duedate { _check_io_auth(); - my $invdate = $form->{invdate} eq 'undefined' ? undef : $form->{invdate}; - my $duedate = $form->get_duedate(\%myconfig, $invdate); + my $js = SL::ClientJS->new(controller => SL::Controller::Base->new); + my $terms = get_payment_terms_for_invoice(); + my $invdate = $::form->{invdate} eq 'undefined' ? DateTime->today_local : DateTime->from_kivitendo($::form->{invdate}); + my $duedate = $terms ? $terms->calc_date(reference_date => $invdate, due_date => $::form->{duedate})->to_kivitendo : ($::form->{duedate} || $invdate->to_kivitendo); - print $form->ajax_response_header() . ($duedate || $invdate); + if ($terms && $terms->auto_calculation) { + $js->hide('#duedate_container') + ->show('#duedate_fixed') + ->html('#duedate_fixed', $duedate); - $main::lxdebug->leave_sub(); + } else { + $js->show('#duedate_container') + ->hide('#duedate_fixed'); + } + + $js->val('#duedate', $duedate) + ->render; } sub _update_part_information { @@ -2033,15 +2044,18 @@ sub _make_record_item { : $class->new; for my $method (apply { s/_$row$// } grep { /_$row$/ } keys %$::form) { - next unless $obj->meta->column($method); - if ($obj->meta->column($method)->isa('Rose::DB::Object::Metadata::Column::Date')) { - $obj->${\"$method\_as_date"}($::form->{"$method\_$row"}); - } elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::(?:Numeric|Float|DoublePrecsion)$/) { - $obj->${\"$method\_as_number"}($::form->{"$method\_$row"}); - } elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::Boolean$/) { - $obj->$method(!!$::form->{$method}); + if ($obj->meta->column($method)) { + if ($obj->meta->column($method)->isa('Rose::DB::Object::Metadata::Column::Date')) { + $obj->${\"$method\_as_date"}($::form->{"$method\_$row"}); + } elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::(?:Numeric|Float|DoublePrecsion)$/) { + $obj->${\"$method\_as_number"}($::form->{"$method\_$row"}); + } elsif ((ref $obj->meta->column($method)) =~ /^Rose::DB::Object::Metadata::Column::Boolean$/) { + $obj->$method(!!$::form->{$method}); + } else { + $obj->$method($::form->{"$method\_$row"}); + } } else { - $obj->$method($::form->{"$method\_$row"}); + $obj->{__additional_form_attributes}{$method} = $::form->{"$method\_$row"}; } }