Revision 94f18b16
Von Sven Schöling vor mehr als 7 Jahren hinzugefügt
bin/mozilla/oe.pl | ||
---|---|---|
59 | 59 |
|
60 | 60 |
use strict; |
61 | 61 |
|
62 |
our %TMPL_VAR; |
|
63 |
|
|
64 | 62 |
1; |
65 | 63 |
|
66 | 64 |
# end of main |
... | ... | |
477 | 475 |
|
478 | 476 |
# Container for template variables. Unfortunately this has to be |
479 | 477 |
# visible in form_footer too, so package local level and not my here. |
480 |
%TMPL_VAR = ();
|
|
478 |
my $TMPL_VAR = $::request->cache('tmpl_var', {});
|
|
481 | 479 |
if ($form->{id}) { |
482 |
$TMPL_VAR{oe_obj} = SL::DB::Order->new(id => $form->{id})->load; |
|
480 |
$TMPL_VAR->{oe_obj} = SL::DB::Order->new(id => $form->{id})->load;
|
|
483 | 481 |
} |
484 |
$TMPL_VAR{vc_obj} = SL::DB::Customer->new(id => $form->{customer_id})->load if $form->{customer_id}; |
|
485 |
$TMPL_VAR{vc_obj} = SL::DB::Vendor->new(id => $form->{vendor_id})->load if $form->{vendor_id}; |
|
482 |
$TMPL_VAR->{vc_obj} = SL::DB::Customer->new(id => $form->{customer_id})->load if $form->{customer_id};
|
|
483 |
$TMPL_VAR->{vc_obj} = SL::DB::Vendor->new(id => $form->{vendor_id})->load if $form->{vendor_id};
|
|
486 | 484 |
|
487 | 485 |
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig); |
488 | 486 |
|
... | ... | |
498 | 496 |
$form->{"delivered"} ? "checked" : "", $locale->text('Delivery Order(s) for full qty created') if $form->{"type"} =~ /_order$/; |
499 | 497 |
push @tmp, sprintf qq|<input name="closed" id="closed" type="checkbox" class="checkbox" value="1" %s><label for="closed">%s</label>|, |
500 | 498 |
$form->{"closed"} ? "checked" : "", $locale->text('Closed') if $form->{id}; |
501 |
$TMPL_VAR{openclosed} = sprintf qq|<tr><td colspan=%d align=center>%s</td></tr>\n|, 2 * scalar @tmp, join "\n", @tmp if @tmp; |
|
499 |
$TMPL_VAR->{openclosed} = sprintf qq|<tr><td colspan=%d align=center>%s</td></tr>\n|, 2 * scalar @tmp, join "\n", @tmp if @tmp;
|
|
502 | 500 |
|
503 | 501 |
my $vc = $form->{vc} eq "customer" ? "customers" : "vendors"; |
504 | 502 |
|
... | ... | |
526 | 524 |
@old_ids_cond, |
527 | 525 |
]); |
528 | 526 |
|
529 |
$TMPL_VAR{ALL_PROJECTS} = SL::DB::Manager::Project->get_all_sorted(query => \@conditions); |
|
530 |
$form->{ALL_PROJECTS} = $TMPL_VAR{ALL_PROJECTS}; # make projects available for second row drop-down in io.pl |
|
527 |
$TMPL_VAR->{ALL_PROJECTS} = SL::DB::Manager::Project->get_all_sorted(query => \@conditions);
|
|
528 |
$form->{ALL_PROJECTS} = $TMPL_VAR->{ALL_PROJECTS}; # make projects available for second row drop-down in io.pl
|
|
531 | 529 |
|
532 | 530 |
# label subs |
533 | 531 |
my $employee_list_query_gen = sub { $::form->{$_[0]} ? [ or => [ id => $::form->{$_[0]}, deleted => 0 ] ] : [ deleted => 0 ] }; |
534 |
$TMPL_VAR{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => $employee_list_query_gen->('employee_id')); |
|
535 |
$TMPL_VAR{ALL_SALESMEN} = SL::DB::Manager::Employee->get_all_sorted(query => $employee_list_query_gen->('salesman_id')); |
|
536 |
$TMPL_VAR{ALL_SHIPTO} = SL::DB::Manager::Shipto->get_all_sorted(query => [ |
|
532 |
$TMPL_VAR->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => $employee_list_query_gen->('employee_id'));
|
|
533 |
$TMPL_VAR->{ALL_SALESMEN} = SL::DB::Manager::Employee->get_all_sorted(query => $employee_list_query_gen->('salesman_id'));
|
|
534 |
$TMPL_VAR->{ALL_SHIPTO} = SL::DB::Manager::Shipto->get_all_sorted(query => [
|
|
537 | 535 |
or => [ trans_id => $::form->{"$::form->{vc}_id"} * 1, and => [ shipto_id => $::form->{shipto_id} * 1, trans_id => undef ] ] |
538 | 536 |
]); |
539 |
$TMPL_VAR{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(query => [ |
|
537 |
$TMPL_VAR->{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(query => [
|
|
540 | 538 |
or => [ |
541 | 539 |
cp_cv_id => $::form->{"$::form->{vc}_id"} * 1, |
542 | 540 |
and => [ |
... | ... | |
545 | 543 |
] |
546 | 544 |
] |
547 | 545 |
]); |
548 |
$TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} }; |
|
546 |
$TMPL_VAR->{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
|
|
549 | 547 |
|
550 | 548 |
# currencies and exchangerate |
551 | 549 |
$form->{currency} = $form->{defaultcurrency} unless $form->{currency}; |
552 |
$TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency}; |
|
550 |
$TMPL_VAR->{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
|
|
553 | 551 |
push @custom_hiddens, "forex"; |
554 | 552 |
push @custom_hiddens, "exchangerate" if $form->{forex}; |
555 | 553 |
|
556 | 554 |
# credit remaining |
557 | 555 |
my $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0; |
558 |
$TMPL_VAR{is_credit_remaining_negativ} = ($form->{creditremaining} =~ /-/) ? "0" : "1"; |
|
556 |
$TMPL_VAR->{is_credit_remaining_negativ} = ($form->{creditremaining} =~ /-/) ? "0" : "1";
|
|
559 | 557 |
|
560 | 558 |
# business |
561 |
$TMPL_VAR{business_label} = ($form->{vc} eq "customer" ? $locale->text('Customer type') : $locale->text('Vendor type')); |
|
559 |
$TMPL_VAR->{business_label} = ($form->{vc} eq "customer" ? $locale->text('Customer type') : $locale->text('Vendor type'));
|
|
562 | 560 |
|
563 | 561 |
push @custom_hiddens, "customer_pricegroup_id" if $form->{vc} eq 'customer'; |
564 | 562 |
|
... | ... | |
566 | 564 |
|
567 | 565 |
my $follow_up_vc = $form->{ $form->{vc} eq 'customer' ? 'customer' : 'vendor' }; |
568 | 566 |
$follow_up_vc =~ s/--\d*\s*$//; |
569 |
$TMPL_VAR{follow_up_trans_info} = ($form->{type} =~ /_quotation$/ ? $form->{quonumber} : $form->{ordnumber}) . " ($follow_up_vc)"; |
|
567 |
$TMPL_VAR->{follow_up_trans_info} = ($form->{type} =~ /_quotation$/ ? $form->{quonumber} : $form->{ordnumber}) . " ($follow_up_vc)";
|
|
570 | 568 |
|
571 | 569 |
if ($form->{id}) { |
572 | 570 |
my $follow_ups = FU->follow_ups('trans_id' => $form->{id}, 'not_done' => 1); |
573 | 571 |
|
574 | 572 |
if (scalar @{ $follow_ups }) { |
575 |
$TMPL_VAR{num_follow_ups} = scalar @{ $follow_ups }; |
|
576 |
$TMPL_VAR{num_due_follow_ups} = sum map { $_->{due} * 1 } @{ $follow_ups }; |
|
573 |
$TMPL_VAR->{num_follow_ups} = scalar @{ $follow_ups };
|
|
574 |
$TMPL_VAR->{num_due_follow_ups} = sum map { $_->{due} * 1 } @{ $follow_ups };
|
|
577 | 575 |
} |
578 | 576 |
} |
579 | 577 |
|
... | ... | |
589 | 587 |
} |
590 | 588 |
|
591 | 589 |
$::request->{layout}->add_javascripts_inline("\$(function(){$dispatch_to_popup});"); |
592 |
$TMPL_VAR{dateformat} = $myconfig{dateformat}; |
|
593 |
$TMPL_VAR{numberformat} = $myconfig{numberformat}; |
|
590 |
$TMPL_VAR->{dateformat} = $myconfig{dateformat};
|
|
591 |
$TMPL_VAR->{numberformat} = $myconfig{numberformat};
|
|
594 | 592 |
|
595 | 593 |
if ($form->{type} eq 'sales_order') { |
596 | 594 |
if (!$form->{periodic_invoices_config}) { |
... | ... | |
624 | 622 |
|
625 | 623 |
push @custom_hiddens, map { "shiptocvar_" . $_->name } @{ SL::DB::Manager::CustomVariableConfig->get_all(where => [ module => 'ShipTo' ]) }; |
626 | 624 |
|
627 |
$TMPL_VAR{HIDDENS} = [ map { name => $_, value => $form->{$_} }, |
|
625 |
$TMPL_VAR->{HIDDENS} = [ map { name => $_, value => $form->{$_} },
|
|
628 | 626 |
qw(id type vc proforma queued printed emailed |
629 | 627 |
title creditlimit creditremaining tradediscount business |
630 | 628 |
max_dunning_level dunning_amount |
... | ... | |
634 | 632 |
@custom_hiddens, |
635 | 633 |
map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts} ]; # deleted: discount |
636 | 634 |
|
637 |
%TMPL_VAR = ( |
|
638 |
%TMPL_VAR, |
|
639 |
%type_check_vars, |
|
640 |
); |
|
635 |
$TMPL_VAR->{$_} = $type_check_vars{$_} for keys %type_check_vars; |
|
641 | 636 |
|
642 |
$TMPL_VAR{ORDER_PROBABILITIES} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ]; |
|
637 |
$TMPL_VAR->{ORDER_PROBABILITIES} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ];
|
|
643 | 638 |
|
644 | 639 |
if ($type_check_vars{is_sales} && $::instance_conf->get_transport_cost_reminder_article_number_id) { |
645 |
$TMPL_VAR{transport_cost_reminder_article} = SL::DB::Part->new(id => $::instance_conf->get_transport_cost_reminder_article_number_id)->load; |
|
640 |
$TMPL_VAR->{transport_cost_reminder_article} = SL::DB::Part->new(id => $::instance_conf->get_transport_cost_reminder_article_number_id)->load;
|
|
646 | 641 |
} |
647 | 642 |
|
648 |
print $form->parse_html_template("oe/form_header", { %TMPL_VAR }); |
|
643 |
print $form->parse_html_template("oe/form_header", { |
|
644 |
%$TMPL_VAR, |
|
645 |
%type_check_vars, |
|
646 |
}); |
|
649 | 647 |
|
650 | 648 |
$main::lxdebug->leave_sub(); |
651 | 649 |
} |
... | ... | |
663 | 661 |
|
664 | 662 |
my $introws = max 5, $form->numtextrows($form->{intnotes}, 35, 8); |
665 | 663 |
|
666 |
$TMPL_VAR{notes} = qq|<textarea name="notes" class="texteditor" wrap="soft" style="width: 350px; height: 150px">| . H($form->{notes}) . qq|</textarea>|; |
|
667 |
$TMPL_VAR{intnotes} = qq|<textarea name=intnotes rows="$introws" cols="35">| . H($form->{intnotes}) . qq|</textarea>|; |
|
664 |
my $TMPL_VAR = $::request->cache('tmpl_var', {}); |
|
665 |
|
|
666 |
$TMPL_VAR->{notes} = qq|<textarea name="notes" class="texteditor" wrap="soft" style="width: 350px; height: 150px">| . H($form->{notes}) . qq|</textarea>|; |
|
667 |
$TMPL_VAR->{intnotes} = qq|<textarea name=intnotes rows="$introws" cols="35">| . H($form->{intnotes}) . qq|</textarea>|; |
|
668 | 668 |
|
669 | 669 |
if( $form->{customer_id} && !$form->{taxincluded_changed_by_user} ) { |
670 | 670 |
my $customer = SL::DB::Customer->new(id => $form->{customer_id})->load(); |
... | ... | |
678 | 678 |
$form->{invtotal} += $form->{"${item}_total"} = $form->round_amount( $form->{"${item}_base"} * $form->{"${item}_rate"}, 2); |
679 | 679 |
$form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2); |
680 | 680 |
|
681 |
$TMPL_VAR{tax} .= qq| |
|
681 |
$TMPL_VAR->{tax} .= qq|
|
|
682 | 682 |
<tr> |
683 | 683 |
<th align=right>$form->{"${item}_description"} | . $form->{"${item}_rate"} * 100 .qq|%</th> |
684 | 684 |
<td align=right>$form->{"${item}_total"}</td> |
... | ... | |
693 | 693 |
$form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2); |
694 | 694 |
$form->{"${item}_netto"} = $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2); |
695 | 695 |
|
696 |
$TMPL_VAR{tax} .= qq| |
|
696 |
$TMPL_VAR->{tax} .= qq|
|
|
697 | 697 |
<tr> |
698 | 698 |
<th align=right>Enthaltene $form->{"${item}_description"} | . $form->{"${item}_rate"} * 100 .qq|%</th> |
699 | 699 |
<td align=right>$form->{"${item}_total"}</td> |
... | ... | |
714 | 714 |
); |
715 | 715 |
$form->{oldinvtotal} = $form->{invtotal}; |
716 | 716 |
|
717 |
$TMPL_VAR{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted(); |
|
717 |
$TMPL_VAR->{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_all_sorted();
|
|
718 | 718 |
|
719 | 719 |
my $print_options_html = setup_sales_purchase_print_options(); |
720 | 720 |
|
721 | 721 |
print $form->parse_html_template("oe/form_footer", { |
722 |
%TMPL_VAR, |
|
722 |
%$TMPL_VAR,
|
|
723 | 723 |
print_options => $print_options_html, |
724 | 724 |
is_sales => scalar ($form->{type} =~ /^sales_/), # these vars are exported, so that the template |
725 | 725 |
is_order => scalar ($form->{type} =~ /_order$/), # may determine what to show |
Auch abrufbar als: Unified diff
oe: implizite global %TMPL_VAR in den request cache verschoben.