+sub setup_gl_action_bar {
+ my %params = @_;
+ my $form = $::form;
+ my $change_never = $::instance_conf->get_gl_changeable == 0;
+ my $change_on_same_day_only = $::instance_conf->get_gl_changeable == 2 && ($form->current_date(\%::myconfig) ne $form->{gldate});
+ my $is_linked_bank_transaction;
+
+ if ($form->{id} && SL::DB::Manager::BankTransactionAccTrans->find_by(gl_id => $form->{id})) {
+ $is_linked_bank_transaction = 1;
+ }
+
+ my $create_post_action = sub {
+ # $_[0]: description
+ # $_[1]: after_action
+ action => [
+ $_[0],
+ submit => [ '#form', { action => 'post', after_action => $_[1] } ],
+ disabled => $form->{locked} ? t8('The billing period has already been locked.')
+ : $form->{storno} ? t8('A canceled general ledger transaction cannot be posted.')
+ : ($form->{id} && $change_never) ? t8('Changing general ledger transaction has been disabled in the configuration.')
+ : ($form->{id} && $change_on_same_day_only) ? t8('General ledger transactions can only be changed on the day they are posted.')
+ : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.')
+ : undef,
+ ],
+ };
+
+ my %post_entry;
+ if ($::instance_conf->get_gl_add_doc && $::instance_conf->get_doc_storage) {
+ %post_entry = (combobox => [ $create_post_action->(t8('Post'), 'doc-tab'),
+ $create_post_action->(t8('Post and new booking')) ]);
+ } elsif ($::instance_conf->get_doc_storage) {
+ %post_entry = (combobox => [ $create_post_action->(t8('Post')),
+ $create_post_action->(t8('Post and upload document'), 'doc-tab') ]);
+ } else {
+ %post_entry = $create_post_action->(t8('Post'));
+ }
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Update'),
+ submit => [ '#form', { action => 'update' } ],
+ id => 'update_button',
+ accesskey => 'enter',
+ ],
+ %post_entry,
+ combobox => [
+ action => [ t8('Storno'),
+ submit => [ '#form', { action => 'storno' } ],
+ confirm => t8('Do you really want to cancel this general ledger transaction?'),
+ disabled => !$form->{id} ? t8('This general ledger transaction has not been posted yet.')
+ : $form->{storno} ? t8('A canceled general ledger transaction cannot be canceled again.')
+ : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.')
+ : 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.')
+ : $form->{locked} ? t8('The billing period has already been locked.')
+ : $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.')
+ : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.')
+ : $form->{storno} ? t8('A canceled general ledger transaction cannot be deleted.')
+ : undef,
+ ],
+ ], # end of combobox "Storno"
+
+ 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', 'gl_transaction' ],
+ ],
+ action => [
+ t8('Drafts'),
+ call => [ 'kivi.Draft.popup', 'gl', 'unknown', $form->{draft_id}, $form->{draft_description} ],
+ disabled => $form->{id} ? t8('This invoice has already been posted.')
+ : $form->{locked} ? t8('The billing period has already been locked.')
+ : undef,
+ ],
+ ], # end of combobox "more"
+ );
+ }
+}
+
+sub setup_gl_search_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Search'),
+ submit => [ '#form', { action => 'continue', nextsub => 'generate_report' } ],
+ accesskey => 'enter',
+ ],
+ );
+ }
+}
+
+sub setup_gl_transactions_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ combobox => [
+ action => [ $::locale->text('Create new') ],
+ action => [
+ $::locale->text('GL Transaction'),
+ submit => [ '#create_new_form', { action => 'gl_transaction' } ],
+ ],
+ action => [
+ $::locale->text('AR Transaction'),
+ submit => [ '#create_new_form', { action => 'ar_transaction' } ],
+ ],
+ action => [
+ $::locale->text('AP Transaction'),
+ submit => [ '#create_new_form', { action => 'ap_transaction' } ],
+ ],
+ action => [
+ $::locale->text('Sales Invoice'),
+ submit => [ '#create_new_form', { action => 'sales_invoice' } ],
+ ],
+ action => [
+ $::locale->text('Vendor Invoice'),
+ submit => [ '#create_new_form', { action => 'vendor_invoice' } ],
+ ],
+ ], # end of combobox "Create new"
+ );
+ }
+}
+