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

(-)a/installer/data/mysql/updatedatabase.pl (-15 / +26 lines)
Lines 13930-13958 $DBversion = "XXX"; Link Here
13930
if ( CheckVersion($DBversion) ) {
13930
if ( CheckVersion($DBversion) ) {
13931
    require Koha::Library::Group;
13931
    require Koha::Library::Group;
13932
13932
13933
    my $search_groups_staff_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS__', description => "Library search groups - Staff only" } )->store();
13933
    $dbh->do(q{
13934
    my $search_groups_opac_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS_OPAC__', description => "Library search groups - OPAC & Staff" } )->store();
13934
        INSERT INTO library_groups ( title, description, created_on ) VALUES ( '__SEARCH_GROUPS__', 'Library search groups - Staff only', NOW() )
13935
    });
13936
    my $search_groups_staff_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
13937
13938
    $dbh->do(q{
13939
        INSERT INTO library_groups ( title, description, created_on ) VALUE ( '__SEARCH_GROUPS_OPAC__', 'Library search groups - Staff only', NOW() )
13940
    });
13941
    my $search_groups_opac_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
13935
13942
13936
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
13943
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
13937
    $sth->execute();
13938
13944
13945
    my $sth2 = $dbh->prepare("INSERT INTO library_groups ( parent_id, title, description, created_on ) VALUES ( ?, ?, ?, NOW() )");
13946
13947
    my $sth3 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
13948
13949
    my $sth4 = $dbh->prepare("INSERT INTO library_groups ( parent_id, branchcode, created_on ) VALUES ( ?, ?, NOW() )");
13950
13951
    $sth->execute();
13939
    while ( my $lc = $sth->fetchrow_hashref ) {
13952
    while ( my $lc = $sth->fetchrow_hashref ) {
13940
        my $description = $lc->{categorycode};
13953
        my $description = $lc->{categorycode};
13941
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
13954
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
13942
13955
13943
        my $subgroup = Koha::Library::Group->new(
13956
        $sth2->execute(
13944
            {
13957
            $lc->{show_in_pulldown} ? $search_groups_opac_root_id : $search_groups_staff_root_id,
13945
                parent_id   => $lc->{show_in_pulldown} ? $search_groups_opac_root->id : $search_groups_staff_root->id,
13958
            $lc->{categoryname},
13946
                title       => $lc->{categoryname},
13959
            $description,
13947
                description => $description,
13960
        );
13948
            }
13961
13949
        )->store();
13962
        my $subgroup_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
13950
13963
13951
        my $sth2 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
13964
        $sth3->execute( $lc->{categorycode} );
13952
        $sth2->execute( $lc->{categorycode} );
13953
13965
13954
        while ( my $l = $sth2->fetchrow_hashref ) {
13966
        while ( my $l = $sth3->fetchrow_hashref ) {
13955
            Koha::Library::Group->new( { parent_id => $subgroup->id, branchcode => $l->{branchcode} } )->store();
13967
            $sth4->execute( $subgroup_id, $l->{branchcode} );
13956
        }
13968
        }
13957
    }
13969
    }
13958
13970
13959
- 

Return to bug 16735