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

(-)a/C4/Installer.pm (-10 / +31 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Encode qw( encode is_utf8 );
22
use Encode qw( encode is_utf8 );
23
use DBIx::RunSQL;
23
use DBIx::RunSQL;
24
use YAML::Syck qw( LoadFile );
24
use C4::Context;
25
use C4::Context;
25
use C4::Installer::PerlModules;
26
use C4::Installer::PerlModules;
26
use DBI;
27
use DBI;
Lines 145-156 sub marc_framework_sql_list { Link Here
145
146
146
    foreach my $requirelevel (@listdir) {
147
    foreach my $requirelevel (@listdir) {
147
        opendir( MYDIR, "$dir/$requirelevel" );
148
        opendir( MYDIR, "$dir/$requirelevel" );
148
        my @listname = grep { !/^\./ && -f "$dir/$requirelevel/$_" && $_ =~ m/\.sql$/ } readdir(MYDIR);
149
        my @listname = grep { !/^\./ && -f "$dir/$requirelevel/$_" && $_ =~ m/\.(sql|yml)$/ } readdir(MYDIR);
149
        closedir MYDIR;
150
        closedir MYDIR;
150
        my %cell;
151
        my %cell;
151
        my @frameworklist;
152
        my @frameworklist;
152
        map {
153
        map {
153
            my $name = substr( $_, 0, -4 );
154
            my $name = substr( $_, 0, -4 ); # FIXME: restricted to 3 letter extension
154
            open my $fh, "<:encoding(UTF-8)", "$dir/$requirelevel/$name.txt";
155
            open my $fh, "<:encoding(UTF-8)", "$dir/$requirelevel/$name.txt";
155
            my $line = <$fh>;
156
            my $line = <$fh>;
156
            $line = Encode::encode('UTF-8', $line) unless ( Encode::is_utf8($line) );
157
            $line = Encode::encode('UTF-8', $line) unless ( Encode::is_utf8($line) );
Lines 222-228 sub sample_data_sql_list { Link Here
222
223
223
    foreach my $requirelevel (@listdir) {
224
    foreach my $requirelevel (@listdir) {
224
        opendir( MYDIR, "$dir/$requirelevel" );
225
        opendir( MYDIR, "$dir/$requirelevel" );
225
        my @listname = grep { !/^\./ && -f "$dir/$requirelevel/$_" && $_ =~ m/\.sql$/ } readdir(MYDIR);
226
        my @listname = grep { !/^\./ && -f "$dir/$requirelevel/$_" && $_ =~ m/\.(sql|yml)$/ } readdir(MYDIR);
226
        closedir MYDIR;
227
        closedir MYDIR;
227
        my %cell;
228
        my %cell;
228
        my @frameworklist;
229
        my @frameworklist;
Lines 439-445 sub set_version_syspref { Link Here
439
440
440
  my $error = $installer->load_sql($filename);
441
  my $error = $installer->load_sql($filename);
441
442
442
Runs a the specified SQL file using a sql loader DBIx::RunSQL
443
Runs the specified input file using a sql loader DBIx::RunSQL, or a yaml loader
443
Returns any strings sent to STDERR
444
Returns any strings sent to STDERR
444
445
445
# FIXME This should be improved: sometimes the caller and load_sql warn the same
446
# FIXME This should be improved: sometimes the caller and load_sql warn the same
Lines 459-470 sub load_sql { Link Here
459
        local *STDERR;
460
        local *STDERR;
460
        open STDERR, ">>", \$dup_stderr;
461
        open STDERR, ">>", \$dup_stderr;
461
462
462
        eval {
463
        if ( $filename =~ /sql$/ ) {                                                        # SQL files
463
            DBIx::RunSQL->run_sql_file(
464
            eval {
464
                dbh     => $dbh,
465
                DBIx::RunSQL->run_sql_file(
465
                sql     => $filename,
466
                    dbh     => $dbh,
466
            );
467
                    sql     => $filename,
467
        };
468
                );
469
            };
470
        }
471
        else {                                                                              # YAML files
472
            eval {
473
                # Note: Only one table per file, multiple table inserts require multiple files
474
                # with proper names to ensure ordered insert
475
                my $yaml         = LoadFile( $filename );                            # Load YAML
476
                my $table        = ( keys %$yaml )[0];                               # table name
477
                my @rows         = @{ $yaml->{$table}->{rows} };                     #
478
                my @columns      = ( sort keys %{$rows[0]} );                        # column names
479
                my $fields       = join ",", @columns;                               # idem, joined
480
                my $placeholders = join ",", map "?",(1..$#columns+1);               # '?,..,?' string
481
                my $query        = "INSERT INTO $table ( $fields ) VALUES ( $placeholders )";
482
                my $loadyaml     = $dbh->prepare($query);
483
                foreach my $row ( @rows ) {
484
                    my @values = map { $row->{$_} } @columns;
485
                    $loadyaml->execute( @values );
486
                }
487
            };
488
        }
468
    };
489
    };
469
    #   errors thrown while loading installer data should be logged
490
    #   errors thrown while loading installer data should be logged
470
    if( $dup_stderr ) {
491
    if( $dup_stderr ) {
(-)a/installer/data/mysql/en/optional/auth_val.sql (-86 lines)
Lines 1-86 Link Here
1
-- Reasons for acceptance or rejection of suggestions in acquisitions
2
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SUGGEST','BSELL','Bestseller');
3
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SUGGEST','SCD','Shelf Copy Damaged');
4
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SUGGEST','LCL','Library Copy Lost');
5
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SUGGEST','AVILL','Available via ILL');
6
7
-- Desired formats for requesting new materials
8
INSERT INTO authorised_values (category, authorised_value, lib, lib_opac) VALUES ('SUGGEST_FORMAT', 'BOOK', 'Book', 'Book');
9
INSERT INTO authorised_values (category, authorised_value, lib, lib_opac) VALUES ('SUGGEST_FORMAT', 'LP', 'Large print', 'Large print');
10
INSERT INTO authorised_values (category, authorised_value, lib, lib_opac) VALUES ('SUGGEST_FORMAT', 'EBOOK', 'EBook', 'Ebook');
11
INSERT INTO authorised_values (category, authorised_value, lib, lib_opac) VALUES ('SUGGEST_FORMAT', 'AUDIOBOOK', 'Audiobook', 'Audiobook');
12
INSERT INTO authorised_values (category, authorised_value, lib, lib_opac) VALUES ('SUGGEST_FORMAT', 'DVD', 'DVD', 'DVD');
13
14
-- availability statuses
15
INSERT INTO `authorised_values`  (category, authorised_value, lib) VALUES ('LOST','2','Long Overdue (Lost)');
16
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOST','1','Lost');
17
INSERT INTO `authorised_values`  (category, authorised_value, lib ) VALUES ('LOST','3','Lost and Paid For');
18
INSERT INTO `authorised_values`  (category, authorised_value, lib )VALUES ('LOST','4','Missing');
19
20
-- damaged status of an item
21
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('DAMAGED','1','Damaged');
22
23
-- location qualification for an item, departments are linked by default to items.location
24
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','FIC','Fiction');
25
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','CHILD','Children\'s Area');
26
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','DISPLAY','On Display');
27
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','NEW','New Materials Shelf');
28
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','STAFF','Staff Office');
29
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','GEN','General Stacks');
30
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','AV','Audio Visual');
31
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','REF','Reference');
32
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','CART','Book Cart');
33
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('LOC','PROC','Processing Center');
34
35
-- collection codes for an item
36
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('CCODE','FIC','Fiction');
37
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('CCODE','REF','Reference');
38
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('CCODE','NFIC','Non-fiction');
39
40
-- withdrawn status of an item, linked to items.withdrawn
41
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('WITHDRAWN','1','Withdrawn');
42
43
-- loanability status of an item, linked to items.notforloan
44
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('NOT_LOAN','-1','Ordered');
45
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('NOT_LOAN','1','Not For Loan');
46
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('NOT_LOAN','2','Staff Collection');
47
48
-- restricted status of an item, linked to items.restricted
49
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('RESTRICTED','1','Restricted Access');
50
51
-- custom borrower notes
52
INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('BOR_NOTES','ADDR','Address Notes');
53
54
-- OPAC Suggestions reasons
55
INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','damaged','The copy on the shelf is damaged','The copy on the shelf is damaged');
56
INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','bestseller','Upcoming title by popular author','Upcoming title by popular author');
57
58
-- Report groups
59
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'CIRC', 'Circulation');
60
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'CAT', 'Catalog');
61
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'PAT', 'Patrons');
62
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'ACQ', 'Acquisitions');
63
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'ACC', 'Accounts');
64
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'SER', 'Serials');
65
66
-- SIP2 media types
67
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '000', 'Other');
68
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '001', 'Book');
69
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '002', 'Magazine');
70
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '003', 'Bound journal');
71
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '004', 'Audio tape');
72
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '005', 'Video tape');
73
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '006', 'CD/CDROM');
74
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '007', 'Diskette');
75
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '008', 'Book with diskette');
76
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '009', 'Book with CD');
77
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '010', 'Book with audio tape');
78
79
-- order cancellation reasons
80
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('ORDER_CANCELLATION_REASON', 0, 'No reason provided');
81
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('ORDER_CANCELLATION_REASON', 1, 'Out of stock');
82
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('ORDER_CANCELLATION_REASON', 2, 'Restocking');
83
84
-- return claims
85
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('RETURN_CLAIM_RESOLUTION', 'RET_BY_PATRON', 'Returned by patron');
86
INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('RETURN_CLAIM_RESOLUTION', 'FOUND_IN_LIB',  'Found in library');
(-)a/installer/data/mysql/en/optional/auth_val.yml (-1 / +325 lines)
Line 0 Link Here
0
- 
1
---
2
#
3
#  Some basic default authorised values for library locations, item lost status, etc.
4
#  You can change these at any time after installation.
5
#
6
#  Copyright 2019 Koha Development Team
7
#
8
#  This file is part of Koha.
9
#
10
#  Koha is free software; you can redistribute it and/or modify it under the
11
#  terms of the GNU General Public License as published by the Free Software
12
#  Foundation; either version 2 of the License, or (at your option) any later
13
#  version.
14
#
15
#  Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
#  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18
#
19
#  You should have received a copy of the GNU General Public License along
20
#  with Koha; if not, write to the Free Software Foundation, Inc.,
21
#  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
#
23
24
authorised_values:
25
    translatable: { lib: 1, lib_opac: 1 }
