Finanzcontrollingbericht: ungültige und inaktive Projekte herausfiltern
[kivitendo-erp.git] / SL / Controller / CustomerVendor.pm
index f2e4ff6..de77490 100644 (file)
@@ -394,6 +394,8 @@ sub action_search_contact {
 sub action_get_delivery {
   my ($self) = @_;
 
+  $::auth->assert('sales_all_edit');
+
   my $dbh = $::form->get_standard_dbh();
 
   my ($arap, $db, $qty_sign);
@@ -407,21 +409,24 @@ sub action_get_delivery {
     $qty_sign = '';
   }
 
-  my $where = ' WHERE 1=1 ';
+  my $where = ' WHERE 1=1';
   my @values;
 
   if ( !$self->is_vendor() && $::form->{shipto_id} && $::form->{shipto_id} ne 'all' ) {
-    $where .= "AND ${arap}.shipto_id = ?";
+    $where .= " AND ${arap}.shipto_id = ?";
     push(@values, $::form->{shipto_id});
+  } else {
+    $where .= " AND ${arap}.${db}_id = ?";
+    push(@values, $::form->{id});
   }
 
   if ( $::form->{delivery_from} ) {
-    $where .= "AND ${arap}.transdate >= ?";
+    $where .= " AND ${arap}.transdate >= ?";
     push(@values, conv_date($::form->{delivery_from}));
   }
 
   if ( $::form->{delivery_to} ) {
-    $where .= "AND ${arap}.transdate <= ?";
+    $where .= " AND ${arap}.transdate <= ?";
     push(@values, conv_date($::form->{delivery_to}));
   }
 
@@ -807,6 +812,8 @@ sub _pre_render {
 
   $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all();
 
+  $self->{all_delivery_terms} = SL::DB::Manager::DeliveryTerm->get_all();
+
   $self->{all_pricegroups} = SL::DB::Manager::Pricegroup->get_all();
 
   $query =