wr76595 (bug 4157): Control barcode display with a borrower attribute
Signed-off-by: Matthias Meusburger <matthias.meusburger@biblibre.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
parent
0ccc89990b
commit
5bcb1529bc
9 changed files with 72 additions and 6 deletions
|
@ -69,7 +69,7 @@ If $all_fields is true, then each hashref also contains the other fields from bo
|
|||
=cut
|
||||
|
||||
sub GetAttributeTypes {
|
||||
my $all = @_ ? shift : 0;
|
||||
my ($all) = @_;
|
||||
my $select = $all ? '*' : 'code, description';
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth = $dbh->prepare("SELECT $select FROM borrower_attribute_types ORDER by code");
|
||||
|
@ -83,6 +83,22 @@ sub GetAttributeTypes_hashref {
|
|||
return \%hash;
|
||||
}
|
||||
|
||||
=head2 AttributeTypeExists
|
||||
|
||||
my $have_attr_xyz = C4::Members::AttributeTypes::AttributeTypeExists($code)
|
||||
|
||||
Returns true if we have attribute type C<$code>
|
||||
in the database.
|
||||
|
||||
=cut
|
||||
|
||||
sub AttributeTypeExists {
|
||||
my ($code) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $exists = $dbh->selectrow_array("SELECT code FROM borrower_attribute_types WHERE code = ?", undef, $code);
|
||||
return $exists;
|
||||
}
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
my $attr_type = C4::Members::AttributeTypes->new($code, $description);
|
||||
|
|
|
@ -31,7 +31,7 @@ BEGIN {
|
|||
# set the version for version checking
|
||||
$VERSION = 3.01;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT_OK = qw(GetBorrowerAttributes CheckUniqueness SetBorrowerAttributes
|
||||
@EXPORT_OK = qw(GetBorrowerAttributes GetBorrowerAttributeValue CheckUniqueness SetBorrowerAttributes
|
||||
extended_attributes_code_value_arrayref extended_attributes_merge
|
||||
SearchIdMatchingAttribute);
|
||||
%EXPORT_TAGS = ( all => \@EXPORT_OK );
|
||||
|
@ -94,6 +94,28 @@ sub GetBorrowerAttributes {
|
|||
return \@results;
|
||||
}
|
||||
|
||||
=head2 GetBorrowerAttributeValue
|
||||
|
||||
my $value = C4::Members::Attributes::GetBorrowerAttributeValue($borrowernumber, $attribute_code);
|
||||
|
||||
Retrieve the value of an extended attribute C<$attribute_code> associated with the
|
||||
patron specified by C<$borrowernumber>.
|
||||
|
||||
=cut
|
||||
|
||||
sub GetBorrowerAttributeValue {
|
||||
my $borrowernumber = shift;
|
||||
my $code = shift;
|
||||
|
||||
my $dbh = C4::Context->dbh();
|
||||
my $query = "SELECT attribute
|
||||
FROM borrower_attributes
|
||||
WHERE borrowernumber = ?
|
||||
AND code = ?";
|
||||
my $value = $dbh->selectrow_array($query, undef, $borrowernumber, $code);
|
||||
return $value;
|
||||
}
|
||||
|
||||
=head2 SearchIdMatchingAttribute
|
||||
|
||||
my $matching_records = C4::Members::Attributes::SearchIdMatchingAttribute($filter);
|
||||
|
|
2
installer/data/mysql/en/mandatory/auth_values.sql
Normal file
2
installer/data/mysql/en/mandatory/auth_values.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','0','No','No');
|
||||
INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','1','Yes','Yes');
|
1
installer/data/mysql/en/mandatory/auth_values.txt
Normal file
1
installer/data/mysql/en/mandatory/auth_values.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Default Koha system authorised values
|
2
installer/data/mysql/en/optional/patron_atributes.sql
Normal file
2
installer/data/mysql/en/optional/patron_atributes.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
INSERT INTO `borrower_attribute_types` (`code`, `description`, `repeatable`, `unique_id`, `opac_display`, `password_allowed`, `staff_searchable`, `authorised_value_category`)
|
||||
VALUES ('SHOW_BCODE', 'Show barcode on the summary screen items listings', 0, 0, 1, 0, 0, 'YES_NO');
|
2
installer/data/mysql/en/optional/patron_atributes.txt
Normal file
2
installer/data/mysql/en/optional/patron_atributes.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
Useful patron atribute types:
|
||||
* SHOW_BCODE - Show barcode on the patron summary screen items listings
|
|
@ -4217,6 +4217,16 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
|
|||
SetVersion ($DBversion);
|
||||
}
|
||||
|
||||
$DBversion = "3.03.00.XXX";
|
||||
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
|
||||
|
||||
$dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','0','No','No')");
|
||||
$dbh->do("INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('YES_NO','1','Yes','Yes')");
|
||||
|
||||
print "Upgrade to $DBversion done ( add generic boolean YES_NO authorised_values pair )\n";
|
||||
SetVersion ($DBversion);
|
||||
}
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 DropAllForeignKeys($table)
|
||||
|
|
|
@ -201,7 +201,7 @@ $.tablesorter.addParser({
|
|||
<!-- TMPL_IF NAME="JacketImages" --><th> </th><!-- /TMPL_IF -->
|
||||
<th>Title</th>
|
||||
<!-- TMPL_UNLESS NAME="item_level_itypes" --><th>Item Type</th> <!-- /TMPL_UNLESS -->
|
||||
<th>Barcode</th>
|
||||
<!-- TMPL_IF NAME="show_barcode" --><th>Barcode</th><!-- /TMPL_IF -->
|
||||
<th>Call No.</th>
|
||||
<th>Due</th>
|
||||
<!-- TMPL_IF name="OpacRenewalAllowed" -->
|
||||
|
@ -242,7 +242,7 @@ $.tablesorter.addParser({
|
|||
<!-- TMPL_VAR NAME="author" -->
|
||||
</span></td>
|
||||
<!-- TMPL_UNLESS NAME="item_level_itypes" --><td><!-- TMPL_IF NAME="imageurl" --><img src="<!-- TMPL_VAR NAME="imageurl" -->" title="<!-- TMPL_VAR name="description" -->" alt="<!-- TMPL_VAR NAME="description" -->" /><!-- /TMPL_IF --> <!-- TMPL_VAR name="description" --></td><!-- /TMPL_UNLESS -->
|
||||
<td><!-- TMPL_VAR NAME="barcode" --></td>
|
||||
<!-- TMPL_IF NAME="show_barcode" --><td><!-- TMPL_VAR NAME="barcode" --></td><!-- /TMPL_IF -->
|
||||
<td><!-- TMPL_VAR NAME="itemcallnumber" --></td>
|
||||
<!-- TMPL_IF NAME="overdue" -->
|
||||
<td class="overdue"><!-- TMPL_VAR NAME="date_due" --></td>
|
||||
|
@ -294,7 +294,7 @@ $.tablesorter.addParser({
|
|||
<!-- TMPL_IF NAME="JacketImages" --><th> </th><!-- /TMPL_IF -->
|
||||
<th>Title</th>
|
||||
<!-- TMPL_UNLESS NAME="item_level_itypes" --><th>Item Type</th> <!-- /TMPL_UNLESS -->
|
||||
<th>Barcode</th>
|
||||
<!-- TMPL_IF NAME="show_barcode" --><th>Barcode</th><!-- /TMPL_IF -->
|
||||
<th>Call No.</th>
|
||||
<th>Due</th>
|
||||
<!-- TMPL_IF name="OpacRenewalAllowed" -->
|
||||
|
@ -326,7 +326,7 @@ $.tablesorter.addParser({
|
|||
<td><a href="/cgi-bin/koha/opac-detail.pl?bib=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" escape="html" --></a> <span class="item-details"><!-- TMPL_VAR NAME="author" --></span></td>
|
||||
|
||||
<!-- TMPL_UNLESS NAME="item_level_itypes" --><td><!-- TMPL_IF NAME="imageurl" --><img src="<!-- TMPL_VAR NAME="imageurl" -->" title="<!-- TMPL_VAR name="description" -->" alt="<!-- TMPL_VAR NAME="description" -->" /><!-- /TMPL_IF --> <!-- TMPL_VAR name="description" --></td><!-- /TMPL_UNLESS -->
|
||||
<td><!-- TMPL_VAR NAME="barcode" --></td>
|
||||
<!-- TMPL_IF NAME="show_barcode" --><td><!-- TMPL_VAR NAME="barcode" --></td><!-- /TMPL_IF -->
|
||||
<td><!-- TMPL_VAR NAME="itemcallnumber" --></td>
|
||||
<td><!-- TMPL_VAR NAME="date_due" --></td>
|
||||
<!-- TMPL_IF name="OpacRenewalAllowed" -->
|
||||
|
|
|
@ -27,6 +27,8 @@ use C4::Koha;
|
|||
use C4::Circulation;
|
||||
use C4::Reserves;
|
||||
use C4::Members;
|
||||
use C4::Members::AttributeTypes;
|
||||
use C4::Members::Attributes qw/GetBorrowerAttributeValue/;
|
||||
use C4::Output;
|
||||
use C4::Biblio;
|
||||
use C4::Items;
|
||||
|
@ -34,6 +36,8 @@ use C4::Dates qw/format_date/;
|
|||
use C4::Letters;
|
||||
use C4::Branch; # GetBranches
|
||||
|
||||
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
|
||||
|
||||
my $query = new CGI;
|
||||
|
||||
BEGIN {
|
||||
|
@ -167,6 +171,13 @@ $template->param( issues_count => $count );
|
|||
$template->param( OVERDUES => \@overdues );
|
||||
$template->param( overdues_count => $overdues_count );
|
||||
|
||||
my $show_barcode = C4::Members::AttributeTypes::AttributeTypeExists( ATTRIBUTE_SHOW_BARCODE );
|
||||
if ($show_barcode) {
|
||||
my $patron_show_barcode = GetBorrowerAttributeValue($borrowernumber, ATTRIBUTE_SHOW_BARCODE);
|
||||
undef $show_barcode if defined($patron_show_barcode) && !$patron_show_barcode;
|
||||
}
|
||||
$template->param( show_barcode => 1 ) if $show_barcode;
|
||||
|
||||
# load the branches
|
||||
my $branches = GetBranches();
|
||||
my @branch_loop;
|
||||
|
|
Loading…
Reference in a new issue