Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 594f0e99

Von Sven Schöling vor mehr als 15 Jahren hinzugefügt

  • ID 594f0e999af123b4aea75f70b19a03585838a748
  • Vorgänger c19f41e1
  • Nachfolger 3b3ef5ba

all_parts -> Konstante in den Header velagert.

Ausserdem weitere korrekturen gemacht um den Code korrekter zu machen.

Unterschiede anzeigen:

SL/IC.pm
92 92
    $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
93 93

  
94 94
    $form->{assembly_rows} = 0;
95
    while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
95
    while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
96 96
      $form->{assembly_rows}++;
97 97
      foreach my $key (keys %{$ref}) {
98 98
        $form->{"${key}_$form->{assembly_rows}"} = $ref->{$key};
......
191 191
              FROM translation
192 192
              WHERE parts_id = ?|;
193 193
  my $trq = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
194
  while (my $tr = $trq->fetchrow_hashref(NAME_lc)) {
194
  while (my $tr = $trq->fetchrow_hashref("NAME_lc")) {
195 195
    $form->{language_values} .= "---+++---" . join('--++--', @{$tr}{qw(language_id translation longdescription)});
196 196
  }
197 197
  $trq->finish;
......
540 540
  }
541 541

  
542 542
  #set expense_accno=inventory_accno if they are different => bilanz
543
  $vendor_accno =
543
  my $vendor_accno =
544 544
    ($form->{expense_accno} != $form->{inventory_accno})
545 545
    ? $form->{inventory_accno}
546 546
    : $form->{expense_accno};
547 547

  
548 548
  # get tax rates and description
549
  $accno_id =
549
  my $accno_id =
550 550
    ($form->{vc} eq "customer") ? $form->{income_accno} : $vendor_accno;
551 551
  $query =
552 552
    qq|SELECT c.accno, c.description, t.rate, t.taxnumber
......
556 556
  my $stw = prepare_execute_query($form, $dbh, $query, $accno_id);
557 557

  
558 558
  $form->{taxaccount} = "";
559
  while (my $ptr = $stw->fetchrow_hashref(NAME_lc)) {
559
  while (my $ptr = $stw->fetchrow_hashref("NAME_lc")) {
560 560
    $form->{taxaccount} .= "$ptr->{accno} ";
561 561
    if (!($form->{taxaccount2} =~ /\Q$ptr->{accno}\E/)) {
562 562
      $form->{"$ptr->{accno}_rate"}        = $ptr->{rate};
......
596 596
  $query =
597 597
    qq|UPDATE parts SET sellprice = sellprice + ?, weight = weight + ?
598 598
       WHERE id = ?|;
599
  @values = ($qty * ($form->{sellprice} - $sellprice),
599
  my @values = ($qty * ($form->{sellprice} - $sellprice),
600 600
             $qty * ($form->{weight} - $weight), conv_i($id));
601 601
  do_query($form, $dbh, $query, @values);
602 602

  
......
688 688
    push(@values, conv_i($form->{id}));
689 689
  }
690 690

  
691
  if ($partnumber) {
691
  if ($form->{partnumber}) {
692 692
    $where .= qq| ORDER BY p.partnumber|;
693 693
  } else {
694 694
    $where .= qq| ORDER BY p.description|;
......
803 803
         ) AS cv ON cv.id = apoe.customer_id OR cv.id = apoe.vendor_id|,
804 804
  );
805 805
  my @join_order = qw(partsgroup makemodel invoice_oi apoe cv pfac);
806

  
807
  my %table_prefix = (
808
     deliverydate => 'apoe.', serialnumber => 'ioi.',
809
     transdate    => 'apoe.', trans_id     => 'ioi.',
810
     module       => 'apoe.', name         => 'cv.',
811
     ordnumber    => 'apoe.', make         => 'mm.',
812
     quonumber    => 'apoe.', model        => 'mm.',
813
     invnumber    => 'apoe.', partsgroup   => 'pg.',
814
     lastcost     => ' ',
815
     factor       => 'pfac.',
816
     'SUM(ioi.qty)' => ' ',
817
  );
818

  
819
  my %renamed_columns = (
820
    'factor'       => 'price_factor',
821
    'SUM(ioi.qty)' => 'soldtotal',
822
  );
823

  
806 824
  my %joins_needed;
807
  my %table_prefix;
808
  my %renamed_columns;
809 825

  
810 826
  if (($form->{searchitems} eq 'assembly') && $form->{l_lastcost}) {
811 827
    @simple_l_switches = grep { $_ ne 'lastcost' } @simple_l_switches;
......
943 959

  
944 960
  #============= build query ================#
945 961

  
946
  %table_prefix = (
947
     %table_prefix,
948
     deliverydate => 'apoe.', serialnumber => 'ioi.',
949
     transdate    => 'apoe.', trans_id     => 'ioi.',
950
     module       => 'apoe.', name         => 'cv.',
951
     ordnumber    => 'apoe.', make         => 'mm.',
952
     quonumber    => 'apoe.', model        => 'mm.',
953
     invnumber    => 'apoe.', partsgroup   => 'pg.',
954
     lastcost     => ' ',
955
     factor       => 'pfac.',
956
     'SUM(ioi.qty)' => ' ',
957
  );
958

  
959 962
  $table_prefix{$q_assembly_lastcost} = ' ';
960 963

  
961
  %renamed_columns = (
962
    %renamed_columns,
963
    'factor'       => 'price_factor',
964
    'SUM(ioi.qty)' => 'soldtotal',
965
  );
966

  
967 964
  map { $table_prefix{$_} = 'ioi.' } qw(description serialnumber qty unit) if $joins_needed{invoice_oi};
968 965
  map { $renamed_columns{$_} = ' AS ' . $renamed_columns{$_} } keys %renamed_columns;
969 966

  
......
1008 1005
      push(@assemblies, $item);
1009 1006
      do_statement($form, $sth, $query, conv_i($item->{id}));
1010 1007

  
1011
      while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
1008
      while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
1012 1009
        $ref->{assemblyitem} = 1;
1013 1010
        map { $ref->{$_} /= $ref->{factor} || 1 } qw(sellprice listprice lastcost);
1014 1011
        push(@assemblies, $ref);
......
1248 1245
  }
1249 1246

  
1250 1247
  my $sth = prepare_execute_query($form, $dbh, $query, @values);
1251
  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
1248
  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
1252 1249
    foreach my $key (split(/:/, $ref->{link})) {
1253 1250
      if ($key =~ /\Q$module\E/) {
1254 1251
        if (   ($ref->{id} eq $ref->{inventory_accno_id})
......
1317 1314
  my $sth = prepare_execute_query($form, $dbh, $query, @values);
1318 1315

  
1319 1316
  my $j = 0;
1320
  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
1317
  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
1321 1318
    if (($ref->{partnumber} eq "*") && ($ref->{description} eq "")) {
1322 1319
      next;
1323 1320
    }
......
1346 1343
  my ($dbh, $id) = @_;
1347 1344

  
1348 1345
  my $query = qq|SELECT sum(qty) FROM invoice WHERE parts_id = ?|;
1349
  my ($sum) = selectrow_query($form, $dbh, $query, conv_i($id));
1346
  my ($sum) = selectrow_query($main::form, $dbh, $query, conv_i($id));
1350 1347
  $sum ||= 0;
1351 1348

  
1352 1349
  $main::lxdebug->leave_sub();

Auch abrufbar als: Unified diff