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

(-)a/Koha/Virtualshelfshare.pm (-1 / +21 lines)
Lines 23-28 use DateTime::Duration; Link Here
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::DateUtils qw( dt_from_string );
24
use Koha::DateUtils qw( dt_from_string );
25
use Koha::Exceptions;
25
use Koha::Exceptions;
26
use Koha::Patron;
26
27
27
use base qw(Koha::Object);
28
use base qw(Koha::Object);
28
29
Lines 38-44 Koha::Virtualshelfshare - Koha Virtualshelfshare Object class Link Here
38
39
39
=cut
40
=cut
40
41
41
=head3 type
42
=head3 accept
42
43
43
=cut
44
=cut
44
45
Lines 66-71 sub accept { Link Here
66
    }
67
    }
67
}
68
}
68
69
70
=head3 has_expired
71
72
=cut
73
69
sub has_expired {
74
sub has_expired {
70
    my ($self) = @_;
75
    my ($self) = @_;
71
    my $dt_sharedate     = dt_from_string( $self->sharedate, 'sql' );
76
    my $dt_sharedate     = dt_from_string( $self->sharedate, 'sql' );
Lines 76-81 sub has_expired { Link Here
76
    return $has_expired == 1 ? 1 : 0
81
    return $has_expired == 1 ? 1 : 0
77
}
82
}
78
83
84
=head3 patron
85
86
    Returns related Koha::Patron object for this share.
87
88
=cut
89
90
sub patron {
91
    my $self = shift;
92
    return Koha::Patron->_new_from_dbic( $self->{_result}->borrowernumber );
93
}
94
95
=head3 _type
96
97
=cut
98
79
sub _type {
99
sub _type {
80
    return 'Virtualshelfshare';
100
    return 'Virtualshelfshare';
81
}
101
}
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt (+31 lines)
Lines 182-189 Link Here
182
                            <span>You do not have permission to delete this list.</span>
182
                            <span>You do not have permission to delete this list.</span>
183
                        [% CASE 'unauthorized_on_add_biblio' %]
183
                        [% CASE 'unauthorized_on_add_biblio' %]
184
                            <span>You do not have permission to add a record to this list.</span>
184
                            <span>You do not have permission to add a record to this list.</span>
185
                        [% CASE 'unauthorized_transfer' %]
186
                            <span>You do not have permission to transfer ownership of this list.</span>
185
                        [% CASE 'no_biblio_removed' %]
187
                        [% CASE 'no_biblio_removed' %]
186
                            <span>No record was removed.</span>
188
                            <span>No record was removed.</span>
189
                        [% CASE 'new_owner_not_found' %]
190
                            <span>The new owner could not be found anymore.</span>
191
                        [% CASE 'new_owner_has_no_share' %]
192
                            <span>The new owner has no share for this list.</span>
193
187
                        [% CASE 'Koha::Exceptions::Virtualshelf::DuplicateObject' %]
194
                        [% CASE 'Koha::Exceptions::Virtualshelf::DuplicateObject' %]
188
                            <span>An error occurred when creating the list. The name [% shelfname | html %] already exists.</span>
195
                            <span>An error occurred when creating the list. The name [% shelfname | html %] already exists.</span>
189
                        [% CASE 'DBIx::Class::Exception' %]
196
                        [% CASE 'DBIx::Class::Exception' %]
Lines 635-640 Link Here
635
                            </fieldset>
642
                            </fieldset>
636
                        </form>
643
                        </form>
637
644
645
                    [% ELSIF op == 'transfer' %]
646
                        <h1>Transfer ownership of shared list '[% shelf.shelfname | html %]'</h1>
647
                        <br/>
648
                        <form action="/cgi-bin/koha/opac-shelves.pl" id="transferform" method="post">
649
                        <fieldset>
650
                            <input type="hidden" name="op" value="transfer" />
651
                            <input type="hidden" name="public" value="0" />
652
                            <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
653
                            <div>
654
                                <label for="find_patron">New owner: </label>
655
                                <select name="new_owner" id="new_owner">
656
                                [% FOREACH sharee IN shared_users %]
657
                                    <option value="[% sharee.borrowernumber | html %]" selected="">[% sharee.email | html %]</option>
658
                                [% END %]
659
                                </select>
660
                            </div>
661
                            <br/>
662
                            <fieldset class="action">
663
                                <input type="submit" value="Transfer" class="submit" />
664
                                <a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;public=0" class="cancel">Cancel</a>
665
                            </fieldset>
666
                        </fieldset>
667
                        </form>
668
638
                    [% ELSIF op == 'list' %]
669
                    [% ELSIF op == 'list' %]
639
                        <h1>Lists</h1>
670
                        <h1>Lists</h1>
640
                        <div class="toptabs ui-tabs ui-widget ui-widget-content ui-corner-all">
671
                        <div class="toptabs ui-tabs ui-widget ui-widget-content ui-corner-all">
(-)a/opac/opac-shelves.pl (-2 / +31 lines)
Lines 38-46 use Koha::Biblios; Link Here
38
use Koha::Biblioitems;
38
use Koha::Biblioitems;
39
use Koha::CirculationRules;
39
use Koha::CirculationRules;
40
use Koha::CsvProfiles;
40
use Koha::CsvProfiles;
41
use Koha::DateUtils qw/dt_from_string/;
41
use Koha::Items;
42
use Koha::Items;
42
use Koha::ItemTypes;
43
use Koha::ItemTypes;
43
use Koha::Patrons;
44
use Koha::Patrons;
45
use Koha::Virtualshelfshares;
44
use Koha::Virtualshelves;
46
use Koha::Virtualshelves;
45
use Koha::RecordProcessor;
47
use Koha::RecordProcessor;
46
48
Lines 257-263 if ( $op eq 'add_form' ) { Link Here
257
    }
259
    }
