# to get something
push @EXPORT, qw(
+ &Get
&GetBiblio
&GetBiblioData
&GetBiblioItemData
&GetBiblioItemByBiblioNumber
&GetBiblioFromItemNumber
+ GetFieldMapping
+ SetFieldMapping
+ DeleteFieldMapping
+
&GetISBDView
&GetMarcNotes
return $num_headings_changed;
}
+=head2 Get
+
+=over 4
+
+my $values = Get($field, $record, $frameworkcode);
+
+=back
+
+Get MARC fields from a keyword defined in fieldmapping table.
+
+=cut
+
+sub Get {
+ my ($field, $record, $frameworkcode) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare('SELECT fieldcode, subfieldcode FROM fieldmapping WHERE frameworkcode = ? AND field = ?');
+ $sth->execute($frameworkcode, $field);
+
+ my @result = ();
+
+ while(my $row = $sth->fetchrow_hashref){
+ foreach my $field ($record->field($row->{fieldcode})){
+ if( ($row->{subfieldcode} ne "" && $field->subfield($row->{subfieldcode}))){
+ foreach my $subfield ($field->subfield($row->{subfieldcode})){
+ push @result, { 'subfield' => $subfield };
+ }
+
+ }elsif($row->{subfieldcode} eq "") {
+ push @result, {'subfield' => $field->as_string()};
+ }
+ }
+ }
+
+ return @result;
+}
+
+=head2 SetFieldMapping
+
+=over 4
+
+SetFieldMapping($framework, $field, $fieldcode, $subfieldcode);
+
+=back
+
+Set a Field to MARC mapping value, if it already exists we don't add a new one.
+
+=cut
+
+sub SetFieldMapping {
+ my ($framework, $field, $fieldcode, $subfieldcode) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare('SELECT * FROM fieldmapping WHERE fieldcode = ? AND subfieldcode = ? AND frameworkcode = ? AND field = ?');
+ $sth->execute($fieldcode, $subfieldcode, $framework, $field);
+ if(not $sth->fetchrow_hashref){
+ my @args;
+ $sth = $dbh->prepare('INSERT INTO fieldmapping (fieldcode, subfieldcode, frameworkcode, field) VALUES(?,?,?,?)');
+
+ $sth->execute($fieldcode, $subfieldcode, $framework, $field);
+ }
+}
+
+=head2 DeleteFieldMapping
+
+=over 4
+
+DeleteFieldMapping($id);
+
+=back
+
+Delete a field mapping from an $id.
+
+=cut
+
+sub DeleteFieldMapping{
+ my ($id) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare('DELETE FROM fieldmapping WHERE id = ?');
+ $sth->execute($id);
+}
+
+=head2 GetFieldMapping
+
+=over 4
+
+GetFieldMapping($frameworkcode);
+
+=back
+
+Get all field mappings for a specified frameworkcode
+
+=cut
+
+sub GetFieldMapping {
+ my ($framework) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $sth = $dbh->prepare('SELECT * FROM fieldmapping where frameworkcode = ?');
+ $sth->execute($framework);
+
+ my @return;
+ while(my $row = $sth->fetchrow_hashref){
+ push @return, $row;
+ }
+ return \@return;
+}
+
=head2 GetBiblioData
=over 4
KEY `branchcode` (`branchcode`,`categorycode`,`item_type`, `notification`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+--
+-- Table structure for table `fieldmapping`
+--
+
+DROP TABLE IF EXISTS `fieldmapping`;
+CREATE TABLE `fieldmapping` (
+ `id` int(11) NOT NULL auto_increment,
+ `field` varchar(255) NOT NULL,
+ `frameworkcode` char(4) NOT NULL default '',
+ `fieldcode` char(3) NOT NULL,
+ `subfieldcode` char(1) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
print "Upgrade to $DBversion done (Moving max allowed reserves from system preference to issuingrule)\n";
}
+$DBversion = "3.01.00.041";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("
+ CREATE TABLE `fieldmapping` (
+ `id` int(11) NOT NULL auto_increment,
+ `field` varchar(255) NOT NULL,
+ `frameworkcode` char(4) NOT NULL default '',
+ `fieldcode` char(3) NOT NULL,
+ `subfieldcode` char(1) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ ");
+ SetVersion ($DBversion);
+}
+
=item DropAllForeignKeys($table)
Drop all foreign keys of the table $table
<dd>Create and manage Bibliographic frameworks that define the characteristics of your MARC Records (field and subfield definitions) as well as templates for the MARC editor.</dd>
<dt><a href="/cgi-bin/koha/admin/koha2marclinks.pl">Koha to MARC mapping</a></dt>
<dd>Define the mapping between the Koha transactional database (SQL) and the MARC Bibliographic records. Note that the mapping can be defined through MARC Bibliographic Framework. This tool is just a shortcut to speed up linkage.</dd>
+ <dt><a href="/cgi-bin/koha/admin/fieldmapping.pl">Keywords to MARC mapping</a></dt>
+ <dd>Define the mapping between keywords and MARC fields, those keywords are used to find some datas independently of the framework.</dd>
<dt><a href="/cgi-bin/koha/admin/checkmarc.pl">MARC Bibliographic framework test</a></dt>
<dd>Checks the MARC structure. If you change your MARC Bibliographic framework it's recommended that you run this tool to test for errors in your definition.</dd>
<dt><a href="/cgi-bin/koha/admin/authtypes.pl">Authority types</a></dt>