X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=143696311499868152f9b9a5402f150cc4a64e16;hb=493457086f727b713cca06c25c1c3bedb92185af;hp=2ace9a7b434c58c380b4e810f8846f4376b0887b;hpb=2879330bd173831981bdd8b25fc1900292efaeac;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 2ace9a7b4..143696311 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -35,6 +35,7 @@ use SL::FU; use SL::IR; use SL::IS; use SL::PE; +use SL::DB::Default; use List::Util qw(max sum); require "bin/mozilla/io.pl"; @@ -283,21 +284,25 @@ sub form_header { my @old_project_ids = ($form->{"globalproject_id"}); map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"}; - $form->get_lists("contacts" => "ALL_CONTACTS", - "shipto" => "ALL_SHIPTO", - "projects" => { "key" => "ALL_PROJECTS", + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 0, "old_id" => \@old_project_ids }, - "employees" => "ALL_EMPLOYEES", "taxzones" => "ALL_TAXZONES", "currencies" => "ALL_CURRENCIES", "vendors" => "ALL_VENDORS", "departments" => "all_departments", "price_factors" => "ALL_PRICE_FACTORS"); - $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} }; -# $TMPL_VAR{shipto_labels} = sub { join "; ", grep { $_ } map { $_[0]->{"shipto${_}" } } qw(name department_1 street city) }; - $TMPL_VAR{contact_labels} = sub { join(', ', $_[0]->{"cp_name"}, $_[0]->{"cp_givenname"}) . ($_[0]->{cp_abteilung} ? " ($_[0]->{cp_abteilung})" : "") }; + $TMPL_VAR{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $::form->{employee_id}, deleted => 0 ] ]); + $TMPL_VAR{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all(query => [ + or => [ + cp_cv_id => $::form->{"$::form->{vc}_id"} * 1, + and => [ + cp_cv_id => undef, + cp_id => $::form->{cp_id} * 1 + ] + ] + ]); $TMPL_VAR{department_labels} = sub { "$_[0]->{description}--$_[0]->{id}" }; # customer @@ -312,7 +317,8 @@ sub form_header { my @values = map { $_ } @{ $form->{ALL_CURRENCIES} }; my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} }; $form->{currency} = $form->{defaultcurrency} unless $form->{currency}; - $TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency}; + # show_exchangerate is also later needed in another template + $form->{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency}; $TMPL_VAR{currencies} = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"}, '-values' => \@values, '-labels' => \%labels, '-onchange' => "document.getElementById('update_button').click();" @@ -323,7 +329,7 @@ sub form_header { $TMPL_VAR{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}; $TMPL_VAR{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/; - $form->{fokus} = "invoice.vendor"; + $::request->{layout}->focus('#vendor'); my $follow_up_vc = $form->{vendor}; $follow_up_vc =~ s/--\d*\s*$//; @@ -410,10 +416,10 @@ sub form_footer { for my $i (1 .. $form->{paidaccounts}) { $form->{"changeable_$i"} = 1; - if ($::lx_office_conf{features}->{payments_changeable} == 0) { + if (SL::DB::Default->get->payments_changeable == 0) { # never $form->{"changeable_$i"} = ($form->{"acc_trans_id_$i"})? 0 : 1; - } elsif ($::lx_office_conf{features}->{payments_changeable} == 2) { + } elsif (SL::DB::Default->get->payments_changeable == 2) { # on the same day $form->{"changeable_$i"} = (($form->{"gldate_$i"} eq '') || ($form->current_date(\%myconfig) eq $form->{"gldate_$i"})); @@ -434,7 +440,9 @@ sub form_footer { totalpaid => $totalpaid, paid_missing => $form->{invtotal} - $totalpaid, show_storno => $form->{id} && !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ap") && !$totalpaid, - show_delete => ($form->current_date(\%myconfig) eq $form->{gldate}), + show_delete => ($::instance_conf->get_ir_changeable == 2) + ? ($form->current_date(\%myconfig) eq $form->{gldate}) + : ($::instance_conf->get_ir_changeable == 1), }); ##print $form->parse_html_template('ir/_payments'); # parser ##print $form->parse_html_template('webdav/_list'); # parser @@ -463,10 +471,11 @@ sub update { $main::auth->assert('vendor_invoice_edit'); -# map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); - &check_name('vendor'); + if (!$form->{forex}) { # read exchangerate from input field (not hidden) + $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}); + } $form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); $form->{exchangerate} = $form->{forex} if $form->{forex}; @@ -569,6 +578,9 @@ sub storno { $form->error($locale->text("Invoice has already been storno'd!")); } + $form->error($locale->text('Cannot post storno for a closed period!')) + if ( $form->date_closed($form->{invdate}, \%myconfig)); + my $employee_id = $form->{employee_id}; invoice_links(); prepare_invoice(); @@ -597,7 +609,7 @@ sub storno { } -sub use_as_template { +sub use_as_new { $main::lxdebug->enter_sub(); my $form = $main::form; @@ -771,8 +783,6 @@ sub delete { $form->header; print qq| - -
{script}> |;