401 |
401 |
my $locale = $main::locale;
|
402 |
402 |
my $cgi = $::request->{cgi};
|
403 |
403 |
|
404 |
|
my %TMPL_VAR = ();
|
|
404 |
my $TMPL_VAR = $::request->cache('tmpl_var', {});
|
405 |
405 |
my @custom_hiddens;
|
406 |
406 |
|
407 |
|
$TMPL_VAR{invoice_obj} = SL::DB::PurchaseInvoice->load_cached($form->{id}) if $form->{id};
|
408 |
|
$TMPL_VAR{vendor_obj} = SL::DB::Vendor->load_cached($form->{vendor_id}) if $form->{vendor_id};
|
|
407 |
$TMPL_VAR->{invoice_obj} = SL::DB::PurchaseInvoice->load_cached($form->{id}) if $form->{id};
|
|
408 |
$TMPL_VAR->{vendor_obj} = SL::DB::Vendor->load_cached($form->{vendor_id}) if $form->{vendor_id};
|
409 |
409 |
my $current_employee = SL::DB::Manager::Employee->current;
|
410 |
410 |
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
|
411 |
411 |
$form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
|
... | ... | |
416 |
416 |
|
417 |
417 |
my @old_project_ids = uniq grep { $_ } map { $_ * 1 } ($form->{"globalproject_id"}, map { $form->{"project_id_$_"} } 1..$form->{"rowcount"});
|
418 |
418 |
my @conditions = @old_project_ids ? (id => \@old_project_ids) : ();
|
419 |
|
$TMPL_VAR{ALL_PROJECTS} = SL::DB::Manager::Project->get_all_sorted(query => [ or => [ active => 1, @conditions ]]);
|
420 |
|
$form->{ALL_PROJECTS} = $TMPL_VAR{ALL_PROJECTS}; # make projects available for second row drop-down in io.pl
|
|
419 |
$TMPL_VAR->{ALL_PROJECTS} = SL::DB::Manager::Project->get_all_sorted(query => [ or => [ active => 1, @conditions ]]);
|
|
420 |
$form->{ALL_PROJECTS} = $TMPL_VAR->{ALL_PROJECTS}; # make projects available for second row drop-down in io.pl
|
421 |
421 |
|
422 |
422 |
$form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
|
423 |
423 |
"currencies" => "ALL_CURRENCIES",
|
424 |
424 |
"price_factors" => "ALL_PRICE_FACTORS");
|
425 |
425 |
|
426 |
|
$TMPL_VAR{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted;
|
427 |
|
$TMPL_VAR{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{employee_id}, deleted => 0 ] ]);
|
428 |
|
$TMPL_VAR{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(query => [
|
|
426 |
$TMPL_VAR->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted;
|
|
427 |
$TMPL_VAR->{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();
|
|
428 |
$TMPL_VAR->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ or => [ id => $::form->{employee_id}, deleted => 0 ] ]);
|
|
429 |
$TMPL_VAR->{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(query => [
|
429 |
430 |
or => [
|
430 |
431 |
cp_cv_id => $::form->{"$::form->{vc}_id"} * 1,
|
431 |
432 |
and => [
|
... | ... | |
441 |
442 |
$form->{currency} = $form->{defaultcurrency} unless $form->{currency};
|
442 |
443 |
# show_exchangerate is also later needed in another template
|
443 |
444 |
$form->{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
|
444 |
|
$TMPL_VAR{currencies} = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
|
|
445 |
$TMPL_VAR->{currencies} = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
|
445 |
446 |
'-values' => \@values, '-labels' => \%labels,
|
446 |
447 |
'-onchange' => "document.getElementById('update_button').click();"
|
447 |
448 |
)) if scalar @values;
|
448 |
449 |
push @custom_hiddens, "forex";
|
449 |
450 |
push @custom_hiddens, "exchangerate" if $form->{forex};
|
450 |
451 |
|
451 |
|
$TMPL_VAR{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update};
|
452 |
|
$TMPL_VAR{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/;
|
|
452 |
$TMPL_VAR->{creditwarning} = ($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update};
|
|
453 |
$TMPL_VAR->{is_credit_remaining_negativ} = $form->{creditremaining} =~ /-/;
|
453 |
454 |
|
454 |
455 |
# set option selected
|
455 |
456 |
foreach my $item (qw(AP)) {
|
... | ... | |
457 |
458 |
$form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
|
458 |
459 |
}
|
459 |
460 |
|
460 |
|
$TMPL_VAR{is_format_html} = $form->{format} eq 'html';
|
461 |
|
$TMPL_VAR{dateformat} = $myconfig{dateformat};
|
462 |
|
$TMPL_VAR{numberformat} = $myconfig{numberformat};
|
463 |
|
$TMPL_VAR{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
|
|
461 |
$TMPL_VAR->{is_format_html} = $form->{format} eq 'html';
|
|
462 |
$TMPL_VAR->{dateformat} = $myconfig{dateformat};
|
|
463 |
$TMPL_VAR->{numberformat} = $myconfig{numberformat};
|
|
464 |
$TMPL_VAR->{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
|
464 |
465 |
|
465 |
466 |
# hiddens
|
466 |
|
$TMPL_VAR{HIDDENS} = [qw(
|
|
467 |
$TMPL_VAR->{HIDDENS} = [qw(
|
467 |
468 |
id type queued printed emailed title vc discount
|
468 |
469 |
title creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
|
469 |
470 |
max_dunning_level dunning_amount
|
... | ... | |
473 |
474 |
), @custom_hiddens,
|
474 |
475 |
map { $_.'_rate', $_.'_description', $_.'_taxnumber', $_.'_tax_id' } split / /, $form->{taxaccounts}];
|
475 |
476 |
|
476 |
|
$TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice();
|
477 |
|
$form->{duedate} = $TMPL_VAR{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{duedate})->to_kivitendo if $TMPL_VAR{payment_terms_obj};
|
|
477 |
$TMPL_VAR->{payment_terms_obj} = get_payment_terms_for_invoice();
|
|
478 |
$form->{duedate} = $TMPL_VAR->{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{duedate})->to_kivitendo if $TMPL_VAR->{payment_terms_obj};
|
478 |
479 |
|
479 |
480 |
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.Draft kivi.File kivi.SalesPurchase kivi.Part kivi.CustomerVendor kivi.Validator ckeditor/ckeditor ckeditor/adapters/jquery kivi.io autocomplete_project client_js));
|
480 |
481 |
|
... | ... | |
482 |
483 |
|
483 |
484 |
$form->header();
|
484 |
485 |
|
485 |
|
print $form->parse_html_template("ir/form_header", \%TMPL_VAR);
|
|
486 |
print $form->parse_html_template("ir/form_header", $TMPL_VAR);
|
486 |
487 |
|
487 |
488 |
$main::lxdebug->leave_sub();
|
488 |
489 |
}
|
... | ... | |
518 |
519 |
$form->{invtotal} = $form->{invsubtotal};
|
519 |
520 |
$form->{oldinvtotal} = $form->{invtotal};
|
520 |
521 |
|
|
522 |
my $TMPL_VAR = $::request->cache('tmpl_var', {});
|
|
523 |
|
521 |
524 |
# tax, total and subtotal calculations
|
522 |
525 |
my ($tax, $subtotal);
|
523 |
526 |
$form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ];
|
... | ... | |
580 |
583 |
$totalpaid += $form->{"paid_$i"};
|
581 |
584 |
}
|
582 |
585 |
|
583 |
|
$form->{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();
|
584 |
|
|
585 |
586 |
print $form->parse_html_template('ir/form_footer', {
|
|
587 |
%$TMPL_VAR,
|
586 |
588 |
totalpaid => $totalpaid,
|
587 |
589 |
paid_missing => $form->{invtotal} - $totalpaid,
|
588 |
590 |
show_storno => $form->{id} && !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ap") && !$totalpaid,
|
design40: DeliveryTerms in alles alten controllern im form_header sichtbar machen