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

(-)a/Koha/Library.pm (+28 lines)
Lines 50-55 sub stockrotationstages { Link Here
50
    return Koha::StockRotationStages->_new_from_dbic( $rs );
50
    return Koha::StockRotationStages->_new_from_dbic( $rs );
51
}
51
}
52
52
53
=head3 outgoing_transfers
54
55
  my $outgoing_transfers = Koha::Library->outgoing_transfers;
56
57
Returns the outgoing item transfers associated with this Library.
58
59
=cut
60
61
sub outgoing_transfers {
62
    my ( $self ) = @_;
63
    my $rs = $self->_result->branchtransfers_frombranches;
64
    return Koha::Item::Transfers->_new_from_dbic( $rs );
65
}
66
67
=head3 inbound_transfers
68
69
  my $inbound_transfers = Koha::Library->inbound_transfers;
70
71
Returns the inbound item transfers associated with this Library.
72
73
=cut
74
75
sub inbound_transfers {
76
    my ( $self ) = @_;
77
    my $rs = $self->_result->branchtransfers_tobranches;
78
    return Koha::Item::Transfers->_new_from_dbic( $rs );
79
}
80
53
=head3 get_effective_marcorgcode
81
=head3 get_effective_marcorgcode
54
82
55
    my $marcorgcode = Koha::Libraries->find( $library_id )->get_effective_marcorgcode();
83
    my $marcorgcode = Koha::Libraries->find( $library_id )->get_effective_marcorgcode();
(-)a/Koha/StockRotationItem.pm (+43 lines)
Lines 275-280 sub advance { Link Here
275
    return $transfer;
275
    return $transfer;
276
}
276
}
277
277
278
=head3 toggle_indemand
279
280
  $sritem->toggle_indemand;
281
282
Toggle this items in_demand status.
283
284
If the item is in the process of being advanced to the next stage then we cancel
285
the transfer, revert the advancement and reset the 'StockrotationAdvance' counter,
286
as though 'in_demand' had been set prior to the call to advance, by updating the
287
in progress transfer.
288
289
=cut
290
291
sub toggle_indemand {
292
    my ( $self ) = @_;
293
294
    # Toggle the item's indemand flag
295
    my $new_indemand = ($self->indemand == 1) ? 0 : 1;
296
297
    # Cancel 'StockrotationAdvance' transfer if one is in progress
298
    if ($new_indemand) {
299
        my $item = $self->itemnumber;
300
        my $transfer = $item->get_transfer;
301
        if ($transfer && $transfer->reason eq 'StockrotationAdvance') {
302
            my $stage = $self->stage;
303
            my $new_stage;
304
            if ( $stage->rota->cyclical && !$stage->first_sibling ) { # First stage
305
                $new_stage = $stage->last_sibling;
306
            } else {
307
                $new_stage = $stage->previous_sibling;
308
            }
309
            $self->stage_id($new_stage->stage_id)->store;        # Revert stage change
310
            $item->homebranch($new_stage->branchcode_id)->store; # Revert update homebranch
311
            $new_indemand = 0;                                   # Reset indemand
312
            $transfer->tobranch($new_stage->branchcode_id);      # Reset StockrotationAdvance
313
            $transfer->datearrived(dt_from_string);              # Reset StockrotationAdvance
314
            $transfer->store;
315
        }
316
    }
317
318
    $self->indemand($new_indemand)->store;
319
}
320
278
=head3 investigate
321
=head3 investigate
279
322
280
  my $report = $item->investigate;
323
  my $report = $item->investigate;
