]> wagnertech.de Git - mfinanz.git/blobdiff - SL/OE.pm
SL::DB::CustomVariable->value: undef anstelle von 0 wenn ref.Objekt nicht existiert
[mfinanz.git] / SL / OE.pm
index 52a5a61d683565b7c8e876d134b01636eda1d365..2c821cb25d5cc093183b67d2c9d313e0081a3735 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -118,6 +118,7 @@ sub transactions {
     qq|  , o.order_probability, o.expected_billing_date, (o.netamount * o.order_probability / 100) AS expected_netamount | .
     qq|FROM oe o | .
     qq|JOIN $vc ct ON (o.${vc}_id = ct.id) | .
+    qq|LEFT JOIN contacts cp ON (o.cp_id = cp.cp_id) | .
     qq|LEFT JOIN employee e ON (o.employee_id = e.id) | .
     qq|LEFT JOIN employee s ON (o.salesman_id = s.id) | .
     qq|LEFT JOIN exchangerate ex ON (ex.currency_id = o.currency_id | .
@@ -168,6 +169,11 @@ SQL
     push(@values, '%' . $form->{$vc} . '%');
   }
 
+  if ($form->{"cp_name"}) {
+    $query .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
+    push(@values, ('%' . $form->{"cp_name"} . '%')x2);
+  }
+
   if (!$main::auth->assert('sales_all_edit', 1)) {
     $query .= " AND o.employee_id = (select id from employee where login= ?)";
     push @values, $form->{login};
@@ -795,6 +801,11 @@ sub retrieve {
   if (!$form->{id}) {
     my $wday         = (localtime(time))[6];
     my $next_workday = $wday == 5 ? 3 : $wday == 6 ? 2 : 1;
+
+    # if we have a client configured interval for sales quotation, we add this
+    $next_workday   += $::instance_conf->get_reqdate_interval if ($::instance_conf->get_reqdate_interval &&
+                                                                    $form->{type} eq 'sales_quotation' );
+
     $query_add       = qq|, current_date AS transdate, date(current_date + interval '${next_workday} days') AS reqdate|;
   }