Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 36c672e1

Von Niklas Schmidt vor 8 Tagen hinzugefügt

  • ID 36c672e19be590333556d44c2c8f06bacfd2821b
  • Vorgänger f92d73ce
  • Nachfolger 12dc7305

bin/mozilla/oe.pl: entferne toten Code (Schritt 2)

-sub set_headings {
-sub setup_oe_action_bar {
-sub form_header {
-sub form_footer {
-sub display_form {

Beachte: in sub invoice wird sub display_form aus ir.pl aufgerufen

Unterschiede anzeigen:

bin/mozilla/oe.pl
return 0;
}
sub set_headings {
$main::lxdebug->enter_sub();
my $form = $main::form;
my $locale = $main::locale;
check_oe_access();
my ($action) = @_;
if ($form->{type} eq 'purchase_order') {
$form->{title} = $action eq "edit" ?
$locale->text('Edit Purchase Order') :
$locale->text('Add Purchase Order');
$form->{heading} = $locale->text('Purchase Order');
$form->{vc} = 'vendor';
}
if ($form->{type} eq 'sales_order') {
$form->{title} = $action eq "edit" ?
$locale->text('Edit Sales Order') :
$locale->text('Add Sales Order');
$form->{heading} = $locale->text('Sales Order');
$form->{vc} = 'customer';
}
if ($form->{type} eq 'request_quotation') {
$form->{title} = $action eq "edit" ?
$locale->text('Edit Request for Quotation') :
$locale->text('Add Request for Quotation');
$form->{heading} = $locale->text('Request for Quotation');
$form->{vc} = 'vendor';
}
if ($form->{type} eq 'sales_quotation') {
$form->{title} = $action eq "edit" ?
$locale->text('Edit Quotation') :
$locale->text('Add Quotation');
$form->{heading} = $locale->text('Quotation');
$form->{vc} = 'customer';
}
$main::lxdebug->leave_sub();
}
sub convert_to_delivery_orders {
# collect order ids
my @multi_ids = map {
......
$main::lxdebug->leave_sub();
}
sub setup_oe_action_bar {
my %params = @_;
my $form = $::form;
my $has_active_periodic_invoice;
if ($params{oe_obj}) {
$has_active_periodic_invoice =
$params{oe_obj}->is_type('sales_order')
&& $params{oe_obj}->periodic_invoices_config
&& $params{oe_obj}->periodic_invoices_config->active
&& ( !$params{oe_obj}->periodic_invoices_config->end_date
|| ($params{oe_obj}->periodic_invoices_config->end_date > DateTime->today_local))
&& $params{oe_obj}->periodic_invoices_config->get_previous_billed_period_start_date;
}
my $allow_invoice = $params{is_req_quo}
|| $params{is_pur_ord}
|| ($params{is_sales_quo} && $::instance_conf->get_allow_sales_invoice_from_sales_quotation)
|| ($params{is_sales_ord} && $::instance_conf->get_allow_sales_invoice_from_sales_order);
my @req_trans_cost_art = qw(kivi.SalesPurchase.check_transport_cost_article_presence) x!!$::instance_conf->get_transport_cost_reminder_article_number_id;
my @warn_p_invoice = qw(kivi.SalesPurchase.oe_warn_save_active_periodic_invoice) x!!$has_active_periodic_invoice;
for my $bar ($::request->layout->get('actionbar')) {
$bar->add(
action => [
t8('Update'),
submit => [ '#form', { action => "update" } ],
id => 'update_button',
accesskey => 'enter',
],
combobox => [
action => [
t8('Save'),
submit => [ '#form', { action => "save" } ],
checks => [ 'kivi.validate_form', @req_trans_cost_art, @warn_p_invoice ],
],
action => [
t8('Save as new'),
submit => [ '#form', { action => "save_as_new" } ],
checks => [ 'kivi.validate_form', @req_trans_cost_art ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
],
action => [
t8('Save and Close'),
submit => [ '#form', { action => "save_and_close" } ],
checks => [ 'kivi.validate_form', @req_trans_cost_art, @warn_p_invoice ],
],
action => [
t8('Delete'),
submit => [ '#form', { action => "delete" } ],
confirm => t8('Do you really want to delete this object?'),
disabled => !$form->{id} ? t8('This record has not been saved yet.')
: ( ($params{is_sales_ord} && !$::instance_conf->get_sales_order_show_delete)
|| ($params{is_pur_ord} && !$::instance_conf->get_purchase_order_show_delete)) ? t8('Deleting this type of record has been disabled in the configuration.')
: undef,
],
], # end of combobox "Save"
'separator',
combobox => [
action => [ t8('Workflow') ],
action => [
t8('Sales Order'),
submit => [ '#form', { action => "sales_order" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
checks => [ 'kivi.validate_form' ],
only_if => $params{is_sales_quo} || $params{is_pur_ord},
],
action => [
t8('Purchase Order'),
submit => [ '#form', { action => "purchase_order" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
checks => [ 'kivi.validate_form' ],
only_if => $params{is_sales_ord} || $params{is_req_quo},
],
action => [
t8('Delivery Order'),
submit => [ '#form', { action => "delivery_order" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
checks => [ 'kivi.validate_form' ],
only_if => $params{is_sales_ord} || $params{is_pur_ord},
],
action => [
t8('Invoice'),
submit => [ '#form', { action => "invoice" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
checks => [ 'kivi.validate_form' ],
only_if => $allow_invoice,
],
action => [
t8('Quotation'),
submit => [ '#form', { action => "quotation" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
checks => [ 'kivi.validate_form' ],
only_if => $params{is_sales_ord},
],
action => [
t8('Request for Quotation'),
submit => [ '#form', { action => "request_for_quotation" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
checks => [ 'kivi.validate_form' ],
only_if => $params{is_pur_ord},
],
], # end of combobox "Workflow"
combobox => [
action => [ t8('Export') ],
action => [
t8('Print'),
call => [ 'kivi.SalesPurchase.show_print_dialog' ],
checks => [ 'kivi.validate_form' ],
],
action => [
t8('E Mail'),
call => [ 'kivi.SalesPurchase.show_email_dialog' ],
checks => [ 'kivi.validate_form' ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
],
action => [
t8('Download attachments of all parts'),
call => [ 'kivi.File.downloadOrderitemsFiles', $::form->{type}, $::form->{id} ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
only_if => $::instance_conf->get_doc_storage,
],
], #end of combobox "Export"
combobox => [
action => [ t8('more') ],
action => [
t8('History'),
call => [ 'set_history_window', $form->{id} * 1, 'id' ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
],
action => [
t8('Follow-Up'),
call => [ 'follow_up_window' ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
],
], # end of combobox "more"
);
}
$::request->layout->add_javascripts('kivi.Validator.js');
}
sub setup_oe_search_action_bar {
my %params = @_;
......
}
}
sub form_header {
$main::lxdebug->enter_sub();
my @custom_hiddens;
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
my $cgi = $::request->{cgi};
check_oe_access();
# Container for template variables. Unfortunately this has to be
# visible in form_footer too, so package local level and not my here.
my $TMPL_VAR = $::request->cache('tmpl_var', {});
if ($form->{id}) {
$TMPL_VAR->{oe_obj} = SL::DB::Order->new(id => $form->{id})->load;
}
$TMPL_VAR->{vc_obj} = SL::DB::Customer->new(id => $form->{customer_id})->load if $form->{customer_id};
$TMPL_VAR->{vc_obj} = SL::DB::Vendor->new(id => $form->{vendor_id})->load if $form->{vendor_id};
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
my $current_employee = SL::DB::Manager::Employee->current;
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
$form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
$form->{employee_id} ||= $current_employee->id;
$form->{salesman_id} ||= $current_employee->id;
# openclosed checkboxes
my @tmp;
push @tmp, sprintf qq|<input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" %s><label for="delivered">%s</label>|,
$form->{"delivered"} ? "checked" : "", $locale->text('Delivery Order(s) for full qty created') if $form->{"type"} =~ /_order$/;
push @tmp, sprintf qq|<input name="closed" id="closed" type="checkbox" class="checkbox" value="1" %s><label for="closed">%s</label>|,
$form->{"closed"} ? "checked" : "", $locale->text('Closed') if $form->{id};
$TMPL_VAR->{openclosed} = sprintf qq|<tr><td colspan=%d align=center>%s</td></tr>\n|, 2 * scalar @tmp, join "\n", @tmp if @tmp;
my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
$form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
"currencies" => "ALL_CURRENCIES",
"price_factors" => "ALL_PRICE_FACTORS");
$form->{ALL_PAYMENTS} = SL::DB::Manager::PaymentTerm->get_all( where => [ or => [ obsolete => 0, id => $form->{payment_id} || undef ] ]);
$form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all_sorted;
$form->{ALL_LANGUAGES} = SL::DB::Manager::Language->get_all_sorted;
# Projects
my @old_project_ids = uniq grep { $_ } map { $_ * 1 } ($form->{"globalproject_id"}, map { $form->{"project_id_$_"} } 1..$form->{"rowcount"});
my @old_ids_cond = @old_project_ids ? (id => \@old_project_ids) : ();
my @customer_cond;
if (($vc eq 'customers') && $::instance_conf->get_customer_projects_only_in_sales) {
@customer_cond = (
or => [
customer_id => $::form->{customer_id},
billable_customer_id => $::form->{customer_id},
]);
}
my @conditions = (
or => [
and => [ active => 1, @customer_cond ],
@old_ids_cond,
]);
$TMPL_VAR->{ALL_PROJECTS} = SL::DB::Manager::Project->get_all_sorted(query => \@conditions);
$TMPL_VAR->{ALL_DELIVERY_TERMS} = SL::DB::Manager::DeliveryTerm->get_valid($form->{delivery_term_id});
$form->{ALL_PROJECTS} = $TMPL_VAR->{ALL_PROJECTS}; # make projects available for second row drop-down in io.pl
# label subs
my $employee_list_query_gen = sub { $::form->{$_[0]} ? [ or => [ id => $::form->{$_[0]}, deleted => 0 ] ] : [ deleted => 0 ] };
$TMPL_VAR->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => $employee_list_query_gen->('employee_id'));
$TMPL_VAR->{ALL_SALESMEN} = SL::DB::Manager::Employee->get_all_sorted(query => $employee_list_query_gen->('salesman_id'));
$TMPL_VAR->{ALL_SHIPTO} = SL::DB::Manager::Shipto->get_all_sorted(query => [
or => [ and => [ trans_id => $::form->{"$::form->{vc}_id"} * 1, module => 'CT' ], and => [ shipto_id => $::form->{shipto_id} * 1, trans_id => undef ] ]
]);
$TMPL_VAR->{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all_sorted(query => [
or => [
cp_cv_id => $::form->{"$::form->{vc}_id"} * 1,
and => [
cp_cv_id => undef,
cp_id => $::form->{cp_id} * 1
]
]
]);
$TMPL_VAR->{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
# currencies and exchangerate
$form->{currency} = $form->{defaultcurrency} unless $form->{currency};
$TMPL_VAR->{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
push @custom_hiddens, "forex";
push @custom_hiddens, "exchangerate" if $form->{forex};
# credit remaining
my $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0;
$TMPL_VAR->{is_credit_remaining_negativ} = ($form->{creditremaining} =~ /-/) ? "0" : "1";
# business
$TMPL_VAR->{business_label} = ($form->{vc} eq "customer" ? $locale->text('Customer type') : $locale->text('Vendor type'));
push @custom_hiddens, "customer_pricegroup_id" if $form->{vc} eq 'customer';
my $credittext = $locale->text('Credit Limit exceeded!!!');
my $follow_up_vc = $form->{ $form->{vc} eq 'customer' ? 'customer' : 'vendor' };
$follow_up_vc =~ s/--\d*\s*$//;
$TMPL_VAR->{follow_up_trans_info} = ($form->{type} =~ /_quotation$/ ? $form->{quonumber} : $form->{ordnumber}) . " ($follow_up_vc)";
if ($form->{id}) {
my $follow_ups = FU->follow_ups('trans_id' => $form->{id}, 'not_done' => 1);
if (scalar @{ $follow_ups }) {
$TMPL_VAR->{num_follow_ups} = scalar @{ $follow_ups };
$TMPL_VAR->{num_due_follow_ups} = sum map { $_->{due} * 1 } @{ $follow_ups };
}
}
my $dispatch_to_popup = '';
if ($form->{resubmit} && ($form->{format} eq "html")) {
$dispatch_to_popup = "window.open('about:blank','Beleg'); document.oe.target = 'Beleg';";
$dispatch_to_popup .= "document.do.submit();";
} elsif ($form->{resubmit} && $form->{action_print}) {
# emulate click for resubmitting actions
$dispatch_to_popup = "kivi.SalesPurchase.show_print_dialog(); kivi.SalesPurchase.print_record();";
} elsif ($creditwarning) {
$::request->{layout}->add_javascripts_inline("alert('$credittext');");
}
$::request->{layout}->add_javascripts_inline("\$(function(){$dispatch_to_popup});");
$TMPL_VAR->{dateformat} = $myconfig{dateformat};
$TMPL_VAR->{numberformat} = $myconfig{numberformat};
$TMPL_VAR->{longdescription_dialog_size_percentage} = SL::Helper::UserPreferences::DisplayPreferences->new()->get_longdescription_dialog_size_percentage();
if ($form->{type} eq 'sales_order') {
if (!$form->{periodic_invoices_config}) {
$form->{periodic_invoices_status} = $locale->text('not configured');
} else {
my $config = SL::YAML::Load($form->{periodic_invoices_config});
$form->{periodic_invoices_status} = $config->{active} ? $locale->text('active') : $locale->text('inactive');
}
}
$::request->{layout}->use_javascript(map { "${_}.js" } qw(kivi.SalesPurchase kivi.File kivi.Part kivi.CustomerVendor kivi.Validator show_form_details show_history show_vc_details ckeditor5/ckeditor ckeditor5/translations/de kivi.io));
# original snippets:
my %type_check_vars = (
is_sales => scalar($form->{type} =~ /^sales_/),
is_order => scalar($form->{type} =~ /_order$/),
is_sales_quo => scalar($form->{type} =~ /sales_quotation$/),
is_req_quo => scalar($form->{type} =~ /request_quotation$/),
is_sales_ord => scalar($form->{type} =~ /sales_order$/),
is_pur_ord => scalar($form->{type} =~ /purchase_order$/),
);
setup_oe_action_bar(
%type_check_vars,
oe_obj => $TMPL_VAR->{oe_obj},
vc_obj => $TMPL_VAR->{vc_obj},
);
$form->header;
if ($form->{CFDD_shipto} && $form->{CFDD_shipto_id} ) {
$form->{shipto_id} = $form->{CFDD_shipto_id};
}
$TMPL_VAR->{HIDDENS} = [ map { name => $_, value => $form->{$_} },
qw(id type vc proforma queued printed emailed
title creditlimit creditremaining tradediscount business
max_dunning_level dunning_amount
CFDD_shipto CFDD_shipto_id
taxpart taxservice taxaccounts cursor_fokus
show_details useasnew),
@custom_hiddens,
map { $_.'_rate', $_.'_description', $_.'_taxnumber', $_.'_tax_id' } split / /, $form->{taxaccounts} ]; # deleted: discount
$TMPL_VAR->{$_} = $type_check_vars{$_} for keys %type_check_vars;
$TMPL_VAR->{ORDER_PROBABILITIES} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ];
if ($type_check_vars{is_sales} && $::instance_conf->get_transport_cost_reminder_article_number_id) {
$TMPL_VAR->{transport_cost_reminder_article} = SL::DB::Part->new(id => $::instance_conf->get_transport_cost_reminder_article_number_id)->load;
}
print $form->parse_html_template("oe/form_header", {
%$TMPL_VAR,
%type_check_vars,
});
$main::lxdebug->leave_sub();
}
sub form_footer {
$main::lxdebug->enter_sub();
my $form = $main::form;
my %myconfig = %main::myconfig;
my $locale = $main::locale;
check_oe_access();
$form->{invtotal} = $form->{invsubtotal};
my $TMPL_VAR = $::request->cache('tmpl_var', {});
if( $form->{customer_id} && !$form->{taxincluded_changed_by_user} ) {
my $customer = SL::DB::Customer->new(id => $form->{customer_id})->load();
$form->{taxincluded} = defined($customer->taxincluded_checked) ? $customer->taxincluded_checked : $myconfig{taxincluded_checked};
}
if (!$form->{taxincluded}) {
foreach my $item (split / /, $form->{taxaccounts}) {
if ($form->{"${item}_base"}) {
$form->{invtotal} += $form->{"${item}_total"} = $form->round_amount( $form->{"${item}_base"} * $form->{"${item}_rate"}, 2);
$form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
$TMPL_VAR->{tax} .= qq|
<tr>
<th align=right>$form->{"${item}_description"}&nbsp;| . $form->{"${item}_rate"} * 100 .qq|%</th>
<td align=right>$form->{"${item}_total"}</td>
</tr> |;
}
}
} else {
foreach my $item (split / /, $form->{taxaccounts}) {
if ($form->{"${item}_base"}) {
$form->{"${item}_total"} = $form->round_amount( ($form->{"${item}_base"} * $form->{"${item}_rate"} / (1 + $form->{"${item}_rate"})), 2);
$form->{"${item}_netto"} = $form->round_amount( ($form->{"${item}_base"} - $form->{"${item}_total"}), 2);
$form->{"${item}_total"} = $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
$form->{"${item}_netto"} = $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
$TMPL_VAR->{tax} .= qq|
<tr>
<th align=right>Enthaltene $form->{"${item}_description"}&nbsp;| . $form->{"${item}_rate"} * 100 .qq|%</th>
<td align=right>$form->{"${item}_total"}</td>
</tr>
<tr>
<th align=right>Nettobetrag</th>
<td align=right>$form->{"${item}_netto"}</td>
</tr> |;
}
}
}
my $grossamount = $form->{invtotal};
$form->{invtotal} = $form->round_amount( $form->{invtotal}, 2, 1);
$form->{rounding} = $form->round_amount(
$form->{invtotal} - $form->round_amount($grossamount, 2),
2
);
$form->{oldinvtotal} = $form->{invtotal};
my $print_options_html = setup_sales_purchase_print_options();
my $shipto_cvars = SL::DB::Shipto->new->cvars_by_config;
foreach my $var (@{ $shipto_cvars }) {
my $name = "shiptocvar_" . $var->config->name;
$var->value($form->{$name}) if exists $form->{$name};
}
print $form->parse_html_template("oe/form_footer", {
%$TMPL_VAR,
print_options => $print_options_html,
is_sales => scalar ($form->{type} =~ /^sales_/), # these vars are exported, so that the template
is_order => scalar ($form->{type} =~ /_order$/), # may determine what to show
is_sales_quo => scalar ($form->{type} =~ /sales_quotation$/),
is_req_quo => scalar ($form->{type} =~ /request_quotation$/),
is_sales_ord => scalar ($form->{type} =~ /sales_order$/),
is_pur_ord => scalar ($form->{type} =~ /purchase_order$/),
shipto_cvars => $shipto_cvars,
});
$main::lxdebug->leave_sub();
}
sub search {
$main::lxdebug->enter_sub();
......
invoice();
}
######################################################################################################
# IO ENTKOPPLUNG
# ###############################################################################################
sub display_form {
$main::lxdebug->enter_sub();
my $form = $main::form;
my %myconfig = %main::myconfig;
check_oe_access();
retrieve_partunits() if ($form->{type} =~ /_delivery_order$/);
$form->{"taxaccounts"} =~ s/\s*$//;
$form->{"taxaccounts"} =~ s/^\s*//;
foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
map({ delete($form->{"${accno}_${_}"}); } qw(rate description taxnumber));
}
$form->{"taxaccounts"} = "";
IC->retrieve_accounts(\%myconfig, $form, map { $_ => $form->{"id_$_"} } 1 .. $form->{rowcount});
$form->{rowcount}++;
$form->{"project_id_$form->{rowcount}"} = $form->{globalproject_id};
$form->language_payment(\%myconfig);
Common::webdav_folder($form);
&form_header;
# create rows
display_row($form->{rowcount}) if $form->{rowcount};
&form_footer;
$main::lxdebug->leave_sub();
}
sub report_for_todo_list {
$main::lxdebug->enter_sub();

Auch abrufbar als: Unified diff