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
                my $yaml         = LoadFile( $filename );                            # Load YAML
474
                for my $table ( @{ $yaml } ) {
475
                    my $table_name   = ( keys %$table )[0];                          # table name
476
                    my @rows         = @{ $table->{$table_name}->{rows} };           #
477
                    my @columns      = ( sort keys %{$rows[0]} );                    # column names
478
                    my $fields       = join ",", @columns;                           # idem, joined
479
                    my $placeholders = join ",", map { "?" } @columns;               # '?,..,?' string
480
                    my $query        = "INSERT INTO $table_name ( $fields ) VALUES ( $placeholders )";
481
                    my $sth          = $dbh->prepare($query);
482
                    foreach my $row ( @rows ) {
483
                        my @values = map { $row->{$_} } @columns;
484
                        $sth->execute( @values );
485
                    }
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 / +287 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 ]
26
    rows:
27
      # Reasons for acceptance or rejection of suggestions in acquisitions
28
      - category: "SUGGEST"
29
        authorised_value: "BSELL"
30
        lib: "Bestseller"
31
32
      - category: "SUGGEST"
33
        authorised_value: "SCD"
34
        lib: "Shelf Copy Damaged"
35
36
      - category: "SUGGEST"
37
        authorised_value: "LCL"
38
        lib: "Library Copy Lost"
39
40
      - category: "SUGGEST"
41
        authorised_value: "AVILL"
42
        lib: "Available via ILL"
43
44
- authorised_values:
45
    translatable: [ lib, lib_opac ]
46
    rows:
47
      # Desired formats for requesting new materials
48
      - category: "SUGGEST_FORMAT"
49
        authorised_value: "BOOK"
50
        lib: "Book"
51
        lib_opac: "Book"
52
53
      - category: "SUGGEST_FORMAT"
54
        authorised_value: "LP"
55
        lib: "Large print"
56
        lib_opac: "Large print"
57
58
      - category: "SUGGEST_FORMAT"
59
        authorised_value: "EBOOK"
60
        lib: "EBook"
61
        lib_opac: "Ebook"
62
63
      - category: "SUGGEST_FORMAT"
64
        authorised_value: "AUDIOBOOK"
65
        lib: "Audiobook"
66
        lib_opac: "Audiobook"
67
68
      - category: "SUGGEST_FORMAT"
69
        authorised_value: "DVD"
70
        lib: "DVD"
71
        lib_opac: "DVD"
72
73
- authorised_values :
74
    translatable: [ lib ]
75
    rows:
76
      # availability statuses
77
      - category: "LOST"
78
        authorised_value: "2"
79
        lib: "Long Overdue (Lost)"
80
81
      - category: "LOST"
82
        authorised_value: "1"
83
        lib: "Lost"
84
85
      - category: "LOST"
86
        authorised_value: "3"
87
        lib : "Lost and Paid For"
88
89
      - category: "LOST"
90
        authorised_value: "4"
91
        lib : "Missing"
92
93
      # damaged status of an item
94
      - category: "DAMAGED"
95
        authorised_value: "1"
96
        lib: "Damaged"
97
98
      # location qualification for an item,departments are linked by default to items.location
99
      - category: "LOC"
100
        authorised_value: "FIC"
101
        lib: "Fiction"
102
103
      - category: "LOC"
104
        authorised_value: "CHILD"
105
        lib: "Children's Area"
106
107
      - category: "LOC"
108
        authorised_value: "DISPLAY"
109
        lib: "On Display"
110
111
      - category: "LOC"
112
        authorised_value: "NEW"
113
        lib: "New Materials Shelf"
114
115
      - category: "LOC"
116
        authorised_value: "STAFF"
117
        lib: "Staff Office"
118
119
      - category: "LOC"
120
        authorised_value: "GEN"
121
        lib: "General Stacks"
122
123
      - category: "LOC"
124
        authorised_value: "AV"
125
        lib: "Audio Visual"
126
127
      - category: "LOC"
128
        authorised_value: "REF"
129
        lib: "Reference"
130
131
      - category: "LOC"
132
        authorised_value: "CART"
133
        lib: "Book Cart"
134
135
      - category: "LOC"
136
        authorised_value: "PROC"
137
        lib: "Processing Center"
138
139
      # collection codes for an item
140
      - category: "CCODE"
141
        authorised_value: "FIC"
142
        lib: "Fiction"
143
144
      - category: "CCODE"
145
        authorised_value: "REF"
146
        lib: "Reference"
147
148
      - category: "CCODE"
149
        authorised_value: "NFIC"
