Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ba6a1366

Von Niclas Zimmermann vor mehr als 11 Jahren hinzugefügt

  • ID ba6a136694f2e54e7bf21b1ecfabfcb872784ef4
  • Vorgänger d0c938cf
  • Nachfolger 26892ad4

Verbesserung Lesbarkeit von Code

Dieser Commit verbessert noch an Stellen, die Währungen betreffen,
die Lesbarkeit des Codes.

Unterschiede anzeigen:

SL/AM.pm
1103 1103

  
1104 1104
  for my $i (1..$form->{rowcount}) {
1105 1105
    if ($form->{"curr_$i"} ne $form->{"old_curr_$i"}) {
1106
      $query = qq|UPDATE currencies SET name = '| . $form->{"curr_$i"} . qq|' WHERE name = '| . $form->{"old_curr_$i"} . qq|'|;
1107
      do_query($form, $dbh, $query);
1106
      $query = qq|UPDATE currencies SET name = ? WHERE name = ?|;
1107
      do_query($form, $dbh, $query, $form->{"curr_$i"}, $form->{"old_curr_$i"});
1108 1108
    }
1109 1109
  }
1110 1110

  
1111 1111
  if (length($form->{new_curr}) > 0) {
1112
    $query = qq|INSERT INTO currencies (name) VALUES ('| . $form->{new_curr} . qq|')|;
1113
    do_query($form, $dbh, $query);
1112
    $query = qq|INSERT INTO currencies (name) VALUES (?)|;
1113
    do_query($form, $dbh, $query, $form->{new_curr});
1114 1114
  }
1115 1115

  
1116 1116
  $dbh->commit();
......
1292 1292
  $sth->finish;
1293 1293

  
1294 1294
  #Get currencies:
1295
  $query = qq|SELECT name AS curr FROM currencies ORDER BY id|;
1296

  
1297
  $form->{CURRENCIES} = [];
1298

  
1299
  $sth = prepare_execute_query($form, $dbh, $query);
1300
  $sth->execute || $form->dberror($query);
1301
  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
1302
    push @{ $form->{ CURRENCIES } } , $ref;
1303
  }
1304
  $sth->finish;
1295
  $query              = qq|SELECT name AS curr FROM currencies ORDER BY id|;
1296
  $form->{CURRENCIES} = selectall_hashref_query($form, $dbh, $query);
1305 1297

  
1306 1298
  #Which of them is the default currency?
1307 1299
  $query = qq|SELECT name AS defaultcurrency FROM currencies WHERE id = (SELECT currency_id FROM defaults LIMIT 1);|;
1308
  $sth   = $dbh->prepare($query);
1309
  $sth->execute || $form->dberror($query);
1310

  
1311
  $form->{defaultcurrency}               = ($sth->fetchrow_hashref("NAME_lc"))->{defaultcurrency};
1312

  
1313
  $sth->finish;
1300
  ($form->{defaultcurrency}) = selectrow_query($form, $dbh, $query);
1314 1301

  
1315 1302
  $dbh->disconnect;
1316 1303

  
SL/Form.pm
1631 1631
  my $dbh      = $self->get_standard_dbh($myconfig);
1632 1632
  my @currencies =();
1633 1633

  
1634
  my $query = qq|SELECT name AS curr FROM currencies|;
1635

  
1636
  my $sth = prepare_execute_query($self, $dbh, $query);
1637

  
1638
  while (my $ref = $sth->fetchrow_hashref()) {
1639
    push(@currencies, $ref->{curr});
1640
  }
1641
  $sth->finish;
1634
  my $query = qq|SELECT name FROM currencies|;
1635
  my @currencies = map { $_->{name} } selectall_hashref_query($self, $dbh, $query);
1642 1636

  
1643 1637
  $main::lxdebug->leave_sub();
1644 1638

  
SL/IR.pm
1087 1087
         v.id AS vendor_id, v.name AS vendor, v.discount as vendor_discount,
