Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3a77cbe1

Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt

  • ID 3a77cbe16e291187e5b271c83ee620eec0a0cb02
  • Vorgänger 09696cb9
  • Nachfolger b945837f

Belegberichte (Angebote/Aufträge) mit Positionsdetails

Unterschiede anzeigen:

SL/OE.pm
467 467

  
468 468
  $sth->finish;
469 469

  
470
  if ($form->{l_items} && scalar @{ $form->{OE} }) {
471
    my ($items_query, $items_sth);
472
    if ($form->{l_items}) {
473
      $items_query =
474
        qq|SELECT id
475
          FROM orderitems
476
          WHERE trans_id  = ?
477
          ORDER BY position|;
478

  
479
      $items_sth = prepare_query($form, $dbh, $items_query);
480
    }
481

  
482
    foreach my $oe (@{ $form->{OE} }) {
483
      do_statement($form, $items_sth, $items_query, $oe->{id});
484
      $oe->{item_ids} = $dbh->selectcol_arrayref($items_sth);
485
      $oe->{item_ids} = undef if !@{$oe->{item_ids}};
486
    }
487
    $items_sth->finish();
488
  }
489

  
470 490
  $main::lxdebug->leave_sub();
471 491
}
472 492

  
SL/Presenter/ItemsList.pm
1
package SL::Presenter::ItemsList;
2

  
3
use strict;
4

  
5
use File::Spec;
6
use Template;
7

  
8
use SL::Presenter;
9
use SL::Presenter::EscapedText qw(escape is_escaped);
10

  
11
use Exporter qw(import);
12
our @EXPORT_OK = qw(items_list);
13

  
14
sub items_list {
15
  my ($items, %params) = @_;
16

  
17
  my $output;
18
  if (delete $params{as_text}) {
19
    my $template = Template->new({ INTERPOLATE => 1,
20
                                   EVAL_PERL   => 0,
21
                                   ABSOLUTE    => 1,
22
                                   CACHE_SIZE  => 0,
23
                                   ENCODING    => 'utf8',
24
                                 });
25
    die "Could not create Template instance" if !$template;
26
    my $filename = File::Spec->catfile($::request->layout->webpages_path, qw(presenter items_list items_list.txt));
27
    $template->process($filename, {%params, items => $items}, \$output) || die $template->error;
28
    # Remove last newline because it can cause problems when rendering pdf.
29
    $output =~ s{\n$}{}x;
30

  
31
  } else {
32
    $output = SL::Presenter->get->render('presenter/items_list/items_list', %params, items => $items);
33
  }
34

  
35
  return $output;
36
}
bin/mozilla/oe.pl
37 37
use POSIX qw(strftime);
38 38

  
39 39
use SL::DB::Order;
40
use SL::DB::OrderItem;
40 41
use SL::DO;
41 42
use SL::FU;
42 43
use SL::OE;
......
44 45
use SL::IS;
45 46
use SL::Helper::UserPreferences::DisplayPreferences;
46 47
use SL::MoreCommon qw(ary_diff restore_form save_form);
48
use SL::Presenter::ItemsList;
47 49
use SL::ReportGenerator;
48 50
use SL::YAML;
49 51
use List::MoreUtils qw(uniq any none);
......
1056 1058
    "taxzone",                 "insertdate",
1057 1059
    "order_probability",       "expected_billing_date", "expected_netamount",
1058 1060
    "payment_terms",           "intnotes",              "order_status",
1061
    "items",
1059 1062
  );
1060 1063

  
1061 1064
  # only show checkboxes if gotten here via sales_order form.
......
1151 1154
    'payment_terms'           => { 'text' => $locale->text('Payment Terms'), },
1152 1155
    'intnotes'                => { 'text' => $locale->text('Internal Notes'), },
1153 1156
    'order_status'            => { 'text' => $locale->text('Status'), },
1157
    'items'                   => { 'text' => $locale->text('Positions'), },
1154 1158
    %column_defs_cvars,
1155 1159
  );
1156 1160

  
......
1169 1173
                             expected_netamount);
1170 1174

  
1171 1175
  $form->{"l_type"} = "Y";
1176

  
1172 1177
  map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
1173 1178
  $column_defs{ids}->{visible} = $allow_multiple_orders ? 'HTML' : 0;
