X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fcommon.pl;h=59c2f9481671e2090b4b05617a31b2a9f109eb21;hb=fc41222c61dbee590005f04c50e8603581462543;hp=17dac992e529617cb37beeb279f52212b372cb4c;hpb=b65a230d60e86d2c18a3ab7222379905aea5ecd7;p=kivitendo-erp.git diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 17dac992e..59c2f9481 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -10,9 +10,11 @@ ###################################################################### use SL::Common; +use SL::DB::Helper::Mappings; use SL::DBUtils; use SL::Form; use SL::MoreCommon; +use SL::Helper::Flash; use strict; @@ -76,6 +78,11 @@ sub select_part { $has_charge = 1; map { $_->{has_charge} = 1; } @parts; } + my $has_bestbefore = 0; + if (defined($parts[0]->{bestbefore})) { + $has_bestbefore = 1; + map { $_->{has_bestbefore} = 1; } @parts; + } my $has_ean = 0; if (defined($parts[0]->{ean})) { $has_ean = 1; @@ -92,6 +99,7 @@ sub select_part { "nextsub" => "select_part_internal", "callback_sub" => $callback_sub, "has_charge" => $has_charge, + "has_bestbefore" => $has_bestbefore, "has_ean" => $has_ean, "remap_parts_id" => $remap_parts_id, "remap_partnumber" => $remap_partnumber }); @@ -161,12 +169,11 @@ sub part_selection_internal { map { $form->{$_} = $options{$_} if ($options{$_}) } qw(no_services no_assemblies assemblies click_button); my $parts = Common->retrieve_parts(\%myconfig, $form, $order_by, $order_dir); - my $onload; if (0 == scalar(@{$parts})) { $form->show_generic_information($locale->text("No part was found matching the search parameters.")); } elsif (1 == scalar(@{$parts})) { - $onload = "part_selected('1')"; + $::request->{layout}->add_javascripts_inline("part_selected('1')"); } map { $parts->[$_]->{selected} = $_ ? 0 : 1; } (0..$#{$parts}); @@ -176,7 +183,7 @@ sub part_selection_internal { my @header_sort = qw(partnumber description); my %header_title = ( "partnumber" => $locale->text("Part Number"), - "description" => $locale->text("Part description"), + "description" => $locale->text("Part Description"), ); my @header = @@ -189,10 +196,9 @@ sub part_selection_internal { $form->{formname} ||= 'Form'; $form->{title} = $locale->text("Select a part"); - $form->header(); + $form->header(no_layout => 1); print $form->parse_html_template("generic/part_selection", { "HEADER" => \@header, - "PARTS" => $parts, - "onload" => $onload }); + "PARTS" => $parts, }); $main::lxdebug->leave_sub(); } @@ -214,11 +220,10 @@ sub delivery_customer_selection { my $delivery = Common->retrieve_delivery_customer(\%myconfig, $form, $order_by, $order_dir); map({ $delivery->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$delivery})); - my $onload; if (0 == scalar(@{$delivery})) { $form->show_generic_information($locale->text("No Customer was found matching the search parameters.")); } elsif (1 == scalar(@{$delivery})) { - $onload = "customer_selected('1')"; + $::request->{layout}->add_javascripts_inline("customer_selected('1')"); } my $callback = "$form->{script}?action=delivery_customer_selection&"; @@ -239,10 +244,9 @@ sub delivery_customer_selection { @header_sort); $form->{"title"} = $locale->text("Select a Customer"); - $form->header(); + $form->header(no_layout => 1); print $form->parse_html_template("generic/select_delivery_customer", { "HEADER" => \@header, - "DELIVERY" => $delivery, - "onload" => $onload }); + "DELIVERY" => $delivery, }); $main::lxdebug->leave_sub(); } @@ -264,11 +268,10 @@ sub vendor_selection { my $vendor = Common->retrieve_vendor(\%myconfig, $form, $order_by, $order_dir); map({ $vendor->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$vendor})); - my $onload; if (0 == scalar(@{$vendor})) { $form->show_generic_information($locale->text("No Vendor was found matching the search parameters.")); } elsif (1 == scalar(@{$vendor})) { - $onload = "vendor_selected('1')"; + $::request->{layout}->add_javascripts_inline("vendor_selected('1')"); } my $callback = "$form->{script}?action=vendor_selection&"; @@ -289,10 +292,9 @@ sub vendor_selection { @header_sort); $form->{"title"} = $locale->text("Select a Customer"); - $form->header(); + $form->header(no_layout => 1); print $form->parse_html_template("generic/select_vendor", { "HEADER" => \@header, - "VENDOR" => $vendor, - "onload" => $onload }); + "VENDOR" => $vendor, }); $main::lxdebug->leave_sub(); } @@ -309,7 +311,6 @@ sub calculate_qty { my ($variable_string, $formel) = split /###/,$form->{formel}; my @variable; - my $onload; # note! this sub is mostly called over a javascript invocation, and it's unlikey that onload is set. foreach my $item (split m/;/, $variable_string) { next unless $item =~ m/^ \s* (\w+) \s* = \s* (\w+) \s* (\w+) \s* $/x; @@ -333,10 +334,9 @@ sub calculate_qty { $form->{formel} = $formel; $form->{title} = $locale->text("Please enter values"); - $form->header(); + $form->header(no_layout => 1); print $form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header, - "VARIABLES" => \@variable, - "onload" => $onload }); + "VARIABLES" => \@variable, }); $main::lxdebug->leave_sub(); } @@ -350,7 +350,7 @@ sub set_longdescription { my $locale = $main::locale; $form->{title} = $locale->text("Enter longdescription"); - $form->header(); + $form->header(no_layout => 1); print $form->parse_html_template("generic/set_longdescription"); $main::lxdebug->leave_sub(); @@ -378,100 +378,11 @@ sub NTI { } sub format_dates { - $main::lxdebug->enter_sub(); - - my ($dateformat, $longformat, @indices) = @_; - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $dateformat = $myconfig{"dateformat"} unless ($dateformat); - - foreach my $idx (@indices) { - if ($form->{TEMPLATE_ARRAYS} && (ref($form->{TEMPLATE_ARRAYS}->{$idx}) eq "ARRAY")) { - for (my $i = 0; $i < scalar(@{$form->{TEMPLATE_ARRAYS}->{$idx}}); $i++) { - $form->{TEMPLATE_ARRAYS}->{$idx}->[$i] = - $locale->reformat_date(\%myconfig, $form->{TEMPLATE_ARRAYS}->{$idx}->[$i], - $dateformat, $longformat); - } - } - - next unless (defined($form->{$idx})); - - if (!ref($form->{$idx})) { - $form->{$idx} = $locale->reformat_date(\%myconfig, $form->{$idx}, - $dateformat, $longformat); - - } elsif (ref($form->{$idx}) eq "ARRAY") { - for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) { - $form->{$idx}->[$i] = - $locale->reformat_date(\%myconfig, $form->{$idx}->[$i], - $dateformat, $longformat); - } - } - } - - $main::lxdebug->leave_sub(); + return $::form->format_dates(@_); } sub reformat_numbers { - $main::lxdebug->enter_sub(); - - my ($numberformat, $places, @indices) = @_; - - my $form = $main::form; - my %myconfig = %main::myconfig; - - return $main::lxdebug->leave_sub() - if (!$numberformat || ($numberformat eq $myconfig{"numberformat"})); - - foreach my $idx (@indices) { - if ($form->{TEMPLATE_ARRAYS} && (ref($form->{TEMPLATE_ARRAYS}->{$idx}) eq "ARRAY")) { - for (my $i = 0; $i < scalar(@{$form->{TEMPLATE_ARRAYS}->{$idx}}); $i++) { - $form->{TEMPLATE_ARRAYS}->{$idx}->[$i] = $form->parse_amount(\%myconfig, $form->{TEMPLATE_ARRAYS}->{$idx}->[$i]); - } - } - - next unless (defined($form->{$idx})); - - if (!ref($form->{$idx})) { - $form->{$idx} = $form->parse_amount(\%myconfig, $form->{$idx}); - - } elsif (ref($form->{$idx}) eq "ARRAY") { - for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) { - $form->{$idx}->[$i] = - $form->parse_amount(\%myconfig, $form->{$idx}->[$i]); - } - } - } - - my $saved_numberformat = $myconfig{"numberformat"}; - $myconfig{"numberformat"} = $numberformat; - - foreach my $idx (@indices) { - if ($form->{TEMPLATE_ARRAYS} && (ref($form->{TEMPLATE_ARRAYS}->{$idx}) eq "ARRAY")) { - for (my $i = 0; $i < scalar(@{$form->{TEMPLATE_ARRAYS}->{$idx}}); $i++) { - $form->{TEMPLATE_ARRAYS}->{$idx}->[$i] = $form->format_amount(\%myconfig, $form->{TEMPLATE_ARRAYS}->{$idx}->[$i], $places); - } - } - - next unless (defined($form->{$idx})); - - if (!ref($form->{$idx})) { - $form->{$idx} = $form->format_amount(\%myconfig, $form->{$idx}, $places); - - } elsif (ref($form->{$idx}) eq "ARRAY") { - for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) { - $form->{$idx}->[$i] = - $form->format_amount(\%myconfig, $form->{$idx}->[$i], $places); - } - } - } - - $myconfig{"numberformat"} = $saved_numberformat; - - $main::lxdebug->leave_sub(); + return $::form->reformat_numbers(@_); } # ------------------------------------------------------------------------- @@ -488,12 +399,12 @@ sub show_history { $sort =~ s/.*\.(.*)/$1/; $form->{title} = $locale->text("History"); - $form->header(); + $form->header(no_layout => 1); print $form->parse_html_template( "common/show_history", { "DATEN" => $form->get_history($dbh,$form->{input_name},"",$form->{order}), "SUCCESS" => ($form->get_history($dbh,$form->{input_name}) ne "0"), uc($sort) => 1, - uc($sort)."BY" => $sortby + uc($sort)."BY" => $sortby, } ); $dbh->disconnect(); @@ -547,7 +458,7 @@ sub show_vc_details { $form->{title} = $form->{vc} eq "customer" ? $locale->text("Customer details") : $locale->text("Vendor details"); - $form->header(); + $form->header(no_layout => 1); print $form->parse_html_template("common/show_vc_details", { "is_customer" => $form->{vc} eq "customer" }); $main::lxdebug->leave_sub(); @@ -605,11 +516,9 @@ sub mark_as_paid_common { } $referer = $script . "?action=mark_as_paid&mark_as_paid=1&id=$form->{id}" . $callback; $form->header(); - print qq||; print qq|

