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

(-)a/admin/smart-rules.pl (-20 / +29 lines)
Lines 426-453 elsif ($op eq "add-branch-item") { Link Here
426
        }
426
        }
427
    }
427
    }
428
}
428
}
429
elsif ( $op eq 'add-refund-lost-item-fee-rule' ) {
429
elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) {
430
    my $ref_branchcode = $input->param('ref_branchcode');
430
431
    my $ref_refund     = $input->param('ref_refund');
431
    my $refund = $input->param('refund');
432
    # We retrieve the object to update it, or create a new one
432
433
    my $refundLostItemFeeRule = Koha::RefundLostItemFeeRules->find({
433
    if ( $refund eq '*' ) {
434
                                    branchcode => $ref_branchcode
434
        if ( $branch ne '*' ) {
435
                                }) // Koha::RefundLostItemFeeRule->new;
435
            # only do something for $refund eq '*' if branch-specific
436
    $refundLostItemFeeRule->set({
436
            eval {
437
        branchcode => $ref_branchcode,
437
                # Delete it so it picks the default
438
            refund => $ref_refund
438
                Koha::RefundLostItemFeeRules->find({
439
    })->store();
439
                    branchcode => $branch
440
}
440
                })->delete;
441
elsif ( $op eq 'del-refund-lost-item-fee-rule' ) {
441
            };
442
    my $ref_branchcode = $input->param('ref_branchcode');
442
        }
443
    eval {
443
    } else {
444
        Koha::RefundLostItemFeeRules->find({
444
        my $refundRule =
445
            branchcode => $ref_branchcode
445
                Koha::RefundLostItemFeeRules->find({
446
        })->delete;
446
                    branchcode => $branch
447
    };
447
                }) // Koha::RefundLostItemFeeRule->new;
448
        $refundRule->set({
449
            branchcode => $branch,
450
                refund => $refund
451
        })->store;
452
    }
448
}
453
}
449
454
450
$template->param( refundLostItemFeeRules => scalar Koha::RefundLostItemFeeRules->search ) ;
455
my $refundLostItemFeeRule = Koha::RefundLostItemFeeRules->find({ branchcode => $branch });
456
$template->param(
457
    refundLostItemFeeRule => $refundLostItemFeeRule,
458
    defaultRefundRule     => Koha::RefundLostItemFeeRules->_default_rule
459
);
451
460
452
my $branches = GetBranches();
461
my $branches = GetBranches();
453
my @branchloop;
462
my @branchloop;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-37 / +59 lines)
Lines 560-615 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
560
    [% END %]
560
    [% END %]
561
561
562
    <div id="refund-lost-item-fee-on-return" class="container">
562
    <div id="refund-lost-item-fee-on-return" class="container">
563
    <h3>Lost item fee refund on return policy</h3>
563
  [% IF current_branch == '*' %]
564
    <h3>Default lost item fee refund on return policy</h3>
565
  [% ELSE %]
566
    <h3>Lost item fee refund on return policy for [% Branches.GetName(current_branch) %]</h3>
567
  [% END %]
564
        <p>Specify the default policy for lost item fees on return.
568
        <p>Specify the default policy for lost item fees on return.
565
        </p>
569
        </p>
566
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
570
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
567
            <input type="hidden" name="op" value="add-refund-lost-item-fee-rule" />
571
            <input type="hidden" name="op" value="mod-refund-lost-item-fee-rule" />
572
            <input type="hidden" name="branch" value="[% current_branch %]" />
568
            <table>
573
            <table>
569
                <tr>
574
                <tr>
570
                    <th>Library</th>
571
                    <th>Refund lost item fee</th>
575
                    <th>Refund lost item fee</th>
572
                    <th>&nbsp;</th>
576
                    <th>&nbsp;</th>
573
                </tr>
577
                </tr>
574
            [% FOREACH refundLostItemFeeRule IN refundLostItemFeeRules %]
575
                <tr>
578
                <tr>
576
                    <td>
579
                    <td>
577
                [% IF refundLostItemFeeRule.branchcode == '*' %]
580
                        <select name="refund">
578
                        All
581
                          [#% Default branch %#]
579
                [% ELSE %]
582
                          [% IF ( current_branch == '*' ) %]
580
                        [% Branches.GetName(refundLostItemFeeRule.branchcode) %]
583
                            [% IF ( refundLostItemFeeRule.refund ) %]
581
                [% END %]
584
                            <option value="1" selected="selected">
582
                    </td>
585
                            [% ELSE %]
583
                    <td>
586
                            <option value="1">
584
                [% IF refundLostItemFeeRule.refund %]
587
                            [% END %]
585
                        Yes
588
                                Yes
586
                [% ELSE %]
589
                            </option>
587
                        No
590
                            [% IF ( not refundLostItemFeeRule.refund ) %]
588
                [% END %]
591
                            <option value="0" selected="selected">
592
                            [% ELSE %]
593
                            <option value="0">
594
                            [% END %]
595
                                No
596
                            </option>
597
                          [% ELSE %]
598
                          [#% Branch-specific %#]
599
                            [% IF ( not refundLostItemFeeRule ) %]
600
                                <option value="*" selected="selected">
601
                            [% ELSE %]
602
                                <option value="*">
603
                            [% END %]
604
                              [% IF defaultRefundRule %]
605
                                Use default (Yes)
606
                              [% ELSE %]
607
                                Use default (No)
608
                              [% END %]
609
                                </option>
610
                            [% IF ( not refundLostItemFeeRule ) %]
611
                                <option value="1">Yes</option>
612
                                <option value="0">No</option>
613
                            [% ELSE %]
614
                                [% IF ( refundLostItemFeeRule.refund ) %]
615
                                <option value="1" selected="selected">
616
                                [% ELSE %]
617
                                <option value="1">
618
                                [% END %]
619
                                    Yes
620
                                </option>
621
                                [% IF ( not refundLostItemFeeRule.refund ) %]
622
                                <option value="0" selected="selected">
623
                                [% ELSE %]
624
                                <option value="0">
625
                                [% END %]
626
                                    No
627
                                </option>
628
                            [% END %]
629
                          [% END %]
630
                        </select>
589
                    </td>
631
                    </td>
590
                    <td class="actions">
632
                    <td class="actions">
591
                    [% IF refundLostItemFeeRule.branchcode != '*' %]
633
                        <button type="submit" class="btn btn-mini"><i class="fa fa-save"></i> Save</button>
592
                        <a class="btn btn-mini delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=del-refund-lost-item-fee-rule&amp;ref_branchcode=[% refundLostItemFeeRule.branchcode %]"><i class="fa fa-trash"></i> Delete</a>
593
                    [% END %]
594
                    </td>
595
                </tr>
596
            [% END %]
597
                <tr>
598
                    <td>
599
                        <select name="ref_branchcode">
600
                            <option value='*'>All</option>
601
                        [% FOREACH branch IN Branches.all %]
602
                            <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
603
                        [% END %]
604
                        </select>
605
                    </td>
634
                    </td>
606
                    <td>
607
                        <select name="ref_refund">
608
                            <option value="0">No</option>
609
                            <option value="1">Yes</option>
610
                        </select>
611
                    </td>
635
                    </td>
612
                    <td class="actions"><button type="submit" class="btn btn-mini"><i class="fa fa-plus"></i> Add</td>
613
                </tr>
636
                </tr>
614
            </table>
637
            </table>
615
        </form>
638
        </form>
616
- 

Return to bug 14048