|
Lines 176-181
sub add_new_branch {
Link Here
|
| 176 |
branchcode => $copyBranch |
176 |
branchcode => $copyBranch |
| 177 |
}); |
177 |
}); |
| 178 |
|
178 |
|
|
|
179 |
unless ($branch_rs->count) { |
| 180 |
$copyBranch = Koha::Libraries->next->branchcode; |
| 181 |
$branch_rs = $schema->resultset('DiscreteCalendar')->search({ |
| 182 |
branchcode => $copyBranch |
| 183 |
}); |
| 184 |
} |
| 185 |
|
| 186 |
$schema->{AutoCommit} = 0; |
| 187 |
$schema->storage->txn_begin; |
| 188 |
|
| 179 |
while(my $row = $branch_rs->next()){ |
189 |
while(my $row = $branch_rs->next()){ |
| 180 |
$schema->resultset('DiscreteCalendar')->create({ |
190 |
$schema->resultset('DiscreteCalendar')->create({ |
| 181 |
date => $row->date(), |
191 |
date => $row->date(), |
|
Lines 187-194
sub add_new_branch {
Link Here
|
| 187 |
}); |
197 |
}); |
| 188 |
} |
198 |
} |
| 189 |
|
199 |
|
|
|
200 |
eval { $schema->storage->txn_commit; }; |
| 201 |
|
| 202 |
if ($@) { |
| 203 |
$schema->storage->rollback; |
| 204 |
} |
| 205 |
|
| 206 |
$schema->{AutoCommit} = 1; |
| 190 |
} |
207 |
} |
| 191 |
|
208 |
|
|
|
209 |
=head2 delete_branch |
| 210 |
|
| 211 |
Koha::DiscreteCalendar->delete_branch($branchcode) |
| 212 |
|
| 213 |
This method will delete every discrete_calendar entry for a given branch |
| 214 |
C<$branchcode> is the code of the branch we want to remove from the table |
| 215 |
|
| 216 |
=cut |
| 217 |
|
| 218 |
sub delete_branch { |
| 219 |
my ( $classname, $branchcode ) = @_; |
| 220 |
|
| 221 |
my $schema = Koha::Database->new->schema; |
| 222 |
|
| 223 |
my $branch_rs = $schema->resultset('DiscreteCalendar')->search({ |
| 224 |
branchcode => $branchcode |
| 225 |
}); |
| 226 |
|
| 227 |
if ($branch_rs->count) { |
| 228 |
$branch_rs->delete; |
| 229 |
} |
| 230 |
} |
| 231 |
|
| 232 |
|
| 192 |
=head2 get_date_info |
233 |
=head2 get_date_info |
| 193 |
|
234 |
|
| 194 |
my $date = $calendar->get_date_info; |
235 |
my $date = $calendar->get_date_info; |