Bug 24819: (follow-up) Rename suggestion_search to suggestor_search
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / js / holds.js
index e3b68c1..41d4762 100644 (file)
@@ -10,28 +10,34 @@ $(document).ready(function() {
     function load_holds_table() {
         var holds = new Array();
         if ( ! holdsTable ) {
-            holdsTable = $("#holds-table").dataTable({
+            holdsTable = $("#holds-table").dataTable($.extend(true, {}, dataTablesDefaults, {
                 "bAutoWidth": false,
                 "sDom": "rt",
                 "columns": [
                     {
-                        "mDataProp": "reservedate_formatted"
+                        "data": { _: "reservedate_formatted", "sort": "reservedate" }
                     },
                     {
                         "mDataProp": function ( oObj ) {
                             title = "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber="
                                   + oObj.biblionumber
                                   + "'>"
-                                  + oObj.title;
+                                  + oObj.title.escapeHtml();
 
                             $.each(oObj.subtitle, function( index, value ) {
-                                      title += " " + value.subfield;
+                                      title += " " + value.escapeHtml();
                             });
 
+                            title += " " + oObj.part_number + " " + oObj.part_name;
+
+                            if ( oObj.enumchron ) {
+                                title += " (" + oObj.enumchron.escapeHtml() + ")";
+                            }
+
                             title += "</a>";
 
                             if ( oObj.author ) {
-                                title += " " + BY.replace( "_AUTHOR_",  oObj.author );
+                                title += " " + BY.replace( "_AUTHOR_",  oObj.author.escapeHtml() );
                             }
 
                             if ( oObj.itemnotes ) {
@@ -39,7 +45,7 @@ $(document).ready(function() {
                                 if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
                                     span_class = "circ-hlt";
                                 }
-                                title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>"
+                                title += " - <span class='" + span_class + "'>" + oObj.itemnotes.escapeHtml() + "</span>"
                             }
 
                             return title;
@@ -47,54 +53,23 @@ $(document).ready(function() {
                     },
                     {
                         "mDataProp": function( oObj ) {
-                            return oObj.itemcallnumber || "";
+                            return oObj.itemcallnumber && oObj.itemcallnumber.escapeHtml() || "";
                         }
                     },
                     {
                         "mDataProp": function( oObj ) {
                             var data = "";
-
-                            if ( oObj.suspend == 1 ) {
-                                data += "<p>" + HOLD_IS_SUSPENDED;
-                                if ( oObj.suspend_until ) {
-                                    data += " " + UNTIL.format( oObj.suspend_until_formatted );
-                                }
-                                data += "</p>";
-                            }
-
-                            if ( oObj.itemtype_limit ) {
-                                data += NEXT_AVAILABLE_ITYPE.format( oObj.itemtype_limit );
-                            }
-
                             if ( oObj.barcode ) {
-                                data += "<em>";
-                                if ( oObj.found == "W" ) {
-
-                                    if ( oObj.waiting_here ) {
-                                        data += ITEM_IS_WAITING_HERE;
-                                    } else {
-                                        data += ITEM_IS_WAITING;
-                                        data += " " + AT.format( oObj.waiting_at );
-                                    }
-
-                                } else if ( oObj.transferred ) {
-                                    data += ITEM_IS_IN_TRANSIT.format( oObj.from_branch, oObj.date_sent );
-                                } else if ( oObj.not_transferred ) {
-                                    data += NOT_TRANSFERRED_YET.format( oObj.not_transferred_by );
-                                }
-                                data += "</em>";
-
-                                data += " <a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
+                                data += " <a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="
                                   + oObj.biblionumber
                                   + "&itemnumber="
                                   + oObj.itemnumber
-                                  + "#"
+                                  + "#item"
                                   + oObj.itemnumber
                                   + "'>"
-                                  + oObj.barcode
+                                  + oObj.barcode.escapeHtml()
                                   + "</a>";
                             }
-
                             return data;
                         }
                     },
@@ -109,20 +84,21 @@ $(document).ready(function() {
 
                                         selectedbranch = " selected='selected' ";
                                         setbranch = CURRENT;
-                                    }
-                                    else{
+                                    } else if ( oObj.branches[i].pickup_location == 0 ) {
+                                        continue;
+                                    } else{
                                         selectedbranch = '';
                                         setbranch = '';
                                     }
-                                    branchSelect += '<option value="'+ oObj.branches[i].branchcode +'"'+selectedbranch+'>'+oObj.branches[i].branchname+setbranch+'</option>';
+                                    branchSelect += '<option value="'+ oObj.branches[i].branchcode.escapeHtml() +'"'+selectedbranch+'>'+oObj.branches[i].branchname.escapeHtml()+setbranch+'</option>';
                                 }
                                 branchSelect +='</select>';
                                 return branchSelect;
                             }
-                            else { return oObj.branchcode || ""; }
+                            else { return oObj.branchcode.escapeHtml() || ""; }
                         }
                     },
-                    { "mDataProp": "expirationdate_formatted" },
+                    { "data": { _: "expirationdate_formatted", "sort": "expirationdate" } },
                     {
                         "mDataProp": function( oObj ) {
                             if ( oObj.priority && parseInt( oObj.priority ) && parseInt( oObj.priority ) > 0 ) {
@@ -146,6 +122,7 @@ $(document).ready(function() {
                     },
                     {
                         "bSortable": false,
+                        "visible": SuspendHoldsIntranet,
                         "mDataProp": function( oObj ) {
                             holds[oObj.reserve_id] = oObj; //Store holds for later use
 
@@ -159,7 +136,44 @@ $(document).ready(function() {
                                      + "<i class='fa fa-pause'></i> " + SUSPEND + "</a>";
                             }
                         }
-                    }
+                    },
+                    {
+                        "mDataProp": function( oObj ) {
+                            var data = "";
+
+                            if ( oObj.suspend == 1 ) {
+                                data += "<p>" + HOLD_IS_SUSPENDED;
+                                if ( oObj.suspend_until ) {
+                                    data += " " + UNTIL.format( oObj.suspend_until_formatted );
+                                }
+                                data += "</p>";
+                            }
+
+                            if ( oObj.itemtype_limit ) {
+                                data += NEXT_AVAILABLE_ITYPE.format( oObj.itemtype_limit );
+                            }
+
+                            if ( oObj.barcode ) {
+                                data += "<em>";
+                                if ( oObj.found == "W" ) {
+
+                                    if ( oObj.waiting_here ) {
+                                        data += ITEM_IS_WAITING_HERE;
+                                    } else {
+                                        data += ITEM_IS_WAITING;
+                                        data += " " + AT.format( oObj.waiting_at );
+                                    }
+
+                                } else if ( oObj.transferred ) {
+                                    data += ITEM_IS_IN_TRANSIT.format( oObj.from_branch, oObj.date_sent );
+                                } else if ( oObj.not_transferred ) {
+                                    data += NOT_TRANSFERRED_YET.format( oObj.not_transferred_by );
+                                }
+                                data += "</em>";
+                            }
+                            return data;
+                        }
+                   }
                 ],
                 "bPaginate": false,
                 "bProcessing": true,
@@ -170,7 +184,7 @@ $(document).ready(function() {
                         d.borrowernumber = borrowernumber;
                     }
                 },
-            });
+            }));
 
             $('#holds-table').on( 'draw.dt', function () {
                 $(".hold-suspend").on( "click", function() {
@@ -202,7 +216,7 @@ $(document).ready(function() {
                     var res_id = $(this).attr('reserve_id');
                     $(this).after('<div id="updating_reserveno'+res_id+'" class="waiting"><img src="/intranet-tmpl/prog/img/spinner-small.gif" alt="" /><span class="waiting_msg"></span></div>');
                     var api_url = '/api/v1/holds/'+res_id;
-                    var update_info = JSON.stringify({ branchcode: $(this).val(), priority: parseInt($(this).attr("priority"),10) });
+                    var update_info = JSON.stringify({ pickup_library_id: $(this).val(), priority: parseInt($(this).attr("priority"),10) });
                     $.ajax({
                         method: "PUT",
                         url: api_url,
@@ -229,7 +243,7 @@ $(document).ready(function() {
     }
 
     $("body").append("\
-        <div id='suspend-modal' class='modal fade' tabindex='-1' role='dialog' aria-hidden='true'>\
+        <div id='suspend-modal' class='modal fade' role='dialog' aria-hidden='true'>\
             <div class='modal-dialog'>\
             <div class='modal-content'>\
             <form id='suspend-modal-form' class='form-inline'>\