+
+output_html_with_http_headers $input, $cookie, $template->output;
+
+#
+# the sub used for searches
+#
+sub StringSearch {
+ my ($searchstring,$frameworkcode)=@_;
+ my $sth = C4::Context->dbh->prepare("
+ SELECT tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value
+ FROM marc_tag_structure
+ WHERE (tagfield >= ? and frameworkcode=?)
+ ORDER BY tagfield
+ ");
+ $sth->execute($searchstring, $frameworkcode);
+ my $results = $sth->fetchall_arrayref({});
+ return (scalar(@$results), $results);
+}
+
+#
+# the sub used to duplicate a framework from an existing one in MARC parameters tables.
+#
+sub duplicate_framework {
+ my ($newframeworkcode,$oldframeworkcode) = @_;
+ my $dbh = C4::Context->dbh;
+ my $sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where frameworkcode=?");
+ $sth->execute($oldframeworkcode);
+ my $sth_insert = $dbh->prepare("insert into marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) values (?,?,?,?,?,?,?)");
+ while ( my ($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value) = $sth->fetchrow) {
+ $sth_insert->execute($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value,$newframeworkcode);
+ }
+
+ $sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden from marc_subfield_structure where frameworkcode=?");
+ $sth->execute($oldframeworkcode);
+ $sth_insert = $dbh->prepare("insert into marc_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
+ while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso,$hidden) = $sth->fetchrow) {
+ $sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso, $hidden);
+ }
+}
+