Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 556a2137

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 556a2137c91ce7bb21efb99c6ec705360a12d521
  • Vorgänger e2305bab
  • Nachfolger 454df69e

Unterstützung für Lieferscheine in Form::lastname_used.

Unterschiede anzeigen:

SL/Form.pm
2762 2762

  
2763 2763
  my ($self, $dbh, $myconfig, $table, $module) = @_;
2764 2764

  
2765
  my $arap  = ($table eq 'customer') ? "ar" : "ap";
2766
  $table = $table eq "customer" ? "customer" : "vendor";
2767
  my $where = "1 = 1";
2765
  my ($arap, $where);
2766

  
2767
  $table         = $table eq "customer" ? "customer" : "vendor";
2768
  my %column_map = ("a.curr"                  => "currency",
2769
                    "a.${table}_id"           => "${table}_id",
2770
                    "a.department_id"         => "department_id",
2771
                    "d.description"           => "department",
2772
                    "ct.name"                 => $table,
2773
                    "current_date + ct.terms" => "duedate",
2774
    );
2775

  
2776
  if ($self->{type} =~ /delivery_order/) {
2777
    $arap  = 'delivery_orders';
2778
    delete $column_map{"a.curr"};
2768 2779

  
2769
  if ($self->{type} =~ /_order/) {
2780
  } elsif ($self->{type} =~ /_order/) {
2770 2781
    $arap  = 'oe';
2771 2782
    $where = "quotation = '0'";
2772
  }
2773
  if ($self->{type} =~ /_quotation/) {
2783

  
2784
  } elsif ($self->{type} =~ /_quotation/) {
2774 2785
    $arap  = 'oe';
2775 2786
    $where = "quotation = '1'";
2787

  
2788
  } elsif ($table eq 'customer') {
2789
    $arap  = 'ar';
2790

  
2791
  } else {
2792
    $arap  = 'ap';
2793

  
2776 2794
  }
2777 2795

  
2778
  my $query = qq|SELECT MAX(id) FROM $arap
2779
                 WHERE $where AND ${table}_id > 0|;
2780
  my ($trans_id) = selectrow_query($self, $dbh, $query);
2796
  $where           = "($where) AND" if ($where);
2797
  my $query        = qq|SELECT MAX(id) FROM $arap
2798
                        WHERE $where ${table}_id > 0|;
2799
  my ($trans_id)   = selectrow_query($self, $dbh, $query);
2800
  $trans_id       *= 1;
2781 2801

  
2782
  $trans_id *= 1;
2783
  $query =
2784
    qq|SELECT
2785
         a.curr, a.${table}_id, a.department_id,
2786
         d.description AS department,
2787
         ct.name, current_date + ct.terms AS duedate
2788
       FROM $arap a
2789
       LEFT JOIN $table ct ON (a.${table}_id = ct.id)
2790
       LEFT JOIN department d ON (a.department_id = d.id)
2791
       WHERE a.id = ?|;
2792
  ($self->{currency},   $self->{"${table}_id"}, $self->{department_id},
2793
   $self->{department}, $self->{$table},        $self->{duedate})
2794
    = selectrow_query($self, $dbh, $query, $trans_id);
2802
  my $column_spec  = join(', ', map { "${_} AS $column_map{$_}" } keys %column_map);
2803
  $query           = qq|SELECT $column_spec
2804
                        FROM $arap a
2805
                        LEFT JOIN $table     ct ON (a.${table}_id = ct.id)
2806
                        LEFT JOIN department d  ON (a.department_id = d.id)
2807
                        WHERE a.id = ?|;
2808
  my $ref          = selectfirst_hashref_query($self, $dbh, $query, $trans_id);
2809

  
2810
  map { $self->{$_} = $ref->{$_} } values %column_map;
2795 2811

  
2796 2812
  $main::lxdebug->leave_sub();
2797 2813
}

Auch abrufbar als: Unified diff