26
    rows:
27
      # Reasons for acceptance or rejection of suggestions in acquisitions
28
      - category: "SUGGEST"
29
        authorised_value: "BSELL"
30
        lib: "Bestseller"
31
        lib_opac: "Bestseller"
32
33
      - category: "SUGGEST"
34
        authorised_value: "SCD"
35
        lib: "Shelf Copy Damaged"
36
        lib_opac: "Shelf Copy Damaged"
37
38
      - category: "SUGGEST"
39
        authorised_value: "LCL"
40
        lib: "Library Copy Lost"
41
        lib_opac: "Library Copy Lost"
42
43
      - category: "SUGGEST"
44
        authorised_value: "AVILL"
45
        lib: "Available via ILL"
46
        lib_opac: "Available via ILL"
47
48
      # Desired formats for requesting new materials
49
      - category: "SUGGEST_FORMAT"
50
        authorised_value: "BOOK"
51
        lib: "Book"
52
        lib_opac: "Book"
53
54
      - category: "SUGGEST_FORMAT"
55
        authorised_value: "LP"
56
        lib: "Large print"
57
        lib_opac: "Large print"
58
59
      - category: "SUGGEST_FORMAT"
60
        authorised_value: "EBOOK"
61
        lib: "EBook"
62
        lib_opac: "Ebook"
