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