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

(-)a/installer/data/mysql/updatedatabase.pl (-15 / +26 lines)
Lines 15054-15082 $DBversion = "XXX"; Link Here
15054
if ( CheckVersion($DBversion) ) {
15054
if ( CheckVersion($DBversion) ) {
15055
    require Koha::Library::Group;
15055
    require Koha::Library::Group;
15056
15056
15057
    my $search_groups_staff_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS__', description => "Library search groups - Staff only" } )->store();
15057
    $dbh->do(q{
15058
    my $search_groups_opac_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS_OPAC__', description => "Library search groups - OPAC & Staff" } )->store();
15058
        INSERT INTO library_groups ( title, description, created_on ) VALUES ( '__SEARCH_GROUPS__', 'Library search groups - Staff only', NOW() )
15059
    });
15060
    my $search_groups_staff_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
15061
15062
    $dbh->do(q{
15063
        INSERT INTO library_groups ( title, description, created_on ) VALUE ( '__SEARCH_GROUPS_OPAC__', 'Library search groups - Staff only', NOW() )
15064
    });
15065
    my $search_groups_opac_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
15059
15066
15060
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
15067
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
15061
    $sth->execute();
15062
15068
15069
    my $sth2 = $dbh->prepare("INSERT INTO library_groups ( parent_id, title, description, created_on ) VALUES ( ?, ?, ?, NOW() )");
15070
15071
    my $sth3 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
15072
15073
    my $sth4 = $dbh->prepare("INSERT INTO library_groups ( parent_id, branchcode, created_on ) VALUES ( ?, ?, NOW() )");
15074
15075
    $sth->execute();
15063
    while ( my $lc = $sth->fetchrow_hashref ) {
15076
    while ( my $lc = $sth->fetchrow_hashref ) {
15064
        my $description = $lc->{categorycode};
15077
        my $description = $lc->{categorycode};
15065
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
15078
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
15066
15079
15067
        my $subgroup = Koha::Library::Group->new(
15080
        $sth2->execute(
15068
            {
15081
            $lc->{show_in_pulldown} ? $search_groups_opac_root_id : $search_groups_staff_root_id,
15069
                parent_id   => $lc->{show_in_pulldown} ? $search_groups_opac_root->id : $search_groups_staff_root->id,
15082
            $lc->{categoryname},
15070
                title       => $lc->{categoryname},
15083
            $description,
15071
                description => $description,
15084
        );
15072
            }
15085
15073
        )->store();
15086
        my $subgroup_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
15074
15087
15075
        my $sth2 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
15088
        $sth3->execute( $lc->{categorycode} );
15076
        $sth2->execute( $lc->{categorycode} );
15077
15089
15078
        while ( my $l = $sth2->fetchrow_hashref ) {
15090
        while ( my $l = $sth3->fetchrow_hashref ) {
15079
            Koha::Library::Group->new( { parent_id => $subgroup->id, branchcode => $l->{branchcode} } )->store();
15091
            $sth4->execute( $subgroup_id, $l->{branchcode} );
15080
        }
15092
        }
15081
    }
15093
    }
15082
15094
15083
- 

Return to bug 16735