Einkaufs-Lieferplan
authorJan Büren <jan@kivitendo-premium.de>
Mon, 3 Nov 2014 12:51:08 +0000 (13:51 +0100)
committerJan Büren <jan@kivitendo-premium.de>
Mon, 3 Nov 2014 12:51:08 +0000 (13:51 +0100)
Lieferplan für noch nicht vollständig gelieferte Einkaufsaufträge.

SL/Controller/DeliveryPlan.pm
locale/de/all
menus/erp.ini
templates/webpages/delivery_plan/_filter.html

index b740e26..b66698d 100644 (file)
@@ -22,16 +22,32 @@ my %sort_columns = (
   partnumber        => t8('Part Number'),
   qty               => t8('Qty'),
   shipped_qty       => t8('shipped'),
-  delivered_qty     => t8('transferred out'),
+  delivered_qty     => t8('transferred in / out'),
   not_shipped_qty   => t8('not shipped'),
   ordnumber         => t8('Order'),
   customer          => t8('Customer'),
+  vendor            => t8('Vendor'),
   value_of_goods    => t8('Value of goods'),
 );
 
+my $vc;
+
 sub action_list {
   my ($self) = @_;
 
+  $vc = "customer";
+  $self->make_filter_summary;
+  $self->prepare_report;
+
+  my $orderitems = $self->models->get;
+
+  $self->report_generator_list_objects(report => $self->{report}, objects => $orderitems);
+}
+
+sub action_list_ap {
+  my ($self) = @_;
+
+  $vc = "vendor";
   $self->make_filter_summary;
   $self->prepare_report;
 
@@ -63,8 +79,8 @@ sub prepare_report {
     delivered_qty     => {      sub => sub { $::form->format_amount(\%::myconfig, $_[0]->delivered_qty, 2) . ' ' . $_[0]->unit } },
     ordnumber         => {      sub => sub { $_[0]->order->ordnumber                                                         },
                            obj_link => sub { $self->link_to($_[0]->order)                                                    } },
-    customer          => {      sub => sub { $_[0]->order->customer->name                                                    },
-                           obj_link => sub { $self->link_to($_[0]->order->customer)                                          } },
+    $vc               => {      sub => sub { $_[0]->order->$vc->name                                                    },
+                           obj_link => sub { $self->link_to($_[0]->order->$vc)                                          } },
   );
 
   # add value of goods in report
@@ -77,7 +93,8 @@ sub prepare_report {
     std_column_visibility => 1,
     controller_class      => 'DeliveryPlan',
     output_format         => 'HTML',
-    top_info_text         => $::locale->text('Delivery Plan for currently outstanding sales orders'),
+    top_info_text         => ($vc eq 'customer') ? $::locale->text('Delivery Plan for currently outstanding sales orders') :
+                                                   $::locale->text('Delivery Plan for currently outstanding purchase orders'),
     title                 => $::locale->text('Delivery Plan'),
     allow_pdf_export      => 1,
     allow_csv_export      => 1,
@@ -90,7 +107,7 @@ sub prepare_report {
   $self->models->finalize; # for filter laundering
   $self->models->set_report_generator_sort_options(report => $report, sortable_columns => \@sortable);
   $report->set_options(
-    raw_top_info_text     => $self->render('delivery_plan/report_top',    { output => 0 }),
+    raw_top_info_text     => $self->render('delivery_plan/report_top',    { output => 0 }, vc => $vc),
     raw_bottom_info_text  => $self->render('delivery_plan/report_bottom', { output => 0 }, models => $self->models),
   );
 }
@@ -108,8 +125,8 @@ sub make_filter_summary {
     [ $filter->{"reqdate:date::ge"},                              $::locale->text('Delivery Date') . " " . $::locale->text('From Date') ],
     [ $filter->{"reqdate:date::le"},                              $::locale->text('Delivery Date') . " " . $::locale->text('To Date')   ],
     [ $filter->{"qty:number"},                                    $::locale->text('Quantity')                                           ],
-    [ $filter->{order}{customer}{"name:substr::ilike"},           $::locale->text('Customer')                                           ],
-    [ $filter->{order}{customer}{"customernumber:substr::ilike"}, $::locale->text('Customer Number')                                    ],
+    [ $filter->{order}{$vc}{"name:substr::ilike"},                ($vc eq 'customer') ? $::locale->text('Customer') : $::locale->text('Vendor')   ],
+    [ $filter->{order}{$vc}{"${vc}number:substr::ilike"},         ($vc eq 'customer') ? $::locale->text('Customer Number') : $::locale->text('Vendor Number') ],
   );
 
   my %flags = (
@@ -131,12 +148,12 @@ sub make_filter_summary {
 
 sub delivery_plan_query {
   my $employee_id = SL::DB::Manager::Employee->current->id;
-  my $oe_owner = $_[0]->all_edit_right ? '' : " oe.eployee_id = $employee_id AND";
+  my $oe_owner = $_[0]->all_edit_right ? '' : " oe.employee_id = $employee_id AND";
   # check delivered state for delivery_orders (transferred out) if enabled
   my $filter_delivered = $::instance_conf->get_delivery_plan_calculate_transferred_do  ?
       "AND (SELECT delivered from delivery_orders where id = doi.delivery_order_id)" : '';
   [
-  'order.customer_id' => { gt => 0 },
+  "order.${vc}_id" => { gt => 0 },
   'order.closed' => 0,
   or => [ 'order.quotation' => 0, 'order.quotation' => undef ],
 
@@ -152,7 +169,7 @@ sub delivery_plan_query {
         FROM orderitems oi, oe, record_links rl, delivery_order_items doi
         WHERE
           oe.id = oi.trans_id AND
-          oe.customer_id IS NOT NULL AND
+          oe.${vc}_id IS NOT NULL AND
           (oe.quotation = 'f' OR oe.quotation IS NULL) AND
           NOT oe.closed AND
           $oe_owner
@@ -176,7 +193,7 @@ sub delivery_plan_query {
     SELECT oi.id FROM orderitems oi, oe
     WHERE
       oe.id = oi.trans_id AND
-      oe.customer_id IS NOT NULL AND
+      oe.${vc}_id IS NOT NULL AND
       (oe.quotation = 'f' OR oe.quotation IS NULL) AND
       NOT oe.closed AND
       $oe_owner
@@ -211,7 +228,7 @@ sub delivery_plan_query {
           rl.from_table = 'oe' AND
           rl.to_table = 'delivery_orders' AND
 
-          oe.customer_id IS NOT NULL AND
+          oe.${vc}_id IS NOT NULL AND
           $oe_owner
           (oe.quotation = 'f' OR oe.quotation IS NULL) AND NOT oe.closed
       ) rl
@@ -228,7 +245,7 @@ sub delivery_plan_query {
         WHERE oi.trans_id = rl.from_id AND rl.from_table = 'oe' AND rl.to_table = 'delivery_orders'
       ) AND
       coalesce(sum, 0) < oi.qty AND
-      oe.customer_id IS NOT NULL AND
+      oe.${vc}_id IS NOT NULL AND
       $oe_owner
       (oe.quotation = 'f' OR oe.quotation IS NULL) AND NOT oe.closed
   " ],
@@ -249,7 +266,7 @@ sub init_models {
       %sort_columns,
     },
     query        => $self->delivery_plan_query,
-    with_objects => [ 'order', 'order.customer', 'part' ],
+    with_objects => [ 'order', "order.$vc", 'part' ],
   );
 }
 
index ec5b713..1b35200 100755 (executable)
@@ -789,7 +789,8 @@ $self->{texts} = {
   'Delivery Orders'             => 'Lieferscheine',
   'Delivery Plan'               => 'Lieferplan',
   'Delivery Plan check for transferred delivery orders' => 'Lieferplan berücksichtig den Status des Lieferscheins (ausgelagert / nicht ausgelagert)',
-  'Delivery Plan for currently outstanding sales orders' => 'Lieferplan für offene Verkaufsaufträge',
+  'Delivery Plan for currently outstanding purchase orders' => 'Lieferplan für nicht vollständig gelieferte Einkaufs-Aufträge',
+  'Delivery Plan for currently outstanding sales orders' => 'Lieferplan für nicht vollständig gelieferte Verkaufsaufträge',
   'Delivery Terms'              => 'Lieferbedingungen',
   'Delivery terms'              => 'Lieferbedingungen',
   'Delivery terms (database ID)' => 'Lieferbedingungen (Datenbank-ID)',
@@ -3125,6 +3126,7 @@ $self->{texts} = {
   'to (time)'                   => 'bis',
   'transfer'                    => 'Umlagerung',
   'transferred in'              => 'eingelagert',
+  'transferred in / out'        => 'ein- / ausgelagert',
   'transferred out'             => 'ausgelagert',
   'trial_balance'               => 'susa',
   'unconfigured'                => 'unkonfiguriert',
index 73de88e..a324a31 100644 (file)
@@ -256,6 +256,10 @@ module=ap.pl
 action=search
 nextsub=ap_transactions
 
+[AP--Reports--Delivery Plan]
+ACCESS=delivery_plan
+module=controller.pl
+action=DeliveryPlan/list_ap
 
 [Warehouse]
 
index d537630..46fe2d2 100644 (file)
    <th align="right">[% 'Quantity' | $T8 %]</th>
    <td>[% L.input_tag('filter.qty:number', filter.qty_number, size = 20) %]</td>
   </tr>
-  <tr>
-   <th align="right">[% 'Customer' | $T8 %]</th>
-   <td>[% L.input_tag('filter.order.customer.name:substr::ilike', filter.order.customer.name_substr__ilike, size = 20) %]</td>
-  </tr>
-  <tr>
-   <th align="right">[% 'Customer Number' | $T8 %]</th>
-   <td>[% L.input_tag('filter.order.customer.customernumber:substr::ilike', filter.order.customer.customernumber_substr__ilike, size = 20) %]</td>
-  </tr>
+[% IF vc == 'customer' %]
+    <tr>
+     <th align="right">[% vc | $T8 %]</th>
+     <td>[% L.input_tag('filter.order.customer.name:substr::ilike', filter.order.customer.name_substr__ilike, size = 20) %]</td>
+   </tr>
+   <tr>
+    <th align="right">[% 'Customer Number' | $T8 %]</th>
+    <td>[% L.input_tag('filter.order.customer.customernumber:substr::ilike', filter.order.customer.customernumber_substr__ilike, size = 20) %]</td>
+   </tr>
+[% ELSE %]  <tr>
+    <th align="right">[% vc | $T8 %]</th>
+    <td>[% L.input_tag('filter.order.vendor.name:substr::ilike', filter.order.vendor.name_substr__ilike, size = 20) %]</td>
+   </tr>
+   <tr>
+    <th align="right">[% 'Vendor Number' | $T8 %]</th>
+    <td>[% L.input_tag('filter.order.vendor.vendornumber:substr::ilike', filter.order.vendor.vendornumber_substr__ilike, size = 20) %]</td>
+   </tr>
+[% END %]
   <tr>
    <th align="right">[% 'Type' | $T8 %]</th>
    <td>
 [% L.hidden_tag('sort_by', FORM.sort_by) %]
 [% L.hidden_tag('sort_dir', FORM.sort_dir) %]
 [% L.hidden_tag('page', FORM.page) %]
-[% L.input_tag('action_list', LxERP.t8('Continue'), type = 'submit', class='submit')%]
+[% IF vc == 'customer' %]
+  [% L.input_tag('action_list', LxERP.t8('Continue'), type = 'submit', class='submit')%]
+[% ELSE %]
+  [% L.input_tag('action_list_ap', LxERP.t8('Continue'), type = 'submit', class='submit')%]
+[% END %]
 
 
 <a href='#' onClick='javascript:$("#filter_table input").val("");$("#filter_table input[type=checkbox]").prop("checked", 0);'>[% 'Reset' | $T8 %]</a>