150
        lib: "Non-fiction"
151
152
      # withdrawn status of an item,linked to items.withdrawn
153
      - category: "WITHDRAWN"
154
        authorised_value: "1"
155
        lib: "Withdrawn"
156
157
      # loanability status of an item,linked to items.notforloan
158
      - category: "NOT_LOAN"
159
        authorised_value: "-1"
160
        lib: "Ordered"
161
162
      - category: "NOT_LOAN"
163
        authorised_value: "1"
164
        lib: "Not For Loan"
165
166
      - category: "NOT_LOAN"
167
        authorised_value: "2"
168
        lib: "Staff Collection"
169
170
      # restricted status of an item,linked to items.restricted
171
      - category: "RESTRICTED"
172
        authorised_value: "1"
173
        lib: "Restricted Access"
174
175
      # custom borrower notes
176
      - category: "BOR_NOTES"
177
        authorised_value: "ADDR"
178
        lib: "Address Notes"
179
180
- authorised_values:
181
    translatable: [ lib, lib_opac ]
182
    rows:
183
      # OPAC Suggestions reasons
184
      - category: "OPAC_SUG"
185
        authorised_value: "damaged"
186
        lib: "The copy on the shelf is damaged"
187
        lib_opac: "The copy on the shelf is damaged"
188
189
      - category: "OPAC_SUG"
190
        authorised_value: "bestseller"
191
        lib: "Upcoming title by popular author"
192
        lib_opac: "Upcoming title by popular author"
193
194
- authorised_values:
195
    translatable: [ lib ]
196
    rows:
197
      # Report groups
198
      - category: "REPORT_GROUP"
199
        authorised_value: "CIRC"
200
        lib: "Circulation"
201
202
      - category: "REPORT_GROUP"
203
        authorised_value: "CAT"
204
        lib: "Catalog"
205
206
      - category: "REPORT_GROUP"
207
        authorised_value: "PAT"
208
        lib: "Patrons"
209
210
      - category: "REPORT_GROUP"
211
        authorised_value: "ACQ"
212
        lib: "Acquisitions"
213
214
      - category: "REPORT_GROUP"
215
        authorised_value: "ACC"
216
        lib: "Accounts"
217
218
      - category: "REPORT_GROUP"
219
        authorised_value: "SER"
220
        lib: "Serials"
221
222
      # SIP2 media types
223
      - category: "SIP_MEDIA_TYPE"
224
        authorised_value: "000"
225
        lib: "Other"
226
227
      - category: "SIP_MEDIA_TYPE"
228
        authorised_value: "001"
229
        lib: "Book"
230
231
      - category: "SIP_MEDIA_TYPE"
232
        authorised_value: "002"
233
        lib: "Magazine"
234
235
      - category: "SIP_MEDIA_TYPE"
236
        authorised_value: "003"
237
        lib: "Bound journal"
238
239
      - category: "SIP_MEDIA_TYPE"
240
        authorised_value: "004"
241
        lib: "Audio tape"
242
243
      - category: "SIP_MEDIA_TYPE"
244
        authorised_value: "005"
245
        lib: "Video tape"
246
247
      - category: "SIP_MEDIA_TYPE"
248
        authorised_value: "006"
249
        lib: "CD/CDROM"
250
251
      - category: "SIP_MEDIA_TYPE"
252
        authorised_value: "007"
253
        lib: "Diskette"
254
255
      - category: "SIP_MEDIA_TYPE"
256
        authorised_value: "008"
257
        lib: "Book with diskette"
258
259
      - category: "SIP_MEDIA_TYPE"
260
        authorised_value: "009"
261
        lib: "Book with CD"
262
263
      - category: "SIP_MEDIA_TYPE"
264
        authorised_value: "010"
265
        lib: "Book with audio tape"
266
267
      # order cancellation reasons
268
      - category: "ORDER_CANCELLATION_REASON"
269
        authorised_value: 0
270
        lib: "No reason provided"
271
272
      - category: "ORDER_CANCELLATION_REASON"
273
        authorised_value: 1
274
        lib: "Out of stock"
275
276
      - category: "ORDER_CANCELLATION_REASON"
277
        authorised_value: 2
278
        lib: "Restocking"
279
280
      # return claims
281
      - category: "RETURN_CLAIM_RESOLUTION"
282
        authorised_value: "RET_BY_PATRON"
283
        lib: "Returned by patron"
284
285
      - category: "RETURN_CLAIM_RESOLUTION"
286
        authorised_value: "FOUND_IN_LIB"
287
        lib: "Found in library"

Return to bug 13897