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

(-)a/C4/RotatingCollections.pm (+12 lines)
Lines 27-32 use Modern::Perl; Link Here
27
use C4::Context;
27
use C4::Context;
28
use C4::Circulation;
28
use C4::Circulation;
29
use C4::Reserves qw(CheckReserves);
29
use C4::Reserves qw(CheckReserves);
30
use Koha::Database;
30
31
31
use DBI;
32
use DBI;
32
33
Lines 84-92 BEGIN { Link Here
84
sub CreateCollection {
85
sub CreateCollection {
85
    my ( $title, $description ) = @_;
86
    my ( $title, $description ) = @_;
86
87
88
    my $schema = Koha::Database->new()->schema();
89
    my $duplicate_titles = $schema->resultset('Collection')->count({ colTitle => $title });
90
87
    ## Check for all neccessary parameters
91
    ## Check for all neccessary parameters
88
    if ( !$title ) {
92
    if ( !$title ) {
89
        return ( 0, 1, "NO_TITLE" );
93
        return ( 0, 1, "NO_TITLE" );
94
    } elsif ( $duplicate_titles ) {
95
        return ( 0, 2, "DUPLICATE_TITLE" );
90
    }
96
    }
91
97
92
    $description ||= q{};
98
    $description ||= q{};
Lines 127-132 Updates a collection Link Here
127
sub UpdateCollection {
133
sub UpdateCollection {
128
    my ( $colId, $title, $description ) = @_;
134
    my ( $colId, $title, $description ) = @_;
129
135
136
    my $schema = Koha::Database->new()->schema();
137
    my $duplicate_titles = $schema->resultset('Collection')->count({ colTitle => $title,  -not => { colId => $colId } });
138
130
    ## Check for all neccessary parameters
139
    ## Check for all neccessary parameters
131
    if ( !$colId ) {
140
    if ( !$colId ) {
132
        return ( 0, 1, "NO_ID" );
141
        return ( 0, 1, "NO_ID" );
Lines 134-139 sub UpdateCollection { Link Here
134
    if ( !$title ) {
143
    if ( !$title ) {
135
        return ( 0, 2, "NO_TITLE" );
144
        return ( 0, 2, "NO_TITLE" );
136
    }
145
    }
146
    if ( $duplicate_titles ) {
147
        return ( 0, 3, "DUPLICATE_TITLE" );
148
    }
137
149
138
    my $dbh = C4::Context->dbh;
150
    my $dbh = C4::Context->dbh;
139
151
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt (-1 / +4 lines)
Lines 37-42 Link Here
37
                    <p>
37
                    <p>
38
                        [% IF failureMessage == "NO_TITLE" %]
38
                        [% IF failureMessage == "NO_TITLE" %]
39
                            No title entered.
39
                            No title entered.
40
                        [% ELSIF failureMessage == "DUPLICATE_TITLE" %]
41
                            Title already in use.
40
                        [% ELSIF failureMessage == "NO_DESCRIPTION" %]
42
                        [% ELSIF failureMessage == "NO_DESCRIPTION" %]
41
                            No description entered.
43
                            No description entered.
42
                        [% ELSE %]
44
                        [% ELSE %]
Lines 70-75 Link Here
70
                    <p>
72
                    <p>
71
                        [% IF failureMessage == "NO_ID" %]
73
                        [% IF failureMessage == "NO_ID" %]
72
                            No collection id given.
74
                            No collection id given.
75
                        [% ELSIF failureMessage == "DUPLICATE_TITLE" %]
76
                            Title already in use.
73
                        [% ELSE %]
77
                        [% ELSE %]
74
                            [% failureMessage %]
78
                            [% failureMessage %]
75
                        [% END %]
79
                        [% END %]
76
- 

Return to bug 8836