X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Farap.pl;h=1ed40a7f942b3b58c47961223edd1246fd3cd754;hb=e09347c89ca119213c4d8ba43083653cda793399;hp=f2e4e822b7a712453e5e95609c06cadb2a17c2fd;hpb=ef17e41a8364c6c97566a054768f573659dbec79;p=kivitendo-erp.git diff --git a/bin/mozilla/arap.pl b/bin/mozilla/arap.pl index f2e4e822b..1ed40a7f9 100644 --- a/bin/mozilla/arap.pl +++ b/bin/mozilla/arap.pl @@ -30,21 +30,29 @@ # common routines for gl, ar, ap, is, ir, oe # +use SL::Projects; + # any custom scripts for this one -if (-f "$form->{path}/custom_arap.pl") { - eval { require "$form->{path}/custom_arap.pl"; }; +if (-f "bin/mozilla/custom_arap.pl") { + eval { require "bin/mozilla/custom_arap.pl"; }; } -if (-f "$form->{path}/$form->{login}_arap.pl") { - eval { require "$form->{path}/$form->{login}_arap.pl"; }; +if (-f "bin/mozilla/$form->{login}_arap.pl") { + eval { require "bin/mozilla/$form->{login}_arap.pl"; }; } 1; +require "bin/mozilla/common.pl"; + # end of main sub check_name { $lxdebug->enter_sub(); + $auth->assert('general_ledger | vendor_invoice_edit | sales_order_edit | invoice_edit |' . + 'request_quotation_edit | sales_quotation_edit | purchase_order_edit | cash |' . + 'purchase_delivery_order_edit | sales_delivery_order_edit'); + my ($name) = @_; $name = $name eq "customer" ? "customer" : "vendor"; @@ -123,6 +131,9 @@ sub check_name { sub select_name { $lxdebug->enter_sub(); + $auth->assert('general_ledger | vendor_invoice_edit | sales_order_edit | invoice_edit |' . + 'request_quotation_edit | sales_quotation_edit | purchase_order_edit | cash'); + my ($table) = @_; @column_index = qw(ndx name address); @@ -206,6 +217,7 @@ sub select_name { # save all other form variables foreach $key (keys %${form}) { + next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); $form->{$key} =~ s/\"/"/g; print qq|\n|; } @@ -229,6 +241,9 @@ sub select_name { sub name_selected { $lxdebug->enter_sub(); + $auth->assert('general_ledger | vendor_invoice_edit | sales_order_edit | invoice_edit |' . + 'request_quotation_edit | sales_quotation_edit | purchase_order_edit | cash'); + # replace the variable with the one checked # index for new item @@ -254,27 +269,13 @@ sub name_selected { $lxdebug->leave_sub(); } -sub add_transaction { +sub check_project { $lxdebug->enter_sub(); - my ($module) = @_; + $auth->assert('general_ledger | vendor_invoice_edit | sales_order_edit | invoice_edit |' . + 'request_quotation_edit | sales_quotation_edit | purchase_order_edit | cash | report'); - delete $form->{script}; - $form->{action} = "add"; - $form->{type} = "invoice" if $module =~ /(is|ir)/; - - $form->{callback} = $form->escape($form->{callback}, 1); - map { $argv .= "$_=$form->{$_}&" } keys %$form; - - $form->{callback} = "$module.pl?$argv"; - - $form->redirect; - - $lxdebug->leave_sub(); -} - -sub check_project { - $lxdebug->enter_sub(); + my $nextsub = shift || 'update'; for $i (1 .. $form->{rowcount}) { my $suffix = $i ? "_$i" : ""; @@ -285,21 +286,19 @@ sub check_project { # get new project $form->{projectnumber} = $form->{"${prefix}projectnumber${suffix}"}; - if (($rows = PE->projects(\%myconfig, $form)) > 1) { + my %params = map { $_ => $form->{$_} } qw(projectnumber description active); + if (($rows = Projects->search_projects(%params)) > 1) { # check form->{project_list} how many there are $form->{rownumber} = $i; - &select_project($i ? undef : 1); + &select_project($i ? undef : 1, $nextsub); exit; } if ($rows == 1) { - $form->{"${prefix}project_id${suffix}"} = - $form->{project_list}->[0]->{id}; - $form->{"${prefix}projectnumber${suffix}"} = - $form->{project_list}->[0]->{projectnumber}; - $form->{"old${prefix}projectnumber${suffix}"} = - $form->{project_list}->[0]->{projectnumber}; + $form->{"${prefix}project_id${suffix}"} = $form->{project_list}->[0]->{id}; + $form->{"${prefix}projectnumber${suffix}"} = $form->{project_list}->[0]->{projectnumber}; + $form->{"old${prefix}projectnumber${suffix}"} = $form->{project_list}->[0]->{projectnumber}; } else { # not on file @@ -317,7 +316,10 @@ sub check_project { sub select_project { $lxdebug->enter_sub(); - my ($is_global) = @_; + $auth->assert('general_ledger | vendor_invoice_edit | sales_order_edit | invoice_edit |' . + 'request_quotation_edit | sales_quotation_edit | purchase_order_edit | cash | report'); + + my ($is_global, $nextsub) = @_; @column_index = qw(ndx projectnumber description); @@ -400,13 +402,15 @@ sub select_project { # save all other form variables foreach $key (keys %${form}) { + next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key})); $form->{$key} =~ s/\"/"/g; print qq|\n|; } - print qq| - - + print + $cgi->hidden('-name' => 'is_global', '-default' => [$is_global]) + . $cgi->hidden('-name' => 'project_selected_nextsub', '-default' => [$nextsub]) + . qq|
{$_} } qw(ndx lastndx nextsub is_global); + my $nextsub = $form->{project_selected_nextsub} || 'update'; - if ($form->{update}) { - &{ $form->{update} }; - } else { - &update; - } + map { delete $form->{$_} } qw(ndx lastndx nextsub is_global project_selected_nextsub); + + call_sub($nextsub); $lxdebug->leave_sub(); } -sub continue { &{ $form->{nextsub} } } -sub gl_transaction { &add } -sub ar_transaction { &add_transaction('ar') } -sub ap_transaction { &add_transaction('ap') } -sub sales_invoice { &add_transaction('is') } -sub vendor_invoice { &add_transaction('ir') } +sub continue { call_sub($form->{"nextsub"}); }