1088 1088
         v.creditlimit, v.terms, v.notes AS intnotes,
1089 1089
         v.email, v.cc, v.bcc, v.language_id, v.payment_id,
1090
         v.street, v.zipcode, v.city, v.country, v.taxzone_id, (SELECT cu.name FROM currencies cu WHERE cu.id=v.currency_id) AS curr, v.direct_debit,
1090
         v.street, v.zipcode, v.city, v.country, v.taxzone_id, cu.name AS curr, v.direct_debit,
1091 1091
         $duedate + COALESCE(pt.terms_netto, 0) AS duedate,
1092 1092
         b.description AS business
1093 1093
       FROM vendor v
1094 1094
       LEFT JOIN business b       ON (b.id = v.business_id)
1095 1095
       LEFT JOIN payment_terms pt ON (v.payment_id = pt.id)
1096
       LEFT JOIN currencies cu    ON (v.currency_id = cu.id)
1096 1097
       WHERE 1=1 $where|;
1097 1098
  my $ref = selectfirst_hashref_query($form, $dbh, $query, @values);
1098 1099
  map { $params->{$_} = $ref->{$_} } keys %$ref;
......
1384 1385
  # fax and phone and email as vendor*
1385 1386
  my $query =
1386 1387
    qq|SELECT ct.*, cp.*, ct.notes as vendornotes, phone as vendorphone, fax as vendorfax, email as vendoremail,
1387
         (SELECT cu.name FROM currencies cu WHERE cu.id=ct.currency_id) AS currency
1388
         cu.name AS currency
1388 1389
       FROM vendor ct
1389 1390
       LEFT JOIN contacts cp ON (ct.id = cp.cp_cv_id)
1391
       LEFT JOIN currencies cu ON (ct.currency_id = cu.id)
1390 1392
       WHERE (ct.id = ?) $contact
1391 1393
       ORDER BY cp.cp_id
1392 1394
       LIMIT 1|;
SL/IS.pm
458 458
  my $query =
459 459
    qq|SELECT ct.*, cp.*, ct.notes as customernotes,
460 460
         ct.phone AS customerphone, ct.fax AS customerfax, ct.email AS customeremail,
461
         (SELECT cu.name FROM currencies cu WHERE cu.id=ct.currency_id) AS currency
461
         cu.name AS currency
462 462
       FROM customer ct
463 463
       LEFT JOIN contacts cp on ct.id = cp.cp_cv_id
464
       LEFT JOIN currencies cu ON (ct.currency_id = cu.id)
464 465
       WHERE (ct.id = ?) $where
465 466
       ORDER BY cp.cp_id
466 467
       LIMIT 1|;
......
1750 1751
         c.id AS customer_id, c.name AS customer, c.discount as customer_discount, c.creditlimit, c.terms,
1751 1752
         c.email, c.cc, c.bcc, c.language_id, c.payment_id,
1752 1753
         c.street, c.zipcode, c.city, c.country,
1753
         c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, (SELECT cu.name FROM currencies cu WHERE cu.id=c.currency_id) AS curr,
1754
         c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, cu.name AS curr,
1754 1755
         c.taxincluded_checked, c.direct_debit,
1755 1756
         $duedate + COALESCE(pt.terms_netto, 0) AS duedate,
1756 1757
         b.discount AS tradediscount, b.description AS business
1757 1758
       FROM customer c
1758 1759
       LEFT JOIN business b ON (b.id = c.business_id)
1759 1760
       LEFT JOIN payment_terms pt ON ($payment_id (c.payment_id = pt.id))
1761
       LEFT JOIN currencies cu ON (c.currency_id=cu.id)
1760 1762
       WHERE c.id = ?|;
1761 1763
  push @values, $cid;
1762 1764
  $ref = selectfirst_hashref_query($form, $dbh, $query, @values);

Auch abrufbar als: Unified diff