(-)a/Koha/Util/StockRotation.pm (-8 / +3 lines)
Lines 97-117 sub get_stages { Link Here
97
97
98
sub toggle_indemand {
98
sub toggle_indemand {
99
99
100
    my ($item_id, $stage_id) = @_;
100
    my ($item_id) = @_;
101
101
102
    # Get the item object
102
    # Get the item object
103
    my $item = Koha::StockRotationItems->find(
103
    my $sr_item = Koha::StockRotationItems->find(
104
        {
104
        {
105
            itemnumber_id => $item_id,
105
            itemnumber_id => $item_id,
106
            stage_id      => $stage_id
107
        }
106
        }
108
    );
107
    );
109
108
110
    # Toggle the item's indemand flag
109
    $sr_item->toggle_indemand;
111
    my $new_indemand = ($item->indemand == 1) ? 0 : 1;
112
113
    $item->indemand($new_indemand)->store;
114
115
}
110
}
116
111
117
=head2 move_to_next_stage
112
=head2 move_to_next_stage
(-)a/circ/transferstosend.pl (+69 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2019 PTFS-Europe Ltd.
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use CGI qw ( -utf8 );
22
use C4::Context;
23
use C4::Auth;
24
use C4::Output;
25
26
use Koha::DateUtils;
27
28
my $input      = new CGI;
29
my $itemnumber = $input->param('itemnumber');
30
31
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
32
    {
33
        template_name   => "circ/transferstosend.tt",
34
        query           => $input,
35
        type            => "intranet",
36
        authnotrequired => 0,
37
        flagsrequired   => { circulate => "circulate_remaining_permissions" },
38
        debug           => 1,
39
    }
40
);
41
42
# set the userenv branch
43
my $branchcode = C4::Context->userenv->{'branch'};
44
45
# transfers requested but not yet sent
46
my @transfers = Koha::Libraries->search(
47
    {
48
        'branchtransfers_tobranches.frombranch'    => $branchcode,
49
        'branchtransfers_tobranches.daterequested' => { '!=' => undef },
50
        'branchtransfers_tobranches.datesent'      => undef,
51
        'branchtransfers_tobranches.datearrived'   => undef,
52
        'branchtransfers_tobranches.datecancelled' => undef,
53
        'branchtransfers_tobranches.reason' =>
54
          [ "StockrotationAdvance", "StockrotationRepatriation" ]
55
    },
56
    {
57
        prefetch => 'branchtransfers_tobranches',
58
        order_by => 'branchtransfers_tobranches.tobranch'
59
    }
60
);
61
62
$template->param(
63
    branchesloop => \@transfers,
64
    show_date    => output_pref(
65
        { dt => dt_from_string, dateformat => 'iso', dateonly => 1 }
66
    )
67
);
68
69
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt (+3 lines)
Lines 97-102 Link Here
97
                            <a class="circ-button" href="/cgi-bin/koha/circ/branchtransfers.pl"><i class="fa fa-exchange"></i> Transfer</a>
97
                            <a class="circ-button" href="/cgi-bin/koha/circ/branchtransfers.pl"><i class="fa fa-exchange"></i> Transfer</a>
98
                        </li>
98
                        </li>
99
                    [% END %]
99
                    [% END %]
100
                    <li>
101
                        <a class="circ-button" href="/cgi-bin/koha/circ/transferstosend.pl"><i class="fa fa-sign-out"></i> Transfers to send</a>
102
                    </li>
100
                    <li>
103
                    <li>
101
                        <a class="circ-button" href="/cgi-bin/koha/circ/transferstoreceive.pl"><i class="fa fa-sign-in"></i> Transfers to receive</a>
104
                        <a class="circ-button" href="/cgi-bin/koha/circ/transferstoreceive.pl"><i class="fa fa-sign-in"></i> Transfers to receive</a>
102
                    </li>
105
                    </li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/transferstosend.tt (-1 / +115 lines)
Line 0 Link Here
0
- 
1
[% USE raw %]
2
[% USE Asset %]
3
[% USE Koha %]
4
[% USE KohaDates %]
5
[% USE Branches %]
6
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
<title>Koha &rsaquo; Circulation &rsaquo; Transfers to send</title>
9
[% INCLUDE 'doc-head-close.inc' %]
10
</head>
11
12
<body id="circ_transferstosend" class="circ">
13
[% INCLUDE 'header.inc' %]
14
[% INCLUDE 'circ-search.inc' %]
15
16
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>  &rsaquo; Transfers to send</div>
17
18
<div class="main container-fluid">
19
    <div class="row">
20
        <div class="col-sm-12">
21
            <main>
22
                <div class="row">
23
24
                    [% IF Koha.Preference('CircSidebar') %]
25
                    <div class="col-sm-10 col-sm-push-2">
26
                    [% ELSE %]
27
                    <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
28
                    [% END %]
29
30
                        <h1>Transfers requested of your library as of [% show_date | $KohaDates %]</h1>
31
32
                        [% IF ( branchesloop ) %]
33
                        <p>Your library is the origin for the following transfer(s)</p>
34
                        <div id="resultlist">
35
                        [% FOREACH branchesloo IN branchesloop %]
36
                            [% IF ( branchesloo.branchcode ) %]
37
                            <table style="width: 100%" id="transferst[% branchesloo.branchcode | html %]">
38
                                <caption>Sending to [% branchesloo.branchname | html %]</caption>
39
                                <thead>
40
                                    <tr>
41
                                        <th class="title-string">Date of request</th>
42
                                        <th class="anti-the">Title</th>
43
                                        <th>Reason</th>
44
                                        <th>On loan</th>
45
                                        <th>Home library</th>
46
                                        <th>Call no.</th>
47
                                        <th>Actions</th>
48
                                    </tr>
49
                                </thead>
50
                                <tbody>
51
                                    [% FOREACH transfer IN branchesloo.inbound_transfers %]
52
                                    [% UNLESS transfer.datesent %]
53
                                    <tr>
54
                                        <td><p><span title="[% transfer.daterequested | html %]">[% transfer.daterequested | $KohaDates %]</span></p></td>
55
                                        <td>
56
                                            [% INCLUDE 'biblio-default-view.inc' biblionumber = transfer.item.biblionumber %][% INCLUDE 'biblio-title.inc' biblio = transfer.item.biblio %]</a> [% IF ( transfer.item.biblio.author ) %]by [% transfer.item.biblio.author | html %][% END %]
57
                                            [% IF ( transfer.item.effective_itemtype ) %] (<b>[% transfer.item.effective_itemtype | html %]</b>)[% END %]
58
                                            <br />Barcode: [% transfer.item.barcode | html %]
59
                                        </td>
60
                                        <td><p>[% transfer.reason | html %]</p></td>
61
                                        <td>[% IF transfer.item.onloan %]Due [% transfer.item.onloan | $KohaDates %][% ELSE %]On shelf[% END %]</td>
62
                                        <td>[% Branches.GetName( transfer.item.homebranch ) | html %]</td>
63
                                        <td>[% transfer.item.itemcallnumber | html %]</td>
64
                                        <td class="actions">
65
                                            [% IF transfer.reason == 'StockrotationAdvance' %]
66
                                            <a href="/cgi-bin/koha/catalogue/stockrotation.pl?op=toggle_in_demand&stage_id=4&item_id=[% transfer.itemnumber | uri %]&biblionumber=[% transfer.item.biblionumber | uri %]" class="btn btn-default btn-xs"><i class="fa fa-fire"></i> Mark "In demand"</a>
67
                                            [% END %]
68
                                        </td>
69
                                    </tr>
70
                                    [% END %]
71
                                    [% END %]
72
                                </tbody>
73
                            </table>
74
                            [% END %]
75
                        [% END %]
76
                        </div>
77
                        [% ELSE %]
78
                        <p>No transfers to send</p>
79
                        [% END %]
80
81
                    </div> <!-- /.col-sm-10.col-sm-push-2 OR /.col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2-->
82
83
                    [% IF Koha.Preference('CircSidebar') %]
84
                    <div class="col-sm-2 col-sm-pull-10">
85
                        <aside>
86
                            [% INCLUDE 'circ-nav.inc' %]
87
                        </aside>
88
                    </div> <!-- /.col-sm-2.col-sm-pull-10 -->
89
                    [% END %]
90
91
                </div> <!-- /.row -->
92
            </main>
93
        </div> <!-- /.col-sm-12 -->
94
    </div> <!-- /.row -->
95
96
[% MACRO jsinclude BLOCK %]
97
    [% INCLUDE 'datatables.inc' %]
98
    <script>
99
        $(document).ready(function() {
100
            [% FOREACH branchesloo IN branchesloop %]
101
            $("#transferst[% branchesloo.branchcode | html %]").dataTable($.extend(true, {}, dataTablesDefaults, {
102
                "aoColumnDefs": [
103
                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
104
                    { "sType": "anti-the", "aTargets" : [ "anti-the" ] },
105
                    { "sType": "title-string", "aTargets" : [ "title-string" ] }
106
                ],
107
                "sDom": 't',
108
                "bPaginate": false
109
            }));
110
            [% END %]
111
        });
112
    </script>
113
[% END %]
114
115
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 22569