|.$locale->text('Mark as paid?').qq|

|; print qq| |; print qq||; - print qq||; } $main::lxdebug->leave_sub(); @@ -632,11 +541,10 @@ sub cov_selection_internal { my $covs = Common->retrieve_customers_or_vendors(\%myconfig, $form, $order_by, $order_dir, $form->{"is_vendor"}, $form->{"allow_both"}); map({ $covs->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$covs})); - my $onload; if (0 == scalar(@{$covs})) { $form->show_generic_information(sprintf($locale->text("No %s was found matching the search parameters."), $type)); } elsif (1 == scalar(@{$covs})) { - $onload = "cov_selected('1')"; + $::request->{layout}->add_javascripts_inline("cov_selected('1')"); } my $callback = "$form->{script}?action=cov_selection_internal&"; @@ -668,8 +576,7 @@ sub cov_selection_internal { $form->{"title"} = $form->{is_vendor} ? $locale->text("Select a vendor") : $locale->text("Select a customer"); $form->header(); print($form->parse_html_template("generic/cov_selection", { "HEADER" => \@header, - "COVS" => $covs, - "onload" => $onload })); + "COVS" => $covs, })); $main::lxdebug->leave_sub(); } @@ -680,19 +587,7 @@ sub cov_selection_internal { sub sales_invoice { $main::lxdebug->enter_sub(); - $main::auth->assert('invoice_edit'); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $form->{script} = 'is.pl'; - my $script = "is"; - $form->{type} = "invoice"; - $locale = new Locale "$myconfig{countrycode}", "$script"; - - require "bin/mozilla/$form->{script}"; - &add; + print $::form->redirect_header('is.pl?action=add&type=invoice'); $main::lxdebug->leave_sub(); } @@ -700,18 +595,7 @@ sub sales_invoice { sub ar_transaction { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $form->{script} = 'ar.pl'; - my $script = "ar"; - $locale = new Locale "$myconfig{countrycode}", "$script"; - - require "bin/mozilla/$form->{script}"; - &add; + print $::form->redirect_header('ar.pl?action=add'); $main::lxdebug->leave_sub(); } @@ -719,19 +603,7 @@ sub ar_transaction { sub vendor_invoice { $main::lxdebug->enter_sub(); - $main::auth->assert('invoice_edit'); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $form->{script} = 'ir.pl'; - my $script = "ir"; - $form->{type} = "invoice"; - $locale = new Locale "$myconfig{countrycode}", "$script"; - - require "bin/mozilla/$form->{script}"; - &add; + print $::form->redirect_header('ir.pl?action=add&type=invoice'); $main::lxdebug->leave_sub(); } @@ -739,18 +611,7 @@ sub vendor_invoice { sub ap_transaction { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $form->{script} = 'ap.pl'; - my $script = "ap"; - $locale = new Locale "$myconfig{countrycode}", "$script"; - - require "bin/mozilla/$form->{script}"; - &add; + print $::form->redirect_header('ap.pl?action=add'); $main::lxdebug->leave_sub(); } @@ -758,20 +619,13 @@ sub ap_transaction { sub gl_transaction { $main::lxdebug->enter_sub(); - $main::auth->assert('general_ledger'); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - - $form->{script} = 'gl.pl'; - my $script = "gl"; - $locale = new Locale "$myconfig{countrycode}", "$script"; - - require "bin/mozilla/$form->{script}"; - &add; + print $::form->redirect_header('gl.pl?action=add'); $main::lxdebug->leave_sub(); } +sub db { + goto &SL::DB::Helper::Mappings::db; +} + 1;