Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b7b5192a

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID b7b5192aac08c3d4fae53ae9d29cb7f2b1d9f45a
  • Vorgänger 247a26dc
  • Nachfolger af59820c

Bei Wandlung von Angeboten/Preisanfragen in Aufträge erst beim Speichern der Aufträge das Angebot/die Preisanfrage schließen.

Unterschiede anzeigen:

SL/OE.pm
467 467
  $form->save_status($dbh);
468 468

  
469 469
  # Link this record to the records it was created from.
470
  RecordLinks->create_links('dbh'        => $dbh,
471
                            'mode'       => 'ids',
472
                            'from_table' => 'oe',
473
                            'from_ids'   => $form->{convert_from_oe_ids},
474
                            'to_table'   => 'oe',
475
                            'to_id'      => $form->{id},
476
    );
470
  $form->{convert_from_oe_ids} =~ s/^\s+//;
471
  $form->{convert_from_oe_ids} =~ s/\s+$//;
472
  my @convert_from_oe_ids      =  split m/\s+/, $form->{convert_from_oe_ids};
477 473
  delete $form->{convert_from_oe_ids};
478 474

  
475
  if (scalar @convert_from_oe_ids) {
476
    RecordLinks->create_links('dbh'        => $dbh,
477
                              'mode'       => 'ids',
478
                              'from_table' => 'oe',
479
                              'from_ids'   => \@convert_from_oe_ids,
480
                              'to_table'   => 'oe',
481
                              'to_id'      => $form->{id},
482
      );
483

  
484
    $self->_close_quotations_rfqs('dbh'     => $dbh,
485
                                  'from_id' => \@convert_from_oe_ids,
486
                                  'to_id'   => $form->{id});
487
  }
488

  
479 489
  if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) {
480 490
    if ($form->{vc} eq 'customer') {
481 491
      $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, $form->{exchangerate}, 0);
......
498 508
  return $rc;
499 509
}
500 510

  
501
# this function closes multiple orders given in $form->{ordnumber_#}.
502
# use this for multiple orders that don't have to be saved back
503
# single orders should use OE::save instead.
504
sub close_orders {
511
sub _close_quotations_rfqs {
505 512
  $main::lxdebug->enter_sub();
506 513

  
507
  my ($self, $myconfig, $form) = @_;
514
  my $self     = shift;
515
  my %params   = @_;
508 516

  
509
  # get ids from $form
510
  map { push @ids, $form->{"ordnumber_$_"} if $form->{"ordnumber_$_"} }
511
    (1 .. $form->{rowcount});
517
  Common::check_params(\%params, qw(from_id to_id));
512 518

  
513
  my $dbh = $form->dbconnect($myconfig);
514
  $query = qq|UPDATE oe SET | .
515
           qq|closed = TRUE | .
516
           qq|WHERE ordnumber IN (|
517
    . join(', ', map { $dbh->quote($_) } @ids) . qq|)|;
518
  $dbh->do($query) || $form->dberror($query);
519
  $dbh->disconnect;
519
  my $myconfig = \%main::myconfig;
520
  my $form     = $main::form;
520 521

  
521
  $main::lxdebug->leave_sub();
522
}
522
  my $dbh      = $params{dbh} || $form->get_standard_dbh($myconfig);
523 523

  
524
sub close_order {
525
  $main::lxdebug->enter_sub();
524
  my $query    = qq|SELECT quotation FROM oe WHERE id = ?|;
525
  my $sth      = prepare_query($form, $dbh, $query);
526 526

  
527
  my ($self, $myconfig, $form) = @_;
527
  do_statement($form, $sth, $query, conv_i($params{to_id}));
528 528

  
529
  return $main::lxdebug->leave_sub() unless ($form->{"id"});
529
  my ($quotation) = $sth->fetchrow_array();
530 530

  
531
  my $dbh = $form->dbconnect($myconfig);
532
  do_query($form, $dbh, qq|UPDATE oe SET closed = TRUE where id = ?|,
533
           $form->{"id"});
534
  $dbh->disconnect;
531
  if ($quotation) {
532
    $main::lxdebug->leave_sub();
533
    return;
534
  }
535

  
536
  my @close_ids;
537

  
538
  foreach my $from_id (@{ $params{from_id} }) {
539
    $from_id = conv_i($from_id);
540
    do_statement($form, $sth, $query, $from_id);
541
    ($quotation) = $sth->fetchrow_array();
542
    push @close_ids, $from_id if ($quotation);
543
  }
544

  
545
  $sth->finish();
546

  
547
  if (scalar @close_ids) {
548
    $query = qq|UPDATE oe SET closed = TRUE WHERE id IN (| . join(', ', ('?') x scalar @close_ids) . qq|)|;
549
    do_query($form, $dbh, $query, @close_ids);
550

  
551
    $dbh->commit() unless ($params{dbh});
552
  }
535 553

  
536 554
  $main::lxdebug->leave_sub();
537 555
}

Auch abrufbar als: Unified diff