]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/oe.pl
Einkaufs- & Verkaufsbelege: Bearbeiter*in & Verkäufer*in mit aktueller Benutzer*in...
[mfinanz.git] / bin / mozilla / oe.pl
index 2d89a05d749c5d89061e637c47f0ac6bddd174bd..8f4f28ac479f7e71312824acd3051283ae68d402 100644 (file)
@@ -358,35 +358,41 @@ sub setup_oe_action_bar {
 
       combobox => [
         action => [ t8('Workflow') ],
-        (action => [
+        action => [
           t8('Sales Order'),
           submit   => [ '#form', { action => "sales_order" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
-        ]) x !!$params{is_sales_quo},
-        (action => [
+          only_if  => $params{is_sales_quo} || $params{is_pur_ord},
+        ],
+        action => [
           t8('Purchase Order'),
-          submit   => [ '#form', { action => "sales_order" } ],
+          submit   => [ '#form', { action => "purchase_order" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
-        ]) x !!$params{is_req_quo},
-        (action => [
+          only_if  => $params{is_sales_ord} || $params{is_req_quo},
+        ],
+        action => [
           t8('Delivery Order'),
           submit   => [ '#form', { action => "delivery_order" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
-        ]) x ($params{is_sales_ord} || $params{is_pur_ord}),
-        (action => [
+          only_if  => $params{is_sales_ord} || $params{is_pur_ord},
+        ],
+        action => [
           t8('Invoice'),
           submit   => [ '#form', { action => "invoice" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
-        ]) x !!$allow_invoice,
+          only_if  => $allow_invoice,
+        ],
         action => [
           t8('Quotation'),
           submit   => [ '#form', { action => "quotation" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+          only_if  => $params{is_sales_ord},
         ],
         action => [
           t8('Request for Quotation'),
-          submit   => [ '#form', { action => "reqest_for_quotation" } ],
+          submit   => [ '#form', { action => "request_for_quotation" } ],
           disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+          only_if  => $params{is_pur_ord},
         ],
       ], # end of combobox "Workflow"
 
@@ -402,6 +408,12 @@ sub setup_oe_action_bar {
           call   => [ 'kivi.SalesPurchase.show_email_dialog' ],
           checks => [ @req_trans_desc ],
         ],
+        action => [
+          t8('Download attachments of all parts'),
+          call     => [ 'kivi.File.downloadOrderitemsFiles', $::form->{type}, $::form->{id} ],
+          disabled => !$form->{id} ? t8('This record has not been saved yet.') : undef,
+          only_if  => $::instance_conf->get_doc_storage,
+        ],
       ], #end of combobox "Export"
 
       combobox => [
@@ -474,8 +486,11 @@ sub form_header {
 
   $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
 
-  $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
-  $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
+  my $current_employee   = SL::DB::Manager::Employee->current;
+  $form->{employee_id}   = $form->{old_employee_id} if $form->{old_employee_id};
+  $form->{salesman_id}   = $form->{old_salesman_id} if $form->{old_salesman_id};
+  $form->{employee_id} ||= $current_employee->id;
+  $form->{salesman_id} ||= $current_employee->id;
 
   # openclosed checkboxes
   my @tmp;
@@ -1007,7 +1022,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 (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));
   map { $form->{"l_${_}"} = 'Y' } qw(order_probability expected_billing_date expected_netamount) if $form->{l_order_probability_expected_billing_date};
 
   my $attachment_basename;
@@ -1257,7 +1272,7 @@ sub orders {
   $report->add_data(create_subtotal_row(\%totals, \@columns, \%column_alignment, \@subtotal_columns, 'listtotal'));
 
   setup_oe_orders_action_bar();
-  $report->generate_with_headers(action_bar => 1);
+  $report->generate_with_headers();
 
   $main::lxdebug->leave_sub();
 }
@@ -1279,6 +1294,8 @@ sub check_delivered_flag {
   foreach my $i (1 .. $form->{rowcount}) {
     next if (!$form->{"id_$i"});
 
+    $form->{"ship_$i"} = 0 if $form->{saveasnew};
+
     if ($form->parse_amount(\%myconfig, $form->{"qty_$i"}) == $form->parse_amount(\%myconfig, $form->{"ship_$i"})) {
       $all_delivered = 1;
       next;
@@ -1289,6 +1306,7 @@ sub check_delivered_flag {
   }
 
   $form->{delivered} = 1 if $all_delivered;
+  $form->{delivered} = 0 if $form->{saveasnew};
 
   $main::lxdebug->leave_sub();
 }