View | Details | Raw Unified | Return to bug 16735
Collapse All | Expand All

(-)a/installer/data/mysql/updatedatabase.pl (-15 / +26 lines)
Lines 13911-13939 $DBversion = "XXX"; Link Here
13911
if ( CheckVersion($DBversion) ) {
13911
if ( CheckVersion($DBversion) ) {
13912
    require Koha::Library::Group;
13912
    require Koha::Library::Group;
13913
13913
13914
    my $search_groups_staff_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS__', description => "Library search groups - Staff only" } )->store();
13914
    $dbh->do(q{
13915
    my $search_groups_opac_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS_OPAC__', description => "Library search groups - OPAC & Staff" } )->store();
13915
        INSERT INTO library_groups ( title, description, created_on ) VALUES ( '__SEARCH_GROUPS__', 'Library search groups - Staff only', NOW() )
13916
    });
13917
    my $search_groups_staff_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
13918
13919
    $dbh->do(q{
13920
        INSERT INTO library_groups ( title, description, created_on ) VALUE ( '__SEARCH_GROUPS_OPAC__', 'Library search groups - Staff only', NOW() )
13921
    });
13922
    my $search_groups_opac_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
13916
13923
13917
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
13924
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
13918
    $sth->execute();
13919
13925
13926
    my $sth2 = $dbh->prepare("INSERT INTO library_groups ( parent_id, title, description, created_on ) VALUES ( ?, ?, ?, NOW() )");
13927
13928
    my $sth3 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
13929
13930
    my $sth4 = $dbh->prepare("INSERT INTO library_groups ( parent_id, branchcode, created_on ) VALUES ( ?, ?, NOW() )");
13931
13932
    $sth->execute();
13920
    while ( my $lc = $sth->fetchrow_hashref ) {
13933
    while ( my $lc = $sth->fetchrow_hashref ) {
13921
        my $description = $lc->{categorycode};
13934
        my $description = $lc->{categorycode};
13922
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
13935
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
13923
13936
13924
        my $subgroup = Koha::Library::Group->new(
13937
        $sth2->execute(
13925
            {
13938
            $lc->{show_in_pulldown} ? $search_groups_opac_root_id : $search_groups_staff_root_id,
13926
                parent_id   => $lc->{show_in_pulldown} ? $search_groups_opac_root->id : $search_groups_staff_root->id,
13939
            $lc->{categoryname},
13927
                title       => $lc->{categoryname},
13940
            $description,
13928
                description => $description,
13941
        );
13929
            }
13942
13930
        )->store();
13943
        my $subgroup_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
13931
13944
13932
        my $sth2 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
13945
        $sth3->execute( $lc->{categorycode} );
13933
        $sth2->execute( $lc->{categorycode} );
13934
13946
13935
        while ( my $l = $sth2->fetchrow_hashref ) {
13947
        while ( my $l = $sth3->fetchrow_hashref ) {
13936
            Koha::Library::Group->new( { parent_id => $subgroup->id, branchcode => $l->{branchcode} } )->store();
13948
            $sth4->execute( $subgroup_id, $l->{branchcode} );
13937
        }
13949
        }
13938
    }
13950
    }
13939
13951
13940
- 

Return to bug 16735