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

(-)a/C4/Koha.pm (-15 / +17 lines)
Lines 41-47 BEGIN { Link Here
41
		&subfield_is_koha_internal_p
41
		&subfield_is_koha_internal_p
42
		&GetPrinters &GetPrinter
42
		&GetPrinters &GetPrinter
43
		&GetItemTypes &getitemtypeinfo
43
		&GetItemTypes &getitemtypeinfo
44
		&GetItemTypesFlat
45
		&GetCcodes
44
		&GetCcodes
46
		&GetSupportName &GetSupportList
45
		&GetSupportName &GetSupportList
47
		&get_itemtypeinfos_of
46
		&get_itemtypeinfos_of
Lines 205-214 sub GetSupportList{ Link Here
205
}
204
}
206
=head2 GetItemTypes
205
=head2 GetItemTypes
207
206
208
  $itemtypes = &GetItemTypes();
207
  $itemtypes = &GetItemTypes( style => $style );
209
208
210
Returns information about existing itemtypes.
209
Returns information about existing itemtypes.
211
210
211
Params: 
212
    style: either 'array' or 'hash', defaults to 'hash'.
213
           'array' returns an arrayref,
214
           'hash' return a hashref with the itemtype value as the key
215
    
212
build a HTML select with the following code :
216
build a HTML select with the following code :
213
217
214
=head3 in PERL SCRIPT
218
=head3 in PERL SCRIPT
Lines 241-247 build a HTML select with the following code : Link Here
241
=cut
245
=cut
242
246
243
sub GetItemTypes {
247
sub GetItemTypes {
244
248
    my ( %params ) = @_;
249
    my $style = defined( $params{'style'} ) ? $params{'style'} : 'hash';
250
    
245
    # returns a reference to a hash of references to itemtypes...
251
    # returns a reference to a hash of references to itemtypes...
246
    my %itemtypes;
252
    my %itemtypes;
247
    my $dbh   = C4::Context->dbh;
253
    my $dbh   = C4::Context->dbh;
Lines 251-269 sub GetItemTypes { Link Here
251
    |;
257
    |;
252
    my $sth = $dbh->prepare($query);
258
    my $sth = $dbh->prepare($query);
253
    $sth->execute;
259
    $sth->execute;
254
    while ( my $IT = $sth->fetchrow_hashref ) {
260
    
255
        $itemtypes{ $IT->{'itemtype'} } = $IT;
261
    if ( $style eq 'hash' ) {
262
        while ( my $IT = $sth->fetchrow_hashref ) {
263
            $itemtypes{ $IT->{'itemtype'} } = $IT;
264
        }
265
        return ( \%itemtypes );
266
    } else {
267
        return $sth->fetchall_arrayref({});
256
    }
268
    }
257
    return ( \%itemtypes );
258
}
259
260
sub GetItemTypesFlat {
261
    my $dbh   = C4::Context->dbh;
262
    my $query = "SELECT * FROM itemtypes ORDER BY description";
263
    my $sth = $dbh->prepare($query);
264
    $sth->execute;
265
266
    return $sth->fetchall_arrayref({});
267
}
269
}
268
270
269
sub get_itemtypeinfos_of {
271
sub get_itemtypeinfos_of {
(-)a/course_reserves/add_items.pl (-1 / +1 lines)
Lines 72-78 if ( $action eq 'lookup' ) { Link Here
72
72
73
        ccodes    => GetAuthorisedValues('CCODE'),
73
        ccodes    => GetAuthorisedValues('CCODE'),
74
        locations => GetAuthorisedValues('LOC'),
74
        locations => GetAuthorisedValues('LOC'),
75
        itypes    => GetItemTypesFlat(),
75
        itypes    => GetItemTypes( style => 'array' ),
76
        branches  => GetBranchesLoop(),
76
        branches  => GetBranchesLoop(),
77
    );
77
    );
78
78
(-)a/course_reserves/mod_course.pl (-5 / +1 lines)
Lines 1-10 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
#script to modify reserves/requests
3
# Copyright 2012 ByWater Solutions
4
#written 2/1/00 by chris@katipo.oc.nz
5
#last update 27/1/2000 by chris@katipo.co.nz
6
7
# Copyright 2000-2002 Katipo Communications
8
#
4
#
9
# This file is part of Koha.
5
# This file is part of Koha.
10
#
6
#
(-)a/installer/data/mysql/kohastructure.sql (-2 / +23 lines)
Lines 505-510 CREATE TABLE `course_instructors` ( Link Here
505
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
505
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
506
506
507
--
507
--
508
-- Constraints for table `course_instructors`
509
--
510
ALTER TABLE `course_instructors`
511
  ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
512
  ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;
513
514
--
508
-- Table structure for table `course_items`
515
-- Table structure for table `course_items`
509
--
516
--
510
517
Lines 523-532 CREATE TABLE `course_items` ( Link Here
523
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no', -- If at least one enabled course has this item on reseve, this field will be 'yes', otherwise it will be 'no'
530
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no', -- If at least one enabled course has this item on reseve, this field will be 'yes', otherwise it will be 'no'
524
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
531
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
525
   PRIMARY KEY (`ci_id`),
532
   PRIMARY KEY (`ci_id`),
526
   UNIQUE KEY `itemnumber` (`itemnumber`)
533
   UNIQUE KEY `itemnumber` (`itemnumber`),
534
   KEY `holdingbranch` (`holdingbranch`)
527
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
535
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
528
536
529
--
537
--
538
-- Constraints for table `course_items`
539
--
540
ALTER TABLE `course_items`
541
  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
542
  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
543
544
--
530
-- Table structure for table `course_reserves`
545
-- Table structure for table `course_reserves`
531
--
546
--
532
547
Lines 542-552 CREATE TABLE `course_reserves` ( Link Here
542
  `public_note` mediumtext, -- Public, OPAC visible note
557
  `public_note` mediumtext, -- Public, OPAC visible note
543
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
558
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
544
   PRIMARY KEY (`cr_id`),
559
   PRIMARY KEY (`cr_id`),
545
   UNIQUE KEY `psuedo_key` (`course_id`,`ci_id`),
560
   UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
546
   KEY `course_id` (`course_id`)
561
   KEY `course_id` (`course_id`)
547
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
562
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
548
563
549
--
564
--
565
-- Constraints for table `course_reserves`
566
--
567
ALTER TABLE `course_reserves`
568
  ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
569
570
--
550
-- Table structure for table `borrower_branch_circ_rules`
571
-- Table structure for table `borrower_branch_circ_rules`
551
--
572
--
552
573
(-)a/installer/data/mysql/updatedatabase.pl (-3 / +21 lines)
Lines 5728-5733 CREATE TABLE `course_instructors` ( Link Here
5728
");
5728
");
5729
5729
5730
$dbh->do("
5730
$dbh->do("
5731
ALTER TABLE `course_instructors`
5732
  ADD CONSTRAINT `course_instructors_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`),
5733
  ADD CONSTRAINT `course_instructors_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE;  
5734
");
5735
5736
$dbh->do("
5731
CREATE TABLE `course_items` (
5737
CREATE TABLE `course_items` (
5732
  `ci_id` int(11) NOT NULL AUTO_INCREMENT,
5738
  `ci_id` int(11) NOT NULL AUTO_INCREMENT,
5733
  `itemnumber` int(11) NOT NULL,
5739
  `itemnumber` int(11) NOT NULL,
Lines 5738-5748 CREATE TABLE `course_items` ( Link Here
5738
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
5744
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no',
5739
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5745
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5740
   PRIMARY KEY (`ci_id`),
5746
   PRIMARY KEY (`ci_id`),
5741
   UNIQUE KEY `itemnumber` (`itemnumber`)
5747
   UNIQUE KEY `itemnumber` (`itemnumber`),
5748
   KEY `holdingbranch` (`holdingbranch`)
5742
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5749
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5743
");
5750
");
5744
5751
5745
$dbh->do("
5752
$dbh->do("
5753
ALTER TABLE `course_items`
5754
  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
5755
  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;  
5756
");
5757
5758
$dbh->do("
5746
CREATE TABLE `course_reserves` (
5759
CREATE TABLE `course_reserves` (
5747
  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
5760
  `cr_id` int(11) NOT NULL AUTO_INCREMENT,
5748
  `course_id` int(11) NOT NULL,
5761
  `course_id` int(11) NOT NULL,
Lines 5751-5762 CREATE TABLE `course_reserves` ( Link Here
5751
  `public_note` mediumtext,
5764
  `public_note` mediumtext,
5752
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5765
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
5753
   PRIMARY KEY (`cr_id`),
5766
   PRIMARY KEY (`cr_id`),
5754
   UNIQUE KEY `psuedo_key` (`course_id`,`ci_id`),
5767
   UNIQUE KEY `pseudo_key` (`course_id`,`ci_id`),
5755
   KEY `course_id` (`course_id`)
5768
   KEY `course_id` (`course_id`)
5756
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5769
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
5757
");
5770
");
5758
5771
5759
$dbh->do("
5772
$dbh->do("
5773
ALTER TABLE `course_reserves`
5774
  ADD CONSTRAINT `course_reserves_ibfk_1` FOREIGN KEY (`course_id`) REFERENCES `courses` (`course_id`);
5775
");
5776
5777
$dbh->do("
5760
INSERT INTO permissions (module_bit, code, description) VALUES
5778
INSERT INTO permissions (module_bit, code, description) VALUES
5761
  (18, 'manage_courses', 'Add, edit and delete courses'),
5779
  (18, 'manage_courses', 'Add, edit and delete courses'),
5762
  (18, 'add_reserves', 'Add course reserves'),
5780
  (18, 'add_reserves', 'Add course reserves'),
Lines 5764-5769 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
5764
;
5782
;
5765
");
5783
");
5766
5784
5785
5767
    print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
5786
    print "Upgrade to $DBversion done (Add Course Reserves ( system preference UseCourseReserves ))\n";
5768
    SetVersion($DBversion);
5787
    SetVersion($DBversion);
5769
}
5788
}
5770
- 

Return to bug 8215