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

(-)a/Koha/Hold.pm (+18 lines)
Lines 200-205 sub cleanup_hold_group { Link Here
200
    }
200
    }
201
}
201
}
202
202
203
=head3 is_hold_group_target
204
205
$self->is_hold_group_target;
206
207
Returns whether this hold is its hold group target
208
209
=cut
210
211
sub is_hold_group_target {
212
    my ($self) = @_;
213
214
    return 1
215
        if $self->hold_group
216
        && $self->hold_group->target_hold_id
217
        && $self->hold_group->target_hold_id eq $self->reserve_id;
218
    return 0;
219
}
220
203
=head3 set_transfer
221
=head3 set_transfer
204
222
205
=cut
223
=cut
(-)a/Koha/HoldGroup.pm (+16 lines)
Lines 78-83 sub holds { Link Here
78
    return Koha::Holds->_new_from_dbic($holds_rs);
78
    return Koha::Holds->_new_from_dbic($holds_rs);
79
}
79
}
80
80
81
=head3 target_hold_id
82
83
    $holds = $hold_group->target_hold_id
84
85
Return the target_hold_id
86
87
=cut
88
89
sub target_hold_id {
90
    my ($self) = @_;
91
92
    return unless $self->_result->hold_group_target_hold;
93
94
    return $self->_result->hold_group_target_hold->reserve_id;
95
}
96
81
=head3 _type
97
=head3 _type
82
98
83
=cut
99
=cut
(-)a/Koha/Schema/Result/HoldGroup.pm (-2 / +17 lines)
Lines 95-100 __PACKAGE__->belongs_to( Link Here
95
  },
95
  },
96
);
96
);
97
97
98
=head2 hold_group_target_hold
99
100
Type: might_have
101
102
Related object: L<Koha::Schema::Result::HoldGroupTargetHold>
103
104
=cut
105
106
__PACKAGE__->might_have(
107
  "hold_group_target_hold",
108
  "Koha::Schema::Result::HoldGroupTargetHold",
109
  { "foreign.hold_group_id" => "self.hold_group_id" },
110
  { cascade_copy => 0, cascade_delete => 0 },
111
);
112
98
=head2 old_reserves
113
=head2 old_reserves
99
114
100
Type: has_many
115
Type: has_many
Lines 126-133 __PACKAGE__->has_many( Link Here
126
);
141
);
127
142
128
143
129
# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-07-25 13:02:35
144
# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-07-25 13:10:48
130
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hlAYDHvqpFZRpNU+d+y4RA
145
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3CiPWMgltRazKxPlIb5x3g
131
146
132
147
133
# You can replace this text with custom code or comments, and it will be preserved on regeneration
148
# You can replace this text with custom code or comments, and it will be preserved on regeneration
(-)a/Koha/Schema/Result/HoldGroupTargetHold.pm (+126 lines)
Line 0 Link Here
1
use utf8;
2
package Koha::Schema::Result::HoldGroupTargetHold;
3
4
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7
=head1 NAME
8
9
Koha::Schema::Result::HoldGroupTargetHold
10
11
=cut
12
13
use strict;
14
use warnings;
15
16
use base 'DBIx::Class::Core';
17
18
=head1 TABLE: C<hold_group_target_holds>
19
20
=cut
21
22
__PACKAGE__->table("hold_group_target_holds");
23
24
=head1 ACCESSORS
25
26
=head2 hold_group_id
27
28
  data_type: 'integer'
29
  extra: {unsigned => 1}
30
  is_foreign_key: 1
31
  is_nullable: 0
32
33
foreign key, linking this to the hold_groups table
34
35
=head2 reserve_id
36
37
  data_type: 'integer'
38
  is_foreign_key: 1
39
  is_nullable: 1
