new feature : image for itemtypes.
[koha_fer] / updater / updatedatabase
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Database Updater
6 # This script checks for required updates to the database.
7
8 # Part of the Koha Library Software www.koha.org
9 # Licensed under the GPL.
10
11 # Bugs/ToDo:
12 # - Would also be a good idea to offer to do a backup at this time...
13
14 # NOTE:  If you do something more than once in here, make it table driven.
15 use strict;
16
17 # CPAN modules
18 use DBI;
19 use Getopt::Long;
20 # Koha modules
21 use C4::Context;
22
23 use MARC::Record;
24 use MARC::File::XML;
25
26 # FIXME - The user might be installing a new database, so can't rely
27 # on /etc/koha.conf anyway.
28
29 my $debug = 0;
30
31 my (
32     $sth, $sti,
33     $query,
34     %existingtables,    # tables already in database
35     %types,
36     $table,
37     $column,
38     $type, $null, $key, $default, $extra,
39     $prefitem,          # preference item in systempreferences table
40 );
41
42 my $silent;
43 GetOptions(
44         's' =>\$silent
45         );
46 my $dbh = C4::Context->dbh;
47 print "connected to your DB. Checking & modifying it\n" unless $silent;
48 $|=1; # flushes output
49
50 #-------------------
51 # Defines
52
53 # Tables to add if they don't exist
54 my %requiretables = (
55     categorytable       => "(categorycode char(5) NOT NULL default '',
56                              description text default '',
57                              itemtypecodes text default '',
58                              PRIMARY KEY (categorycode)
59                             )",
60     subcategorytable       => "(subcategorycode char(5) NOT NULL default '',
61                              description text default '',
62                              itemtypecodes text default '',
63                              PRIMARY KEY (subcategorycode)
64                             )",
65     mediatypetable       => "(mediatypecode char(5) NOT NULL default '',
66                              description text default '',
67                              itemtypecodes text default '',
68                              PRIMARY KEY (mediatypecode)
69                             )",
70     action_logs         => "(
71                                     `timestamp` TIMESTAMP NOT NULL ,
72                                     `user` INT( 11 ) NOT NULL ,
73                                     `module` TEXT default '',
74                                     `action` TEXT default '' ,
75                                     `object` INT(11) default '' ,
76                                     `info` TEXT default '' ,
77                                     PRIMARY KEY ( `timestamp` , `user` )
78                             )",
79         letter          => "(
80                                         module varchar(20) NOT NULL default '',
81                                         code varchar(20) NOT NULL default '',
82                                         name varchar(100) NOT NULL default '',
83                                         title varchar(200) NOT NULL default '',
84                                         content text,
85                                         PRIMARY KEY  (module,code)
86                                 )",
87         alert           =>"(
88                                         alertid int(11) NOT NULL auto_increment,
89                                         borrowernumber int(11) NOT NULL default '0',
90                                         type varchar(10) NOT NULL default '',
91                                         externalid varchar(20) NOT NULL default '',
92                                         PRIMARY KEY  (alertid),
93                                         KEY borrowernumber (borrowernumber),
94                                         KEY type (type,externalid)
95                                 )",
96
97 );
98
99 my %requirefields = (
100         subscription => { 'letter' => 'char(20) NULL'},
101         itemtypes => { 'imageurl' => 'char(200) NULL'},
102 #    tablename        => { 'field' => 'fieldtype' },
103 );
104
105 my %dropable_table = (
106 # tablename => 'tablename',
107 );
108
109 my %uselessfields = (
110 # tablename => "field1,field2",
111         );
112 # the other hash contains other actions that can't be done elsewhere. they are done
113 # either BEFORE of AFTER everything else, depending on "when" entry (default => AFTER)
114
115 # The tabledata hash contains data that should be in the tables.
116 # The uniquefieldrequired hash entry is used to determine which (if any) fields
117 # must not exist in the table for this row to be inserted.  If the
118 # uniquefieldrequired entry is already in the table, the existing data is not
119 # modified, unless the forceupdate hash entry is also set.  Fields in the
120 # anonymous "forceupdate" hash will be forced to be updated to the default
121 # values given in the %tabledata hash.
122
123 my %tabledata = (
124 # tablename => [
125 #       {       uniquefielrequired => 'fieldname', # the primary key in the table
126 #               fieldname => fieldvalue,
127 #               fieldname2 => fieldvalue2,
128 #       },
129 # ],
130     systempreferences => [
131                 {
132             uniquefieldrequired => 'variable',
133             variable            => 'Activate_Log',
134             value               => 'On',
135             forceupdate         => { 'explanation' => 1,
136                                      'type' => 1},
137             explanation         => 'Turn Log Actions on DB On an Off',
138             type                => 'YesNo',
139         },
140         {
141             uniquefieldrequired => 'variable',
142             variable            => 'IndependantBranches',
143             value               => 0,
144             forceupdate         => { 'explanation' => 1,
145                                      'type' => 1},
146             explanation         => 'Turn Branch independancy management On an Off',
147             type                => 'YesNo',
148         },
149                 {
150             uniquefieldrequired => 'variable',
151             variable            => 'ReturnBeforeExpiry',
152             value               => 'Off',
153             forceupdate         => { 'explanation' => 1,
154                                      'type' => 1},
155             explanation         => 'If Yes, Returndate on issuing can\'t be after borrower card expiry',
156             type                => 'YesNo',
157         },
158     ],
159
160 );
161
162 my %fielddefinitions = (
163 # fieldname => [
164 #       {                 field => 'fieldname',
165 #             type    => 'fieldtype',
166 #             null    => '',
167 #             key     => '',
168 #             default => ''
169 #         },
170 #     ],
171         serial => [
172         {
173             field   => 'notes',
174             type    => 'TEXT',
175             null    => 'NULL',
176             key     => '',
177             default => '',
178             extra   => ''
179         },
180     ],
181 );
182
183 #-------------------
184 # Initialize
185
186 # Start checking
187
188 # Get version of MySQL database engine.
189 my $mysqlversion = `mysqld --version`;
190 $mysqlversion =~ /Ver (\S*) /;
191 $mysqlversion = $1;
192 if ( $mysqlversion ge '3.23' ) {
193     print "Could convert to MyISAM database tables...\n" unless $silent;
194 }
195
196 #---------------------------------
197 # Tables
198
199 # Collect all tables into a list
200 $sth = $dbh->prepare("show tables");
201 $sth->execute;
202 while ( my ($table) = $sth->fetchrow ) {
203     $existingtables{$table} = 1;
204 }
205
206
207 # Now add any missing tables
208 foreach $table ( keys %requiretables ) {
209     unless ( $existingtables{$table} ) {
210         print "Adding $table table...\n" unless $silent;
211         my $sth = $dbh->prepare("create table $table $requiretables{$table}");
212         $sth->execute;
213         if ( $sth->err ) {
214             print "Error : $sth->errstr \n";
215             $sth->finish;
216         }    # if error
217     }    # unless exists
218 }    # foreach
219
220 # now drop useless tables
221 foreach $table ( keys %dropable_table ) {
222         if ( $existingtables{$table} ) {
223                 print "Dropping unused table $table\n" if $debug and not $silent;
224                 $dbh->do("drop table $table");
225                 if ( $dbh->err ) {
226                         print "Error : $dbh->errstr \n";
227                 }
228         }
229 }
230
231 #---------------------------------
232 # Columns
233
234 foreach $table ( keys %requirefields ) {
235     print "Check table $table\n" if $debug and not $silent;
236     $sth = $dbh->prepare("show columns from $table");
237     $sth->execute();
238     undef %types;
239     while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
240     {
241         $types{$column} = $type;
242     }    # while
243     foreach $column ( keys %{ $requirefields{$table} } ) {
244         print "  Check column $column  [$types{$column}]\n" if $debug and not $silent;
245         if ( !$types{$column} ) {
246
247             # column doesn't exist
248             print "Adding $column field to $table table...\n" unless $silent;
249             $query = "alter table $table
250                         add column $column " . $requirefields{$table}->{$column};
251             print "Execute: $query\n" if $debug;
252             my $sti = $dbh->prepare($query);
253             $sti->execute;
254             if ( $sti->err ) {
255                 print "**Error : $sti->errstr \n";
256                 $sti->finish;
257             }    # if error
258         }    # if column
259     }    # foreach column
260 }    # foreach table
261
262 foreach $table ( keys %fielddefinitions ) {
263         print "Check table $table\n" if $debug;
264         $sth = $dbh->prepare("show columns from $table");
265         $sth->execute();
266         my $definitions;
267         while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
268         {
269                 $definitions->{$column}->{type}    = $type;
270                 $definitions->{$column}->{null}    = $null;
271                 $definitions->{$column}->{key}     = $key;
272                 $definitions->{$column}->{default} = $default;
273                 $definitions->{$column}->{extra}   = $extra;
274         }    # while
275         my $fieldrow = $fielddefinitions{$table};
276         foreach my $row (@$fieldrow) {
277                 my $field   = $row->{field};
278                 my $type    = $row->{type};
279                 my $null    = $row->{null};
280 #               $null    = 'YES' if $row->{null} eq 'NULL';
281                 my $key     = $row->{key};
282                 my $default = $row->{default};
283                 $default="''" unless $default;
284                 my $extra   = $row->{extra};
285                 my $def     = $definitions->{$field};
286                 unless ( $type eq $def->{type}
287                         && $null eq $def->{null}
288                         && $key eq $def->{key}
289                         && $default eq $def->{default}
290                         && $extra eq $def->{extra} )
291                 {
292
293                         if ( $null eq '' ) {
294                                 $null = 'NOT NULL';
295                         }
296                         if ( $key eq 'PRI' ) {
297                                 $key = 'PRIMARY KEY';
298                         }
299                         unless ( $extra eq 'auto_increment' ) {
300                                 $extra = '';
301                         }
302                         # if it's a new column use "add", if it's an old one, use "change".
303                         my $action;
304                         if ($definitions->{$field}->{type}) {
305                                 $action="change $field"
306                         } else {
307                                 $action="add";
308                         }
309 # if it's a primary key, drop the previous pk, before altering the table
310                         my $sth;
311                         if ($key ne 'PRIMARY KEY') {
312                                 $sth =$dbh->prepare("alter table $table $action $field $type $null $key $extra default ?");
313                         } else {
314                                 $sth =$dbh->prepare("alter table $table drop primary key, $action $field $type $null $key $extra default ?");
315                         }
316                         $sth->execute($default);
317                         print "  Alter $field in $table\n" unless $silent;
318                 }
319         }
320 }
321
322
323 # Populate tables with required data
324 foreach my $table ( keys %tabledata ) {
325     print "Checking for data required in table $table...\n" unless $silent;
326     my $tablerows = $tabledata{$table};
327     foreach my $row (@$tablerows) {
328         my $uniquefieldrequired = $row->{uniquefieldrequired};
329         my $uniquevalue         = $row->{$uniquefieldrequired};
330         my $forceupdate         = $row->{forceupdate};
331         my $sth                 =
332           $dbh->prepare(
333 "select $uniquefieldrequired from $table where $uniquefieldrequired=?"
334         );
335         $sth->execute($uniquevalue);
336         if ($sth->rows) {
337             foreach my $field (keys %$forceupdate) {
338                 if ($forceupdate->{$field}) {
339                     my $sth=$dbh->prepare("update systempreferences set $field=? where $uniquefieldrequired=?");
340                     $sth->execute($row->{$field}, $uniquevalue);
341                 }
342             }
343         } else {
344             print "Adding row to $table: " unless $silent;
345             my @values;
346             my $fieldlist;
347             my $placeholders;
348             foreach my $field ( keys %$row ) {
349                 next if $field eq 'uniquefieldrequired';
350                 next if $field eq 'forceupdate';
351                 my $value = $row->{$field};
352                 push @values, $value;
353                 print "  $field => $value" unless $silent;
354                 $fieldlist .= "$field,";
355                 $placeholders .= "?,";
356             }
357             print "\n" unless $silent;
358             $fieldlist    =~ s/,$//;
359             $placeholders =~ s/,$//;
360             my $sth =
361               $dbh->prepare(
362                 "insert into $table ($fieldlist) values ($placeholders)");
363             $sth->execute(@values);
364         }
365     }
366 }
367
368 #
369 # SPECIFIC STUFF
370 #
371 #
372 # create frameworkcode row in biblio table & fill it with marc_biblio.frameworkcode.
373 #
374
375 # 1st, get how many biblio we will have to do...
376 $sth = $dbh->prepare('select count(*) from marc_biblio');
377 $sth->execute;
378 my ($totaltodo) = $sth->fetchrow;
379
380 $sth = $dbh->prepare("show columns from biblio");
381 $sth->execute();
382 my $definitions;
383 my $bibliofwexist=0;
384 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ){
385         $bibliofwexist=1 if $column eq 'frameworkcode';
386 }
387 unless ($bibliofwexist) {
388         print "moving biblioframework to biblio table\n";
389         $dbh->do('ALTER TABLE `biblio` ADD `frameworkcode` VARCHAR( 4 ) NOT NULL AFTER `biblionumber`');
390         $sth = $dbh->prepare('select biblionumber,frameworkcode from marc_biblio');
391         $sth->execute;
392         my $sth_update = $dbh->prepare('update biblio set frameworkcode=? where biblionumber=?');
393         my $totaldone=0;
394         while (my ($biblionumber,$frameworkcode) = $sth->fetchrow) {
395                 $sth_update->execute($frameworkcode,$biblionumber);
396                 $totaldone++;
397                 print "\r$totaldone / $totaltodo" unless ($totaldone % 100);
398         }
399         print "\rdone\n";
400 }
401
402 #
403 # moving MARC data from marc_subfield_table to biblioitems.marc
404 #
405 $sth = $dbh->prepare("show columns from biblioitems");
406 $sth->execute();
407 my $definitions;
408 my $marcdone=0;
409 while ( ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow ){
410         $marcdone=1 if ($type eq 'blob' && $column eq 'marc') ;
411 }
412 unless ($marcdone) {
413         print "moving MARC record to biblioitems table\n";
414         # changing marc field type
415         $dbh->do('ALTER TABLE `biblioitems` CHANGE `marc` `marc` BLOB NULL DEFAULT NULL ');
416         # adding marc xml, just for convenience
417         $dbh->do('ALTER TABLE `biblioitems` ADD `marcxml` TEXT NOT NULL');
418         # moving data from marc_subfield_value to biblio
419         $sth = $dbh->prepare('select bibid,biblionumber from marc_biblio');
420         $sth->execute;
421         my $sth_update = $dbh->prepare('update biblioitems set marc=?, marcxml=? where biblionumber=?');
422         my $totaldone=0;
423         while (my ($bibid,$biblionumber) = $sth->fetchrow) {
424                 my $record = MARCgetbiblio($dbh,$bibid);
425                 $sth_update->execute($record->as_usmarc(),$record->as_xml(),$biblionumber);
426                 $totaldone++;
427                 print "\r$totaldone / $totaltodo" unless ($totaldone % 100);
428         }
429         print "\rdone\n";
430 }
431
432 # at last, remove useless fields
433 foreach $table ( keys %uselessfields ) {
434         my @fields = split /,/,$uselessfields{$table};
435         my $fields;
436         my $exists;
437         foreach my $fieldtodrop (@fields) {
438                 $fieldtodrop =~ s/\t//g;
439                 $fieldtodrop =~ s/\n//g;
440                 $exists =0;
441                 $sth = $dbh->prepare("show columns from $table");
442                 $sth->execute;
443                 while ( my ( $column, $type, $null, $key, $default, $extra ) = $sth->fetchrow )
444                 {
445                         $exists =1 if ($column eq $fieldtodrop);
446                 }
447                 if ($exists) {
448                         print "deleting $fieldtodrop field in $table...\n" unless $silent;
449                         my $sth = $dbh->prepare("alter table $table drop $fieldtodrop");
450                         $sth->execute;
451                 }
452         }
453 }    # foreach
454
455
456 $sth->finish;
457
458 #
459 # those 2 subs are a copy of Biblio.pm, version 2.2.4
460 # they are useful only once, for moving from 2.2 to 3.0
461 # the MARCgetbiblio & MARCgetitem subs in Biblio.pm
462 # are still here, but uses other tables
463 # (the ones that are filled by updatedatabase !)
464 #
465 sub MARCgetbiblio {
466
467     # Returns MARC::Record of the biblio passed in parameter.
468     my ( $dbh, $bibid ) = @_;
469     my $record = MARC::Record->new();
470 #       warn "". $bidid;
471
472     my $sth =
473       $dbh->prepare(
474 "select bibid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink
475                                  from marc_subfield_table
476                                  where bibid=? order by tag,tagorder,subfieldorder
477                          "
478     );
479     my $sth2 =
480       $dbh->prepare(
481         "select subfieldvalue from marc_blob_subfield where blobidlink=?");
482     $sth->execute($bibid);
483     my $prevtagorder = 1;
484     my $prevtag      = 'XXX';
485     my $previndicator;
486     my $field;        # for >=10 tags
487     my $prevvalue;    # for <10 tags
488     while ( my $row = $sth->fetchrow_hashref ) {
489
490         if ( $row->{'valuebloblink'} ) {    #---- search blob if there is one
491             $sth2->execute( $row->{'valuebloblink'} );
492             my $row2 = $sth2->fetchrow_hashref;
493             $sth2->finish;
494             $row->{'subfieldvalue'} = $row2->{'subfieldvalue'};
495         }
496         if ( $row->{tagorder} ne $prevtagorder || $row->{tag} ne $prevtag ) {
497             $previndicator .= "  ";
498             if ( $prevtag < 10 ) {
499                                 if ($prevtag ne '000') {
500                         $record->add_fields( ( sprintf "%03s", $prevtag ), $prevvalue ) unless $prevtag eq "XXX";    # ignore the 1st loop
501                                 } else {
502                                         $record->leader(sprintf("%24s",$prevvalue));
503                                 }
504             }
505             else {
506                 $record->add_fields($field) unless $prevtag eq "XXX";
507             }
508             undef $field;
509             $prevtagorder  = $row->{tagorder};
510             $prevtag       = $row->{tag};
511             $previndicator = $row->{tag_indicator};
512             if ( $row->{tag} < 10 ) {
513                 $prevvalue = $row->{subfieldvalue};
514             }
515             else {
516                 $field = MARC::Field->new(
517                     ( sprintf "%03s", $prevtag ),
518                     substr( $row->{tag_indicator} . '  ', 0, 1 ),
519                     substr( $row->{tag_indicator} . '  ', 1, 1 ),
520                     $row->{'subfieldcode'},
521                     $row->{'subfieldvalue'}
522                 );
523             }
524         }
525         else {
526             if ( $row->{tag} < 10 ) {
527                 $record->add_fields( ( sprintf "%03s", $row->{tag} ),
528                     $row->{'subfieldvalue'} );
529             }
530             else {
531                 $field->add_subfields( $row->{'subfieldcode'},
532                     $row->{'subfieldvalue'} );
533             }
534             $prevtag       = $row->{tag};
535             $previndicator = $row->{tag_indicator};
536         }
537     }
538
539     # the last has not been included inside the loop... do it now !
540     if ( $prevtag ne "XXX" )
541     { # check that we have found something. Otherwise, prevtag is still XXX and we
542          # must return an empty record, not make MARC::Record fail because we try to
543          # create a record with XXX as field :-(
544         if ( $prevtag < 10 ) {
545             $record->add_fields( $prevtag, $prevvalue );
546         }
547         else {
548
549             #           my $field = MARC::Field->new( $prevtag, "", "", %subfieldlist);
550             $record->add_fields($field);
551         }
552     }
553     return $record;
554 }
555
556 sub MARCgetitem {
557
558     # Returns MARC::Record of the biblio passed in parameter.
559     my ( $dbh, $bibid, $itemnumber ) = @_;
560     my $record = MARC::Record->new();
561
562     # search MARC tagorder
563     my $sth2 =
564       $dbh->prepare(
565 "select tagorder from marc_subfield_table,marc_subfield_structure where marc_subfield_table.tag=marc_subfield_structure.tagfield and marc_subfield_table.subfieldcode=marc_subfield_structure.tagsubfield and bibid=? and kohafield='items.itemnumber' and subfieldvalue=?"
566     );
567     $sth2->execute( $bibid, $itemnumber );
568     my ($tagorder) = $sth2->fetchrow_array();
569
570     #---- TODO : the leader is missing
571     my $sth =
572       $dbh->prepare(
573 "select bibid,subfieldid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue,valuebloblink
574                                  from marc_subfield_table
575                                  where bibid=? and tagorder=? order by subfieldcode,subfieldorder
576                          "
577     );
578     $sth2 =
579       $dbh->prepare(
580         "select subfieldvalue from marc_blob_subfield where blobidlink=?");
581     $sth->execute( $bibid, $tagorder );
582     while ( my $row = $sth->fetchrow_hashref ) {
583         if ( $row->{'valuebloblink'} ) {    #---- search blob if there is one
584             $sth2->execute( $row->{'valuebloblink'} );
585             my $row2 = $sth2->fetchrow_hashref;
586             $sth2->finish;
587             $row->{'subfieldvalue'} = $row2->{'subfieldvalue'};
588         }
589         if ( $record->field( $row->{'tag'} ) ) {
590             my $field;
591
592 #--- this test must stay as this, because of strange behaviour of mySQL/Perl DBI with char var containing a number...
593             #--- sometimes, eliminates 0 at beginning, sometimes no ;-\\\
594             if ( length( $row->{'tag'} ) < 3 ) {
595                 $row->{'tag'} = "0" . $row->{'tag'};
596             }
597             $field = $record->field( $row->{'tag'} );
598             if ($field) {
599                 my $x =
600                   $field->add_subfields( $row->{'subfieldcode'},
601                     $row->{'subfieldvalue'} );
602                 $record->delete_field($field);
603                 $record->add_fields($field);
604             }
605         }
606         else {
607             if ( length( $row->{'tag'} ) < 3 ) {
608                 $row->{'tag'} = "0" . $row->{'tag'};
609             }
610             my $temp =
611               MARC::Field->new( $row->{'tag'}, " ", " ",
612                 $row->{'subfieldcode'} => $row->{'subfieldvalue'} );
613             $record->add_fields($temp);
614         }
615
616     }
617     return $record;
618 }
619
620
621 exit;
622
623 # $Log$
624 # Revision 1.122  2005/09/02 14:18:38  tipaul
625 # new feature : image for itemtypes.
626 #
627 # * run updater/updatedatabase to create imageurl field in itemtypes.
628 # * go to Koha >> parameters >> itemtypes >> modify (or add) an itemtype. You will see around 20 nice images to choose between (thanks to owen). If you prefer your own image, you also can type a complete url (http://www.myserver.lib/path/to/my/image.gif)
629 # * go to OPAC, and search something. In the result list, you now have the picture instead of the text itemtype.
630 #
631 # Revision 1.121  2005/08/24 08:49:03  hdl
632 # Adding a note field in serial table.
633 # This will allow librarian to mention a note on a peculiar waiting serial number.
634 #
635 # Revision 1.120  2005/08/09 14:10:32  tipaul
636 # 1st commit to go to zebra.
637 # don't update your cvs if you want to have a working head...
638 #
639 # this commit contains :
640 # * updater/updatedatabase : get rid with marc_* tables, but DON'T remove them. As a lot of things uses them, it would not be a good idea for instance to drop them. If you really want to play, you can rename them to test head without them but being still able to reintroduce them...
641 # * Biblio.pm : modify MARCgetbiblio to find the raw marc record in biblioitems.marc field, not from marc_subfield_table, modify MARCfindframeworkcode to find frameworkcode in biblio.frameworkcode, modify some other subs to use biblio.biblionumber & get rid of bibid.
642 # * other files : get rid of bibid and use biblionumber instead.
643 #
644 # What is broken :
645 # * does not do anything on zebra yet.
646 # * if you rename marc_subfield_table, you can't search anymore.
647 # * you can view a biblio & bibliodetails, go to MARC editor, but NOT save any modif.
648 # * don't try to add a biblio, it would add data poorly... (don't try to delete either, it may work, but that would be a surprise ;-) )
649 #
650 # IMPORTANT NOTE : you need MARC::XML package (http://search.cpan.org/~esummers/MARC-XML-0.7/lib/MARC/File/XML.pm), that requires a recent version of MARC::Record
651 # Updatedatabase stores the iso2709 data in biblioitems.marc field & an xml version in biblioitems.marcxml Not sure we will keep it when releasing the stable version, but I think it's a good idea to have something readable in sql, at least for development stage.
652 #
653 # Revision 1.119  2005/08/04 16:07:58  tipaul
654 # Synch really broke this script...
655 #
656 # Revision 1.118  2005/08/04 16:02:55  tipaul
657 # oops... error in synch between 2.2 and head
658 #
659 # Revision 1.117  2005/08/04 14:24:39  tipaul
660 # synch'ing 2.2 and head
661 #
662 # Revision 1.116  2005/08/04 08:55:54  tipaul
663 # Letters / alert system, continuing...
664 #
665 # * adding a package Letters.pm, that manages Letters & alerts.
666 # * adding feature : it's now possible to define a "letter" for any subscription created. If a letter is defined, users in OPAC can put an alert on the subscription. When an issue is marked "arrived", all users in the alert will recieve a mail (as defined in the "letter"). This last part (= send the mail) is not yet developped. (Should be done this week)
667 # * adding feature : it's now possible to "put to an alert" in OPAC, for any serial subscription. The alert is stored in a new table, called alert. An alert can be put only if the librarian has activated them in subscription (and they activate it just by choosing a "letter" to sent to borrowers on new issues)
668 # * adding feature : librarian can see in borrower detail which alerts they have put, and a user can see in opac-detail which alert they have put too.
669 #
670 # Note that the system should be generic enough to manage any type of alert.
671 # I plan to extend it soon to virtual shelves : a borrower will be able to put an alert on a virtual shelf, to be warned when something is changed in the virtual shelf (mail being sent once a day by cron, or manually by the shelf owner. Anyway, a mail won't be sent on every change, users would be spammed by Koha ;-) )
672 #
673 # Revision 1.115  2005/08/02 16:15:34  tipaul
674 # adding 2 fields to letter system :
675 # * module (acquisition, catalogue...) : it will be usefull to show the librarian only letters he may be interested by.
676 # * title, that will be used as mail subject.
677 #
678 # Revision 1.114  2005/07/28 15:10:13  tipaul
679 # Introducing new "Letters" system : Letters will be used everytime you want to sent something to someone (through mail or paper). For example, sending a mail for overdues use letter that you can put as parameters. Sending a mail to a borrower when a suggestion is validated uses a letter too.
680 # the letter table contains 3 fields :
681 # * code => the code of the letter
682 # * name => the complete name of the letter
683 # * content => the complete text. It's a TEXT field type, so has no limits.
684 #
685 # My next goal now is to work on point 2-I "serial issue alert"
686 # With this feature, in serials, a user can subscribe the "issue alert". For every issue arrived/missing, a mail is sent to all subscribers of this list. The mail warns the user that the issue is arrive or missing. Will be in head.
687 # (see mail on koha-devel, 2005/04/07)
688 #
689 # The "serial issue alert" will be the 1st to use this letter system that probably needs some tweaking ;-)
690 #
691 # Once it will be stabilised default letters (in any languages) could be added during installer to help the library begin with this new feature.
692 #
693 # Revision 1.113  2005/07/28 08:38:41  tipaul
694 # For instance, the return date does not rely on the borrower expiration date. A systempref will be added in Koha, to modify return date calculation schema :
695 # * ReturnBeforeExpiry = yes => return date can't be after expiry date
696 # * ReturnBeforeExpiry = no  => return date can be after expiry date
697 #
698 # Revision 1.112  2005/07/26 08:19:47  hdl
699 # Adding IndependantBranches System preference variable in order to manage Branch independancy.
700 #
701 # Revision 1.111  2005/07/25 15:35:38  tipaul
702 # we have decided that moving to Koha 3.0 requires being already in Koha 2.2.x
703 # So, the updatedatabase script can highly be cleaned (90% removed).
704 # Let's play with the new Koha DB structure now ;-)
705 #