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

(-)a/admin/smart-rules.pl (-11 / +19 lines)
Lines 442-449 $sth2->execute($language, $branch); Link Here
442
442
443
while (my $row = $sth2->fetchrow_hashref) {
443
while (my $row = $sth2->fetchrow_hashref) {
444
    $row->{'current_branch'} ||= $row->{'branchcode'};
444
    $row->{'current_branch'} ||= $row->{'branchcode'};
445
    $row->{'humanitemtype'} ||= $row->{'itemtype'};
445
    $row->{translated_description} ||= $row->{translated_description};
446
    $row->{'default_humanitemtype'} = 1 if $row->{'humanitemtype'} eq '*';
446
    $row->{default_translated_description} = 1 if $row->{humanitemtype} eq '*';
447
    $row->{'humancategorycode'} ||= $row->{'categorycode'};
447
    $row->{'humancategorycode'} ||= $row->{'categorycode'};
448
    $row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*';
448
    $row->{'default_humancategorycode'} = 1 if $row->{'humancategorycode'} eq '*';
449
    $row->{'fine'} = sprintf('%.2f', $row->{'fine'});
449
    $row->{'fine'} = sprintf('%.2f', $row->{'fine'});
Lines 498-523 foreach my $entry (@sorted_branch_cat_rules, @sorted_row_loop) { Link Here
498
my $sth_branch_item;
498
my $sth_branch_item;
499
if ($branch eq "*") {
499
if ($branch eq "*") {
500
    $sth_branch_item = $dbh->prepare("
500
    $sth_branch_item = $dbh->prepare("
501
        SELECT default_branch_item_rules.*, itemtypes.description AS humanitemtype
501
        SELECT default_branch_item_rules.*,
502
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
502
        FROM default_branch_item_rules
503
        FROM default_branch_item_rules
503
        JOIN itemtypes USING (itemtype)
504
        JOIN itemtypes USING (itemtype)
505
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
506
            AND localization.entity = 'itemtypes'
507
            AND localization.lang = ?
504
    ");
508
    ");
505
    $sth_branch_item->execute();
509
    $sth_branch_item->execute($language);
506
} else {
510
} else {
507
    $sth_branch_item = $dbh->prepare("
511
    $sth_branch_item = $dbh->prepare("
508
        SELECT branch_item_rules.*, itemtypes.description AS humanitemtype
512
        SELECT branch_item_rules.*,
513
            COALESCE( localization.translation, itemtypes.description ) AS translated_description
509
        FROM branch_item_rules
514
        FROM branch_item_rules
510
        JOIN itemtypes USING (itemtype)
515
        JOIN itemtypes USING (itemtype)
516
        LEFT JOIN localization ON itemtypes.itemtype = localization.code
517
            AND localization.entity = 'itemtypes'
518
            AND localization.lang = ?
511
        WHERE branch_item_rules.branchcode = ?
519
        WHERE branch_item_rules.branchcode = ?
512
    ");
520
    ");
513
    $sth_branch_item->execute($branch);
521
    $sth_branch_item->execute($language, $branch);
514
}
522
}
515
523
516
my @branch_item_rules = ();
524
my @branch_item_rules = ();
517
while (my $row = $sth_branch_item->fetchrow_hashref) {
525
while (my $row = $sth_branch_item->fetchrow_hashref) {
518
    push @branch_item_rules, $row;
526
    push @branch_item_rules, $row;
519
}
527
}
520
my @sorted_branch_item_rules = sort { $a->{'humanitemtype'} cmp $b->{'humanitemtype'} } @branch_item_rules;
528
my @sorted_branch_item_rules = sort { $a->{translated_description} cmp $b->{translated_description} } @branch_item_rules;
521
529
522
# note undef holdallowed so that template can deal with them
530
# note undef holdallowed so that template can deal with them
523
foreach my $entry (@sorted_branch_item_rules) {
531
foreach my $entry (@sorted_branch_item_rules) {
Lines 591-601 sub by_category { Link Here
591
599
592
sub by_itemtype {
600
sub by_itemtype {
593
    my ($a, $b) = @_;
601
    my ($a, $b) = @_;
594
    if ($a->{'default_humanitemtype'}) {
602
    if ($a->{default_translated_description}) {
595
        return ($b->{'default_humanitemtype'} ? 0 : 1);
603
        return ($b->{'default_translated_description'} ? 0 : 1);
596
    } elsif ($b->{'default_humanitemtype'}) {
604
    } elsif ($b->{'default_translated_description'}) {
597
        return -1;
605
        return -1;
598
    } else {
606
    } else {
599
        return $a->{'humanitemtype'} cmp $b->{'humanitemtype'};
607
        return $a->{'translated_description'} cmp $b->{'translated_description'};
600
    }
608
    }
601
}
609
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-3 / +2 lines)
Lines 173-179 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
173
									[% rule.humancategorycode %]
173
									[% rule.humancategorycode %]
174
								[% END %]
174
								[% END %]
175
							</td>
175
							</td>
176
							<td>[% IF ( rule.default_humanitemtype ) %]
176
							<td>[% IF rule.default_translated_description %]
177
									<em>All</em>
177
									<em>All</em>
178
								[% ELSE %]
178
								[% ELSE %]
179
									[% rule.translated_description %]
179
									[% rule.translated_description %]
Lines 527-533 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
527
                    [% ELSE %]
527
                    [% ELSE %]
528
                    <tr>
528
                    <tr>
529
                    [% END %]
529
                    [% END %]
530
                        <td>[% IF ( branch_item_rule_loo.default_humanitemtype ) %]
530
                        <td>[% IF ( branch_item_rule_loo.default_translated_description ) %]
531
                                <em>Default</em>
531
                                <em>Default</em>
532
                            [% ELSE %]
532
                            [% ELSE %]
533
                                [% branch_item_rule_loo.translated_description %]
533
                                [% branch_item_rule_loo.translated_description %]
534
- 

Return to bug 15354