View | Details | Raw Unified | Return to bug 15354
Collapse All | Expand All

(-)a/admin/smart-rules.pl (-11 / +19 lines)
Lines 460-467 $sth2->execute($language, $branch); Link Here
460
460
461
while (my $row = $sth2->fetchrow_hashref) {
461
while (my $row = $sth2->fetchrow_hashref) {
462
    $row->{'current_branch'} ||= $row->{'branchcode'};
462
    $row->{'current_branch'} ||= $row->{'branchcode'};
463
    $row->{'humanitemtype'} ||= $row->{'itemtype'};
463
    $row->{translated_description} ||= $row->{translated_description};
464
    $row->{'default_humanitemtype'} = 1 if $row->{'humanitemtype'} eq '*';
464
    $row->{default_translated_description} = 1 if $row->{humanitemtype} eq '*';
465
    $row->{'humancategorycode'} ||= $row->{'categorycode'};
465
    $row->{'humancategorycode'} ||= $row->{'categorycode'};
466
    $row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*';
466
    $row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*';
467
    $row->{'fine'} = sprintf('%.2f', $row->{'fine'});
467
    $row->{'fine'} = sprintf('%.2f', $row->{'fine'});
Lines 516-541 foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { Link Here
516
my $sth_branch_item;
516
my $sth_branch_item;
517
if ($branch eq "*") {
517
if ($branch eq "*") {
518
    $sth_branch_item = $dbh->prepare("
518
    $sth_branch_item = $dbh->prepare("
519
        SELECT default_branch_item_rules.*, itemtypes.description AS humanitemtype
519
        SELECT default_branch_item_rules.*,
520
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
520
        FROM default_branch_item_rules
521
        FROM default_branch_item_rules
521
        JOIN itemtypes USING (itemtype)
522
        JOIN itemtypes USING (itemtype)
523
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
524
            AND localization.entity = 'itemtypes'
525
            AND localization.lang = ?
522
    ");
526
    ");
523
    $sth_branch_item->execute();
527
    $sth_branch_item->execute($language);
524
} else {
528
} else {
525
    $sth_branch_item = $dbh->prepare("
529
    $sth_branch_item = $dbh->prepare("
526
        SELECT branch_item_rules.*, itemtypes.description AS humanitemtype
530
        SELECT branch_item_rules.*,
531
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
527
        FROM branch_item_rules
532
        FROM branch_item_rules
528
        JOIN itemtypes USING (itemtype)
533
        JOIN itemtypes USING (itemtype)
534
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
535
            AND localization.entity = 'itemtypes'
536
            AND localization.lang = ?
529
        WHERE branch_item_rules.branchcode = ?
537
        WHERE branch_item_rules.branchcode = ?
530
    ");
538
    ");
531
    $sth_branch_item->execute($branch);
539
    $sth_branch_item->execute($language, $branch);
532
}
540
}
533
541
534
my @branch_item_rules = ();
542
my @branch_item_rules = ();
535
while (my $row = $sth_branch_item->fetchrow_hashref) {
543
while (my $row = $sth_branch_item->fetchrow_hashref) {
536
    push @branch_item_rules, $row;
544
    push @branch_item_rules, $row;
537
}
545
}
538
my @sorted_branch_item_rules = sort { $a->{'humanitemtype'} cmp $b->{'humanitemtype'} } @branch_item_rules;
546
my @sorted_branch_item_rules = sort { $a->{translated_description} cmp $b->{translated_description} } @branch_item_rules;
539
547
540
# note undef holdallowed so that template can deal with them
548
# note undef holdallowed so that template can deal with them
541
foreach my $entry (@sorted_branch_item_rules) {
549
foreach my $entry (@sorted_branch_item_rules) {
Lines 609-619 sub by_category { Link Here
609
617
610
sub by_itemtype {
618
sub by_itemtype {
611
    my ($a, $b) = @_;
619
    my ($a, $b) = @_;
612
    if ($a->{'default_humanitemtype'}) {
620
    if ($a->{default_translated_description}) {
613
        return ($b->{'default_humanitemtype'} ? 0 : 1);
621
        return ($b->{'default_translated_description'} ? 0 : 1);
614
    } elsif ($b->{'default_humanitemtype'}) {
622
    } elsif ($b->{'default_translated_description'}) {
615
        return -1;
623
        return -1;
616
    } else {
624
    } else {
617
        return $a->{'humanitemtype'} cmp $b->{'humanitemtype'};
625
        return $a->{'translated_description'} cmp $b->{'translated_description'};
618
    }
626
    }
619
}
627
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-3 / +2 lines)
Lines 185-191 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
185
									[% rule.humancategorycode %]
185
									[% rule.humancategorycode %]
186
								[% END %]
186
								[% END %]
187
							</td>
187
							</td>
188
							<td>[% IF ( rule.default_humanitemtype ) %]
188
							<td>[% IF rule.default_translated_description %]
189
									<em>All</em>
189
									<em>All</em>
190
								[% ELSE %]
190
								[% ELSE %]
191
									[% rule.translated_description %]
191
									[% rule.translated_description %]
Lines 545-551 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
545
                    [% ELSE %]
545
                    [% ELSE %]
546
                    <tr>
546
                    <tr>
547
                    [% END %]
547
                    [% END %]
548
                        <td>[% IF ( branch_item_rule_loo.default_humanitemtype ) %]
548
                        <td>[% IF ( branch_item_rule_loo.default_translated_description ) %]
549
                                <em>Default</em>
549
                                <em>Default</em>
550
                            [% ELSE %]
550
                            [% ELSE %]
551
                                [% branch_item_rule_loo.translated_description %]
551
                                [% branch_item_rule_loo.translated_description %]
552
- 

Return to bug 15354