Bug 15774: Use Koha::Object(s) for additional fields
[koha.git] / Koha / Schema / Result / Subscription.pm
blob5ccb9ee44f5ccec80d17f09bf786e0303b41816d
1 use utf8;
2 package Koha::Schema::Result::Subscription;
4 # Created by DBIx::Class::Schema::Loader
5 # DO NOT MODIFY THE FIRST PART OF THIS FILE
7 =head1 NAME
9 Koha::Schema::Result::Subscription
11 =cut
13 use strict;
14 use warnings;
16 use base 'DBIx::Class::Core';
18 =head1 TABLE: C<subscription>
20 =cut
22 __PACKAGE__->table("subscription");
24 =head1 ACCESSORS
26 =head2 biblionumber
28 data_type: 'integer'
29 default_value: 0
30 is_nullable: 0
32 =head2 subscriptionid
34 data_type: 'integer'
35 is_auto_increment: 1
36 is_nullable: 0
38 =head2 librarian
40 data_type: 'varchar'
41 default_value: (empty string)
42 is_nullable: 1
43 size: 100
45 =head2 startdate
47 data_type: 'date'
48 datetime_undef_if_invalid: 1
49 is_nullable: 1
51 =head2 aqbooksellerid
53 data_type: 'integer'
54 default_value: 0
55 is_nullable: 1
57 =head2 cost
59 data_type: 'integer'
60 default_value: 0
61 is_nullable: 1
63 =head2 aqbudgetid
65 data_type: 'integer'
66 default_value: 0
67 is_nullable: 1
69 =head2 weeklength
71 data_type: 'integer'
72 default_value: 0
73 is_nullable: 1
75 =head2 monthlength
77 data_type: 'integer'
78 default_value: 0
79 is_nullable: 1
81 =head2 numberlength
83 data_type: 'integer'
84 default_value: 0
85 is_nullable: 1
87 =head2 periodicity
89 data_type: 'integer'
90 is_foreign_key: 1
91 is_nullable: 1
93 =head2 countissuesperunit
95 data_type: 'integer'
96 default_value: 1
97 is_nullable: 0
99 =head2 notes
101 data_type: 'longtext'
102 is_nullable: 1
104 =head2 status
106 data_type: 'varchar'
107 default_value: (empty string)
108 is_nullable: 0
109 size: 100
111 =head2 lastvalue1
113 data_type: 'integer'
114 is_nullable: 1
116 =head2 innerloop1
118 data_type: 'integer'
119 default_value: 0
120 is_nullable: 1
122 =head2 lastvalue2
124 data_type: 'integer'
125 is_nullable: 1
127 =head2 innerloop2
129 data_type: 'integer'
130 default_value: 0
131 is_nullable: 1
133 =head2 lastvalue3
135 data_type: 'integer'
136 is_nullable: 1
138 =head2 innerloop3
140 data_type: 'integer'
141 default_value: 0
142 is_nullable: 1
144 =head2 firstacquidate
146 data_type: 'date'
147 datetime_undef_if_invalid: 1
148 is_nullable: 1
150 =head2 manualhistory
152 data_type: 'tinyint'
153 default_value: 0
154 is_nullable: 0
156 =head2 irregularity
158 data_type: 'mediumtext'
159 is_nullable: 1
161 =head2 skip_serialseq
163 data_type: 'tinyint'
164 default_value: 0
165 is_nullable: 0
167 =head2 letter
169 data_type: 'varchar'
170 is_nullable: 1
171 size: 20
173 =head2 numberpattern
175 data_type: 'integer'
176 is_foreign_key: 1
177 is_nullable: 1
179 =head2 locale
181 data_type: 'varchar'
182 is_nullable: 1
183 size: 80
185 =head2 distributedto
187 data_type: 'mediumtext'
188 is_nullable: 1
190 =head2 internalnotes
192 data_type: 'longtext'
193 is_nullable: 1
195 =head2 callnumber
197 data_type: 'mediumtext'
198 is_nullable: 1
200 =head2 location
202 data_type: 'varchar'
203 default_value: (empty string)
204 is_nullable: 1
205 size: 80
207 =head2 branchcode
209 data_type: 'varchar'
210 default_value: (empty string)
211 is_nullable: 0
212 size: 10
214 =head2 lastbranch
216 data_type: 'varchar'
217 is_nullable: 1
218 size: 10
220 =head2 serialsadditems
222 data_type: 'tinyint'
223 default_value: 0
224 is_nullable: 0
226 =head2 staffdisplaycount
228 data_type: 'varchar'
229 is_nullable: 1
230 size: 10
232 =head2 opacdisplaycount
234 data_type: 'varchar'
235 is_nullable: 1
236 size: 10
238 =head2 graceperiod
240 data_type: 'integer'
241 default_value: 0
242 is_nullable: 0
244 =head2 enddate
246 data_type: 'date'
247 datetime_undef_if_invalid: 1
248 is_nullable: 1
250 =head2 closed
252 data_type: 'integer'
253 default_value: 0
254 is_nullable: 0
256 =head2 reneweddate
258 data_type: 'date'
259 datetime_undef_if_invalid: 1
260 is_nullable: 1
262 =head2 itemtype
264 data_type: 'varchar'
265 is_nullable: 1
266 size: 10
268 =head2 previousitemtype
270 data_type: 'varchar'
271 is_nullable: 1
272 size: 10
274 =head2 mana_id
276 data_type: 'integer'
277 is_nullable: 1
279 =cut
281 __PACKAGE__->add_columns(
282 "biblionumber",
283 { data_type => "integer", default_value => 0, is_nullable => 0 },
284 "subscriptionid",
285 { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
286 "librarian",
287 { data_type => "varchar", default_value => "", is_nullable => 1, size => 100 },
288 "startdate",
289 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
290 "aqbooksellerid",
291 { data_type => "integer", default_value => 0, is_nullable => 1 },
292 "cost",
293 { data_type => "integer", default_value => 0, is_nullable => 1 },
294 "aqbudgetid",
295 { data_type => "integer", default_value => 0, is_nullable => 1 },
296 "weeklength",
297 { data_type => "integer", default_value => 0, is_nullable => 1 },
298 "monthlength",
299 { data_type => "integer", default_value => 0, is_nullable => 1 },
300 "numberlength",
301 { data_type => "integer", default_value => 0, is_nullable => 1 },
302 "periodicity",
303 { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
304 "countissuesperunit",
305 { data_type => "integer", default_value => 1, is_nullable => 0 },
306 "notes",
307 { data_type => "longtext", is_nullable => 1 },
308 "status",
309 { data_type => "varchar", default_value => "", is_nullable => 0, size => 100 },
310 "lastvalue1",
311 { data_type => "integer", is_nullable => 1 },
312 "innerloop1",
313 { data_type => "integer", default_value => 0, is_nullable => 1 },
314 "lastvalue2",
315 { data_type => "integer", is_nullable => 1 },
316 "innerloop2",
317 { data_type => "integer", default_value => 0, is_nullable => 1 },
318 "lastvalue3",
319 { data_type => "integer", is_nullable => 1 },
320 "innerloop3",
321 { data_type => "integer", default_value => 0, is_nullable => 1 },
322 "firstacquidate",
323 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
324 "manualhistory",
325 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
326 "irregularity",
327 { data_type => "mediumtext", is_nullable => 1 },
328 "skip_serialseq",
329 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
330 "letter",
331 { data_type => "varchar", is_nullable => 1, size => 20 },
332 "numberpattern",
333 { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
334 "locale",
335 { data_type => "varchar", is_nullable => 1, size => 80 },
336 "distributedto",
337 { data_type => "mediumtext", is_nullable => 1 },
338 "internalnotes",
339 { data_type => "longtext", is_nullable => 1 },
340 "callnumber",
341 { data_type => "mediumtext", is_nullable => 1 },
342 "location",
343 { data_type => "varchar", default_value => "", is_nullable => 1, size => 80 },
344 "branchcode",
345 { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 },
346 "lastbranch",
347 { data_type => "varchar", is_nullable => 1, size => 10 },
348 "serialsadditems",
349 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
350 "staffdisplaycount",
351 { data_type => "varchar", is_nullable => 1, size => 10 },
352 "opacdisplaycount",
353 { data_type => "varchar", is_nullable => 1, size => 10 },
354 "graceperiod",
355 { data_type => "integer", default_value => 0, is_nullable => 0 },
356 "enddate",
357 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
358 "closed",
359 { data_type => "integer", default_value => 0, is_nullable => 0 },
360 "reneweddate",
361 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
362 "itemtype",
363 { data_type => "varchar", is_nullable => 1, size => 10 },
364 "previousitemtype",
365 { data_type => "varchar", is_nullable => 1, size => 10 },
366 "mana_id",
367 { data_type => "integer", is_nullable => 1 },
370 =head1 PRIMARY KEY
372 =over 4
374 =item * L</subscriptionid>
376 =back
378 =cut
380 __PACKAGE__->set_primary_key("subscriptionid");
382 =head1 RELATIONS
384 =head2 aqorders
386 Type: has_many
388 Related object: L<Koha::Schema::Result::Aqorder>
390 =cut
392 __PACKAGE__->has_many(
393 "aqorders",
394 "Koha::Schema::Result::Aqorder",
395 { "foreign.subscriptionid" => "self.subscriptionid" },
396 { cascade_copy => 0, cascade_delete => 0 },
399 =head2 numberpattern
401 Type: belongs_to
403 Related object: L<Koha::Schema::Result::SubscriptionNumberpattern>
405 =cut
407 __PACKAGE__->belongs_to(
408 "numberpattern",
409 "Koha::Schema::Result::SubscriptionNumberpattern",
410 { id => "numberpattern" },
412 is_deferrable => 1,
413 join_type => "LEFT",
414 on_delete => "SET NULL",
415 on_update => "CASCADE",
419 =head2 periodicity
421 Type: belongs_to
423 Related object: L<Koha::Schema::Result::SubscriptionFrequency>
425 =cut
427 __PACKAGE__->belongs_to(
428 "periodicity",
429 "Koha::Schema::Result::SubscriptionFrequency",
430 { id => "periodicity" },
432 is_deferrable => 1,
433 join_type => "LEFT",
434 on_delete => "SET NULL",
435 on_update => "CASCADE",
439 =head2 subscriptionroutinglists
441 Type: has_many
443 Related object: L<Koha::Schema::Result::Subscriptionroutinglist>
445 =cut
447 __PACKAGE__->has_many(
448 "subscriptionroutinglists",
449 "Koha::Schema::Result::Subscriptionroutinglist",
450 { "foreign.subscriptionid" => "self.subscriptionid" },
451 { cascade_copy => 0, cascade_delete => 0 },
455 # Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-01-23 12:56:39
456 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dTb/JOO3KQ3NZGypFbRiEw
458 __PACKAGE__->has_many(
459 "additional_field_values",
460 "Koha::Schema::Result::AdditionalFieldValue",
461 sub {
462 my ($args) = @_;
464 return {
465 "$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.subscriptionid" },
467 # TODO Add column additional_field_values.tablename to avoid subquery ?
468 "$args->{foreign_alias}.field_id" =>
469 { -in => \'(SELECT id FROM additional_fields WHERE tablename = "subscription")' },
472 { cascade_copy => 0, cascade_delete => 0 },
475 # You can replace this text with custom content, and it will be preserved on regeneration