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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-1 / +1 lines)
Lines 1073-1079 Link Here
1073
1073
1074
                                <form method="post" action="/cgi-bin/koha/tools/batch_modify_holds.pl" id="batch_modify_holds" target="_blank">
1074
                                <form method="post" action="/cgi-bin/koha/tools/batch_modify_holds.pl" id="batch_modify_holds" target="_blank">
1075
                                    [% INCLUDE 'csrf-token.inc' %]
1075
                                    [% INCLUDE 'csrf-token.inc' %]
1076
                                    <input type="hidden" name="op" value="form" />
1076
                                    <input type="hidden" name="op" value="cud-form" />
1077
                                    <textarea style="display:none" name="reserve_ids_list" id="reserve_ids_list">
1077
                                    <textarea style="display:none" name="reserve_ids_list" id="reserve_ids_list">
1078
                                    [%# Preserve the whitespace of the following textarea in order to format the values correctly %]
1078
                                    [%# Preserve the whitespace of the following textarea in order to format the values correctly %]
1079
                                        [%- reserve_ids = PROCESS batch_list results=results batch_type='reserve_id' | trim | html %][% IF reserve_ids %][% SET batch_reserve_ids = 1 %][% reserve_ids | html %][% END -%]
1079
                                        [%- reserve_ids = PROCESS batch_list results=results batch_type='reserve_id' | trim | html %][% IF reserve_ids %][% SET batch_reserve_ids = 1 %][% reserve_ids | html %][% END -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt (-12 / +30 lines)
Lines 42-48 Link Here
42
        <div class="col-sm-10 col-sm-push-2 order-sm-1">
42
        <div class="col-sm-10 col-sm-push-2 order-sm-1">
43
            <main>
43
            <main>
44
                <h1>Batch modify holds</h1>
44
                <h1>Batch modify holds</h1>
45
                [% IF view == "form" %]
45
                [% IF view == "cud-form" %]
46
                    <div id="modify_holds_search">
46
                    <div id="modify_holds_search">
47
                        <form method="get" action="/cgi-bin/koha/tools/batch_modify_holds.pl" id="modify_holds_form">
47
                        <form method="get" action="/cgi-bin/koha/tools/batch_modify_holds.pl" id="modify_holds_form">
48
                            <fieldset class="rows">
48
                            <fieldset class="rows">
Lines 50-56 Link Here
50
                                <ol>
50
                                <ol>
51
                                    <li>
51
                                    <li>
52
                                        <label for="expirationdate_from">Expiration date from:</label>
52
                                        <label for="expirationdate_from">Expiration date from:</label>
53
                                        <input type="text" size="10" id="expirationdate_from" name="expirationdate_from" class="flatpickr" data-date_to="expirationdate_to" />
53
                                        <input type="text" size="10" id="expirationdate_from" name="expirationdate_from" class="flatpickr" />
54
                                    </li>
54
                                    </li>
55
                                    <li>
55
                                    <li>
56
                                        <label for="expirationdate_to">Expiration date to:</label>
56
                                        <label for="expirationdate_to">Expiration date to:</label>
Lines 303-311 Link Here
303
                        var expirationdate_from = modify_holds_form.find("#expirationdate_from").val();
303
                        var expirationdate_from = modify_holds_form.find("#expirationdate_from").val();
304
                        var expirationdate_to   = modify_holds_form.find("#expirationdate_to").val();
304
                        var expirationdate_to   = modify_holds_form.find("#expirationdate_to").val();
305
305
306
                        searchpattern += expirationdate_from && expirationdate_to ? _("expiration date between ")+ expirationdate_from + " and " + expirationdate_to + " ": "";
306
                        if (expirationdate_from && expirationdate_to){
307
307
                            searchpattern += _("expiration date between ") + expirationdate_from + " and " + expirationdate_to + " ";
308
                        return expirationdate_from && expirationdate_to ? {"-between": [expirationdate_from, expirationdate_to]} : "";
308
                            return {"-between": [expirationdate_from, expirationdate_to]};
309
                        }
310
                        else if (expirationdate_from && !expirationdate_to){
311
                            searchpattern += _("expiration date from ") + expirationdate_from + " ";
312
                            return {">=": expirationdate_from };
313
                        } else if (!expirationdate_from && expirationdate_to){
314
                            searchpattern += _("expiration date to ") + expirationdate_to + " ";
315
                            return {"<=": expirationdate_to };
316
                        }
309
                    },
317
                    },
310
                    "me.branchcode": function(){
318
                    "me.branchcode": function(){
311
                        var branchcodes = modify_holds_form.find("#branchcodes").val();
319
                        var branchcodes = modify_holds_form.find("#branchcodes").val();
Lines 354-360 Link Here
354
                        var suspend_until_from  = modify_holds_form.find("#suspend_until_from").val();
362
                        var suspend_until_from  = modify_holds_form.find("#suspend_until_from").val();
355
                        var suspend_until_to    = modify_holds_form.find("#suspend_until_to").val();
363
                        var suspend_until_to    = modify_holds_form.find("#suspend_until_to").val();
356
364
357
                        searchpattern += suspend_until_from && suspend_until_to ? _("suspend date between ")+ suspend_until_from +"-"+suspend_until_to : "";
365
                        searchpattern += suspend_until_from && suspend_until_to ? _("suspend date between ")+ suspend_until_from +" and "+suspend_until_to : "";
358
366
359
                        return suspend_until_from && suspend_until_to ? {"-between": [suspend_until_from, suspend_until_to]} : "";
367
                        return suspend_until_from && suspend_until_to ? {"-between": [suspend_until_from, suspend_until_to]} : "";
360
                    },
368
                    },
Lines 468-477 Link Here
468
                        {
476
                        {
469
                            "data": "suspended",
477
                            "data": "suspended",
470
                            "name": "suspended",
478
                            "name": "suspended",
479
                            "className": "suspended",
471
                            "title": _("Suspended"),
480
                            "title": _("Suspended"),
472
                            "orderable": true,
481
                            "orderable": true,
473
                            "render": function( data, type, row, meta ) {
482
                            "render": function( data, type, row, meta ) {
474
                                return data == 0 ? _("No") : _("Yes");
483
                                var suspended_string = data == 0 ? _("No") : _("Yes");
484
                                return "<span data-suspended='" + data + "'>" + suspended_string + "</span>";
475
                            }
485
                            }
476
                        },
486
                        },
477
                        {
487
                        {
Lines 521-527 Link Here
521
                    errors.push(_("Please select at least one hold to process."));
531
                    errors.push(_("Please select at least one hold to process."));
522
                }
532
                }
523
533
524
                if( new_pickup_loc || new_suspend_status ){
534
                if( new_pickup_loc || new_suspend_status || new_suspend_date ){
525
                    var found = false;
535
                    var found = false;
526
                    holds_checked.each(function(){
536
                    holds_checked.each(function(){
527
                        if($(this).parents("tr").children(".found_status").children("span").data("found-status")){
537
                        if($(this).parents("tr").children(".found_status").children("span").data("found-status")){
Lines 529-544 Link Here
529
                            found = true;
539
                            found = true;
530
                        }
540
                        }
531
                    });
541
                    });
532
                    if( new_suspend_status && found ){
542
                    if( ( new_suspend_status || new_suspend_date ) && found ){
533
                        errors.push(_("One or more holds have found status and can't be suspended."));
543
                        errors.push(_("One or more holds have found status and can't be suspended."));
534
                    }
544
                    }
535
                    if( new_pickup_loc && found ){
545
                    if( new_pickup_loc && found ){
536
                        errors.push(_("One or more holds have found status and their pick up location can't be changed."));
546
                        errors.push(_("One or more holds have found status and their pick up location can't be changed."));
537
                    }
547
                    }
538
                }
548
                }
539
                if( ( !new_suspend_status || new_suspend_status == "0") && new_suspend_date ){
549
540
                    e.preventDefault();
550
                var suspended = false;
541
                    errors.push(_("You have to suspend holds if new suspend until date is set."));
551
552
                holds_checked.each(function(){
553
                    if($(this).parents("tr").children(".suspended").children("span").data("suspended")){
554
                        suspended = true;
555
                    }
556
                });
557
558
                if( ( !new_suspend_status || new_suspend_status == "0" || !suspended ) && new_suspend_date ){
559
                    new_suspend_status = 1;
542
                }
560
                }
543
561
544
                if (errors.length > 0) {
562
                if (errors.length > 0) {
(-)a/tools/batch_modify_holds.pl (-13 / +13 lines)
Lines 30-36 use Koha::DateUtils qw( dt_from_string ); Link Here
30
use Koha::Holds;
30
use Koha::Holds;
31
31
32
my $input = CGI->new;
32
my $input = CGI->new;
33
my $op    = $input->param('op') // q|form|;
33
my $op    = $input->param('op') // q|cud-form|;
34
34
35
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
35
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
36
    {
36
    {
Lines 43-55 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
43
43
44
my @hold_ids;
44
my @hold_ids;
45
45
46
if ( $op eq 'form' ) {
46
if ( $op eq 'cud-form' ) {
47
    my $reserve_ids_list = $input->param('reserve_ids_list') || undef;
47
    my $reserve_ids_list = $input->param('reserve_ids_list') || undef;
48
    if ($reserve_ids_list) {
48
    if ($reserve_ids_list) {
49
        my @reserve_ids = split /\n/, $reserve_ids_list;
49
        my @reserve_ids = split /\n/, $reserve_ids_list;
50
        $template->param( reserve_ids_list => to_json( \@reserve_ids ), );
50
        $template->param( reserve_ids_list => to_json( \@reserve_ids ), );
51
    }
51
    }
52
    $template->param( view => 'form', );
52
    $template->param( view => 'cud-form', );
53
} elsif ( $op eq 'cud-modify' ) {
53
} elsif ( $op eq 'cud-modify' ) {
54
    my $new_expiration_date = $input->param('new_expiration_date');
54
    my $new_expiration_date = $input->param('new_expiration_date');
55
    my $new_pickup_loc      = $input->param('new_pickup_loc');
55
    my $new_pickup_loc      = $input->param('new_pickup_loc');
Lines 73-90 if ( $op eq 'form' ) { Link Here
73
            $hold->branchcode($new_pickup_loc)->store;
73
            $hold->branchcode($new_pickup_loc)->store;
74
        }
74
        }
75
75
76
        if ( $new_suspend_status ne "" && !$hold->is_found ) {
76
        if ( $new_suspend_status && $new_suspend_status ne "" && !$hold->is_found ) {
77
            if ($new_suspend_status) {
77
            $hold->suspend(1)->store;
78
                $hold->suspend(1)->store;
78
            if ($new_suspend_date) {
79
                if ($new_suspend_date) {
79
                $hold->suspend_until($new_suspend_date)->store;
80
                    $hold->suspend_until($new_suspend_date)->store;
81
                } else {
82
                    $hold->suspend_until(undef)->store;
83
                }
84
            } else {
80
            } else {
85
                $hold->suspend(0)->store;
86
                $hold->suspend_until(undef)->store;
81
                $hold->suspend_until(undef)->store;
87
            }
82
            }
83
        } elsif ( !$new_suspend_status && $new_suspend_date ) {
84
            $hold->suspend(1)->store;
85
            $hold->suspend_until($new_suspend_date)->store;
86
        } else {
87
            $hold->suspend(0)->store;
88
            $hold->suspend_until(undef)->store;
88
        }
89
        }
89
90
90
        if ($new_hold_note) {
91
        if ($new_hold_note) {
91
- 

Return to bug 36135