X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fap.pl;h=3440f93fbbc3f2d4268957358b3f8310f5f11d71;hb=71c23cdf2826595579b8e62fc964393875ef070f;hp=dddf6c515dc061039aa9c7e0a7c353fb53e1cba2;hpb=9fe004908828ea3844303b0da3dd893caaf82357;p=kivitendo-erp.git
diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl
index dddf6c515..3440f93fb 100644
--- a/bin/mozilla/ap.pl
+++ b/bin/mozilla/ap.pl
@@ -24,7 +24,8 @@
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
#======================================================================
#
# Accounts Payables
@@ -32,19 +33,21 @@
#======================================================================
use POSIX qw(strftime);
-use List::Util qw(sum);
+use List::Util qw(max sum);
+use List::UtilsBy qw(sort_by);
use SL::AP;
use SL::FU;
use SL::IR;
use SL::IS;
-use SL::PE;
use SL::ReportGenerator;
use SL::DB::Default;
+use SL::DB::PurchaseInvoice;
+use SL::Webdav;
+use SL::Locale::String qw(t8);
require "bin/mozilla/arap.pl";
require "bin/mozilla/common.pl";
-require "bin/mozilla/drafts.pl";
require "bin/mozilla/reportgenerator.pl";
use strict;
@@ -87,18 +90,17 @@ sub add {
my $form = $main::form;
my %myconfig = %main::myconfig;
- $main::auth->assert('general_ledger');
-
- return $main::lxdebug->leave_sub() if (load_draft_maybe());
+ $main::auth->assert('ap_transactions');
$form->{title} = "Add";
- $form->{callback} = "ap.pl?action=add&DONT_LOAD_DRAFT=1" unless $form->{callback};
+ $form->{callback} = "ap.pl?action=add" unless $form->{callback};
AP->get_transdate(\%myconfig, $form);
$form->{initial_transdate} = $form->{transdate};
- &create_links;
+ create_links(dont_save => 1);
$form->{transdate} = $form->{initial_transdate};
+
&display_form;
$main::lxdebug->leave_sub();
@@ -109,11 +111,11 @@ sub edit {
my $form = $main::form;
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ap_transactions');
$form->{title} = "Edit";
- &create_links;
+ create_links();
&display_form;
$main::lxdebug->leave_sub();
@@ -124,8 +126,21 @@ sub display_form {
my $form = $main::form;
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ap_transactions');
+ # get all files stored in the webdav folder
+ if ($form->{invnumber} && $::instance_conf->get_webdav) {
+ my $webdav = SL::Webdav->new(
+ type => 'accounts_payable',
+ number => $form->{invnumber},
+ );
+ my $webdav_path = $webdav->webdav_path;
+ my @all_objects = $webdav->get_all_objects;
+ @{ $form->{WEBDAV} } = map { { name => $_->filename,
+ type => t8('File'),
+ link => File::Spec->catfile($_->full_filedescriptor),
+ } } @all_objects;
+ }
&form_header;
&form_footer;
@@ -135,18 +150,25 @@ sub display_form {
sub create_links {
$main::lxdebug->enter_sub();
+ my %params = @_;
+
my $form = $main::form;
my %myconfig = %main::myconfig;
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ap_transactions');
$form->create_links("AP", \%myconfig, "vendor");
- my $taxincluded = $form->{taxincluded};
- my $duedate = $form->{duedate};
+ my %saved;
+ if (!$params{dont_save}) {
+ %saved = map { ($_ => $form->{$_}) } qw(direct_debit taxincluded);
+ $saved{duedate} = $form->{duedate} if $form->{duedate};
+ $saved{currency} = $form->{currency} if $form->{currency};
+ $saved{taxincluded} = $form->{taxincluded} if $form->{taxincluded};
+ }
IR->get_vendor(\%myconfig, \%$form);
- $form->{taxincluded} = $taxincluded;
- $form->{duedate} = $duedate if $duedate;
+
+ $form->{$_} = $saved{$_} for keys %saved;
$form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
$form->{rowcount} = 1;
@@ -156,6 +178,7 @@ sub create_links {
# currencies
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
+ $form->{selectcurrency} = "";
map { my $quoted = H($_); $form->{selectcurrency} .= "