63
64
      - category: "SUGGEST_FORMAT"
65
        authorised_value: "AUDIOBOOK"
66
        lib: "Audiobook"
67
        lib_opac: "Audiobook"
68
69
      - category: "SUGGEST_FORMAT"
70
        authorised_value: "DVD"
71
        lib: "DVD"
72
        lib_opac: "DVD"
73
74
      # availability statuses
75
      - category: "LOST"
76
        authorised_value: "2"
77
        lib: "Long Overdue (Lost)"
78
        lib_opac: "Long Overdue (Lost)"
79
80
      - category: "LOST"
81
        authorised_value: "1"
82
        lib: "Lost"
83
        lib_opac: "Lost"
84
85
      - category: "LOST"
86
        authorised_value: "3"
87
        lib: "Lost and Paid For"
88
        lib_opac: "Lost and Paid For"
89
90
      - category: "LOST"
91
        authorised_value: "4"
92
        lib: "Missing"
93
        lib_opac: "Missing"
94
95
      # damaged status of an item
96
      - category: "DAMAGED"
97
        authorised_value: "1"
98
        lib: "Damaged"
99
        lib_opac: "Damaged"
100
101
      # location qualification for an item, departments are linked by default to items.location
102
      - category: "LOC"
103
        authorised_value: "FIC"