40
41
foreign key, linking this to the reserves table
42
43
=cut
44
45
__PACKAGE__->add_columns(
46
  "hold_group_id",
47
  {
48
    data_type => "integer",
49
    extra => { unsigned => 1 },
50
    is_foreign_key => 1,
51
    is_nullable => 0,
52
  },
53
  "reserve_id",
54
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
55
);
56
57
=head1 UNIQUE CONSTRAINTS
58
59
=head2 C<hold_group_id>
60
61
=over 4
62
63
=item * L</hold_group_id>
64
65
=back
66
67
=cut
68
69
__PACKAGE__->add_unique_constraint("hold_group_id", ["hold_group_id"]);
70
71
=head2 C<reserve_id>
72
73
=over 4
74
75
=item * L</reserve_id>
76
77
=back
78
79
=cut
80
81
__PACKAGE__->add_unique_constraint("reserve_id", ["reserve_id"]);
82
83
=head1 RELATIONS
84
85
=head2 hold_group
86
87
Type: belongs_to
88
89
Related object: L<Koha::Schema::Result::HoldGroup>
90
91
=cut
92
93
__PACKAGE__->belongs_to(
94
  "hold_group",
95
  "Koha::Schema::Result::HoldGroup",
96
  { hold_group_id => "hold_group_id" },
97
  { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" },
98
);
99
100
=head2 reserve
101
102
Type: belongs_to
103
104
Related object: L<Koha::Schema::Result::Reserve>
105
106
=cut
107
108
__PACKAGE__->belongs_to(
109
  "reserve",
110
  "Koha::Schema::Result::Reserve",
111
  { reserve_id => "reserve_id" },
112
  {
113
    is_deferrable => 1,
114
    join_type     => "LEFT",
115
    on_delete     => "CASCADE",
116
    on_update     => "RESTRICT",
117
  },
118
);
119
120
121
# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-07-25 13:10:48
122
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xgRnzTXH+Q+YxYLKQeGe+g
123
124
125
# You can replace this text with custom code or comments, and it will be preserved on regeneration
126
1;
(-)a/Koha/Schema/Result/Reserve.pm (-2 / +17 lines)
Lines 440-445 __PACKAGE__->belongs_to( Link Here
440
  },
440
  },
