Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ca5de571

Von Moritz Bunkus vor etwa 18 Jahren hinzugefügt

  • ID ca5de5712845a874f8abe976d92aef945d513ca7
  • Vorgänger c8ab196a
  • Nachfolger 8c667be6

Speichern der Historie in einer eigenen Tabelle. Auch ein Fix für Bugzilla-ID 558.

Unterschiede anzeigen:

SL/Form.pm
&get_employee($self, $dbh);
}
my $query = qq|INSERT INTO status (trans_id, employee_id, addition, what_done)
VALUES ($self->{id}, $self->{employee_id}, '$self->{addition}', '$self->{what_done}')|;
$dbh->do($query) || $self->dberror($query);
my $query =
qq|INSERT INTO history_erp (trans_id, employee_id, addition, what_done) | .
qq|VALUES (?, ?, ?, ?)|;
my @values = (conv_i($self->{id}), conv_i($self->{employee_id}),
$self->{addition}, $self->{what_done});
do_query($self, $dbh, $query, @values);
$main::lxdebug->leave_sub();
}
......
my $restriction = shift();
my @tempArray;
my $i = 0;
if($trans_id ne ""){
my $query = qq|SELECT st.employee_id, st.itime, st.addition, st.what_done, emp.name
FROM status st
LEFT JOIN employee emp
ON emp.id = st.employee_id
WHERE trans_id = $trans_id|
. $restriction;
if ($trans_id ne "") {
my $query =
qq|SELECT h.employee_id, h.itime, h.addition, h.what_done, emp.name | .
qq|FROM history_erp h | .
qq|LEFT JOIN employee emp | .
qq|ON emp.id = st.employee_id | .
qq|WHERE trans_id = ? |
. $restriction;
my $sth = $dbh->prepare($query) || $self->dberror($query);
$sth->execute() || $self->dberror($query);
$sth->execute($trans_id) || $self->dberror("$query ($trans_id)");
while(my $hash_ref = $sth->fetchrow_hashref()) {
$hash_ref->{addition} = $main::locale->text($hash_ref->{addition});
$hash_ref->{what_done} = $main::locale->text($hash_ref->{what_done});
$tempArray[$i++] = $hash_ref;
}
return \@tempArray if ($i > 0 && $tempArray[0] ne "");
$main::lxdebug->leave_sub() and return \@tempArray
if ($i > 0 && $tempArray[0] ne "");
}
return 0;
$main::lxdebug->leave_sub();
return 0;
}
sub save_status {
sql/Pg-upgrade2/history_erp.sql
-- @tag: history_erp
-- @description: Entfernen der Spalten in Tabelle status zum Speichern der history und dafür eigene Tabelle für die history
-- @depends: status_history
ALTER TABLE status DROP COLUMN id;
ALTER TABLE status DROP COLUMN employee_id;
ALTER TABLE status DROP COLUMN addition;
ALTER TABLE status DROP COLUMN what_done;
CREATE TABLE history_erp (
id integer NOT NULL DEFAULT nextval('id'),
trans_id integer,
employee_id integer,
addition text,
what_done text,
PRIMARY KEY (id),
FOREIGN KEY (employee_id) REFERENCES employee (id)
);

Auch abrufbar als: Unified diff