Bug 28530: (QA follow-up) Use DBIC in controller

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2026-02-04 17:45:19 +00:00 committed by Lucas Gass
parent 24afe8e36e
commit 3ee2efa9d0
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 13 additions and 9 deletions

View File

@ -48,21 +48,25 @@ if ( $op eq 'cud-set_float_limits' ) {
$schema->txn_do(
sub {
$schema->storage->dbh->do("DELETE FROM library_float_limits");
# Clear all existing float limits using DBIC
Koha::Library::FloatLimits->delete;
foreach my $branch (@branches) {
foreach my $itemtype (@itemtypes) {
my $branchcode = $branch->id;
my $itype = $itemtype->id;
my $limit = $input->param( "limit_" . $branchcode . "_" . $itype );
Koha::Library::FloatLimit->new(
{
branchcode => $branchcode,
itemtype => $itype,
float_limit => $limit,
}
)->store()
if $limit ne q{}; # update or insert
# Validate: must be empty or a non-negative integer
if ( $limit ne q{} && $limit =~ /^\d+$/ && $limit >= 0 ) {
Koha::Library::FloatLimit->new(
{
branchcode => $branchcode,
itemtype => $itype,
float_limit => $limit,
}
)->store(); # update or insert
}
}
}
$template->param( float_limits_updated => 1 );