@@ -, +, @@ biblioitems. New sortable Zebra index. 'misc/batchRebuildBiblioTables.pl --upstream' automatic Zebra indexing is enabled in your environment. datereceived=2015-12-04 where the Date is the day when you added those Items from step 2. (should be today) The easiest way is to use the batchRebuildBiblioTables.pl but some records can be manually created as well. You can set the datereceived from the Item-form, so set some Items to past and some Items to have a datereceived in the future. Be aware that the first Item created sets the Parent Biblio's datereceived. --- C4/Search.pm | 8 +++ Koha/QueryParser/Driver/PQF.pm | 2 + etc/zebradb/biblios/etc/bib1.att | 1 + etc/zebradb/ccl.properties | 3 + .../marc21/biblios/biblio-koha-indexdefs.xml | 11 ++++ .../marc21/biblios/biblio-zebra-indexdefs.xsl | 14 +++++ .../marc21/mandatory/marc21_framework_DEFAULT.sql | 2 + .../marc21/optional/marc21_fastadd_framework.sql | 2 + .../optional/marc21_simple_bib_frameworks.sql | 16 ++++++ installer/data/mysql/updatedatabase.pl | 58 ++++++++++++++++++++ .../intranet-tmpl/prog/en/includes/resort_form.inc | 12 ++++ .../bootstrap/en/includes/resort_form.inc | 10 ++++ 12 files changed, 139 insertions(+) --- a/C4/Search.pm +++ a/C4/Search.pm @@ -413,6 +413,12 @@ sub getRecords { elsif ( $sort eq "acqdate_dsc" ) { $sort_by .= "1=32 >i "; } + elsif ( $sort eq "datereceived_asc" ) { + $sort_by .= "1=9015 add_bib1_filter_map( 'biblioserver', 'copydate', { 'target_syntax_callback' => \&Koha::QueryParser::Driver::PQF::date_filter_target_callback, '1' => '30', '4' => '4' }); $self->add_bib1_filter_map( 'biblioserver', 'pubdate', { 'target_syntax_callback' => \&Koha::QueryParser::Driver::PQF::date_filter_target_callback, '1' => 'pubdate', '4' => '4' }); $self->add_bib1_filter_map( 'biblioserver', 'acqdate', { 'target_syntax_callback' => \&Koha::QueryParser::Driver::PQF::date_filter_target_callback, '1' => 'Date-of-acquisition', '4' => '4' }); + $self->add_bib1_field_map('keyword' => 'datereceived' => 'biblioserver' => { '1' => '9015' } ); + $self->add_search_field_alias( 'keyword' => 'date-of-receival' => 'datereceived' ); $self->add_bib1_field_map('keyword' => 'isbn' => 'biblioserver' => { '1' => '7' } ); $self->add_search_field_alias( 'keyword' => 'isbn' => 'nb' ); $self->add_bib1_field_map('keyword' => 'issn' => 'biblioserver' => { '1' => '8' } ); --- a/etc/zebradb/biblios/etc/bib1.att +++ a/etc/zebradb/biblios/etc/bib1.att @@ -219,6 +219,7 @@ att 9009 cn-prefix att 9010 cn-suffix att 9011 Suppress att 9012 Identifier-other +att 9015 Date-of-receival # Items Index att 8001 withdrawn --- a/etc/zebradb/ccl.properties +++ a/etc/zebradb/ccl.properties @@ -346,6 +346,9 @@ pubdate Date-of-publication Date-of-acquisition 1=32 acqdate Date-of-acquisition +Date-of-receival 1=9015 +datereceived Date-of-receival + #Date/time added to 1011 The date and time that a 008/00-05 #database record was added to the # database. --- a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml +++ a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml @@ -1095,6 +1095,12 @@ totalissues:n totalissues:s + + + Date-of-receival:w + Date-of-receival:d + Date-of-receival:s + cn-bib-source:w @@ -1255,6 +1261,11 @@ datelastseen:w + + + Date-of-receival:w + Date-of-receival:d + datelastborrowed:w --- a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl +++ a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl @@ -1056,6 +1056,13 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) + + + + + + + @@ -1296,6 +1303,13 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) + + + + + + + --- a/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql +++ a/installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql @@ -56,6 +56,7 @@ INSERT IGNORE INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, INSERT IGNORE INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, -5, '', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, '', '', '', NULL);"); ('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, '', '', '', NULL), ('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, '', '', '', NULL), ('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, '', '', '', NULL), @@ -114,6 +115,7 @@ INSERT IGNORE INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblib ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', 0, 0, '', '', '', NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, -5, '', '', '', NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, -5, '', '', '', NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, '', '', '', NULL);"); ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, -5, '', '', '', NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, '', '', '', NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', 1, 0, '', '', '', NULL), --- a/installer/data/mysql/en/marcflavour/marc21/optional/marc21_fastadd_framework.sql +++ a/installer/data/mysql/en/marcflavour/marc21/optional/marc21_fastadd_framework.sql @@ -99,6 +99,7 @@ INSERT IGNORE INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblib ('500', 'x', 'International Standard Serial Number (SE) [OBSOLETE]', 'International Standard Serial Number (SE) [OBSOLETE]', 0, 0, '', 0, '', '', '', 0, 0, 'FA', NULL, '', ''), ('500', 'z', 'Source of note information (AM SE) [OBSOLETE]', 'Source of note information (AM SE) [OBSOLETE]', 0, 0, '', 0, '', '', '', 0, 0, 'FA', NULL, '', ''), ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, 5, 'FA', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, 'FA', '', '', NULL), ('942', 'c', 'Koha item type', 'Koha item type', 0, 1, 'biblioitems.itemtype', 9, 'itemtypes', '', '', NULL, 5, 'FA', '', '', NULL), ('942', 'n', 'Suppress in OPAC', 'Suppress in OPAC', 0, 0, NULL, 9, '', '', '', 0, 5, 'FA', '', '', NULL), ('942', 's', 'Serial record flag', 'Serial record', 0, 0, 'biblio.serial', 9, '', '', '', NULL, 5, 'FA', '', '', NULL), @@ -129,6 +130,7 @@ INSERT IGNORE INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblib ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', NULL, 0, 'FA', '', NULL, NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, 0, 'FA', '', NULL, NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, 0, 'FA', '', NULL, NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, 'FA', '', '', NULL), ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, 0, 'FA', '', NULL, NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, 'FA', '', NULL, NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', NULL, 0, 'FA', '', NULL, NULL), --- a/installer/data/mysql/en/marcflavour/marc21/optional/marc21_simple_bib_frameworks.sql +++ a/installer/data/mysql/en/marcflavour/marc21/optional/marc21_simple_bib_frameworks.sql @@ -131,6 +131,7 @@ INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeat INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, -5, 'BKS', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, 'BKS', '', '', NULL), ('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, 'BKS', '', '', NULL), ('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, 'BKS', '', '', NULL), ('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, 'BKS', '', '', NULL), @@ -189,6 +190,7 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', 0, 0, 'BKS', '', '', NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, -5, 'BKS', '', '', NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, -5, 'BKS', '', '', NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, 'BKS', '', '', NULL), ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, -5, 'BKS', '', '', NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, 'BKS', '', '', NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', 1, 0, 'BKS', '', '', NULL), @@ -4138,6 +4140,7 @@ INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeat INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, -5, 'CF', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, 'CF', '', '', NULL), ('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, 'CF', '', '', NULL), ('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, 'CF', '', '', NULL), ('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, 'CF', '', '', NULL), @@ -4196,6 +4199,7 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', 0, 0, 'CF', '', '', NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, -5, 'CF', '', '', NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, -5, 'CF', '', '', NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, 'CF', '', '', NULL), ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, -5, 'CF', '', '', NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, 'CF', '', '', NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', 1, 0, 'CF', '', '', NULL), @@ -8146,6 +8150,7 @@ INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeat INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, -5, 'SR', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, 'SR', '', '', NULL), ('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, 'SR', '', '', NULL), ('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, 'SR', '', '', NULL), ('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, 'SR', '', '', NULL), @@ -8204,6 +8209,7 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', 0, 0, 'SR', '', '', NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, -5, 'SR', '', '', NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, -5, 'SR', '', '', NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, 'SR', '', '', NULL), ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, -5, 'SR', '', '', NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, 'SR', '', '', NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', 1, 0, 'SR', '', '', NULL), @@ -12153,6 +12159,7 @@ INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeat INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, -5, 'VR', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, 'VR', '', '', NULL), ('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, 'VR', '', '', NULL), ('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, 'VR', '', '', NULL), ('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, 'VR', '', '', NULL), @@ -12211,6 +12218,7 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', 0, 0, 'VR', '', '', NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, -5, 'VR', '', '', NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, -5, 'VR', '', '', NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, 'VR', '', '', NULL), ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, -5, 'VR', '', '', NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, 'VR', '', '', NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', 1, 0, 'VR', '', '', NULL), @@ -16159,6 +16167,7 @@ INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeat INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, -5, 'AR', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, 'AR', '', '', NULL), ('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, 'AR', '', '', NULL), ('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, 'AR', '', '', NULL), ('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, 'AR', '', '', NULL), @@ -16217,6 +16226,7 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', 0, 0, 'AR', '', '', NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, -5, 'AR', '', '', NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, -5, 'AR', '', '', NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, 'AR', '', '', NULL), ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, -5, 'AR', '', '', NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, 'AR', '', '', NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', 1, 0, 'AR', '', '', NULL), @@ -20164,6 +20174,7 @@ INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeat INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, -5, 'KT', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, 'KT', '', '', NULL), ('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, 'KT', '', '', NULL), ('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, 'KT', '', '', NULL), ('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, 'KT', '', '', NULL), @@ -20222,6 +20233,7 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', 0, 0, 'KT', '', '', NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, -5, 'KT', '', '', NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, -5, 'KT', '', '', NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, 'KT', '', '', NULL), ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, -5, 'KT', '', '', NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, 'KT', '', '', NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', 1, 0, 'KT', '', '', NULL), @@ -24170,6 +24182,7 @@ INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeat INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, -5, 'IR', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, 'IR', '', '', NULL) ('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, 'IR', '', '', NULL), ('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, 'IR', '', '', NULL), ('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, 'IR', '', '', NULL), @@ -24228,6 +24241,7 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', 0, 0, 'IR', '', '', NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, -5, 'IR', '', '', NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, -5, 'IR', '', '', NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, 'IR', '', '', NULL), ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, -5, 'IR', '', '', NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, 'IR', '', '', NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', 1, 0, 'IR', '', '', NULL), @@ -28174,6 +28188,7 @@ INSERT INTO `marc_tag_structure` (`tagfield`, `liblibrarian`, `libopac`, `repeat INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian`, `libopac`, `repeatable`, `mandatory`, `kohafield`, `tab`, `authorised_value`, `authtypecode`, `value_builder`, `isurl`, `hidden`, `frameworkcode`, `seealso`, `link`, `defaultvalue`) VALUES ('942', '0', 'Koha issues (borrowed), all copies', 'Koha issues (borrowed), all copies', 0, 0, 'biblioitems.totalissues', 9, '', '', '', NULL, -5, 'SER', '', '', NULL), + ('942', '1', 'First date received', 'First date received', 0, 0, 'biblioitems.datereceived',9, '', '', '', NULL, 0, 'SER', '', '', NULL), ('942', '2', 'Source of classification or shelving scheme', 'Source of classification or shelving scheme', 0, 0, 'biblioitems.cn_source', 9, 'cn_source', '', '', NULL, 0, 'SER', '', '', NULL), ('942', '6', 'Koha normalized classification for sorting', 'Koha normalized classification for sorting', 0, 0, 'biblioitems.cn_sort', -1, '', '', '', 0, 7, 'SER', '', '', NULL), ('942', 'a', 'Institution code [OBSOLETE]', 'Institution code [OBSOLETE]', 0, 0, '', 9, '', '', '', NULL, -5, 'SER', '', '', NULL), @@ -28232,6 +28247,7 @@ INSERT INTO `marc_subfield_structure` (`tagfield`, `tagsubfield`, `liblibrarian` ('952', 'p', 'Barcode', 'Barcode', 0, 0, 'items.barcode', 10, '', '', 'barcode.pl', 0, 0, 'SER', '', '', NULL), ('952', 'q', 'Checked out', 'Checked out', 0, 0, 'items.onloan', 10, '', '', '', NULL, -5, 'SER', '', '', NULL), ('952', 'r', 'Date last seen', 'Date last seen', 0, 0, 'items.datelastseen', 10, '', '', '', NULL, -5, 'SER', '', '', NULL), + ('952', 'R', 'Date received', 'Date received', 0, 0, 'items.datereceived', 10, '', '', '', NULL, 0, 'SER', '', '', NULL), ('952', 's', 'Date last checked out', 'Date last checked out', 0, 0, 'items.datelastborrowed', 10, '', '', '', NULL, -5, 'SER', '', '', NULL), ('952', 't', 'Copy number', 'Copy number', 0, 0, 'items.copynumber', 10, '', '', '', NULL, 0, 'SER', '', '', NULL), ('952', 'u', 'Uniform Resource Identifier', 'Uniform Resource Identifier', 0, 0, 'items.uri', 10, '', '', '', 1, 0, 'SER', '', '', NULL), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -7901,6 +7901,64 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.19.00.XXX"; +if ( CheckVersion($DBversion) ) { + require C4::Biblio; + #Check if it is safe to do the upgrade by looking if the default mappings have alredy been taken. + my $sth3 = $dbh->prepare("SELECT 1 FROM marc_subfield_structure WHERE (tagfield = '942' AND tagsubfield = '1') OR (tagfield = '952' AND tagsubfield = 'R')"); + $sth3->execute(); + my $mappingUsed = $sth3->fetchall_arrayref(); + $sth3->finish(); + if (@$mappingUsed > 0) { + print "Upgrade to $DBversion failed (Bug 13707 - Adding a new column datereceived for items and biblioitems. New sortable Zebra index! ). The default \"Koha to MARC mappings\" for biblioitems.datereceived are already taken. You must manually map biblioitems.datereceived to a MARC framework to enable searching by datereceived. You can see the subroutine inside this upgrade clause on how to do that.\n"; + } + else { + my $doTheDirtyDeed = sub { + print "Upgrading Bug 13707, mapping biblioitems.datereceived to MARC 954\$1 and mapping items.datereceived to 952\$R. Then putting biblioitems.datereceived to all MARC Records. This will take several hours.\n"; + + my $sth = $dbh->prepare("SELECT frameworkcode FROM biblio_framework"); + $sth->execute(); + my $frameworks = $sth->fetchall_arrayref(); + $sth->finish(); + push @$frameworks, ['']; #Add the Default framework + + ###Add the default "Koha to MARC mappings" ### + foreach my $fwAry (@$frameworks) { + my $framework = $fwAry->[0]; + $dbh->do("INSERT INTO marc_subfield_structure VALUES ('952','R','Date received','Date received','0','0','items.datereceived','10','','','','0','0','$framework',NULL,'','','9999');"); + $dbh->do("INSERT INTO marc_subfield_structure VALUES ('942','1','First date received','First date received','0','0','biblioitems.datereceived','9','','','','0','0','$framework',NULL,'','','9999');"); + } + my ( $datereceivedFieldCode, $datereceivedSubfieldCode ) = + C4::Biblio::GetMarcFromKohaField( "biblioitems.datereceived", '' ); + ###Add the biblioitems.datereceived to all MARC Records to the mapped location. ### + #Fetch all biblios + my $sth2 = $dbh->prepare(" SELECT b.biblionumber, datereceived, frameworkcode FROM biblioitems bi LEFT JOIN biblio b ON b.biblionumber = bi.biblionumber WHERE datereceived IS NOT NULL; "); + $sth2->execute(); + my $biblios = $sth2->fetchall_arrayref({}); + $sth2->finish(); + foreach my $b (@$biblios) { + #UPSERT the datereceived + my $record = C4::Biblio::GetMarcBiblio( $b->{biblionumber} ); + my @existingFields = $record->field($datereceivedFieldCode); + if ($existingFields[0]) { + $existingFields[0]->update($datereceivedSubfieldCode => $b->{datereceived}); + } + else { + my $newField = MARC::Field->new($datereceivedFieldCode, '', '', $datereceivedSubfieldCode => $b->{datereceived}); + $record->insert_fields_ordered($newField); + } + C4::Biblio::ModBiblio($record, $b->{biblionumber}, $b->{frameworkcode}); + } + + print "Upgrade to $DBversion done (Bug 13707 - Adding a new column datereceived for items and biblioitems. New sortable Zebra index! )\n"; + print "- All MARC records have now been updated, but Zebra needs to be fully reindexed.\n"; + }; + &$doTheDirtyDeed(); + } + + SetVersion ($DBversion); +} + $DBversion = "3.15.00.008"; if ( CheckVersion($DBversion) ) { $dbh->do(q{ --- a/koha-tmpl/intranet-tmpl/prog/en/includes/resort_form.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/resort_form.inc @@ -70,6 +70,18 @@ [% ELSE %] [% END %] + +[% IF ( sort_by == "datereceived_dsc" ) %] + +[% ELSE %] + +[% END %] + +[% IF ( sort_by == "datereceived_asc" ) %] + +[% ELSE %] + +[% END %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/resort_form.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/resort_form.inc @@ -56,6 +56,16 @@ [% ELSE %] [% END %] + [% IF ( sort_by == "datereceived_dsc" ) %] + + [% ELSE %] + + [% END %] + [% IF ( sort_by == "datereceived_asc" ) %] + + [% ELSE %] + + [% END %] [% IF ( sort_by == "title_az" || sort_by == "title_asc" ) %] --