441
);
441
);
442
442
443
=head2 hold_group_target_hold
444
445
Type: might_have
446
447
Related object: L<Koha::Schema::Result::HoldGroupTargetHold>
448
449
=cut
450
451
__PACKAGE__->might_have(
452
  "hold_group_target_hold",
453
  "Koha::Schema::Result::HoldGroupTargetHold",
454
  { "foreign.reserve_id" => "self.reserve_id" },
455
  { cascade_copy => 0, cascade_delete => 0 },
456
);
457
443
=head2 item_group
458
=head2 item_group
444
459
445
Type: belongs_to
460
Type: belongs_to
Lines 501-508 __PACKAGE__->belongs_to( Link Here
501
);
516
);
502
517
503
518
504
# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-07-25 13:02:35
519
# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-07-25 13:10:48
505
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:x5AS7F7aOMb9ihb8gaxZvQ
520
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hipLVZ6zkbJZha+kYRMslQ
506
521
507
__PACKAGE__->belongs_to(
522
__PACKAGE__->belongs_to(
508
  "item",
523
  "item",
(-)a/api/v1/swagger/definitions/hold_group.yaml (+3 lines)
Lines 10-15 properties: Link Here
10
  visual_hold_group_id:
10
  visual_hold_group_id:
11
    type: integer
11
    type: integer
12
    description: Visual ID for this hold group, in the context of the related patron
12
    description: Visual ID for this hold group, in the context of the related patron
13
  target_hold_id:
14
    type: integer
15
    description: Target hold ID of this hold group
13
  holds:
16
  holds:
14
    type:
17
    type:
15
      - array
18
      - array
(-)a/installer/data/mysql/atomicupdate/bug_40529_-_hold_group_table_target.pl (+25 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "40529",
6
    description => "Add 'hold_groups_target_hold_id' column to hold_groups",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        unless ( TableExists('hold_group_target_holds') ) {
12
            $dbh->do(
13
                q{
14
                    CREATE TABLE hold_group_target_holds (
15
                        `hold_group_id` int unsigned NOT NULL UNIQUE 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',
17
                        CONSTRAINT `hold_group_target_holds_ibfk_1` FOREIGN KEY (`hold_group_id`) REFERENCES `hold_groups` (`hold_group_id`) ON DELETE CASCADE,
18
                        CONSTRAINT `hold_group_target_holds_ibfk_2` FOREIGN KEY (`reserve_id`) REFERENCES `reserves` (`reserve_id`) ON DELETE CASCADE
19
                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
20
                }
21
            );
22
            say_success( $out, "Added table 'hold_group_target_holds'" );
23
        }
24
    },
25
};
(-)a/installer/data/mysql/kohastructure.sql (+14 lines)
Lines 5074-5079 CREATE TABLE hold_groups ( Link Here
5074
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5074
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5075
/*!40101 SET character_set_client = @saved_cs_client */;
5075
/*!40101 SET character_set_client = @saved_cs_client */;
5076
5076
5077
--
5078
-- Table structure for table `hold_group_target_holds`
5079
--
5080
DROP TABLE IF EXISTS `hold_group_target_holds`;
5081
/*!40101 SET @saved_cs_client     = @@character_set_client */;
5082
/*!40101 SET character_set_client = utf8 */;
5083
CREATE TABLE hold_group_target_holds (
5084
    `hold_group_id` int unsigned NOT NULL UNIQUE COMMENT 'foreign key, linking this to the hold_groups table',
5085
    `reserve_id` int(11) DEFAULT NULL UNIQUE COMMENT 'foreign key, linking this to the reserves table',
5086
    CONSTRAINT `hold_group_target_holds_ibfk_1` FOREIGN KEY (`hold_group_id`) REFERENCES `hold_groups` (`hold_group_id`) ON DELETE CASCADE,
5087
    CONSTRAINT `hold_group_target_holds_ibfk_2` FOREIGN KEY (`reserve_id`) REFERENCES `reserves` (`reserve_id`) ON DELETE CASCADE
5088
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
5089
/*!40101 SET character_set_client = @saved_cs_client */;
5090
5077
--
5091
--
5078
-- Table structure for table `old_reserves`
5092
-- Table structure for table `old_reserves`
5079
--
5093
--
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (+8 lines)
Lines 259-264 $(document).ready(function () { Link Here
259
                                        "</span>";
259
                                        "</span>";
260
                                }
260
                                }
261
261
262
                                if (oObj.is_hold_group_target) {
263
                                    var link = __("target of hold group");
264
                                    title +=
265
                                        '<br><span class="fw-bold fst-italic">(' +
266
                                        link +
267
                                        ")</span>";
268
                                }
269
262
                                return title;
270
                                return title;
263
                            },
271
                            },
264
                        },
272
                        },
(-)a/svc/holds (-1 / +1 lines)
Lines 115-120 while ( my $h = $holds_rs->next() ) { Link Here
115
        itemtype_limit        => $itemtype_limit,
115
        itemtype_limit        => $itemtype_limit,
116
        hold_group_id         => $h->hold_group_id,
116
        hold_group_id         => $h->hold_group_id,
117
        visual_hold_group_id  => $h->hold_group ? $h->hold_group->visual_hold_group_id : q{},
117
        visual_hold_group_id  => $h->hold_group ? $h->hold_group->visual_hold_group_id : q{},
118
        is_hold_group_target  => $h->is_hold_group_target,
118
        reservedate_formatted => $h->reservedate()
119
        reservedate_formatted => $h->reservedate()
119
        ? output_pref( { dt => dt_from_string( $h->reservedate() ), dateonly => 1 } )
120
        ? output_pref( { dt => dt_from_string( $h->reservedate() ), dateonly => 1 } )
120
        : q{},
121
        : q{},
121
- 

Return to bug 40529