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

(-)a/installer/data/mysql/updatedatabase.pl (-15 / +26 lines)
Lines 14599-14627 $DBversion = "XXX"; Link Here
14599
if ( CheckVersion($DBversion) ) {
14599
if ( CheckVersion($DBversion) ) {
14600
    require Koha::Library::Group;
14600
    require Koha::Library::Group;
14601
14601
14602
    my $search_groups_staff_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS__', description => "Library search groups - Staff only" } )->store();
14602
    $dbh->do(q{
14603
    my $search_groups_opac_root = Koha::Library::Group->new( { title => '__SEARCH_GROUPS_OPAC__', description => "Library search groups - OPAC & Staff" } )->store();
14603
        INSERT INTO library_groups ( title, description, created_on ) VALUES ( '__SEARCH_GROUPS__', 'Library search groups - Staff only', NOW() )
14604
    });
14605
    my $search_groups_staff_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
14606
14607
    $dbh->do(q{
14608
        INSERT INTO library_groups ( title, description, created_on ) VALUE ( '__SEARCH_GROUPS_OPAC__', 'Library search groups - Staff only', NOW() )
14609
    });
14610
    my $search_groups_opac_root_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
14604
14611
14605
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
14612
    my $sth = $dbh->prepare("SELECT * FROM branchcategories");
14606
    $sth->execute();
14607
14613
14614
    my $sth2 = $dbh->prepare("INSERT INTO library_groups ( parent_id, title, description, created_on ) VALUES ( ?, ?, ?, NOW() )");
14615
14616
    my $sth3 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
14617
14618
    my $sth4 = $dbh->prepare("INSERT INTO library_groups ( parent_id, branchcode, created_on ) VALUES ( ?, ?, NOW() )");
14619
14620
    $sth->execute();
14608
    while ( my $lc = $sth->fetchrow_hashref ) {
14621
    while ( my $lc = $sth->fetchrow_hashref ) {
14609
        my $description = $lc->{categorycode};
14622
        my $description = $lc->{categorycode};
14610
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
14623
        $description .= " - " . $lc->{codedescription} if $lc->{codedescription};
14611
14624
14612
        my $subgroup = Koha::Library::Group->new(
14625
        $sth2->execute(
14613
            {
14626
            $lc->{show_in_pulldown} ? $search_groups_opac_root_id : $search_groups_staff_root_id,
14614
                parent_id   => $lc->{show_in_pulldown} ? $search_groups_opac_root->id : $search_groups_staff_root->id,
14627
            $lc->{categoryname},
14615
                title       => $lc->{categoryname},
14628
            $description,
14616
                description => $description,
14629
        );
14617
            }
14630
14618
        )->store();
14631
        my $subgroup_id = $dbh->last_insert_id(undef, undef, 'library_groups', undef);
14619
14632
14620
        my $sth2 = $dbh->prepare("SELECT * FROM branchrelations WHERE categorycode = ?");
14633
        $sth3->execute( $lc->{categorycode} );
14621
        $sth2->execute( $lc->{categorycode} );
14622
14634
14623
        while ( my $l = $sth2->fetchrow_hashref ) {
14635
        while ( my $l = $sth3->fetchrow_hashref ) {
14624
            Koha::Library::Group->new( { parent_id => $subgroup->id, branchcode => $l->{branchcode} } )->store();
14636
            $sth4->execute( $subgroup_id, $l->{branchcode} );
14625
        }
14637
        }
14626
    }
14638
    }
14627
14639
14628
- 

Return to bug 16735