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

(-)a/Koha/Hold.pm (-2 / +2 lines)
Lines 284-290 sub set_as_hold_group_target { Link Here
284
284
285
    if ( $self->hold_group && !$self->hold_group->target_hold_id && C4::Context->preference("DisplayAddHoldGroups") ) {
285
    if ( $self->hold_group && !$self->hold_group->target_hold_id && C4::Context->preference("DisplayAddHoldGroups") ) {
286
        $self->_result->create_related(
286
        $self->_result->create_related(
287
            'hold_group_target_hold',
287
            'hold_groups_target_hold',
288
            { hold_group_id => $self->hold_group->hold_group_id }
288
            { hold_group_id => $self->hold_group->hold_group_id }
289
        );
289
        );
290
    }
290
    }
Lines 308-314 sub remove_as_hold_group_target { Link Here
308
        && C4::Context->preference("DisplayAddHoldGroups") )
308
        && C4::Context->preference("DisplayAddHoldGroups") )
309
    {
309
    {
310
        $self->_result->find_related(
310
        $self->_result->find_related(
311
            'hold_group_target_hold',
311
            'hold_groups_target_hold',
312
            { hold_group_id => $self->hold_group->hold_group_id, reserve_id => $self->reserve_id }
312
            { hold_group_id => $self->hold_group->hold_group_id, reserve_id => $self->reserve_id }
313
        )->delete();
313
        )->delete();
314
    }
314
    }
(-)a/Koha/HoldGroup.pm (-4 / +4 lines)
Lines 89-97 Return the target_hold_id Link Here
89
sub target_hold_id {
89
sub target_hold_id {
90
    my ($self) = @_;
90
    my ($self) = @_;
91
91
92
    return unless $self->_result->hold_group_target_hold;
92
    return unless $self->_result->hold_groups_target_hold;
93
93
94
    return $self->_result->hold_group_target_hold->reserve_id;
94
    return $self->_result->hold_groups_target_hold->reserve_id;
95
}
95
}
96
96
97
=head3 skip_non_target_holds_query
97
=head3 skip_non_target_holds_query
Lines 116-127 sub skip_non_target_holds_query { Link Here
116
                -and => { '!=' => undef },
116
                -and => { '!=' => undef },
117
                {
117
                {
118
                    -not_in => \
118
                    -not_in => \
119
                        'SELECT hold_group_id FROM hold_group_target_holds WHERE reserve_id IS NOT NULL AND reserve_id != me.reserve_id'
119
                        'SELECT hold_group_id FROM hold_groups_target_holds WHERE reserve_id IS NOT NULL AND reserve_id != me.reserve_id'
120
                }
120
                }
121
            ]
121
            ]
122
        ],
122
        ],
123
        'sql' =>
123
        'sql' =>
124
            'AND (hold_group_id IS NULL OR reserves.hold_group_id NOT IN (SELECT hold_group_id FROM hold_group_target_holds WHERE reserve_id IS NOT NULL AND reserve_id != reserves.reserve_id))'
124
            'AND (hold_group_id IS NULL OR reserves.hold_group_id NOT IN (SELECT hold_group_id FROM hold_groups_target_holds WHERE reserve_id IS NOT NULL AND reserve_id != reserves.reserve_id))'
125
    };
125
    };
126
126
127
    return unless $query_type && exists $query_types->{$query_type};
127
    return unless $query_type && exists $query_types->{$query_type};
