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

(-)a/installer/data/mysql/updatedatabase.pl (-15 / +26 lines)
Lines 15181-15209 $DBversion = "XXX"; Link Here
15181
if ( CheckVersion($DBversion) ) {
15181
if ( CheckVersion($DBversion) ) {
15182
    require Koha::Library::Group;
15182
    require Koha::Library::Group;
15183
15183
15184
    my $search_groups_staff_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS__', description => "Library search groups - Staff only" } )->store();
15184
    $dbh->do(q{
15185
    my $search_groups_opac_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS_OPAC__', description => "Library search groups - OPAC & Staff" } )->store();
15185
        INSERT INTO library_groups ( title, description, created_on ) VALUES ( '__SEARCH_GROUPS__', 'Library search groups - Staff only', NOW() )
15186
    });
15187
    my $search_groups_staff_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
15188
15189
    $dbh->do(q{
15190
        INSERT INTO library_groups ( title, description, created_on ) VALUE ( '__SEARCH_GROUPS_OPAC__', 'Library search groups - Staff only', NOW() )
15191
    });
15192
    my $search_groups_opac_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
15186
15193
15187
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
15194
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
15188
    $sth->execute();
15189
15195
15196
    my $sth2 = $dbh->prepare("INSERT INTO library_groups ( parent_id, title, description, created_on ) VALUES ( ?, ?, ?, NOW() )");
15197
15198
    my $sth3 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
15199
15200
    my $sth4 = $dbh->prepare("INSERT INTO library_groups ( parent_id, branchcode, created_on ) VALUES ( ?, ?, NOW() )");
15201
15202
    $sth->execute();
15190
    while ( my $lc = $sth->fetchrow_hashref ) {
15203
    while ( my $lc = $sth->fetchrow_hashref ) {
15191
        my $description = $lc->{categorycode};
15204
        my $description = $lc->{categorycode};
15192
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
15205
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
15193
15206
15194
        my $subgroup = Koha::Library::Group->new(
15207
        $sth2->execute(
15195
            {
15208
            $lc->{show_in_pulldown} ? $search_groups_opac_root_id : $search_groups_staff_root_id,
15196
                parent_id   => $lc->{show_in_pulldown} ? $search_groups_opac_root->id : $search_groups_staff_root->id,
15209
            $lc->{categoryname},
15197
                title       => $lc->{categoryname},
15210
            $description,
15198
                description => $description,
15211
        );
15199
            }
15212
15200
        )->store();
15213
        my $subgroup_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
15201
15214
15202
        my $sth2 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
15215
        $sth3->execute( $lc->{categorycode} );
15203
        $sth2->execute( $lc->{categorycode} );
15204
15216
15205
        while ( my $l = $sth2->fetchrow_hashref ) {
15217
        while ( my $l = $sth3->fetchrow_hashref ) {
15206
            Koha::Library::Group->new( { parent_id => $subgroup->id, branchcode => $l->{branchcode} } )->store();
15218
            $sth4->execute( $subgroup_id, $l->{branchcode} );
15207
        }
15219
        }
15208
    }
15220
    }
15209
15221
15210
- 

Return to bug 16735