Browse Source

Bug 13084 [Master] - QA Followup - Use DBIx::Class to simplify logic

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
MM-OPAC/theme_dep
Kyle Hall 8 years ago
committed by Tomas Cohen Arazi
parent
commit
b95617ec9e
  1. 32
      C4/Members.pm

32
C4/Members.pm

@ -1814,28 +1814,16 @@ The routine returns 1 for success, undef for failure.
sub MoveMemberToDeleted {
my ($member) = shift or return;
my $dbh = C4::Context->dbh;
my $query = qq|SELECT *
FROM borrowers
WHERE borrowernumber=?|;
my $sth = $dbh->prepare($query);
$sth->execute($member);
my $data = $sth->fetchrow_hashref;
return if !$data; # probably bad borrowernumber
#now construct a insert query that does not depend on the same order of
#columns in borrowers and deletedborrowers (see BZ 13084)
my $insertq = "INSERT INTO deletedborrowers (";
my @values;
foreach my $key ( keys %$data ) {
$insertq.= $key.",";
push @values, $data->{$key};
}
$insertq =~ s/,$//; #remove last comma
$insertq .= ") VALUES (" . ( "?," x ( scalar(@values) - 1 ) ) . "?)";
$sth = $dbh->prepare( $insertq );
$sth->execute(@values);
return $sth->err? undef: 1;
my $schema = Koha::Database->new()->schema();
my $borrowers_rs = $schema->resultset('Borrower');
$borrowers_rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
my $borrower = $borrowers_rs->find($member);
return unless $borrower;
my $deleted = $schema->resultset('Deletedborrower')->create($borrower);
return $deleted ? 1 : undef;
}
=head2 DelMember

Loading…
Cancel
Save