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 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-237 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;
229
        map {
230
        map {
230
            my $name = substr( $_, 0, -4 );
231
            my ( $name, $ext ) = split /\./, $_;
231
            open my $fh , "<:encoding(UTF-8)", "$dir/$requirelevel/$name.txt";
232
            my @lines;
232
            my $line = <$fh>;
233
            if ( $ext =~ /yml/ ) {
233
            $line = Encode::encode('UTF-8', $line) unless ( Encode::is_utf8($line) );
234
                my $yaml = LoadFile("$dir/$requirelevel/$name\.$ext");
234
            my @lines = split /\n/, $line;
235
                @lines = @{ $yaml->{'description'} };
236
            } else {
237
                open my $fh, "<:encoding(UTF-8)", "$dir/$requirelevel/$name.txt";
238
                my $line = <$fh>;
239
                $line = Encode::encode('UTF-8', $line) unless ( Encode::is_utf8($line) );
240
                @lines = split /\n/, $line;
241
            }
235
            my $mandatory = ($requirelevel =~ /(mandatory|requi|oblig|necess)/i);
242
            my $mandatory = ($requirelevel =~ /(mandatory|requi|oblig|necess)/i);
236
            push @frameworklist,
243
            push @frameworklist,
237
              {
244
              {
Lines 439-445 sub set_version_syspref { Link Here
439
446
440
  my $error = $installer->load_sql($filename);
447
  my $error = $installer->load_sql($filename);
441
448
442
Runs a the specified SQL file using a sql loader DBIx::RunSQL
449
Runs the specified input file using a sql loader DBIx::RunSQL, or a yaml loader
443
Returns any strings sent to STDERR
450
Returns any strings sent to STDERR
444
451
445
# FIXME This should be improved: sometimes the caller and load_sql warn the same
452
# 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;
466
        local *STDERR;
460
        open STDERR, ">>", \$dup_stderr;
467
        open STDERR, ">>", \$dup_stderr;
461
468
462
        eval {
469
        if ( $filename =~ /sql$/ ) {                                                        # SQL files
463
            DBIx::RunSQL->run_sql_file(
470
            eval {
464
                dbh     => $dbh,
471
                DBIx::RunSQL->run_sql_file(
465
                sql     => $filename,
472
                    dbh     => $dbh,
466
            );
473
                    sql     => $filename,
467
        };
474
                );
475
            };
476
        }
477
        else {                                                                       # YAML files
478
            eval {
479
                my $yaml         = LoadFile( $filename );                            # Load YAML
480
                for my $table ( @{ $yaml->{'tables'} } ) {
481
                    my $table_name   = ( keys %$table )[0];                          # table name
482
                    my @rows         = @{ $table->{$table_name}->{rows} };           #
483
                    my @columns      = ( sort keys %{$rows[0]} );                    # column names
484
                    my $fields       = join ",", @columns;                           # idem, joined
485
                    my $placeholders = join ",", map { "?" } @columns;               # '?,..,?' string
486
                    my $query        = "INSERT INTO $table_name ( $fields ) VALUES ( $placeholders )";
487
                    my $sth          = $dbh->prepare($query);
488
                    foreach my $row ( @rows ) {
489
                        my @values = map { $row->{$_} } @columns;
490
                        $sth->execute( @values );
491
                    }
492
                }
493
            };
494
        }
468
    };
495
    };
469
    #   errors thrown while loading installer data should be logged
496
    #   errors thrown while loading installer data should be logged
470
    if( $dup_stderr ) {
497
    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