Bug 36687: DBIC schema update
[koha.git] / Koha / Schema / Result / Itemtype.pm
1 use utf8;
2 package Koha::Schema::Result::Itemtype;
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::Itemtype
10
11 =cut
12
13 use strict;
14 use warnings;
15
16 use base 'DBIx::Class::Core';
17
18 =head1 TABLE: C<itemtypes>
19
20 =cut
21
22 __PACKAGE__->table("itemtypes");
23
24 =head1 ACCESSORS
25
26 =head2 itemtype
27
28   data_type: 'varchar'
29   default_value: (empty string)
30   is_nullable: 0
31   size: 10
32
33 unique key, a code associated with the item type
34
35 =head2 parent_type
36
37   data_type: 'varchar'
38   is_foreign_key: 1
39   is_nullable: 1
40   size: 10
41
42 unique key, a code associated with the item type
43
44 =head2 description
45
46   data_type: 'longtext'
47   is_nullable: 1
48
49 a plain text explanation of the item type
50
51 =head2 rentalcharge
52
53   data_type: 'decimal'
54   is_nullable: 1
55   size: [28,6]
56
57 the amount charged when this item is checked out/issued
58
59 =head2 rentalcharge_daily
60
61   data_type: 'decimal'
62   is_nullable: 1
63   size: [28,6]
64
65 the amount charged for each day between checkout date and due date
66
67 =head2 rentalcharge_daily_calendar
68
69   data_type: 'tinyint'
70   default_value: 1
71   is_nullable: 0
72
73 controls if the daily rental fee is calculated directly or using finesCalendar
74
75 =head2 rentalcharge_hourly
76
77   data_type: 'decimal'
78   is_nullable: 1
79   size: [28,6]
80
81 the amount charged for each hour between checkout date and due date
82
83 =head2 rentalcharge_hourly_calendar
84
85   data_type: 'tinyint'
86   default_value: 1
87   is_nullable: 0
88
89 controls if the hourly rental fee is calculated directly or using finesCalendar
90
91 =head2 defaultreplacecost
92
93   data_type: 'decimal'
94   is_nullable: 1
95   size: [28,6]
96
97 default replacement cost
98
99 =head2 processfee
100
101   data_type: 'decimal'
102   is_nullable: 1
103   size: [28,6]
104
105 default text be recorded in the column note when the processing fee is applied
106
107 =head2 notforloan
108
109   data_type: 'tinyint'
110   default_value: 0
111   is_nullable: 0
112
113 1 if the item is not for loan, 0 if the item is available for loan
114
115 =head2 imageurl
116
117   data_type: 'varchar'
118   is_nullable: 1
119   size: 200
120
121 URL for the item type icon
122
123 =head2 summary
124
125   data_type: 'mediumtext'
126   is_nullable: 1
127
128 information from the summary field, may include HTML
129
130 =head2 checkinmsg
131
132   data_type: 'varchar'
133   is_nullable: 1
134   size: 255
135
136 message that is displayed when an item with the given item type is checked in
137
138 =head2 checkinmsgtype
139
140   data_type: 'char'
141   default_value: 'message'
142   is_nullable: 0
143   size: 16
144
145 type (CSS class) for the checkinmsg, can be 'alert' or 'message'
146
147 =head2 sip_media_type
148
149   data_type: 'varchar'
150   is_nullable: 1
151   size: 3
152
153 SIP2 protocol media type for this itemtype
154
155 =head2 hideinopac
156
157   data_type: 'tinyint'
158   default_value: 0
159   is_nullable: 0
160
161 Hide the item type from the search options in OPAC
162
163 =head2 searchcategory
164
165   data_type: 'varchar'
166   is_nullable: 1
167   size: 80
168
169 Group this item type with others with the same value on OPAC search options
170
171 =head2 automatic_checkin
172
173   data_type: 'tinyint'
174   default_value: 0
175   is_nullable: 0
176
177 If automatic checkin is enabled for items of this type
178
179 =cut
180
181 __PACKAGE__->add_columns(
182   "itemtype",
183   { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 },
184   "parent_type",
185   { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
186   "description",
187   { data_type => "longtext", is_nullable => 1 },
188   "rentalcharge",
189   { data_type => "decimal", is_nullable => 1, size => [28, 6] },
190   "rentalcharge_daily",
191   { data_type => "decimal", is_nullable => 1, size => [28, 6] },
192   "rentalcharge_daily_calendar",
193   { data_type => "tinyint", default_value => 1, is_nullable => 0 },
194   "rentalcharge_hourly",
195   { data_type => "decimal", is_nullable => 1, size => [28, 6] },
196   "rentalcharge_hourly_calendar",
197   { data_type => "tinyint", default_value => 1, is_nullable => 0 },
198   "defaultreplacecost",
199   { data_type => "decimal", is_nullable => 1, size => [28, 6] },
200   "processfee",
201   { data_type => "decimal", is_nullable => 1, size => [28, 6] },
202   "notforloan",
203   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
204   "imageurl",
205   { data_type => "varchar", is_nullable => 1, size => 200 },
206   "summary",
207   { data_type => "mediumtext", is_nullable => 1 },
208   "checkinmsg",
209   { data_type => "varchar", is_nullable => 1, size => 255 },
210   "checkinmsgtype",
211   {
212     data_type => "char",
213     default_value => "message",
214     is_nullable => 0,
215     size => 16,
216   },
217   "sip_media_type",
218   { data_type => "varchar", is_nullable => 1, size => 3 },
219   "hideinopac",
220   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
221   "searchcategory",
222   { data_type => "varchar", is_nullable => 1, size => 80 },
223   "automatic_checkin",
224   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
225 );
226
227 =head1 PRIMARY KEY
228
229 =over 4
230
231 =item * L</itemtype>
232
233 =back
234
235 =cut
236
237 __PACKAGE__->set_primary_key("itemtype");
238
239 =head1 RELATIONS
240
241 =head2 circulation_rules
242
243 Type: has_many
244
245 Related object: L<Koha::Schema::Result::CirculationRule>
246
247 =cut
248
249 __PACKAGE__->has_many(
250   "circulation_rules",
251   "Koha::Schema::Result::CirculationRule",
252   { "foreign.itemtype" => "self.itemtype" },
253   { cascade_copy => 0, cascade_delete => 0 },
254 );
255
256 =head2 itemtypes
257
258 Type: has_many
259
260 Related object: L<Koha::Schema::Result::Itemtype>
261
262 =cut
263
264 __PACKAGE__->has_many(
265   "itemtypes",
266   "Koha::Schema::Result::Itemtype",
267   { "foreign.parent_type" => "self.itemtype" },
268   { cascade_copy => 0, cascade_delete => 0 },
269 );
270
271 =head2 itemtypes_branches
272
273 Type: has_many
274
275 Related object: L<Koha::Schema::Result::ItemtypesBranch>
276
277 =cut
278
279 __PACKAGE__->has_many(
280   "itemtypes_branches",
281   "Koha::Schema::Result::ItemtypesBranch",
282   { "foreign.itemtype" => "self.itemtype" },
283   { cascade_copy => 0, cascade_delete => 0 },
284 );
285
286 =head2 old_reserves
287
288 Type: has_many
289
290 Related object: L<Koha::Schema::Result::OldReserve>
291
292 =cut
293
294 __PACKAGE__->has_many(
295   "old_reserves",
296   "Koha::Schema::Result::OldReserve",
297   { "foreign.itemtype" => "self.itemtype" },
298   { cascade_copy => 0, cascade_delete => 0 },
299 );
300
301 =head2 parent_type
302
303 Type: belongs_to
304
305 Related object: L<Koha::Schema::Result::Itemtype>
306
307 =cut
308
309 __PACKAGE__->belongs_to(
310   "parent_type",
311   "Koha::Schema::Result::Itemtype",
312   { itemtype => "parent_type" },
313   {
314     is_deferrable => 1,
315     join_type     => "LEFT",
316     on_delete     => "RESTRICT",
317     on_update     => "RESTRICT",
318   },
319 );
320
321 =head2 reserves
322
323 Type: has_many
324
325 Related object: L<Koha::Schema::Result::Reserve>
326
327 =cut
328
329 __PACKAGE__->has_many(
330   "reserves",
331   "Koha::Schema::Result::Reserve",
332   { "foreign.itemtype" => "self.itemtype" },
333   { cascade_copy => 0, cascade_delete => 0 },
334 );
335
336
337 # Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-05-08 14:38:07
338 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9NChRQA4eBUqHpLXUFmOuw
339
340 __PACKAGE__->add_columns(
341     '+automatic_checkin'            => { is_boolean => 1 },
342     '+hideinopac'                   => { is_boolean => 1 },
343     '+notforloan'                   => { is_boolean => 1 },
344     '+rentalcharge_daily_calendar'  => { is_boolean => 1 },
345     '+rentalcharge_hourly_calendar' => { is_boolean => 1 },
346 );
347
348 # Use the ItemtypeLocalization view to create the join on localization
349 our $LANGUAGE;
350 __PACKAGE__->has_many(
351   "localization" => "Koha::Schema::Result::ItemtypeLocalization",
352     sub {
353         my $args = shift;
354
355         die "no lang specified!" unless $LANGUAGE;
356
357         return ({
358             "$args->{self_alias}.itemtype" => { -ident => "$args->{foreign_alias}.code" },
359             "$args->{foreign_alias}.lang" => $LANGUAGE,
360         });
361
362     }
363 );
364
365 sub koha_object_class {
366     'Koha::ItemType';
367 }
368 sub koha_objects_class {
369     'Koha::ItemTypes';
370 }
371
372 1;