Lines 457-464
$sth2->execute($language, $branch);
Link Here
|
457 |
|
457 |
|
458 |
while (my $row = $sth2->fetchrow_hashref) { |
458 |
while (my $row = $sth2->fetchrow_hashref) { |
459 |
$row->{'current_branch'} ||= $row->{'branchcode'}; |
459 |
$row->{'current_branch'} ||= $row->{'branchcode'}; |
460 |
$row->{'humanitemtype'} ||= $row->{'itemtype'}; |
460 |
$row->{translated_description} ||= $row->{translated_description}; |
461 |
$row->{'default_humanitemtype'} = 1 if $row->{'humanitemtype'} eq '*'; |
461 |
$row->{default_translated_description} = 1 if $row->{humanitemtype} eq '*'; |
462 |
$row->{'humancategorycode'} ||= $row->{'categorycode'}; |
462 |
$row->{'humancategorycode'} ||= $row->{'categorycode'}; |
463 |
$row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*'; |
463 |
$row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*'; |
464 |
$row->{'fine'} = sprintf('%.2f', $row->{'fine'}); |
464 |
$row->{'fine'} = sprintf('%.2f', $row->{'fine'}); |
Lines 513-538
foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) {
Link Here
|
513 |
my $sth_branch_item; |
513 |
my $sth_branch_item; |
514 |
if ($branch eq "*") { |
514 |
if ($branch eq "*") { |
515 |
$sth_branch_item = $dbh->prepare(" |
515 |
$sth_branch_item = $dbh->prepare(" |
516 |
SELECT default_branch_item_rules.*, itemtypes.description AS humanitemtype |
516 |
SELECT default_branch_item_rules.*, |
|
|
517 |
COALESCE( localization.translation, itemtypes.description ) AS translated_description |
517 |
FROM default_branch_item_rules |
518 |
FROM default_branch_item_rules |
518 |
JOIN itemtypes USING (itemtype) |
519 |
JOIN itemtypes USING (itemtype) |
|
|
520 |
LEFT JOIN localization ON itemtypes.itemtype = localization.code |
521 |
AND localization.entity = 'itemtypes' |
522 |
AND localization.lang = ? |
519 |
"); |
523 |
"); |
520 |
$sth_branch_item->execute(); |
524 |
$sth_branch_item->execute($language); |
521 |
} else { |
525 |
} else { |
522 |
$sth_branch_item = $dbh->prepare(" |
526 |
$sth_branch_item = $dbh->prepare(" |
523 |
SELECT branch_item_rules.*, itemtypes.description AS humanitemtype |
527 |
SELECT branch_item_rules.*, |
|
|
528 |
COALESCE( localization.translation, itemtypes.description ) AS translated_description |
524 |
FROM branch_item_rules |
529 |
FROM branch_item_rules |
525 |
JOIN itemtypes USING (itemtype) |
530 |
JOIN itemtypes USING (itemtype) |
|
|
531 |
LEFT JOIN localization ON itemtypes.itemtype = localization.code |
532 |
AND localization.entity = 'itemtypes' |
533 |
AND localization.lang = ? |
526 |
WHERE branch_item_rules.branchcode = ? |
534 |
WHERE branch_item_rules.branchcode = ? |
527 |
"); |
535 |
"); |
528 |
$sth_branch_item->execute($branch); |
536 |
$sth_branch_item->execute($language, $branch); |
529 |
} |
537 |
} |
530 |
|
538 |
|
531 |
my @branch_item_rules = (); |
539 |
my @branch_item_rules = (); |
532 |
while (my $row = $sth_branch_item->fetchrow_hashref) { |
540 |
while (my $row = $sth_branch_item->fetchrow_hashref) { |
533 |
push @branch_item_rules, $row; |
541 |
push @branch_item_rules, $row; |
534 |
} |
542 |
} |
535 |
my @sorted_branch_item_rules = sort { $a->{'humanitemtype'} cmp $b->{'humanitemtype'} } @branch_item_rules; |
543 |
my @sorted_branch_item_rules = sort { $a->{translated_description} cmp $b->{translated_description} } @branch_item_rules; |
536 |
|
544 |
|
537 |
# note undef holdallowed so that template can deal with them |
545 |
# note undef holdallowed so that template can deal with them |
538 |
foreach my $entry (@sorted_branch_item_rules) { |
546 |
foreach my $entry (@sorted_branch_item_rules) { |
Lines 606-616
sub by_category {
Link Here
|
606 |
|
614 |
|
607 |
sub by_itemtype { |
615 |
sub by_itemtype { |
608 |
my ($a, $b) = @_; |
616 |
my ($a, $b) = @_; |
609 |
if ($a->{'default_humanitemtype'}) { |
617 |
if ($a->{default_translated_description}) { |
610 |
return ($b->{'default_humanitemtype'} ? 0 : 1); |
618 |
return ($b->{'default_translated_description'} ? 0 : 1); |
611 |
} elsif ($b->{'default_humanitemtype'}) { |
619 |
} elsif ($b->{'default_translated_description'}) { |
612 |
return -1; |
620 |
return -1; |
613 |
} else { |
621 |
} else { |
614 |
return $a->{'humanitemtype'} cmp $b->{'humanitemtype'}; |
622 |
return $a->{'translated_description'} cmp $b->{'translated_description'}; |
615 |
} |
623 |
} |
616 |
} |
624 |
} |