my ($class, $data) = @_;
my ($text, %params) = @$data;
+ return if exists($params{only_if}) && !$params{only_if};
+ return if exists($params{not_if}) && $params{not_if};
return SL::Layout::ActionBar::Submit->new(text => $text, params => \%params);
}
sub setup_do_action_bar {
my @transfer_qty = qw(kivi.SalesPurchase.delivery_order_check_transfer_qty);
my @req_trans_desc = qw(kivi.SalesPurchase.check_transaction_description) x!!$::instance_conf->get_require_transaction_description_ps;
+ my $is_customer = $::form->{vc} eq 'customer';
for my $bar ($::request->layout->get('actionbar')) {
$bar->add(
],
combobox => [
- (action => [
+ action => [
t8('Transfer out'),
submit => [ '#form', { action => "transfer_out" } ],
checks => [ @req_trans_desc, @transfer_qty ],
disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
- ]) x ($::form->{vc} eq 'customer'),
- (action => [
+ only_if => $is_customer,
+ ],
+ action => [
t8('Transfer out via default'),
submit => [ '#form', { action => "transfer_out_default" } ],
checks => [ @req_trans_desc, @transfer_qty ],
disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
- ]) x ($::form->{vc} eq 'customer' && $::instance_conf->get_transfer_default),
- (action => [
+ only_if => $is_customer && $::instance_conf->get_transfer_default,
+ ],
+ action => [
t8('Transfer in'),
submit => [ '#form', { action => "transfer_in"> 1 } ],
checks => [ @req_trans_desc, @transfer_qty ],
disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
- ]) x ($::form->{vc} eq 'vendor'),
- (action => [
+ only_if => !$is_customer,
+ ],
+ action => [
t8('Transfer in via default'),
submit => [ '#form', { action => "transfer_in_default" } ],
checks => [ @req_trans_desc, @transfer_qty ],
disabled => $::form->{delivered} ? t8('This record has already been delivered.') : undef,
- ]) x ($::form->{vc} eq 'vendor' && $::instance_conf->get_transfer_default),
+ only_if => !$is_customer && $::instance_conf->get_transfer_default,
+ ],
], # end of combobox "Transfer out"
submit => [ '#form', { action => "post_payment" } ],
disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
],
- (action => [
+ 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,
- ]) x !!$::instance_conf->get_ir_show_mark_as_paid,
+ only_if => $::instance_conf->get_ir_show_mark_as_paid,
+ ],
], # end of combobox "Post"
combobox => [
checks => [ @req_trans_desc ],
disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
],
- (action => [ t8('Mark as paid'),
+ 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,
- ]) x !!$::instance_conf->get_is_show_mark_as_paid,
+ only_if => $::instance_conf->get_is_show_mark_as_paid,
+ ],
], # end of combobox "Post"
combobox => [
combobox => [
action => [ t8('Workflow') ],
- (action => [
+ action => [
t8('Sales Order'),
submit => [ '#form', { action => "sales_order" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]) x !!$params{is_sales_quo},
- (action => [
+ only_if => $params{is_sales_quo},
+ ],
+ action => [
t8('Purchase Order'),
submit => [ '#form', { action => "sales_order" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]) x !!$params{is_req_quo},
- (action => [
+ only_if => $params{is_req_quo},
+ ],
+ action => [
t8('Delivery Order'),
submit => [ '#form', { action => "delivery_order" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]) x ($params{is_sales_ord} || $params{is_pur_ord}),
- (action => [
+ only_if => $params{is_sales_ord} || $params{is_pur_ord},
+ ],
+ action => [
t8('Invoice'),
submit => [ '#form', { action => "invoice" } ],
disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
- ]) x !!$allow_invoice,
+ only_if => $allow_invoice,
+ ],
action => [
t8('Quotation'),
submit => [ '#form', { action => "quotation" } ],