$has_charge = 1;
map { $_->{has_charge} = 1; } @parts;
}
+ my $has_ean = 0;
+ if (defined($parts[0]->{ean})) {
+ $has_ean = 1;
+ map { $_->{has_ean} = 1; } @parts;
+ }
my $old_form = save_form();
"nextsub" => "select_part_internal",
"callback_sub" => $callback_sub,
"has_charge" => $has_charge,
+ "has_ean" => $has_ean,
"remap_parts_id" => $remap_parts_id,
"remap_partnumber" => $remap_partnumber });
}
}
- map { $form->{$_} = $options{$_} if ($options{$_}) } qw(no_services no_assemblies click_button);
+ map { $form->{$_} = $options{$_} if ($options{$_}) } qw(no_services no_assemblies assemblies click_button);
$parts = Common->retrieve_parts(\%myconfig, $form, $order_by, $order_dir);
sub calculate_qty {
$lxdebug->enter_sub();
- my @variable_sort = ();
- my %variable_list = ();
- my $unit_list = ();
$form->{formel} =~ s/\r\n//g;
my ($variable_string, $formel) = split /###/,$form->{formel};
-
- split m/;/, $variable_string;
- foreach $item (@_) {
- my($name, $valueunit) = split /=/,$item;
- my($value, $unit) = split / /, $valueunit;
-
- push(@variable_sort, $value);
- $variable_list{$value} = $name;
- $unit_list{$value} = $unit;
+ foreach $item (split m/;/, $variable_string) {
+ next unless $item =~ m/^ \s* (\w+) \s* = \s* (\w+) \s* (\w+) \s* $/x;
+ push @variable, {
+ description => $1,
+ name => $2,
+ unit => $3,
+ };
}
my @header_sort = qw(variable value unit);
- my %header_title = ( "variable" => $locale->text("Variable"),
- "value" => $locale->text("Value"),
- "unit" => $locale->text("Unit"),
- );
-
- my @variable = map(+{ "description" => $variable_list{$_},
- "name" => $_,
- "unit" => $unit_list{$_} }, @variable_sort);
+ my %header_title = (
+ variable => $locale->text("Variable"),
+ value => $locale->text("Value"),
+ unit => $locale->text("Unit"),
+ );
+ my @header = map +{
+ column_title => $header_title{$_},
+ column => $_,
+ }, @header_sort;
- my @header =
- map(+{ "column_title" => $header_title{$_},
- "column" => $_,
- },
- @header_sort);
$form->{formel} = $formel;
- $form->{"title"} = $locale->text("Please enter values");
+ $form->{title} = $locale->text("Please enter values");
$form->header();
- print($form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header,
+ print $form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header,
"VARIABLES" => \@variable,
- "onload" => $onload }));
+ "onload" => $onload });
$lxdebug->leave_sub();
}
$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})) {
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})) {
$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})) {
} else {
my $referer = $ENV{HTTP_REFERER};
- $referer =~ s/^(.*)action\=.*\&(.*)$/$1action\=mark_as_paid\&mark_as_paid\=1\&id\=$form->{id}\&$2/;
+ if ($referer =~ /action/) {
+ $referer =~ /^(.*)\?action\=[^\&]*(\&.*)$/;
+ $script = $1;
+ $callback = $2;
+ } else {
+ $script = $referer;
+ $callback = "";
+ }
+ $referer = $script . "?action=mark_as_paid&mark_as_paid=1&id=$form->{id}" . $callback;
$form->header();
print qq|<body>|;
print qq|<p><b>|.$locale->text('Mark as paid?').qq|</b></p>|;
$cov->{address} =~ s{^,}{}x;
$cov->{address} =~ s{\ +}{\ }gx;
- $cov->{contact} = join " ", map { $cov->{$_} } qw(cp_greeting cp_title cp_givenname cp_name);
+ $cov->{contact} = join " ", map { $cov->{$_} } qw(cp_gender cp_title cp_givenname cp_name);
$cov->{contact} =~ s{\ +}{\ }gx;
}
$lxdebug->leave_sub();
}
-=item cross BLOCK ARRAY ARRAY
-
-Evaluates BLOCK for each combination of elements in ARRAY1 and ARRAY2
-and returns a new list consisting of BLOCK's return values.
-The two elements are set to $a and $b.
-Note that those two are aliases to the original value so changing them
-will modify the input arrays.
-
- # append each to each
- @a = qw/a b c/;
- @b = qw/1 2 3/;
- @x = pairwise { "$a$b" } @a, @b;
- # returns a1, a2, a3, b1, b2, b3, c1, c2, c3
-
-As cross expects an array but returns a list it is not directly chainable
-at the moment. This will be corrected in the future.
-
-=cut
-sub cross(&\@\@) {
- my $op = shift;
- use vars qw/@A @B/;
- local (*A, *B) = @_; # syms for caller's input arrays
-
- # Localise $a, $b
- my ($caller_a, $caller_b) = do {
- my $pkg = caller();
- no strict 'refs';
- \*{$pkg.'::a'}, \*{$pkg.'::b'};
- };
-
- local(*$caller_a, *$caller_b);
-
- # This map expression is also the return value.
- map { my $a_index = $_;
- map { my $b_index = $_;
- # assign to $a, $b as refs to caller's array elements
- (*$caller_a, *$caller_b) = \($A[$a_index], $B[$b_index]);
- $op->(); # perform the transformation
- } 0 .. $#B;
- } 0 .. $#A;
+
+# Functions to call add routines beneath different reports
+
+sub sales_invoice {
+ $lxdebug->enter_sub();
+
+ $auth->assert('invoice_edit');
+
+
+ $form->{script} = 'is.pl';
+ $script = "is";
+ $form->{type} = "invoice";
+ $locale = new Locale "$myconfig{countrycode}", "$script";
+
+ require "bin/mozilla/$form->{script}";
+ &add;
+
+ $lxdebug->leave_sub();
+}
+
+sub ar_transaction {
+ $lxdebug->enter_sub();
+
+ $auth->assert('general_ledger');
+
+
+ $form->{script} = 'ar.pl';
+ $script = "ar";
+ $locale = new Locale "$myconfig{countrycode}", "$script";
+
+ require "bin/mozilla/$form->{script}";
+ &add;
+
+ $lxdebug->leave_sub();
+}
+
+sub vendor_invoice {
+ $lxdebug->enter_sub();
+
+ $auth->assert('invoice_edit');
+
+
+ $form->{script} = 'ir.pl';
+ $script = "ir";
+ $form->{type} = "invoice";
+ $locale = new Locale "$myconfig{countrycode}", "$script";
+
+ require "bin/mozilla/$form->{script}";
+ &add;
+
+ $lxdebug->leave_sub();
+}
+
+sub ap_transaction {
+ $lxdebug->enter_sub();
+
+ $auth->assert('general_ledger');
+
+
+ $form->{script} = 'ap.pl';
+ $script = "ap";
+ $locale = new Locale "$myconfig{countrycode}", "$script";
+
+ require "bin/mozilla/$form->{script}";
+ &add;
+
+ $lxdebug->leave_sub();
+}
+
+sub gl_transaction {
+ $lxdebug->enter_sub();
+
+ $auth->assert('general_ledger');
+
+
+ $form->{script} = 'gl.pl';
+ $script = "gl";
+ $locale = new Locale "$myconfig{countrycode}", "$script";
+
+ require "bin/mozilla/$form->{script}";
+ &add;
+
+ $lxdebug->leave_sub();
}
1;