1174 1179

  
......
1299 1304

  
1300 1305
    foreach my $column (@columns) {
1301 1306
      next if ($column eq 'ids');
1307
      next if ($column eq 'items');
1302 1308
      $row->{$column} = {
1303 1309
        'data'  => $oe->{$column},
1304 1310
        'align' => $column_alignment{$column},
......
1314 1320

  
1315 1321
    $row->{$ordnumber}->{link} = $edit_url . "&id=" . E($oe->{id}) . "&callback=${callback}" unless $params{want_binary_pdf};
1316 1322

  
1323
    if ($form->{l_items}) {
1324
      my $items = SL::DB::Manager::OrderItem->get_all_sorted(where => [id => $oe->{item_ids}]);
1325
      $row->{items}->{raw_data}  = SL::Presenter::ItemsList::items_list($items)               if lc($report->{options}->{output_format}) eq 'html';
1326
      $row->{items}->{data}      = SL::Presenter::ItemsList::items_list($items, as_text => 1) if lc($report->{options}->{output_format}) ne 'html';
1327
    }
1328

  
1317 1329
    my $row_set = [ $row ];
1318 1330

  
1319 1331
    if (($form->{l_subtotal} eq 'Y')
scripts/locales.pl
52 52

  
53 53
my %ignore_unused_templates = (
54 54
  map { $_ => 1 } qw(ct/testpage.html oe/periodic_invoices_email.txt part/testpage.html t/render.html t/render.js task_server/failure_notification_email.txt
55
                     failed_background_jobs_report/email.txt)
55
                     failed_background_jobs_report/email.txt presenter/items_list/items_list.txt)
56 56
);
57 57

  
58 58
my (%referenced_html_files, %locale, %htmllocale, %alllocales, %cached, %submit, %jslocale);
templates/webpages/oe/search.html
315 315
         <label for="l_order_status">[% 'Status' | $T8 %]</label>
316 316
        </td>
317 317
       </tr>
318
       <tr>
319
        <td>
320
         <input name="l_items" id="l_items" class="checkbox" type="checkbox" value="Y">
321
         <label for="l_items">[% 'Positions' | $T8 %]</label>
322
        </td>
323
       </tr>
318 324
       <tr>
319 325
        <td colspan=4 align=left><b>[% HTML.escape(vclabel) %]</b></td>
320 326
       </tr>
templates/webpages/presenter/items_list/items_list.html
1
[% USE L %][% USE LxERP %][%- USE P -%][%- USE T8 -%]
2

  
3
<font size="-2">
4
[%- IF items.size > 0 %]
5
 <table>
6
  <tr class="listheading">
7
   <th>[% 'Position'    | $T8 %]</th>
8
   <th>[% 'Partnumber'  | $T8 %]</th>
9
   <th>[% 'Description' | $T8 %]</th>
10
   <th>[% 'Qty'         | $T8 %]</th>
11
   <th>[% 'Unit'        | $T8 %]</th>
12
  </tr>
13
  [%- FOREACH item = items %]
14
  <tr class="listrow[% IF !loop.first %] item_row_toggle_[% items.0.id %][% END %]"[% IF !loop.first %] style="display:none"[% END %]>
15
   <td align="right">[% P.escape(item.position) %]</td>
16
   <td>[% P.escape(item.part.partnumber) %]</td>
17
   <td>[% P.escape(item.description) %]</td>
18
   <td align="right">[% P.escape(item.qty_as_number) %]</td>
19
   <td>[% P.escape(item.unit) %]</td>
20
  </tr>
21
  [%- END %]
22
 </table>
23
 [%- IF items.size > 1 %]
24
  <a href="javascript:void(0);" onClick="javascript:$('.item_row_toggle_[% items.0.id %]').toggle();$('.item_row_toggle_[% items.0.id %]').is(':hidden') ? $('#toggle_text_[% items.0.id %]').html('… ⏷') : $('#toggle_text_[% items.0.id %]').html('⏶');"><span id='toggle_text_[% items.0.id %]'>… ⏷</span></a>
25
 [%- END %]
26
[%- END %]
27
</font>
templates/webpages/presenter/items_list/items_list.txt
1
[% FOREACH item = items -%]
2
[% item.position %]: [% item.part.partnumber %] [% item.description %] [% item.qty_as_number %] [% item.unit %]
3
[% END -%]

Auch abrufbar als: Unified diff