|
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 |
|