104
        lib: "Fiction"
105
        lib_opac: "Fiction"
106
107
      - category: "LOC"
108
        authorised_value: "CHILD"
109
        lib: "Children\'s Area"
110
        lib_opac: "Children\'s Area"
111
112
      - category: "LOC"
113
        authorised_value: "DISPLAY"
114
        lib: "On Display"
115
        lib_opac: "On Display"
116
117
      - category: "LOC"
118
        authorised_value: "NEW"
119
        lib: "New Materials Shelf"
120
        lib_opac: "New Materials Shelf"
121
122
      - category: "LOC"
123
        authorised_value: "STAFF"
124
        lib: "Staff Office"
125
        lib_opac: "Staff Office"
126
127
      - category: "LOC"
128
        authorised_value: "GEN"
129
        lib: "General Stacks"
130
        lib_opac: "General Stacks"
131
132
      - category: "LOC"
133
        authorised_value: "AV"
134
        lib: "Audio Visual"
135
        lib_opac: "Audio Visual"
136
137
      - category: "LOC"
138
        authorised_value: "REF"
139
        lib: "Reference"
140
        lib_opac: "Reference"
141
142
      - category: "LOC"
143
        authorised_value: "CART"
144
        lib: "Book Cart"
145
        lib_opac: "Book Cart"
146
147
      - category: "LOC"
148
        authorised_value: "PROC"
149
        lib: "Processing Center"
150
        lib_opac: "Processing Center"
151
152
      # collection codes for an item
153
      - category: "CCODE"
154
        authorised_value: "FIC"
155
        lib: "Fiction"
156
        lib_opac: "Fiction"
157
158
      - category: "CCODE"
159
        authorised_value: "REF"
160
        lib: "Reference"
161
        lib_opac: "Reference"
162
163
      - category: "CCODE"
164
        authorised_value: "NFIC"
165
        lib: "Non-fiction"
166
        lib_opac: "Non-fiction"
167
168
      # withdrawn status of an item, linked to items.withdrawn
169
      - category: "WITHDRAWN"
170
        authorised_value: "1"
171
        lib: "Withdrawn"
172
        lib_opac: "Withdrawn"
173
174
      # loanability status of an item, linked to items.notforloan
175
      - category: "NOT_LOAN"
176
        authorised_value: "-1"
177
        lib: "Ordered"
178
        lib_opac: "Ordered"
179
180
      - category: "NOT_LOAN"
181
        authorised_value: "1"
182
        lib: "Not For Loan"
183
        lib_opac: "Not For Loan"
184
185
      - category: "NOT_LOAN"
186
        authorised_value: "2"
187
        lib: "Staff Collection"
188
        lib_opac: "Staff Collection"
189
190
      # restricted status of an item, linked to items.restricted
191
      - category: "RESTRICTED"
192
        authorised_value: "1"
193
        lib: "Restricted Access"
194
        lib_opac: "Restricted Access"
195
196
      # custom borrower notes
197
      - category: "BOR_NOTES"
198
        authorised_value: "ADDR"
199
        lib: "Address Notes"
200
        lib_opac: "Address Notes"
201
202
      # OPAC Suggestions reasons
203
      - category: "OPAC_SUG"
204
        authorised_value: "damaged"
205
        lib: "The copy on the shelf is damaged"
206
        lib_opac: "The copy on the shelf is damaged"
