use strict;
use parent qw(SL::Layout::Base);
+use Carp;
+use Scalar::Util qw(blessed);
use SL::Layout::ActionBar::Action;
+use SL::Layout::ActionBar::ComboBox;
+use SL::Layout::ActionBar::Separator;
use constant HTML_CLASS => 'layout-actionbar';
'scalar --get_set_init' => [ qw(actions) ],
);
+my %class_descriptors = (
+ action => { class => 'SL::Layout::ActionBar::Action', num_params => 1, },
+ combobox => { class => 'SL::Layout::ActionBar::ComboBox', num_params => 1, },
+ separator => { class => 'SL::Layout::ActionBar::Separator', num_params => 0, },
+);
###### Layout overrides
###### interface
-sub add_actions {
+sub add {
my ($self, @actions) = @_;
- push @{ $self->actions }, map {
- !ref $_ ? SL::Layout::ActionBar::Action->from_descriptor($_)
- : ref $_ && 'ARRAY' eq ref $_ ? SL::Layout::ActionBar::Action->simple($_)
- : ref $_ && $_->isa('SL::Layout::Action') ? $_
- : do { die 'invalid action' };
- } @actions;
-}
-sub init_actions {
- []
+ push @{ $self->actions }, $self->parse_actions(@actions);
+
+ return $self->actions->[-1];
}
+sub parse_actions {
+ my ($self_or_class, @actions) = @_;
+
+ my @parsed;
+
+ while (my $type = shift(@actions)) {
+ if (blessed($type) && $type->isa('SL::Layout::ActionBar::Action')) {
+ push @parsed, $type;
+ continue;
+ }
+ my $descriptor = $class_descriptors{lc $type} || croak("Unknown action type '${type}'");
+ my @params = splice(@actions, 0, $descriptor->{num_params});
+ push @parsed, $descriptor->{class}->from_params(@params);
+ }
+
+ return @parsed;
+}
+
+sub init_actions {
+ []
+}
1;
sprintf q|$('#%s').data('action', %s);|, $_[0]->id, JSON->new->allow_blessed->convert_blessed->encode($_[0]->params);
}
-# static constructors
-
-sub from_descriptor {
- my ($class, $descriptor) = @_;
- require SL::Layout::ActionBar::Separator;
- require SL::Layout::ActionBar::ComboBox;
-
- return {
- separator => SL::Layout::ActionBar::Separator->new,
- combobox => SL::Layout::ActionBar::ComboBox->new,
- }->{$descriptor} || do { die 'unknown descriptor' };
-}
-
# this is mostly so that outside consumer don't need to load subclasses themselves
-sub simple {
+sub from_params {
my ($class, $data) = @_;
my ($text, %params) = @$data;
TODO:
- runtime disable/enable
-
'scalar --get_set_init' => [ qw(actions) ],
);
-sub parsed_actions {
- $_[0]{parsed_actions} ||=
- [ map { SL::Layout::ActionBar::Action->simple($_) } @{ $_[0]->actions || [] } ];
-}
+sub from_params {
+ my ($class, $actions) = @_;
+
+ my $combobox = $class->new;
+ push @{ $combobox->actions }, SL::Layout::ActionBar->parse_actions(@{ $actions });
-sub add_actions {
- push @{$_[0]{actions} //= $_[0]->init_actions}, @_[1..$#_]
+ return $combobox;
}
sub render {
- my ($first, @rest) = @{ $_[0]->parsed_actions };
+ my ($first, @rest) = @{ $_[0]->actions };
$_[0]->p->html_tag('div',
$_[0]->p->html_tag('div', $first->render . $_[0]->p->html_tag('span'), class => 'layout-actionbar-combobox-head') .
$_[0]->p->html_tag('div', join('', map { $_->render } @rest), class => 'layout-actionbar-combobox-list'),
}
sub script {
- map { $_->script } @{ $_[0]->parsed_actions }
+ map { $_->script } @{ $_[0]->actions }
}
sub init_actions { [] }
use strict;
use parent qw(SL::Layout::ActionBar::Action);
+sub from_params { $_[0]->new }
+
sub render {
$_[0]->p->html_tag('div', '', class => 'layout-actionbar-separator');
}
my $change_on_same_day_only = $::instance_conf->get_ir_changeable == 2 && ($form->current_date(\%::myconfig) ne $form->{gldate});
for my $bar ($::request->layout->get('actionbar')) {
- $bar->add_actions([ t8('Update'),
- submit => [ '#form', { action_update => 1 } ],
- id => 'update_button',
- accesskey => 'enter',
- ]);
-
- $bar->add_actions("combobox");
- $bar->actions->[-1]->add_actions([ t8('Post'),
- submit => [ '#form', { action_post => 1 } ],
- disabled => $form->{locked} ? t8('The billing period has already been locked.')
- : $form->{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,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Post Payment'),
- submit => [ '#form', { action_post_payment => 1 } ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('mark as paid'),
- submit => [ '#form', { action_mark_as_paid => 1 } ],
- 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,
- ]) if $::instance_conf->get_ir_show_mark_as_paid;
-
-
- $bar->add_actions("combobox");
- $bar->actions->[-1]->add_actions([ t8('Storno'),
- submit => [ '#form', { action_storno => 1 } ],
- confirm => t8('Do you really want to cancel this invoice?'),
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Delete'),
- submit => [ '#form', { action_delete => 1 } ],
- 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.')
- : undef,
- ]);
-
- $bar->add_actions('separator');
-
- $bar->add_actions('combobox');
- $bar->actions->[-1]->add_actions([ t8('more') ]);
- $bar->actions->[-1]->add_actions([ t8('History'),
- call => [ 'set_history_window', $::form->{id} * 1, 'id', 'glid' ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Follow-Up'),
- call => [ 'follow_up_window' ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Drafts'),
- call => [ 'kivi.Draft.popup', 'ir', 'invoice', $::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,
- ]);
+ $bar->add(
+ action => [
+ t8('Update'),
+ submit => [ '#form', { action_update => 1 } ],
+ id => 'update_button',
+ accesskey => 'enter',
+ ],
+
+ combobox => [
+ action => [
+ t8('Post'),
+ submit => [ '#form', { action_post => 1 } ],
+ disabled => $form->{locked} ? t8('The billing period has already been locked.')
+ : $form->{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 => 1 } ],
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ (action => [
+ t8('mark as paid'),
+ submit => [ '#form', { action_mark_as_paid => 1 } ],
+ 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,
+ ]) x !!$::instance_conf->get_ir_show_mark_as_paid,
+ ], # end of combobox "Post"
+
+ combobox => [
+ action => [ t8('Storno'),
+ submit => [ '#form', { action_storno => 1 } ],
+ confirm => t8('Do you really want to cancel this invoice?'),
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ action => [ t8('Delete'),
+ submit => [ '#form', { action_delete => 1 } ],
+ 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.')
+ : undef,
+ ],
+ ], # end of combobox "Storno"
+
+ 'separator',
+
+ combobox => [
+ action => [ t8('more') ],
+ action => [
+ t8('History'),
+ call => [ 'set_history_window', $::form->{id} * 1, 'id', '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('Drafts'),
+ call => [ 'kivi.Draft.popup', 'ir', 'invoice', $::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"
+ );
}
}
my @req_trans_desc = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps;
for my $bar ($::request->layout->get('actionbar')) {
- $bar->add_actions([ t8('Update'),
- submit => [ '#form', { action_update => 1 } ],
- disabled => $form->{locked} ? t8('The billing period has already been locked.') : undef,
- id => 'update_button',
- accesskey => 'enter',
- ]);
-
- $bar->add_actions("combobox");
- $bar->actions->[-1]->add_actions([ t8('Post'),
- submit => [ '#form', { action_post => 1 } ],
- checks => [ @req_trans_desc ],
- disabled => $form->{locked} ? t8('The billing period has already been locked.')
- : $form->{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,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Post Payment'),
- submit => [ '#form', { action_post_payment => 1 } ],
- checks => [ @req_trans_desc ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('mark as paid'),
- submit => [ '#form', { action_mark_as_paid => 1 } ],
- 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,
- ]) if $::instance_conf->get_is_show_mark_as_paid;
-
-
- $bar->add_actions("combobox");
- $bar->actions->[-1]->add_actions([ t8('Storno'),
- submit => [ '#form', { action_storno => 1 } ],
- confirm => t8('Do you really want to cancel this invoice?'),
- checks => [ @req_trans_desc ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Delete'),
- submit => [ '#form', { action_delete => 1 } ],
- confirm => t8('Do you really want to delete this object?'),
- checks => [ @req_trans_desc ],
- 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.')
- : undef,
- ]);
-
- $bar->add_actions('separator');
-
- $bar->add_actions('combobox');
- $bar->actions->[-1]->add_actions([ t8('Workflow') ]);
- $bar->actions->[-1]->add_actions([ t8('Use As New'),
- submit => [ '#form', { action_use_as_new => 1 } ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Credit Note'),
- submit => [ '#form', { action_credit_note => 1 } ],
- checks => [ @req_trans_desc ],
- disabled => $form->{type} eq "credit_note" ? t8('Credit notes cannot be converted into other credit notes.')
- : !$form->{id} ? t8('This invoice has not been posted yet.')
- : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Sales Order'),
- submit => [ '#form', { action_sales_order => 1 } ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
-
- $bar->add_actions('combobox');
- $bar->actions->[-1]->add_actions([ t8('Export') ]);
- $bar->actions->[-1]->add_actions([ ($form->{id} ? t8('Print') : t8('Preview')),
- submit => [ '#form', { action_print => 1 } ],
- checks => [ @req_trans_desc ],
- disabled => !$form->{id} && $form->{locked} ? t8('The billing period has already been locked.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('E Mail'),
- submit => [ '#form', { action_print => 1 } ],
- checks => [ @req_trans_desc ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->add_actions('combobox');
- $bar->actions->[-1]->add_actions([ t8('more') ]);
- $bar->actions->[-1]->add_actions([ t8('History'),
- call => [ 'set_history_window', $form->{id} * 1, 'id' ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Follow-Up'),
- call => [ 'follow_up_window' ],
- disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Drafts'),
- call => [ 'kivi.Draft.popup', 'is', 'invoice', $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,
- ]);
+ $bar->add(
+ action => [
+ t8('Update'),
+ submit => [ '#form', { action_update => 1 } ],
+ disabled => $form->{locked} ? t8('The billing period has already been locked.') : undef,
+ id => 'update_button',
+ accesskey => 'enter',
+ ],
+
+ combobox => [
+ action => [
+ t8('Post'),
+ submit => [ '#form', { action_post => 1 } ],
+ checks => [ @req_trans_desc ],
+ disabled => $form->{locked} ? t8('The billing period has already been locked.')
+ : $form->{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 => 1 } ],
+ checks => [ @req_trans_desc ],
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ (action => [ t8('mark as paid'),
+ submit => [ '#form', { action_mark_as_paid => 1 } ],
+ 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,
+ ]) x !!$::instance_conf->get_is_show_mark_as_paid,
+ ], # end of combobox "Post"
+
+ combobox => [
+ action => [ t8('Storno'),
+ submit => [ '#form', { action_storno => 1 } ],
+ confirm => t8('Do you really want to cancel this invoice?'),
+ checks => [ @req_trans_desc ],
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ action => [ t8('Delete'),
+ submit => [ '#form', { action_delete => 1 } ],
+ confirm => t8('Do you really want to delete this object?'),
+ checks => [ @req_trans_desc ],
+ 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.')
+ : undef,
+ ],
+ ], # end of combobox "Storno"
+
+ 'separator',
+
+ combobox => [
+ action => [ t8('Workflow') ],
+ action => [
+ t8('Use As New'),
+ submit => [ '#form', { action_use_as_new => 1 } ],
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ action => [
+ t8('Credit Note'),
+ submit => [ '#form', { action_credit_note => 1 } ],
+ checks => [ @req_trans_desc ],
+ disabled => $form->{type} eq "credit_note" ? t8('Credit notes cannot be converted into other credit notes.')
+ : !$form->{id} ? t8('This invoice has not been posted yet.')
+ : undef,
+ ],
+ action => [
+ t8('Sales Order'),
+ submit => [ '#form', { action_sales_order => 1 } ],
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ ], # end of combobox "Workflow"
+
+ combobox => [
+ action => [ t8('Export') ],
+ action => [
+ ($form->{id} ? t8('Print') : t8('Preview')),
+ submit => [ '#form', { action_print => 1 } ],
+ checks => [ @req_trans_desc ],
+ disabled => !$form->{id} && $form->{locked} ? t8('The billing period has already been locked.') : undef,
+ ],
+ action => [ t8('E Mail'),
+ submit => [ '#form', { action_print => 1 } ],
+ checks => [ @req_trans_desc ],
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ ], # end of combobox "Export"
+
+ combobox => [
+ action => [ t8('more') ],
+ action => [
+ t8('History'),
+ call => [ 'set_history_window', $form->{id} * 1, 'id' ],
+ 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('Drafts'),
+ call => [ 'kivi.Draft.popup', 'is', 'invoice', $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"
+ );
}
}
my @warn_p_invoice = qw(kivi.SalesPurchase.oe_warn_save_active_periodic_invoice) x!!$has_active_periodic_invoice;
for my $bar ($::request->layout->get('actionbar')) {
- $bar->add_actions([ t8('Update'),
- submit => [ '#form', { action_update => 1 } ],
- id => 'update_button',
- accesskey => 'enter',
- ]);
-
- $bar->add_actions("combobox");
- $bar->actions->[-1]->add_actions([ t8('Save'),
- submit => [ '#form', { action_save => 1 } ],
- checks => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
- ]);
- $bar->actions->[-1]->add_actions([ t8('Save as new'),
- submit => [ '#form', { action_save_as_new => 1 } ],
- checks => [ @req_trans_desc, @req_trans_cost_art ],
- disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Save and Close'),
- submit => [ '#form', { action_save_and_close => 1 } ],
- checks => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
- ]);
- $bar->add_actions([ t8('Delete'),
- submit => [ '#form', { action_delete => 1 } ],
- confirm => t8('Do you really want to delete this object?'),
- disabled => !$form->{id} ? t8('This record has not been saved yet.')
- : ( ($params{is_sales_ord} && !$::instance_conf->get_sales_order_show_delete)
- || ($params{is_pur_ord} && !$::instance_conf->get_purchase_order_show_delete)) ? t8('Deleting this type of record has been disabled in the configuration.')
- : undef,
- ]);
-
- $bar->add_actions('separator');
-
- $bar->add_actions('combobox');
- $bar->actions->[-1]->add_actions([ t8('Workflow') ]);
- $bar->actions->[-1]->add_actions([ t8('Sales Order'),
- submit => [ '#form', { action_sales_order => 1 } ],
- disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]) if $params{is_sales_quo};
- $bar->actions->[-1]->add_actions([ t8('Purchase Order'),
- submit => [ '#form', { action_sales_order => 1 } ],
- disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]) if $params{is_req_quo};
- $bar->actions->[-1]->add_actions([ t8('Delivery Order'),
- submit => [ '#form', { action_delivery_order => 1 } ],
- disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]) if $params{is_sales_ord} || $params{is_pur_ord};
- $bar->actions->[-1]->add_actions([ t8('Invoice'),
- submit => [ '#form', { action_invoice => 1 } ],
- disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]) if $allow_invoice;
- $bar->actions->[-1]->add_actions([ t8('Quotation'),
- submit => [ '#form', { action_quotation => 1 } ],
- disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Request for Quotation'),
- submit => [ '#form', { action_reqest_for_quotation => 1 } ],
- disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]);
-
- $bar->add_actions('combobox');
- $bar->actions->[-1]->add_actions([ t8('Export') ]);
- $bar->actions->[-1]->add_actions([ t8('Print'),
- submit => [ '#form', { action_print => 1 } ],
- checks => [ @req_trans_desc ],
- ]);
- $bar->actions->[-1]->add_actions([ t8('E Mail'),
- submit => [ '#form', { action_print => 1 } ],
- checks => [ @req_trans_desc ],
- ]);
- $bar->add_actions('combobox');
- $bar->actions->[-1]->add_actions([ t8('more') ]);
- $bar->actions->[-1]->add_actions([ t8('History'),
- call => [ 'set_history_window', $form->{id} * 1, 'id' ],
- disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]);
- $bar->actions->[-1]->add_actions([ t8('Follow-Up'),
- call => [ 'follow_up_window' ],
- disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]);
+ $bar->add(
+ action => [
+ t8('Update'),
+ submit => [ '#form', { action_update => 1 } ],
+ id => 'update_button',
+ accesskey => 'enter',
+ ],
+
+ combobox => [
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action_save => 1 } ],
+ checks => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
+ ],
+ action => [
+ t8('Save as new'),
+ submit => [ '#form', { action_save_as_new => 1 } ],
+ checks => [ @req_trans_desc, @req_trans_cost_art ],
+ disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+ ],
+ action => [
+ t8('Save and Close'),
+ submit => [ '#form', { action_save_and_close => 1 } ],
+ checks => [ @req_trans_desc, @req_trans_cost_art, @warn_p_invoice ],
+ ],
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action_delete => 1 } ],
+ confirm => t8('Do you really want to delete this object?'),
+ disabled => !$form->{id} ? t8('This record has not been saved yet.')
+ : ( ($params{is_sales_ord} && !$::instance_conf->get_sales_order_show_delete)
+ || ($params{is_pur_ord} && !$::instance_conf->get_purchase_order_show_delete)) ? t8('Deleting this type of record has been disabled in the configuration.')
+ : undef,
+ ],
+ ], # end of combobox "Save"
+
+ 'separator',
+
+ combobox => [
+ action => [ t8('Workflow') ],
+ (action => [
+ t8('Sales Order'),
+ submit => [ '#form', { action_sales_order => 1 } ],
+ disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+ ]) x !!$params{is_sales_quo},
+ (action => [
+ t8('Purchase Order'),
+ submit => [ '#form', { action_sales_order => 1 } ],
+ disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+ ]) x !!$params{is_req_quo},
+ (action => [
+ t8('Delivery Order'),
+ submit => [ '#form', { action_delivery_order => 1 } ],
+ disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+ ]) x ($params{is_sales_ord} || $params{is_pur_ord}),
+ (action => [
+ t8('Invoice'),
+ submit => [ '#form', { action_invoice => 1 } ],
+ disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+ ]) x !!$allow_invoice,
+ action => [
+ t8('Quotation'),
+ submit => [ '#form', { action_quotation => 1 } ],
+ disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+ ],
+ action => [
+ t8('Request for Quotation'),
+ submit => [ '#form', { action_reqest_for_quotation => 1 } ],
+ disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+ ],
+ ], # end of combobox "Workflow"
+
+ combobox => [
+ action => [ t8('Export') ],
+ action => [
+ t8('Print'),
+ submit => [ '#form', { action_print => 1 } ],
+ checks => [ @req_trans_desc ],
+ ],
+ action => [
+ t8('E Mail'),
+ submit => [ '#form', { action_print => 1 } ],
+ checks => [ @req_trans_desc ],
+ ],
+ ], #end of combobox "Export"
+
+ combobox => [
+ action => [ t8('more') ],
+ action => [
+ t8('History'),
+ call => [ 'set_history_window', $form->{id} * 1, 'id' ],
+ disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+ ],
+ action => [
+ t8('Follow-Up'),
+ call => [ 'follow_up_window' ],
+ disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+ ],
+ ], # end of combobox "more"
+ );
}
}