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

(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-15 / +31 lines)
Lines 101-111 $(document).ready(function() { Link Here
101
                    {
101
                    {
102
                        "mDataProp": function( oObj ) {
102
                        "mDataProp": function( oObj ) {
103
                            if( oObj.branches.length > 1 && oObj.found !== 'W' && oObj.found !== 'T' ){
103
                            if( oObj.branches.length > 1 && oObj.found !== 'W' && oObj.found !== 'T' ){
104
                                var branchSelect='<select class="hold_location_select" reserve_id="'+oObj.reserve_id+'" name="pick-location">';
104
                                var branchSelect='<select priority='+oObj.priority+' class="hold_location_select" reserve_id="'+oObj.reserve_id+'" name="pick-location">';
105
                                for ( var i=0; i < oObj.branches.length; i++ ){
105
                                for ( var i=0; i < oObj.branches.length; i++ ){
106
                                    var selectedbranch;
106
                                    var selectedbranch;
107
                                    if( oObj.branches[i].selected ){selectedbranch=" selected='selected' "}else{selectedbranch=''}
107
                                    var setbranch;
108
                                    branchSelect += '<option value="'+ oObj.branches[i].value +'"'+selectedbranch+'>'+oObj.branches[i].branchname+'</option>';
108
                                    if( oObj.branches[i].selected ){
109
                                        selectedbranch = " selected='selected' ";
110
                                        setbranch = " (set) ";
111
                                    }
112
                                    else{
113
                                        selectedbranch = '';
114
                                        setbranch = '';
115
                                    }
116
                                    branchSelect += '<option value="'+ oObj.branches[i].value +'"'+selectedbranch+'>'+oObj.branches[i].branchname+setbranch+'</option>';
109
                                }
117
                                }
110
                                branchSelect +='</select>';
118
                                branchSelect +='</select>';
111
                                return branchSelect;
119
                                return branchSelect;
Lines 189-205 $(document).ready(function() { Link Here
189
197
190
                $(".hold_location_select").change(function(){
198
                $(".hold_location_select").change(function(){
191
                    if( confirm( _("Do you want to change the pickup location?") ) ){
199
                    if( confirm( _("Do you want to change the pickup location?") ) ){
192
                        $.post('/cgi-bin/koha/svc/hold/update_location', { "reserve_id": $(this).attr('reserve_id'), "updated_branch": $(this).val() }, function( data ){
200
                        $(this).prop("disabled",true);
193
                            if ( data.success ) {
201
                        var cur_select = $(this);
194
                                holdsTable.api().ajax.reload();
202
                        $(this).after('<i id="holdwaiter" class="fa fa-circle-o-notch fa-spin fa-lg fa-fw"></i>');
195
                            }
203
                        var api_url = '/api/v1/holds/'+$(this).attr('reserve_id');
196
                        else {
204
                        var update_info = JSON.stringify({ branchcode: $(this).val(), priority: parseInt($(this).attr("priority"),10) });
197
                            if ( data.error == "HOLD_NOT_FOUND" ) {
205
                        $.ajax({
198
                                alert ( RESUME_HOLD_ERROR_NOT_FOUND );
206
                            method: "PUT",
199
                                holdsTable.api().ajax.reload();
207
                            url: api_url,
200
                            }
208
                            data: update_info ,
201
                        }
209
                            success: function( data ){ holdsTable.api().ajax.reload(); },
202
                      });
210
                            error: function( jqXHR, textStatus, errorThrown) {
211
                                alert('There was an error:'+textStatus+" "+errorThrown);
212
                                cur_select.prop("disabled",false);
213
                                $("#holdwaiter").remove();
214
                                cur_select.val( cur_select.children('option[selected="selected"]').val() );
215
                            },
216
                        });
217
                    }
218
                    else{
219
                        $(this).val( $(this).children('option[selected="selected"]').val()  );
203
                    }
220
                    }
204
                });
221
                });
205
222
206
- 

Return to bug 8030