From: Chris Nighswonger Date: Thu, 6 Mar 2008 13:05:31 +0000 (-0500) Subject: Adding Update/Delete functions to patron image management on Details page X-Git-Tag: v3.00.00-beta~178 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=55b353f79a1fc58af04fcfb348e6850257963a94;p=koha.git Adding Update/Delete functions to patron image management on Details page Signed-off-by: Joshua Ferraro --- diff --git a/C4/Members.pm b/C4/Members.pm index 6e81ea3044..f01fb4e3af 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -57,8 +57,10 @@ BEGIN { &GetRoadTypeDetails &GetSortDetails &GetTitles + &GetPatronImage &PutPatronImage + &RmPatronImage &GetMemberAccountRecords &GetBorNotifyAcctRecord @@ -1708,7 +1710,7 @@ Returns the mimetype and binary image data of the image for the patron with the sub GetPatronImage { my ($cardnumber) = @_; - warn "Cardnumber passed to GetPatronImage is $cardnumber"; # if $debug; + warn "Cardnumber passed to GetPatronImage is $cardnumber" if $debug; my $dbh = C4::Context->dbh; my $query = "SELECT mimetype, imagefile FROM patronimage WHERE cardnumber = ?;"; my $sth = $dbh->prepare($query); @@ -1732,15 +1734,36 @@ sub PutPatronImage { my ($cardnumber, $mimetype, $imgfile) = @_; warn "Parameters passed in: Cardnumber=$cardnumber, Mimetype=$mimetype, " . ($imgfile ? "Imagefile" : "No Imagefile") if $debug; my $dbh = C4::Context->dbh; - my $query = "INSERT INTO patronimage (cardnumber, mimetype, imagefile) VALUES (?,?,?) ON DUPLICATE KEY UPDATE cardnumber = ?;"; + my $query = "INSERT INTO patronimage (cardnumber, mimetype, imagefile) VALUES (?,?,?) ON DUPLICATE KEY UPDATE imagefile = ?;"; my $sth = $dbh->prepare($query); - $sth->execute($cardnumber,$mimetype,$imgfile,$cardnumber); + $sth->execute($cardnumber,$mimetype,$imgfile,$imgfile); warn "Error returned inserting $cardnumber.$mimetype." if $sth->errstr; my $dberror = $sth->errstr; $sth->finish; return $dberror; } +=head2 RmPatronImage + + my ($dberror) = RmPatronImage($cardnumber); + +Removes the image for the patron with the supplied cardnumber. + +=cut + +sub RmPatronImage { + my ($cardnumber) = @_; + warn "Cardnumber passed to GetPatronImage is $cardnumber" if $debug; + my $dbh = C4::Context->dbh; + my $query = "DELETE FROM patronimage WHERE cardnumber = ?;"; + my $sth = $dbh->prepare($query); + $sth->execute($cardnumber); + my $dberror = $sth->errstr; + warn "Database error!" if $sth->errstr; + $sth->finish; + return $dberror; +} + =head2 GetRoadTypeDetails (OUEST-PROVENCE) ($roadtype) = &GetRoadTypeDetails($roadtypeid); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl index 2108b58318..c601bd8252 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl @@ -196,10 +196,16 @@ for (var i=0;i - +
-
Upload Patron Image -
does not currently have an image available. To import an image for , enter the name of an image file to upload.
+ +
Manage Patron Image +
To update the image for , enter the name of the new image file to upload and click 'Upload.'
Click the 'Delete' button to remove the current image.
+ + +
Upload Patron Image +
does not currently have an image available. To import an image for , enter the name of an image file to upload.
+ " /> " /> @@ -208,11 +214,13 @@ for (var i=0;iSelect the file to upload: -
+
+ + +
- - + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tmpl index 2188794709..190eb8d076 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tmpl @@ -98,7 +98,9 @@
-
Cancel +
+ +
diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl index 96e84eaafb..144ca78e7f 100755 --- a/tools/picture-upload.pl +++ b/tools/picture-upload.pl @@ -46,6 +46,7 @@ my $cardnumber = $input->param('cardnumber'); my $uploadfilename = $input->param('uploadfile'); my $uploadfile = $input->upload('uploadfile'); my $borrowernumber = $input->param('borrowernumber'); +my $op = $input->param('op'); #FIXME: This code is really in the rough. The variables need to be re-scoped as the two subs depend on global vars to operate. # Other parts of this code could be optimized as well, I think. Perhaps the file upload could be done with YUI's upload @@ -67,11 +68,11 @@ THis script is called and presents the user with an interface allowing him/her t =cut - +warn "Operation requested: $op" if $DEBUG; my ( $total, $handled, @counts, $tempfile, $tfh ); -if ( $uploadfile ) { +if ( ($op eq 'Upload') && $uploadfile ) { # Case is important in these operational values as the template must use case to be visually pleasing! my $dirname = File::Temp::tempdir( CLEANUP => 1); warn "dirname = $dirname" if $DEBUG; my $filesuffix = $1 if $uploadfilename =~ m/(\..+)$/i; @@ -132,13 +133,18 @@ if ( $uploadfile ) { ); } } -} else { - $template->param(cardnumber => $cardnumber ); - $template->param(filetype => $filetype ); +} elsif ( ($op eq 'Upload') && !$uploadfile ) { + warn "Problem uploading file or no file uploaded."; + $template->param(cardnumber => $cardnumber); + $template->param(filetype => $filetype); +} elsif ( $op eq 'Delete' ) { + my $dberror = RmPatronImage($cardnumber); + warn "Database returned $dberror" if $dberror; +} elsif ( $op eq 'Cancel' ) { + print $input->redirect ("/cgi-bin/koha/tools/picture-upload.pl"); } if ( $borrowernumber && !$errors && !$template->param('ERRORS') ) { - my $urlbase = $input->url(-base => 1 -rewrite => 1); print $input->redirect ("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber"); } else { output_html_with_http_headers $input, $cookie, $template->output;