Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ef220490

Von Moritz Bunkus vor mehr als 15 Jahren hinzugefügt

  • ID ef220490853ca3b41b4b67568af4bf6b6dc5cc30
  • Vorgänger 5c8d3d82
  • Nachfolger 0af7a3a5

Ausweitung der benutzerdefinierten Variablen für Waren/Dienstleistungen/Erzeugnisse auf Anzeige/Modifikation in Angeboten/Aufträgen.

Unterschiede anzeigen:

SL/OE.pm
37 37
use List::Util qw(max first);
38 38
use SL::AM;
39 39
use SL::Common;
40
use SL::CVar;
40 41
use SL::DBUtils;
41 42
use SL::IC;
42 43

  
......
248 249
  my $all_units = AM->retrieve_units($myconfig, $form);
249 250
  $form->{all_units} = $all_units;
250 251

  
252
  my $ic_cvar_configs = CVar->get_configs(module => 'IC',
253
                                          dbh    => $dbh);
254

  
251 255
  $form->{employee_id} = (split /--/, $form->{employee})[1] if !$form->{employee_id};
252 256
  unless ($form->{employee_id}) {
253 257
    $form->get_employee($dbh);
......
256 260
  my $ml = ($form->{type} eq 'sales_order') ? 1 : -1;
257 261

  
258 262
  if ($form->{id}) {
263
    $query = qq|DELETE FROM custom_variables
264
                WHERE (config_id IN (SELECT id FROM custom_variable_configs WHERE module = 'IC'))
265
                  AND (sub_module = 'orderitems')
266
                  AND (trans_id IN (SELECT id FROM orderitems WHERE trans_id = ?))|;
267
    do_query($form, $dbh, $query, $form->{id});
259 268

  
260 269
    $query = qq|DELETE FROM orderitems WHERE trans_id = ?|;
261 270
    do_query($form, $dbh, $query, $form->{id});
......
379 388
      $pricegroup_id *= 1;
380 389

  
381 390
      # save detail record in orderitems table
391
      my $orderitems_id = $form->{"orderitems_id_$i"};
392
      ($orderitems_id)  = selectfirst_array_query($form, $dbh, qq|SELECT nextval('orderitemsid')|) if (!$orderitems_id);
393

  
382 394
      @values = ();
383
      $query = qq|INSERT INTO orderitems (|;
384
      if ($form->{"orderitems_id_$i"}) {
385
        $query .= "id, ";
386
      }
387
      $query .= qq|trans_id, parts_id, description, longdescription, qty, base_qty, | .
388
                qq|sellprice, discount, unit, reqdate, project_id, serialnumber, ship, | .
389
                qq|pricegroup_id, ordnumber, transdate, cusordnumber, subtotal, | .
390
                qq|marge_percent, marge_total, lastcost, price_factor_id, price_factor, marge_price_factor) | .
391
                qq|VALUES (|;
392
      if($form->{"orderitems_id_$i"}) {
393
        $query .= qq|?,|;
394
        push(@values, $form->{"orderitems_id_$i"});
395
      }
396
      $query .= qq|?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
397
                   (SELECT factor FROM price_factors WHERE id = ?), ?)|;
395
      $query = qq|INSERT INTO orderitems (
396
                    id, trans_id, parts_id, description, longdescription, qty, base_qty,
397
                    sellprice, discount, unit, reqdate, project_id, serialnumber, ship,
398
                    pricegroup_id, ordnumber, transdate, cusordnumber, subtotal,
399
                    marge_percent, marge_total, lastcost, price_factor_id, price_factor, marge_price_factor)
400
                  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
401
                          (SELECT factor FROM price_factors WHERE id = ?), ?)|;
398 402
      push(@values,
399
           conv_i($form->{id}), conv_i($form->{"id_$i"}),
403
           conv_i($orderitems_id), conv_i($form->{id}), conv_i($form->{"id_$i"}),
400 404
           $form->{"description_$i"}, $form->{"longdescription_$i"},
401 405
           $form->{"qty_$i"}, $baseqty,
402 406
           $fxsellprice, $form->{"discount_$i"},
......
412 416

  
413 417
      $form->{"sellprice_$i"} = $fxsellprice;
414 418
      $form->{"discount_$i"} *= 100;
419

  
420
      CVar->save_custom_variables(module       => 'IC',
421
                                  sub_module   => 'orderitems',
422
                                  trans_id     => $orderitems_id,
423
                                  configs      => $ic_cvar_configs,
424
                                  variables    => $form,
425
                                  name_prefix  => 'ic_',
426
                                  name_postfix => "_$i",
427
                                  dbh          => $dbh);
415 428
    }
416 429
  }
417 430

  
......
637 650

  
638 651
  my ($query, $query_add, @values, @ids, $sth);
639 652

  
653
  my $ic_cvar_configs = CVar->get_configs(module => 'IC',
654
                                          dbh    => $dbh);
655

  
640 656
  # translate the ids (given by id_# and trans_id_#) into one array of ids, so we can join them later
641 657
  map {
642 658
    push @ids, $form->{"trans_id_$_"}
......
798 814
    $sth = prepare_execute_query($form, $dbh, $query, @values);
799 815

  
800 816
    while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
817
      # Retrieve custom variables.
818
      my $cvars = CVar->get_custom_variables(dbh        => $dbh,
819
                                             module     => 'IC',
820
                                             sub_module => 'orderitems',
821
                                             trans_id   => $ref->{orderitems_id},
822
                                            );
823
      # $main::lxdebug->dump(0, "cv", $cvars);
824
      map { $ref->{"ic_cvar_$_->{name}"} = $_->{value} } @{ $cvars };
825

  
826
      # Handle accounts.
801 827
      if (!$ref->{"part_inventory_accno_id"}) {
802 828
        map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid));
803 829
      }
......
874 900
      }
875 901

  
876 902
      chop $ref->{taxaccounts};
903

  
877 904
      push @{ $form->{form_details} }, $ref;
878 905
      $stw->finish;
879 906
    }
......
971 998

  
972 999
  IC->prepare_parts_for_printing();
973 1000

  
1001
  my $ic_cvar_configs = CVar->get_configs(module => 'IC');
1002

  
974 1003
  my @arrays =
975 1004
    qw(runningnumber number description longdescription qty ship unit bin
976 1005
       partnotes serialnumber reqdate sellprice listprice netprice
......
978 1007
       linetotal  nodiscount_linetotal tax_rate projectnumber
979 1008
       price_factor price_factor_name partsgroup);
980 1009

  
1010
  push @arrays, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
1011

  
981 1012
  my @tax_arrays = qw(taxbase tax taxdescription taxrate taxnumber);
982 1013

  
983 1014
  $form->{TEMPLATE_ARRAYS} = { map { $_ => [] } (@arrays, @tax_arrays) };
......
1142 1173
        $sth->finish;
1143 1174
      }
1144 1175

  
1176
      map { push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, $form->{"ic_cvar_$_->{name}_$i"} } @{ $ic_cvar_configs };
1145 1177
    }
1146 1178
  }
1147 1179

  

Auch abrufbar als: Unified diff