# safety
__PACKAGE__->run_before('check_auth');
+__PACKAGE__->run_before('check_auth_save',
+ except => [ qw(edit show_customer_vendor_details_dialog price_popup load_second_rows) ]);
+
__PACKAGE__->run_before('recalc',
only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_invoice_for_advance_payment save_and_final_invoice save_and_ap_transaction
print send_email) ]);
sub check_auth {
my ($self) = @_;
+ my $right_for = { map { $_ => $_.'_edit' . ' | ' . $_.'_view' } @{$self->valid_types} };
+
+ my $right = $right_for->{ $self->type };
+ $right ||= 'DOES_NOT_EXIST';
+
+ $::auth->assert($right);
+}
+
+sub check_auth_save {
+ my ($self) = @_;
+
my $right_for = { map { $_ => $_.'_edit' } @{$self->valid_types} };
my $right = $right_for->{ $self->type };
$has_final_invoice = any {'SL::DB::Invoice' eq ref $_ && "final_invoice" eq $_->type} @$lr;
}
+ my $right_for = { map { $_ => $_.'_edit' } @{$self->valid_types} };
+ my $right = $right_for->{ $self->type };
+ $right ||= 'DOES_NOT_EXIST';
+
+ if ($::auth->assert($right, 1)) {
for my $bar ($::request->layout->get('actionbar')) {
$bar->add(
combobox => [
only_if => $deletion_allowed,
],
+ );
+ }
+ }
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
combobox => [
action => [
t8('more')
], # end of combobox "more"
);
}
+
}
sub generate_doc {
use SL::Locale::String qw(t8);
-sub auth { 'purchase_order_edit' }
+sub auth { 'purchase_order_edit | purchase_order_view' }
sub name { 'purchase_order' }
use SL::Locale::String qw(t8);
-sub auth { 'request_quotation_edit' }
+sub auth { 'request_quotation_edit | request_quotation_view' }
sub name { 'request_quotation' }
use SL::Locale::String qw(t8);
-sub auth { 'sales_order_edit' }
+sub auth { 'sales_order_edit | sales_order_view' }
sub name { 'sales_order' }
use SL::Locale::String qw(t8);
-sub auth { 'sales_quotation_edit' }
+sub auth { 'sales_quotation_edit | sales_quotation_view' }
sub name { 'sales_quotation' }
'sales_quotation' => 'sales_quotation_edit',
};
+my $oe_view_access_map = {
+ 'sales_order' => 'sales_order_edit | sales_order_view',
+ 'purchase_order' => 'purchase_order_edit | purchase_order_view',
+ 'request_quotation' => 'request_quotation_edit | request_quotation_view',
+ 'sales_quotation' => 'sales_quotation_edit | sales_quotation_view',
+};
+
sub check_oe_access {
+ my (%params) = @_;
my $form = $main::form;
- my $right = $oe_access_map->{$form->{type}};
+ my $right = ($params{with_view}) ? $oe_view_access_map->{$form->{type}} : $oe_access_map->{$form->{type}};
$right ||= 'DOES_NOT_EXIST';
$main::auth->assert($right);
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- check_oe_access();
+ check_oe_access(with_view => 1);
if ($form->{type} eq 'purchase_order') {
$form->{vc} = 'vendor';
my $cgi = $::request->{cgi};
my %params = @_;
- check_oe_access();
+ check_oe_access(with_view => 1);
my $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
name: Quotations
icon: report_quotations
order: 200
- access: sales_quotation_edit
+ access: sales_quotation_edit | sales_quotation_view
module: oe.pl
params:
action: search
name: Sales Orders
icon: report_sales_orders
order: 300
- access: sales_order_edit
+ access: sales_order_edit | sales_order_view
module: oe.pl
params:
action: search
name: RFQs
icon: rfq_report
order: 100
- access: request_quotation_edit
+ access: request_quotation_edit | request_quotation_view
module: oe.pl
params:
action: search
name: Purchase Orders
icon: purchase_order_report
order: 200
- access: purchase_order_edit
+ access: purchase_order_edit | purchase_order_view
module: oe.pl
params:
action: search