90 |
90 |
|
91 |
91 |
$self->render(
|
92 |
92 |
'order/form',
|
93 |
|
title => $self->get_title_for('add'),
|
|
93 |
title => $self->type_data->text('add'),
|
94 |
94 |
%{$self->{template_args}}
|
95 |
95 |
);
|
96 |
96 |
}
|
... | ... | |
118 |
118 |
|
119 |
119 |
$self->render(
|
120 |
120 |
'order/form',
|
121 |
|
title => $self->get_title_for('edit'),
|
|
121 |
title => $self->type_data->text('edit'),
|
122 |
122 |
%{$self->{template_args}}
|
123 |
123 |
);
|
124 |
124 |
}
|
... | ... | |
151 |
151 |
$self->pre_render();
|
152 |
152 |
$self->render(
|
153 |
153 |
'order/form',
|
154 |
|
title => $self->get_title_for('edit'),
|
|
154 |
title => $self->type_data->text('edit'),
|
155 |
155 |
%{$self->{template_args}}
|
156 |
156 |
);
|
157 |
157 |
}
|
... | ... | |
480 |
480 |
email_form => $email_form,
|
481 |
481 |
show_bcc => $::auth->assert('email_bcc', 'may fail'),
|
482 |
482 |
FILES => \%files,
|
483 |
|
is_customer => $self->cv eq 'customer',
|
|
483 |
is_customer => $self->type_data->properties('is_customer'),
|
484 |
484 |
ALL_EMPLOYEES => \@employees_with_email,
|
485 |
485 |
ALL_PARTNER_EMAIL_ADDRESSES => $all_partner_email_addresses,
|
486 |
486 |
is_final_version => $self->is_final_version,
|
... | ... | |
914 |
914 |
|
915 |
915 |
$self->render(
|
916 |
916 |
'order/form',
|
917 |
|
title => $self->get_title_for('edit'),
|
|
917 |
title => $self->type_data->text('edit'),
|
918 |
918 |
%{$self->{template_args}}
|
919 |
919 |
);
|
920 |
920 |
}
|
... | ... | |
974 |
974 |
sub action_show_customer_vendor_details_dialog {
|
975 |
975 |
my ($self) = @_;
|
976 |
976 |
|
977 |
|
my $is_customer = 'customer' eq $::form->{vc};
|
|
977 |
my $is_customer = $self->type_data->properties('is_customer');
|
978 |
978 |
my $cv;
|
979 |
979 |
if ($is_customer) {
|
980 |
980 |
$cv = SL::DB::Customer->new(id => $::form->{vc_id})->load;
|
... | ... | |
1318 |
1318 |
|
1319 |
1319 |
$self->render(
|
1320 |
1320 |
'order/form',
|
1321 |
|
title => $self->get_title_for('edit'),
|
|
1321 |
title => $self->type_data->text('edit'),
|
1322 |
1322 |
%{$self->{template_args}}
|
1323 |
1323 |
);
|
1324 |
1324 |
|
... | ... | |
1637 |
1637 |
sub init_cv {
|
1638 |
1638 |
my ($self) = @_;
|
1639 |
1639 |
|
1640 |
|
my $cv = (any { $self->type eq $_ } (SALES_ORDER_TYPE(), SALES_QUOTATION_TYPE())) ? 'customer'
|
1641 |
|
: (any { $self->type eq $_ } (PURCHASE_ORDER_TYPE(), REQUEST_QUOTATION_TYPE())) ? 'vendor'
|
1642 |
|
: die "Not a valid type for order";
|
1643 |
|
|
1644 |
|
return $cv;
|
|
1640 |
return $self->type_data->properties('customervendor');
|
1645 |
1641 |
}
|
1646 |
1642 |
|
1647 |
1643 |
sub init_search_cvpartnumber {
|
... | ... | |
1675 |
1671 |
|
1676 |
1672 |
sub init_part_picker_classification_ids {
|
1677 |
1673 |
my ($self) = @_;
|
1678 |
|
my $attribute = 'used_for_' . ($self->type =~ m{sales} ? 'sale' : 'purchase');
|
1679 |
1674 |
|
1680 |
|
return [ map { $_->id } @{ SL::DB::Manager::PartClassification->get_all(where => [ $attribute => 1 ]) } ];
|
|
1675 |
return [ map { $_->id } @{ SL::DB::Manager::PartClassification->get_all(
|
|
1676 |
where => $self->type_data->part_classification_query()) } ];
|
1681 |
1677 |
}
|
1682 |
1678 |
|
1683 |
1679 |
sub init_is_final_version {
|
... | ... | |
1696 |
1692 |
|
1697 |
1693 |
sub check_auth {
|
1698 |
1694 |
my ($self) = @_;
|
1699 |
|
|
1700 |
|
my $right_for = { map { $_ => $_.'_edit' . ' | ' . $_.'_view' } @{$self->valid_types} };
|
1701 |
|
|
1702 |
|
my $right = $right_for->{ $self->type };
|
1703 |
|
$right ||= 'DOES_NOT_EXIST';
|
1704 |
|
|
1705 |
|
$::auth->assert($right);
|
|
1695 |
$::auth->assert($self->type_data->rights('view'));
|
1706 |
1696 |
}
|
1707 |
1697 |
|
1708 |
1698 |
sub check_auth_for_edit {
|
1709 |
1699 |
my ($self) = @_;
|
1710 |
|
|
1711 |
|
my $right_for = { map { $_ => $_.'_edit' } @{$self->valid_types} };
|
1712 |
|
|
1713 |
|
my $right = $right_for->{ $self->type };
|
1714 |
|
$right ||= 'DOES_NOT_EXIST';
|
1715 |
|
|
1716 |
|
$::auth->assert($right);
|
|
1700 |
$::auth->assert($self->type_data->rights('edit'));
|
1717 |
1701 |
}
|
1718 |
1702 |
|
1719 |
1703 |
# build the selection box for contacts
|
... | ... | |
2213 |
2197 |
sub setup_edit_action_bar {
|
2214 |
2198 |
my ($self, %params) = @_;
|
2215 |
2199 |
|
2216 |
|
my $deletion_allowed = (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE()))
|
2217 |
|
|| (($self->type eq SALES_ORDER_TYPE()) && $::instance_conf->get_sales_order_show_delete)
|
2218 |
|
|| (($self->type eq PURCHASE_ORDER_TYPE()) && $::instance_conf->get_purchase_order_show_delete);
|
2219 |
|
|
2220 |
2200 |
my @req_trans_cost_art = qw(kivi.Order.check_transport_cost_article_presence) x!!$::instance_conf->get_transport_cost_reminder_article_number_id;
|
2221 |
2201 |
my @req_cusordnumber = qw(kivi.Order.check_cusordnumber_presence) x($self->type eq SALES_ORDER_TYPE() && $::instance_conf->get_order_warn_no_cusordnumber);
|
2222 |
2202 |
|
... | ... | |
2232 |
2212 |
$has_final_invoice = any {'SL::DB::Invoice' eq ref $_ && "final_invoice" eq $_->type} @$lr;
|
2233 |
2213 |
}
|
2234 |
2214 |
|
2235 |
|
my $right_for = { map { $_ => $_.'_edit' } @{$self->valid_types} };
|
2236 |
|
my $right = $right_for->{ $self->type };
|
2237 |
|
$right ||= 'DOES_NOT_EXIST';
|
2238 |
|
my $may_edit_create = $::auth->assert($right, 'may fail');
|
|
2215 |
my $may_edit_create = $::auth->assert($self->type_data->rights('edit'), 'may fail');
|
2239 |
2216 |
|
2240 |
2217 |
my $is_final_version = $self->is_final_version;
|
2241 |
2218 |
|
... | ... | |
2297 |
2274 |
t8('Save and Quotation'),
|
2298 |
2275 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => SALES_QUOTATION_TYPE()), '#order_form' ],
|
2299 |
2276 |
checks => [ @req_trans_cost_art, @req_cusordnumber ],
|
2300 |
|
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), REQUEST_QUOTATION_TYPE())),
|
|
2277 |
only_if => $self->type_data->show_menu('save_and_quotation'),
|
2301 |
2278 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2302 |
2279 |
],
|
2303 |
2280 |
action => [
|
2304 |
2281 |
t8('Save and RFQ'),
|
2305 |
2282 |
call => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => REQUEST_QUOTATION_TYPE() } ],
|
2306 |
|
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), SALES_QUOTATION_TYPE(), PURCHASE_ORDER_TYPE())),
|
|
2283 |
only_if => $self->type_data->show_menu('save_and_rfq'),
|
2307 |
2284 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2308 |
2285 |
],
|
2309 |
2286 |
action => [
|
2310 |
2287 |
t8('Save and Sales Order'),
|
2311 |
2288 |
call => [ 'kivi.submit_ajax_form', $self->url_for(action => "save_and_order_workflow", to_type => SALES_ORDER_TYPE()), '#order_form' ],
|
2312 |
2289 |
checks => [ @req_trans_cost_art ],
|
2313 |
|
only_if => (any { $self->type eq $_ } (SALES_QUOTATION_TYPE(), REQUEST_QUOTATION_TYPE(), PURCHASE_ORDER_TYPE())),
|
|
2290 |
only_if => $self->type_data->show_menu('save_and_sales_order'),
|
2314 |
2291 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2315 |
2292 |
],
|
2316 |
2293 |
action => [
|
2317 |
2294 |
t8('Save and Purchase Order'),
|
2318 |
2295 |
call => [ 'kivi.Order.purchase_check_for_direct_delivery', { to_type => PURCHASE_ORDER_TYPE() } ],
|
2319 |
2296 |
checks => [ @req_trans_cost_art, @req_cusordnumber ],
|
2320 |
|
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), REQUEST_QUOTATION_TYPE())),
|
|
2297 |
only_if => $self->type_data->show_menu('save_and_purchase_order'),
|
2321 |
2298 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2322 |
2299 |
],
|
2323 |
2300 |
action => [
|
... | ... | |
2329 |
2306 |
checks => [ 'kivi.Order.check_save_active_periodic_invoices',
|
2330 |
2307 |
@req_trans_cost_art, @req_cusordnumber,
|
2331 |
2308 |
],
|
2332 |
|
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), PURCHASE_ORDER_TYPE())),
|
|
2309 |
only_if => $self->type_data->show_menu('save_and_delivery_order'),
|
2333 |
2310 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2334 |
2311 |
],
|
2335 |
2312 |
action => [
|
... | ... | |
2352 |
2329 |
checks => [ 'kivi.Order.check_save_active_periodic_invoices',
|
2353 |
2330 |
@req_trans_cost_art, @req_cusordnumber,
|
2354 |
2331 |
],
|
2355 |
|
only_if => (any { $self->type eq $_ } (PURCHASE_ORDER_TYPE())),
|
|
2332 |
only_if => $self->type_data->show_menu('save_and_supplier_delivery_order'),
|
2356 |
2333 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2357 |
2334 |
],
|
2358 |
2335 |
action => [
|
... | ... | |
2360 |
2337 |
call => [ 'kivi.Order.save', { action => 'save_and_reclamation',
|
2361 |
2338 |
warn_on_duplicates => $::instance_conf->get_order_warn_duplicate_parts },
|
2362 |
2339 |
],
|
2363 |
|
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE(), PURCHASE_ORDER_TYPE()))
|
|
2340 |
only_if =>$self->type_data->show_menu('save_and_reclamation')
|
2364 |
2341 |
],
|
2365 |
2342 |
action => [
|
2366 |
2343 |
t8('Save and Invoice'),
|
... | ... | |
2371 |
2348 |
@req_trans_cost_art, @req_cusordnumber,
|
2372 |
2349 |
],
|
2373 |
2350 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
|
2351 |
only_if => $self->type_data->show_menu('save_and_invoice'),
|
2374 |
2352 |
],
|
2375 |
2353 |
action => [
|
2376 |
2354 |
($has_invoice_for_advance_payment ? t8('Save and Further Invoice for Advance Payment') : t8('Save and Invoice for Advance Payment')),
|
... | ... | |
2383 |
2361 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.')
|
2384 |
2362 |
: $has_final_invoice ? t8('This order has already a final invoice.')
|
2385 |
2363 |
: undef,
|
2386 |
|
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE())),
|
|
2364 |
only_if => $self->type_data->show_menu('save_and_invoice_for_advance_payment'),
|
2387 |
2365 |
],
|
2388 |
2366 |
action => [
|
2389 |
2367 |
t8('Save and Final Invoice'),
|
... | ... | |
2396 |
2374 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.')
|
2397 |
2375 |
: $has_final_invoice ? t8('This order has already a final invoice.')
|
2398 |
2376 |
: undef,
|
2399 |
|
only_if => (any { $self->type eq $_ } (SALES_ORDER_TYPE())) && $has_invoice_for_advance_payment,
|
|
2377 |
only_if => $self->type_data->show_menu('save_and_final_invoice') && $has_invoice_for_advance_payment,
|
2400 |
2378 |
],
|
2401 |
2379 |
action => [
|
2402 |
2380 |
t8('Save and AP Transaction'),
|
2403 |
2381 |
call => [ 'kivi.Order.save', { action => 'save_and_ap_transaction',
|
2404 |
2382 |
warn_on_duplicates => $::instance_conf->get_order_warn_duplicate_parts },
|
2405 |
2383 |
],
|
2406 |
|
only_if => (any { $self->type eq $_ } (PURCHASE_ORDER_TYPE())),
|
|
2384 |
only_if => $self->type_data->show_menu('save_and_ap_transaction'),
|
2407 |
2385 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.') : undef,
|
2408 |
2386 |
],
|
2409 |
2387 |
|
... | ... | |
2458 |
2436 |
disabled => !$may_edit_create ? t8('You do not have the permissions to access this function.')
|
2459 |
2437 |
: !$self->order->id ? t8('This object has not been saved yet.')
|
2460 |
2438 |
: undef,
|
2461 |
|
only_if => $deletion_allowed,
|
|
2439 |
only_if => $self->type_data->show_menu('delete'),
|
2462 |
2440 |
],
|
2463 |
2441 |
|
2464 |
2442 |
combobox => [
|
... | ... | |
2603 |
2581 |
return $active ? t8('active') : t8('inactive');
|
2604 |
2582 |
}
|
2605 |
2583 |
|
2606 |
|
sub get_title_for {
|
2607 |
|
my ($self, $action) = @_;
|
2608 |
|
|
2609 |
|
return '' if none { lc($action)} qw(add edit);
|
2610 |
|
|
2611 |
|
# for locales:
|
2612 |
|
# $::locale->text("Add Sales Order");
|
2613 |
|
# $::locale->text("Add Purchase Order");
|
2614 |
|
# $::locale->text("Add Quotation");
|
2615 |
|
# $::locale->text("Add Request for Quotation");
|
2616 |
|
# $::locale->text("Edit Sales Order");
|
2617 |
|
# $::locale->text("Edit Purchase Order");
|
2618 |
|
# $::locale->text("Edit Quotation");
|
2619 |
|
# $::locale->text("Edit Request for Quotation");
|
2620 |
|
|
2621 |
|
$action = ucfirst(lc($action));
|
2622 |
|
return $self->type eq SALES_ORDER_TYPE() ? $::locale->text("$action Sales Order")
|
2623 |
|
: $self->type eq PURCHASE_ORDER_TYPE() ? $::locale->text("$action Purchase Order")
|
2624 |
|
: $self->type eq SALES_QUOTATION_TYPE() ? $::locale->text("$action Quotation")
|
2625 |
|
: $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text("$action Request for Quotation")
|
2626 |
|
: '';
|
2627 |
|
}
|
2628 |
|
|
2629 |
2584 |
sub get_item_cvpartnumber {
|
2630 |
2585 |
my ($self, $item) = @_;
|
2631 |
2586 |
|
... | ... | |
2701 |
2656 |
}
|
2702 |
2657 |
|
2703 |
2658 |
sub nr_key {
|
2704 |
|
return $_[0]->type eq SALES_ORDER_TYPE() ? 'ordnumber'
|
2705 |
|
: $_[0]->type eq PURCHASE_ORDER_TYPE() ? 'ordnumber'
|
2706 |
|
: $_[0]->type eq SALES_QUOTATION_TYPE() ? 'quonumber'
|
2707 |
|
: $_[0]->type eq REQUEST_QUOTATION_TYPE() ? 'quonumber'
|
2708 |
|
: '';
|
|
2659 |
my ($self) = @_;
|
|
2660 |
|
|
2661 |
return $self->type_data->properties('nr_key');
|
2709 |
2662 |
}
|
2710 |
2663 |
|
2711 |
2664 |
sub save_and_redirect_to {
|
... | ... | |
2713 |
2666 |
|
2714 |
2667 |
$self->save();
|
2715 |
2668 |
|
2716 |
|
my $text = $self->type eq SALES_ORDER_TYPE() ? $::locale->text('The order has been saved')
|
2717 |
|
: $self->type eq PURCHASE_ORDER_TYPE() ? $::locale->text('The order has been saved')
|
2718 |
|
: $self->type eq SALES_QUOTATION_TYPE() ? $::locale->text('The quotation has been saved')
|
2719 |
|
: $self->type eq REQUEST_QUOTATION_TYPE() ? $::locale->text('The rfq has been saved')
|
2720 |
|
: '';
|
2721 |
|
flash_later('info', $text);
|
|
2669 |
flash_later('info', $self->type_data->text('saved'));
|
2722 |
2670 |
|
2723 |
2671 |
$self->redirect_to(%params, id => $self->order->id);
|
2724 |
2672 |
}
|
Order: nutze TypeData