]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/DO.pm
PriceSource: Spalte vor Preis und Rabatt anzeigen.
[kivitendo-erp.git] / SL / DO.pm
index a66b64d5f81b1e469b6ed88d3378c63ea08271b0..478a12512ed12a917c91d8a9e3d8a1974a37becc 100644 (file)
--- a/SL/DO.pm
+++ b/SL/DO.pm
@@ -76,6 +76,7 @@ sub transactions {
          sm.name AS salesman
        FROM delivery_orders dord
        LEFT JOIN $vc ct ON (dord.${vc}_id = ct.id)
+       LEFT JOIN contacts cp ON (dord.cp_id = cp.cp_id)
        LEFT JOIN employee e ON (dord.employee_id = e.id)
        LEFT JOIN employee sm ON (dord.salesman_id = sm.id)
        LEFT JOIN project pr ON (dord.globalproject_id = pr.id)
@@ -106,6 +107,11 @@ sub transactions {
     push @values, '%' . $form->{$vc} . '%';
   }
 
+  if ($form->{"cp_name"}) {
+    push @where, "(cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)";
+    push @values, ('%' . $form->{"cp_name"} . '%')x2;
+  }
+
   foreach my $item (qw(employee_id salesman_id)) {
     next unless ($form->{$item});
     push @where, "dord.$item = ?";
@@ -278,9 +284,10 @@ sub save {
          id, delivery_order_id, parts_id, description, longdescription, qty, base_qty,
          sellprice, discount, unit, reqdate, project_id, serialnumber,
          ordnumber, transdate, cusordnumber,
-         lastcost, price_factor_id, price_factor, marge_price_factor, pricegroup_id)
+         lastcost, price_factor_id, price_factor, marge_price_factor, pricegroup_id,
+         active_price_source, active_discount_source)
        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
-         (SELECT factor FROM price_factors WHERE id = ?), ?, ?)|;
+         (SELECT factor FROM price_factors WHERE id = ?), ?, ?, ?, ?)|;
   my $h_item = prepare_query($form, $dbh, $q_item);
 
   my $q_item_stock =
@@ -335,7 +342,8 @@ sub save {
                $form->{"lastcost_$i"},
                conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}),
                conv_i($form->{"marge_price_factor_$i"}),
-               $pricegroup_id);
+               $pricegroup_id,
+               $form->{"active_price_source_$i"}, $form->{"active_discount_source_$i"});
     do_statement($form, $h_item, $q_item, @values);
 
     my $stock_info = DO->unpack_stock_information('packed' => $form->{"stock_${in_out}_$i"});
@@ -682,6 +690,7 @@ sub retrieve {
          doi.reqdate, doi.project_id, doi.serialnumber, doi.lastcost,
          doi.ordnumber, doi.transdate, doi.cusordnumber, doi.longdescription,
          doi.price_factor_id, doi.price_factor, doi.marge_price_factor, doi.pricegroup_id,
+         doi.active_price_source, doi.active_discount_source,
          pr.projectnumber, dord.transdate AS dord_transdate, dord.donumber,
          pg.partsgroup
        FROM delivery_order_items doi