From: Bernd Bleßmann Date: Mon, 20 Sep 2021 08:57:36 +0000 (+0200) Subject: Auftrags-Controller: Warnung bei fehlendem Transportkosten-Artikel … X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~345 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=9ce44b6f09f77fc51a69e4536fa44dee68d0ab85;p=kivitendo-erp.git Auftrags-Controller: Warnung bei fehlendem Transportkosten-Artikel … bei VK-Angebot und -Auftrag, wenn in der Mandanten-Konfiguration angegeben. --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index ae8c8dea6..284e200ab 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -1873,6 +1873,11 @@ sub pre_render { } } @all_objects; } + if ( (any { $self->type eq $_ } (sales_quotation_type(), sales_order_type())) + && $::instance_conf->get_transport_cost_reminder_article_number_id ) { + $self->{template_args}->{transport_cost_reminder_article} = SL::DB::Part->new(id => $::instance_conf->get_transport_cost_reminder_article_number_id)->load; + } + $self->get_item_cvpartnumber($_) for @{$self->order->items_sorted}; $::request->{layout}->use_javascript("${_}.js") for qw(kivi.SalesPurchase kivi.Order kivi.File ckeditor/ckeditor ckeditor/adapters/jquery @@ -1887,6 +1892,8 @@ sub setup_edit_action_bar { || (($self->type eq sales_order_type()) && $::instance_conf->get_sales_order_show_delete) || (($self->type eq purchase_order_type()) && $::instance_conf->get_purchase_order_show_delete); + my @req_trans_cost_art = qw(kivi.Order.check_transport_cost_article_presence) x!!$::instance_conf->get_transport_cost_reminder_article_number_id; + for my $bar ($::request->layout->get('actionbar')) { $bar->add( combobox => [ @@ -1895,12 +1902,12 @@ sub setup_edit_action_bar { call => [ 'kivi.Order.save', 'save', $::instance_conf->get_order_warn_duplicate_parts, $::instance_conf->get_order_warn_no_deliverydate, ], - checks => [ 'kivi.Order.check_save_active_periodic_invoices', ['kivi.validate_form','#order_form'] ], + checks => [ 'kivi.Order.check_save_active_periodic_invoices', ['kivi.validate_form','#order_form'], @req_trans_cost_art ], ], action => [ t8('Save as new'), call => [ 'kivi.Order.save', 'save_as_new', $::instance_conf->get_order_warn_duplicate_parts ], - checks => [ 'kivi.Order.check_save_active_periodic_invoices' ], + checks => [ 'kivi.Order.check_save_active_periodic_invoices', @req_trans_cost_art ], disabled => !$self->order->id ? t8('This object has not been saved yet.') : undef, ], ], # end of combobox "Save" @@ -1912,6 +1919,7 @@ sub setup_edit_action_bar { action => [ t8('Save and Quotation'), submit => [ '#order_form', { action => "Order/sales_quotation" } ], + checks => [ @req_trans_cost_art ], only_if => (any { $self->type eq $_ } (sales_order_type())), ], action => [ @@ -1922,11 +1930,13 @@ sub setup_edit_action_bar { action => [ t8('Save and Sales Order'), submit => [ '#order_form', { action => "Order/sales_order" } ], + checks => [ @req_trans_cost_art ], only_if => (any { $self->type eq $_ } (sales_quotation_type(), purchase_order_type())), ], action => [ t8('Save and Purchase Order'), call => [ 'kivi.Order.purchase_order_check_for_direct_delivery' ], + checks => [ @req_trans_cost_art ], only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())), ], action => [ @@ -1934,13 +1944,13 @@ sub setup_edit_action_bar { call => [ 'kivi.Order.save', 'save_and_delivery_order', $::instance_conf->get_order_warn_duplicate_parts, $::instance_conf->get_order_warn_no_deliverydate, ], - checks => [ 'kivi.Order.check_save_active_periodic_invoices' ], + checks => [ 'kivi.Order.check_save_active_periodic_invoices', @req_trans_cost_art ], only_if => (any { $self->type eq $_ } (sales_order_type(), purchase_order_type())) ], action => [ t8('Save and Invoice'), call => [ 'kivi.Order.save', 'save_and_invoice', $::instance_conf->get_order_warn_duplicate_parts ], - checks => [ 'kivi.Order.check_save_active_periodic_invoices' ], + checks => [ 'kivi.Order.check_save_active_periodic_invoices', @req_trans_cost_art ], ], action => [ t8('Save and AP Transaction'), @@ -1956,15 +1966,17 @@ sub setup_edit_action_bar { ], action => [ t8('Save and preview PDF'), - call => [ 'kivi.Order.save', 'preview_pdf', $::instance_conf->get_order_warn_duplicate_parts, - $::instance_conf->get_order_warn_no_deliverydate, - ], + call => [ 'kivi.Order.save', 'preview_pdf', $::instance_conf->get_order_warn_duplicate_parts, + $::instance_conf->get_order_warn_no_deliverydate, + ], + checks => [ @req_trans_cost_art ], ], action => [ t8('Save and print'), - call => [ 'kivi.Order.show_print_options', $::instance_conf->get_order_warn_duplicate_parts, - $::instance_conf->get_order_warn_no_deliverydate, - ], + call => [ 'kivi.Order.show_print_options', $::instance_conf->get_order_warn_duplicate_parts, + $::instance_conf->get_order_warn_no_deliverydate, + ], + checks => [ @req_trans_cost_art ], ], action => [ t8('Save and E-mail'), @@ -2416,7 +2428,7 @@ java script functions =item * optional client/user behaviour (transactions has to be set - department has to be set - - force project if enabled in client config - transport cost reminder) + force project if enabled in client config) =back diff --git a/js/kivi.Order.js b/js/kivi.Order.js index a96f49f7f..140eba2f0 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -844,6 +844,23 @@ namespace('kivi.Order', function(ns) { $.post("controller.pl", data, kivi.eval_json_result); }; + ns.check_transport_cost_article_presence = function() { + var $form = $('#order_form'); + var wanted_part_id = $form.data('transport-cost-reminder-article-id'); + + if (!wanted_part_id) return true + + var id_arr = $('[name="order.orderitems[].parts_id"]').map(function() { return this.value; }).get(); + id_arr = $.grep(id_arr, function(elt) { + return ((elt*1) === wanted_part_id); + }); + + if (id_arr.length) return true; + + var description = $form.data('transport-cost-reminder-article-description'); + return confirm(kivi.t8("The transport cost article '#1' is missing. Do you want to continue anyway?", [ description ])); + }; + }); $(function() { diff --git a/templates/webpages/order/form.html b/templates/webpages/order/form.html index c3ff986aa..17534de23 100644 --- a/templates/webpages/order/form.html +++ b/templates/webpages/order/form.html @@ -15,7 +15,9 @@ -
+ [% L.hidden_tag('callback', FORM.callback) %] [% L.hidden_tag('type', FORM.type) %] [% L.hidden_tag('id', SELF.order.id) %]