From 8e77bd29b697f3a86f9376e2b733b064712a6ff6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Wed, 31 Jan 2018 15:09:49 +0100 Subject: [PATCH] =?utf8?q?Auftrags-Controller:=20auch=20f=C3=BCr=20Angebot?= =?utf8?q?e/Anfragen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Order.pm | 68 +++++++++++++++---- bin/mozilla/oe.pl | 4 +- js/kivi.Order.js | 6 +- menus/user/10-order-controller.yaml | 18 +++++ .../webpages/order/tabs/_second_row.html | 14 ++-- templates/webpages/order/tabs/basic_data.html | 42 ++++++++++-- 6 files changed, 124 insertions(+), 28 deletions(-) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index ac619d5bd..4345f6687 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -60,8 +60,10 @@ sub action_add { $self->_pre_render(); $self->render( 'order/form', - title => $self->type eq _sales_order_type() ? $::locale->text('Add Sales Order') - : $self->type eq _purchase_order_type() ? $::locale->text('Add Purchase Order') + title => $self->type eq _sales_order_type() ? $::locale->text('Add Sales Order') + : $self->type eq _purchase_order_type() ? $::locale->text('Add Purchase Order') + : $self->type eq _sales_quotation_type() ? $::locale->text('Add Quotation') + : $self->type eq _request_quotation_type() ? $::locale->text('Add Request for Quotation') : '', %{$self->{template_args}} ); @@ -76,8 +78,10 @@ sub action_edit { $self->_pre_render(); $self->render( 'order/form', - title => $self->type eq _sales_order_type() ? $::locale->text('Edit Sales Order') - : $self->type eq _purchase_order_type() ? $::locale->text('Edit Purchase Order') + title => $self->type eq _sales_order_type() ? $::locale->text('Edit Sales Order') + : $self->type eq _purchase_order_type() ? $::locale->text('Edit Purchase Order') + : $self->type eq _sales_quotation_type() ? $::locale->text('Edit Quotation') + : $self->type eq _request_quotation_type() ? $::locale->text('Edit Request for Quotation') : '', %{$self->{template_args}} ); @@ -94,7 +98,13 @@ sub action_delete { return $self->js->render(); } - flash_later('info', $::locale->text('The order has been deleted')); + my $text = $self->type eq _sales_order_type() ? $::locale->text('The order has been deleted') + : $self->type eq _purchase_order_type() ? $::locale->text('The order has been deleted') + : $self->type eq _sales_quotation_type() ? $::locale->text('The quotation has been deleted') + : $self->type eq _request_quotation_type() ? $::locale->text('The rfq has been deleted') + : ''; + flash_later('info', $text); + my @redirect_params = ( action => 'add', type => $self->type, @@ -114,7 +124,13 @@ sub action_save { return $self->js->render(); } - flash_later('info', $::locale->text('The order has been saved')); + my $text = $self->type eq _sales_order_type() ? $::locale->text('The order has been saved') + : $self->type eq _purchase_order_type() ? $::locale->text('The order has been saved') + : $self->type eq _sales_quotation_type() ? $::locale->text('The quotation has been saved') + : $self->type eq _request_quotation_type() ? $::locale->text('The rfq has been saved') + : ''; + flash_later('info', $text); + my @redirect_params = ( action => 'edit', type => $self->type, @@ -458,7 +474,13 @@ sub action_save_and_delivery_order { $self->js->flash('error', $_) foreach @{ $errors }; return $self->js->render(); } - flash_later('info', $::locale->text('The order has been saved')); + + my $text = $self->type eq _sales_order_type() ? $::locale->text('The order has been saved') + : $self->type eq _purchase_order_type() ? $::locale->text('The order has been saved') + : $self->type eq _sales_quotation_type() ? $::locale->text('The quotation has been saved') + : $self->type eq _request_quotation_type() ? $::locale->text('The rfq has been saved') + : ''; + flash_later('info', $text); my @redirect_params = ( controller => 'oe.pl', @@ -480,7 +502,13 @@ sub action_save_and_invoice { $self->js->flash('error', $_) foreach @{ $errors }; return $self->js->render(); } - flash_later('info', $::locale->text('The order has been saved')); + + my $text = $self->type eq _sales_order_type() ? $::locale->text('The order has been saved') + : $self->type eq _purchase_order_type() ? $::locale->text('The order has been saved') + : $self->type eq _sales_quotation_type() ? $::locale->text('The quotation has been saved') + : $self->type eq _request_quotation_type() ? $::locale->text('The rfq has been saved') + : ''; + flash_later('info', $text); my @redirect_params = ( controller => 'oe.pl', @@ -856,7 +884,7 @@ sub _js_redisplay_amounts_and_taxes { # sub init_valid_types { - [ _sales_order_type(), _purchase_order_type() ]; + [ _sales_order_type(), _purchase_order_type(), _sales_quotation_type(), _request_quotation_type() ]; } sub init_type { @@ -872,8 +900,8 @@ sub init_type { sub init_cv { my ($self) = @_; - my $cv = $self->type eq _sales_order_type() ? 'customer' - : $self->type eq _purchase_order_type() ? 'vendor' + my $cv = (any { $self->type eq $_ } (_sales_order_type(), _sales_quotation_type())) ? 'customer' + : (any { $self->type eq $_ } (_purchase_order_type(), _request_quotation_type())) ? 'vendor' : die "Not a valid type for order"; return $cv; @@ -1007,7 +1035,8 @@ sub _make_order { # order here solves this problem. my $order; $order = SL::DB::Manager::Order->find_by(id => $::form->{id}) if $::form->{id}; - $order ||= SL::DB::Order->new(orderitems => []); + $order ||= SL::DB::Order->new(orderitems => [], + quotation => (any { $self->type eq $_ } (_sales_quotation_type(), _request_quotation_type()))); my $form_orderitems = delete $::form->{order}->{orderitems}; my $form_periodic_invoices_config = delete $::form->{order}->{periodic_invoices_config}; @@ -1226,6 +1255,7 @@ sub _pre_render { $self->{all_delivery_terms} = SL::DB::Manager::DeliveryTerm->get_all_sorted(); $self->{current_employee_id} = SL::DB::Manager::Employee->current->id; $self->{periodic_invoices_status} = $self->_get_periodic_invoices_status($self->order->periodic_invoices_config); + $self->{order_probabilities} = [ map { { title => ($_ * 10) . '%', id => $_ * 10 } } (0..10) ]; my $print_form = Form->new(''); $print_form->{type} = $self->type; @@ -1266,8 +1296,9 @@ sub _pre_render { sub _setup_edit_action_bar { my ($self, %params) = @_; - my $deletion_allowed = (($self->cv eq 'customer') && $::instance_conf->get_sales_order_show_delete) - || (($self->cv eq 'vendor') && $::instance_conf->get_purchase_order_show_delete); + my $deletion_allowed = (any { $self->type eq $_ } (_sales_quotation_type(), _request_quotation_type())) + || (($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); for my $bar ($::request->layout->get('actionbar')) { $bar->add( @@ -1282,6 +1313,7 @@ sub _setup_edit_action_bar { t8('Save and Delivery Order'), call => [ 'kivi.Order.save_and_delivery_order', $::instance_conf->get_order_warn_duplicate_parts ], checks => [ 'kivi.Order.check_save_active_periodic_invoices' ], + only_if => (any { $self->type eq $_ } (_sales_order_type(), _purchase_order_type())) ], action => [ t8('Save and Invoice'), @@ -1435,6 +1467,14 @@ sub _purchase_order_type { 'purchase_order'; } +sub _sales_quotation_type { + 'sales_quotation'; +} + +sub _request_quotation_type { + 'request_quotation'; +} + 1; __END__ diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 2a57dcae5..7832b2e39 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1035,7 +1035,7 @@ sub orders { $form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed}); $form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered}); $form->{l_periodic_invoices} = "Y" if ($form->{periodic_invoices_active} && $form->{periodic_invoices_inactive}); - $form->{l_edit_exp} = "Y" if $::instance_conf->get_feature_experimental && (any { $form->{type} eq $_ } qw(sales_order purchase_order)); + $form->{l_edit_exp} = "Y" if $::instance_conf->get_feature_experimental && (any { $form->{type} eq $_ } qw(sales_order purchase_order sales_quotation request_quotation)); map { $form->{"l_${_}"} = 'Y' } qw(order_probability expected_billing_date expected_netamount) if $form->{l_order_probability_expected_billing_date}; my $attachment_basename; @@ -1265,7 +1265,7 @@ sub orders { $row->{$ordnumber}->{link} = $edit_url . "&id=" . E($oe->{id}) . "&callback=${callback}"; - $row->{edit_exp}->{data} = $oe->{ordnumber}; + $row->{edit_exp}->{data} = $oe->{$ordnumber}; $row->{edit_exp}->{link} = build_std_url('script=controller.pl', 'action=Order/edit', "type=$form->{type}", 'id=' . E($oe->{id})); my $row_set = [ $row ]; diff --git a/js/kivi.Order.js b/js/kivi.Order.js index 39e0191a4..18756f21c 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -1,6 +1,6 @@ namespace('kivi.Order', function(ns) { ns.check_cv = function() { - if ($('#type').val() == 'sales_order') { + if ($('#type').val() == 'sales_order' || $('#type').val() == 'sales_quotation' ) { if ($('#order_customer_id').val() === '') { alert(kivi.t8('Please select a customer.')); return false; @@ -610,13 +610,13 @@ namespace('kivi.Order', function(ns) { }); $(function(){ - if ($('#type').val() == 'sales_order') { + if ($('#type').val() == 'sales_order' || $('#type').val() == 'sales_quotation' ) { $('#order_customer_id').change(kivi.Order.reload_cv_dependant_selections); } else { $('#order_vendor_id').change(kivi.Order.reload_cv_dependant_selections); } - if ($('#type').val() == 'sales_order') { + if ($('#type').val() == 'sales_order' || $('#type').val() == 'sales_quotation' ) { $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.sellprice, -2)) }); } else { $('#add_item_parts_id').on('set_item:PartPicker', function(e,o) { $('#add_item_sellprice_as_number').val(kivi.format_amount(o.lastcost, -2)) }); diff --git a/menus/user/10-order-controller.yaml b/menus/user/10-order-controller.yaml index b26b75b5b..e36c7c93a 100644 --- a/menus/user/10-order-controller.yaml +++ b/menus/user/10-order-controller.yaml @@ -1,3 +1,12 @@ +- parent: ar + id: ar_add_quotation_experimental + name: Add Quotation (experimental) + icon: quotation_add + order: 250 + access: sales_quotation_edit & client/feature_experimental + params: + action: Order/add + type: sales_quotation - parent: ar id: ar_add_sales_order_experimental name: Add Sales Order (experimental) @@ -8,6 +17,15 @@ action: Order/add type: sales_order +- parent: ap + id: ap_add_rfq_experimental + name: Add RFQ (experimental) + icon: rfq_add + order: 150 + access: request_quotation_edit & client/feature_experimental + params: + action: Order/add + type: request_quotation - parent: ap id: ap_add_purchase_order_experimental name: Add Purchase Order (experimental) diff --git a/templates/webpages/order/tabs/_second_row.html b/templates/webpages/order/tabs/_second_row.html index d8d8a8644..18226ab07 100644 --- a/templates/webpages/order/tabs/_second_row.html +++ b/templates/webpages/order/tabs/_second_row.html @@ -6,15 +6,19 @@ [% END %] + [%- IF (SELF.type == "sales_order" || SELF.type == "purchase_order") -%] + [%- END -%] + [%- IF (SELF.type == "sales_order" || SELF.type == "sales_quotation") -%] + [%- SET quo_nr_txt = 'Quotation Number' -%] + [%- ELSE -%] + [%- SET quo_nr_txt = 'RFQ Number' -%] + [%- END -%] - + + [%- IF (SELF.type == "sales_order" || SELF.type == "purchase_order") -%] - + [%- END -%] + + [%- IF (SELF.type == "sales_order" || SELF.type == "purchase_order") -%] + [%- SET transdate_txt = 'Order Date' -%] + [%- ELSIF SELF.type == "sales_quotation" -%] + [%- SET transdate_txt = 'Quotation Date' -%] + [%- ELSE -%] + [%- SET transdate_txt = 'RFQ Date' -%] + [%- END -%] - + + [%- IF (SELF.type == "sales_order" || SELF.type == "purchase_order") -%] + [%- SET reqdate_txt = 'Reqdate' -%] + [%- ELSIF SELF.type == "sales_quotation" -%] + [%- SET reqdate_txt = 'Valid until' -%] + [%- ELSE -%] + [%- SET reqdate_txt = 'Required by' -%] + [%- END -%] - + + [%- IF SELF.type == "sales_quotation" -%] + + + + + + + + + [%- END %] + -- 2.20.1
- [%- 'Serial No.' | $T8 %]  - [%- L.input_tag("order.orderitems[].serialnumber", ITEM.serialnumber, size = 15) %]  + [%- IF (TYPE == "sales_order" || TYPE == "purchase_order") %] + [%- 'Serial No.' | $T8 %]  + [%- L.input_tag("order.orderitems[].serialnumber", ITEM.serialnumber, size = 15) %]  + [%- END %] [%- 'Project' | $T8 %]  [% P.project.picker("order.orderitems[].project_id", ITEM.project_id, size = 15) %]  - [%- 'Reqdate' | $T8 %]  - [% L.date_tag("order.orderitems[].reqdate", ITEM.reqdate) %]  + [%- IF (TYPE == "sales_order" || TYPE == "purchase_order") %] + [%- 'Reqdate' | $T8 %]  + [% L.date_tag("order.orderitems[].reqdate", ITEM.reqdate) %]  + [%- END %] [%- 'Subtotal' | $T8 %]  [% L.yes_no_tag("order.orderitems[].subtotal", ITEM.subtotal) %]  - [%- IF TYPE == "sales_order" %] + [%- IF (TYPE == "sales_order" || TYPE == "sales_quotation") %] [%- 'Ertrag' | $T8 %]  diff --git a/templates/webpages/order/tabs/basic_data.html b/templates/webpages/order/tabs/basic_data.html index d41e57b6a..877e5fdf6 100644 --- a/templates/webpages/order/tabs/basic_data.html +++ b/templates/webpages/order/tabs/basic_data.html @@ -108,31 +108,65 @@
[% 'Order Number' | $T8 %] [% L.input_tag('order.ordnumber', SELF.order.ordnumber, size = 11) %]
[% 'Quotation Number' | $T8 %][% quo_nr_txt | $T8 %] [% L.input_tag('order.quonumber', SELF.order.quonumber, size = 11) %]
[% 'Customer Order Number' | $T8 %] [% L.input_tag('order.cusordnumber', SELF.order.cusordnumber, size = 11) %]
[% 'Order Date' | $T8 %][% transdate_txt | $T8 %] [% L.date_tag('order.transdate', SELF.order.transdate) %]
[% 'Reqdate' | $T8 %][% reqdate_txt | $T8 %] [% L.date_tag('order.reqdate', SELF.order.reqdate) %]
[% 'Order probability' | $T8 %][%- L.select_tag('order.order_probability', SELF.order_probabilities, title='title', default=SELF.order.order_probability) %]%
[% 'Expected billing date' | $T8 %][%- L.date_tag('order.expected_billing_date', SELF.order.expected_billing_date) %]
[% 'Insert Date' | $T8 %] [% SELF.order.itime_as_date %]