&GetRoadTypeDetails
&GetSortDetails
&GetTitles
+
&GetPatronImage
&PutPatronImage
+ &RmPatronImage
&GetMemberAccountRecords
&GetBorNotifyAcctRecord
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);
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);
<div>
<!-- TMPL_IF NAME="patronimages" -->
- <!-- TMPL_IF NAME="CAN_user_tools" --><!-- TMPL_UNLESS NAME="picture" -->
+ <!-- TMPL_IF NAME="CAN_user_tools" -->
<form method="post" action="/cgi-bin/koha/tools/picture-upload.pl" enctype="multipart/form-data">
- <fieldset class="brief"><legend>Upload Patron Image</legend>
- <div class="hint"><!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --> does not currently have an image available. To import an image for <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="surname" -->, enter the name of an image file to upload.</div>
+ <!-- TMPL_IF NAME="picture" -->
+ <fieldset class="brief"><legend>Manage Patron Image</legend>
+ <div class="hint">To update the image for <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="surname" -->, enter the name of the new image file to upload and click 'Upload.' <br />Click the 'Delete' button to remove the current image.</div>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_UNLESS NAME="picture" -->
+ <fieldset class="brief"><legend>Upload Patron Image</legend>
+ <div class="hint"><!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="firstname" --> <!-- TMPL_VAR NAME="surname" --> does not currently have an image available. To import an image for <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="surname" -->, enter the name of an image file to upload.</div>
+ <!-- /TMPL_UNLESS -->
<input type="hidden" id="image" name="filetype" value="image" />
<input type="hidden" id="cardnumber" name="cardnumber" value="<!-- TMPL_VAR NAME="cardnumber" -->" />
<input type="hidden" id="borrowernumber" name="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernumber" -->" />
<label for="uploadfile">Select the file to upload: </label><input type="file" id="uploadfile" name="uploadfile" />
</li>
</ol>
- <fieldset class="action"><input type="submit" value="Upload" class="submit" />
+ <fieldset class="action">
+ <input name="op" type="submit" value="Upload" class="submit" />
+ <!-- TMPL_IF NAME="picture" --><input name="op" type="submit" value="Delete" class="submit" /><!-- /TMPL_IF -->
+ </fieldset>
</fieldset>
</form>
-<!-- /TMPL_UNLESS -->
-<!-- /TMPL_IF -->
+ <!-- /TMPL_IF -->
<!-- /TMPL_IF -->
</div>
</ol>
</li></ol>
</fieldset>
- <fieldset class="action"><input type="submit" value="Upload" class="submit" /> <a href="/cgi-bin/koha/tools/picture-upload.pl" class="cancel">Cancel</a>
+ <fieldset class="action">
+ <input type="submit" name="op" value="Upload" class="submit" />
+ <input type="submit" name="op" value="Cancel" class="submit" />
</fieldset>
</form>
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
=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;
);
}
}
-} 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;