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

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

Return to bug 13897