Revision 2a72d256
Von Moritz Bunkus vor fast 4 Jahren hinzugefügt
SL/CT.pm | ||
---|---|---|
244 | 244 |
push @values, $form->{create_zugferd_invoices}; |
245 | 245 |
} |
246 | 246 |
|
247 |
# Nur Kunden finden, bei denen ich selber der Verkäufer bin |
|
248 |
# Gilt nicht für Lieferanten |
|
249 |
if ($cv eq 'customer' && !$main::auth->assert('customer_vendor_all_edit', 1)) { |
|
250 |
$where .= qq| AND ct.salesman_id = (select em.id from employee em where em.login = ?)|; |
|
251 |
push(@values, $::myconfig{login}); |
|
252 |
} |
|
253 |
|
|
254 | 247 |
my ($cvar_where, @cvar_values) = CVar->build_filter_query('module' => 'CT', |
255 | 248 |
'trans_id_field' => 'ct.id', |
256 | 249 |
'filter' => $form); |
SL/Controller/Customer.pm | ||
---|---|---|
6 | 6 |
use SL::DB::Customer; |
7 | 7 |
use SL::JSON; |
8 | 8 |
|
9 |
# safety |
|
10 |
__PACKAGE__->run_before(sub { $::auth->assert('customer_vendor_edit') }); |
|
11 |
|
|
12 | 9 |
sub action_get_hourly_rate { |
13 | 10 |
my ($self, %params) = @_; |
14 | 11 |
|
SL/Controller/CustomerVendor.pm | ||
---|---|---|
41 | 41 |
use Data::Dumper; |
42 | 42 |
|
43 | 43 |
use Rose::Object::MakeMethods::Generic ( |
44 |
scalar => [ qw(user_has_edit_rights) ], |
|
44 | 45 |
'scalar --get_set_init' => [ qw(customer_models vendor_models zugferd_settings) ], |
45 | 46 |
); |
46 | 47 |
|
47 | 48 |
# safety |
48 |
__PACKAGE__->run_before( |
|
49 |
sub { |
|
50 |
$::auth->assert('customer_vendor_edit'); |
|
51 |
}, |
|
52 |
except => [ qw(ajaj_autocomplete) ], |
|
53 |
); |
|
54 | 49 |
__PACKAGE__->run_before( |
55 | 50 |
'_instantiate_args', |
56 | 51 |
only => [ |
... | ... | |
81 | 76 |
); |
82 | 77 |
|
83 | 78 |
# make sure this comes after _load_customer_vendor |
84 |
__PACKAGE__->run_before( |
|
85 |
'_check_customer_vendor_all_edit', |
|
86 |
only => [ |
|
87 |
'edit', |
|
88 |
'show', |
|
89 |
'update', |
|
90 |
'delete', |
|
91 |
'save', |
|
92 |
'save_and_ap_transaction', |
|
93 |
'save_and_ar_transaction', |
|
94 |
'save_and_close', |
|
95 |
'save_and_invoice', |
|
96 |
'save_and_order', |
|
97 |
'save_and_quotation', |
|
98 |
'save_and_rfq', |
|
99 |
'delete', |
|
100 |
'delete_contact', |
|
101 |
'delete_shipto', |
|
102 |
] |
|
103 |
); |
|
79 |
__PACKAGE__->run_before('_check_auth'); |
|
104 | 80 |
|
105 | 81 |
__PACKAGE__->run_before( |
106 | 82 |
'_create_customer_vendor', |
... | ... | |
656 | 632 |
if (1 == scalar @{ $exact_matches = $manager->get_all( |
657 | 633 |
query => [ |
658 | 634 |
obsolete => 0, |
659 |
(salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1), |
|
660 | 635 |
or => [ |
661 | 636 |
name => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, |
662 | 637 |
$number => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, |
... | ... | |
912 | 887 |
} |
913 | 888 |
} |
914 | 889 |
|
915 |
sub _check_customer_vendor_all_edit {
|
|
916 |
my ($self) = @_;
|
|
890 |
sub _check_auth {
|
|
891 |
my ($self, $action) = @_;
|
|
917 | 892 |
|
918 |
unless ($::auth->assert('customer_vendor_all_edit', 1)) { |
|
919 |
die($::locale->text("You don't have the rights to edit this customer.") . "\n") |
|
920 |
if $self->{cv}->is_customer and |
|
921 |
SL::DB::Manager::Employee->current->id != $self->{cv}->salesman_id; |
|
922 |
}; |
|
923 |
}; |
|
893 |
my $is_new = !$self->{cv} || !$self->{cv}->id; |
|
894 |
my $is_own_customer = !$is_new |
|
895 |
&& $self->{cv}->is_customer |
|
896 |
&& (SL::DB::Manager::Employee->current->id == $self->{cv}->salesman_id); |
|
897 |
my $has_edit_rights = $::auth->assert('customer_vendor_all_edit', 1); |
|
898 |
$has_edit_rights ||= $::auth->assert('customer_vendor_edit', 1) && ($is_new || $is_own_customer); |
|
899 |
my $needs_edit_rights = $action =~ m{^(?:add|save|delete|update)}; |
|
900 |
|
|
901 |
$self->user_has_edit_rights($has_edit_rights); |
|
902 |
|
|
903 |
return 1 if $has_edit_rights; |
|
904 |
return 0 if $needs_edit_rights; |
|
905 |
return 1; |
|
906 |
} |
|
924 | 907 |
|
925 | 908 |
sub _create_customer_vendor { |
926 | 909 |
my ($self) = @_; |
... | ... | |
1075 | 1058 |
sub _setup_form_action_bar { |
1076 | 1059 |
my ($self) = @_; |
1077 | 1060 |
|
1061 |
my $no_rights = $self->user_has_edit_rights ? undef |
|
1062 |
: $self->{cv}->is_customer ? t8("You don't have the rights to edit this customer.") |
|
1063 |
: t8("You don't have the rights to edit this vendor."); |
|
1064 |
|
|
1078 | 1065 |
for my $bar ($::request->layout->get('actionbar')) { |
1079 | 1066 |
$bar->add( |
1080 | 1067 |
combobox => [ |
... | ... | |
1083 | 1070 |
submit => [ '#form', { action => "CustomerVendor/save" } ], |
1084 | 1071 |
checks => [ 'check_taxzone_and_ustid' ], |
1085 | 1072 |
accesskey => 'enter', |
1073 |
disabled => $no_rights, |
|
1086 | 1074 |
], |
1087 | 1075 |
action => [ |
1088 | 1076 |
t8('Save and Close'), |
1089 | 1077 |
submit => [ '#form', { action => "CustomerVendor/save_and_close" } ], |
1090 | 1078 |
checks => [ 'check_taxzone_and_ustid' ], |
1079 |
disabled => $no_rights, |
|
1091 | 1080 |
], |
1092 | 1081 |
], # end of combobox "Save" |
1093 | 1082 |
|
... | ... | |
1097 | 1086 |
t8('Save and AP Transaction'), |
1098 | 1087 |
submit => [ '#form', { action => "CustomerVendor/save_and_ap_transaction" } ], |
1099 | 1088 |
checks => [ 'check_taxzone_and_ustid' ], |
1089 |
disabled => $no_rights, |
|
1100 | 1090 |
]) x !!$self->is_vendor, |
1101 | 1091 |
(action => [ |
1102 | 1092 |
t8('Save and AR Transaction'), |
1103 | 1093 |
submit => [ '#form', { action => "CustomerVendor/save_and_ar_transaction" } ], |
1104 | 1094 |
checks => [ 'check_taxzone_and_ustid' ], |
1095 |
disabled => $no_rights, |
|
1105 | 1096 |
]) x !$self->is_vendor, |
1106 | 1097 |
action => [ |
1107 | 1098 |
t8('Save and Invoice'), |
1108 | 1099 |
submit => [ '#form', { action => "CustomerVendor/save_and_invoice" } ], |
1109 | 1100 |
checks => [ 'check_taxzone_and_ustid' ], |
1101 |
disabled => $no_rights, |
|
1110 | 1102 |
], |
1111 | 1103 |
action => [ |
1112 | 1104 |
t8('Save and Order'), |
1113 | 1105 |
submit => [ '#form', { action => "CustomerVendor/save_and_order" } ], |
1114 | 1106 |
checks => [ 'check_taxzone_and_ustid' ], |
1107 |
disabled => $no_rights, |
|
1115 | 1108 |
], |
1116 | 1109 |
(action => [ |
1117 | 1110 |
t8('Save and RFQ'), |
1118 | 1111 |
submit => [ '#form', { action => "CustomerVendor/save_and_rfq" } ], |
1119 | 1112 |
checks => [ 'check_taxzone_and_ustid' ], |
1113 |
disabled => $no_rights, |
|
1120 | 1114 |
]) x !!$self->is_vendor, |
1121 | 1115 |
(action => [ |
1122 | 1116 |
t8('Save and Quotation'), |
1123 | 1117 |
submit => [ '#form', { action => "CustomerVendor/save_and_quotation" } ], |
1124 | 1118 |
checks => [ 'check_taxzone_and_ustid' ], |
1119 |
disabled => $no_rights, |
|
1125 | 1120 |
]) x !$self->is_vendor, |
1126 | 1121 |
], # end of combobox "Workflow" |
1127 | 1122 |
|
... | ... | |
1131 | 1126 |
confirm => t8('Do you really want to delete this object?'), |
1132 | 1127 |
disabled => !$self->{cv}->id ? t8('This object has not been saved yet.') |
1133 | 1128 |
: !$self->is_orphaned ? t8('This object has already been used.') |
1134 |
: undef,
|
|
1129 |
: $no_rights,
|
|
1135 | 1130 |
], |
1136 | 1131 |
|
1137 | 1132 |
'separator', |
... | ... | |
1214 | 1209 |
}, |
1215 | 1210 |
customernumber => t8('Customer Number'), |
1216 | 1211 |
}, |
1217 |
query => [ |
|
1218 |
( salesman_id => SL::DB::Manager::Employee->current->id) x !$::auth->assert('customer_vendor_all_edit', 1), |
|
1219 |
], |
|
1220 | 1212 |
); |
1221 | 1213 |
} |
1222 | 1214 |
|
SL/Controller/TopQuickSearch/Contact.pm | ||
---|---|---|
8 | 8 |
use SL::DBUtils qw(selectfirst_array_query like); |
9 | 9 |
use SL::Locale::String qw(t8); |
10 | 10 |
|
11 |
sub auth { 'customer_vendor_edit' }
|
|
11 |
sub auth { undef }
|
|
12 | 12 |
|
13 | 13 |
sub name { 'contact' } |
14 | 14 |
|
SL/Controller/TopQuickSearch/Customer.pm | ||
---|---|---|
6 | 6 |
|
7 | 7 |
use SL::Locale::String qw(t8); |
8 | 8 |
|
9 |
sub auth { 'customer_vendor_edit' }
|
|
9 |
sub auth { undef }
|
|
10 | 10 |
|
11 | 11 |
sub name { 'customer' } |
12 | 12 |
|
SL/Controller/TopQuickSearch/Vendor.pm | ||
---|---|---|
6 | 6 |
|
7 | 7 |
use SL::Locale::String qw(t8); |
8 | 8 |
|
9 |
sub auth { 'customer_vendor_edit' }
|
|
9 |
sub auth { undef }
|
|
10 | 10 |
|
11 | 11 |
sub name { 'vendor' } |
12 | 12 |
|
bin/mozilla/ct.pl | ||
---|---|---|
76 | 76 |
sub search { |
77 | 77 |
$main::lxdebug->enter_sub(); |
78 | 78 |
|
79 |
$main::auth->assert('customer_vendor_edit'); |
|
80 |
|
|
81 | 79 |
my $form = $main::form; |
82 | 80 |
my $locale = $main::locale; |
83 | 81 |
|
... | ... | |
107 | 105 |
|
108 | 106 |
sub search_contact { |
109 | 107 |
$::lxdebug->enter_sub; |
110 |
$::auth->assert('customer_vendor_edit'); |
|
111 | 108 |
|
112 | 109 |
$::form->{CUSTOM_VARIABLES} = CVar->get_configs('module' => 'Contacts'); |
113 | 110 |
($::form->{CUSTOM_VARIABLES_FILTER_CODE}, |
... | ... | |
128 | 125 |
sub list_names { |
129 | 126 |
$main::lxdebug->enter_sub(); |
130 | 127 |
|
131 |
$main::auth->assert('customer_vendor_edit'); |
|
132 |
|
|
133 | 128 |
my $form = $main::form; |
134 | 129 |
my %myconfig = %main::myconfig; |
135 | 130 |
my $locale = $main::locale; |
... | ... | |
339 | 334 |
|
340 | 335 |
sub list_contacts { |
341 | 336 |
$::lxdebug->enter_sub; |
342 |
$::auth->assert('customer_vendor_edit'); |
|
343 | 337 |
|
344 | 338 |
$::form->{sortdir} = 1 unless defined $::form->{sortdir}; |
345 | 339 |
|
locale/de/all | ||
---|---|---|
4058 | 4058 |
'You do not have permission to access this entry.' => 'Sie verfügen nicht über die Berechtigung, auf diesen Eintrag zuzugreifen.', |
4059 | 4059 |
'You do not have the permissions to access this function.' => 'Sie verfügen nicht über die notwendigen Rechte, um auf diese Funktion zuzugreifen.', |
4060 | 4060 |
'You don\'t have the rights to edit this customer.' => 'Sie verfügen nicht über die erforderlichen Rechte, um diesen Kunden zu bearbeiten.', |
4061 |
'You don\'t have the rights to edit this vendor.' => 'Sie verfügen nicht über die erforderlichen Rechte, um diesen Lieferanten zu bearbeiten.', |
|
4061 | 4062 |
'You have changed the currency or exchange rate. Please check prices.' => 'Die Währung oder der Wechselkurs hat sich geändert. Bitte überprüfen Sie die Preise.', |
4062 | 4063 |
'You have entered or selected the following shipping address for this customer:' => 'Sie haben die folgende Lieferadresse eingegeben oder ausgewählt:', |
4063 | 4064 |
'You have never worked with currencies.' => 'Sie haben noch nie mit Währungen gearbeitet.', |
menus/user/00-erp.yaml | ||
---|---|---|
34 | 34 |
name: Add Customer |
35 | 35 |
icon: customer_add |
36 | 36 |
order: 100 |
37 |
access: customer_vendor_edit |
|
37 |
access: customer_vendor_edit|customer_vendor_all_edit
|
|
38 | 38 |
params: |
39 | 39 |
action: CustomerVendor/add |
40 | 40 |
db: customer |
... | ... | |
43 | 43 |
name: Add Vendor |
44 | 44 |
icon: vendor_add |
45 | 45 |
order: 200 |
46 |
access: customer_vendor_edit |
|
46 |
access: customer_vendor_edit|customer_vendor_all_edit
|
|
47 | 47 |
params: |
48 | 48 |
action: CustomerVendor/add |
49 | 49 |
db: vendor |
... | ... | |
121 | 121 |
name: Customers |
122 | 122 |
icon: customer_report |
123 | 123 |
order: 100 |
124 |
access: customer_vendor_edit |
|
125 | 124 |
params: |
126 | 125 |
action: CustomerVendor/search |
127 | 126 |
db: customer |
... | ... | |
130 | 129 |
name: Vendors |
131 | 130 |
icon: vendor_report |
132 | 131 |
order: 200 |
133 |
access: customer_vendor_edit |
|
134 | 132 |
params: |
135 | 133 |
action: CustomerVendor/search |
136 | 134 |
db: vendor |
... | ... | |
138 | 136 |
id: master_data_reports_contacts |
139 | 137 |
name: Contacts |
140 | 138 |
order: 300 |
141 |
access: customer_vendor_edit |
|
142 | 139 |
params: |
143 | 140 |
action: CustomerVendor/search_contact |
144 | 141 |
db: customer |
Auch abrufbar als: Unified diff
Kunden-/Lieferantenstammdaten: Berechtigungsmodell gefixt
Neues Modell sieht wie folgt aus:
1. Alle Personen haben Leserechte auf alle Kunden- &
Lieferantenstammdaten. Das betrifft nicht nur die Stammdatenmasken,
sondern auch die AJAJ-Autovervollständigung (Kunden-/
Lieferanten-Picker) oder die Detail-Popup-Fenster in Einkaufs-/
Verkaufsbelegmasken.
2. Personen mit »edit«-Recht aber ohne »edit all«-Recht dürfen nur die
eigenen Kundenstammdaten verändern (speichern/löschen), wobei
»eigen« definiert ist als »aktuelle Person ist Verkäufer*in des
Kunden«. Neue Kunden dürfen angelegt werden. Bei Lieferanten dürfen
hingegen alle Stammdaten bearbeitet werden.
3. Personen mit »edit all«-Recht haben Vollzugriff auf alle Kunden- &
Lieferantenstammdaten.
(cherry picked from commit 433f3b22eb2ebfa433f090b60bd27797d5dd3b04)