Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 64a2d791

Von Sven Schöling vor etwa 11 Jahren hinzugefügt

  • ID 64a2d7910d7935825f26a3d1512205003cd79e14
  • Vorgänger 45659209
  • Nachfolger 65e5f16a

Eigenes Recht für Lieferplan und "sales_all_edit" berücksichtigen

Unterschiede anzeigen:

SL/Auth.pm
["sales_all_edit", $locale->text("View/edit all employees sales documents")],
["edit_prices", $locale->text("Edit prices and discount (if not used, textfield is ONLY set readonly)")],
["show_ar_transactions", $locale->text("Show AR transactions as part of AR invoice report")],
["delivery_plan", $locale->text("Show delivery plan")],
["--ap", $locale->text("AP")],
["request_quotation_edit", $locale->text("Create and edit RFQs")],
["purchase_order_edit", $locale->text("Create and edit purchase orders")],
SL/Controller/DeliveryPlan.pm
use Rose::Object::MakeMethods::Generic (
scalar => [ qw(db_args flat_filter) ],
'scalar --get_set_init' => [ qw(models) ],
'scalar --get_set_init' => [ qw(models all_edit_right) ],
);
__PACKAGE__->run_before(sub { $::auth->assert('sales_order_edit'); });
__PACKAGE__->run_before(sub { $::auth->assert('delivery_plan'); });
my %sort_columns = (
reqdate => t8('Reqdate'),
......
customer => t8('Customer'),
);
my $delivery_plan_query = [
'order.customer_id' => { gt => 0 },
'order.closed' => 0,
or => [ 'order.quotation' => 0, 'order.quotation' => undef ],
# filter by shipped_qty < qty, read from innermost to outermost
'id' => [ \"
-- 3. resolve the desired information about those
SELECT oi.id FROM (
-- 2. slice only part, orderitem and both quantities from it
SELECT parts_id, trans_id, qty, SUM(doi_qty) AS doi_qty FROM (
-- 1. join orderitems and deliverorder items via record_links.
-- also add customer data to filter for sales_orders
SELECT oi.parts_id, oi.trans_id, oi.id, oi.qty, doi.qty AS doi_qty
FROM orderitems oi, oe, record_links rl, delivery_order_items doi
WHERE
oe.id = oi.trans_id AND
oe.customer_id IS NOT NULL AND
(oe.quotation = 'f' OR oe.quotation IS NULL) AND
NOT oe.closed AND
rl.from_id = oe.id AND
rl.from_id = oi.trans_id AND
oe.id = oi.trans_id AND
rl.from_table = 'oe' AND
rl.to_table = 'delivery_orders' AND
rl.to_id = doi.delivery_order_id AND
oi.parts_id = doi.parts_id
) tuples GROUP BY parts_id, trans_id, qty
) partials
LEFT JOIN orderitems oi ON partials.parts_id = oi.parts_id AND partials.trans_id = oi.trans_id
WHERE oi.qty > doi_qty
UNION ALL
-- 4. since the join over record_links fails for sales_orders wihtout any delivery order
-- retrieve those without record_links at all
SELECT oi.id FROM orderitems oi, oe
WHERE
oe.id = oi.trans_id AND
oe.customer_id IS NOT NULL AND
(oe.quotation = 'f' OR oe.quotation IS NULL) AND
NOT oe.closed AND
oi.trans_id NOT IN (
SELECT from_id
FROM record_links rl
WHERE
rl.from_table ='oe' AND
rl.to_table = 'delivery_orders'
)
UNION ALL
-- 5. In case someone deleted a line of the delivery_order there will be a record_link (4 fails)
-- but there won't be a delivery_order_items to find (3 fails too). Search for orphaned orderitems this way
SELECT oi.id FROM orderitems AS oi, oe, record_links AS rl
WHERE
rl.from_table = 'oe' AND
rl.to_table = 'delivery_orders' AND
oi.trans_id = rl.from_id AND
oi.parts_id NOT IN (
SELECT doi.parts_id FROM delivery_order_items AS doi WHERE doi.delivery_order_id = rl.to_id
) AND
oe.id = oi.trans_id AND
oe.customer_id IS NOT NULL AND
(oe.quotation = 'f' OR oe.quotation IS NULL) AND
NOT oe.closed
" ],
];
sub action_list {
my ($self) = @_;
......
$self->{filter_summary} = join ', ', @filter_strings;
}
sub delivery_plan_query {
my $employee_id = SL::DB::Manager::Employee->current->id;
my $oe_owner = $_[0]->all_edit_right ? '' : " oe.eployee_id = $employee_id AND";
[
'order.customer_id' => { gt => 0 },
'order.closed' => 0,
or => [ 'order.quotation' => 0, 'order.quotation' => undef ],
# filter by shipped_qty < qty, read from innermost to outermost
'id' => [ \"
-- 3. resolve the desired information about those
SELECT oi.id FROM (
-- 2. slice only part, orderitem and both quantities from it
SELECT parts_id, trans_id, qty, SUM(doi_qty) AS doi_qty FROM (
-- 1. join orderitems and deliverorder items via record_links.
-- also add customer data to filter for sales_orders
SELECT oi.parts_id, oi.trans_id, oi.id, oi.qty, doi.qty AS doi_qty
FROM orderitems oi, oe, record_links rl, delivery_order_items doi
WHERE
oe.id = oi.trans_id AND
oe.customer_id IS NOT NULL AND
(oe.quotation = 'f' OR oe.quotation IS NULL) AND
NOT oe.closed AND
$oe_owner
rl.from_id = oe.id AND
rl.from_id = oi.trans_id AND
oe.id = oi.trans_id AND
rl.from_table = 'oe' AND
rl.to_table = 'delivery_orders' AND
rl.to_id = doi.delivery_order_id AND
oi.parts_id = doi.parts_id
) tuples GROUP BY parts_id, trans_id, qty
) partials
LEFT JOIN orderitems oi ON partials.parts_id = oi.parts_id AND partials.trans_id = oi.trans_id
WHERE oi.qty > doi_qty
UNION ALL
-- 4. since the join over record_links fails for sales_orders wihtout any delivery order
-- retrieve those without record_links at all
SELECT oi.id FROM orderitems oi, oe
WHERE
oe.id = oi.trans_id AND
oe.customer_id IS NOT NULL AND
(oe.quotation = 'f' OR oe.quotation IS NULL) AND
NOT oe.closed AND
$oe_owner
oi.trans_id NOT IN (
SELECT from_id
FROM record_links rl
WHERE
rl.from_table ='oe' AND
rl.to_table = 'delivery_orders'
)
UNION ALL
-- 5. In case someone deleted a line of the delivery_order there will be a record_link (4 fails)
-- but there won't be a delivery_order_items to find (3 fails too). Search for orphaned orderitems this way
SELECT oi.id FROM orderitems AS oi, oe, record_links AS rl
WHERE
rl.from_table = 'oe' AND
rl.to_table = 'delivery_orders' AND
oi.trans_id = rl.from_id AND
oi.parts_id NOT IN (
SELECT doi.parts_id FROM delivery_order_items AS doi WHERE doi.delivery_order_id = rl.to_id
) AND
oe.id = oi.trans_id AND
oe.customer_id IS NOT NULL AND
(oe.quotation = 'f' OR oe.quotation IS NULL) AND
$oe_owner
NOT oe.closed
" ],
]
}
sub init_models {
my ($self) = @_;
......
},
%sort_columns,
},
query => $delivery_plan_query,
query => $self->delivery_plan_query,
with_objects => [ 'order', 'order.customer', 'part' ],
);
}
sub init_all_edit_right {
$::auth->assert('sales_all_edit', 1)
}
sub link_to {
my ($self, $object, %params) = @_;
locale/de/all
'Show delete button in purchase orders?' => 'Soll der "Löschen"-Knopf bei Lieferantenaufträgen angezeigt werden?',
'Show delete button in sales delivery orders?' => 'Soll der "Löschen"-Knopf bei Verkaufslieferscheinen angezeigt werden?',
'Show delete button in sales orders?' => 'Soll der "Löschen"-Knopf bei Kundenaufträgen angezeigt werden?',
'Show delivery plan' => 'Lieferplan anzeigen',
'Show details' => 'Detailsanzeige',
'Show details and reports of parts, services, assemblies' => 'Details und Berichte von Waren, Dienstleistungen und Erzeugnissen anzeigen',
'Show fields used for the best before date?' => 'Felder zur Eingabe des Mindesthaltbarkeitsdatums anzeigen?',
menus/erp.ini
action=search
[AR--Reports--Delivery Plan]
ACCESS=sales_order_edit
ACCESS=delivery_plan
module=controller.pl
action=DeliveryPlan/list
sql/Pg-upgrade2-auth/delivery_plan_rights.pl
# @tag: delivery_plan_rights
# @description: Setzt das neue Recht den Lieferplan anzuzeigen
# @depends: release_3_0_0
package SL::DBUpgrade2::delivery_plan_rights;
use strict;
use utf8;
use parent qw(SL::DBUpgrade2::Base);
use SL::DBUtils;
sub run {
my ($self) = @_;
my $groups = $main::auth->read_groups();
foreach my $group (values %{$groups}) {
$group->{rights}->{delivery_plan_rights} = $group->{rights}->{sales_order_edit};
$main::auth->save_group($group);
}
return 1;
} # end run
1;

Auch abrufbar als: Unified diff