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";
$form->{initial_transdate} = $form->{transdate};
create_links(dont_save => 1);
$form->{transdate} = $form->{initial_transdate};
+
&display_form;
$main::lxdebug->leave_sub();
$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;
(@{ $form->{all_vendor} });
}
- # departments
- if (@{ $form->{all_departments} || [] }) {
- $form->{department} = "$form->{department}--$form->{department_id}";
- $form->{selectdepartment} = "<option>\n" . join('', map { my $quoted = H("$_->{description}--$_->{id}"); "<option value=\"${quoted}\">${quoted}\n"} @{ $form->{all_departments} || [] });
- }
+ $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
$form->{employee} = "$form->{employee}--$form->{employee_id}";
# type=submit $locale->text('Edit Accounts Payables Transaction')
# set option selected
- foreach my $item (qw(vendor currency department)) {
+ foreach my $item (qw(vendor currency)) {
my $to_replace = H($form->{$item});
$form->{"select$item"} =~ s/ selected//;
$form->{"select$item"} =~ s/>\Q${to_replace}\E/ selected>${to_replace}/;
@{ $form->{ALL_CHARTS} }
);
+ $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
+
my %project_labels = ();
foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
$project_labels{$item->{id}} = $item->{projectnumber};
$main::lxdebug->leave_sub();
}
+sub show_draft {
+ $::form->{transdate} = DateTime->today_local->to_kivitendo if !$::form->{transdate};
+ $::form->{gldate} = $::form->{transdate} if !$::form->{gldate};
+ update();
+}
+
sub update {
$main::lxdebug->enter_sub();
$form->isblank("vendor", $locale->text('Vendor missing!'));
$form->isblank("invnumber", $locale->text('Invoice Number missing!'));
- if ($myconfig{mandatory_departments} && !$form->{department}) {
+ if ($myconfig{mandatory_departments} && !$form->{department_id}) {
$form->{saved_message} = $::locale->text('You have to specify a department.');
update();
exit;
$form->{id} = 0 if $form->{postasnew};
if (AP->post_transaction(\%myconfig, \%$form)) {
+ # create webdav folder
+ if ($::instance_conf->get_webdav) {
+ SL::Webdav->new(type => 'accounts_payable',
+ number => $form->{invnumber},
+ )->webdav_path;
+ }
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
$form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{title} = $locale->text('AP Transactions');
$form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 },
- "departments" => "ALL_DEPARTMENTS",
"vendors" => "ALL_VC");
+ $::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
# constants and subs for template
$form->{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
vendornumber country ustid taxzone payment_terms charts direct_debit);
my @hidden_variables = map { "l_${_}" } @columns;
- push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id transdatefrom transdateto department
+ push @hidden_variables, "l_subtotal", qw(open closed vendor invnumber ordnumber transaction_description notes project_id transdatefrom transdateto
parts_partnumber parts_description);
my $href = build_std_url('action=ap_transactions', grep { $form->{$_} } @hidden_variables);
my @options;
push @options, $locale->text('Vendor') . " : $form->{vendor}" if ($form->{vendor});
push @options, $locale->text('Contact Person') . " : $form->{cp_name}" if ($form->{cp_name});
- push @options, $locale->text('Department') . " : " . (split /--/, $form->{department})[0] if ($form->{department});
+ push @options, $locale->text('Department') . " : $form->{department}" if ($form->{department});
push @options, $locale->text('Invoice Number') . " : $form->{invnumber}" if ($form->{invnumber});
push @options, $locale->text('Order Number') . " : $form->{ordnumber}" if ($form->{ordnumber});
push @options, $locale->text('Notes') . " : $form->{notes}" if ($form->{notes});