258
    $op = 'view';
260
    $op = 'view';
259
} elsif( $op eq 'transfer' ) {
261
} elsif( $op eq 'transfer' ) {
260
    $op = 'list'; # TODO
262
    $shelfnumber = $query->param('shelfnumber');
263
    $shelf = Koha::Virtualshelves->find($shelfnumber) if $shelfnumber;
264
    my $new_owner = $query->param('new_owner'); # borrowernumber or undef
265
266
    $op = 'list';
267
    if( !$shelf ) {
268
        push @messages, { type => 'error', code => 'does_not_exist' };
269
    } elsif( $shelf->public or !$shelf->is_shared or !$shelf->can_be_managed($loggedinuser) ) {
270
        push @messages, { type => 'error', code => 'unauthorized_transfer' };
271
    } elsif( !$new_owner ) {
272
        my $patrons = [];
273
        my $shares = $shelf->get_shares->search({ borrowernumber => { '!=' => undef } });
274
        while( my $share = $shares->next ) {
275
            push @$patrons, { email => $share->patron->notice_email_address, borrowernumber => $share->get_column('borrowernumber') };
276
        }
277
        $template->param( shared_users => $patrons );
278
        $op = 'transfer';
279
    } elsif( !Koha::Patrons->find($new_owner) ) {
280
        push @messages, { type => 'error', code => 'new_owner_not_found' };
281
    } elsif( !$shelf->get_shares->search({ borrowernumber => $new_owner })->count ) {
282
        push @messages, { type => 'error', code => 'new_owner_has_no_share' };
283
    } else {
284
        # Remove from virtualshelfshares new_owner, add loggedinuser
285
        $shelf->_result->result_source->schema->txn_do( sub {
286
            $shelf->get_shares->search({ borrowernumber => $new_owner })->delete;
287
            Koha::Virtualshelfshare->new({ shelfnumber => $shelfnumber, borrowernumber => $loggedinuser, sharedate => dt_from_string })->store;
288
            $shelf->owner($new_owner)->store;
289
        });
290
    }
261
}
291
}
262
292
263
# PART 2: After a possible action, view one list or show a number of lists
293
# PART 2: After a possible action, view one list or show a number of lists
264
- 

Return to bug 25498