[Koha-patches] [PATCH] Analytical record: improved code to create analytical record from an item
LAURENT Henri-Damien
henridamien.laurent at biblibre.com
Wed Nov 10 22:59:43 CET 2010
Le 10/11/2010 19:22, savitra.sirohi at osslabs.biz a écrit :
> From: Amit Gupta <amit.gupta at osslabs.biz>
>
> ---
> cataloguing/addbiblio.pl | 57 ++++++-------------
> .../prog/en/modules/cataloguing/addbiblio.tmpl | 2 +-
> 2 files changed, 19 insertions(+), 40 deletions(-)
>
> diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl
> index 4e56fad..28aad1f 100755
> --- a/cataloguing/addbiblio.pl
> +++ b/cataloguing/addbiblio.pl
> @@ -346,8 +346,6 @@ sub create_input {
> );
> # always expand all subfields of a mandatory field
> $subfield_data{visibility} = "" if $tagslib->{$tag}->{mandatory};
> - # expand all subfields of 773 if there is a host item provided in the input
> - $subfield_data{visibility} ="" if ($tag eq 773 and $cgi->param('hostitemnumber'));
> # it's an authorised field
> if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
> $subfield_data{marc_value} =
> @@ -679,14 +677,6 @@ sub build_tabs ($$$$$) {
> # if breeding is empty
> }
> else {
> - my $hostbiblionumber;
> - my $hostitemnumber;
> - my $hostrecord;
> - if ($tag eq 773){
> - $hostbiblionumber = $input->param('hostbiblionumber');
> - $hostitemnumber = $input->param('hostitemnumber');
> - $hostrecord = &GetMarcBiblio($hostbiblionumber);
> - }
> my @subfields_data;
> foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) ) {
> next if ( length $subfield != 1 );
> @@ -703,35 +693,6 @@ sub build_tabs ($$$$$) {
> # always include in the form regardless of the hidden setting - bug 2206
> next
> if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
> - if ( $tag eq 773 and $hostbiblionumber){
> - if ($subfield eq "w"){
> - push(
> - @subfields_data,
> - &create_input(
> - $tag, $subfield,$hostbiblionumber, $index_tag, $tabloop, $record,
> - $authorised_values_sth,$input
> - ));
> - next;
> - }
> - if ($subfield eq "a"){
> - push(
> - @subfields_data,
> - &create_input(
> - $tag, $subfield,$hostrecord->subfield('245',"a"), $index_tag, $tabloop, $record,
> - $authorised_values_sth,$input
> - ));
> - next;
> - }
> - if ($subfield eq "o"){
> - push(
> - @subfields_data,
> - &create_input(
> - $tag, $subfield,$hostitemnumber, $index_tag, $tabloop, $record,
> - $authorised_values_sth,$input
> - ));
> - next;
> - }
> - }
> push(
> @subfields_data,
> &create_input(
> @@ -870,6 +831,8 @@ my $mode = $input->param('mode');
> my $frameworkcode = $input->param('frameworkcode');
> my $redirect = $input->param('redirect');
> my $dbh = C4::Context->dbh;
> +my $hostbiblionumber = $input->param('hostbiblionumber');
> +my $hostitemnumber = $input->param('hostitemnumber');
>
> my $userflags = ($frameworkcode eq 'FA') ? "fast_cataloging" : "edit_catalogue";
>
> @@ -927,6 +890,20 @@ if (($biblionumber) && !($breedingid)){
> if ($breedingid) {
> ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
> }
> +#populate 773 if hostbiblionumber is available
> +if ($hostbiblionumber){
> + my $hostrecord = &GetMarcBiblio($hostbiblionumber);
> + $record=MARC::Record->new();
> + $record->leader('');
> + my $field = MARC::Field->new(
> + 773, '', '',
> + 'w' => $hostbiblionumber,
> + 'o' => $hostitemnumber,
> + 'a' => $hostrecord->subfield('245','a'),
> + 'x' => $hostrecord->subfield('245','x')
This is marc21 only.
Could you be so kind as to at least use some variables ?
Or create the variable and then populate it ?
> + );
> + $record->append_fields($field);
> +}
>
> $is_a_modif = 0;
>
> @@ -1053,6 +1030,8 @@ elsif ( $op eq "delete" ) {
> biblioitemnumtagfield => $biblioitemnumtagfield,
> biblioitemnumtagsubfield => $biblioitemnumtagsubfield,
> biblioitemnumber => $biblioitemnumber,
> + hostbiblionumber => $hostbiblionumber,
> + hostitemnumber => $hostitemnumber
> );
> }
>
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl
> index 3e510c5..86905ad 100644
> --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tmpl
> @@ -195,7 +195,7 @@ function GetZ3950Terms(){
>
> function Changefwk(FwkList) {
> var fwk = FwkList.options[FwkList.selectedIndex].value;
> - window.location = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!--TMPL_VAR Name="biblionumber"-->&breedingid=<!-- TMPL_VAR name="breedingid" -->&frameworkcode="+fwk;
> + window.location = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!--TMPL_VAR Name="biblionumber"-->&breedingid=<!-- TMPL_VAR name="breedingid" -->&hostbiblionumber=<!-- TMPL_VAR Name="hostbiblionumber" -->&hostitemnumber=<!--TMPL_VAR Name="hostitemnumber" -->&frameworkcode="+fwk;
>
> }
>
More information about the Koha-patches
mailing list