(-)a/installer/data/mysql/atomicupdate/bug_40529_-_hold_group_table_target.pl (-6 / +8 lines)
Lines 8-26 return { Link Here
8
        my ($args) = @_;
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
10
11
        unless ( TableExists('hold_group_target_holds') ) {
11
        unless ( TableExists('hold_groups_target_holds') ) {
12
            $dbh->do(
12
            $dbh->do(
13
                q{
13
                q{
14
                    CREATE TABLE hold_group_target_holds (
14
                    CREATE TABLE `hold_groups_target_holds` (
15
                        `hold_group_id` int unsigned NOT NULL UNIQUE COMMENT 'foreign key, linking this to the hold_groups table',
15
                        `hold_group_id` int(10) unsigned NOT NULL COMMENT 'foreign key, linking this to the hold_groups table',
16
                        `reserve_id` int(11) DEFAULT NULL UNIQUE COMMENT 'foreign key, linking this to the reserves table',
16
                        `reserve_id` int(11) NOT NULL COMMENT 'foreign key, linking this to the reserves table',
17
                        PRIMARY KEY (`hold_group_id`, `reserve_id`),
17
                        PRIMARY KEY (`hold_group_id`,`reserve_id`),
18
                        UNIQUE KEY `uq_hold_group_target_holds_hold_group_id` (`hold_group_id`),
19
                        UNIQUE KEY `uq_hold_group_target_holds_reserve_id` (`reserve_id`),
18
                        CONSTRAINT `hold_group_target_holds_ibfk_1` FOREIGN KEY (`hold_group_id`) REFERENCES `hold_groups` (`hold_group_id`) ON DELETE CASCADE,
20
                        CONSTRAINT `hold_group_target_holds_ibfk_1` FOREIGN KEY (`hold_group_id`) REFERENCES `hold_groups` (`hold_group_id`) ON DELETE CASCADE,
19
                        CONSTRAINT `hold_group_target_holds_ibfk_2` FOREIGN KEY (`reserve_id`) REFERENCES `reserves` (`reserve_id`) ON DELETE CASCADE
21
                        CONSTRAINT `hold_group_target_holds_ibfk_2` FOREIGN KEY (`reserve_id`) REFERENCES `reserves` (`reserve_id`) ON DELETE CASCADE
20
                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
22
                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
21
                }
23
                }
22
            );
24
            );
23
            say_success( $out, "Added table 'hold_group_target_holds'" );
25
            say_success( $out, "Added table 'hold_groups_target_holds'" );
24
        }
26
        }
25
    },
27
    },
26
};
28
};
(-)a/installer/data/mysql/kohastructure.sql (-16 / +18 lines)
Lines 3560-3565 CREATE TABLE `hold_groups` ( Link Here
3560
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3560
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3561
/*!40101 SET character_set_client = @saved_cs_client */;
3561
/*!40101 SET character_set_client = @saved_cs_client */;
3562
3562
3563
--
3564
-- Table structure for table `hold_groups_target_holds`
3565
--
3566
3567
DROP TABLE IF EXISTS `hold_groups_target_holds`;
3568
/*!40101 SET @saved_cs_client     = @@character_set_client */;
3569
/*!40101 SET character_set_client = utf8mb4 */;
3570
CREATE TABLE `hold_groups_target_holds` (
3571
  `hold_group_id` int(10) unsigned NOT NULL COMMENT 'foreign key, linking this to the hold_groups table',
3572
  `reserve_id` int(11) NOT NULL COMMENT 'foreign key, linking this to the reserves table',
3573
  PRIMARY KEY (`hold_group_id`,`reserve_id`),
3574
  UNIQUE KEY `uq_hold_group_target_holds_hold_group_id` (`hold_group_id`),
3575
  UNIQUE KEY `uq_hold_group_target_holds_reserve_id` (`reserve_id`),
3576
  CONSTRAINT `hold_group_target_holds_ibfk_1` FOREIGN KEY (`hold_group_id`) REFERENCES `hold_groups` (`hold_group_id`) ON DELETE CASCADE,
3577
  CONSTRAINT `hold_group_target_holds_ibfk_2` FOREIGN KEY (`reserve_id`) REFERENCES `reserves` (`reserve_id`) ON DELETE CASCADE
3578
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3579
/*!40101 SET character_set_client = @saved_cs_client */;
3580
3563
--
3581
--
3564
-- Table structure for table `housebound_profile`
3582
-- Table structure for table `housebound_profile`
3565
--
3583
--
Lines 5113-5133 CREATE TABLE `old_issues` ( Link Here
5113
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5131
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5114
/*!40101 SET character_set_client = @saved_cs_client */;
5132
/*!40101 SET character_set_client = @saved_cs_client */;
5115
5133
5116
--
5117
-- Table structure for table `hold_group_target_holds`
5118
--
5119
DROP TABLE IF EXISTS `hold_group_target_holds`;
5120
/*!40101 SET @saved_cs_client     = @@character_set_client */;
5121
/*!40101 SET character_set_client = utf8 */;
5122
CREATE TABLE hold_group_target_holds (
5123
    `hold_group_id` int unsigned NOT NULL UNIQUE COMMENT 'foreign key, linking this to the hold_groups table',
5124
    `reserve_id` int(11) DEFAULT NULL UNIQUE COMMENT 'foreign key, linking this to the reserves table',
5125
    PRIMARY KEY (`hold_group_id`, `reserve_id`),
5126
    CONSTRAINT `hold_group_target_holds_ibfk_1` FOREIGN KEY (`hold_group_id`) REFERENCES `hold_groups` (`hold_group_id`) ON DELETE CASCADE,
5127
    CONSTRAINT `hold_group_target_holds_ibfk_2` FOREIGN KEY (`reserve_id`) REFERENCES `reserves` (`reserve_id`) ON DELETE CASCADE
5128
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5129
/*!40101 SET character_set_client = @saved_cs_client */;
5130
5131
--
5134
--
5132
-- Table structure for table `old_reserves`
5135
-- Table structure for table `old_reserves`
5133
--
5136
--
5134
- 

Return to bug 40529