=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");
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);
# 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 );
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);
--- /dev/null
+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');
--- /dev/null
+Default Koha system authorised values
--- /dev/null
+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');
--- /dev/null
+Useful patron atribute types:
+* SHOW_BCODE - Show barcode on the patron summary screen items listings
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)
<!-- 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" -->
<!-- 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>
<!-- 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" -->
<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" -->
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;
use C4::Letters;
use C4::Branch; # GetBranches
+use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
+
my $query = new CGI;
BEGIN {
$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;