+
+sub setup_ap_search_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ $::locale->text('Search'),
+ submit => [ '#form', { action => "ap_transactions" } ],
+ checks => [ 'kivi.validate_form' ],
+ accesskey => 'enter',
+ ],
+ );
+ }
+ $::request->layout->add_javascripts('kivi.Validator.js');
+}
+
+sub setup_ap_transactions_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ combobox => [
+ action => [ t8('Add') ],
+ link => [
+ t8('Purchase Invoice'),
+ link => [ 'ir.pl?action=add' ],
+ ],
+ link => [
+ t8('AP Transaction'),
+ link => [ 'ap.pl?action=add' ],
+ ],
+ ], # end of combobox "Add"
+ );
+ }
+}
+
+sub setup_ap_display_form_action_bar {
+ my $transdate = $::form->datetonum($::form->{transdate}, \%::myconfig);
+ my $closedto = $::form->datetonum($::form->{closedto}, \%::myconfig);
+ my $is_closed = $transdate <= $closedto;
+
+ my $change_never = $::instance_conf->get_ap_changeable == 0;
+ my $change_on_same_day_only = $::instance_conf->get_ap_changeable == 2 && ($::form->current_date(\%::myconfig) ne $::form->{gldate});
+
+ my $is_storno = IS->is_storno(\%::myconfig, $::form, 'ap', $::form->{id});
+ my $has_storno = IS->has_storno(\%::myconfig, $::form, 'ap');
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Update'),
+ submit => [ '#form', { action => "update" } ],
+ id => 'update_button',
+ checks => [ 'kivi.validate_form' ],
+ accesskey => 'enter',
+ ],
+
+ combobox => [
+ action => [
+ t8('Post'),
+ submit => [ '#form', { action => "post" } ],
+ checks => [ 'kivi.validate_form', 'kivi.AP.check_fields_before_posting' ],
+ disabled => $is_closed ? t8('The billing period has already been locked.')
+ : $is_storno ? t8('A canceled invoice cannot be posted.')
+ : ($::form->{id} && $change_never) ? t8('Changing invoices has been disabled in the configuration.')
+ : ($::form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.')
+ : undef,
+ ],
+ action => [
+ t8('Post Payment'),
+ submit => [ '#form', { action => "post_payment" } ],
+ checks => [ 'kivi.validate_form' ],
+ disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ action => [ t8('Mark as paid'),
+ submit => [ '#form', { action => "mark_as_paid" } ],
+ confirm => t8('This will remove the invoice from showing as unpaid even if the unpaid amount does not match the amount. Proceed?'),
+ disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ only_if => $::instance_conf->get_is_show_mark_as_paid,
+ ],
+ ], # end of combobox "Post"
+
+ combobox => [
+ action => [ t8('Storno'),
+ submit => [ '#form', { action => "storno" } ],
+ checks => [ 'kivi.validate_form', 'kivi.AP.check_fields_before_posting' ],
+ confirm => t8('Do you really want to cancel this invoice?'),
+ disabled => !$::form->{id} ? t8('This invoice has not been posted yet.')
+ : $has_storno ? t8('This invoice has been canceled already.')
+ : $is_storno ? t8('Reversal invoices cannot be canceled.')
+ : $::form->{totalpaid} ? t8('Invoices with payments cannot be canceled.')
+ : undef,
+ ],
+ action => [ t8('Delete'),
+ submit => [ '#form', { action => "delete" } ],
+ confirm => t8('Do you really want to delete this object?'),
+ disabled => !$::form->{id} ? t8('This invoice has not been posted yet.')
+ : $change_never ? t8('Changing invoices has been disabled in the configuration.')
+ : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
+ : $has_storno ? t8('This invoice has been canceled already.')
+ : $is_closed ? t8('The billing period has already been locked.')
+ : undef,
+ ],
+ ], # end of combobox "Storno"
+
+ 'separator',
+
+ combobox => [
+ action => [ t8('Workflow') ],
+ action => [
+ t8('Use As New'),
+ submit => [ '#form', { action => "use_as_new" } ],
+ checks => [ 'kivi.validate_form' ],
+ disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ ], # end of combobox "Workflow"
+
+ combobox => [
+ action => [ t8('more') ],
+ action => [
+ t8('History'),
+ call => [ 'set_history_window', $::form->{id} * 1, 'glid' ],
+ disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ action => [
+ t8('Follow-Up'),
+ call => [ 'follow_up_window' ],
+ disabled => !$::form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ action => [
+ t8('Record templates'),
+ call => [ 'kivi.RecordTemplate.popup', 'ap_transaction' ],
+ ],
+ action => [
+ t8('Drafts'),
+ call => [ 'kivi.Draft.popup', 'ap', 'invoice', $::form->{draft_id}, $::form->{draft_description} ],
+ disabled => $::form->{id} ? t8('This invoice has already been posted.')
+ : $is_closed ? t8('The billing period has already been locked.')
+ : undef,
+ ],
+ ], # end of combobox "more"
+ );
+ }
+ $::request->layout->add_javascripts('kivi.Validator.js');
+}