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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-1 / +71 lines)
Lines 114-119 Link Here
114
                </a>
114
                </a>
115
            </li>
115
            </li>
116
        [% END %]
116
        [% END %]
117
118
        [% IF op == 'transfer' %]
119
            <li><a href="#" aria-current="page">Transfer list <em>[% shelf.shelfname | html %]</em></a></li>
120
        [% END %]
117
    </ol>
121
    </ol>
118
</nav>
122
</nav>
119
123
Lines 122-128 Link Here
122
            <div class="col-sm-10 col-sm-push-1">
126
            <div class="col-sm-10 col-sm-push-1">
123
                <main>
127
                <main>
124
128
125
                [% INCLUDE 'virtualshelves-toolbar.inc' %]
129
                [% IF op != 'transfer' %][% INCLUDE 'virtualshelves-toolbar.inc' %][% END %]
126
130
127
[% FOR m IN messages %]
131
[% FOR m IN messages %]
128
    <div class="dialog [% m.type | html %]">
132
    <div class="dialog [% m.type | html %]">
Lines 169-188 Link Here
169
           <span>You do not have permission to delete this list.</span>
173
           <span>You do not have permission to delete this list.</span>
170
        [% CASE 'unauthorized_on_add_biblio' %]
174
        [% CASE 'unauthorized_on_add_biblio' %]
171
            <span>You do not have permission to add a record to this list.</span>
175
            <span>You do not have permission to add a record to this list.</span>
176
        [% CASE 'unauthorized_transfer' %]
177
            <span>You do not have permission to transfer ownership of this list.</span>
178
        [% CASE 'new_owner_not_found' %]
179
            <span>The new owner could not be found anymore.</span>
172
        [% CASE 'no_biblio_removed' %]
180
        [% CASE 'no_biblio_removed' %]
173
            <span>No record was removed.</span>
181
            <span>No record was removed.</span>
182
174
        [% CASE 'Koha::Exceptions::Virtualshelf::DuplicateObject' %]
183
        [% CASE 'Koha::Exceptions::Virtualshelf::DuplicateObject' %]
175
            <span>An error occurred when creating this list. The name [% shelfname | html %] already exists.</span>
184
            <span>An error occurred when creating this list. The name [% shelfname | html %] already exists.</span>
176
        [% CASE 'Koha::Exceptions::Virtualshelf::UseDbAdminAccount' %]
185
        [% CASE 'Koha::Exceptions::Virtualshelf::UseDbAdminAccount' %]
177
            <span>List could not be created. (Do not use the database administrator account.)</span>
186
            <span>List could not be created. (Do not use the database administrator account.)</span>
178
        [% CASE 'DBIx::Class::Exception' %]
187
        [% CASE 'DBIx::Class::Exception' %]
179
            [% m.msg | html %]
188
            [% m.msg | html %]
189
180
        [% CASE %]
190
        [% CASE %]
181
            [% m.code | html %] [% m.msg | html %]
191
            [% m.code | html %] [% m.msg | html %]
182
        [% END %]
192
        [% END %]
183
    </div>
193
    </div>
184
[% END %]
194
[% END %]
185
195
196
[% IF op == 'transfer' %]
197
    <h1>Transfer ownership of public list [% shelf.shelfname | html %]</h1>
198
199
    <form action="/cgi-bin/koha/virtualshelves/shelves.pl" id="transferform" method="post">
200
    <fieldset>
201
        <input type="hidden" name="op" value="transfer" />
202
        <input type="hidden" name="public" value="1" />
203
        <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
204
205
        <div>
206
            <label for="find_patron">Search for new owner: </label>
207
            <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
208
        </div>
209
210
        <br/>
211
        <div>
212
            <label for="find_patron">New owner: </label>
213
            <span id="new_owner_name"></span>
214
            <input type="hidden" id="new_owner" name="new_owner" value="" />
215
        </div>
216
217
        <br/>
218
        <fieldset class="action">
219
            <input type="submit" value="Transfer" class="submit" />
220
            <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&amp;public=1" class="cancel">Cancel</a>
221
        </fieldset>
222
223
    </fieldset>
224
    </form>
225
[% END %]
226
186
[% IF op == 'view' %]
227
[% IF op == 'view' %]
187
    <h1>Contents of <em>[% shelf.shelfname | html %]</em></h1>
228
    <h1>Contents of <em>[% shelf.shelfname | html %]</em></h1>
188
    [% IF itemsloop %]
229
    [% IF itemsloop %]
Lines 848-853 Link Here
848
             });
889
             });
849
890
850
        [% END %]
891
        [% END %]
892
893
        [% IF op == 'transfer' %]
894
            $(document).ready(function() {
895
                $('#find_patron').autocomplete({
896
                    source: "/cgi-bin/koha/circ/ysearch.pl",
897
                    minLength: 3,
898
                    select: function( event, ui ) {
899
                        $('#new_owner_name').html( ui.item.firstname + " " + ui.item.surname );
900
                        $('#new_owner').val( ui.item.borrowernumber );
901
                        $('#find_patron').val('').focus();
902
                        return false;
903
                    },
904
                }).data('ui-autocomplete')._renderItem = function( ul, item ) {
905
                    return $('<li></li>')
906
                        .data( 'ui-autocomplete-item', item )
907
                        .append( '<a>' + item.surname + ', ' + item.firstname + '</a>' )
908
                        .appendTo(ul);
909
                };
910
911
                $('#transferform').submit(function() {
912
                    if( $('#new_owner').val() == '' ) {
913
                        alert( _("Please select a new owner first") );
914
                        return false;
915
                    }
916
                    return true;
917
                });
918
             });
919
        [% END %]
920
851
    </script>
921
    </script>
852
[% END %]
922
[% END %]
853
923
(-)a/virtualshelves/shelves.pl (-1 / +19 lines)
Lines 235-240 if ( $op eq 'add_form' ) { Link Here
235
        push @messages, { type => 'alert', code => 'does_not_exist' };
235
        push @messages, { type => 'alert', code => 'does_not_exist' };
236
    }
236
    }
237
    $op = $referer;
237
    $op = $referer;
238
} elsif ( $op eq 'transfer' ) {
239
    $shelfnumber = $query->param('shelfnumber');
240
    $shelf = Koha::Virtualshelves->find($shelfnumber) if $shelfnumber;
241
    my $new_owner = $query->param('new_owner'); # is a borrowernumber
242
243
    if( $new_owner ) {
244
        $op = 'list';
245
        # First check: shelf found, permission, patron found?
246
        if( !$shelf ) {
247
            push @messages, { type => 'alert', code => 'does_not_exist' };
248
        } elsif( !haspermission(C4::Context->userenv->{id}, { lists => 'edit_public_lists' }) ) {
249
            push @messages, { type => 'alert', code => 'unauthorized_transfer' };
250
        } elsif( !Koha::Patrons->find($new_owner) ) {
251
            push @messages, { type => 'alert', code => 'new_owner_not_found' };
252
            $op = 'transfer'; # find again..
253
        } else { # success
254
            $shelf->owner($new_owner)->store;
255
        }
256
    }
238
}
257
}
239
258
240
if ( $op eq 'view' ) {
259
if ( $op eq 'view' ) {
241
- 

Return to bug 25498