X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fap.pl;h=8d55d01acde552e986aa54c759b66a3727d6156f;hb=aa63ebae1c0a758ec438c594acb328b1f0e5e001;hp=28fa8d2ede9616a8e4fc6a127d67af05219b5c87;hpb=56f92e7f079924263f2303ae1e01ff73c9a6aa06;p=kivitendo-erp.git
diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl
index 28fa8d2ed..8d55d01ac 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
@@ -37,14 +38,16 @@ use List::UtilsBy qw(sort_by);
use SL::AP;
use SL::FU;
+use SL::GL;
use SL::IR;
use SL::IS;
-use SL::PE;
use SL::ReportGenerator;
+use SL::DB::Currency;
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/reportgenerator.pl";
@@ -88,7 +91,7 @@ sub add {
my $form = $main::form;
my %myconfig = %main::myconfig;
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ap_transactions');
$form->{title} = "Add";
@@ -98,6 +101,12 @@ sub add {
$form->{initial_transdate} = $form->{transdate};
create_links(dont_save => 1);
$form->{transdate} = $form->{initial_transdate};
+
+ if ($form->{vendor_id}) {
+ my $last_used_ap_chart = SL::DB::Vendor->load_cached($form->{vendor_id})->last_used_ap_chart;
+ $form->{"AP_amount_chart_id_1"} = $last_used_ap_chart->id if $last_used_ap_chart;
+ }
+
&display_form;
$main::lxdebug->leave_sub();
@@ -108,7 +117,7 @@ sub edit {
my $form = $main::form;
- $main::auth->assert('general_ledger');
+ $main::auth->assert('ap_transactions');
$form->{title} = "Edit";
@@ -123,8 +132,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;
@@ -139,7 +161,7 @@ sub create_links {
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 %saved;
@@ -153,8 +175,8 @@ sub create_links {
IR->get_vendor(\%myconfig, \%$form);
$form->{$_} = $saved{$_} for keys %saved;
- $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
$form->{rowcount} = 1;
+ $form->{AP_chart_id} = $form->{acc_trans} && $form->{acc_trans}->{AP} ? $form->{acc_trans}->{AP}->[0]->{chart_id} : $form->{AP_links}->{AP}->[0]->{chart_id};
# build the popup menus
$form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
@@ -162,21 +184,7 @@ sub create_links {
# currencies
$form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
- $form->{selectcurrency} = "";
- map { my $quoted = H($_); $form->{selectcurrency} .= "