Lines 1944-1962
sub GetTitles {
Link Here
|
1944 |
|
1944 |
|
1945 |
=head2 GetPatronImage |
1945 |
=head2 GetPatronImage |
1946 |
|
1946 |
|
1947 |
my ($imagedata, $dberror) = GetPatronImage($cardnumber); |
1947 |
my ($imagedata, $dberror) = GetPatronImage($borrowernumber); |
1948 |
|
1948 |
|
1949 |
Returns the mimetype and binary image data of the image for the patron with the supplied cardnumber. |
1949 |
Returns the mimetype and binary image data of the image for the patron with the supplied borrowernumber. |
1950 |
|
1950 |
|
1951 |
=cut |
1951 |
=cut |
1952 |
|
1952 |
|
1953 |
sub GetPatronImage { |
1953 |
sub GetPatronImage { |
1954 |
my ($cardnumber) = @_; |
1954 |
my ($borrowernumber) = @_; |
1955 |
warn "Cardnumber passed to GetPatronImage is $cardnumber" if $debug; |
1955 |
warn "Borrowernumber passed to GetPatronImage is $borrowernumber" if $debug; |
1956 |
my $dbh = C4::Context->dbh; |
1956 |
my $dbh = C4::Context->dbh; |
1957 |
my $query = 'SELECT mimetype, imagefile FROM patronimage WHERE cardnumber = ?'; |
1957 |
my $query = 'SELECT mimetype, imagefile FROM patronimage WHERE borrowernumber = ?'; |
1958 |
my $sth = $dbh->prepare($query); |
1958 |
my $sth = $dbh->prepare($query); |
1959 |
$sth->execute($cardnumber); |
1959 |
$sth->execute($borrowernumber); |
1960 |
my $imagedata = $sth->fetchrow_hashref; |
1960 |
my $imagedata = $sth->fetchrow_hashref; |
1961 |
warn "Database error!" if $sth->errstr; |
1961 |
warn "Database error!" if $sth->errstr; |
1962 |
return $imagedata, $sth->errstr; |
1962 |
return $imagedata, $sth->errstr; |
Lines 1975-1981
sub PutPatronImage {
Link Here
|
1975 |
my ($cardnumber, $mimetype, $imgfile) = @_; |
1975 |
my ($cardnumber, $mimetype, $imgfile) = @_; |
1976 |
warn "Parameters passed in: Cardnumber=$cardnumber, Mimetype=$mimetype, " . ($imgfile ? "Imagefile" : "No Imagefile") if $debug; |
1976 |
warn "Parameters passed in: Cardnumber=$cardnumber, Mimetype=$mimetype, " . ($imgfile ? "Imagefile" : "No Imagefile") if $debug; |
1977 |
my $dbh = C4::Context->dbh; |
1977 |
my $dbh = C4::Context->dbh; |
1978 |
my $query = "INSERT INTO patronimage (cardnumber, mimetype, imagefile) VALUES (?,?,?) ON DUPLICATE KEY UPDATE imagefile = ?;"; |
1978 |
my $query = "INSERT INTO patronimage (borrowernumber, mimetype, imagefile) VALUES ( ( SELECT borrowernumber from borrowers WHERE cardnumber = ? ),?,?) ON DUPLICATE KEY UPDATE imagefile = ?;"; |
1979 |
my $sth = $dbh->prepare($query); |
1979 |
my $sth = $dbh->prepare($query); |
1980 |
$sth->execute($cardnumber,$mimetype,$imgfile,$imgfile); |
1980 |
$sth->execute($cardnumber,$mimetype,$imgfile,$imgfile); |
1981 |
warn "Error returned inserting $cardnumber.$mimetype." if $sth->errstr; |
1981 |
warn "Error returned inserting $cardnumber.$mimetype." if $sth->errstr; |
Lines 1984-2002
sub PutPatronImage {
Link Here
|
1984 |
|
1984 |
|
1985 |
=head2 RmPatronImage |
1985 |
=head2 RmPatronImage |
1986 |
|
1986 |
|
1987 |
my ($dberror) = RmPatronImage($cardnumber); |
1987 |
my ($dberror) = RmPatronImage($borrowernumber); |
1988 |
|
1988 |
|
1989 |
Removes the image for the patron with the supplied cardnumber. |
1989 |
Removes the image for the patron with the supplied borrowernumber. |
1990 |
|
1990 |
|
1991 |
=cut |
1991 |
=cut |
1992 |
|
1992 |
|
1993 |
sub RmPatronImage { |
1993 |
sub RmPatronImage { |
1994 |
my ($cardnumber) = @_; |
1994 |
my ($borrowernumber) = @_; |
1995 |
warn "Cardnumber passed to GetPatronImage is $cardnumber" if $debug; |
1995 |
warn "Borrowernumber passed to GetPatronImage is $borrowernumber" if $debug; |
1996 |
my $dbh = C4::Context->dbh; |
1996 |
my $dbh = C4::Context->dbh; |
1997 |
my $query = "DELETE FROM patronimage WHERE cardnumber = ?;"; |
1997 |
my $query = "DELETE FROM patronimage WHERE borrowernumber = ?;"; |
1998 |
my $sth = $dbh->prepare($query); |
1998 |
my $sth = $dbh->prepare($query); |
1999 |
$sth->execute($cardnumber); |
1999 |
$sth->execute($borrowernumber); |
2000 |
my $dberror = $sth->errstr; |
2000 |
my $dberror = $sth->errstr; |
2001 |
warn "Database error!" if $sth->errstr; |
2001 |
warn "Database error!" if $sth->errstr; |
2002 |
return $dberror; |
2002 |
return $dberror; |