207
208
      - category: "OPAC_SUG"
209
        authorised_value: "bestseller"
210
        lib: "Upcoming title by popular author"
211
        lib_opac: "Upcoming title by popular author"
212
213
      # Report groups
214
      - category: "REPORT_GROUP"
215
        authorised_value: "CIRC"
216
        lib: "Circulation"
217
        lib_opac: "Circulation"
218
219
      - category: "REPORT_GROUP"
220
        authorised_value: "CAT"
221
        lib: "Catalog"
222
        lib_opac: "Catalog"
223
224
      - category: "REPORT_GROUP"
225
        authorised_value: "PAT"
226
        lib: "Patrons"
227
        lib_opac: "Patrons"
228
229
      - category: "REPORT_GROUP"
230
        authorised_value: "ACQ"
231
        lib: "Acquisitions"
232
        lib_opac: "Acquisitions"
233
234
      - category: "REPORT_GROUP"
235
        authorised_value: "ACC"
236
        lib: "Accounts"
237
        lib_opac: "Accounts"
238
239
      - category: "REPORT_GROUP"
240
        authorised_value: "SER"
241
        lib: "Serials"
242
        lib_opac: "Serials"
243
244
      # SIP2 media types
245
      - category: "SIP_MEDIA_TYPE"
246
        authorised_value: "000"
247
        lib: "Other"
248
        lib_opac: "Other"
249
250
      - category: "SIP_MEDIA_TYPE"
251
        authorised_value: "001"
252
        lib: "Book"
253
        lib_opac: "Book"
254
255
      - category: "SIP_MEDIA_TYPE"
256
        authorised_value: "002"
257
        lib: "Magazine"
258
        lib_opac: "Magazine"
259
260
      - category: "SIP_MEDIA_TYPE"
261
        authorised_value: "003"
262
        lib: "Bound journal"
263
        lib_opac: "Bound journal"
264
265
      - category: "SIP_MEDIA_TYPE"
266
        authorised_value: "004"
267
        lib: "Audio tape"
268
        lib_opac: "Audio tape"
269
270
      - category: "SIP_MEDIA_TYPE"
271
        authorised_value: "005"
272
        lib: "Video tape"
273
        lib_opac: "Video tape"
274
275
      - category: "SIP_MEDIA_TYPE"
276
        authorised_value: "006"
277
        lib: "CD/CDROM"
278
        lib_opac: "CD/CDROM"
279
280
      - category: "SIP_MEDIA_TYPE"
281
        authorised_value: "007"
282
        lib: "Diskette"
283
        lib_opac: "Diskette"
284
285
      - category: "SIP_MEDIA_TYPE"
286
        authorised_value: "008"
287
        lib: "Book with diskette"
288
        lib_opac: "Book with diskette"
289
290
      - category: "SIP_MEDIA_TYPE"
291
        authorised_value: "009"
292
        lib: "Book with CD"
293
        lib_opac: "Book with CD"
294
295
      - category: "SIP_MEDIA_TYPE"
296
        authorised_value: "010"
297
        lib: "Book with audio tape"
298
        lib_opac: "Book with audio tape"
299
300
      # order cancellation reasons
301
      - category: "ORDER_CANCELLATION_REASON"
302
        authorised_value: "0"
303
        lib: "No reason provided"
304
        lib_opac: "No reason provided"
305
306
      - category: "ORDER_CANCELLATION_REASON"
307
        authorised_value: "1"
308
        lib: "Out of stock"
309
        lib_opac: "Out of stock"
310
311
      - category: "ORDER_CANCELLATION_REASON"
312
        authorised_value: "2"
313
        lib: "Restocking"
314
        lib_opac: "Restocking"
315
316
      # return claims
317
      - category: "RETURN_CLAIM_RESOLUTION"
318
        authorised_value: "RET_BY_PATRON"
319
        lib: "Returned by patron"
320
        lib_opac: "Returned by patron"
321
322
      - category: "RETURN_CLAIM_RESOLUTION"
323
        authorised_value: "FOUND_IN_LIB"
324
        lib: "Found in library"
325
        lib_opac: "Found in library"

Return to bug 13897